Project

General

Profile

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

    
356
/**
357
 * <p>
358
 * CdmFormFactory class.
359
 * </p>
360
 *
361
 * @author n.hoffmann
362
 * @created Feb 24, 2010
363
 * @version 1.0
364
 */
365
public class CdmFormFactory extends FormToolkit {
366

    
367
    private BoldFontHolder2 boldFontHolder2;
368
    private MouseListener selectionMouseHandler;
369
    private FocusListener selectionFocusHandler;
370

    
371
    @Inject
372
    private IEclipseContext context;
373

    
374
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
375

    
376
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
377

    
378
    private final int orientation = Window.getDefaultOrientation();
379
    private ISelectionProvider selectionProvider;
380

    
381
    /** Constant <code>EMPTY_SELECTION</code> */
382
    public static ISelection EMPTY_SELECTION = new ISelection() {
383
        @Override
384
        public boolean isEmpty() {
385
            return true;
386
        }
387
    };
388

    
389
    /**
390
     *
391
     * @author n.hoffmann
392
     * @date Jan 25, 2010
393
     *
394
     */
395
    private class SelectionMouseHandler extends MouseAdapter {
396
        @Override
397
        public void mouseDown(MouseEvent e) {
398
            notifySelectionListeners(e);
399
        }
400
    }
401

    
402
    /**
403
     *
404
     * @author n.hoffmann
405
     * @date Jan 25, 2010
406
     *
407
     */
408
    private class SelectionFocusHandler extends FocusAdapter {
409
        @Override
410
        public void focusGained(FocusEvent e) {
411
            notifySelectionListeners(e);
412
        }
413
    }
414

    
415
    private void notifySelectionListeners(TypedEvent e) {
416
        Event event = new Event();
417
        event.widget = e.widget;
418
        SelectionEvent selectionEvent = new SelectionEvent(event);
419

    
420
        for (SelectionListener listener : selectionListenerList) {
421
            listener.widgetSelected(selectionEvent);
422
        }
423
    }
424

    
425
    public CdmFormFactory(Display display) {
426
        this(display, null);
427
    }
428

    
429
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
430
        super(display);
431
        this.selectionProvider = selectionProvider;
432
        init();
433
    }
434

    
435
    private void init() {
436
        boldFontHolder2 = new BoldFontHolder2();
437
        selectionMouseHandler = new SelectionMouseHandler();
438
        selectionFocusHandler = new SelectionFocusHandler();
439
    }
440

    
441
    public IEclipseContext getContext() {
442
        return context;
443
    }
444

    
445
    /**
446
     * Creates an instance initialized with the correct selectionProvider
447
     *
448
     * Make sure to remove the instance when the entityComposite disposes via
449
     * destroySelectionArbitrator(..)
450
     *
451
     * @param entityElement
452
     *            a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
453
     *            object.
454
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
455
     *         object.
456
     */
457
    public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
458
        SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
459
        selectionArbitrator.addSelectionProvider(selectionProvider);
460
        selectionProvider.addSelectionChangedListener(selectionArbitrator);
461
        addSelectionListener(selectionArbitrator);
462
        return selectionArbitrator;
463
    }
464

    
465
    /**
466
     * <p>
467
     * destroySelectionArbitrator
468
     * </p>
469
     *
470
     * @param selectionArbitrator
471
     *            a
472
     *            {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
473
     *            object.
474
     */
475
    public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
476
        removeSelectionListener(selectionArbitrator);
477
        if (selectionProvider != null) {
478
            selectionProvider.removeSelectionChangedListener(selectionArbitrator);
479
        } else {
480
            MessagingUtils.error(this.getClass(),
481
                    "Tried to destroy a selection listener from this factories listeners but was null", null);
482
        }
483
    }
484

    
485
    /**
486
     * <p>
487
     * Adapts the {@link AbstractCdmFormElement}:<br>
488
     * - sets the {@link IPropertyChangeListener}s handled by this class
489
     * </p>
490
     *
491
     * @param formElement
492
     *            a
493
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
494
     *            object.
495
     */
496
    public void adapt(ICdmFormElement formElement) {
497
        formElement.setPropertyChangeListeners(propertyChangeListeners);
498
    }
499

    
500
    /** {@inheritDoc} */
501
    @Override
502
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
503
        if (trackFocus) {
504
            control.addFocusListener(selectionFocusHandler);
505
        }
506
        super.adapt(control, trackFocus, trackKeyboard);
507
    }
508

    
509
    /** {@inheritDoc} */
510
    @Override
511
    public void adapt(Composite composite) {
512
        composite.addMouseListener(selectionMouseHandler);
513

    
514
        super.adapt(composite);
515
    }
516

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

    
560
    /**
561
     * <p>
562
     * createEmptyCell
563
     * </p>
564
     *
565
     * @param parent
566
     *            a {@link org.eclipse.swt.widgets.Composite} object.
567
     * @return a {@link org.eclipse.swt.widgets.Label} object.
568
     */
569
    public Label createEmptyCell(Composite parent) {
570
        return this.createLabel(parent, null);
571
    }
572

    
573
    /**
574
     * <p>
575
     * createMultiLanguageTextElement
576
     * </p>
577
     *
578
     * @param parentElement
579
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
580
     *            object.
581
     * @param labelString
582
     *            a {@link java.lang.String} object.
583
     * @param multilanguageText
584
     *            a {@link java.util.Map} object.
585
     * @param textHeight
586
     *            a int.
587
     * @param style
588
     *            a int.
589
     * @return a
590
     *         {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
591
     *         object.
592
     */
593
    public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
594
            Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
595
        MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
596
                multilanguageText, textHeight, style);
597
        adapt(element);
598
        parentElement.addElement(element);
599
        return element;
600
    }
601

    
602
    /**
603
     * <p>
604
     * createMultiLanguageTextElement
605
     * </p>
606
     *
607
     * @param parentElement
608
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
609
     *            object.
610
     *
611
     * @param Representation
612
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
613
     * @param textHeight
614
     *            a int.
615
     * @param style
616
     *            a int.
617
     * @return a
618
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
619
     *         object.
620
     */
621
    public RepresentationElement createRepresentationElement(ICdmFormElement parentElement, Representation representation, TermBase term,int textHeight, int style, boolean fillDetails) {
622
        RepresentationElement element = new RepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
623
        adapt(element);
624
        parentElement.addElement(element);
625
        return element;
626
    }
627

    
628
    /**
629
     * <p>
630
     * createMultiLanguageTextElement
631
     * </p>
632
     *
633
     * @param parentElement
634
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
635
     *            object.
636
     *
637
     * @param Representation
638
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
639
     * @param textHeight
640
     *            a int.
641
     * @param style
642
     *            a int.
643
     * @return a
644
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
645
     *         object.
646
     */
647
    public TranslatableRepresentationElement createTranslatableRepresentationElement(ICdmFormElement parentElement, Representation representation, TermBase term,int textHeight, int style, boolean fillDetails) {
648
        TranslatableRepresentationElement element = new TranslatableRepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
649
        adapt(element);
650
        parentElement.addElement(element);
651
        return element;
652
    }
653

    
654
    /**
655
     * <p>
656
     * createMultiLanguageTextElement
657
     * </p>
658
     *
659
     * @param parentElement
660
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
661
     *            object.
662
     *
663
     * @param term
664
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
665
     * @param textHeight
666
     *            a int.
667
     * @param style
668
     *            a int.
669
     * @return a
670
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
671
     *         object.
672
     */
673
    public RepresentationElement createRepresentationElement(ICdmFormElement parentElement, TermBase term, int textHeight, int style, boolean fillDetails) {
674
        RepresentationElement element = new RepresentationElement(this, parentElement, term, textHeight, style, fillDetails);
675
        adapt(element);
676
        parentElement.addElement(element);
677
        return element;
678
    }
679

    
680
    /**
681
     * <p>
682
     * createMultiLanguageTextElement
683
     * </p>
684
     *
685
     * @param parentElement
686
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
687
     *            object.
688
     *
689
     * @param term
690
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
691
     * @param textHeight
692
     *            a int.
693
     * @param style
694
     *            a int.
695
     * @return a
696
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
697
     *         object.
698
     */
699
    public TranslatableRepresentationElement createTranslatableRepresentationElement(ICdmFormElement parentElement, TermBase term, int textHeight, int style, boolean fillDetails) {
700
        TranslatableRepresentationElement element = new TranslatableRepresentationElement(this, parentElement, term, textHeight, style, fillDetails);
701
        adapt(element);
702
        parentElement.addElement(element);
703
        return element;
704
    }
705

    
706
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
707
            KeyStatement keyStatement, int textHeight, int style) {
708
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
709
                textHeight, style);
710
        adapt(element);
711
        parentElement.addElement(element);
712
        return element;
713
    }
714

    
715
    /**
716
     * Creates a text field with a label. The initial content will be the return value of the initalObject's {@link #toString()}
717
     * method.<br>
718
     * <b>Note</b>: if initialObject is <code>null</code> then an empty string is used.
719
     * @param parentElement the parent container
720
     * @param labelString the label name
721
     * @param initialObject the object from which the <code>toString()</code> method is called
722
     * @param style {@link SWT} style constant
723
     * @return the created textfield with label
724
     */
725
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
726
            Object initialObject, int style) {
727
        return createTextWithLabelElement(parentElement, labelString, initialObject==null?"":initialObject.toString(), style);
728
    }
729

    
730
    /**
731
     * <p>
732
     * createTextWithLabelElement
733
     * </p>
734
     *
735
     * @param parentElement
736
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
737
     *            object.
738
     * @param labelString
739
     *            a {@link java.lang.String} object.
740
     * @param initialText
741
     *            a {@link java.lang.String} object.
742
     * @param style
743
     *            a int.
744
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
745
     *         object.
746
     */
747
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
748
            String initialText, int style) {
749
        return createTextWithLabelElement(parentElement, labelString, initialText, null, style);
750
    }
751
    /**
752
     * <p>
753
     * createTextWithLabelElement
754
     * </p>
755
     *
756
     * @param parentElement
757
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
758
     *            object.
759
     * @param labelString
760
     *            a {@link java.lang.String} object.
761
     * @param initialText
762
     *            a {@link java.lang.String} object.
763
     * @param textLimit maximal number of characters allowed
764
     * @param style
765
     *            a int.
766
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
767
     *         object.
768
     */
769
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
770
            String initialText, Integer textLimit, int style) {
771
        if(initialText==null){
772
            initialText = "";
773
        }
774

    
775
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
776
                textLimit, style);
777
        adapt(element);
778
        parentElement.addElement(element);
779
        return element;
780
    }
781

    
782
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
783
            int textHeight, int style) {
784
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
785
        adapt(element);
786
        parentElement.addElement(element);
787
        return element;
788
    }
789

    
790
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
791
            LSID initialLsid, int style) {
792
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
793
        adapt(element);
794
        parentElement.addElement(element);
795
        return element;
796
    }
797

    
798
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
799
            URI initialUri, int style) {
800
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
801
        adapt(element);
802
        parentElement.addElement(element);
803
        return element;
804
    }
805

    
806
    /**
807
     * @param element
808
     * @param string
809
     * @param uri
810
     * @param style
811
     * @return
812
     */
813
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
814
            IOpenUrlEnabled openUrlEnabled, int style) {
815
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
816
                style);
817
        adapt(element);
818
        parentElement.addElement(element);
819
        return element;
820
    }
821

    
822
    /**
823
     *
824
     * @param parentElement
825
     * @param labelString
826
     * @param conversationEnabled
827
     * @param user
828
     * @param style
829
     * @return
830
     */
831
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
832
            ConversationHolder conversation, User user, int style) {
833
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
834
        adapt(element);
835
        parentElement.addElement(element);
836
        return element;
837
    }
838

    
839
    /**
840
     * <p>
841
     * createIntegerTextWithLabelElement
842
     * </p>
843
     *
844
     * @param parentElement
845
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
846
     *            object.
847
     * @param labelString
848
     *            a {@link java.lang.String} object.
849
     * @param initialInteger
850
     *            a {@link java.lang.Integer} object.
851
     * @param style
852
     *            a int.
853
     * @return a
854
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
855
     *         object.
856
     */
857
	public NumberWithLabelElement createNumberTextWithLabelElement(
858
			ICdmFormElement parentElement, String labelString,
859
			Number initialNumber, int style) {
860
		NumberWithLabelElement element = new NumberWithLabelElement(this,
861
				parentElement, labelString, initialNumber, style);
862
		adapt(element);
863
		parentElement.addElement(element);
864
		return element;
865
	}
866

    
867
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
868
            String labelString, LanguageString languageString, int style) {
869
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
870
    }
871

    
872
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
873
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
874
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
875
                languageString, height, isMultiLine, style);
876
        adapt(element);
877
        parentElement.addElement(element);
878
        return element;
879
    }
880

    
881
    /**
882
     * <p>
883
     * createKeyValueViewerElement
884
     * </p>
885
     *
886
     * @param parentElement
887
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
888
     *            object.
889
     * @param keyHeading
890
     *            a {@link java.lang.String} object.
891
     * @param valueHeading
892
     *            a {@link java.lang.String} object.
893
     * @param map
894
     *            a {@link java.util.Map} object.
895
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
896
     *         object.
897
     */
898
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
899
            String valueHeading, Map<Object, Object> map) {
900
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
901
        adapt(element);
902
        parentElement.addElement(element);
903
        return element;
904
    }
905
    /**
906
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
907
     */
908
    @Deprecated
909
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
910
            ICdmFormElement parentElement, String labelString, T selection, int style) {
911
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString, selection, true, style);
912
        adapt(element);
913
        parentElement.addElement(element);
914
        return element;
915
    }
916

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

    
927
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
928
			TermType termType,
929
			ICdmFormElement parentElement,
930
			String labelString,
931
			T selection,
932
			boolean addEmptyElement,
933
			int style) {
934
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, false, null);
935
	}
936

    
937
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
938
			TermType termType,
939
			ICdmFormElement parentElement,
940
			String labelString,
941
			T selection,
942
			int style) {
943
		return  this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false, null);
944
	}
945
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
946
			TermType termType,
947
			ICdmFormElement parentElement,
948
			String labelString,
949
			T selection,
950
			boolean addEmptyElement,
951
			int style,
952
			boolean useAbbrevLabel) {
953
		return createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
954
	}
955

    
956

    
957
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
958
            TermVocabulary<?> termVocabulary,
959
            ICdmFormElement parentElement,
960
            String labelString,
961
            T selection,
962
            int style) {
963
        return this.createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, true, style, false, null);
964
    }
965

    
966
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
967
	        TermVocabulary<?> termVocabulary,
968
	        ICdmFormElement parentElement,
969
	        String labelString,
970
	        T selection,
971
	        boolean addEmptyElement,
972
	        int style,
973
	        boolean useAbbrevLabel) {
974
	    return createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
975
	}
976

    
977
	private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
978
	        TermType termType,
979
	        TermVocabulary<?> termVocabulary,
980
	        ICdmFormElement parentElement,
981
	        String labelString,
982
	        T selection,
983
	        boolean addEmptyElement,
984
	        int style,
985
	        boolean useAbbrevLabel,
986
	        Comparator<T> comparator) {
987
	    if(termType!=null){
988
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
989
	        adapt(element);
990
	        parentElement.addElement(element);
991
	        return element;
992
	    }
993
	    else if(termVocabulary!=null){
994
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
995
	        if (comparator!= null){
996
	        	element.setTermComparator(comparator);
997
	        }
998
	        adapt(element);
999
	        parentElement.addElement(element);
1000
	        return element;
1001
	    }
1002
	    else{
1003
	        //this should never happen
1004
	        return null;
1005
	    }
1006
	}
1007
	public MisappliedRelationshipComboElement createMisappliedRelationshipComboElement(
1008
	        ICdmFormElement parentElement,
1009
            String labelString,
1010
            TaxonRelationshipType selection,
1011
            int style) {
1012
	    MisappliedRelationshipComboElement combo = new MisappliedRelationshipComboElement(this, parentElement, labelString, selection, false, style, false);
1013
	    adapt(combo);
1014
        parentElement.addElement(combo);
1015
        return combo;
1016
    }
1017

    
1018
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1019
	        Class<T> enumComboType, ICdmFormElement parentElement,
1020
	        int style) {
1021
	    return createEnumComboElement(enumComboType, parentElement, null, style);
1022
	}
1023

    
1024
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1025
			Class<T> enumComboType, ICdmFormElement parentElement, Comparator<T> comparator,
1026
			int style) {
1027
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, comparator, style);
1028
        adapt(element);
1029
        parentElement.addElement(element);
1030
        return element;
1031
    }
1032

    
1033
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
1034
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
1035
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1036
	    adapt(element);
1037
	    parentElement.addElement(element);
1038
	    return element;
1039
	}
1040

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

    
1063
    /**
1064
     * <p>
1065
     * createImageElement
1066
     * </p>
1067
     *
1068
     * @param parentElement
1069
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1070
     *            object.
1071
     * @param imageUri
1072
     *            a {@link java.net.URI} object.
1073
     * @param style
1074
     *            a int.
1075
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1076
     */
1077
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1078
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1079
        adapt(element);
1080
        parentElement.addElement(element);
1081
        return element;
1082
    }
1083

    
1084
    /**
1085
     * <p>
1086
     * createTextActionElement
1087
     * </p>
1088
     *
1089
     * @param labelString
1090
     *            a {@link java.lang.String} object.
1091
     * @param initialText
1092
     *            a {@link java.lang.String} object.
1093
     * @param style
1094
     *            a int.
1095
     * @param parentElement
1096
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1097
     *            object.
1098
     * @param buttonLabel
1099
     *            a {@link java.lang.String} object.
1100
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
1101
     *         object.
1102
     */
1103
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
1104
            String buttonLabel, String initialText, int style) {
1105
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
1106
                style);
1107
        adapt(element);
1108
        parentElement.addElement(element);
1109
        return element;
1110
    }
1111

    
1112
    /**
1113
     * <p>
1114
     * createCheckbox
1115
     * </p>
1116
     *
1117
     * @param parentElement
1118
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1119
     *            object.
1120
     * @param label
1121
     *            a {@link java.lang.String} object.
1122
     * @param initialState
1123
     *            a boolean.
1124
     * @param style
1125
     *            a int.
1126
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1127
     *         object.
1128
     */
1129
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1130
        if(initialState==null){
1131
            initialState = Boolean.FALSE;
1132
        }
1133
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1134
        adapt(element);
1135
        parentElement.addElement(element);
1136
        return element;
1137
    }
1138

    
1139
    /**
1140
     * Creates a section as a part of the form.
1141
     *
1142
     * @return the section widget
1143
     * @param section
1144
     *            a
1145
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1146
     *            object.
1147
     */
1148
    public Section adapt(AbstractFormSection section) {
1149
        section.setMenu(section.getLayoutComposite().getMenu());
1150
        adapt(section, true, true);
1151

    
1152
        // handle focus and property change events for cdm use
1153
        section.addFocusListener(selectionFocusHandler);
1154
        section.setPropertyChangeListeners(propertyChangeListeners);
1155

    
1156
        if (section.getToggle() != null) {
1157
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1158
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1159
        }
1160

    
1161
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1162

    
1163
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1164
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1165
            getColors().initializeSectionToolBarColors();
1166
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1167
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1168
        }
1169
        // call setTitleBarForeground regardless as it also sets the label color
1170
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1171
        return section;
1172
    }
1173

    
1174
    private class BoldFontHolder2 {
1175
        private Font normalFont;
1176

    
1177
        private Font boldFont;
1178

    
1179
        public BoldFontHolder2() {
1180
        }
1181

    
1182
        public Font getBoldFont(Font font) {
1183
            createBoldFont(font);
1184
            return boldFont;
1185
        }
1186

    
1187
        private void createBoldFont(Font font) {
1188
            if (normalFont == null || !normalFont.equals(font)) {
1189
                normalFont = font;
1190
                dispose();
1191
            }
1192
            if (boldFont == null) {
1193
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1194
            }
1195
        }
1196

    
1197
        public void dispose() {
1198
            if (boldFont != null) {
1199
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1200
                boldFont = null;
1201
            }
1202
        }
1203
    }
1204

    
1205
    /**
1206
     * <p>
1207
     * createToggleableTextField
1208
     * </p>
1209
     *
1210
     * @param parentElement
1211
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1212
     *            object.
1213
     * @param labelString
1214
     *            a {@link java.lang.String} object.
1215
     * @param initialText
1216
     *            a {@link java.lang.String} object.
1217
     * @param initialState
1218
     *            a boolean.
1219
     * @param style
1220
     *            a int.
1221
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1222
     *         object.
1223
     */
1224
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1225
            String initialText, boolean initialState, int style) {
1226
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1227
                initialState, style | orientation);
1228
        adapt(element);
1229
        parentElement.addElement(element);
1230
        return element;
1231
    }
1232

    
1233
    /**
1234
     * <p>
1235
     * createTimePeriodElement
1236
     * </p>
1237
     *
1238
     * @param parentElement
1239
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1240
     *            object.
1241
     * @param labelString
1242
     *            a {@link java.lang.String} object.
1243
     * @param timePeriod
1244
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1245
     * @param style
1246
     *            a int.
1247
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1248
     *         object.
1249
     */
1250
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1251
            TimePeriod timePeriod, int style) {
1252
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1253
        adapt(element);
1254
        parentElement.addElement(element);
1255
        return element;
1256
    }
1257

    
1258
    /**
1259
     * <p>
1260
     * createVerbatimTimePeriodElement
1261
     * </p>
1262
     *
1263
     * @param parentElement
1264
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1265
     *            object.
1266
     * @param labelString
1267
     *            a {@link java.lang.String} object.
1268
     * @param timePeriod
1269
     *            a {@link eu.etaxonomy.cdm.model.common.VerbatimTimePeriod} object.
1270
     * @param style
1271
     *            a int.
1272
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.VerbatimTimePeriodElement}
1273
     *         object.
1274
     */
1275
    public VerbatimTimePeriodElement createVerbatimTimePeriodElement(ICdmFormElement parentElement, String labelString,
1276
            VerbatimTimePeriod timePeriod, int style) {
1277
        VerbatimTimePeriodElement element = new VerbatimTimePeriodElement(this, parentElement, labelString, timePeriod, style);
1278
        adapt(element);
1279
        parentElement.addElement(element);
1280
        return element;
1281
    }
1282

    
1283
	/**
1284
	 * <p>
1285
	 * createGatheringEventUnitElement
1286
	 * </p>
1287
	 *
1288
	 * @param parentElement
1289
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1290
	 *            object.
1291
	 * @param labelString
1292
	 *            a {@link java.lang.String} object.
1293
	 * @param timePeriod
1294
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1295
	 * @param style
1296
	 *            a int.
1297
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1298
	 *         object.
1299
	 */
1300
	public GatheringEventUnitElement createGatheringEventUnitElement(
1301
			ICdmFormElement parentElement,
1302
			String labelString,
1303
			DerivedUnitFacade gatheringEvent,
1304
			MinMaxTextSection.UnitType unitType,
1305
			int style) {
1306
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1307
				parentElement,
1308
				labelString,
1309
				gatheringEvent,
1310
				unitType,
1311
				style);
1312
		adapt(element);
1313
		parentElement.addElement(element);
1314
		return element;
1315
	}
1316

    
1317
    /**
1318
     * <p>
1319
     * createPointElement
1320
     * </p>
1321
     *
1322
     * @param style
1323
     *            a int.
1324
     * @param parentElement
1325
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1326
     *            object.
1327
     * @param point
1328
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1329
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1330
     */
1331
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1332
        PointElement element = new PointElement(this, parentElement, point, style);
1333
        adapt(element);
1334
        parentElement.addElement(element);
1335
        return element;
1336
    }
1337

    
1338

    
1339

    
1340
    /**
1341
     * @param conversationHolder
1342
     * @param parent
1343
     * @param detailsViewer
1344
     * @param i
1345
     * @return
1346
     */
1347
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1348
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1349
        parentElement.addElement(section);
1350
        adapt(section);
1351
        return section;
1352
    }
1353

    
1354
    /**
1355
     * <p>
1356
     * createDateDetailSection
1357
     * </p>
1358
     *
1359
     * @param parentElement
1360
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1361
     *            object.
1362
     * @param style
1363
     *            a int.
1364
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1365
     *         object.
1366
     */
1367
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1368
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1369
        parentElement.addElement(section);
1370
        adapt(section);
1371
        return section;
1372
    }
1373

    
1374
    /**
1375
     * <p>
1376
     * createVerbatimDateDetailSection
1377
     * </p>
1378
     *
1379
     * @param parentElement
1380
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1381
     *            object.
1382
     * @param style
1383
     *            a int.
1384
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.VerbatimDateDetailSection}
1385
     *         object.
1386
     */
1387
    public VerbatimDateDetailSection createVerbatimDateDetailSection(ICdmFormElement parentElement, int style) {
1388
        VerbatimDateDetailSection section = new VerbatimDateDetailSection(this, parentElement, style);
1389
        parentElement.addElement(section);
1390
        adapt(section);
1391
        return section;
1392
    }
1393

    
1394
	/**
1395
	 * <p>
1396
	 * createDateDetailSection
1397
	 * </p>
1398
	 *
1399
	 * @param parentElement
1400
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1401
	 *            object.
1402
	 * @param style
1403
	 *            a int.
1404
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1405
	 *         object.
1406
	 */
1407
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1408
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1409
		parentElement.addElement(section);
1410
		adapt(section);
1411
		return section;
1412
	}
1413

    
1414
    /**
1415
     * <p>
1416
     * createPartialElement
1417
     * </p>
1418
     *
1419
     * @param parentElement
1420
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1421
     *            object.
1422
     * @param labelString
1423
     *            a {@link java.lang.String} object.
1424
     * @param partial
1425
     *            a {@link org.joda.time.Partial} object.
1426
     * @param style
1427
     *            a int.
1428
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1429
     *         object.
1430
     */
1431
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1432
            int style) {
1433
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1434
        adapt(element);
1435
        parentElement.addElement(element);
1436
        return element;
1437
    }
1438

    
1439
    /**
1440
     * <p>
1441
     * addSelectionListener
1442
     * </p>
1443
     *
1444
     * @param listener
1445
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1446
     */
1447
    public void addSelectionListener(SelectionListener listener) {
1448
        selectionListenerList.add(listener);
1449
    }
1450

    
1451
    /**
1452
     * <p>
1453
     * removeSelectionListener
1454
     * </p>
1455
     *
1456
     * @param listener
1457
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1458
     */
1459
    public void removeSelectionListener(SelectionListener listener) {
1460
        if (listener == null) {
1461
            MessagingUtils.error(this.getClass(),
1462
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1463
        } else {
1464
            selectionListenerList.remove(listener);
1465
        }
1466
    }
1467

    
1468
    /**
1469
     * <p>
1470
     * addPropertyChangeListener
1471
     * </p>
1472
     *
1473
     * @param listener
1474
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1475
     *            object.
1476
     */
1477
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1478
        if (propertyChangeListeners.contains(listener)) {
1479
            return;
1480
        }
1481
        propertyChangeListeners.add(0, listener);
1482
    }
1483

    
1484
    /**
1485
     * <p>
1486
     * removePropertyChangeListener
1487
     * </p>
1488
     *
1489
     * @param listener
1490
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1491
     *            object.
1492
     */
1493
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1494
        propertyChangeListeners.remove(listener);
1495
    }
1496

    
1497
    /**
1498
     * @return the propertyChangeListeners
1499
     */
1500
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1501
        return propertyChangeListeners;
1502
    }
1503

    
1504
    /**
1505
     * <p>
1506
     * createHorizontalSeparator
1507
     * </p>
1508
     *
1509
     * @param parentElement
1510
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1511
     *            object.
1512
     * @param style
1513
     *            a int.
1514
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1515
     */
1516
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1517
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1518
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1519
        return separator;
1520
    }
1521

    
1522
    /**
1523
     * <p>
1524
     * createVersionElement
1525
     * </p>
1526
     *
1527
     * @param parentElement
1528
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1529
     *            object.
1530
     * @param entity
1531
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1532
     *            object.
1533
     * @param style
1534
     *            a int.
1535
     * @return a
1536
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1537
     *         object.
1538
     */
1539
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1540
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1541
        adapt(element);
1542
        parentElement.addElement(element);
1543
        return element;
1544
    }
1545

    
1546
    /**
1547
     * @param cdmBaseSection
1548
     * @param object
1549
     * @param style
1550
     * @return
1551
     */
1552
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1553
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1554
        adapt(element);
1555
        parentElement.addElement(element);
1556
        return element;
1557
    }
1558

    
1559
    /**
1560
     * <p>
1561
     * createVersionSection
1562
     * </p>
1563
     *
1564
     * @param parentElement
1565
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1566
     *            object.
1567
     * @param style
1568
     *            a int.
1569
     * @return a
1570
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1571
     *         object.
1572
     */
1573
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1574
        VersionSection section = new VersionSection(this, parentElement, style);
1575
        parentElement.addElement(section);
1576
        adapt(section);
1577
        return section;
1578
    }
1579

    
1580
    /**
1581
     * @param parent
1582
     * @param i
1583
     * @return
1584
     */
1585
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1586
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1587
        parentElement.addElement(section);
1588
        adapt(section);
1589
        return section;
1590
    }
1591

    
1592
    /**
1593
     * <p>
1594
     * createEmptyElement
1595
     * </p>
1596
     *
1597
     * @param parentElement
1598
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1599
     *            object.
1600
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1601
     */
1602
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1603
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1604
        adapt(element);
1605
        parentElement.addElement(element);
1606
        return element;
1607
    }
1608

    
1609
    /**
1610
     * <p>
1611
     * createHeadlineSection
1612
     * </p>
1613
     *
1614
     * @param parentElement
1615
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1616
     *            object.
1617
     * @return a
1618
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1619
     *         object.
1620
     */
1621
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1622
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1623
        parentElement.addElement(section);
1624
        adapt(section);
1625
        return section;
1626
    }
1627

    
1628
    /**
1629
     * <p>
1630
     * createParsingMessageElement
1631
     * </p>
1632
     *
1633
     * @param parentElement
1634
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1635
     *            object.
1636
     * @param parserProblem
1637
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1638
     *            object.
1639
     * @param style
1640
     *            a int.
1641
     * @return a
1642
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1643
     *         object.
1644
     */
1645
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1646
            ParserProblem parserProblem, int style) {
1647
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1648
        adapt(element);
1649
        parentElement.addElement(element);
1650
        return element;
1651
    }
1652

    
1653
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1654
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1655

    
1656
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1657
                selectionProvider, style);
1658

    
1659
        parentElement.addElement(section);
1660
        adapt(section);
1661
        return section;
1662

    
1663
    }
1664

    
1665
    /**
1666
     * @param definedTermClass
1667
     * @param formElement
1668
     * @param style
1669
     * @return
1670
     */
1671
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1672
            AbstractCdmDetailSection parentElement, int style) {
1673
        AbstractCdmDetailElement element = null;
1674

    
1675
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1676
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1677
        } else if (definedTermClass.equals(Feature.class)) {
1678
            element = new FeatureDetailElement(this, parentElement);
1679
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1680
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1681
        } else {
1682
            element = new DefinedTermDetailElement(this, parentElement);
1683
        }
1684

    
1685

    
1686
        adapt(element);
1687
        parentElement.addElement(element);
1688
        return element;
1689
    }
1690

    
1691
    public CharacterDetailSection createCharacterDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1692
        CharacterDetailSection section = new CharacterDetailSection(this, conversation, parentElement, selectionProvider, style);
1693
        addAndAdaptSection(parentElement, section);
1694
        return section;
1695
    }
1696

    
1697
    public CharacterDetailElement createCharacterDetailElement(ICdmFormElement parentElement, int style){
1698
        CharacterDetailElement element = new CharacterDetailElement(this, parentElement);
1699
        addAndAdaptElement(parentElement, element);
1700
        return element;
1701
    }
1702

    
1703
    public FeatureTreeDetailElement createFeatureTreeDetailElement(ICdmFormElement parentElement, int style){
1704
        FeatureTreeDetailElement element = new FeatureTreeDetailElement(this, parentElement);
1705
        addAndAdaptElement(parentElement, element);
1706
        return element;
1707
    }
1708

    
1709
    public FeatureNodeDetailElement createFeatureNodeDetailElement(ICdmFormElement parentElement, int style){
1710
        FeatureNodeDetailElement element = new FeatureNodeDetailElement(this, parentElement);
1711
        addAndAdaptElement(parentElement, element);
1712
        return element;
1713
    }
1714

    
1715

    
1716
    //--------DetailSections---------
1717
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1718
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1719
        addAndAdaptSection(parentElement, section);
1720
        return section;
1721
    }
1722

    
1723
    public FeatureNodeDetailSection createFeatureNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1724
        FeatureNodeDetailSection section = new FeatureNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1725
        addAndAdaptSection(parentElement, section);
1726
        return section;
1727
    }
1728

    
1729
    public FeatureTreeDetailSection createFeatureTreeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1730
        FeatureTreeDetailSection section = new FeatureTreeDetailSection(this, conversation, parentElement, selectionProvider, style);
1731
        addAndAdaptSection(parentElement, section);
1732
        return section;
1733
    }
1734

    
1735
    public ReferenceDetailSection createReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1736
        ReferenceDetailSection section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1737
        addAndAdaptSection(parentElement, section);
1738
        return section;
1739
    }
1740

    
1741
    public NomenclaturalReferenceDetailSection createNomenclaturalReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1742
        NomenclaturalReferenceDetailSection section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1743
        addAndAdaptSection(parentElement, section);
1744
        return section;
1745
    }
1746

    
1747
    public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1748
        TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1749
        addAndAdaptSection(parentElement, section);
1750
        return section;
1751
    }
1752

    
1753
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1754
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1755
        addAndAdaptSection(parentElement, section);
1756
        return section;
1757
    }
1758

    
1759
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1760
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1761
        addAndAdaptSection(parentElement, section);
1762
        return section;
1763
    }
1764

    
1765
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1766
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1767
        addAndAdaptSection(parentElement, section);
1768
        return section;
1769
    }
1770

    
1771
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1772
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1773
        addAndAdaptSection(parentElement, section);
1774
        return section;
1775
    }
1776

    
1777
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1778
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1779
        addAndAdaptSection(parentElement, section);
1780
        return section;
1781
    }
1782

    
1783
    public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1784
        DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1785
        addAndAdaptSection(parentElement, section);
1786
        return section;
1787
    }
1788

    
1789
    public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1790
        ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1791
        addAndAdaptSection(parentElement, section);
1792
        return section;
1793
    }
1794

    
1795

    
1796

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1959
    public AmplificationGeneralDetailSection createAmplificationGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1960
        AmplificationGeneralDetailSection section = new AmplificationGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1961
        addAndAdaptSection(parentElement, section);
1962
        return section;
1963
    }
1964

    
1965
    public AmplificationPrimerDetailSection createAmplificationPrimerDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1966
        AmplificationPrimerDetailSection section = new AmplificationPrimerDetailSection(this, conversation, parentElement, selectionProvider, style);
1967
        addAndAdaptSection(parentElement, section);
1968
        return section;
1969
    }
1970

    
1971
    public AmplificationCloningDetailSection createAmplificationCloningDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1972
        AmplificationCloningDetailSection section = new AmplificationCloningDetailSection(this, conversation, parentElement, selectionProvider, style);
1973
        addAndAdaptSection(parentElement, section);
1974
        return section;
1975
    }
1976

    
1977
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1978
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1979
        addAndAdaptSection(parentElement, section);
1980
        return section;
1981
    }
1982

    
1983
    public MediaSpecimenGeneralDetailSection createMediaSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1984
        MediaSpecimenGeneralDetailSection section = new MediaSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1985
        addAndAdaptSection(parentElement, section);
1986
        return section;
1987
    }
1988

    
1989
    public HybridDetailSection createHybridDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1990
        HybridDetailSection section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
1991
        addAndAdaptSection(parentElement, section);
1992
        return section;
1993
    }
1994

    
1995
    public UserDetailSection createUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1996
        UserDetailSection section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
1997
        addAndAdaptSection(parentElement, section);
1998
        return section;
1999
    }
2000

    
2001
    public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2002
        GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
2003
        addAndAdaptSection(parentElement, section);
2004
        return section;
2005
    }
2006

    
2007
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2008
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
2009
        addAndAdaptSection(parentElement, section);
2010
        return section;
2011
    }
2012

    
2013
    public SampleDesignationDetailSection createSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2014
        SampleDesignationDetailSection section = new SampleDesignationDetailSection(this, conversation, parentElement, selectionProvider, style);
2015
        addAndAdaptSection(parentElement, section);
2016
        return section;
2017
    }
2018

    
2019
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2020
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style, true);
2021
        addAndAdaptSection(parentElement, section);
2022
        return section;
2023
    }
2024

    
2025
    public ReferencedEntityDetailSection createReferencedEntityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2026
        ReferencedEntityDetailSection section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
2027
        addAndAdaptSection(parentElement, section);
2028
        return section;
2029
    }
2030

    
2031
    public TermVocabularyDetailSection createTermVocabularyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2032
        TermVocabularyDetailSection section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
2033
        addAndAdaptSection(parentElement, section);
2034
        return section;
2035
    }
2036

    
2037
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2038
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
2039
        addAndAdaptSection(parentElement, section);
2040
        return section;
2041
    }
2042

    
2043
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2044
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
2045
        addAndAdaptSection(parentElement, section);
2046
        return section;
2047
    }
2048

    
2049
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2050
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
2051
        addAndAdaptSection(parentElement, section);
2052
        return section;
2053
    }
2054

    
2055
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
2056
        parentElement.addElement(section);
2057
        adapt(section);
2058
    }
2059

    
2060
    //--------DetailElements------------
2061

    
2062
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
2063
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
2064
        addAndAdaptElement(parentElement, element);
2065
        return element;
2066
    }
2067

    
2068
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
2069
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
2070
        addAndAdaptElement(parentElement, element);
2071
        return element;
2072
    }
2073

    
2074
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
2075
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
2076
        addAndAdaptElement(parentElement, element);
2077
        return element;
2078
    }
2079

    
2080
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
2081
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
2082
        addAndAdaptElement(parentElement, element);
2083
        return element;
2084
    }
2085

    
2086
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
2087
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
2088
        addAndAdaptElement(parentElement, element);
2089
        return element;
2090
    }
2091

    
2092
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
2093
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
2094
        addAndAdaptElement(parentElement, element);
2095
        return element;
2096
    }
2097

    
2098
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
2099
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2100
        addAndAdaptElement(parentElement, element);
2101
        return element;
2102
    }
2103

    
2104
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2105
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2106
        addAndAdaptElement(parentElement, element);
2107
        return element;
2108
    }
2109

    
2110
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2111
        UserDetailElement element = new UserDetailElement(this, parentElement);
2112
        addAndAdaptElement(parentElement, element);
2113
        return element;
2114
    }
2115

    
2116
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2117
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2118
        addAndAdaptElement(parentElement, element);
2119
        return element;
2120
    }
2121

    
2122
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2123
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2124
        addAndAdaptElement(parentElement, element);
2125
        return element;
2126
    }
2127

    
2128
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2129
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2130
        addAndAdaptElement(parentElement, element);
2131
        return element;
2132
    }
2133

    
2134
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2135
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2136
        addAndAdaptElement(parentElement, element);
2137
        return element;
2138
    }
2139

    
2140
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2141
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2142
        addAndAdaptElement(parentElement, element);
2143
        return element;
2144
    }
2145

    
2146
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2147
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2148
        adapt(element);
2149
        parentElement.addElement(element);
2150

    
2151
        return element;
2152
    }
2153

    
2154
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2155
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2156
        addAndAdaptElement(parentElement, element);
2157
        return element;
2158
    }
2159

    
2160
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
2161
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
2162
        addAndAdaptElement(parentElement, element);
2163
        return element;
2164
    }
2165

    
2166
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2167
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2168
        addAndAdaptElement(parentElement, element);
2169
        return element;
2170
    }
2171

    
2172
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2173
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2174
        addAndAdaptElement(parentElement, element);
2175
        return element;
2176
    }
2177

    
2178
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2179
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2180
        addAndAdaptElement(parentElement, element);
2181
        return element;
2182
    }
2183

    
2184
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2185
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2186
        addAndAdaptElement(parentElement, element);
2187
        return element;
2188
    }
2189

    
2190
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2191
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2192
        addAndAdaptElement(parentElement, element);
2193
        return element;
2194
    }
2195

    
2196
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2197
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2198
        addAndAdaptElement(parentElement, element);
2199
        return element;
2200
    }
2201

    
2202
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2203
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2204
        addAndAdaptElement(parentElement, element);
2205
        return element;
2206
    }
2207

    
2208
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2209
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2210
        addAndAdaptElement(parentElement, element);
2211
        return element;
2212
    }
2213

    
2214
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2215
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2216
        addAndAdaptElement(parentElement, element);
2217
        return element;
2218
    }
2219

    
2220
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2221
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2222
        addAndAdaptElement(parentElement, element);
2223
        return element;
2224
    }
2225

    
2226
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2227
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2228
        addAndAdaptElement(parentElement, element);
2229
        return element;
2230
    }
2231

    
2232
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2233
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2234
        addAndAdaptElement(parentElement, element);
2235
        return element;
2236
    }
2237

    
2238
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2239
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2240
        addAndAdaptElement(parentElement, element);
2241
        return element;
2242
    }
2243

    
2244

    
2245
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2246
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2247
        addAndAdaptElement(parentElement, element);
2248
        return element;
2249
    }
2250

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

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

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

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

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

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

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

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

    
2299
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2300
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2301
        addAndAdaptElement(parentElement, element);
2302
        return element;
2303
    }
2304

    
2305
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2306
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2307
        addAndAdaptElement(parentElement, element);
2308
        return element;
2309
    }
2310

    
2311
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2312
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2313
        addAndAdaptElement(parentElement, element);
2314
        return element;
2315
    }
2316

    
2317
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2318
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2319
        addAndAdaptElement(parentElement, element);
2320
        return element;
2321
    }
2322

    
2323
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2324
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2325
        addAndAdaptElement(parentElement, element);
2326
        return element;
2327
    }
2328

    
2329
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2330
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2331
        addAndAdaptElement(parentElement, element);
2332
        return element;
2333
    }
2334

    
2335
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2336
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2337
        addAndAdaptElement(parentElement, element);
2338
        return element;
2339
    }
2340

    
2341
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2342
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2343
        addAndAdaptElement(parentElement, mediaDetailElement);
2344
        return mediaDetailElement;
2345
    }
2346

    
2347
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2348
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2349
        addAndAdaptElement(parentElement, element);
2350
        return element;
2351
    }
2352

    
2353
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2354
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2355
        addAndAdaptElement(parentElement, element);
2356
        return element;
2357
    }
2358

    
2359
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2360
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2361
        addAndAdaptElement(parentElement, element);
2362
        return element;
2363
    }
2364

    
2365
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2366
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2367
        addAndAdaptElement(parentElement, element);
2368
        return element;
2369
    }
2370

    
2371
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2372
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2373
        addAndAdaptElement(parentElement, element);
2374
        return element;
2375
    }
2376

    
2377
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2378
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2379
        addAndAdaptElement(parentElement, element);
2380
        return element;
2381
    }
2382

    
2383
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2384
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2385
        addAndAdaptElement(parentElement, element);
2386
        return element;
2387
    }
2388

    
2389
    /**
2390
     * @param parentElement
2391
     * @param element
2392
     */
2393
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2394
        adapt(element);
2395
        parentElement.addElement(element);
2396
    }
2397

    
2398
    //--------EntityCollectionSection----------
2399
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2400
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2401
        addAndAdaptSection(parentElement, section);
2402
        return section;
2403
    }
2404

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2573
    public GeoScopeDetailSection createGeoScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2574
        GeoScopeDetailSection section = new GeoScopeDetailSection(this, conversation, parentElement, style);
2575
        addAndAdaptSection(parentElement, section);
2576
        return section;
2577
    }
2578

    
2579
    public GeoScopePolyKeyDetailSection createGeoScopePolyKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2580
        GeoScopePolyKeyDetailSection section = new GeoScopePolyKeyDetailSection(this, conversation, parentElement, style);
2581
        addAndAdaptSection(parentElement, section);
2582
        return section;
2583
    }
2584

    
2585
    public IdentifierSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2586
        IdentifierSection section = new IdentifierSection(this, conversation, parentElement, style);
2587
        addAndAdaptSection(parentElement, section);
2588
        return section;
2589
    }
2590

    
2591
    public DerivedUnitFacadeIdentifierSection createDerivedUnitFacadeIdentifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2592
    	DerivedUnitFacadeIdentifierSection section = new DerivedUnitFacadeIdentifierSection(this, conversation, parentElement, style);
2593
    	addAndAdaptSection(parentElement, section);
2594
    	return section;
2595
    }
2596

    
2597
    public CurrentSampleDesignationDetailSection createCurrentSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2598
        CurrentSampleDesignationDetailSection section = new CurrentSampleDesignationDetailSection(this, conversation, parentElement, style);
2599
        addAndAdaptSection(parentElement, section);
2600
        return section;
2601
    }
2602

    
2603
    public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2604
        CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
2605
        addAndAdaptSection(parentElement, section);
2606
        return section;
2607
    }
2608

    
2609
    public PreservedSpecimenCurrentDeterminationDetailSection createPreservedSpecimenCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2610
        PreservedSpecimenCurrentDeterminationDetailSection section = new PreservedSpecimenCurrentDeterminationDetailSection(this, conversation, parentElement, style);
2611
        addAndAdaptSection(parentElement, section);
2612
        return section;
2613
    }
2614

    
2615
    public SampleDesignationHistoryDetailSection createSampleDesignationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2616
        SampleDesignationHistoryDetailSection section = new SampleDesignationHistoryDetailSection(this, conversation, parentElement, style);
2617
        addAndAdaptSection(parentElement, section);
2618
        return section;
2619
    }
2620

    
2621
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2622
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
2623
        addAndAdaptSection(parentElement, section);
2624
        return section;
2625
    }
2626

    
2627
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2628
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
2629
        addAndAdaptSection(parentElement, section);
2630
        return section;
2631
    }
2632

    
2633
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2634
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2635
        addAndAdaptSection(parentElement, section);
2636
        return section;
2637
    }
2638

    
2639
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2640
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2641
        addAndAdaptSection(parentElement, section);
2642
        return section;
2643
    }
2644

    
2645
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2646
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2647
        addAndAdaptSection(parentElement, section);
2648
        return section;
2649
    }
2650

    
2651
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2652
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2653
        addAndAdaptSection(parentElement, section);
2654
        return section;
2655
    }
2656

    
2657
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2658
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2659
        addAndAdaptSection(parentElement, section);
2660
        return section;
2661
    }
2662

    
2663
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2664
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2665
        addAndAdaptSection(parentElement, section);
2666
        return section;
2667
    }
2668

    
2669
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2670
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2671
        addAndAdaptSection(parentElement, section);
2672
        return section;
2673
    }
2674

    
2675

    
2676
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2677
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2678
        AbstractEntityCollectionElement<?> element = null;
2679

    
2680
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2681

    
2682
        if (entity instanceof Annotation) {
2683
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2684
        }else if (entity instanceof Person ) {
2685
            boolean isNomenclatural = false;
2686
            if (parentElement instanceof TeamMemberSection){
2687
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2688
            }
2689
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2690
        } else if (entity instanceof Credit) {
2691
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2692
        } else if (entity instanceof Extension) {
2693
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2694
        } else if (entity instanceof Marker) {
2695
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2696
        } else if (entity instanceof TaxonNodeAgentRelation) {
2697
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2698
        }else if (entity instanceof Media) {
2699
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2700
        } else if (entity instanceof MediaRepresentation) {
2701
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2702
                    style);
2703
        } else if (entity instanceof ImageFile) {
2704
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2705
        } else if (entity instanceof MediaRepresentationPart) {
2706
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2707
                    removeListener, style);
2708
        } else if (entity instanceof NomenclaturalStatus) {
2709
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2710
                    style);
2711
        } else if (entity instanceof Rights) {
2712
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2713
        } else if (entity instanceof DescriptionElementSource) {
2714
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2715
                    removeListener, style);
2716
        } else if (entity instanceof TaxonNodeAgentRelation) {
2717
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2718
                    removeListener,backgroundColor, style);
2719
        }
2720
        else if (entity instanceof IdentifiableSource) {
2721
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2722
                    style);
2723
        } else if (entity instanceof DefinedTerm) {
2724
            switch(((DefinedTerm)entity).getTermType()) {
2725
            case Scope:
2726
                element = new ScopeElement(this,
2727
                        parentElement,
2728
                        (DefinedTerm) entity,
2729
                        removeListener,
2730
                        style);
2731
                break;
2732
            case Modifier:
2733
                element = new ModifierElement(this,
2734
                        parentElement,
2735
                        (DefinedTerm) entity,
2736
                        removeListener,
2737
                        style);
2738
                break;
2739
            default:
2740
                break;
2741

    
2742
            }
2743
        } else if (entity instanceof Reference) {
2744
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2745
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2746
            }
2747
            else{
2748
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2749
            }
2750
        } else if (entity instanceof NameTypeDesignation) {
2751
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2752
                    style);
2753
        } else if (entity instanceof NameRelationship) {
2754
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2755
                    style);
2756
        } else if (entity instanceof SpecimenTypeDesignation) {
2757
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
2758
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2759
                        removeListener, style);
2760
            }
2761
            else{
2762
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2763
                        removeListener, style);
2764
            }
2765
        } else if (entity instanceof StateData) {
2766
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2767
        } else if (entity instanceof StatisticalMeasurementValue) {
2768
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2769
                    removeListener, style);
2770
        } else if (entity instanceof DerivedUnit) {
2771
            switch(((DerivedUnit)entity).getRecordBasis()) {
2772
            case LivingSpecimen:
2773
            case PreservedSpecimen:
2774
            case OtherSpecimen:
2775
                element = new SpecimenCollectionDetailElement(this,
2776
                        parentElement,
2777
                        (DerivedUnit) entity,
2778
                        removeListener,
2779
                        style);
2780
                break;
2781
            default:
2782
                element = new DerivedUnitElement(this,
2783
                        parentElement,
2784
                        (DerivedUnit) entity,
2785
                        removeListener,
2786
                        style);
2787
            }
2788

    
2789
        } else if (entity instanceof NamedArea) {
2790
            element = new CollectingAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2791
        } else if (entity instanceof DeterminationEvent) {
2792
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2793
        } else if (entity instanceof User) {
2794
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2795
        } else if (entity instanceof GrantedAuthority) {
2796
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
2797
                    removeListener, style);
2798
        } else if (entity instanceof Group) {
2799
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2800
        } else if (entity instanceof Taxon) {
2801
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2802
        } else if (entity instanceof DescriptionElementBase) {
2803
            // this is the special case for protologs, maybe we can do this
2804
            // differently when API improves
2805
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2806
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2807
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2808
            }
2809
        } else if (entity instanceof Identifier) {
2810
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2811
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2812
            }
2813
            else{
2814
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
2815
            }
2816
        } else if (entity instanceof TermVocabulary) {
2817
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
2818
            switch (termVocabulary.getTermType()) {
2819
            case State:
2820
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
2821
                break;
2822
            case Modifier:
2823
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
2824
                break;
2825
            default:
2826
                break;
2827
            }
2828
        } else if (entity instanceof MeasurementUnit) {
2829
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2830
        } else if (entity instanceof StatisticalMeasure) {
2831
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2832
        } else if (entity instanceof State && parentElement instanceof InapplicableIfEntityCollectionSection) {
2833
            element = new InapplicableIfCollectionElement(this, parentElement, (State) entity, removeListener, backgroundColor, style);
2834
        } else if (entity instanceof State && parentElement instanceof OnlyApplicableIfEntityCollectionSection) {
2835
            element = new OnlyApplicableIfCollectionElement(this, parentElement, (State) entity, removeListener, backgroundColor, style);
2836
        }
2837

    
2838
        //check for parent section when entity is null
2839
        //this happens when AbstractUnboundEntityCollectionSection is used
2840
        if(entity==null){
2841
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
2842
                element = new ScopeElement(this,
2843
                        parentElement,
2844
                        (DefinedTerm) entity,
2845
                        removeListener,
2846
                        style);
2847
            }
2848
            else if(parentElement instanceof ModifierSection){
2849
                element = new ModifierElement(this,
2850
                        parentElement,
2851
                        (DefinedTerm) entity,
2852
                        removeListener,
2853
                        style);
2854
            }
2855
        }
2856

    
2857

    
2858
        if (element == null) {
2859
            MessagingUtils.messageDialog("No element for entity", this,
2860
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2861
                            + entity, null);
2862
        }
2863

    
2864
        else{
2865
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2866
                element.setPersistentBackground(backgroundColor);
2867
            }
2868
            adapt(element);
2869
            parentElement.addElement(element);
2870
        }
2871

    
2872
        return element;
2873
    }
2874

    
2875
    /**
2876
     * <p>
2877
     * Creates a selection element for the given type T.
2878
     * </p>
2879
     * <p>
2880
     * <strong>Selection elements not handled by this method:</strong>
2881
     * <ul>
2882
     * <li>{@link TaxonNodeSelectionElement} see
2883
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2884
     * </li>
2885
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2886
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2887
     * </li>
2888
     * </ul>
2889
     * </p>
2890
     *
2891
     * @param clazz
2892
     *            a {@link Class} object of the type that you want the selection
2893
     *            element to handle
2894
     * @param parentElement
2895
     *            a {@link ICdmFormElement} object.
2896
     * @param labelString
2897
     *            a {@link String} object.
2898
     * @param selectionType
2899
     * @param selection
2900
     *            a {@link ICdmBase} object.
2901
     * @param style
2902
     *            a int.
2903
     * @param conversation
2904
     *            a {@link ConversationHolder} object.
2905
     * @return a {@link EntitySelectionElement} object.
2906
     */
2907
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2908
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2909
            int style, boolean filterElement) {
2910
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
2911
                parentElement, clazz,
2912
                labelString, selection, mode, style, filterElement);
2913
        adapt(element);
2914
        parentElement.addElement(element);
2915
        return element;
2916
    }
2917

    
2918
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2919
//            ConversationHolder conversation,
2920
            ICdmFormElement parentElement, String labelString, T selection, int mode,
2921
            int style) {
2922
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
2923
                parentElement, clazz,
2924
                labelString, selection, mode, style);
2925
        adapt(element);
2926
        parentElement.addElement(element);
2927
        return element;
2928
    }
2929

    
2930
    /**
2931
     * <p>
2932
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
2933
     * </p>
2934
     * <p>
2935
     * <strong>Selection elements not handled by this method:</strong>
2936
     * <ul>
2937
     * <li>{@link TaxonNodeSelectionElement} see
2938
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2939
     * </li>
2940
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2941
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2942
     * </li>
2943
     * </ul>
2944
     * </p>
2945
     *
2946
     * @param clazz
2947
     *            a {@link Class} object of the type that you want the selection
2948
     *            element to handle
2949
     * @param parentElement
2950
     *            a {@link ICdmFormElement} object.
2951
     * @param labelString
2952
     *            a {@link String} object.
2953
     * @param selectionType
2954
     * @param selection
2955
     *            a {@link ICdmBase} object.
2956
     * @param style
2957
     *            a int.
2958
     * @param conversation
2959
     *            a {@link ConversationHolder} object.
2960
     * @return a {@link EntitySelectionElement} object.
2961
     */
2962
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
2963
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
2964
            T selection, int mode, int style) {
2965
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, //conversation,
2966
                parentElement, clazz,
2967
                labelString, selection, mode, style);
2968
        adapt(element);
2969
        parentElement.addElement(element);
2970
        return element;
2971
    }
2972

    
2973
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2974
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2975
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
2976
                parentElement,
2977
                labelString, selection, mode, style);
2978
        adapt(element);
2979
        parentElement.addElement(element);
2980
        return element;
2981
    }
2982

    
2983

    
2984

    
2985
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2986
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2987
//            int mode, int style) {
2988
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2989
//                conversation, parentElement, labelString, selection, mode, style);
2990
//        adapt(element);
2991
//        parentElement.addElement(element);
2992
//        return element;
2993
//    }
2994

    
2995
    /** {@inheritDoc} */
2996
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2997
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2998
        adapt(labelElement);
2999
        parentElement.addElement(labelElement);
3000
        return labelElement;
3001
    }
3002

    
3003
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
3004
//        Label label = new Label(formElement.getLayoutComposite(), style);
3005
//        label.setText(labelText+" (yyyy-MM-dd)");
3006
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
3007
//        dateElement.initInternalController();
3008
//
3009
//        return dateElement;
3010
//    }
3011

    
3012
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
3013
    	 Label label = new Label(formElement.getLayoutComposite(), style);
3014
         label.setText(labelText);
3015
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3016
         DateElement dateElement = new DateElement(this, formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
3017
         dateElement.initController(this, formElement);
3018
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3019
         return dateElement;
3020
    }
3021

    
3022
    /**
3023
     * <p>
3024
     * Getter for the field <code>selectionProvider</code>.
3025
     * </p>
3026
     *
3027
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
3028
     */
3029
    public ISelectionProvider getSelectionProvider() {
3030
        return selectionProvider;
3031
    }
3032

    
3033
    /**
3034
     * <p>
3035
     * createDetailedDescriptionDetailElement
3036
     * </p>
3037
     *
3038
     * @param parentElement
3039
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3040
     *            object.
3041
     * @param entity
3042
     *            a
3043
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
3044
     *            object.
3045
     * @param style
3046
     *            a int.
3047
     * @return a
3048
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
3049
     *         object.
3050
     */
3051
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
3052
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
3053
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
3054

    
3055
        if (entity instanceof CategoricalData) {
3056
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
3057
                    (CategoricalData) entity, style);
3058
        } else if (entity instanceof CommonTaxonName) {
3059
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
3060
                    style);
3061
        } else if (entity instanceof Distribution && !enabled) {
3062
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3063
                    enabled, style);
3064
        } else if (entity instanceof Distribution) {
3065
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3066
                    true, style);
3067
        }else if (entity instanceof IndividualsAssociation) {
3068
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
3069
                    (IndividualsAssociation) entity, style);
3070
        } else if (entity instanceof QuantitativeData) {
3071
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
3072
                    (QuantitativeData) entity, style);
3073
        } else if (entity instanceof TaxonInteraction) {
3074
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
3075
                    (TaxonInteraction) entity, style);
3076
        } else if (entity instanceof TextData) {
3077
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
3078
        } else {
3079
            throw new IllegalStateException("There is no interface for the given description element");
3080
        }
3081
        adapt(detailedDescriptionElement);
3082
        parentElement.addElement(detailedDescriptionElement);
3083
        return detailedDescriptionElement;
3084

    
3085
    }
3086

    
3087
    /**
3088
     * Creates a styled text as a part of the form.
3089
     *
3090
     * @param parent
3091
     *            the text parent
3092
     * @param value
3093
     *            the text initial value
3094
     * @param style
3095
     *            the text style
3096
     * @return the text widget
3097
     */
3098
    public StyledText createStyledText(Composite parent, String value, int style) {
3099
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3100
        if (value != null) {
3101
            text.setText(value);
3102
        }
3103
        text.setForeground(getColors().getForeground());
3104
        text.setBackground(getColors().getBackground());
3105
        // text.addFocusListener(visibilityHandler);
3106
        return text;
3107
    }
3108

    
3109
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3110
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3111
        addAndAdaptSection(parentElement, section);
3112
        return section;
3113
    }
3114

    
3115
    /**
3116
     * @param formElement
3117
     * @param conversationHolder
3118
     * @param style
3119
     * @return
3120
     */
3121
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3122
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3123
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3124
        addAndAdaptSection(formElement, section);
3125
        return section;
3126
    }
3127

    
3128

    
3129
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3130
			ICdmFormElement parentElement, int style) {
3131
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3132
		addAndAdaptElement(parentElement, section);
3133
        return section;
3134
	}
3135

    
3136
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3137
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3138
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3139
	        addAndAdaptSection(formElement, section);
3140
	        return section;
3141
	}
3142

    
3143

    
3144

    
3145
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3146
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3147
//				 initialText, textHeight, style);
3148
//	        adapt(element);
3149
//	        parentElement.addElement(element);
3150
//	        return element;
3151
//	}
3152

    
3153

    
3154

    
3155

    
3156

    
3157

    
3158

    
3159
}
(7-7/47)