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

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

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

    
371
    @Inject
372
    private IEclipseContext context;
373

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
514
        super.adapt(composite);
515
    }
516

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
956

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1174
    private class BoldFontHolder2 {
1175
        private Font normalFont;
1176

    
1177
        private Font boldFont;
1178

    
1179
        public BoldFontHolder2() {
1180
        }
1181

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1493
    /**
1494
     * @return the propertyChangeListeners
1495
     */
1496
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1497
        return propertyChangeListeners;
1498
    }
1499

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

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

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

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

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

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

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

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

    
1649
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1650
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1651

    
1652
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1653
                selectionProvider, style);
1654

    
1655
        parentElement.addElement(section);
1656
        adapt(section);
1657
        return section;
1658

    
1659
    }
1660

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

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

    
1681

    
1682
        adapt(element);
1683
        parentElement.addElement(element);
1684
        return element;
1685
    }
1686

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

    
1693
    public CharacterDetailElement createCharacterDetailElement(ICdmFormElement parentElement, int style){
1694
        CharacterDetailElement element = new CharacterDetailElement(this, parentElement);
1695
        addAndAdaptElement(parentElement, element);
1696
        return element;
1697
    }
1698

    
1699
    public FeatureTreeDetailElement createFeatureTreeDetailElement(ICdmFormElement parentElement, int style){
1700
        FeatureTreeDetailElement element = new FeatureTreeDetailElement(this, parentElement);
1701
        addAndAdaptElement(parentElement, element);
1702
        return element;
1703
    }
1704

    
1705
    public FeatureNodeDetailElement createFeatureNodeDetailElement(ICdmFormElement parentElement, int style){
1706
        FeatureNodeDetailElement element = new FeatureNodeDetailElement(this, parentElement);
1707
        addAndAdaptElement(parentElement, element);
1708
        return element;
1709
    }
1710

    
1711

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1791

    
1792

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2051
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
2052
        parentElement.addElement(section);
2053
        adapt(section);
2054
    }
2055

    
2056
    //--------DetailElements------------
2057

    
2058
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
2059
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
2060
        addAndAdaptElement(parentElement, element);
2061
        return element;
2062
    }
2063

    
2064
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
2065
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
2066
        addAndAdaptElement(parentElement, element);
2067
        return element;
2068
    }
2069

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

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

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

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

    
2094
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
2095
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2096
        addAndAdaptElement(parentElement, element);
2097
        return element;
2098
    }
2099

    
2100
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2101
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2102
        addAndAdaptElement(parentElement, element);
2103
        return element;
2104
    }
2105

    
2106
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2107
        UserDetailElement element = new UserDetailElement(this, parentElement);
2108
        addAndAdaptElement(parentElement, element);
2109
        return element;
2110
    }
2111

    
2112
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2113
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2114
        addAndAdaptElement(parentElement, element);
2115
        return element;
2116
    }
2117

    
2118
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2119
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2120
        addAndAdaptElement(parentElement, element);
2121
        return element;
2122
    }
2123

    
2124
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2125
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2126
        addAndAdaptElement(parentElement, element);
2127
        return element;
2128
    }
2129

    
2130
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2131
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2132
        addAndAdaptElement(parentElement, element);
2133
        return element;
2134
    }
2135

    
2136
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2137
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2138
        addAndAdaptElement(parentElement, element);
2139
        return element;
2140
    }
2141

    
2142
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2143
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2144
        adapt(element);
2145
        parentElement.addElement(element);
2146

    
2147
        return element;
2148
    }
2149

    
2150
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2151
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2152
        addAndAdaptElement(parentElement, element);
2153
        return element;
2154
    }
2155

    
2156
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
2157
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
2158
        addAndAdaptElement(parentElement, element);
2159
        return element;
2160
    }
2161

    
2162
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2163
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2164
        addAndAdaptElement(parentElement, element);
2165
        return element;
2166
    }
2167

    
2168
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2169
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2170
        addAndAdaptElement(parentElement, element);
2171
        return element;
2172
    }
2173

    
2174
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2175
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2176
        addAndAdaptElement(parentElement, element);
2177
        return element;
2178
    }
2179

    
2180
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2181
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2182
        addAndAdaptElement(parentElement, element);
2183
        return element;
2184
    }
2185

    
2186
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2187
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2188
        addAndAdaptElement(parentElement, element);
2189
        return element;
2190
    }
2191

    
2192
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2193
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2194
        addAndAdaptElement(parentElement, element);
2195
        return element;
2196
    }
2197

    
2198
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2199
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2200
        addAndAdaptElement(parentElement, element);
2201
        return element;
2202
    }
2203

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

    
2210
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2211
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2212
        addAndAdaptElement(parentElement, element);
2213
        return element;
2214
    }
2215

    
2216
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2217
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2218
        addAndAdaptElement(parentElement, element);
2219
        return element;
2220
    }
2221

    
2222
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2223
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2224
        addAndAdaptElement(parentElement, element);
2225
        return element;
2226
    }
2227

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

    
2234
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2235
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2236
        addAndAdaptElement(parentElement, element);
2237
        return element;
2238
    }
2239

    
2240

    
2241
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2242
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2243
        addAndAdaptElement(parentElement, element);
2244
        return element;
2245
    }
2246

    
2247
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2248
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2249
        addAndAdaptElement(parentElement, element);
2250
        return element;
2251
    }
2252

    
2253
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2254
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2255
        addAndAdaptElement(parentElement, element);
2256
        return element;
2257
    }
2258

    
2259
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2260
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2261
        addAndAdaptElement(parentElement, element);
2262
        return element;
2263
    }
2264

    
2265
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2266
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2267
        addAndAdaptElement(parentElement, element);
2268
        return element;
2269
    }
2270

    
2271
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2272
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2273
        addAndAdaptElement(parentElement, element);
2274
        return element;
2275
    }
2276

    
2277
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2278
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2279
        addAndAdaptElement(parentElement, element);
2280
        return element;
2281
    }
2282

    
2283
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2284
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2285
        addAndAdaptElement(parentElement, element);
2286
        return element;
2287
    }
2288

    
2289
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2290
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2291
        addAndAdaptElement(parentElement, element);
2292
        return element;
2293
    }
2294

    
2295
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2296
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2297
        addAndAdaptElement(parentElement, element);
2298
        return element;
2299
    }
2300

    
2301
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2302
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2303
        addAndAdaptElement(parentElement, element);
2304
        return element;
2305
    }
2306

    
2307
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2308
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2309
        addAndAdaptElement(parentElement, element);
2310
        return element;
2311
    }
2312

    
2313
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2314
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2315
        addAndAdaptElement(parentElement, element);
2316
        return element;
2317
    }
2318

    
2319
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2320
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2321
        addAndAdaptElement(parentElement, element);
2322
        return element;
2323
    }
2324

    
2325
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2326
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2327
        addAndAdaptElement(parentElement, element);
2328
        return element;
2329
    }
2330

    
2331
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2332
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2333
        addAndAdaptElement(parentElement, element);
2334
        return element;
2335
    }
2336

    
2337
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2338
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2339
        addAndAdaptElement(parentElement, mediaDetailElement);
2340
        return mediaDetailElement;
2341
    }
2342

    
2343
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2344
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2345
        addAndAdaptElement(parentElement, element);
2346
        return element;
2347
    }
2348

    
2349
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2350
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2351
        addAndAdaptElement(parentElement, element);
2352
        return element;
2353
    }
2354

    
2355
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2356
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2357
        addAndAdaptElement(parentElement, element);
2358
        return element;
2359
    }
2360

    
2361
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2362
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2363
        addAndAdaptElement(parentElement, element);
2364
        return element;
2365
    }
2366

    
2367
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2368
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2369
        addAndAdaptElement(parentElement, element);
2370
        return element;
2371
    }
2372

    
2373
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2374
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2375
        addAndAdaptElement(parentElement, element);
2376
        return element;
2377
    }
2378

    
2379
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2380
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2381
        addAndAdaptElement(parentElement, element);
2382
        return element;
2383
    }
2384

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2485
    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2486
        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2487
        addAndAdaptSection(parentElement, section);
2488
        return section;
2489
    }
2490

    
2491
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2492
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2493
        addAndAdaptSection(parentElement, section);
2494
        return section;
2495
    }
2496

    
2497
    public SourceSection createSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2498
        SourceSection section = new SourceSection(this, conversation, parentElement, style);
2499
        addAndAdaptSection(parentElement, section);
2500
        return section;
2501
    }
2502

    
2503
    public ScopeSection createScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2504
        ScopeSection section = new ScopeSection(this, conversation, parentElement, style);
2505
        addAndAdaptSection(parentElement, section);
2506
        return section;
2507
    }
2508

    
2509
    public DescriptionSourceSection createDescriptionSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2510
        DescriptionSourceSection section = new DescriptionSourceSection(this, conversation, parentElement, style);
2511
        addAndAdaptSection(parentElement, section);
2512
        return section;
2513
    }
2514

    
2515
    public TypeDesignationSection createTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2516
        TypeDesignationSection section = new TypeDesignationSection(this, conversation, parentElement, style);
2517
        addAndAdaptSection(parentElement, section);
2518
        return section;
2519
    }
2520

    
2521
    public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2522
        StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
2523
        addAndAdaptSection(parentElement, section);
2524
        return section;
2525
    }
2526

    
2527
    public StatisticalMeasurementValueSection createStatisticalMeasurementValueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2528
        StatisticalMeasurementValueSection section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
2529
        addAndAdaptSection(parentElement, section);
2530
        return section;
2531
    }
2532

    
2533
    public DescribedSpecimenSection createDescribedSpecimenSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2534
        DescribedSpecimenSection section = new DescribedSpecimenSection(this, conversation, parentElement, style);
2535
        addAndAdaptSection(parentElement, section);
2536
        return section;
2537
    }
2538

    
2539
    public StateVocabularyCollectionSection createStateVocabulariesSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2540
        StateVocabularyCollectionSection section = new StateVocabularyCollectionSection(this, conversation, parentElement, style);
2541
        addAndAdaptSection(parentElement, section);
2542
        return section;
2543
    }
2544

    
2545
    public RecommendedModifierVocabulariesCollectionSection createRecommendedModifierVocabulariesCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2546
        RecommendedModifierVocabulariesCollectionSection section = new RecommendedModifierVocabulariesCollectionSection(this, conversation, parentElement, style);
2547
        addAndAdaptSection(parentElement, section);
2548
        return section;
2549
    }
2550

    
2551
    public MeasurementUnitCollectionSection createMeasurementUnitCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2552
        MeasurementUnitCollectionSection section = new MeasurementUnitCollectionSection(this, conversation, parentElement, style);
2553
        addAndAdaptSection(parentElement, section);
2554
        return section;
2555
    }
2556

    
2557
    public StatisticalMeasureCollectionSection createStatisticalMeasureCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2558
        StatisticalMeasureCollectionSection section = new StatisticalMeasureCollectionSection(this, conversation, parentElement, style);
2559
        addAndAdaptSection(parentElement, section);
2560
        return section;
2561
    }
2562

    
2563
    public CollectingAreasDetailSection createCollectingAreasDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2564
        CollectingAreasDetailSection section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
2565
        addAndAdaptSection(parentElement, section);
2566
        return section;
2567
    }
2568

    
2569
    public GeoScopeDetailSection createGeoScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2570
        GeoScopeDetailSection section = new GeoScopeDetailSection(this, conversation, parentElement, style);
2571
        addAndAdaptSection(parentElement, section);
2572
        return section;
2573
    }
2574

    
2575
    public GeoScopePolyKeyDetailSection createGeoScopePolyKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2576
        GeoScopePolyKeyDetailSection section = new GeoScopePolyKeyDetailSection(this, conversation, parentElement, style);
2577
        addAndAdaptSection(parentElement, section);
2578
        return section;
2579
    }
2580

    
2581
    public IdentifierSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2582
        IdentifierSection section = new IdentifierSection(this, conversation, parentElement, style);
2583
        addAndAdaptSection(parentElement, section);
2584
        return section;
2585
    }
2586

    
2587
    public DerivedUnitFacadeIdentifierSection createDerivedUnitFacadeIdentifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2588
    	DerivedUnitFacadeIdentifierSection section = new DerivedUnitFacadeIdentifierSection(this, conversation, parentElement, style);
2589
    	addAndAdaptSection(parentElement, section);
2590
    	return section;
2591
    }
2592

    
2593
    public CurrentSampleDesignationDetailSection createCurrentSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2594
        CurrentSampleDesignationDetailSection section = new CurrentSampleDesignationDetailSection(this, conversation, parentElement, style);
2595
        addAndAdaptSection(parentElement, section);
2596
        return section;
2597
    }
2598

    
2599
    public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2600
        CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
2601
        addAndAdaptSection(parentElement, section);
2602
        return section;
2603
    }
2604

    
2605
    public PreservedSpecimenCurrentDeterminationDetailSection createPreservedSpecimenCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2606
        PreservedSpecimenCurrentDeterminationDetailSection section = new PreservedSpecimenCurrentDeterminationDetailSection(this, conversation, parentElement, style);
2607
        addAndAdaptSection(parentElement, section);
2608
        return section;
2609
    }
2610

    
2611
    public SampleDesignationHistoryDetailSection createSampleDesignationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2612
        SampleDesignationHistoryDetailSection section = new SampleDesignationHistoryDetailSection(this, conversation, parentElement, style);
2613
        addAndAdaptSection(parentElement, section);
2614
        return section;
2615
    }
2616

    
2617
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2618
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
2619
        addAndAdaptSection(parentElement, section);
2620
        return section;
2621
    }
2622

    
2623
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2624
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
2625
        addAndAdaptSection(parentElement, section);
2626
        return section;
2627
    }
2628

    
2629
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2630
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2631
        addAndAdaptSection(parentElement, section);
2632
        return section;
2633
    }
2634

    
2635
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2636
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2637
        addAndAdaptSection(parentElement, section);
2638
        return section;
2639
    }
2640

    
2641
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2642
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2643
        addAndAdaptSection(parentElement, section);
2644
        return section;
2645
    }
2646

    
2647
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2648
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2649
        addAndAdaptSection(parentElement, section);
2650
        return section;
2651
    }
2652

    
2653
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2654
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2655
        addAndAdaptSection(parentElement, section);
2656
        return section;
2657
    }
2658

    
2659
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2660
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2661
        addAndAdaptSection(parentElement, section);
2662
        return section;
2663
    }
2664

    
2665
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2666
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2667
        addAndAdaptSection(parentElement, section);
2668
        return section;
2669
    }
2670

    
2671

    
2672
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2673
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2674
        AbstractEntityCollectionElement<?> element = null;
2675

    
2676
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2677

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

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

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

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

    
2853

    
2854
        if (element == null) {
2855
            MessagingUtils.messageDialog(
2856
                    String.format("Error when creating section %s",
2857
                            parentElement.getClass().getSimpleName()),
2858
                    this,
2859
                    String.format("Could not generate collection element for entity of class %s."
2860
                            + " Looks like the case is not yet handled. Check implementation.\n"
2861
                            + "Entity: %s", entity.getClass(), entity.toString()), null);
2862
        }
2863

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

    
2872
        return element;
2873
    }
2874

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

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

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

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

    
2983

    
2984

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

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

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

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

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

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

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

    
3085
    }
3086

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

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

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

    
3128

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

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

    
3143

    
3144

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

    
3153

    
3154

    
3155

    
3156

    
3157

    
3158

    
3159
}
(7-7/47)