Project

General

Profile

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

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

    
370
    private BoldFontHolder2 boldFontHolder2;
371
    private MouseListener selectionMouseHandler;
372
    private FocusListener selectionFocusHandler;
373

    
374
    @Inject
375
    private IEclipseContext context;
376

    
377
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
378

    
379
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
380

    
381
    private final int orientation = Window.getDefaultOrientation();
382
    private ISelectionProvider selectionProvider;
383

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

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

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

    
418
    private void notifySelectionListeners(TypedEvent e) {
419
        Event event = new Event();
420
        event.widget = e.widget;
421
        SelectionEvent selectionEvent = new SelectionEvent(event);
422

    
423
        for (SelectionListener listener : selectionListenerList) {
424
            listener.widgetSelected(selectionEvent);
425
        }
426
    }
427

    
428
    public CdmFormFactory(Display display) {
429
        this(display, null);
430
    }
431

    
432
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
433
        super(display);
434
        this.selectionProvider = selectionProvider;
435
        init();
436
    }
437

    
438
    private void init() {
439
        boldFontHolder2 = new BoldFontHolder2();
440
        selectionMouseHandler = new SelectionMouseHandler();
441
        selectionFocusHandler = new SelectionFocusHandler();
442
    }
443

    
444
    public IEclipseContext getContext() {
445
        return context;
446
    }
447

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

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

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

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

    
512
    /** {@inheritDoc} */
513
    @Override
514
    public void adapt(Composite composite) {
515
        composite.addMouseListener(selectionMouseHandler);
516

    
517
        super.adapt(composite);
518
    }
519

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
870
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
871
            String labelString, LanguageString languageString, int style) {
872
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
873
    }
874

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

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

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

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

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

    
959

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

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

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

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

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

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

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

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

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

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

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

    
1155
        // handle focus and property change events for cdm use
1156
        section.addFocusListener(selectionFocusHandler);
1157
        section.setPropertyChangeListeners(propertyChangeListeners);
1158

    
1159
        if (section.getToggle() != null) {
1160
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1161
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1162
        }
1163

    
1164
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1165

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

    
1177
    private class BoldFontHolder2 {
1178
        private Font normalFont;
1179

    
1180
        private Font boldFont;
1181

    
1182
        public BoldFontHolder2() {
1183
        }
1184

    
1185
        public Font getBoldFont(Font font) {
1186
            createBoldFont(font);
1187
            return boldFont;
1188
        }
1189

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

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

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

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

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

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

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

    
1341
    /**
1342
     * Creates an empty section with the given message.<br>
1343
     * If message is <code>null</code> a default message will be displayed.
1344
     */
1345
    public EmptySection createEmptySection(String message, CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1346
        EmptySection section = new EmptySection(message, formFactory, parentElement, style);
1347
        parentElement.addElement(section);
1348
        adapt(section);
1349
        return section;
1350
    }
1351

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1662
    }
1663

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

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

    
1684

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

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

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

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

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

    
1714

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1794

    
1795

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2059
    //--------DetailElements------------
2060

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2150
        return element;
2151
    }
2152

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2243

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2488
    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2489
        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2490
        addAndAdaptSection(parentElement, section);
2491
        return section;
2492
    }
2493
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2494
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, style);
2495
        addAndAdaptSection(parentElement, section);
2496
        return section;
2497
    }
2498

    
2499
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2500
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2501
        addAndAdaptSection(parentElement, section);
2502
        return section;
2503
    }
2504

    
2505
    public SourceSection createSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2506
        SourceSection section = new SourceSection(this, conversation, parentElement, style);
2507
        addAndAdaptSection(parentElement, section);
2508
        return section;
2509
    }
2510

    
2511
    public ScopeSection createScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2512
        ScopeSection section = new ScopeSection(this, conversation, parentElement, style);
2513
        addAndAdaptSection(parentElement, section);
2514
        return section;
2515
    }
2516

    
2517
    public DescriptionSourceSection createDescriptionSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2518
        DescriptionSourceSection section = new DescriptionSourceSection(this, conversation, parentElement, style);
2519
        addAndAdaptSection(parentElement, section);
2520
        return section;
2521
    }
2522

    
2523
    public TypeDesignationSection createTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2524
        TypeDesignationSection section = new TypeDesignationSection(this, conversation, parentElement, style);
2525
        addAndAdaptSection(parentElement, section);
2526
        return section;
2527
    }
2528

    
2529
    public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2530
        StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
2531
        addAndAdaptSection(parentElement, section);
2532
        return section;
2533
    }
2534

    
2535
    public StatisticalMeasurementValueSection createStatisticalMeasurementValueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2536
        StatisticalMeasurementValueSection section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
2537
        addAndAdaptSection(parentElement, section);
2538
        return section;
2539
    }
2540

    
2541
    public DescribedSpecimenSection createDescribedSpecimenSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2542
        DescribedSpecimenSection section = new DescribedSpecimenSection(this, conversation, parentElement, style);
2543
        addAndAdaptSection(parentElement, section);
2544
        return section;
2545
    }
2546

    
2547
    public StateVocabularyCollectionSection createStateVocabulariesSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2548
        StateVocabularyCollectionSection section = new StateVocabularyCollectionSection(this, conversation, parentElement, style);
2549
        addAndAdaptSection(parentElement, section);
2550
        return section;
2551
    }
2552

    
2553
    public RecommendedModifierVocabulariesCollectionSection createRecommendedModifierVocabulariesCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2554
        RecommendedModifierVocabulariesCollectionSection section = new RecommendedModifierVocabulariesCollectionSection(this, conversation, parentElement, style);
2555
        addAndAdaptSection(parentElement, section);
2556
        return section;
2557
    }
2558

    
2559
    public MeasurementUnitCollectionSection createMeasurementUnitCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2560
        MeasurementUnitCollectionSection section = new MeasurementUnitCollectionSection(this, conversation, parentElement, style);
2561
        addAndAdaptSection(parentElement, section);
2562
        return section;
2563
    }
2564

    
2565
    public StatisticalMeasureCollectionSection createStatisticalMeasureCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2566
        StatisticalMeasureCollectionSection section = new StatisticalMeasureCollectionSection(this, conversation, parentElement, style);
2567
        addAndAdaptSection(parentElement, section);
2568
        return section;
2569
    }
2570

    
2571
    public CollectingAreasDetailSection createCollectingAreasDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2572
        CollectingAreasDetailSection section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
2573
        addAndAdaptSection(parentElement, section);
2574
        return section;
2575
    }
2576

    
2577
    public GeoScopeDetailSection createGeoScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2578
        GeoScopeDetailSection section = new GeoScopeDetailSection(this, conversation, parentElement, style);
2579
        addAndAdaptSection(parentElement, section);
2580
        return section;
2581
    }
2582

    
2583
    public GeoScopePolyKeyDetailSection createGeoScopePolyKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2584
        GeoScopePolyKeyDetailSection section = new GeoScopePolyKeyDetailSection(this, conversation, parentElement, style);
2585
        addAndAdaptSection(parentElement, section);
2586
        return section;
2587
    }
2588

    
2589
    public IdentifierSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2590
        IdentifierSection section = new IdentifierSection(this, conversation, parentElement, style);
2591
        addAndAdaptSection(parentElement, section);
2592
        return section;
2593
    }
2594

    
2595
    public DerivedUnitFacadeIdentifierSection createDerivedUnitFacadeIdentifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2596
    	DerivedUnitFacadeIdentifierSection section = new DerivedUnitFacadeIdentifierSection(this, conversation, parentElement, style);
2597
    	addAndAdaptSection(parentElement, section);
2598
    	return section;
2599
    }
2600

    
2601
    public CurrentSampleDesignationDetailSection createCurrentSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2602
        CurrentSampleDesignationDetailSection section = new CurrentSampleDesignationDetailSection(this, conversation, parentElement, style);
2603
        addAndAdaptSection(parentElement, section);
2604
        return section;
2605
    }
2606

    
2607
    public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2608
        CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
2609
        addAndAdaptSection(parentElement, section);
2610
        return section;
2611
    }
2612

    
2613
    public PreservedSpecimenCurrentDeterminationDetailSection createPreservedSpecimenCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2614
        PreservedSpecimenCurrentDeterminationDetailSection section = new PreservedSpecimenCurrentDeterminationDetailSection(this, conversation, parentElement, style);
2615
        addAndAdaptSection(parentElement, section);
2616
        return section;
2617
    }
2618

    
2619
    public SampleDesignationHistoryDetailSection createSampleDesignationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2620
        SampleDesignationHistoryDetailSection section = new SampleDesignationHistoryDetailSection(this, conversation, parentElement, style);
2621
        addAndAdaptSection(parentElement, section);
2622
        return section;
2623
    }
2624

    
2625
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2626
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
2627
        addAndAdaptSection(parentElement, section);
2628
        return section;
2629
    }
2630

    
2631
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2632
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
2633
        addAndAdaptSection(parentElement, section);
2634
        return section;
2635
    }
2636

    
2637
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2638
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2639
        addAndAdaptSection(parentElement, section);
2640
        return section;
2641
    }
2642

    
2643
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2644
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2645
        addAndAdaptSection(parentElement, section);
2646
        return section;
2647
    }
2648

    
2649
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2650
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2651
        addAndAdaptSection(parentElement, section);
2652
        return section;
2653
    }
2654

    
2655
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2656
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2657
        addAndAdaptSection(parentElement, section);
2658
        return section;
2659
    }
2660

    
2661
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2662
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2663
        addAndAdaptSection(parentElement, section);
2664
        return section;
2665
    }
2666

    
2667
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2668
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2669
        addAndAdaptSection(parentElement, section);
2670
        return section;
2671
    }
2672

    
2673
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2674
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2675
        addAndAdaptSection(parentElement, section);
2676
        return section;
2677
    }
2678

    
2679

    
2680
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2681
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2682
        AbstractEntityCollectionElement<?> element = null;
2683

    
2684
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2685

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

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

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

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

    
2863

    
2864
        if (element == null) {
2865
            MessagingUtils.messageDialog(
2866
                    String.format("Error when creating section %s",
2867
                            parentElement.getClass().getSimpleName()),
2868
                    this,
2869
                    String.format("Could not generate collection element for entity of class %s."
2870
                            + " Looks like the case is not yet handled. Check implementation.\n"
2871
                            + "Entity: %s", entity.getClass(), entity.toString()), null);
2872
        }
2873

    
2874
        else{
2875
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2876
                element.setPersistentBackground(backgroundColor);
2877
            }
2878
            adapt(element);
2879
            parentElement.addElement(element);
2880
        }
2881

    
2882
        return element;
2883
    }
2884

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

    
2928
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2929
//            ConversationHolder conversation,
2930
            ICdmFormElement parentElement, String labelString, T selection, int mode,
2931
            int style) {
2932
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
2933
                parentElement, clazz,
2934
                labelString, selection, mode, style);
2935
        adapt(element);
2936
        parentElement.addElement(element);
2937
        return element;
2938
    }
2939

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

    
2983
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2984
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2985
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
2986
                parentElement,
2987
                labelString, selection, mode, style);
2988
        adapt(element);
2989
        parentElement.addElement(element);
2990
        return element;
2991
    }
2992

    
2993

    
2994

    
2995
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2996
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2997
//            int mode, int style) {
2998
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2999
//                conversation, parentElement, labelString, selection, mode, style);
3000
//        adapt(element);
3001
//        parentElement.addElement(element);
3002
//        return element;
3003
//    }
3004

    
3005
    /** {@inheritDoc} */
3006
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
3007
        LabelElement labelElement = new LabelElement(this, parentElement, text);
3008
        adapt(labelElement);
3009
        parentElement.addElement(labelElement);
3010
        return labelElement;
3011
    }
3012

    
3013
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
3014
//        Label label = new Label(formElement.getLayoutComposite(), style);
3015
//        label.setText(labelText+" (yyyy-MM-dd)");
3016
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
3017
//        dateElement.initInternalController();
3018
//
3019
//        return dateElement;
3020
//    }
3021

    
3022
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
3023
    	 Label label = new Label(formElement.getLayoutComposite(), style);
3024
         label.setText(labelText);
3025
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3026
         DateElement dateElement = new DateElement(this, formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
3027
         dateElement.initController(this, formElement);
3028
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3029
         return dateElement;
3030
    }
3031

    
3032
    /**
3033
     * <p>
3034
     * Getter for the field <code>selectionProvider</code>.
3035
     * </p>
3036
     *
3037
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
3038
     */
3039
    public ISelectionProvider getSelectionProvider() {
3040
        return selectionProvider;
3041
    }
3042

    
3043
    /**
3044
     * <p>
3045
     * createDetailedDescriptionDetailElement
3046
     * </p>
3047
     *
3048
     * @param parentElement
3049
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3050
     *            object.
3051
     * @param entity
3052
     *            a
3053
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
3054
     *            object.
3055
     * @param style
3056
     *            a int.
3057
     * @return a
3058
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
3059
     *         object.
3060
     */
3061
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
3062
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
3063
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
3064

    
3065
        if (entity instanceof CategoricalData) {
3066
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
3067
                    (CategoricalData) entity, style);
3068
        } else if (entity instanceof CommonTaxonName) {
3069
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
3070
                    style);
3071
        } else if (entity instanceof Distribution && !enabled) {
3072
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3073
                    enabled, style);
3074
        } else if (entity instanceof Distribution) {
3075
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3076
                    true, style);
3077
        }else if (entity instanceof IndividualsAssociation) {
3078
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
3079
                    (IndividualsAssociation) entity, style);
3080
        } else if (entity instanceof QuantitativeData) {
3081
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
3082
                    (QuantitativeData) entity, style);
3083
        } else if (entity instanceof TaxonInteraction) {
3084
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
3085
                    (TaxonInteraction) entity, style);
3086
        } else if (entity instanceof TextData) {
3087
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
3088
        } else {
3089
            throw new IllegalStateException("There is no interface for the given description element");
3090
        }
3091
        adapt(detailedDescriptionElement);
3092
        parentElement.addElement(detailedDescriptionElement);
3093
        return detailedDescriptionElement;
3094

    
3095
    }
3096

    
3097
    /**
3098
     * Creates a styled text as a part of the form.
3099
     *
3100
     * @param parent
3101
     *            the text parent
3102
     * @param value
3103
     *            the text initial value
3104
     * @param style
3105
     *            the text style
3106
     * @return the text widget
3107
     */
3108
    public StyledText createStyledText(Composite parent, String value, int style) {
3109
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3110
        if (value != null) {
3111
            text.setText(value);
3112
        }
3113
        text.setForeground(getColors().getForeground());
3114
        text.setBackground(getColors().getBackground());
3115
        // text.addFocusListener(visibilityHandler);
3116
        return text;
3117
    }
3118

    
3119
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3120
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3121
        addAndAdaptSection(parentElement, section);
3122
        return section;
3123
    }
3124

    
3125
    /**
3126
     * @param formElement
3127
     * @param conversationHolder
3128
     * @param style
3129
     * @return
3130
     */
3131
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3132
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3133
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3134
        addAndAdaptSection(formElement, section);
3135
        return section;
3136
    }
3137

    
3138

    
3139
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3140
			ICdmFormElement parentElement, int style) {
3141
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3142
		addAndAdaptElement(parentElement, section);
3143
        return section;
3144
	}
3145

    
3146
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3147
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3148
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3149
	        addAndAdaptSection(formElement, section);
3150
	        return section;
3151
	}
3152

    
3153

    
3154

    
3155
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3156
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3157
//				 initialText, textHeight, style);
3158
//	        adapt(element);
3159
//	        parentElement.addElement(element);
3160
//	        return element;
3161
//	}
3162

    
3163

    
3164

    
3165

    
3166

    
3167

    
3168

    
3169
}
(7-7/47)