Project

General

Profile

Download (143 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 *
3
 */
4
package eu.etaxonomy.taxeditor.ui.element;
5

    
6
import java.net.URI;
7
import java.util.ArrayList;
8
import java.util.Comparator;
9
import java.util.HashSet;
10
import java.util.List;
11
import java.util.Map;
12
import java.util.Set;
13

    
14
import javax.inject.Inject;
15

    
16
import org.eclipse.e4.core.contexts.IEclipseContext;
17
import org.eclipse.jface.util.IPropertyChangeListener;
18
import org.eclipse.jface.viewers.ISelection;
19
import org.eclipse.jface.viewers.ISelectionProvider;
20
import org.eclipse.jface.window.Window;
21
//import org.eclipse.nebula.widgets.richtext.RichTextEditor;
22
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.custom.StyledText;
24
import org.eclipse.swt.events.FocusAdapter;
25
import org.eclipse.swt.events.FocusEvent;
26
import org.eclipse.swt.events.FocusListener;
27
import org.eclipse.swt.events.MouseAdapter;
28
import org.eclipse.swt.events.MouseEvent;
29
import org.eclipse.swt.events.MouseListener;
30
import org.eclipse.swt.events.SelectionEvent;
31
import org.eclipse.swt.events.SelectionListener;
32
import org.eclipse.swt.events.TypedEvent;
33
import org.eclipse.swt.graphics.Color;
34
import org.eclipse.swt.graphics.Font;
35
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.swt.widgets.Control;
37
import org.eclipse.swt.widgets.Display;
38
import org.eclipse.swt.widgets.Event;
39
import org.eclipse.swt.widgets.Label;
40
import org.eclipse.ui.forms.IFormColors;
41
import org.eclipse.ui.forms.widgets.ExpandableComposite;
42
import org.eclipse.ui.forms.widgets.FormToolkit;
43
import org.eclipse.ui.forms.widgets.Section;
44
import org.eclipse.ui.forms.widgets.TableWrapData;
45
import org.eclipse.ui.internal.forms.widgets.FormFonts;
46
import org.joda.time.DateTime;
47
import org.joda.time.Partial;
48
import org.springframework.security.core.GrantedAuthority;
49

    
50
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
51
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
52
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
53
import eu.etaxonomy.cdm.model.agent.Person;
54
import eu.etaxonomy.cdm.model.agent.Team;
55
import eu.etaxonomy.cdm.model.common.Annotation;
56
import eu.etaxonomy.cdm.model.common.CdmBase;
57
import eu.etaxonomy.cdm.model.common.Credit;
58
import eu.etaxonomy.cdm.model.common.DefinedTerm;
59
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
60
import eu.etaxonomy.cdm.model.common.Extension;
61
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
62
import eu.etaxonomy.cdm.model.common.Group;
63
import eu.etaxonomy.cdm.model.common.ICdmBase;
64
import eu.etaxonomy.cdm.model.common.IEnumTerm;
65
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
66
import eu.etaxonomy.cdm.model.common.Identifier;
67
import eu.etaxonomy.cdm.model.common.LSID;
68
import eu.etaxonomy.cdm.model.common.Language;
69
import eu.etaxonomy.cdm.model.common.LanguageString;
70
import eu.etaxonomy.cdm.model.common.Marker;
71
import eu.etaxonomy.cdm.model.common.Representation;
72
import eu.etaxonomy.cdm.model.common.TermBase;
73
import eu.etaxonomy.cdm.model.common.TermType;
74
import eu.etaxonomy.cdm.model.common.TermVocabulary;
75
import eu.etaxonomy.cdm.model.common.TimePeriod;
76
import eu.etaxonomy.cdm.model.common.User;
77
import eu.etaxonomy.cdm.model.common.VersionableEntity;
78
import eu.etaxonomy.cdm.model.description.CategoricalData;
79
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
80
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
81
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
82
import eu.etaxonomy.cdm.model.description.Distribution;
83
import eu.etaxonomy.cdm.model.description.Feature;
84
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
85
import eu.etaxonomy.cdm.model.description.KeyStatement;
86
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
87
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
88
import eu.etaxonomy.cdm.model.description.QuantitativeData;
89
import eu.etaxonomy.cdm.model.description.State;
90
import eu.etaxonomy.cdm.model.description.StateData;
91
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
92
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
93
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
94
import eu.etaxonomy.cdm.model.description.TextData;
95
import eu.etaxonomy.cdm.model.location.NamedArea;
96
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
97
import eu.etaxonomy.cdm.model.location.Point;
98
import eu.etaxonomy.cdm.model.media.ImageFile;
99
import eu.etaxonomy.cdm.model.media.Media;
100
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
101
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
102
import eu.etaxonomy.cdm.model.media.Rights;
103
import eu.etaxonomy.cdm.model.molecular.DnaSample;
104
import eu.etaxonomy.cdm.model.name.NameRelationship;
105
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
106
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
107
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
108
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
109
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
110
import eu.etaxonomy.cdm.model.reference.Reference;
111
import eu.etaxonomy.cdm.model.taxon.Taxon;
112
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
113
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
114
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
115
import eu.etaxonomy.taxeditor.model.MessagingUtils;
116
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
117
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
118
import eu.etaxonomy.taxeditor.ui.combo.VocabularyComboElement;
119
import eu.etaxonomy.taxeditor.ui.dialog.CloneClassificationDetailElement;
120
import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection.UnitType;
121
import eu.etaxonomy.taxeditor.ui.mvc.element.DateElement;
122
import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
123
import eu.etaxonomy.taxeditor.ui.openurl.OpenUrlSelectorElement;
124
import eu.etaxonomy.taxeditor.ui.password.EditPasswordElement;
125
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
126
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
127
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
128
import eu.etaxonomy.taxeditor.ui.section.EmptyElement;
129
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement;
130
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection;
131
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailElement;
132
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
133
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailElement;
134
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
135
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
136
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberSection;
137
import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
138
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailElement;
139
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailSection;
140
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeAgentRelationCollectionElement;
141
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeAgentRelationCollectionSection;
142
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailElement;
143
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailSection;
144
import eu.etaxonomy.taxeditor.ui.section.common.ReferenceEntityDetailElement;
145
import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
146
import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
147
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
148
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailElement;
149
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
150
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
151
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
152
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
153
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceElement;
154
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
155
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceElement;
156
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
157
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
158
import eu.etaxonomy.taxeditor.ui.section.description.ModifierElement;
159
import eu.etaxonomy.taxeditor.ui.section.description.ModifierSection;
160
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageDetailElement;
161
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
162
import eu.etaxonomy.taxeditor.ui.section.description.ScopeElement;
163
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
164
import eu.etaxonomy.taxeditor.ui.section.description.StateDataElement;
165
import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;
166
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueElement;
167
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueSection;
168
import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;
169
import eu.etaxonomy.taxeditor.ui.section.description.detail.CategoricalDataDetailElement;
170
import eu.etaxonomy.taxeditor.ui.section.description.detail.CommonNameDetailElement;
171
import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
172
import eu.etaxonomy.taxeditor.ui.section.description.detail.IndividualsAssociationDetailElement;
173
import eu.etaxonomy.taxeditor.ui.section.description.detail.QuantitativeDataDetailElement;
174
import eu.etaxonomy.taxeditor.ui.section.description.detail.TaxonInteractionDetailElement;
175
import eu.etaxonomy.taxeditor.ui.section.description.detail.TextDataDetailElement;
176
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement;
177
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
178
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityCollectionElement;
179
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailElement;
180
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
181
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailElement;
182
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
183
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailElement;
184
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
185
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailElement;
186
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
187
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailElement;
188
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
189
import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
190
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
191
import eu.etaxonomy.taxeditor.ui.section.media.ImageFileElement;
192
import eu.etaxonomy.taxeditor.ui.section.media.MediaDetailElement;
193
import eu.etaxonomy.taxeditor.ui.section.media.MediaMetaElement;
194
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationElement;
195
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartElement;
196
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartSection;
197
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationSection;
198
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
199
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
200
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailSection;
201
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailElement;
202
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailSection;
203
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailElement;
204
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailSection;
205
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailElement;
206
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
207
import eu.etaxonomy.taxeditor.ui.section.name.NameTypeDesignationElement;
208
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusElement;
209
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
210
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailElement;
211
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
212
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueElement;
213
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
214
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
215
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
216
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
217
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
218
import eu.etaxonomy.taxeditor.ui.section.occurrence.CurrentDeterminationDetailSection;
219
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailElement;
220
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
221
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailElement;
222
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
223
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement;
224
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
225
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement;
226
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection;
227
import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
228
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailElement;
229
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailSection;
230
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailElement;
231
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSection;
232
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailElement;
233
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
234
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopeDetailSection;
235
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopePolyKeyDetailSection;
236
import eu.etaxonomy.taxeditor.ui.section.occurrence.NamedAreaDetailElement;
237
import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
238
import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
239
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElement;
240
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailSection;
241
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenHierarchyDetailElement;
242
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenHierarchyDetailSection;
243
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationElement;
244
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationSection;
245
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailElement;
246
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
247
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenCurrentDeterminationDetailSection;
248
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailElement;
249
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailSection;
250
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailElement;
251
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailSection;
252
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenSourceCollectionDetailSection;
253
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractSampleDesignationDetailSection;
254
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailElement;
255
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailSection;
256
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoCollectionDetailSection;
257
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoDetailElement;
258
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailElement;
259
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailSection;
260
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailElement;
261
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailSection;
262
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.CurrentSampleDesignationDetailSection;
263
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailElement;
264
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
265
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailElement;
266
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
267
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationDetailElement;
268
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationSection;
269
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.PrimerGeneralDetailElement;
270
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailElement;
271
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailSection;
272
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationHistoryDetailSection;
273
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationTextDetailElement;
274
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceContigFileCollectionDetailSection;
275
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailElement;
276
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
277
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailElement;
278
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
279
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailElement;
280
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
281
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadPherogramCollectionDetailSection;
282
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailElement;
283
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
284
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailElement;
285
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
286
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
287
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
288
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement;
289
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
290
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationElement;
291
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
292
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseElement;
293
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
294
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditElement;
295
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
296
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionElement;
297
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
298
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
299
import eu.etaxonomy.taxeditor.ui.section.supplemental.IdentifiableSourceElement;
300
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerElement;
301
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
302
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsElement;
303
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
304
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
305
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement;
306
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
307
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.DerivedUnitFacadeIdentifierSection;
308
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierElement;
309
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierSection;
310
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement;
311
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
312
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailElement;
313
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
314
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailElement;
315
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailSection;
316
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonOfRelationshipElement;
317
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailElement;
318
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
319
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailElement;
320
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
321
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailElement;
322
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
323
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailElement;
324
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
325
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement;
326
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailSection;
327
import eu.etaxonomy.taxeditor.ui.section.vocabulary.FeatureDetailElement;
328
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionElement;
329
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionSection;
330
import eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailSection;
331
import eu.etaxonomy.taxeditor.ui.section.vocabulary.PresenceAbsenceTermDetailElement;
332
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesCollectionSection;
333
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesElement;
334
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionElement;
335
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionSection;
336
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionElement;
337
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionSection;
338
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailElement;
339
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
340
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
341
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementWithAbbreviatedTitle;
342
import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
343
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
344

    
345
/**
346
 * <p>
347
 * CdmFormFactory class.
348
 * </p>
349
 *
350
 * @author n.hoffmann
351
 * @created Feb 24, 2010
352
 * @version 1.0
353
 */
354
public class CdmFormFactory extends FormToolkit {
355

    
356
    private BoldFontHolder2 boldFontHolder2;
357
    private MouseListener selectionMouseHandler;
358
    private FocusListener selectionFocusHandler;
359

    
360
    @Inject
361
    private IEclipseContext context;
362

    
363
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
364

    
365
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
366

    
367
    private final int orientation = Window.getDefaultOrientation();
368
    private ISelectionProvider selectionProvider;
369

    
370
    /** Constant <code>EMPTY_SELECTION</code> */
371
    public static ISelection EMPTY_SELECTION = new ISelection() {
372
        @Override
373
        public boolean isEmpty() {
374
            return true;
375
        }
376
    };
377

    
378
    /**
379
     *
380
     * @author n.hoffmann
381
     * @date Jan 25, 2010
382
     *
383
     */
384
    private class SelectionMouseHandler extends MouseAdapter {
385
        @Override
386
        public void mouseDown(MouseEvent e) {
387
            notifySelectionListeners(e);
388
        }
389
    }
390

    
391
    /**
392
     *
393
     * @author n.hoffmann
394
     * @date Jan 25, 2010
395
     *
396
     */
397
    private class SelectionFocusHandler extends FocusAdapter {
398
        @Override
399
        public void focusGained(FocusEvent e) {
400
            notifySelectionListeners(e);
401
        }
402
    }
403

    
404
    private void notifySelectionListeners(TypedEvent e) {
405
        Event event = new Event();
406
        event.widget = e.widget;
407
        SelectionEvent selectionEvent = new SelectionEvent(event);
408

    
409
        for (SelectionListener listener : selectionListenerList) {
410
            listener.widgetSelected(selectionEvent);
411
        }
412
    }
413

    
414
    public CdmFormFactory(Display display) {
415
        this(display, null);
416
    }
417

    
418
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
419
        super(display);
420
        this.selectionProvider = selectionProvider;
421
        init();
422
    }
423

    
424
    private void init() {
425
        boldFontHolder2 = new BoldFontHolder2();
426
        selectionMouseHandler = new SelectionMouseHandler();
427
        selectionFocusHandler = new SelectionFocusHandler();
428
    }
429

    
430
    public IEclipseContext getContext() {
431
        return context;
432
    }
433

    
434
    /**
435
     * Creates an instance initialized with the correct selectionProvider
436
     *
437
     * Make sure to remove the instance when the entityComposite disposes via
438
     * destroySelectionArbitrator(..)
439
     *
440
     * @param entityElement
441
     *            a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
442
     *            object.
443
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
444
     *         object.
445
     */
446
    public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
447
        SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
448
        selectionArbitrator.addSelectionProvider(selectionProvider);
449
        selectionProvider.addSelectionChangedListener(selectionArbitrator);
450
        addSelectionListener(selectionArbitrator);
451
        return selectionArbitrator;
452
    }
453

    
454
    /**
455
     * <p>
456
     * destroySelectionArbitrator
457
     * </p>
458
     *
459
     * @param selectionArbitrator
460
     *            a
461
     *            {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
462
     *            object.
463
     */
464
    public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
465
        removeSelectionListener(selectionArbitrator);
466
        if (selectionProvider != null) {
467
            selectionProvider.removeSelectionChangedListener(selectionArbitrator);
468
        } else {
469
            MessagingUtils.error(this.getClass(),
470
                    "Tried to destroy a selection listener from this factories listeners but was null", null);
471
        }
472
    }
473

    
474
    /**
475
     * <p>
476
     * Adapts the {@link AbstractCdmFormElement}:<br>
477
     * - sets the {@link IPropertyChangeListener}s handled by this class
478
     * </p>
479
     *
480
     * @param formElement
481
     *            a
482
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
483
     *            object.
484
     */
485
    public void adapt(ICdmFormElement formElement) {
486
        formElement.setPropertyChangeListeners(propertyChangeListeners);
487
    }
488

    
489
    /** {@inheritDoc} */
490
    @Override
491
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
492
        if (trackFocus) {
493
            control.addFocusListener(selectionFocusHandler);
494
        }
495
        super.adapt(control, trackFocus, trackKeyboard);
496
    }
497

    
498
    /** {@inheritDoc} */
499
    @Override
500
    public void adapt(Composite composite) {
501
        composite.addMouseListener(selectionMouseHandler);
502

    
503
        super.adapt(composite);
504
    }
505

    
506
    /**
507
     * <p>
508
     * destroyElement
509
     * </p>
510
     *
511
     * @param formElement
512
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
513
     *            object.
514
     */
515
    public void destroyElement(ICdmFormElement formElement) {
516
        // return if element was not initialized
517
        if (formElement == null) {
518
            return;
519
        }
520
        // destroy selection arbitrator, if any
521
        if (formElement instanceof ISelectableElement) {
522
            destroySelectionArbitrator(((ISelectableElement) formElement).getSelectionArbitrator());
523
        }
524
        // remove this element form its parents list of elements
525
        // ICdmFormElement parentElement = formElement.getParentElement();
526
        // if(parentElement != null){
527
        // parentElement.removeElement(formElement);
528
        // }
529
        // call destroy on child elements recursively
530
        for (ICdmFormElement childElement : formElement.getElements()) {
531
            destroyElement(childElement);
532
        }
533
        // dispose of the controls
534
        for (Control control : formElement.getControls()) {
535
            // we added the layoutComposite of the parental element as the
536
            // layout composite to this formElement
537
            // but we do not want to destroy it.
538
            if (control.equals(formElement.getLayoutComposite())) {
539
                continue;
540
            } else {
541
                if (control != null && !control.isDisposed()){
542
                    control.dispose();
543
                }
544
                control = null;
545
            }
546
        }
547
    }
548

    
549
    /**
550
     * <p>
551
     * createEmptyCell
552
     * </p>
553
     *
554
     * @param parent
555
     *            a {@link org.eclipse.swt.widgets.Composite} object.
556
     * @return a {@link org.eclipse.swt.widgets.Label} object.
557
     */
558
    public Label createEmptyCell(Composite parent) {
559
        return this.createLabel(parent, null);
560
    }
561

    
562
    /**
563
     * <p>
564
     * createMultiLanguageTextElement
565
     * </p>
566
     *
567
     * @param parentElement
568
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
569
     *            object.
570
     * @param labelString
571
     *            a {@link java.lang.String} object.
572
     * @param multilanguageText
573
     *            a {@link java.util.Map} object.
574
     * @param textHeight
575
     *            a int.
576
     * @param style
577
     *            a int.
578
     * @return a
579
     *         {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
580
     *         object.
581
     */
582
    public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
583
            Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
584
        MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
585
                multilanguageText, textHeight, style);
586
        adapt(element);
587
        parentElement.addElement(element);
588
        return element;
589
    }
590

    
591
    /**
592
     * <p>
593
     * createMultiLanguageTextElement
594
     * </p>
595
     *
596
     * @param parentElement
597
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
598
     *            object.
599
     *
600
     * @param Representation
601
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
602
     * @param textHeight
603
     *            a int.
604
     * @param style
605
     *            a int.
606
     * @return a
607
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
608
     *         object.
609
     */
610
    public RepresentationElement createRepresentationElement(ICdmFormElement parentElement, Representation representation, TermBase term,int textHeight, int style, boolean fillDetails) {
611
        RepresentationElement element = new RepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
612
        adapt(element);
613
        parentElement.addElement(element);
614
        return element;
615
    }
616

    
617
    /**
618
     * <p>
619
     * createMultiLanguageTextElement
620
     * </p>
621
     *
622
     * @param parentElement
623
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
624
     *            object.
625
     *
626
     * @param Representation
627
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
628
     * @param textHeight
629
     *            a int.
630
     * @param style
631
     *            a int.
632
     * @return a
633
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
634
     *         object.
635
     */
636
    public TranslatableRepresentationElement createTranslatableRepresentationElement(ICdmFormElement parentElement, Representation representation, TermBase term,int textHeight, int style, boolean fillDetails) {
637
        TranslatableRepresentationElement element = new TranslatableRepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
638
        adapt(element);
639
        parentElement.addElement(element);
640
        return element;
641
    }
642

    
643
    /**
644
     * <p>
645
     * createMultiLanguageTextElement
646
     * </p>
647
     *
648
     * @param parentElement
649
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
650
     *            object.
651
     *
652
     * @param term
653
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
654
     * @param textHeight
655
     *            a int.
656
     * @param style
657
     *            a int.
658
     * @return a
659
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
660
     *         object.
661
     */
662
    public RepresentationElement createRepresentationElement(ICdmFormElement parentElement, TermBase term, int textHeight, int style, boolean fillDetails) {
663
        RepresentationElement element = new RepresentationElement(this, parentElement, term, textHeight, style, fillDetails);
664
        adapt(element);
665
        parentElement.addElement(element);
666
        return element;
667
    }
668

    
669
    /**
670
     * <p>
671
     * createMultiLanguageTextElement
672
     * </p>
673
     *
674
     * @param parentElement
675
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
676
     *            object.
677
     *
678
     * @param term
679
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
680
     * @param textHeight
681
     *            a int.
682
     * @param style
683
     *            a int.
684
     * @return a
685
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
686
     *         object.
687
     */
688
    public TranslatableRepresentationElement createTranslatableRepresentationElement(ICdmFormElement parentElement, TermBase term, int textHeight, int style, boolean fillDetails) {
689
        TranslatableRepresentationElement element = new TranslatableRepresentationElement(this, parentElement, term, textHeight, style, fillDetails);
690
        adapt(element);
691
        parentElement.addElement(element);
692
        return element;
693
    }
694

    
695
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
696
            KeyStatement keyStatement, int textHeight, int style) {
697
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
698
                textHeight, style);
699
        adapt(element);
700
        parentElement.addElement(element);
701
        return element;
702
    }
703

    
704
    /**
705
     * Creates a text field with a label. The initial content will be the return value of the initalObject's {@link #toString()}
706
     * method.<br>
707
     * <b>Note</b>: if initialObject is <code>null</code> then an empty string is used.
708
     * @param parentElement the parent container
709
     * @param labelString the label name
710
     * @param initialObject the object from which the <code>toString()</code> method is called
711
     * @param style {@link SWT} style constant
712
     * @return the created textfield with label
713
     */
714
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
715
            Object initialObject, int style) {
716
        return createTextWithLabelElement(parentElement, labelString, initialObject==null?"":initialObject.toString(), style);
717
    }
718

    
719
    /**
720
     * <p>
721
     * createTextWithLabelElement
722
     * </p>
723
     *
724
     * @param parentElement
725
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
726
     *            object.
727
     * @param labelString
728
     *            a {@link java.lang.String} object.
729
     * @param initialText
730
     *            a {@link java.lang.String} object.
731
     * @param style
732
     *            a int.
733
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
734
     *         object.
735
     */
736
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
737
            String initialText, int style) {
738
        return createTextWithLabelElement(parentElement, labelString, initialText, null, style);
739
    }
740
    /**
741
     * <p>
742
     * createTextWithLabelElement
743
     * </p>
744
     *
745
     * @param parentElement
746
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
747
     *            object.
748
     * @param labelString
749
     *            a {@link java.lang.String} object.
750
     * @param initialText
751
     *            a {@link java.lang.String} object.
752
     * @param textLimit maximal number of characters allowed
753
     * @param style
754
     *            a int.
755
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
756
     *         object.
757
     */
758
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
759
            String initialText, Integer textLimit, int style) {
760
        if(initialText==null){
761
            initialText = "";
762
        }
763

    
764
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
765
                textLimit, style);
766
        adapt(element);
767
        parentElement.addElement(element);
768
        return element;
769
    }
770

    
771
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
772
            int textHeight, int style) {
773
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
774
        adapt(element);
775
        parentElement.addElement(element);
776
        return element;
777
    }
778

    
779
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
780
            LSID initialLsid, int style) {
781
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
782
        adapt(element);
783
        parentElement.addElement(element);
784
        return element;
785
    }
786

    
787
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
788
            URI initialUri, int style) {
789
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
790
        adapt(element);
791
        parentElement.addElement(element);
792
        return element;
793
    }
794

    
795
    /**
796
     * @param element
797
     * @param string
798
     * @param uri
799
     * @param style
800
     * @return
801
     */
802
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
803
            IOpenUrlEnabled openUrlEnabled, int style) {
804
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
805
                style);
806
        adapt(element);
807
        parentElement.addElement(element);
808
        return element;
809
    }
810

    
811
    /**
812
     *
813
     * @param parentElement
814
     * @param labelString
815
     * @param conversationEnabled
816
     * @param user
817
     * @param style
818
     * @return
819
     */
820
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
821
            ConversationHolder conversation, User user, int style) {
822
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
823
        adapt(element);
824
        parentElement.addElement(element);
825
        return element;
826
    }
827

    
828
    /**
829
     * <p>
830
     * createIntegerTextWithLabelElement
831
     * </p>
832
     *
833
     * @param parentElement
834
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
835
     *            object.
836
     * @param labelString
837
     *            a {@link java.lang.String} object.
838
     * @param initialInteger
839
     *            a {@link java.lang.Integer} object.
840
     * @param style
841
     *            a int.
842
     * @return a
843
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
844
     *         object.
845
     */
846
	public NumberWithLabelElement createNumberTextWithLabelElement(
847
			ICdmFormElement parentElement, String labelString,
848
			Number initialNumber, int style) {
849
		NumberWithLabelElement element = new NumberWithLabelElement(this,
850
				parentElement, labelString, initialNumber, style);
851
		adapt(element);
852
		parentElement.addElement(element);
853
		return element;
854
	}
855

    
856
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
857
            String labelString, LanguageString languageString, int style) {
858
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
859
    }
860

    
861
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
862
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
863
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
864
                languageString, height, isMultiLine, style);
865
        adapt(element);
866
        parentElement.addElement(element);
867
        return element;
868
    }
869

    
870
    /**
871
     * <p>
872
     * createKeyValueViewerElement
873
     * </p>
874
     *
875
     * @param parentElement
876
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
877
     *            object.
878
     * @param keyHeading
879
     *            a {@link java.lang.String} object.
880
     * @param valueHeading
881
     *            a {@link java.lang.String} object.
882
     * @param map
883
     *            a {@link java.util.Map} object.
884
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
885
     *         object.
886
     */
887
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
888
            String valueHeading, Map<Object, Object> map) {
889
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
890
        adapt(element);
891
        parentElement.addElement(element);
892
        return element;
893
    }
894
    /**
895
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
896
     */
897
    @Deprecated
898
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
899
            ICdmFormElement parentElement, String labelString, T selection, int style) {
900
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString, selection, true, style);
901
        adapt(element);
902
        parentElement.addElement(element);
903
        return element;
904
    }
905

    
906
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
907
            TermType termType,
908
            ICdmFormElement parentElement,
909
            String labelString,
910
            T selection,
911
            int style,
912
            Comparator<T> comparator) {
913
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false, comparator);
914
    }
915

    
916
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
917
			TermType termType,
918
			ICdmFormElement parentElement,
919
			String labelString,
920
			T selection,
921
			boolean addEmptyElement,
922
			int style) {
923
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, false, null);
924
	}
925

    
926
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
927
			TermType termType,
928
			ICdmFormElement parentElement,
929
			String labelString,
930
			T selection,
931
			int style) {
932
		return  this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false, null);
933
	}
934
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
935
			TermType termType,
936
			ICdmFormElement parentElement,
937
			String labelString,
938
			T selection,
939
			boolean addEmptyElement,
940
			int style,
941
			boolean useAbbrevLabel) {
942
		return createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
943
	}
944

    
945

    
946
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
947
            TermVocabulary<?> termVocabulary,
948
            ICdmFormElement parentElement,
949
            String labelString,
950
            T selection,
951
            int style) {
952
        return this.createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, true, style, false, null);
953
    }
954

    
955
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
956
	        TermVocabulary<?> termVocabulary,
957
	        ICdmFormElement parentElement,
958
	        String labelString,
959
	        T selection,
960
	        boolean addEmptyElement,
961
	        int style,
962
	        boolean useAbbrevLabel) {
963
	    return createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
964
	}
965

    
966
	private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
967
	        TermType termType,
968
	        TermVocabulary<?> termVocabulary,
969
	        ICdmFormElement parentElement,
970
	        String labelString,
971
	        T selection,
972
	        boolean addEmptyElement,
973
	        int style,
974
	        boolean useAbbrevLabel,
975
	        Comparator<T> comparator) {
976
	    if(termType!=null){
977
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
978
	        adapt(element);
979
	        parentElement.addElement(element);
980
	        return element;
981
	    }
982
	    else if(termVocabulary!=null){
983
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
984
	        if (comparator!= null){
985
	        	element.setTermComparator(comparator);
986
	        }
987
	        adapt(element);
988
	        parentElement.addElement(element);
989
	        return element;
990
	    }
991
	    else{
992
	        //this should never happen
993
	        return null;
994
	    }
995
	}
996

    
997
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
998
	        Class<T> enumComboType, ICdmFormElement parentElement,
999
	        int style) {
1000
	    return createEnumComboElement(enumComboType, parentElement, null, style);
1001
	}
1002

    
1003
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1004
			Class<T> enumComboType, ICdmFormElement parentElement, Comparator<T> comparator,
1005
			int style) {
1006
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, comparator, style);
1007
        adapt(element);
1008
        parentElement.addElement(element);
1009
        return element;
1010
    }
1011

    
1012
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
1013
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
1014
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1015
	    adapt(element);
1016
	    parentElement.addElement(element);
1017
	    return element;
1018
	}
1019

    
1020
    /**
1021
     * <p>
1022
     * createBrowserElement
1023
     * </p>
1024
     *
1025
     * @param imageUri
1026
     *            a {@link java.net.URI} object.
1027
     * @param style
1028
     *            a int.
1029
     * @param parentElement
1030
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1031
     *            object.
1032
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
1033
     *         object.
1034
     */
1035
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
1036
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
1037
        adapt(element);
1038
        parentElement.addElement(element);
1039
        return element;
1040
    }
1041

    
1042
    /**
1043
     * <p>
1044
     * createImageElement
1045
     * </p>
1046
     *
1047
     * @param parentElement
1048
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1049
     *            object.
1050
     * @param imageUri
1051
     *            a {@link java.net.URI} object.
1052
     * @param style
1053
     *            a int.
1054
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1055
     */
1056
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1057
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1058
        adapt(element);
1059
        parentElement.addElement(element);
1060
        return element;
1061
    }
1062

    
1063
    /**
1064
     * <p>
1065
     * createTextActionElement
1066
     * </p>
1067
     *
1068
     * @param labelString
1069
     *            a {@link java.lang.String} object.
1070
     * @param initialText
1071
     *            a {@link java.lang.String} object.
1072
     * @param style
1073
     *            a int.
1074
     * @param parentElement
1075
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1076
     *            object.
1077
     * @param buttonLabel
1078
     *            a {@link java.lang.String} object.
1079
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
1080
     *         object.
1081
     */
1082
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
1083
            String buttonLabel, String initialText, int style) {
1084
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
1085
                style);
1086
        adapt(element);
1087
        parentElement.addElement(element);
1088
        return element;
1089
    }
1090

    
1091
    /**
1092
     * <p>
1093
     * createCheckbox
1094
     * </p>
1095
     *
1096
     * @param parentElement
1097
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1098
     *            object.
1099
     * @param label
1100
     *            a {@link java.lang.String} object.
1101
     * @param initialState
1102
     *            a boolean.
1103
     * @param style
1104
     *            a int.
1105
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1106
     *         object.
1107
     */
1108
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1109
        if(initialState==null){
1110
            initialState = Boolean.FALSE;
1111
        }
1112
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1113
        adapt(element);
1114
        parentElement.addElement(element);
1115
        return element;
1116
    }
1117

    
1118
    /**
1119
     * Creates a section as a part of the form.
1120
     *
1121
     * @return the section widget
1122
     * @param section
1123
     *            a
1124
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1125
     *            object.
1126
     */
1127
    public Section adapt(AbstractFormSection section) {
1128
        section.setMenu(section.getLayoutComposite().getMenu());
1129
        adapt(section, true, true);
1130

    
1131
        // handle focus and property change events for cdm use
1132
        section.addFocusListener(selectionFocusHandler);
1133
        section.setPropertyChangeListeners(propertyChangeListeners);
1134

    
1135
        if (section.getToggle() != null) {
1136
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1137
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1138
        }
1139

    
1140
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1141

    
1142
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1143
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1144
            getColors().initializeSectionToolBarColors();
1145
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1146
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1147
        }
1148
        // call setTitleBarForeground regardless as it also sets the label color
1149
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1150
        return section;
1151
    }
1152

    
1153
    private class BoldFontHolder2 {
1154
        private Font normalFont;
1155

    
1156
        private Font boldFont;
1157

    
1158
        public BoldFontHolder2() {
1159
        }
1160

    
1161
        public Font getBoldFont(Font font) {
1162
            createBoldFont(font);
1163
            return boldFont;
1164
        }
1165

    
1166
        private void createBoldFont(Font font) {
1167
            if (normalFont == null || !normalFont.equals(font)) {
1168
                normalFont = font;
1169
                dispose();
1170
            }
1171
            if (boldFont == null) {
1172
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1173
            }
1174
        }
1175

    
1176
        public void dispose() {
1177
            if (boldFont != null) {
1178
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1179
                boldFont = null;
1180
            }
1181
        }
1182
    }
1183

    
1184
    /**
1185
     * <p>
1186
     * createToggleableTextField
1187
     * </p>
1188
     *
1189
     * @param parentElement
1190
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1191
     *            object.
1192
     * @param labelString
1193
     *            a {@link java.lang.String} object.
1194
     * @param initialText
1195
     *            a {@link java.lang.String} object.
1196
     * @param initialState
1197
     *            a boolean.
1198
     * @param style
1199
     *            a int.
1200
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1201
     *         object.
1202
     */
1203
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1204
            String initialText, boolean initialState, int style) {
1205
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1206
                initialState, style | orientation);
1207
        adapt(element);
1208
        parentElement.addElement(element);
1209
        return element;
1210
    }
1211

    
1212
    /**
1213
     * <p>
1214
     * createTimePeriodElement
1215
     * </p>
1216
     *
1217
     * @param parentElement
1218
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1219
     *            object.
1220
     * @param labelString
1221
     *            a {@link java.lang.String} object.
1222
     * @param timePeriod
1223
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1224
     * @param style
1225
     *            a int.
1226
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1227
     *         object.
1228
     */
1229
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1230
            TimePeriod timePeriod, int style) {
1231
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1232
        adapt(element);
1233
        parentElement.addElement(element);
1234
        return element;
1235
    }
1236

    
1237
	/**
1238
	 * <p>
1239
	 * createGatheringEventUnitElement
1240
	 * </p>
1241
	 *
1242
	 * @param parentElement
1243
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1244
	 *            object.
1245
	 * @param labelString
1246
	 *            a {@link java.lang.String} object.
1247
	 * @param timePeriod
1248
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1249
	 * @param style
1250
	 *            a int.
1251
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1252
	 *         object.
1253
	 */
1254
	public GatheringEventUnitElement createGatheringEventUnitElement(
1255
			ICdmFormElement parentElement,
1256
			String labelString,
1257
			DerivedUnitFacade gatheringEvent,
1258
			MinMaxTextSection.UnitType unitType,
1259
			int style) {
1260
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1261
				parentElement,
1262
				labelString,
1263
				gatheringEvent,
1264
				unitType,
1265
				style);
1266
		adapt(element);
1267
		parentElement.addElement(element);
1268
		return element;
1269
	}
1270

    
1271
    /**
1272
     * <p>
1273
     * createPointElement
1274
     * </p>
1275
     *
1276
     * @param style
1277
     *            a int.
1278
     * @param parentElement
1279
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1280
     *            object.
1281
     * @param point
1282
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1283
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1284
     */
1285
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1286
        PointElement element = new PointElement(this, parentElement, point, style);
1287
        adapt(element);
1288
        parentElement.addElement(element);
1289
        return element;
1290
    }
1291

    
1292

    
1293

    
1294
    /**
1295
     * @param conversationHolder
1296
     * @param parent
1297
     * @param detailsViewer
1298
     * @param i
1299
     * @return
1300
     */
1301
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1302
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1303
        parentElement.addElement(section);
1304
        adapt(section);
1305
        return section;
1306
    }
1307

    
1308
    /**
1309
     * <p>
1310
     * createDateDetailSection
1311
     * </p>
1312
     *
1313
     * @param parentElement
1314
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1315
     *            object.
1316
     * @param style
1317
     *            a int.
1318
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1319
     *         object.
1320
     */
1321
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1322
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1323
        parentElement.addElement(section);
1324
        adapt(section);
1325
        return section;
1326
    }
1327

    
1328
	/**
1329
	 * <p>
1330
	 * createDateDetailSection
1331
	 * </p>
1332
	 *
1333
	 * @param parentElement
1334
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1335
	 *            object.
1336
	 * @param style
1337
	 *            a int.
1338
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1339
	 *         object.
1340
	 */
1341
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1342
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1343
		parentElement.addElement(section);
1344
		adapt(section);
1345
		return section;
1346
	}
1347

    
1348
    /**
1349
     * <p>
1350
     * createPartialElement
1351
     * </p>
1352
     *
1353
     * @param parentElement
1354
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1355
     *            object.
1356
     * @param labelString
1357
     *            a {@link java.lang.String} object.
1358
     * @param partial
1359
     *            a {@link org.joda.time.Partial} object.
1360
     * @param style
1361
     *            a int.
1362
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1363
     *         object.
1364
     */
1365
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1366
            int style) {
1367
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1368
        adapt(element);
1369
        parentElement.addElement(element);
1370
        return element;
1371
    }
1372

    
1373
    /**
1374
     * <p>
1375
     * addSelectionListener
1376
     * </p>
1377
     *
1378
     * @param listener
1379
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1380
     */
1381
    public void addSelectionListener(SelectionListener listener) {
1382
        selectionListenerList.add(listener);
1383
    }
1384

    
1385
    /**
1386
     * <p>
1387
     * removeSelectionListener
1388
     * </p>
1389
     *
1390
     * @param listener
1391
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1392
     */
1393
    public void removeSelectionListener(SelectionListener listener) {
1394
        if (listener == null) {
1395
            MessagingUtils.error(this.getClass(),
1396
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1397
        } else {
1398
            selectionListenerList.remove(listener);
1399
        }
1400
    }
1401

    
1402
    /**
1403
     * <p>
1404
     * addPropertyChangeListener
1405
     * </p>
1406
     *
1407
     * @param listener
1408
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1409
     *            object.
1410
     */
1411
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1412
        if (propertyChangeListeners.contains(listener)) {
1413
            return;
1414
        }
1415
        propertyChangeListeners.add(0, listener);
1416
    }
1417

    
1418
    /**
1419
     * <p>
1420
     * removePropertyChangeListener
1421
     * </p>
1422
     *
1423
     * @param listener
1424
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1425
     *            object.
1426
     */
1427
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1428
        propertyChangeListeners.remove(listener);
1429
    }
1430

    
1431
    /**
1432
     * @return the propertyChangeListeners
1433
     */
1434
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1435
        return propertyChangeListeners;
1436
    }
1437

    
1438
    /**
1439
     * <p>
1440
     * createHorizontalSeparator
1441
     * </p>
1442
     *
1443
     * @param parentElement
1444
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1445
     *            object.
1446
     * @param style
1447
     *            a int.
1448
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1449
     */
1450
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1451
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1452
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1453
        return separator;
1454
    }
1455

    
1456
    /**
1457
     * <p>
1458
     * createVersionElement
1459
     * </p>
1460
     *
1461
     * @param parentElement
1462
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1463
     *            object.
1464
     * @param entity
1465
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1466
     *            object.
1467
     * @param style
1468
     *            a int.
1469
     * @return a
1470
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1471
     *         object.
1472
     */
1473
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1474
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1475
        adapt(element);
1476
        parentElement.addElement(element);
1477
        return element;
1478
    }
1479

    
1480
    /**
1481
     * @param cdmBaseSection
1482
     * @param object
1483
     * @param style
1484
     * @return
1485
     */
1486
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1487
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1488
        adapt(element);
1489
        parentElement.addElement(element);
1490
        return element;
1491
    }
1492

    
1493
    /**
1494
     * <p>
1495
     * createVersionSection
1496
     * </p>
1497
     *
1498
     * @param parentElement
1499
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1500
     *            object.
1501
     * @param style
1502
     *            a int.
1503
     * @return a
1504
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1505
     *         object.
1506
     */
1507
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1508
        VersionSection section = new VersionSection(this, parentElement, style);
1509
        parentElement.addElement(section);
1510
        adapt(section);
1511
        return section;
1512
    }
1513

    
1514
    /**
1515
     * @param parent
1516
     * @param i
1517
     * @return
1518
     */
1519
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1520
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1521
        parentElement.addElement(section);
1522
        adapt(section);
1523
        return section;
1524
    }
1525

    
1526
    /**
1527
     * <p>
1528
     * createEmptyElement
1529
     * </p>
1530
     *
1531
     * @param parentElement
1532
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1533
     *            object.
1534
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1535
     */
1536
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1537
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1538
        adapt(element);
1539
        parentElement.addElement(element);
1540
        return element;
1541
    }
1542

    
1543
    /**
1544
     * <p>
1545
     * createHeadlineSection
1546
     * </p>
1547
     *
1548
     * @param parentElement
1549
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1550
     *            object.
1551
     * @return a
1552
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1553
     *         object.
1554
     */
1555
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1556
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1557
        parentElement.addElement(section);
1558
        adapt(section);
1559
        return section;
1560
    }
1561

    
1562
    /**
1563
     * <p>
1564
     * createParsingMessageElement
1565
     * </p>
1566
     *
1567
     * @param parentElement
1568
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1569
     *            object.
1570
     * @param parserProblem
1571
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1572
     *            object.
1573
     * @param style
1574
     *            a int.
1575
     * @return a
1576
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1577
     *         object.
1578
     */
1579
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1580
            ParserProblem parserProblem, int style) {
1581
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1582
        adapt(element);
1583
        parentElement.addElement(element);
1584
        return element;
1585
    }
1586

    
1587
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1588
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1589

    
1590
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1591
                selectionProvider, style);
1592

    
1593
        parentElement.addElement(section);
1594
        adapt(section);
1595
        return section;
1596

    
1597
    }
1598

    
1599
    /**
1600
     * @param definedTermClass
1601
     * @param formElement
1602
     * @param style
1603
     * @return
1604
     */
1605
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1606
            AbstractCdmDetailSection parentElement, int style) {
1607
        AbstractCdmDetailElement element = null;
1608

    
1609
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1610
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1611
        } else if (definedTermClass.equals(Feature.class)) {
1612
            element = new FeatureDetailElement(this, parentElement);
1613
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1614
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1615
        } else {
1616
            element = new DefinedTermDetailElement(this, parentElement);
1617
        }
1618

    
1619

    
1620
        adapt(element);
1621
        parentElement.addElement(element);
1622
        return element;
1623
    }
1624

    
1625

    
1626
    //--------DetailSections---------
1627
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1628
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1629
        addAndAdaptSection(parentElement, section);
1630
        return section;
1631
    }
1632

    
1633
    public ReferenceDetailSection createReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1634
        ReferenceDetailSection section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1635
        addAndAdaptSection(parentElement, section);
1636
        return section;
1637
    }
1638

    
1639
    public NomenclaturalReferenceDetailSection createNomenclaturalReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1640
        NomenclaturalReferenceDetailSection section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1641
        addAndAdaptSection(parentElement, section);
1642
        return section;
1643
    }
1644

    
1645
    public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1646
        TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1647
        addAndAdaptSection(parentElement, section);
1648
        return section;
1649
    }
1650

    
1651
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1652
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1653
        addAndAdaptSection(parentElement, section);
1654
        return section;
1655
    }
1656

    
1657
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1658
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1659
        addAndAdaptSection(parentElement, section);
1660
        return section;
1661
    }
1662

    
1663
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1664
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1665
        addAndAdaptSection(parentElement, section);
1666
        return section;
1667
    }
1668

    
1669
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1670
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1671
        addAndAdaptSection(parentElement, section);
1672
        return section;
1673
    }
1674

    
1675
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1676
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1677
        addAndAdaptSection(parentElement, section);
1678
        return section;
1679
    }
1680

    
1681
    public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1682
        DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1683
        addAndAdaptSection(parentElement, section);
1684
        return section;
1685
    }
1686

    
1687
    public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1688
        ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1689
        addAndAdaptSection(parentElement, section);
1690
        return section;
1691
    }
1692

    
1693

    
1694

    
1695
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, boolean nameChoosable, int style){
1696
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, nameChoosable, style);
1697
        addAndAdaptSection(parentElement, section);
1698
        return section;
1699
    }
1700

    
1701
    public MediaDetailsSection createMediaDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1702
        MediaDetailsSection section = new MediaDetailsSection(this, conversation, parentElement, selectionProvider, style);
1703
        addAndAdaptSection(parentElement, section);
1704
        return section;
1705
    }
1706

    
1707
    public FieldUnitDetailSection createFieldUnitDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1708
        FieldUnitDetailSection section = new FieldUnitDetailSection(this, conversation, parentElement, selectionProvider, style);
1709
        addAndAdaptSection(parentElement, section);
1710
        return section;
1711
    }
1712

    
1713
    public GatheringEventDetailSection createGatheringEventDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1714
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1715
        addAndAdaptSection(parentElement, section);
1716
        return section;
1717
    }
1718

    
1719
    public SpecimenHierarchyDetailSection createSpecimenHierarchyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1720
        SpecimenHierarchyDetailSection section = new SpecimenHierarchyDetailSection(this, conversation, parentElement, selectionProvider, style);
1721
        addAndAdaptSection(parentElement, section);
1722
        return section;
1723
    }
1724

    
1725
    public DerivedUnitBaseDetailSection createDerivedUnitBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1726
        DerivedUnitBaseDetailSection section = new DerivedUnitBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1727
        addAndAdaptSection(parentElement, section);
1728
        return section;
1729
    }
1730

    
1731
    public DerivedUnitTypeDesignationSection createDerivedUnitTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1732
        DerivedUnitTypeDesignationSection section = new DerivedUnitTypeDesignationSection(this, conversation, parentElement, style);
1733
        addAndAdaptSection(parentElement, section);
1734
        return section;
1735
    }
1736

    
1737
    public TaxonAssociationDetailSection createTaxonAssociationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1738
        TaxonAssociationDetailSection section = new TaxonAssociationDetailSection(this, conversation, parentElement, selectionProvider, style);
1739
        addAndAdaptSection(parentElement, section);
1740
        return section;
1741
    }
1742

    
1743
    public OriginalLabelDataSection createOriginalLabelDataSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1744
        OriginalLabelDataSection section = new OriginalLabelDataSection(this, conversation, parentElement, selectionProvider, style);
1745
        addAndAdaptSection(parentElement, section);
1746
        return section;
1747
    }
1748

    
1749
    public NaturalLanguageSection createNaturalLanguageSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1750
        NaturalLanguageSection section = new NaturalLanguageSection(this, conversation, parentElement, selectionProvider, style);
1751
        addAndAdaptSection(parentElement, section);
1752
        return section;
1753
    }
1754

    
1755
    public FeatureDistributionDetailSection createFeatureDistributionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1756
        FeatureDistributionDetailSection section = new FeatureDistributionDetailSection(this, conversation, parentElement, selectionProvider, style);
1757
        addAndAdaptSection(parentElement, section);
1758
        return section;
1759
    }
1760

    
1761
    public ClassificationDetailSection createClassificationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1762
        ClassificationDetailSection section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style);
1763
        addAndAdaptSection(parentElement, section);
1764
        return section;
1765
    }
1766

    
1767
    public TaxonNodeDetailSection createTaxonNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1768
        TaxonNodeDetailSection section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1769
        addAndAdaptSection(parentElement, section);
1770
        return section;
1771
    }
1772

    
1773
    public PolytomousKeyDetailSection createPolytomousKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1774
        PolytomousKeyDetailSection section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
1775
        addAndAdaptSection(parentElement, section);
1776
        return section;
1777
    }
1778

    
1779
    public PolytomousKeyNodeDetailSection createPolytomousKeyNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1780
        PolytomousKeyNodeDetailSection section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1781
        addAndAdaptSection(parentElement, section);
1782
        return section;
1783
    }
1784

    
1785
    public InstitutionDetailSection createInstitutionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1786
        InstitutionDetailSection section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
1787
        addAndAdaptSection(parentElement, section);
1788
        return section;
1789
    }
1790

    
1791
    public FieldUnitGeneralDetailSection createFieldUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1792
        FieldUnitGeneralDetailSection section = new FieldUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1793
        addAndAdaptSection(parentElement, section);
1794
        return section;
1795
    }
1796

    
1797
    public DerivedUnitGeneralDetailSection createDerivedUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1798
        DerivedUnitGeneralDetailSection section = new DerivedUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1799
        addAndAdaptSection(parentElement, section);
1800
        return section;
1801
    }
1802

    
1803
    public PreservedSpecimenGeneralDetailSection createPreservedSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1804
        PreservedSpecimenGeneralDetailSection section = new PreservedSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1805
        addAndAdaptSection(parentElement, section);
1806
        return section;
1807
    }
1808

    
1809
    public TissueSampleGeneralDetailSection createTissueSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1810
        TissueSampleGeneralDetailSection section = new TissueSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1811
        addAndAdaptSection(parentElement, section);
1812
        return section;
1813
    }
1814

    
1815
    public DnaSampleGeneralDetailSection createDnaSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1816
        DnaSampleGeneralDetailSection section = new DnaSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1817
        addAndAdaptSection(parentElement, section);
1818
        return section;
1819
    }
1820

    
1821
    public DnaSamplePreparationPreservationSection createDnaSamplePreparationPreservationSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1822
        DnaSamplePreparationPreservationSection section = new DnaSamplePreparationPreservationSection(this, conversation, parentElement, selectionProvider, style);
1823
        addAndAdaptSection(parentElement, section);
1824
        return section;
1825
    }
1826

    
1827
    public DnaQualityDetailSection createDnaQualityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1828
        DnaQualityDetailSection section = new DnaQualityDetailSection(this, conversation, parentElement, selectionProvider, style);
1829
        addAndAdaptSection(parentElement, section);
1830
        return section;
1831
    }
1832

    
1833
    public SequenceGeneralDetailSection createSequenceGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1834
        SequenceGeneralDetailSection section = new SequenceGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1835
        addAndAdaptSection(parentElement, section);
1836
        return section;
1837
    }
1838

    
1839
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1840
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
1841
        addAndAdaptSection(parentElement, section);
1842
        return section;
1843
    }
1844

    
1845
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1846
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
1847
        addAndAdaptSection(parentElement, section);
1848
        return section;
1849
    }
1850

    
1851
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1852
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1853
        addAndAdaptSection(parentElement, section);
1854
        return section;
1855
    }
1856

    
1857
    public SingleReadGeneralDetailSection createSingleReadGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1858
        SingleReadGeneralDetailSection section = new SingleReadGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1859
        addAndAdaptSection(parentElement, section);
1860
        return section;
1861
    }
1862

    
1863
    public AmplificationGeneralDetailSection createAmplificationGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1864
        AmplificationGeneralDetailSection section = new AmplificationGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1865
        addAndAdaptSection(parentElement, section);
1866
        return section;
1867
    }
1868

    
1869
    public AmplificationPrimerDetailSection createAmplificationPrimerDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1870
        AmplificationPrimerDetailSection section = new AmplificationPrimerDetailSection(this, conversation, parentElement, selectionProvider, style);
1871
        addAndAdaptSection(parentElement, section);
1872
        return section;
1873
    }
1874

    
1875
    public AmplificationCloningDetailSection createAmplificationCloningDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1876
        AmplificationCloningDetailSection section = new AmplificationCloningDetailSection(this, conversation, parentElement, selectionProvider, style);
1877
        addAndAdaptSection(parentElement, section);
1878
        return section;
1879
    }
1880

    
1881
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1882
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1883
        addAndAdaptSection(parentElement, section);
1884
        return section;
1885
    }
1886

    
1887
    public MediaSpecimenGeneralDetailSection createMediaSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1888
        MediaSpecimenGeneralDetailSection section = new MediaSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1889
        addAndAdaptSection(parentElement, section);
1890
        return section;
1891
    }
1892

    
1893
    public HybridDetailSection createHybridDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1894
        HybridDetailSection section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
1895
        addAndAdaptSection(parentElement, section);
1896
        return section;
1897
    }
1898

    
1899
    public UserDetailSection createUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1900
        UserDetailSection section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
1901
        addAndAdaptSection(parentElement, section);
1902
        return section;
1903
    }
1904

    
1905
    public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1906
        GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
1907
        addAndAdaptSection(parentElement, section);
1908
        return section;
1909
    }
1910

    
1911
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1912
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1913
        addAndAdaptSection(parentElement, section);
1914
        return section;
1915
    }
1916

    
1917
    public SampleDesignationDetailSection createSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1918
        SampleDesignationDetailSection section = new SampleDesignationDetailSection(this, conversation, parentElement, selectionProvider, style);
1919
        addAndAdaptSection(parentElement, section);
1920
        return section;
1921
    }
1922

    
1923
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1924
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style, true);
1925
        addAndAdaptSection(parentElement, section);
1926
        return section;
1927
    }
1928

    
1929
    public ReferencedEntityDetailSection createReferencedEntityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1930
        ReferencedEntityDetailSection section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
1931
        addAndAdaptSection(parentElement, section);
1932
        return section;
1933
    }
1934

    
1935
    public TermVocabularyDetailSection createTermVocabularyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1936
        TermVocabularyDetailSection section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
1937
        addAndAdaptSection(parentElement, section);
1938
        return section;
1939
    }
1940

    
1941
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1942
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1943
        addAndAdaptSection(parentElement, section);
1944
        return section;
1945
    }
1946

    
1947
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1948
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
1949
        addAndAdaptSection(parentElement, section);
1950
        return section;
1951
    }
1952

    
1953
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1954
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
1955
        addAndAdaptSection(parentElement, section);
1956
        return section;
1957
    }
1958

    
1959
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1960
        parentElement.addElement(section);
1961
        adapt(section);
1962
    }
1963

    
1964
    //--------DetailElements------------
1965

    
1966
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1967
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1968
        addAndAdaptElement(parentElement, element);
1969
        return element;
1970
    }
1971

    
1972
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1973
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1974
        addAndAdaptElement(parentElement, element);
1975
        return element;
1976
    }
1977

    
1978
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1979
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1980
        addAndAdaptElement(parentElement, element);
1981
        return element;
1982
    }
1983

    
1984
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1985
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1986
        addAndAdaptElement(parentElement, element);
1987
        return element;
1988
    }
1989

    
1990
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1991
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1992
        addAndAdaptElement(parentElement, element);
1993
        return element;
1994
    }
1995

    
1996
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1997
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1998
        addAndAdaptElement(parentElement, element);
1999
        return element;
2000
    }
2001

    
2002
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
2003
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2004
        addAndAdaptElement(parentElement, element);
2005
        return element;
2006
    }
2007

    
2008
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2009
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2010
        addAndAdaptElement(parentElement, element);
2011
        return element;
2012
    }
2013

    
2014
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2015
        UserDetailElement element = new UserDetailElement(this, parentElement);
2016
        addAndAdaptElement(parentElement, element);
2017
        return element;
2018
    }
2019

    
2020
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2021
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2022
        addAndAdaptElement(parentElement, element);
2023
        return element;
2024
    }
2025

    
2026
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2027
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2028
        addAndAdaptElement(parentElement, element);
2029
        return element;
2030
    }
2031

    
2032
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2033
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2034
        addAndAdaptElement(parentElement, element);
2035
        return element;
2036
    }
2037

    
2038
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2039
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2040
        addAndAdaptElement(parentElement, element);
2041
        return element;
2042
    }
2043

    
2044
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2045
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2046
        addAndAdaptElement(parentElement, element);
2047
        return element;
2048
    }
2049

    
2050
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2051
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2052
        adapt(element);
2053
        parentElement.addElement(element);
2054

    
2055
        return element;
2056
    }
2057

    
2058
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2059
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2060
        addAndAdaptElement(parentElement, element);
2061
        return element;
2062
    }
2063

    
2064
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
2065
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
2066
        addAndAdaptElement(parentElement, element);
2067
        return element;
2068
    }
2069

    
2070
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2071
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2072
        addAndAdaptElement(parentElement, element);
2073
        return element;
2074
    }
2075

    
2076
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2077
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2078
        addAndAdaptElement(parentElement, element);
2079
        return element;
2080
    }
2081

    
2082
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2083
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2084
        addAndAdaptElement(parentElement, element);
2085
        return element;
2086
    }
2087

    
2088
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2089
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2090
        addAndAdaptElement(parentElement, element);
2091
        return element;
2092
    }
2093

    
2094
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2095
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2096
        addAndAdaptElement(parentElement, element);
2097
        return element;
2098
    }
2099

    
2100
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2101
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2102
        addAndAdaptElement(parentElement, element);
2103
        return element;
2104
    }
2105

    
2106
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2107
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2108
        addAndAdaptElement(parentElement, element);
2109
        return element;
2110
    }
2111

    
2112
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2113
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2114
        addAndAdaptElement(parentElement, element);
2115
        return element;
2116
    }
2117

    
2118
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2119
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2120
        addAndAdaptElement(parentElement, element);
2121
        return element;
2122
    }
2123

    
2124
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2125
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2126
        addAndAdaptElement(parentElement, element);
2127
        return element;
2128
    }
2129

    
2130
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2131
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2132
        addAndAdaptElement(parentElement, element);
2133
        return element;
2134
    }
2135

    
2136
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2137
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2138
        addAndAdaptElement(parentElement, element);
2139
        return element;
2140
    }
2141

    
2142
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2143
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2144
        addAndAdaptElement(parentElement, element);
2145
        return element;
2146
    }
2147

    
2148

    
2149
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2150
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2151
        addAndAdaptElement(parentElement, element);
2152
        return element;
2153
    }
2154

    
2155
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2156
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2157
        addAndAdaptElement(parentElement, element);
2158
        return element;
2159
    }
2160

    
2161
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2162
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2163
        addAndAdaptElement(parentElement, element);
2164
        return element;
2165
    }
2166

    
2167
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2168
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2169
        addAndAdaptElement(parentElement, element);
2170
        return element;
2171
    }
2172

    
2173
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2174
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2175
        addAndAdaptElement(parentElement, element);
2176
        return element;
2177
    }
2178

    
2179
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2180
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2181
        addAndAdaptElement(parentElement, element);
2182
        return element;
2183
    }
2184

    
2185
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2186
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2187
        addAndAdaptElement(parentElement, element);
2188
        return element;
2189
    }
2190

    
2191
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2192
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2193
        addAndAdaptElement(parentElement, element);
2194
        return element;
2195
    }
2196

    
2197
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2198
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2199
        addAndAdaptElement(parentElement, element);
2200
        return element;
2201
    }
2202

    
2203
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2204
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2205
        addAndAdaptElement(parentElement, element);
2206
        return element;
2207
    }
2208

    
2209
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2210
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2211
        addAndAdaptElement(parentElement, element);
2212
        return element;
2213
    }
2214

    
2215
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2216
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2217
        addAndAdaptElement(parentElement, element);
2218
        return element;
2219
    }
2220

    
2221
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2222
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2223
        addAndAdaptElement(parentElement, element);
2224
        return element;
2225
    }
2226

    
2227
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2228
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2229
        addAndAdaptElement(parentElement, element);
2230
        return element;
2231
    }
2232

    
2233
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2234
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2235
        addAndAdaptElement(parentElement, element);
2236
        return element;
2237
    }
2238

    
2239
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2240
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2241
        addAndAdaptElement(parentElement, element);
2242
        return element;
2243
    }
2244

    
2245
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2246
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2247
        addAndAdaptElement(parentElement, mediaDetailElement);
2248
        return mediaDetailElement;
2249
    }
2250

    
2251
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2252
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2253
        addAndAdaptElement(parentElement, element);
2254
        return element;
2255
    }
2256

    
2257
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2258
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2259
        addAndAdaptElement(parentElement, element);
2260
        return element;
2261
    }
2262

    
2263
    public SpecimenHierarchyDetailElement createSpecimenHierarchyDetailElement(ICdmFormElement parentElement) {
2264
        SpecimenHierarchyDetailElement element = new SpecimenHierarchyDetailElement(this, parentElement);
2265
        addAndAdaptElement(parentElement, element);
2266
        return element;
2267
    }
2268

    
2269
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2270
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2271
        addAndAdaptElement(parentElement, element);
2272
        return element;
2273
    }
2274

    
2275
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2276
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2277
        addAndAdaptElement(parentElement, element);
2278
        return element;
2279
    }
2280

    
2281
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2282
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2283
        addAndAdaptElement(parentElement, element);
2284
        return element;
2285
    }
2286

    
2287
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2288
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2289
        addAndAdaptElement(parentElement, element);
2290
        return element;
2291
    }
2292

    
2293
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2294
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2295
        addAndAdaptElement(parentElement, element);
2296
        return element;
2297
    }
2298

    
2299
    /**
2300
     * @param parentElement
2301
     * @param element
2302
     */
2303
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2304
        adapt(element);
2305
        parentElement.addElement(element);
2306
    }
2307

    
2308
    //--------EntityCollectionSection----------
2309
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2310
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2311
        addAndAdaptSection(parentElement, section);
2312
        return section;
2313
    }
2314

    
2315
    public AnnotationSection createAnnotationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2316
        AnnotationSection section = new AnnotationSection(this, conversation, parentElement, style);
2317
        addAndAdaptSection(parentElement, section);
2318
        return section;
2319
    }
2320

    
2321
    public CreditSection createCreditSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2322
        CreditSection section = new CreditSection(this, conversation, parentElement, style);
2323
        addAndAdaptSection(parentElement, section);
2324
        return section;
2325
    }
2326

    
2327
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2328
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2329
        addAndAdaptSection(parentElement, section);
2330
        return section;
2331
    }
2332

    
2333
    public ExtensionSection createExtensionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2334
        ExtensionSection section = new ExtensionSection(this, conversation, parentElement, style);
2335
        addAndAdaptSection(parentElement, section);
2336
        return section;
2337
    }
2338

    
2339
    public MarkerSection createMarkerSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2340
        MarkerSection section = new MarkerSection(this, conversation, parentElement, style);
2341
        addAndAdaptSection(parentElement, section);
2342
        return section;
2343
    }
2344

    
2345
    public MediaSection createMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2346
        MediaSection section = new MediaSection(this, conversation, parentElement, style);
2347
        addAndAdaptSection(parentElement, section);
2348
        return section;
2349
    }
2350

    
2351
    public DescriptionElementMediaSection createDescriptionElementMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2352
        DescriptionElementMediaSection section = new DescriptionElementMediaSection(this, conversation, parentElement, style);
2353
        addAndAdaptSection(parentElement, section);
2354
        return section;
2355
    }
2356

    
2357
    public MediaRepresentationSection createMediaRepresentationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2358
        MediaRepresentationSection section = new MediaRepresentationSection(this, conversation, parentElement, style);
2359
        addAndAdaptSection(parentElement, section);
2360
        return section;
2361
    }
2362

    
2363
    public MediaRepresentationPartSection createMediaRepresentationPartSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2364
        MediaRepresentationPartSection section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
2365
        addAndAdaptSection(parentElement, section);
2366
        return section;
2367
    }
2368

    
2369
    public ModifierSection createModifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2370
        ModifierSection section = new ModifierSection(this, conversation, parentElement, style);
2371
        addAndAdaptSection(parentElement, section);
2372
        return section;
2373
    }
2374

    
2375
    public NomenclaturalStatusSection createNomenclaturalStatusSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2376
        NomenclaturalStatusSection section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
2377
        addAndAdaptSection(parentElement, section);
2378
        return section;
2379
    }
2380

    
2381
    public NameRelationshipDetailSection createNameRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2382
        NameRelationshipDetailSection section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
2383
        addAndAdaptSection(parentElement, section);
2384
        return section;
2385
    }
2386

    
2387
    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2388
        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2389
        addAndAdaptSection(parentElement, section);
2390
        return section;
2391
    }
2392

    
2393
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2394
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2395
        addAndAdaptSection(parentElement, section);
2396
        return section;
2397
    }
2398

    
2399
    public SourceSection createSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2400
        SourceSection section = new SourceSection(this, conversation, parentElement, style);
2401
        addAndAdaptSection(parentElement, section);
2402
        return section;
2403
    }
2404

    
2405
    public ScopeSection createScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2406
        ScopeSection section = new ScopeSection(this, conversation, parentElement, style);
2407
        addAndAdaptSection(parentElement, section);
2408
        return section;
2409
    }
2410

    
2411
    public DescriptionSourceSection createDescriptionSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2412
        DescriptionSourceSection section = new DescriptionSourceSection(this, conversation, parentElement, style);
2413
        addAndAdaptSection(parentElement, section);
2414
        return section;
2415
    }
2416

    
2417
    public TypeDesignationSection createTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2418
        TypeDesignationSection section = new TypeDesignationSection(this, conversation, parentElement, style);
2419
        addAndAdaptSection(parentElement, section);
2420
        return section;
2421
    }
2422

    
2423
    public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2424
        StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
2425
        addAndAdaptSection(parentElement, section);
2426
        return section;
2427
    }
2428

    
2429
    public StatisticalMeasurementValueSection createStatisticalMeasurementValueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2430
        StatisticalMeasurementValueSection section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
2431
        addAndAdaptSection(parentElement, section);
2432
        return section;
2433
    }
2434

    
2435
    public DescribedSpecimenSection createDescribedSpecimenSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2436
        DescribedSpecimenSection section = new DescribedSpecimenSection(this, conversation, parentElement, style);
2437
        addAndAdaptSection(parentElement, section);
2438
        return section;
2439
    }
2440

    
2441
    public StateVocabularyCollectionSection createStateVocabulariesSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2442
        StateVocabularyCollectionSection section = new StateVocabularyCollectionSection(this, conversation, parentElement, style);
2443
        addAndAdaptSection(parentElement, section);
2444
        return section;
2445
    }
2446

    
2447
    public RecommendedModifierVocabulariesCollectionSection createRecommendedModifierVocabulariesCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2448
        RecommendedModifierVocabulariesCollectionSection section = new RecommendedModifierVocabulariesCollectionSection(this, conversation, parentElement, style);
2449
        addAndAdaptSection(parentElement, section);
2450
        return section;
2451
    }
2452

    
2453
    public MeasurementUnitCollectionSection createMeasurementUnitCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2454
        MeasurementUnitCollectionSection section = new MeasurementUnitCollectionSection(this, conversation, parentElement, style);
2455
        addAndAdaptSection(parentElement, section);
2456
        return section;
2457
    }
2458

    
2459
    public StatisticalMeasureCollectionSection createStatisticalMeasureCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2460
        StatisticalMeasureCollectionSection section = new StatisticalMeasureCollectionSection(this, conversation, parentElement, style);
2461
        addAndAdaptSection(parentElement, section);
2462
        return section;
2463
    }
2464

    
2465
    public CollectingAreasDetailSection createCollectingAreasDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2466
        CollectingAreasDetailSection section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
2467
        addAndAdaptSection(parentElement, section);
2468
        return section;
2469
    }
2470

    
2471
    public GeoScopeDetailSection createGeoScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2472
        GeoScopeDetailSection section = new GeoScopeDetailSection(this, conversation, parentElement, style);
2473
        addAndAdaptSection(parentElement, section);
2474
        return section;
2475
    }
2476

    
2477
    public GeoScopePolyKeyDetailSection createGeoScopePolyKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2478
        GeoScopePolyKeyDetailSection section = new GeoScopePolyKeyDetailSection(this, conversation, parentElement, style);
2479
        addAndAdaptSection(parentElement, section);
2480
        return section;
2481
    }
2482

    
2483
    public IdentifierSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2484
        IdentifierSection section = new IdentifierSection(this, conversation, parentElement, style);
2485
        addAndAdaptSection(parentElement, section);
2486
        return section;
2487
    }
2488

    
2489
    public DerivedUnitFacadeIdentifierSection createDerivedUnitFacadeIdentifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2490
    	DerivedUnitFacadeIdentifierSection section = new DerivedUnitFacadeIdentifierSection(this, conversation, parentElement, style);
2491
    	addAndAdaptSection(parentElement, section);
2492
    	return section;
2493
    }
2494

    
2495
    public CurrentSampleDesignationDetailSection createCurrentSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2496
        CurrentSampleDesignationDetailSection section = new CurrentSampleDesignationDetailSection(this, conversation, parentElement, style);
2497
        addAndAdaptSection(parentElement, section);
2498
        return section;
2499
    }
2500

    
2501
    public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2502
        CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
2503
        addAndAdaptSection(parentElement, section);
2504
        return section;
2505
    }
2506

    
2507
    public PreservedSpecimenCurrentDeterminationDetailSection createPreservedSpecimenCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2508
        PreservedSpecimenCurrentDeterminationDetailSection section = new PreservedSpecimenCurrentDeterminationDetailSection(this, conversation, parentElement, style);
2509
        addAndAdaptSection(parentElement, section);
2510
        return section;
2511
    }
2512

    
2513
    public SampleDesignationHistoryDetailSection createSampleDesignationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2514
        SampleDesignationHistoryDetailSection section = new SampleDesignationHistoryDetailSection(this, conversation, parentElement, style);
2515
        addAndAdaptSection(parentElement, section);
2516
        return section;
2517
    }
2518

    
2519
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2520
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
2521
        addAndAdaptSection(parentElement, section);
2522
        return section;
2523
    }
2524

    
2525
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2526
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
2527
        addAndAdaptSection(parentElement, section);
2528
        return section;
2529
    }
2530

    
2531
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2532
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2533
        addAndAdaptSection(parentElement, section);
2534
        return section;
2535
    }
2536

    
2537
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2538
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2539
        addAndAdaptSection(parentElement, section);
2540
        return section;
2541
    }
2542

    
2543
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2544
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2545
        addAndAdaptSection(parentElement, section);
2546
        return section;
2547
    }
2548

    
2549
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2550
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2551
        addAndAdaptSection(parentElement, section);
2552
        return section;
2553
    }
2554

    
2555
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2556
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2557
        addAndAdaptSection(parentElement, section);
2558
        return section;
2559
    }
2560

    
2561
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2562
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2563
        addAndAdaptSection(parentElement, section);
2564
        return section;
2565
    }
2566

    
2567
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2568
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2569
        addAndAdaptSection(parentElement, section);
2570
        return section;
2571
    }
2572

    
2573

    
2574
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2575
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2576
        AbstractEntityCollectionElement element = null;
2577

    
2578
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2579

    
2580
        if (entity instanceof Annotation) {
2581
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2582
        }else if (entity instanceof Person ) {
2583
            boolean isNomenclatural = false;
2584
            if (parentElement instanceof TeamMemberSection){
2585
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2586
            }
2587
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2588
        } else if (entity instanceof Credit) {
2589
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2590
        } else if (entity instanceof Extension) {
2591
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2592
        } else if (entity instanceof Marker) {
2593
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2594
        } else if (entity instanceof TaxonNodeAgentRelation) {
2595
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2596
        }else if (entity instanceof Media) {
2597
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2598
        } else if (entity instanceof MediaRepresentation) {
2599
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2600
                    style);
2601
        } else if (entity instanceof ImageFile) {
2602
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2603
        } else if (entity instanceof MediaRepresentationPart) {
2604
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2605
                    removeListener, style);
2606
        } else if (entity instanceof NomenclaturalStatus) {
2607
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2608
                    style);
2609
        } else if (entity instanceof Rights) {
2610
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2611
        } else if (entity instanceof DescriptionElementSource) {
2612
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2613
                    removeListener, style);
2614
        } else if (entity instanceof TaxonNodeAgentRelation) {
2615
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2616
                    removeListener,backgroundColor, style);
2617
        }
2618
        else if (entity instanceof IdentifiableSource) {
2619
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2620
                    style);
2621
        } else if (entity instanceof DefinedTerm) {
2622
            switch(((DefinedTerm)entity).getTermType()) {
2623
            case Scope:
2624
                element = new ScopeElement(this,
2625
                        parentElement,
2626
                        (DefinedTerm) entity,
2627
                        removeListener,
2628
                        style);
2629
                break;
2630
            case Modifier:
2631
                element = new ModifierElement(this,
2632
                        parentElement,
2633
                        (DefinedTerm) entity,
2634
                        removeListener,
2635
                        style);
2636
                break;
2637
            default:
2638
                break;
2639

    
2640
            }
2641
        } else if (entity instanceof Reference) {
2642
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2643
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2644
            }
2645
            else{
2646
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2647
            }
2648
        } else if (entity instanceof NameTypeDesignation) {
2649
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2650
                    style);
2651
        } else if (entity instanceof NameRelationship) {
2652
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2653
                    style);
2654
        } else if (entity instanceof SpecimenTypeDesignation) {
2655
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
2656
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2657
                        removeListener, style);
2658
            }
2659
            else{
2660
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2661
                        removeListener, style);
2662
            }
2663
        } else if (entity instanceof StateData) {
2664
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2665
        } else if (entity instanceof StatisticalMeasurementValue) {
2666
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2667
                    removeListener, style);
2668
        } else if (entity instanceof DerivedUnit) {
2669
            switch(((DerivedUnit)entity).getRecordBasis()) {
2670
            case LivingSpecimen:
2671
            case PreservedSpecimen:
2672
            case OtherSpecimen:
2673
                element = new SpecimenCollectionDetailElement(this,
2674
                        parentElement,
2675
                        (DerivedUnit) entity,
2676
                        removeListener,
2677
                        style);
2678
                break;
2679
            default:
2680
                element = new DerivedUnitElement(this,
2681
                        parentElement,
2682
                        (DerivedUnit) entity,
2683
                        removeListener,
2684
                        style);
2685
            }
2686

    
2687
        } else if (entity instanceof NamedArea) {
2688
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2689
        } else if (entity instanceof DeterminationEvent) {
2690
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2691
        } else if (entity instanceof User) {
2692
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2693
        } else if (entity instanceof GrantedAuthority) {
2694
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
2695
                    removeListener, style);
2696
        } else if (entity instanceof Group) {
2697
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2698
        } else if (entity instanceof Taxon) {
2699
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2700
        } else if (entity instanceof DescriptionElementBase) {
2701
            // this is the special case for protologs, maybe we can do this
2702
            // differently when API improves
2703
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2704
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2705
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2706
            }
2707
        } else if (entity instanceof Identifier) {
2708
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2709
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2710
            }
2711
            else{
2712
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
2713
            }
2714
        } else if (entity instanceof TermVocabulary) {
2715
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
2716
            switch (termVocabulary.getTermType()) {
2717
            case State:
2718
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
2719
                break;
2720
            case Modifier:
2721
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
2722
                break;
2723
            default:
2724
                break;
2725
            }
2726
        } else if (entity instanceof MeasurementUnit) {
2727
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2728
        } else if (entity instanceof StatisticalMeasure) {
2729
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2730
        }
2731

    
2732
        //check for parent section when entity is null
2733
        //this happens when AbstractUnboundEntityCollectionSection is used
2734
        if(entity==null){
2735
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
2736
                element = new ScopeElement(this,
2737
                        parentElement,
2738
                        (DefinedTerm) entity,
2739
                        removeListener,
2740
                        style);
2741
            }
2742
            else if(parentElement instanceof ModifierSection){
2743
                element = new ModifierElement(this,
2744
                        parentElement,
2745
                        (DefinedTerm) entity,
2746
                        removeListener,
2747
                        style);
2748
            }
2749
        }
2750

    
2751

    
2752
        if (element == null) {
2753
            MessagingUtils.messageDialog("No element for entity", this,
2754
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2755
                            + entity, null);
2756
        }
2757

    
2758
        else{
2759
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2760
                element.setPersistentBackground(backgroundColor);
2761
            }
2762
            adapt(element);
2763
            parentElement.addElement(element);
2764
        }
2765

    
2766
        return element;
2767
    }
2768

    
2769
    /**
2770
     * <p>
2771
     * Creates a selection element for the given type T.
2772
     * </p>
2773
     * <p>
2774
     * <strong>Selection elements not handled by this method:</strong>
2775
     * <ul>
2776
     * <li>{@link TaxonNodeSelectionElement} see
2777
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2778
     * </li>
2779
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2780
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2781
     * </li>
2782
     * </ul>
2783
     * </p>
2784
     *
2785
     * @param clazz
2786
     *            a {@link Class} object of the type that you want the selection
2787
     *            element to handle
2788
     * @param parentElement
2789
     *            a {@link ICdmFormElement} object.
2790
     * @param labelString
2791
     *            a {@link String} object.
2792
     * @param selectionType
2793
     * @param selection
2794
     *            a {@link ICdmBase} object.
2795
     * @param style
2796
     *            a int.
2797
     * @param conversation
2798
     *            a {@link ConversationHolder} object.
2799
     * @return a {@link EntitySelectionElement} object.
2800
     */
2801
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2802
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2803
            int style, boolean filterElement) {
2804
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
2805
                parentElement, clazz,
2806
                labelString, selection, mode, style, filterElement);
2807
        adapt(element);
2808
        parentElement.addElement(element);
2809
        return element;
2810
    }
2811

    
2812
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2813
//            ConversationHolder conversation,
2814
            ICdmFormElement parentElement, String labelString, T selection, int mode,
2815
            int style) {
2816
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
2817
                parentElement, clazz,
2818
                labelString, selection, mode, style);
2819
        adapt(element);
2820
        parentElement.addElement(element);
2821
        return element;
2822
    }
2823

    
2824
    /**
2825
     * <p>
2826
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
2827
     * </p>
2828
     * <p>
2829
     * <strong>Selection elements not handled by this method:</strong>
2830
     * <ul>
2831
     * <li>{@link TaxonNodeSelectionElement} see
2832
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2833
     * </li>
2834
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2835
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2836
     * </li>
2837
     * </ul>
2838
     * </p>
2839
     *
2840
     * @param clazz
2841
     *            a {@link Class} object of the type that you want the selection
2842
     *            element to handle
2843
     * @param parentElement
2844
     *            a {@link ICdmFormElement} object.
2845
     * @param labelString
2846
     *            a {@link String} object.
2847
     * @param selectionType
2848
     * @param selection
2849
     *            a {@link ICdmBase} object.
2850
     * @param style
2851
     *            a int.
2852
     * @param conversation
2853
     *            a {@link ConversationHolder} object.
2854
     * @return a {@link EntitySelectionElement} object.
2855
     */
2856
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
2857
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
2858
            T selection, int mode, int style) {
2859
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, //conversation,
2860
                parentElement, clazz,
2861
                labelString, selection, mode, style);
2862
        adapt(element);
2863
        parentElement.addElement(element);
2864
        return element;
2865
    }
2866

    
2867
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2868
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2869
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
2870
                parentElement,
2871
                labelString, selection, mode, style);
2872
        adapt(element);
2873
        parentElement.addElement(element);
2874
        return element;
2875
    }
2876

    
2877
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2878
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2879
//            int mode, int style) {
2880
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2881
//                conversation, parentElement, labelString, selection, mode, style);
2882
//        adapt(element);
2883
//        parentElement.addElement(element);
2884
//        return element;
2885
//    }
2886

    
2887
    /** {@inheritDoc} */
2888
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2889
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2890
        adapt(labelElement);
2891
        parentElement.addElement(labelElement);
2892
        return labelElement;
2893
    }
2894

    
2895
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2896
//        Label label = new Label(formElement.getLayoutComposite(), style);
2897
//        label.setText(labelText+" (yyyy-MM-dd)");
2898
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
2899
//        dateElement.initInternalController();
2900
//
2901
//        return dateElement;
2902
//    }
2903

    
2904
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
2905
    	 Label label = new Label(formElement.getLayoutComposite(), style);
2906
         label.setText(labelText);
2907
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2908
         DateElement dateElement = new DateElement(this, formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
2909
         dateElement.initController(this, formElement);
2910
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2911
         return dateElement;
2912
    }
2913

    
2914
    /**
2915
     * <p>
2916
     * Getter for the field <code>selectionProvider</code>.
2917
     * </p>
2918
     *
2919
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2920
     */
2921
    public ISelectionProvider getSelectionProvider() {
2922
        return selectionProvider;
2923
    }
2924

    
2925
    /**
2926
     * <p>
2927
     * createDetailedDescriptionDetailElement
2928
     * </p>
2929
     *
2930
     * @param parentElement
2931
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2932
     *            object.
2933
     * @param entity
2934
     *            a
2935
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2936
     *            object.
2937
     * @param style
2938
     *            a int.
2939
     * @return a
2940
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2941
     *         object.
2942
     */
2943
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2944
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2945
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2946

    
2947
        if (entity instanceof CategoricalData) {
2948
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2949
                    (CategoricalData) entity, style);
2950
        } else if (entity instanceof CommonTaxonName) {
2951
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2952
                    style);
2953
        } else if (entity instanceof Distribution ) {
2954
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2955
                    style);
2956
        } else if (entity instanceof IndividualsAssociation) {
2957
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2958
                    (IndividualsAssociation) entity, style);
2959
        } else if (entity instanceof QuantitativeData) {
2960
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2961
                    (QuantitativeData) entity, style);
2962
        } else if (entity instanceof TaxonInteraction) {
2963
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2964
                    (TaxonInteraction) entity, style);
2965
        } else if (entity instanceof TextData) {
2966
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2967
        } else {
2968
            throw new IllegalStateException("There is no interface for the given description element");
2969
        }
2970
        adapt(detailedDescriptionElement);
2971
        parentElement.addElement(detailedDescriptionElement);
2972
        return detailedDescriptionElement;
2973

    
2974
    }
2975

    
2976
    /**
2977
     * Creates a styled text as a part of the form.
2978
     *
2979
     * @param parent
2980
     *            the text parent
2981
     * @param value
2982
     *            the text initial value
2983
     * @param style
2984
     *            the text style
2985
     * @return the text widget
2986
     */
2987
    public StyledText createStyledText(Composite parent, String value, int style) {
2988
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2989
        if (value != null) {
2990
            text.setText(value);
2991
        }
2992
        text.setForeground(getColors().getForeground());
2993
        text.setBackground(getColors().getBackground());
2994
        // text.addFocusListener(visibilityHandler);
2995
        return text;
2996
    }
2997

    
2998
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2999
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3000
        addAndAdaptSection(parentElement, section);
3001
        return section;
3002
    }
3003

    
3004
    /**
3005
     * @param formElement
3006
     * @param conversationHolder
3007
     * @param style
3008
     * @return
3009
     */
3010
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3011
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3012
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3013
        addAndAdaptSection(formElement, section);
3014
        return section;
3015
    }
3016

    
3017

    
3018
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3019
			ICdmFormElement parentElement, int style) {
3020
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3021
		addAndAdaptElement(parentElement, section);
3022
        return section;
3023
	}
3024

    
3025
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3026
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3027
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3028
	        addAndAdaptSection(formElement, section);
3029
	        return section;
3030
	}
3031

    
3032

    
3033

    
3034
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3035
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3036
//				 initialText, textHeight, style);
3037
//	        adapt(element);
3038
//	        parentElement.addElement(element);
3039
//	        return element;
3040
//	}
3041

    
3042

    
3043

    
3044

    
3045

    
3046

    
3047

    
3048
}
(7-7/45)