Project

General

Profile

Download (171 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.ui.element;
10

    
11
import java.util.ArrayList;
12
import java.util.Comparator;
13
import java.util.HashSet;
14
import java.util.List;
15
import java.util.Map;
16
import java.util.Set;
17

    
18
import javax.inject.Inject;
19

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

    
56
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
57
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
58
import eu.etaxonomy.cdm.common.DOI;
59
import eu.etaxonomy.cdm.common.URI;
60
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
61
import eu.etaxonomy.cdm.model.agent.ORCID;
62
import eu.etaxonomy.cdm.model.agent.Person;
63
import eu.etaxonomy.cdm.model.agent.Team;
64
import eu.etaxonomy.cdm.model.common.Annotation;
65
import eu.etaxonomy.cdm.model.common.CdmBase;
66
import eu.etaxonomy.cdm.model.common.Credit;
67
import eu.etaxonomy.cdm.model.common.ExtendedTimePeriod;
68
import eu.etaxonomy.cdm.model.common.Extension;
69
import eu.etaxonomy.cdm.model.common.ICdmBase;
70
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
71
import eu.etaxonomy.cdm.model.common.Identifier;
72
import eu.etaxonomy.cdm.model.common.LSID;
73
import eu.etaxonomy.cdm.model.common.Language;
74
import eu.etaxonomy.cdm.model.common.LanguageString;
75
import eu.etaxonomy.cdm.model.common.Marker;
76
import eu.etaxonomy.cdm.model.common.TimePeriod;
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.FeatureState;
86
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
87
import eu.etaxonomy.cdm.model.description.KeyStatement;
88
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
89
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
90
import eu.etaxonomy.cdm.model.description.QuantitativeData;
91
import eu.etaxonomy.cdm.model.description.State;
92
import eu.etaxonomy.cdm.model.description.StateData;
93
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
94
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
95
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
96
import eu.etaxonomy.cdm.model.description.TemporalData;
97
import eu.etaxonomy.cdm.model.description.TextData;
98
import eu.etaxonomy.cdm.model.location.NamedArea;
99
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
100
import eu.etaxonomy.cdm.model.location.Point;
101
import eu.etaxonomy.cdm.model.media.ExternalLink;
102
import eu.etaxonomy.cdm.model.media.ImageFile;
103
import eu.etaxonomy.cdm.model.media.Media;
104
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
105
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
106
import eu.etaxonomy.cdm.model.media.Rights;
107
import eu.etaxonomy.cdm.model.molecular.DnaSample;
108
import eu.etaxonomy.cdm.model.name.NameRelationship;
109
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
110
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
111
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
112
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
113
import eu.etaxonomy.cdm.model.name.TextualTypeDesignation;
114
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
115
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
116
import eu.etaxonomy.cdm.model.permission.GrantedAuthorityImpl;
117
import eu.etaxonomy.cdm.model.permission.Group;
118
import eu.etaxonomy.cdm.model.permission.User;
119
import eu.etaxonomy.cdm.model.reference.Reference;
120
import eu.etaxonomy.cdm.model.taxon.Taxon;
121
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
122
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
123
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
124
import eu.etaxonomy.cdm.model.term.DefinedTerm;
125
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
126
import eu.etaxonomy.cdm.model.term.IEnumTerm;
127
import eu.etaxonomy.cdm.model.term.Representation;
128
import eu.etaxonomy.cdm.model.term.TermBase;
129
import eu.etaxonomy.cdm.model.term.TermTree;
130
import eu.etaxonomy.cdm.model.term.TermType;
131
import eu.etaxonomy.cdm.model.term.TermVocabulary;
132
import eu.etaxonomy.cdm.persistence.dto.TermDto;
133
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
134
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
135
import eu.etaxonomy.taxeditor.model.MessagingUtils;
136
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
137
import eu.etaxonomy.taxeditor.store.StoreUtil;
138
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
139
import eu.etaxonomy.taxeditor.ui.combo.InverseTermWrapper;
140
import eu.etaxonomy.taxeditor.ui.combo.MisappliedRelationshipComboElement;
141
import eu.etaxonomy.taxeditor.ui.combo.NameRelationshipTypeCombo;
142
import eu.etaxonomy.taxeditor.ui.combo.VocabularyComboElement;
143
import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
144
import eu.etaxonomy.taxeditor.ui.dialog.CloneClassificationDetailElement;
145
import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection.UnitType;
146
import eu.etaxonomy.taxeditor.ui.mvc.element.DateElement;
147
import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
148
import eu.etaxonomy.taxeditor.ui.openurl.OpenUrlSelectorElement;
149
import eu.etaxonomy.taxeditor.ui.password.EditPasswordElement;
150
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
151
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
152
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
153
import eu.etaxonomy.taxeditor.ui.section.EmptyElement;
154
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement;
155
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection;
156
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailElement;
157
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
158
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailElement;
159
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
160
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
161
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberSection;
162
import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
163
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailElement;
164
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailSection;
165
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeAgentRelationCollectionElement;
166
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeAgentRelationCollectionSection;
167
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailElement;
168
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailSection;
169
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksElement;
170
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
171
import eu.etaxonomy.taxeditor.ui.section.common.ReferenceEntityDetailElement;
172
import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
173
import eu.etaxonomy.taxeditor.ui.section.description.CommonNameSourceElement;
174
import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
175
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
176
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailElement;
177
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
178
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
179
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
180
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
181
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceElement;
182
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
183
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceElement;
184
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
185
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
186
import eu.etaxonomy.taxeditor.ui.section.description.ModifierElement;
187
import eu.etaxonomy.taxeditor.ui.section.description.ModifierSection;
188
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageDetailElement;
189
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
190
import eu.etaxonomy.taxeditor.ui.section.description.ScopeElement;
191
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
192
import eu.etaxonomy.taxeditor.ui.section.description.StateDataElement;
193
import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;
194
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueElement;
195
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueSection;
196
import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;
197
import eu.etaxonomy.taxeditor.ui.section.description.detail.CategoricalDataDetailElement;
198
import eu.etaxonomy.taxeditor.ui.section.description.detail.CommonNameDetailElement;
199
import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
200
import eu.etaxonomy.taxeditor.ui.section.description.detail.IndividualsAssociationDetailElement;
201
import eu.etaxonomy.taxeditor.ui.section.description.detail.QuantitativeDataDetailElement;
202
import eu.etaxonomy.taxeditor.ui.section.description.detail.TaxonInteractionDetailElement;
203
import eu.etaxonomy.taxeditor.ui.section.description.detail.TemporalDataDetailElement;
204
import eu.etaxonomy.taxeditor.ui.section.description.detail.TextDataDetailElement;
205
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDetailElement;
206
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDetailSection;
207
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDtoDetailElement;
208
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDtoDetailSection;
209
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDetailElement;
210
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDetailSection;
211
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDtoDetailElement;
212
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDtoDetailSection;
213
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement;
214
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
215
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureNodeDetailElement;
216
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureNodeDetailSection;
217
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureTreeDetailElement;
218
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureTreeDetailElementForNode;
219
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureTreeDetailSection;
220
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureTreeDetailSectionForNode;
221
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfCollectionElement;
222
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfEntityCollectionSection;
223
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfEntityCollectionSectionForNode;
224
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfCollectionElement;
225
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfEntityCollectionSection;
226
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfEntityCollectionSectionForNode;
227
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityCollectionElement;
228
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailElement;
229
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
230
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailElement;
231
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
232
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailElement;
233
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
234
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailElement;
235
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
236
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailElement;
237
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
238
import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
239
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
240
import eu.etaxonomy.taxeditor.ui.section.media.ImageFileElement;
241
import eu.etaxonomy.taxeditor.ui.section.media.MediaDetailElement;
242
import eu.etaxonomy.taxeditor.ui.section.media.MediaMetaElement;
243
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationElement;
244
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartElement;
245
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartSection;
246
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationSection;
247
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
248
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
249
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailSection;
250
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailElement;
251
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailSection;
252
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailElement;
253
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailSection;
254
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailElement;
255
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
256
import eu.etaxonomy.taxeditor.ui.section.name.NameTypeDesignationElement;
257
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusElement;
258
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
259
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailElement;
260
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
261
import eu.etaxonomy.taxeditor.ui.section.name.RuleConsideredElement;
262
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
263
import eu.etaxonomy.taxeditor.ui.section.name.TextTypeDesignationElement;
264
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
265
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreaDetailElement;
266
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
267
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
268
import eu.etaxonomy.taxeditor.ui.section.occurrence.CurrentDeterminationDetailSection;
269
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailElement;
270
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
271
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailElement;
272
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
273
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitMediaSection;
274
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement;
275
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
276
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement;
277
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection;
278
import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
279
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailElement;
280
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailSection;
281
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailElement;
282
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSection;
283
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailElement;
284
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
285
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopeDetailSection;
286
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopePolyKeyDetailSection;
287
import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
288
import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
289
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElement;
290
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailSection;
291
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationElement;
292
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationSection;
293
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailElement;
294
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
295
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenCurrentDeterminationDetailSection;
296
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailElement;
297
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailSection;
298
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailElement;
299
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailSection;
300
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenSourceCollectionDetailSection;
301
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractSampleDesignationDetailSection;
302
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailElement;
303
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailSection;
304
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoCollectionDetailSection;
305
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoDetailElement;
306
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailElement;
307
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailSection;
308
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailElement;
309
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailSection;
310
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.CurrentSampleDesignationDetailSection;
311
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailElement;
312
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
313
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailElement;
314
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
315
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationDetailElement;
316
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationSection;
317
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.PrimerGeneralDetailElement;
318
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailElement;
319
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailSection;
320
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationHistoryDetailSection;
321
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationTextDetailElement;
322
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceContigFileCollectionDetailSection;
323
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailElement;
324
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
325
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailElement;
326
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
327
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailElement;
328
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
329
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadPherogramCollectionDetailSection;
330
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailElement;
331
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
332
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailElement;
333
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
334
import eu.etaxonomy.taxeditor.ui.section.reference.AdvancedNomenclaturalSourceElement;
335
import eu.etaxonomy.taxeditor.ui.section.reference.AdvancedSourceElement;
336
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
337
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
338
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalSourceElement;
339
import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceAdvancedSection;
340
import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceElement;
341
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement;
342
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
343
import eu.etaxonomy.taxeditor.ui.section.reference.SingleSourceSection;
344
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationElement;
345
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
346
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseElement;
347
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
348
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditElement;
349
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
350
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionElement;
351
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
352
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
353
import eu.etaxonomy.taxeditor.ui.section.supplemental.IdentifiableSourceElement;
354
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerElement;
355
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
356
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsElement;
357
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
358
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
359
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement;
360
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
361
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.DerivedUnitFacadeIdentifierSection;
362
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierElement;
363
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierSection;
364
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement;
365
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
366
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailElement;
367
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
368
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailElement;
369
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailSection;
370
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonOfRelationshipElement;
371
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailElement;
372
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
373
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailElement;
374
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
375
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailElement;
376
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
377
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailElement;
378
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
379
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement;
380
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailSection;
381
import eu.etaxonomy.taxeditor.ui.section.vocabulary.FeatureDetailElement;
382
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionElement;
383
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionSection;
384
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitDtoCollectionElement;
385
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitDtoCollectionSection;
386
import eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailSection;
387
import eu.etaxonomy.taxeditor.ui.section.vocabulary.PresenceAbsenceTermDetailElement;
388
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierDtoVocabulariesElement;
389
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesCollectionSection;
390
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesDtoCollectionSection;
391
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesElement;
392
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionElement;
393
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionSection;
394
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyDtoCollectionElement;
395
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyDtoCollectionSection;
396
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionElement;
397
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionSection;
398
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureDtoCollectionElement;
399
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureDtoCollectionSection;
400
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermMediaSection;
401
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailElement;
402
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
403
import eu.etaxonomy.taxeditor.ui.selection.CommonNameReferenceSelectionElement;
404
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
405
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementWithAbbreviatedTitle;
406
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementWithIdInVocabulary;
407
import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
408
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
409
import eu.etaxonomy.taxeditor.view.detail.CdmSectionPart;
410

    
411
/**
412
 * CdmFormFactory class.
413
 *
414
 * @author n.hoffmann
415
 * @created Feb 24, 2010
416
 */
417
public class CdmFormFactory extends FormToolkit {
418

    
419
    private BoldFontHolder2 boldFontHolder2;
420
    private MouseListener selectionMouseHandler;
421
    private FocusListener selectionFocusHandler;
422

    
423
    @Inject
424
    private IEclipseContext context;
425

    
426
    private final Set<SelectionListener> selectionListenerList = new HashSet<>();
427

    
428
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<>();
429

    
430
    private final int orientation = Window.getDefaultOrientation();
431
    private ISelectionProvider selectionProvider;
432

    
433
    /** Constant <code>EMPTY_SELECTION</code> */
434
    public static ISelection EMPTY_SELECTION = new ISelection() {
435
        @Override
436
        public boolean isEmpty() {
437
            return true;
438
        }
439
    };
440

    
441
    /**
442
     * @author n.hoffmann
443
     * @date Jan 25, 2010
444
     */
445
    private class SelectionMouseHandler extends MouseAdapter {
446
        @Override
447
        public void mouseDown(MouseEvent e) {
448
            notifySelectionListeners(e);
449
        }
450
    }
451

    
452
    /**
453
     * @author n.hoffmann
454
     * @date Jan 25, 2010
455
     */
456
    private class SelectionFocusHandler extends FocusAdapter {
457
        @Override
458
        public void focusGained(FocusEvent e) {
459
            notifySelectionListeners(e);
460
        }
461
    }
462

    
463
    private void notifySelectionListeners(TypedEvent e) {
464
        Event event = new Event();
465
        event.widget = e.widget;
466
        SelectionEvent selectionEvent = new SelectionEvent(event);
467

    
468
        for (SelectionListener listener : selectionListenerList) {
469
            listener.widgetSelected(selectionEvent);
470
        }
471
    }
472

    
473
    public CdmFormFactory(Display display) {
474
        this(display, null);
475
    }
476

    
477
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
478
        super(display);
479
        this.selectionProvider = selectionProvider;
480
        init();
481
    }
482

    
483
    private void init() {
484
        boldFontHolder2 = new BoldFontHolder2();
485
        selectionMouseHandler = new SelectionMouseHandler();
486
        selectionFocusHandler = new SelectionFocusHandler();
487
    }
488

    
489
    public IEclipseContext getContext() {
490
        return context;
491
    }
492

    
493
    /**
494
     * Creates an instance initialized with the correct selectionProvider
495
     *
496
     * Make sure to remove the instance when the entityComposite disposes via
497
     * destroySelectionArbitrator(..)
498
     *
499
     * @param entityElement
500
     *            a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
501
     *            object.
502
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
503
     *         object.
504
     */
505
    public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
506
        SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
507
        selectionArbitrator.addSelectionProvider(selectionProvider);
508
        selectionProvider.addSelectionChangedListener(selectionArbitrator);
509
        addSelectionListener(selectionArbitrator);
510
        return selectionArbitrator;
511
    }
512

    
513
    /**
514
     * <p>
515
     * destroySelectionArbitrator
516
     * </p>
517
     *
518
     * @param selectionArbitrator
519
     *            a
520
     *            {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
521
     *            object.
522
     */
523
    public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
524
        if(selectionArbitrator==null){
525
            return;
526
        }
527
        removeSelectionListener(selectionArbitrator);
528
        if (selectionProvider != null) {
529
            selectionProvider.removeSelectionChangedListener(selectionArbitrator);
530
        } else {
531
            MessagingUtils.error(this.getClass(),
532
                    "Tried to destroy a selection listener from this factories listeners but was null", null);
533
        }
534
    }
535

    
536
    /**
537
     * <p>
538
     * Adapts the {@link AbstractCdmFormElement}:<br>
539
     * - sets the {@link IPropertyChangeListener}s handled by this class
540
     * </p>
541
     *
542
     * @param formElement
543
     *            a
544
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
545
     *            object.
546
     */
547
    public void adapt(ICdmFormElement formElement) {
548
        formElement.setPropertyChangeListeners(propertyChangeListeners);
549
    }
550

    
551
    @Override
552
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
553
        if (trackFocus) {
554
            control.addFocusListener(selectionFocusHandler);
555
        }
556
        super.adapt(control, trackFocus, trackKeyboard);
557
    }
558

    
559
    @Override
560
    public void adapt(Composite composite) {
561
        composite.addMouseListener(selectionMouseHandler);
562

    
563
        super.adapt(composite);
564
    }
565

    
566
    /**
567
     * destroyElement
568
     *
569
     * @param formElement
570
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
571
     *            object.
572
     */
573
    public void destroyElement(ICdmFormElement formElement) {
574
        // return if element was not initialized
575
        if (formElement == null) {
576
            return;
577
        }
578
        // destroy selection arbitrator, if any
579
        if (formElement instanceof ISelectableElement) {
580
            destroySelectionArbitrator(((ISelectableElement) formElement).getSelectionArbitrator());
581
        }
582
        // remove this element form its parents list of elements
583
        // ICdmFormElement parentElement = formElement.getParentElement();
584
        // if(parentElement != null){
585
        // parentElement.removeElement(formElement);
586
        // }
587
        // call destroy on child elements recursively
588

    
589
        Set<ICdmFormElement> tempFormElements = new HashSet<>();
590
        tempFormElements.addAll(formElement.getElements());
591
        for(ICdmFormElement childElement: tempFormElements) {
592
            destroyElement(childElement);
593
        }
594
        // dispose of the controls
595
        for (Control control : formElement.getControls()) {
596
            // we added the layoutComposite of the parental element as the
597
            // layout composite to this formElement
598
            // but we do not want to destroy it.
599
            if (control.equals(formElement.getLayoutComposite())) {
600
                continue;
601
            } else {
602
                if (!control.isDisposed()){
603
                    control.dispose();
604
                }
605
                control = null; //needed?
606
            }
607
        }
608
    }
609

    
610
    /**
611
     * createEmptyCell
612
     *
613
     * @param parent
614
     *            a {@link org.eclipse.swt.widgets.Composite} object.
615
     * @return a {@link org.eclipse.swt.widgets.Label} object.
616
     */
617
    public Label createEmptyCell(Composite parent) {
618
        return this.createLabel(parent, null);
619
    }
620

    
621
    /**
622
     * createMultiLanguageTextElement
623
     *
624
     * @param parentElement
625
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
626
     *            object.
627
     * @param labelString
628
     *            a {@link java.lang.String} object.
629
     * @param multilanguageText
630
     *            a {@link java.util.Map} object.
631
     * @param textHeight
632
     *            a int.
633
     * @param style
634
     *            a int.
635
     * @return a
636
     *         {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
637
     *         object.
638
     */
639
    public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
640
            Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
641
        MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
642
                multilanguageText, textHeight, style);
643
        adapt(element);
644
        parentElement.addElement(element);
645
        return element;
646
    }
647

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

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

    
696
    public TranslatableRepresentationElement createTranslatableRepresentationElementDto(ICdmFormElement parentElement, Representation representation, TermDto term,int textHeight, int style, boolean fillDetails) {
697
        TranslatableRepresentationElement element = new TranslatableRepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
698
        adapt(element);
699
        parentElement.addElement(element);
700
        return element;
701
    }
702

    
703

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

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

    
728
    /**
729
     * <p>
730
     * createTextWithLabelElement
731
     * </p>
732
     *
733
     * @param parentElement
734
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
735
     *            object.
736
     * @param labelString
737
     *            a {@link java.lang.String} object.
738
     * @param initialText
739
     *            a {@link java.lang.String} object.
740
     * @param style
741
     *            a int.
742
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
743
     *         object.
744
     */
745
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
746
            String initialText, int style) {
747
        return createTextWithLabelElement(parentElement, labelString, initialText, null, style);
748
    }
749

    
750
    /**
751
     * createTextWithLabelElement
752
     *
753
     * @param parentElement
754
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
755
     *            object.
756
     * @param labelString
757
     *            a {@link java.lang.String} object.
758
     * @param initialText
759
     *            a {@link java.lang.String} object.
760
     * @param textLimit maximal number of characters allowed
761
     * @param style
762
     *            a int.
763
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
764
     *         object.
765
     */
766
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
767
            String initialText, Integer textLimit, int style) {
768
        if(initialText==null){
769
            initialText = "";
770
        }
771

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

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

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

    
795
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
796
            URI initialUri, int style) {
797
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
798
        adapt(element);
799
        parentElement.addElement(element);
800
        return element;
801
    }
802
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
803
            URI initialUri,Integer textHeight, int style) {
804
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, textHeight, style);
805
        adapt(element);
806
        parentElement.addElement(element);
807
        return element;
808
    }
809

    
810

    
811
    public DoiWithLabelElement createDoiWithLabelElement(ICdmFormElement parentElement, String labelString,
812
            DOI initialDoi, int style) {
813
        DoiWithLabelElement element = new DoiWithLabelElement(this, parentElement, labelString, initialDoi, null, style);
814
        adapt(element);
815
        parentElement.addElement(element);
816
        return element;
817
    }
818
    public DoiWithLabelElement createDoiWithLabelElement(ICdmFormElement parentElement, String labelString,
819
            DOI initialDoi,Integer textHeight, int style) {
820
        DoiWithLabelElement element = new DoiWithLabelElement(this, parentElement, labelString, initialDoi, textHeight, style);
821
        adapt(element);
822
        parentElement.addElement(element);
823
        return element;
824
    }
825

    
826
    public OrcidWithLabelElement createOrcidWithLabelElement(ICdmFormElement parentElement, String labelString,
827
            ORCID initialDoi, int style) {
828
        OrcidWithLabelElement element = new OrcidWithLabelElement(this, parentElement, labelString, initialDoi, null, style);
829
        adapt(element);
830
        parentElement.addElement(element);
831
        return element;
832
    }
833
    public OrcidWithLabelElement createDoiWithLabelElement(ICdmFormElement parentElement, String labelString,
834
            ORCID initialDoi,Integer textHeight, int style) {
835
        OrcidWithLabelElement element = new OrcidWithLabelElement(this, parentElement, labelString, initialDoi, textHeight, style);
836
        adapt(element);
837
        parentElement.addElement(element);
838
        return element;
839
    }
840

    
841
    /**
842
     * @param element
843
     * @param string
844
     * @param uri
845
     * @param style
846
     * @return
847
     */
848
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
849
            IOpenUrlEnabled openUrlEnabled, int style) {
850
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
851
                style);
852
        adapt(element);
853
        parentElement.addElement(element);
854
        return element;
855
    }
856

    
857
    /**
858
     *
859
     * @param parentElement
860
     * @param labelString
861
     * @param conversationEnabled
862
     * @param user
863
     * @param style
864
     * @return
865
     */
866
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
867
            ConversationHolder conversation, User user, int style) {
868
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
869
        adapt(element);
870
        parentElement.addElement(element);
871
        return element;
872
    }
873

    
874
    /**
875
     * <p>
876
     * createIntegerTextWithLabelElement
877
     * </p>
878
     *
879
     * @param parentElement
880
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
881
     *            object.
882
     * @param labelString
883
     *            a {@link java.lang.String} object.
884
     * @param initialInteger
885
     *            a {@link java.lang.Integer} object.
886
     * @param style
887
     *            a int.
888
     * @return a
889
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
890
     *         object.
891
     */
892
	public FloatWithLabelElement createFloatTextWithLabelElement(
893
			ICdmFormElement parentElement, String labelString,
894
			Number initialNumber, int style) {
895
		FloatWithLabelElement element = new FloatWithLabelElement(this,
896
				parentElement, labelString, initialNumber, style);
897
		adapt(element);
898
		parentElement.addElement(element);
899
		return element;
900
	}
901

    
902
	public BigDecimalWithLabelElement createBigDecimalTextWithLabelElement(
903
            ICdmFormElement parentElement, String labelString,
904
            Number initialNumber, int style) {
905
	    BigDecimalWithLabelElement element = new BigDecimalWithLabelElement(this,
906
                parentElement, labelString, initialNumber, style);
907
        adapt(element);
908
        parentElement.addElement(element);
909
        return element;
910
    }
911

    
912
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
913
            String labelString, LanguageString languageString, int style) {
914
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
915
    }
916

    
917
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
918
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
919
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
920
                languageString, height, isMultiLine, style);
921
        adapt(element);
922
        parentElement.addElement(element);
923
        return element;
924
    }
925

    
926
    /**
927
     * <p>
928
     * createKeyValueViewerElement
929
     * </p>
930
     *
931
     * @param parentElement
932
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
933
     *            object.
934
     * @param keyHeading
935
     *            a {@link java.lang.String} object.
936
     * @param valueHeading
937
     *            a {@link java.lang.String} object.
938
     * @param map
939
     *            a {@link java.util.Map} object.
940
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
941
     *         object.
942
     */
943
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
944
            String valueHeading, Map<Object, Object> map) {
945
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
946
        adapt(element);
947
        parentElement.addElement(element);
948
        return element;
949
    }
950

    
951
    /**
952
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
953
     */
954
    @Deprecated
955
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
956
            ICdmFormElement parentElement, String labelString, T selection, int style) {
957
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString, selection, true, style);
958
        adapt(element);
959
        parentElement.addElement(element);
960
        return element;
961
    }
962

    
963
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
964
            TermType termType,
965
            ICdmFormElement parentElement,
966
            String labelString,
967
            T selection,
968
            int style,
969
            Comparator<T> comparator) {
970
        return this.createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, true, style, false, comparator);
971
    }
972

    
973
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
974
			TermType termType,
975
			ICdmFormElement parentElement,
976
			String labelString,
977
			T selection,
978
			boolean addEmptyElement,
979
			int style) {
980
        return this.createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, addEmptyElement, style, false, null);
981
	}
982

    
983
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
984
			TermType termType,
985
			ICdmFormElement parentElement,
986
			String labelString,
987
			T selection,
988
			int style) {
989
		return  this.createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, true, style, false, null);
990
	}
991
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElementDto(
992
            TermType termType,
993
            ICdmFormElement parentElement,
994
            String labelString,
995
            TermDto selection,
996
            int style) {
997
        return  this.createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, true, style, false, null);
998
    }
999

    
1000
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1001
            List<T> terms,
1002
            ICdmFormElement parentElement,
1003
            String labelString,
1004
            T selection,
1005
            int style) {
1006
        return  this.createDefinedTermComboElement(null, null, terms, parentElement, labelString, selection, true, style, false, null);
1007
    }
1008

    
1009
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1010
	        List<T> terms,
1011
	        ICdmFormElement parentElement,
1012
	        String labelString,
1013
	        T selection,
1014
	        boolean addEmptyElement,
1015
	        int style) {
1016
	    return  this.createDefinedTermComboElement(null, null, terms, parentElement, labelString, selection, addEmptyElement, style, false, null);
1017
	}
1018

    
1019
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1020
			TermType termType,
1021
			ICdmFormElement parentElement,
1022
			String labelString,
1023
			T selection,
1024
			boolean addEmptyElement,
1025
			int style,
1026
			boolean useAbbrevLabel) {
1027
		return createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
1028
	}
1029

    
1030

    
1031
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1032
            TermVocabulary<?> termVocabulary,
1033
            ICdmFormElement parentElement,
1034
            String labelString,
1035
            T selection,
1036
            int style) {
1037
        return this.createDefinedTermComboElement(null, termVocabulary, null, parentElement, labelString, selection, true, style, false, null);
1038
    }
1039

    
1040
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1041
	        TermVocabulary<?> termVocabulary,
1042
	        ICdmFormElement parentElement,
1043
	        String labelString,
1044
	        T selection,
1045
	        boolean addEmptyElement,
1046
	        int style,
1047
	        boolean useAbbrevLabel) {
1048
	    return createDefinedTermComboElement(null, termVocabulary, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
1049
	}
1050

    
1051
	private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1052
	        TermType termType,
1053
	        TermVocabulary<?> termVocabulary,
1054
	        List<T> terms,
1055
	        ICdmFormElement parentElement,
1056
	        String labelString,
1057
	        T selection,
1058
	        boolean addEmptyElement,
1059
	        int style,
1060
	        boolean useAbbrevLabel,
1061
	        Comparator<T> comparator) {
1062

    
1063
	    if(termType!=null){
1064
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1065
	        adapt(element);
1066
	        parentElement.addElement(element);
1067
	        return element;
1068
	    }
1069
	    else if(termVocabulary!=null){
1070
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1071
	        if (comparator!= null){
1072
	        	element.setTermComparator(comparator);
1073
	        }
1074
	        adapt(element);
1075
	        parentElement.addElement(element);
1076
	        return element;
1077
	    }else if (terms != null){
1078

    
1079
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, terms, labelString, selection, addEmptyElement, style, useAbbrevLabel);
1080
            if (comparator!= null){
1081
                element.setTermComparator(comparator);
1082
            }
1083
            adapt(element);
1084
            parentElement.addElement(element);
1085
            return element;
1086
	    }
1087
	    else {
1088
	        //this should never happen
1089
	        return null;
1090
	    }
1091
	}
1092

    
1093
	   private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1094
	            TermType termType,
1095
	            TermVocabulary<?> termVocabulary,
1096
	            List<T> terms,
1097
	            ICdmFormElement parentElement,
1098
	            String labelString,
1099
	            TermDto selection,
1100
	            boolean addEmptyElement,
1101
	            int style,
1102
	            boolean useAbbrevLabel,
1103
	            Comparator<T> comparator) {
1104
	        if(termType!=null){
1105
	            TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1106
	            adapt(element);
1107
	            parentElement.addElement(element);
1108
	            return element;
1109
	        }
1110

    
1111
	        else {
1112
	            //this should never happen
1113
	            return null;
1114
	        }
1115
	    }
1116

    
1117
	public NameRelationshipTypeCombo createNameRelationshipTypeCombo(ICdmFormElement parentElement,
1118
            String labelString,
1119
            int style,
1120
            boolean useAbbrevLabel,
1121
            Comparator<NameRelationshipType> comparator) {
1122

    
1123
        NameRelationshipTypeCombo<InverseTermWrapper> element = new NameRelationshipTypeCombo(this, parentElement, labelString, true, style, useAbbrevLabel, comparator);
1124
        adapt(element);
1125
        parentElement.addElement(element);
1126
        return element;
1127
    }
1128

    
1129
	public MisappliedRelationshipComboElement createMisappliedRelationshipComboElement(
1130
	        ICdmFormElement parentElement,
1131
            String labelString,
1132
            TaxonRelationshipType selection,
1133
            int style) {
1134
	    MisappliedRelationshipComboElement combo = new MisappliedRelationshipComboElement(this, parentElement, labelString, selection, false, style, false);
1135
	    adapt(combo);
1136
        parentElement.addElement(combo);
1137
        return combo;
1138
    }
1139

    
1140
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1141
	        Class<T> enumComboType, ICdmFormElement parentElement,
1142
	        int style, boolean hasNullValue) {
1143
	    return createEnumComboElement(enumComboType, parentElement, null, style, hasNullValue);
1144
	}
1145
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1146
            Class<T> enumComboType, ICdmFormElement parentElement,
1147
            int style) {
1148
        return createEnumComboElement(enumComboType, parentElement, null, style, false);
1149
    }
1150

    
1151
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1152
			Class<T> enumComboType, ICdmFormElement parentElement, Comparator<T> comparator,
1153
			int style, boolean hasNullValue) {
1154
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, comparator, style, hasNullValue);
1155
        adapt(element);
1156
        parentElement.addElement(element);
1157
        return element;
1158
    }
1159

    
1160
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
1161
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
1162
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1163
	    adapt(element);
1164
	    parentElement.addElement(element);
1165
	    return element;
1166
	}
1167

    
1168
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyDtoComboElement(
1169
            TermType termType, String label, TermVocabularyDto selection, ICdmFormElement parentElement, int style) {
1170
        VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1171
        adapt(element);
1172
        parentElement.addElement(element);
1173
        return element;
1174
    }
1175

    
1176
    /**
1177
     * <p>
1178
     * createBrowserElement
1179
     * </p>
1180
     *
1181
     * @param imageUri
1182
     *            a {@link eu.etaxonomy.cdm.common.URI} object.
1183
     * @param style
1184
     *            a int.
1185
     * @param parentElement
1186
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1187
     *            object.
1188
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
1189
     *         object.
1190
     */
1191
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
1192
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
1193
        adapt(element);
1194
        parentElement.addElement(element);
1195
        return element;
1196
    }
1197

    
1198
    /**
1199
     * <p>
1200
     * createImageElement
1201
     * </p>
1202
     *
1203
     * @param parentElement
1204
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1205
     *            object.
1206
     * @param imageUri
1207
     *            a {@link eu.etaxonomy.cdm.common.URI} object.
1208
     * @param style
1209
     *            a int.
1210
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1211
     */
1212
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1213
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1214
        adapt(element);
1215
        parentElement.addElement(element);
1216
        return element;
1217
    }
1218

    
1219
    /**
1220
     * <p>
1221
     * createTextActionElement
1222
     * </p>
1223
     *
1224
     * @param labelString
1225
     *            a {@link java.lang.String} object.
1226
     * @param initialText
1227
     *            a {@link java.lang.String} object.
1228
     * @param style
1229
     *            a int.
1230
     * @param parentElement
1231
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1232
     *            object.
1233
     * @param buttonLabel
1234
     *            a {@link java.lang.String} object.
1235
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
1236
     *         object.
1237
     */
1238
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
1239
            String buttonLabel, String initialText, int style) {
1240
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
1241
                style);
1242
        adapt(element);
1243
        parentElement.addElement(element);
1244
        return element;
1245
    }
1246

    
1247
    /**
1248
     * <p>
1249
     * createCheckbox
1250
     * </p>
1251
     *
1252
     * @param parentElement
1253
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1254
     *            object.
1255
     * @param label
1256
     *            a {@link java.lang.String} object.
1257
     * @param initialState
1258
     *            a boolean.
1259
     * @param style
1260
     *            a int.
1261
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1262
     *         object.
1263
     */
1264
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1265
        if(initialState==null){
1266
            initialState = Boolean.FALSE;
1267
        }
1268
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1269
        adapt(element);
1270
        parentElement.addElement(element);
1271
        return element;
1272
    }
1273

    
1274
    /**
1275
     * Creates a section as a part of the form.
1276
     *
1277
     * @return the section widget
1278
     * @param section
1279
     *            a
1280
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1281
     *            object.
1282
     */
1283
    public Section adapt(AbstractFormSection section) {
1284
        section.setMenu(section.getLayoutComposite().getMenu());
1285
        adapt(section, true, true);
1286

    
1287
        // handle focus and property change events for cdm use
1288
        section.addFocusListener(selectionFocusHandler);
1289
        section.setPropertyChangeListeners(propertyChangeListeners);
1290

    
1291
        section.addExpansionListener(new ExpansionAdapter(){
1292
            @Override
1293
            public void expansionStateChanged(ExpansionEvent e) {
1294
                super.expansionStateChanged(e);
1295
                if(section.getEntity()!=null){
1296
                    PreferencesUtil.setStringValue(StoreUtil.getPrefKey(section.getClass(), section.getEntity().getClass().getCanonicalName()), e.getState()?CdmSectionPart.EXPANDED:CdmSectionPart.COLLAPSED);
1297
                }
1298
            }
1299
        });
1300

    
1301
        if (section.getToggle() != null) {
1302
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1303
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1304
        }
1305

    
1306
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1307

    
1308
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1309
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1310
            getColors().initializeSectionToolBarColors();
1311
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1312
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1313
        }
1314
        // call setTitleBarForeground regardless as it also sets the label color
1315
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1316
        return section;
1317
    }
1318

    
1319
    private class BoldFontHolder2 {
1320
        private Font normalFont;
1321

    
1322
        private Font boldFont;
1323

    
1324
        public BoldFontHolder2() {
1325
        }
1326

    
1327
        public Font getBoldFont(Font font) {
1328
            createBoldFont(font);
1329
            return boldFont;
1330
        }
1331

    
1332
        private void createBoldFont(Font font) {
1333
            if (normalFont == null || !normalFont.equals(font)) {
1334
                normalFont = font;
1335
                dispose();
1336
            }
1337
            if (boldFont == null) {
1338
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1339
            }
1340
        }
1341

    
1342
        public void dispose() {
1343
            if (boldFont != null) {
1344
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1345
                boldFont = null;
1346
            }
1347
        }
1348
    }
1349

    
1350
    /**
1351
     * createToggleableTextField
1352
     */
1353
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1354
            String initialText, boolean initialState, int style) {
1355
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1356
                initialState, style | orientation);
1357

    
1358
        adapt(element);
1359
        parentElement.addElement(element);
1360
        return element;
1361
    }
1362

    
1363
    /**
1364
     * createTimePeriodElement
1365
     */
1366
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1367
            TimePeriod timePeriod, int style) {
1368
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1369
        adapt(element);
1370
        parentElement.addElement(element);
1371
        return element;
1372
    }
1373

    
1374
    /**
1375
     * createVerbatimTimePeriodElement
1376
     */
1377
    public VerbatimTimePeriodElement createVerbatimTimePeriodElement(ICdmFormElement parentElement, String labelString,
1378
            VerbatimTimePeriod timePeriod, int style) {
1379
        VerbatimTimePeriodElement element = new VerbatimTimePeriodElement(this, parentElement, labelString, timePeriod, style);
1380
        adapt(element);
1381
        parentElement.addElement(element);
1382
        return element;
1383
    }
1384

    
1385
	/**
1386
	 * createGatheringEventUnitElement
1387
	 */
1388
	public GatheringEventUnitElement createGatheringEventUnitElement(
1389
			ICdmFormElement parentElement,
1390
			String labelString,
1391
			DerivedUnitFacade gatheringEvent,
1392
			MinMaxTextSection.UnitType unitType,
1393
			int style) {
1394
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1395
				parentElement,
1396
				labelString,
1397
				gatheringEvent,
1398
				unitType,
1399
				style);
1400
		adapt(element);
1401
		parentElement.addElement(element);
1402
		return element;
1403
	}
1404

    
1405
    /**
1406
     * createPointElement
1407
     */
1408
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1409
        PointElement element = new PointElement(this, parentElement, point, style);
1410
        adapt(element);
1411
        parentElement.addElement(element);
1412
        return element;
1413
    }
1414

    
1415
    /**
1416
     * Creates an empty section with the given message.<br>
1417
     * If message is <code>null</code> a default message will be displayed.
1418
     */
1419
    public EmptySection createEmptySection(String message, CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1420
        EmptySection section = new EmptySection(message, formFactory, parentElement, style);
1421
        parentElement.addElement(section);
1422
        adapt(section);
1423
        return section;
1424
    }
1425

    
1426
    /**
1427
     * <p>
1428
     * createDateDetailSection
1429
     * </p>
1430
     *
1431
     * @param parentElement
1432
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1433
     *            object.
1434
     * @param style
1435
     *            a int.
1436
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1437
     *         object.
1438
     */
1439
    public DateDetailSection<TimePeriod> createDateDetailSection(ICdmFormElement parentElement, int style) {
1440
        DateDetailSection<TimePeriod> section = new DateDetailSection<TimePeriod>(this, parentElement, false, style);
1441
        parentElement.addElement(section);
1442
        adapt(section);
1443
        return section;
1444
    }
1445

    
1446
    /**
1447
     * <p>
1448
     * createVerbatimDateDetailSection
1449
     * </p>
1450
     *
1451
     * @param parentElement
1452
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1453
     *            object.
1454
     * @param style
1455
     *            a int.
1456
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.VerbatimDateDetailSection}
1457
     *         object.
1458
     */
1459
    public DateDetailSection<VerbatimTimePeriod> createVerbatimDateDetailSection(ICdmFormElement parentElement, int style) {
1460
        DateDetailSection<VerbatimTimePeriod> section
1461
        	= new DateDetailSection<VerbatimTimePeriod>(this, parentElement, true, style);
1462
        parentElement.addElement(section);
1463
        adapt(section);
1464
        return section;
1465
    }
1466

    
1467
	/**
1468
	 * <p>
1469
	 * createDateDetailSection
1470
	 * </p>
1471
	 *
1472
	 * @param parentElement
1473
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1474
	 *            object.
1475
	 * @param style
1476
	 *            a int.
1477
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1478
	 *         object.
1479
	 */
1480
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1481
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1482
		parentElement.addElement(section);
1483
		adapt(section);
1484
		return section;
1485
	}
1486

    
1487
    /**
1488
     * <p>
1489
     * createPartialElement
1490
     * </p>
1491
     *
1492
     * @param parentElement
1493
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1494
     *            object.
1495
     * @param labelString
1496
     *            a {@link java.lang.String} object.
1497
     * @param partial
1498
     *            a {@link org.joda.time.Partial} object.
1499
     * @param style
1500
     *            a int.
1501
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1502
     *         object.
1503
     */
1504
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1505
            int style) {
1506
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1507
        adapt(element);
1508
        parentElement.addElement(element);
1509
        return element;
1510
    }
1511

    
1512
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial, boolean showYear,
1513
            int style) {
1514
        PartialElement element = new PartialElement(this, parentElement, labelString, style, showYear);
1515
        adapt(element);
1516
        parentElement.addElement(element);
1517
        return element;
1518
    }
1519

    
1520
    /**
1521
     * <p>
1522
     * addSelectionListener
1523
     * </p>
1524
     *
1525
     * @param listener
1526
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1527
     */
1528
    public void addSelectionListener(SelectionListener listener) {
1529
        selectionListenerList.add(listener);
1530
    }
1531

    
1532
    /**
1533
     * <p>
1534
     * removeSelectionListener
1535
     * </p>
1536
     *
1537
     * @param listener
1538
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1539
     */
1540
    public void removeSelectionListener(SelectionListener listener) {
1541
        if (listener == null) {
1542
            MessagingUtils.error(this.getClass(),
1543
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1544
        } else {
1545
            selectionListenerList.remove(listener);
1546
        }
1547
    }
1548

    
1549
    /**
1550
     * <p>
1551
     * addPropertyChangeListener
1552
     * </p>
1553
     *
1554
     * @param listener
1555
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1556
     *            object.
1557
     */
1558
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1559
        if (propertyChangeListeners.contains(listener)) {
1560
            return;
1561
        }
1562
        propertyChangeListeners.add(0, listener);
1563
    }
1564

    
1565
    /**
1566
     * <p>
1567
     * removePropertyChangeListener
1568
     * </p>
1569
     *
1570
     * @param listener
1571
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1572
     *            object.
1573
     */
1574
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1575
        propertyChangeListeners.remove(listener);
1576
    }
1577

    
1578
    /**
1579
     * @return the propertyChangeListeners
1580
     */
1581
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1582
        return propertyChangeListeners;
1583
    }
1584

    
1585
    /**
1586
     * <p>
1587
     * createHorizontalSeparator
1588
     * </p>
1589
     *
1590
     * @param parentElement
1591
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1592
     *            object.
1593
     * @param style
1594
     *            a int.
1595
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1596
     */
1597
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1598
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1599
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1600
        return separator;
1601
    }
1602

    
1603
    /**
1604
     * <p>
1605
     * createVersionElement
1606
     * </p>
1607
     *
1608
     * @param parentElement
1609
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1610
     *            object.
1611
     * @param entity
1612
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1613
     *            object.
1614
     * @param style
1615
     *            a int.
1616
     * @return a
1617
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1618
     *         object.
1619
     */
1620
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1621
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1622
        adapt(element);
1623
        parentElement.addElement(element);
1624
        return element;
1625
    }
1626

    
1627
    /**
1628
     * @param cdmBaseSection
1629
     * @param object
1630
     * @param style
1631
     * @return
1632
     */
1633
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1634
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1635
        adapt(element);
1636
        parentElement.addElement(element);
1637
        return element;
1638
    }
1639

    
1640
    /**
1641
     * <p>
1642
     * createVersionSection
1643
     * </p>
1644
     *
1645
     * @param parentElement
1646
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1647
     *            object.
1648
     * @param style
1649
     *            a int.
1650
     * @return a
1651
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1652
     *         object.
1653
     */
1654
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1655
        VersionSection section = new VersionSection(this, parentElement, style);
1656
        parentElement.addElement(section);
1657
        adapt(section);
1658
        return section;
1659
    }
1660

    
1661
    /**
1662
     * @param parent
1663
     * @param i
1664
     * @return
1665
     */
1666
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1667
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1668
        parentElement.addElement(section);
1669
        adapt(section);
1670
        return section;
1671
    }
1672

    
1673
    /**
1674
     * <p>
1675
     * createEmptyElement
1676
     * </p>
1677
     *
1678
     * @param parentElement
1679
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1680
     *            object.
1681
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1682
     */
1683
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1684
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1685
        adapt(element);
1686
        parentElement.addElement(element);
1687
        return element;
1688
    }
1689

    
1690
    /**
1691
     * <p>
1692
     * createHeadlineSection
1693
     * </p>
1694
     *
1695
     * @param parentElement
1696
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1697
     *            object.
1698
     * @return a
1699
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1700
     *         object.
1701
     */
1702
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1703
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1704
        parentElement.addElement(section);
1705
        adapt(section);
1706
        return section;
1707
    }
1708

    
1709
    /**
1710
     * <p>
1711
     * createParsingMessageElement
1712
     * </p>
1713
     *
1714
     * @param parentElement
1715
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1716
     *            object.
1717
     * @param parserProblem
1718
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1719
     *            object.
1720
     * @param style
1721
     *            a int.
1722
     * @return a
1723
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1724
     *         object.
1725
     */
1726
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1727
            ParserProblem parserProblem, int style) {
1728
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1729
        adapt(element);
1730
        parentElement.addElement(element);
1731
        return element;
1732
    }
1733

    
1734
    public DefinedTermDetailSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1735
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1736

    
1737
        DefinedTermDetailSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1738
                selectionProvider, style);
1739

    
1740
        parentElement.addElement(section);
1741
        adapt(section);
1742
        return section;
1743

    
1744
    }
1745

    
1746
    public TermMediaSection createTermMediaSection(ConversationHolder conversation,
1747
            ICdmFormElement parentElement, int style) {
1748
        TermMediaSection section = new TermMediaSection(this, conversation, parentElement, style);
1749
        parentElement.addElement(section);
1750
        adapt(section);
1751
        return section;
1752

    
1753
    }
1754

    
1755
    public DerivedUnitMediaSection createDerivedUnitMediaSection(ConversationHolder conversation,
1756
            ICdmFormElement parentElement, int style) {
1757
        DerivedUnitMediaSection section = new DerivedUnitMediaSection(this, conversation, parentElement, style);
1758
        parentElement.addElement(section);
1759
        adapt(section);
1760
        return section;
1761

    
1762
    }
1763

    
1764
    /**
1765
     * @param definedTermClass
1766
     * @param formElement
1767
     * @param style
1768
     * @return
1769
     */
1770
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1771
            AbstractCdmDetailSection parentElement, int style) {
1772
        AbstractCdmDetailElement element = null;
1773

    
1774
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1775
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1776
        } else if (definedTermClass.equals(Feature.class)) {
1777
            element = new FeatureDetailElement(this, parentElement);
1778
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1779
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1780
        } else {
1781
            element = new DefinedTermDetailElement(this, parentElement);
1782
        }
1783

    
1784

    
1785
        adapt(element);
1786
        parentElement.addElement(element);
1787
        return element;
1788
    }
1789

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

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

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

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

    
1814
    public CharacterNodeDetailElement createCharacterNodeDetailElement(ICdmFormElement parentElement, int style){
1815
        CharacterNodeDetailElement element = new CharacterNodeDetailElement(this, parentElement);
1816
        addAndAdaptElement(parentElement, element);
1817
        return element;
1818
    }
1819
    public CharacterNodeDtoDetailElement createCharacterNodeDtoDetailElement(ICdmFormElement parentElement, int style){
1820
        CharacterNodeDtoDetailElement element = new CharacterNodeDtoDetailElement(this, parentElement);
1821
        addAndAdaptElement(parentElement, element);
1822
        return element;
1823
    }
1824

    
1825
    public CharacterDetailElement createCharacterDetailElement(ICdmFormElement parentElement, int style){
1826
        CharacterDetailElement element = new CharacterDetailElement(this, parentElement);
1827
        addAndAdaptElement(parentElement, element);
1828
        return element;
1829
    }
1830
    public CharacterDtoDetailElement createCharacterDtoDetailElement(ICdmFormElement parentElement, int style){
1831
        CharacterDtoDetailElement element = new CharacterDtoDetailElement(this, parentElement);
1832
        addAndAdaptElement(parentElement, element);
1833
        return element;
1834
    }
1835

    
1836
    public FeatureTreeDetailElement createFeatureTreeDetailElement(ICdmFormElement parentElement, int style){
1837
        FeatureTreeDetailElement element = new FeatureTreeDetailElement(this, parentElement);
1838
        addAndAdaptElement(parentElement, element);
1839
        return element;
1840
    }
1841

    
1842
    /**
1843
     * @param parentElement
1844
     * @param style
1845
     * @return
1846
     */
1847
    public AbstractCdmDetailElement<TermTree> createFeatureTreeDetailElementForTree(
1848
            AbstractCdmDetailSection<TermTree> parentElement, int style) {
1849
        FeatureTreeDetailElementForNode element = new FeatureTreeDetailElementForNode(this, parentElement);
1850
        addAndAdaptElement(parentElement, element);
1851
        return element;
1852
    }
1853

    
1854
    public FeatureNodeDetailElement createFeatureNodeDetailElement(ICdmFormElement parentElement, int style){
1855
        FeatureNodeDetailElement element = new FeatureNodeDetailElement(this, parentElement);
1856
        addAndAdaptElement(parentElement, element);
1857
        return element;
1858
    }
1859

    
1860

    
1861
    //--------DetailSections---------
1862
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1863
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1864
        addAndAdaptSection(parentElement, section);
1865
        return section;
1866
    }
1867

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

    
1874
    public FeatureTreeDetailSection createFeatureTreeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1875
        FeatureTreeDetailSection section = new FeatureTreeDetailSection(this, conversation, parentElement, selectionProvider, style);
1876
        addAndAdaptSection(parentElement, section);
1877
        return section;
1878
    }
1879
    public FeatureTreeDetailSectionForNode createFeatureTreeDetailSectionForTree(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1880
        FeatureTreeDetailSectionForNode section = new FeatureTreeDetailSectionForNode(this, conversation, parentElement, selectionProvider, style);
1881
        addAndAdaptSection(parentElement, section);
1882
        return section;
1883
    }
1884

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

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

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

    
1903
    public AdvancedSourceElement createAdvancedSourceDetailElement(ICdmFormElement parentElement, int style){
1904
        AdvancedSourceElement element = new AdvancedSourceElement(this, parentElement);
1905
        addAndAdaptElement(parentElement, element);
1906
        return element;
1907
    }
1908

    
1909
    public AdvancedSourceElement createAdvancedNomenclaturalSourceDetailElement(ICdmFormElement parentElement, int style){
1910
        AdvancedNomenclaturalSourceElement element = new AdvancedNomenclaturalSourceElement(this, parentElement);
1911
        addAndAdaptElement(parentElement, element);
1912
        return element;
1913
    }
1914

    
1915
    public SingleSourceSection createSingleSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, CdmBase cdmEntity, ISelectionProvider selectionProvider, String label, int style){
1916
        SingleSourceSection section = new SingleSourceSection(this, conversation, parentElement, cdmEntity, selectionProvider, style, label);
1917
        addAndAdaptSection(parentElement, section);
1918
        return section;
1919
    }
1920

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

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

    
1933
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1934
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1935
        addAndAdaptSection(parentElement, section);
1936
        return section;
1937
    }
1938

    
1939
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1940
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1941
        addAndAdaptSection(parentElement, section);
1942
        return section;
1943
    }
1944

    
1945
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1946
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1947
        addAndAdaptSection(parentElement, section);
1948
        return section;
1949
    }
1950

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

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

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

    
1969

    
1970

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2055
    public InstitutionDetailSection createInstitutionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2056
        InstitutionDetailSection section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
2057
        addAndAdaptSection(parentElement, section);
2058
        return section;
2059
    }
2060

    
2061
    public FieldUnitGeneralDetailSection createFieldUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2062
        FieldUnitGeneralDetailSection section = new FieldUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2063
        addAndAdaptSection(parentElement, section);
2064
        return section;
2065
    }
2066

    
2067
    public DerivedUnitGeneralDetailSection createDerivedUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2068
        DerivedUnitGeneralDetailSection section = new DerivedUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2069
        addAndAdaptSection(parentElement, section);
2070
        return section;
2071
    }
2072

    
2073
    public PreservedSpecimenGeneralDetailSection createPreservedSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2074
        PreservedSpecimenGeneralDetailSection section = new PreservedSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2075
        addAndAdaptSection(parentElement, section);
2076
        return section;
2077
    }
2078

    
2079
    public TissueSampleGeneralDetailSection createTissueSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2080
        TissueSampleGeneralDetailSection section = new TissueSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2081
        addAndAdaptSection(parentElement, section);
2082
        return section;
2083
    }
2084

    
2085
    public DnaSampleGeneralDetailSection createDnaSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2086
        DnaSampleGeneralDetailSection section = new DnaSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2087
        addAndAdaptSection(parentElement, section);
2088
        return section;
2089
    }
2090

    
2091
    public DnaSamplePreparationPreservationSection createDnaSamplePreparationPreservationSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2092
        DnaSamplePreparationPreservationSection section = new DnaSamplePreparationPreservationSection(this, conversation, parentElement, selectionProvider, style);
2093
        addAndAdaptSection(parentElement, section);
2094
        return section;
2095
    }
2096

    
2097
    public DnaQualityDetailSection createDnaQualityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2098
        DnaQualityDetailSection section = new DnaQualityDetailSection(this, conversation, parentElement, selectionProvider, style);
2099
        addAndAdaptSection(parentElement, section);
2100
        return section;
2101
    }
2102

    
2103
    public SequenceGeneralDetailSection createSequenceGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2104
        SequenceGeneralDetailSection section = new SequenceGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2105
        addAndAdaptSection(parentElement, section);
2106
        return section;
2107
    }
2108

    
2109
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2110
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
2111
        addAndAdaptSection(parentElement, section);
2112
        return section;
2113
    }
2114

    
2115
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2116
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
2117
        addAndAdaptSection(parentElement, section);
2118
        return section;
2119
    }
2120

    
2121
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2122
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
2123
        addAndAdaptSection(parentElement, section);
2124
        return section;
2125
    }
2126

    
2127
    public SingleReadGeneralDetailSection createSingleReadGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2128
        SingleReadGeneralDetailSection section = new SingleReadGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2129
        addAndAdaptSection(parentElement, section);
2130
        return section;
2131
    }
2132

    
2133
    public AmplificationGeneralDetailSection createAmplificationGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2134
        AmplificationGeneralDetailSection section = new AmplificationGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2135
        addAndAdaptSection(parentElement, section);
2136
        return section;
2137
    }
2138

    
2139
    public AmplificationPrimerDetailSection createAmplificationPrimerDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2140
        AmplificationPrimerDetailSection section = new AmplificationPrimerDetailSection(this, conversation, parentElement, selectionProvider, style);
2141
        addAndAdaptSection(parentElement, section);
2142
        return section;
2143
    }
2144

    
2145
    public AmplificationCloningDetailSection createAmplificationCloningDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2146
        AmplificationCloningDetailSection section = new AmplificationCloningDetailSection(this, conversation, parentElement, selectionProvider, style);
2147
        addAndAdaptSection(parentElement, section);
2148
        return section;
2149
    }
2150

    
2151
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2152
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
2153
        addAndAdaptSection(parentElement, section);
2154
        return section;
2155
    }
2156

    
2157
    public MediaSpecimenGeneralDetailSection createMediaSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2158
        MediaSpecimenGeneralDetailSection section = new MediaSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2159
        addAndAdaptSection(parentElement, section);
2160
        return section;
2161
    }
2162

    
2163
    public HybridDetailSection createHybridDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2164
        HybridDetailSection section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
2165
        addAndAdaptSection(parentElement, section);
2166
        return section;
2167
    }
2168

    
2169
    public UserDetailSection createUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2170
        UserDetailSection section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
2171
        addAndAdaptSection(parentElement, section);
2172
        return section;
2173
    }
2174

    
2175
    public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2176
        GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
2177
        addAndAdaptSection(parentElement, section);
2178
        return section;
2179
    }
2180

    
2181
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2182
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
2183
        addAndAdaptSection(parentElement, section);
2184
        return section;
2185
    }
2186

    
2187
    public SampleDesignationDetailSection createSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2188
        SampleDesignationDetailSection section = new SampleDesignationDetailSection(this, conversation, parentElement, selectionProvider, style);
2189
        addAndAdaptSection(parentElement, section);
2190
        return section;
2191
    }
2192

    
2193
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2194
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style, true);
2195
        addAndAdaptSection(parentElement, section);
2196
        return section;
2197
    }
2198

    
2199
    public ReferencedEntityDetailSection createReferencedEntityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2200
        ReferencedEntityDetailSection section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
2201
        addAndAdaptSection(parentElement, section);
2202
        return section;
2203
    }
2204

    
2205
    public TermVocabularyDetailSection createTermVocabularyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2206
        TermVocabularyDetailSection section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
2207
        addAndAdaptSection(parentElement, section);
2208
        return section;
2209
    }
2210

    
2211
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2212
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
2213
        addAndAdaptSection(parentElement, section);
2214
        return section;
2215
    }
2216

    
2217
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2218
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
2219
        addAndAdaptSection(parentElement, section);
2220
        return section;
2221
    }
2222

    
2223
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2224
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
2225
        addAndAdaptSection(parentElement, section);
2226
        return section;
2227
    }
2228

    
2229
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
2230
        parentElement.addElement(section);
2231
        adapt(section);
2232
    }
2233

    
2234
    //--------DetailElements------------
2235

    
2236
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
2237
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
2238
        addAndAdaptElement(parentElement, element);
2239
        return element;
2240
    }
2241

    
2242
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
2243
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
2244
        addAndAdaptElement(parentElement, element);
2245
        return element;
2246
    }
2247

    
2248
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
2249
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
2250
        addAndAdaptElement(parentElement, element);
2251
        return element;
2252
    }
2253

    
2254
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
2255
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
2256
        addAndAdaptElement(parentElement, element);
2257
        return element;
2258
    }
2259

    
2260
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
2261
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
2262
        addAndAdaptElement(parentElement, element);
2263
        return element;
2264
    }
2265
    public OriginalSourceElement createOriginalSourceElement(ICdmFormElement parentElement, CdmBase cdmEntity, String label){
2266
        OriginalSourceElement element = new OriginalSourceElement(this, parentElement, cdmEntity, label);
2267
        addAndAdaptElement(parentElement, element);
2268
        return element;
2269
    }
2270

    
2271

    
2272
    public NomenclaturalSourceElement createNomenclaturalSourceElement(ICdmFormElement parentElement, CdmBase cdmEntity, String label){
2273
        NomenclaturalSourceElement element = new NomenclaturalSourceElement(this, parentElement, cdmEntity, label);
2274
        addAndAdaptElement(parentElement, element);
2275
        return element;
2276
    }
2277

    
2278
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
2279
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
2280
        addAndAdaptElement(parentElement, element);
2281
        return element;
2282
    }
2283

    
2284
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
2285
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2286
        addAndAdaptElement(parentElement, element);
2287
        return element;
2288
    }
2289

    
2290
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2291
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2292
        addAndAdaptElement(parentElement, element);
2293
        return element;
2294
    }
2295

    
2296
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2297
        UserDetailElement element = new UserDetailElement(this, parentElement);
2298
        addAndAdaptElement(parentElement, element);
2299
        return element;
2300
    }
2301

    
2302
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2303
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2304
        addAndAdaptElement(parentElement, element);
2305
        return element;
2306
    }
2307

    
2308
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2309
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2310
        addAndAdaptElement(parentElement, element);
2311
        return element;
2312
    }
2313

    
2314
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2315
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2316
        addAndAdaptElement(parentElement, element);
2317
        return element;
2318
    }
2319

    
2320
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2321
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2322
        addAndAdaptElement(parentElement, element);
2323
        return element;
2324
    }
2325

    
2326
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2327
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2328
        addAndAdaptElement(parentElement, element);
2329
        return element;
2330
    }
2331

    
2332
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2333
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2334
        adapt(element);
2335
        parentElement.addElement(element);
2336

    
2337
        return element;
2338
    }
2339

    
2340
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2341
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2342
        addAndAdaptElement(parentElement, element);
2343
        return element;
2344
    }
2345

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

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

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

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

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

    
2376
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2377
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2378
        addAndAdaptElement(parentElement, element);
2379
        return element;
2380
    }
2381

    
2382
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2383
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2384
        addAndAdaptElement(parentElement, element);
2385
        return element;
2386
    }
2387

    
2388
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2389
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2390
        addAndAdaptElement(parentElement, element);
2391
        return element;
2392
    }
2393

    
2394
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2395
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2396
        addAndAdaptElement(parentElement, element);
2397
        return element;
2398
    }
2399

    
2400
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2401
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2402
        addAndAdaptElement(parentElement, element);
2403
        return element;
2404
    }
2405

    
2406
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2407
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2408
        addAndAdaptElement(parentElement, element);
2409
        return element;
2410
    }
2411

    
2412
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2413
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2414
        addAndAdaptElement(parentElement, element);
2415
        return element;
2416
    }
2417

    
2418
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
2419
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
2420
        addAndAdaptElement(parentElement, element);
2421
        return element;
2422
    }
2423

    
2424
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2425
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2426
        addAndAdaptElement(parentElement, element);
2427
        return element;
2428
    }
2429

    
2430

    
2431
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2432
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2433
        addAndAdaptElement(parentElement, element);
2434
        return element;
2435
    }
2436

    
2437
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2438
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2439
        addAndAdaptElement(parentElement, element);
2440
        return element;
2441
    }
2442

    
2443
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2444
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2445
        addAndAdaptElement(parentElement, element);
2446
        return element;
2447
    }
2448

    
2449
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2450
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2451
        addAndAdaptElement(parentElement, element);
2452
        return element;
2453
    }
2454

    
2455
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2456
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2457
        addAndAdaptElement(parentElement, element);
2458
        return element;
2459
    }
2460

    
2461
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2462
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2463
        addAndAdaptElement(parentElement, element);
2464
        return element;
2465
    }
2466

    
2467
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2468
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2469
        addAndAdaptElement(parentElement, element);
2470
        return element;
2471
    }
2472

    
2473
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2474
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2475
        addAndAdaptElement(parentElement, element);
2476
        return element;
2477
    }
2478

    
2479
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2480
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2481
        addAndAdaptElement(parentElement, element);
2482
        return element;
2483
    }
2484

    
2485
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2486
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2487
        addAndAdaptElement(parentElement, element);
2488
        return element;
2489
    }
2490

    
2491
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2492
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2493
        addAndAdaptElement(parentElement, element);
2494
        return element;
2495
    }
2496

    
2497
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2498
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2499
        addAndAdaptElement(parentElement, element);
2500
        return element;
2501
    }
2502

    
2503
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2504
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2505
        addAndAdaptElement(parentElement, element);
2506
        return element;
2507
    }
2508

    
2509
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2510
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2511
        addAndAdaptElement(parentElement, element);
2512
        return element;
2513
    }
2514

    
2515
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2516
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2517
        addAndAdaptElement(parentElement, element);
2518
        return element;
2519
    }
2520

    
2521
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2522
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2523
        addAndAdaptElement(parentElement, element);
2524
        return element;
2525
    }
2526

    
2527
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2528
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2529
        addAndAdaptElement(parentElement, mediaDetailElement);
2530
        return mediaDetailElement;
2531
    }
2532

    
2533
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2534
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2535
        addAndAdaptElement(parentElement, element);
2536
        return element;
2537
    }
2538

    
2539
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2540
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2541
        addAndAdaptElement(parentElement, element);
2542
        return element;
2543
    }
2544

    
2545
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2546
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2547
        addAndAdaptElement(parentElement, element);
2548
        return element;
2549
    }
2550

    
2551
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2552
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2553
        addAndAdaptElement(parentElement, element);
2554
        return element;
2555
    }
2556

    
2557
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2558
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2559
        addAndAdaptElement(parentElement, element);
2560
        return element;
2561
    }
2562

    
2563
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2564
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2565
        addAndAdaptElement(parentElement, element);
2566
        return element;
2567
    }
2568

    
2569
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2570
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2571
        addAndAdaptElement(parentElement, element);
2572
        return element;
2573
    }
2574

    
2575
    /**
2576
     * @param parentElement
2577
     * @param element
2578
     */
2579
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2580
        adapt(element);
2581
        parentElement.addElement(element);
2582
    }
2583

    
2584
    //--------EntityCollectionSection----------
2585
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2586
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2587
        addAndAdaptSection(parentElement, section);
2588
        return section;
2589
    }
2590

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

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

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

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

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

    
2621
    public CreditSection createCreditSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2622
        CreditSection section = new CreditSection(this, conversation, parentElement, style);
2623
        addAndAdaptSection(parentElement, section);
2624
        return section;
2625
    }
2626
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2627
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2628
        addAndAdaptSection(parentElement, section);
2629
        return section;
2630
    }
2631
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, Reference defaultSource, int style){
2632
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, defaultSource, style);
2633
        addAndAdaptSection(parentElement, section);
2634
        return section;
2635
    }
2636

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

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

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

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

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

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

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

    
2679
    public NomenclaturalStatusSection createNomenclaturalStatusSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2680
        NomenclaturalStatusSection section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
2681
        addAndAdaptSection(parentElement, section);
2682
        return section;
2683
    }
2684

    
2685
    public NameRelationshipDetailSection createNameRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2686
        NameRelationshipDetailSection section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
2687
        addAndAdaptSection(parentElement, section);
2688
        return section;
2689
    }
2690

    
2691
//    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2692
//        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2693
//        addAndAdaptSection(parentElement, section);
2694
//        return section;
2695
//    }
2696
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2697
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, style);
2698
        addAndAdaptSection(parentElement, section);
2699
        return section;
2700
    }
2701

    
2702
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, String label, int style){
2703
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, label, style);
2704
        addAndAdaptSection(parentElement, section);
2705
        return section;
2706
    }
2707

    
2708
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2709
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2710

    
2711
        addAndAdaptSection(parentElement, section);
2712
        return section;
2713
    }
2714

    
2715
    public SourceSection createSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2716
        SourceSection section = new SourceSection(this, conversation, parentElement, style);
2717
        addAndAdaptSection(parentElement, section);
2718
        return section;
2719
    }
2720

    
2721
    public ScopeSection createScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2722
        ScopeSection section = new ScopeSection(this, conversation, parentElement, style);
2723
        addAndAdaptSection(parentElement, section);
2724
        return section;
2725
    }
2726

    
2727
    public DescriptionSourceSection createDescriptionSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2728
        DescriptionSourceSection section = new DescriptionSourceSection(this, conversation, parentElement, style);
2729
        addAndAdaptSection(parentElement, section);
2730
        return section;
2731
    }
2732

    
2733
    public TypeDesignationSection createTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2734
        TypeDesignationSection section = new TypeDesignationSection(this, conversation, parentElement, style);
2735
        addAndAdaptSection(parentElement, section);
2736
        return section;
2737
    }
2738

    
2739
    public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2740
        StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
2741
        addAndAdaptSection(parentElement, section);
2742
        return section;
2743
    }
2744

    
2745
    public StatisticalMeasurementValueSection createStatisticalMeasurementValueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2746
        StatisticalMeasurementValueSection section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
2747
        addAndAdaptSection(parentElement, section);
2748
        return section;
2749
    }
2750

    
2751
    public DescribedSpecimenSection createDescribedSpecimenSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2752
        DescribedSpecimenSection section = new DescribedSpecimenSection(this, conversation, parentElement, style);
2753
        addAndAdaptSection(parentElement, section);
2754
        return section;
2755
    }
2756

    
2757
    public StateVocabularyCollectionSection createStateVocabulariesSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2758
        StateVocabularyCollectionSection section = new StateVocabularyCollectionSection(this, conversation, parentElement, style);
2759
        addAndAdaptSection(parentElement, section);
2760
        return section;
2761
    }
2762

    
2763
    public StateVocabularyDtoCollectionSection createStateVocabulariesDtoSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2764
        StateVocabularyDtoCollectionSection section = new StateVocabularyDtoCollectionSection(this, conversation, parentElement, style);
2765
        addAndAdaptSection(parentElement, section);
2766
        return section;
2767
    }
2768

    
2769
    public RecommendedModifierVocabulariesCollectionSection createRecommendedModifierVocabulariesCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2770
        RecommendedModifierVocabulariesCollectionSection section = new RecommendedModifierVocabulariesCollectionSection(this, conversation, parentElement, style);
2771
        addAndAdaptSection(parentElement, section);
2772
        return section;
2773
    }
2774
    public RecommendedModifierVocabulariesDtoCollectionSection createRecommendedModifierVocabulariesDtoCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2775
        RecommendedModifierVocabulariesDtoCollectionSection section = new RecommendedModifierVocabulariesDtoCollectionSection(this, conversation, parentElement, style);
2776
        addAndAdaptSection(parentElement, section);
2777
        return section;
2778
    }
2779

    
2780
    public MeasurementUnitCollectionSection createMeasurementUnitCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2781
        MeasurementUnitCollectionSection section = new MeasurementUnitCollectionSection(this, conversation, parentElement, style);
2782
        addAndAdaptSection(parentElement, section);
2783
        return section;
2784
    }
2785

    
2786
    public MeasurementUnitDtoCollectionSection createMeasurementUnitDtoCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2787
        MeasurementUnitDtoCollectionSection section = new MeasurementUnitDtoCollectionSection(this, conversation, parentElement, style);
2788
        addAndAdaptSection(parentElement, section);
2789
        return section;
2790
    }
2791
    public StatisticalMeasureCollectionSection createStatisticalMeasureCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2792
        StatisticalMeasureCollectionSection section = new StatisticalMeasureCollectionSection(this, conversation, parentElement, style);
2793
        addAndAdaptSection(parentElement, section);
2794
        return section;
2795
    }
2796

    
2797
    public StatisticalMeasureDtoCollectionSection createStatisticalMeasureDtoCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2798
        StatisticalMeasureDtoCollectionSection section = new StatisticalMeasureDtoCollectionSection(this, conversation, parentElement, style);
2799
        addAndAdaptSection(parentElement, section);
2800
        return section;
2801
    }
2802

    
2803
    public CollectingAreasDetailSection createCollectingAreasDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2804
        CollectingAreasDetailSection section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
2805
        addAndAdaptSection(parentElement, section);
2806
        return section;
2807
    }
2808

    
2809
    public GeoScopeDetailSection createGeoScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2810
        GeoScopeDetailSection section = new GeoScopeDetailSection(this, conversation, parentElement, style);
2811
        addAndAdaptSection(parentElement, section);
2812
        return section;
2813
    }
2814

    
2815
    public GeoScopePolyKeyDetailSection createGeoScopePolyKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2816
        GeoScopePolyKeyDetailSection section = new GeoScopePolyKeyDetailSection(this, conversation, parentElement, style);
2817
        addAndAdaptSection(parentElement, section);
2818
        return section;
2819
    }
2820

    
2821
    public IdentifierSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2822
        IdentifierSection section = new IdentifierSection(this, conversation, parentElement, style);
2823
        addAndAdaptSection(parentElement, section);
2824
        return section;
2825
    }
2826

    
2827
    public DerivedUnitFacadeIdentifierSection createDerivedUnitFacadeIdentifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2828
    	DerivedUnitFacadeIdentifierSection section = new DerivedUnitFacadeIdentifierSection(this, conversation, parentElement, style);
2829
    	addAndAdaptSection(parentElement, section);
2830
    	return section;
2831
    }
2832

    
2833
    public CurrentSampleDesignationDetailSection createCurrentSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2834
        CurrentSampleDesignationDetailSection section = new CurrentSampleDesignationDetailSection(this, conversation, parentElement, style);
2835
        addAndAdaptSection(parentElement, section);
2836
        return section;
2837
    }
2838

    
2839
    public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2840
        CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
2841
        addAndAdaptSection(parentElement, section);
2842
        return section;
2843
    }
2844

    
2845
    public PreservedSpecimenCurrentDeterminationDetailSection createPreservedSpecimenCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2846
        PreservedSpecimenCurrentDeterminationDetailSection section = new PreservedSpecimenCurrentDeterminationDetailSection(this, conversation, parentElement, style);
2847
        addAndAdaptSection(parentElement, section);
2848
        return section;
2849
    }
2850

    
2851
    public SampleDesignationHistoryDetailSection createSampleDesignationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2852
        SampleDesignationHistoryDetailSection section = new SampleDesignationHistoryDetailSection(this, conversation, parentElement, style);
2853
        addAndAdaptSection(parentElement, section);
2854
        return section;
2855
    }
2856

    
2857
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2858
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
2859
        addAndAdaptSection(parentElement, section);
2860
        return section;
2861
    }
2862

    
2863
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2864
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
2865
        addAndAdaptSection(parentElement, section);
2866
        return section;
2867
    }
2868

    
2869
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2870
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2871
        addAndAdaptSection(parentElement, section);
2872
        return section;
2873
    }
2874

    
2875
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2876
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2877
        addAndAdaptSection(parentElement, section);
2878
        return section;
2879
    }
2880

    
2881
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2882
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2883
        addAndAdaptSection(parentElement, section);
2884
        return section;
2885
    }
2886

    
2887
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2888
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2889
        addAndAdaptSection(parentElement, section);
2890
        return section;
2891
    }
2892

    
2893
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2894
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2895
        addAndAdaptSection(parentElement, section);
2896
        return section;
2897
    }
2898

    
2899
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2900
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2901
        addAndAdaptSection(parentElement, section);
2902
        return section;
2903
    }
2904

    
2905
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2906
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2907
        addAndAdaptSection(parentElement, section);
2908
        return section;
2909
    }
2910

    
2911
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2912
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2913
        AbstractEntityCollectionElement<?> element = null;
2914

    
2915
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2916

    
2917
        if (entity instanceof Annotation) {
2918
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2919
        }else if (entity instanceof Person ) {
2920
            boolean isNomenclatural = false;
2921
            if (parentElement instanceof TeamMemberSection){
2922
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2923
            }
2924
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2925
        } else if (entity instanceof Credit) {
2926
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2927
        } else if (entity instanceof Extension) {
2928
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2929
        } else if (entity instanceof ExternalLink) {
2930
            element = new ExternalLinksElement(this, parentElement, (ExternalLink) entity, removeListener, style);
2931
        } else if (entity instanceof Marker) {
2932
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2933
        } else if (entity instanceof TaxonNodeAgentRelation) {
2934
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2935
        }else if (entity instanceof Media) {
2936
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2937
        } else if (entity instanceof MediaRepresentation) {
2938
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2939
                    style);
2940
        } else if (entity instanceof ImageFile) {
2941
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2942
        } else if (entity instanceof MediaRepresentationPart) {
2943
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2944
                    removeListener, style);
2945
        } else if (entity instanceof NomenclaturalStatus) {
2946
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2947
                    style);
2948
        } else if (entity instanceof Rights) {
2949
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2950
        } else if (entity instanceof DescriptionElementSource && parentElement.getEntity() instanceof CommonTaxonName) {
2951
            element = new CommonNameSourceElement(this, parentElement, (DescriptionElementSource) entity,
2952
                    removeListener, style);
2953
        } else if (entity instanceof DescriptionElementSource  && parentElement.getEntity() instanceof Distribution) {
2954
            Composite parent = null;
2955
            if (parentElement instanceof DescriptionElementSourceSection){
2956
               parent = ((DescriptionElementSourceSection)parentElement).getParent();
2957
            }
2958
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2959
                    removeListener, style, false);
2960
        } else if (entity instanceof DescriptionElementSource) {
2961
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2962
                    removeListener, style, false);
2963
        }else if (entity instanceof TaxonNodeAgentRelation) {
2964
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2965
                    removeListener,backgroundColor, style);
2966
        }else if (entity instanceof IdentifiableSource && parentElement.getEntity() instanceof DescriptionElementBase) {
2967
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2968
                    style, false);
2969
        } else if (entity instanceof IdentifiableSource ) {
2970
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2971
                    style, true);
2972
        } else if (entity instanceof DefinedTerm) {
2973
            switch(((DefinedTerm)entity).getTermType()) {
2974
            case Scope:
2975
                element = new ScopeElement(this,
2976
                        parentElement,
2977
                        (DefinedTerm) entity,
2978
                        removeListener,
2979
                        style);
2980
                break;
2981
            case Modifier:
2982
                element = new ModifierElement(this,
2983
                        parentElement,
2984
                        (DefinedTerm) entity,
2985
                        removeListener,
2986
                        style);
2987
                break;
2988
            default:
2989
                break;
2990

    
2991
            }
2992
        } else if (entity instanceof Reference) {
2993
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2994
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2995
            }
2996
            else{
2997
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2998
            }
2999
        } else if (entity instanceof NameTypeDesignation) {
3000
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
3001
                    style);
3002
        } else if (entity instanceof TextualTypeDesignation) {
3003
            element = new TextTypeDesignationElement(this, parentElement, (TextualTypeDesignation) entity, removeListener,
3004
                    style);
3005
        } else if (entity instanceof NameRelationship) {
3006
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
3007
                    style);
3008
        } else if (entity instanceof SpecimenTypeDesignation) {
3009
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
3010
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
3011
                        removeListener, style);
3012
            }
3013
            else{
3014
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
3015
                        removeListener, style);
3016
            }
3017
        } else if (entity instanceof StateData) {
3018
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
3019
        } else if (entity instanceof StatisticalMeasurementValue) {
3020
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
3021
                    removeListener, style);
3022
        } else if (entity instanceof DerivedUnit) {
3023
            switch(((DerivedUnit)entity).getRecordBasis()) {
3024
            case LivingSpecimen:
3025
            case PreservedSpecimen:
3026
            case OtherSpecimen:
3027
                element = new SpecimenCollectionDetailElement(this,
3028
                        parentElement,
3029
                        (DerivedUnit) entity,
3030
                        removeListener,
3031
                        style);
3032
                break;
3033
            default:
3034
                element = new DerivedUnitElement(this,
3035
                        parentElement,
3036
                        (DerivedUnit) entity,
3037
                        removeListener,
3038
                        style);
3039
            }
3040

    
3041
        } else if (entity instanceof NamedArea) {
3042
            element = new CollectingAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
3043
        } else if (entity instanceof DeterminationEvent) {
3044
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
3045
        } else if (entity instanceof User) {
3046
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
3047
        } else if (entity instanceof GrantedAuthority) {
3048
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
3049
                    removeListener, style);
3050
        } else if (entity instanceof Group) {
3051
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
3052
        } else if (entity instanceof Taxon) {
3053
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
3054
        } else if (entity instanceof DescriptionElementBase) {
3055
            // this is the special case for protologs, maybe we can do this
3056
            // differently when API improves
3057
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
3058
//            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
3059
//                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
3060
//            }
3061
        } else if (entity instanceof Identifier) {
3062
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
3063
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
3064
            }
3065
            else{
3066
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
3067
            }
3068
        } else if (entity instanceof TermVocabulary) {
3069
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
3070
            switch (termVocabulary.getTermType()) {
3071
            case State:
3072
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
3073
                break;
3074
            case Modifier:
3075
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
3076
                break;
3077
            default:
3078
                break;
3079
            }
3080
        }else if (entity instanceof TermVocabularyDto) {
3081
            TermVocabularyDto termVocabulary = (TermVocabularyDto)entity;
3082
            switch (termVocabulary.getTermType()) {
3083
            case State:
3084
                element = new StateVocabularyDtoCollectionElement(this, parentElement, termVocabulary, removeListener, backgroundColor, style);
3085
                break;
3086
            case Modifier:
3087
                element = new RecommendedModifierDtoVocabulariesElement(this, parentElement, termVocabulary, removeListener, backgroundColor, style);
3088
                break;
3089
            default:
3090
                break;
3091
            }
3092
        }else if (entity instanceof MeasurementUnit) {
3093
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
3094
        }else if (entity instanceof TermDto) {
3095
            if(((TermDto)entity).getTermType().equals(TermType.MeasurementUnit)){
3096
                element = new MeasurementUnitDtoCollectionElement(this, parentElement, (TermDto) entity, removeListener, backgroundColor, style);
3097
            }else if (((TermDto)entity).getTermType().equals(TermType.StatisticalMeasure)){
3098
                element = new StatisticalMeasureDtoCollectionElement(this, parentElement, (TermDto) entity, removeListener, backgroundColor, style);
3099
            }
3100
        }else if (entity instanceof StatisticalMeasure) {
3101
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
3102
        } else if (entity instanceof FeatureState && parentElement instanceof InapplicableIfEntityCollectionSection) {
3103
            element = new InapplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
3104
        } else if (entity instanceof FeatureState && parentElement instanceof OnlyApplicableIfEntityCollectionSection) {
3105
            element = new OnlyApplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
3106
        }
3107

    
3108
        //check for parent section when entity is null
3109
        //this happens when AbstractUnboundEntityCollectionSection is used
3110
        if(element==null){
3111
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
3112
                element = new ScopeElement(this,
3113
                        parentElement,
3114
                        (DefinedTerm) entity,
3115
                        removeListener,
3116
                        style);
3117
            }
3118
            else if(parentElement instanceof ModifierSection){
3119
                element = new ModifierElement(this,
3120
                        parentElement,
3121
                        (DefinedTerm) entity,
3122
                        removeListener,
3123
                        style);
3124
            }
3125
        }
3126

    
3127

    
3128
        if (element == null) {
3129
            MessagingUtils.messageDialog(
3130
                    String.format("Error when creating section %s",
3131
                            parentElement.getClass().getSimpleName()),
3132
                    this,
3133
                    String.format("Could not generate collection element for entity of class %s."
3134
                            + " Looks like the case is not yet handled. Check implementation.\n"
3135
                            + "Entity: %s", entity.getClass(), entity.toString()), null);
3136
        }
3137

    
3138
        else{
3139
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
3140
                element.setPersistentBackground(backgroundColor);
3141
            }
3142
            adapt(element);
3143
            parentElement.addElement(element);
3144
        }
3145

    
3146
        return element;
3147
    }
3148

    
3149
    /**
3150
     * <p>
3151
     * Creates a selection element for the given type T.
3152
     * </p>
3153
     * <p>
3154
     * <strong>Selection elements not handled by this method:</strong>
3155
     * <ul>
3156
     * <li>{@link TaxonNodeSelectionElement} see
3157
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
3158
     * </li>
3159
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
3160
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
3161
     * </li>
3162
     * </ul>
3163
     * </p>
3164
     *
3165
     * @param clazz
3166
     *            a {@link Class} object of the type that you want the selection
3167
     *            element to handle
3168
     * @param parentElement
3169
     *            a {@link ICdmFormElement} object.
3170
     * @param labelString
3171
     *            a {@link String} object.
3172
     * @param selectionType
3173
     * @param selection
3174
     *            a {@link ICdmBase} object.
3175
     * @param style
3176
     *            a int.
3177
     * @param conversation
3178
     *            a {@link ConversationHolder} object.
3179
     * @return a {@link EntitySelectionElement} object.
3180
     */
3181
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3182
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3183
            int style, Integer limit) {
3184
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this,
3185
                parentElement, clazz,
3186
                labelString, selection, mode, style, limit);
3187
        adapt(element);
3188
        parentElement.addElement(element);
3189
        return element;
3190
    }
3191

    
3192
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3193
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3194
            int style, boolean filterElement) {
3195
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
3196
                parentElement, clazz,
3197
                labelString, selection, mode, style, filterElement);
3198
        adapt(element);
3199
        parentElement.addElement(element);
3200
        return element;
3201
    }
3202

    
3203
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3204
//            ConversationHolder conversation,
3205
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3206
            int style) {
3207
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this,
3208
                parentElement, clazz,
3209
                labelString, selection, mode, style);
3210
        adapt(element);
3211
        parentElement.addElement(element);
3212
        return element;
3213
    }
3214

    
3215
    public CommonNameReferenceSelectionElement createCommonNameReferenceSelectionElement(ICdmFormElement parentElement, String labelString, Reference selection, int mode,
3216
          int style) {
3217
        CommonNameReferenceSelectionElement element = new CommonNameReferenceSelectionElement(this,
3218
              parentElement, labelString, selection, mode, style);
3219
      adapt(element);
3220
      parentElement.addElement(element);
3221
      return element;
3222
  }
3223

    
3224
    /**
3225
     * <p>
3226
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
3227
     * </p>
3228
     * <p>
3229
     * <strong>Selection elements not handled by this method:</strong>
3230
     * <ul>
3231
     * <li>{@link TaxonNodeSelectionElement} see
3232
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
3233
     * </li>
3234
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
3235
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
3236
     * </li>
3237
     * </ul>
3238
     * </p>
3239
     *
3240
     * @param clazz
3241
     *            a {@link Class} object of the type that you want the selection
3242
     *            element to handle
3243
     * @param parentElement
3244
     *            a {@link ICdmFormElement} object.
3245
     * @param labelString
3246
     *            a {@link String} object.
3247
     * @param selectionType
3248
     * @param selection
3249
     *            a {@link ICdmBase} object.
3250
     * @param style
3251
     *            a int.
3252
     * @param conversation
3253
     *            a {@link ConversationHolder} object.
3254
     * @return a {@link EntitySelectionElement} object.
3255
     */
3256
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
3257
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
3258
            T selection, int mode, int style) {
3259
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, //conversation,
3260
                parentElement, clazz,
3261
                labelString, selection, mode, style);
3262
        adapt(element);
3263
        parentElement.addElement(element);
3264
        return element;
3265
    }
3266

    
3267
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3268
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
3269
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this,
3270
                parentElement,
3271
                labelString, selection, mode, style, null);
3272
        adapt(element);
3273
        parentElement.addElement(element);
3274
        return element;
3275
    }
3276
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3277
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style, Integer limit) {
3278
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
3279
                parentElement,
3280
                labelString, selection, mode, style, limit);
3281
        adapt(element);
3282
        parentElement.addElement(element);
3283
        return element;
3284
    }
3285

    
3286

    
3287
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
3288
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
3289
//            int mode, int style) {
3290
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
3291
//                conversation, parentElement, labelString, selection, mode, style);
3292
//        adapt(element);
3293
//        parentElement.addElement(element);
3294
//        return element;
3295
//    }
3296

    
3297
    /** {@inheritDoc} */
3298
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
3299
        LabelElement labelElement = new LabelElement(this, parentElement, text);
3300
        adapt(labelElement);
3301
        parentElement.addElement(labelElement);
3302
        return labelElement;
3303
    }
3304

    
3305

    
3306

    
3307
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
3308
//        Label label = new Label(formElement.getLayoutComposite(), style);
3309
//        label.setText(labelText+" (yyyy-MM-dd)");
3310
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
3311
//        dateElement.initInternalController();
3312
//
3313
//        return dateElement;
3314
//    }
3315

    
3316
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
3317
    	 Label label = new Label(formElement.getLayoutComposite(), style);
3318
         label.setText(labelText);
3319
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3320
         DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
3321
         dateElement.initController(this, formElement);
3322
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3323
         return dateElement;
3324
    }
3325

    
3326
    /**
3327
     * <p>
3328
     * Getter for the field <code>selectionProvider</code>.
3329
     * </p>
3330
     *
3331
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
3332
     */
3333
    public ISelectionProvider getSelectionProvider() {
3334
        return selectionProvider;
3335
    }
3336

    
3337
    /**
3338
     * <p>
3339
     * createDetailedDescriptionDetailElement
3340
     * </p>
3341
     *
3342
     * @param parentElement
3343
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3344
     *            object.
3345
     * @param entity
3346
     *            a
3347
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
3348
     *            object.
3349
     * @param style
3350
     *            a int.
3351
     * @return a
3352
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
3353
     *         object.
3354
     */
3355
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
3356
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
3357
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
3358

    
3359
        if (entity instanceof CategoricalData) {
3360
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
3361
                    (CategoricalData) entity, style);
3362
        } else if (entity instanceof CommonTaxonName) {
3363
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
3364
                    style);
3365
        } else if (entity instanceof Distribution && !enabled) {
3366
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3367
                    enabled, style);
3368
        } else if (entity instanceof Distribution) {
3369
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3370
                    true, style);
3371
        }else if (entity instanceof IndividualsAssociation) {
3372
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
3373
                    (IndividualsAssociation) entity, style);
3374
        } else if (entity instanceof QuantitativeData) {
3375
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
3376
                    (QuantitativeData) entity, style);
3377
        } else if (entity instanceof TaxonInteraction) {
3378
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
3379
                    (TaxonInteraction) entity, style);
3380
        } else if (entity instanceof TemporalData) {
3381
            detailedDescriptionElement = new TemporalDataDetailElement(this, parentElement, (TemporalData) entity, style);
3382
        } else if (entity instanceof TextData) {
3383
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
3384
        }
3385
        else {
3386
            throw new IllegalStateException("There is no interface for the given description element");
3387
        }
3388
        adapt(detailedDescriptionElement);
3389
        parentElement.addElement(detailedDescriptionElement);
3390
        return detailedDescriptionElement;
3391

    
3392
    }
3393

    
3394
    /**
3395
     * Creates a styled text as a part of the form.
3396
     *
3397
     * @param parent
3398
     *            the text parent
3399
     * @param value
3400
     *            the text initial value
3401
     * @param style
3402
     *            the text style
3403
     * @return the text widget
3404
     */
3405
    public StyledText createStyledText(Composite parent, String value, int style) {
3406
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3407
        if (value != null) {
3408
            text.setText(value);
3409
        }
3410
        text.setForeground(getColors().getForeground());
3411
        text.setBackground(getColors().getBackground());
3412
        // text.addFocusListener(visibilityHandler);
3413
        return text;
3414
    }
3415

    
3416
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3417
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3418
        addAndAdaptSection(parentElement, section);
3419
        return section;
3420
    }
3421

    
3422
    /**
3423
     * @param formElement
3424
     * @param conversationHolder
3425
     * @param style
3426
     * @return
3427
     */
3428
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3429
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3430
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3431
        addAndAdaptSection(formElement, section);
3432
        return section;
3433
    }
3434

    
3435

    
3436
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3437
			ICdmFormElement parentElement, int style) {
3438
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3439
		addAndAdaptElement(parentElement, section);
3440
        return section;
3441
	}
3442

    
3443
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3444
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3445
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3446
	        addAndAdaptSection(formElement, section);
3447
	        return section;
3448
	}
3449

    
3450

    
3451
    /**
3452
     * <p>
3453
     * createTextWithLabelElement
3454
     * </p>
3455
     *
3456
     * @param parentElement
3457
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3458
     *            object.
3459
     * @param labelString
3460
     *            a {@link java.lang.String} object.
3461
     * @param initialText
3462
     *            a {@link java.lang.String} object.
3463
     * @param textLimit maximal number of characters allowed
3464
     * @param style
3465
     *            a int.
3466
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
3467
     *         object.
3468
     */
3469
    public RuleConsideredElement createRuleConsideredElement(ICdmFormElement parentElement, String labelString, boolean isShowCodeEdition, int style) {
3470
        RuleConsideredElement element = new RuleConsideredElement(this, parentElement, labelString, isShowCodeEdition, style);
3471
        adapt(element);
3472
        parentElement.addElement(element);
3473
        return element;
3474
    }
3475

    
3476
    /**
3477
     * @param class1
3478
     * @param formElement
3479
     * @param string
3480
     * @param area
3481
     * @param nothing
3482
     * @param style
3483
     * @return
3484
     */
3485
    public EntitySelectionElementWithIdInVocabulary createSelectionElementWithIdInVocabulary(Class<NamedArea> clazz,
3486
            ICdmFormElement formElement, String labelString, NamedArea area, int mode, int style) {
3487
        EntitySelectionElementWithIdInVocabulary element = new EntitySelectionElementWithIdInVocabulary(this,
3488
                formElement, clazz, labelString, area, mode, style);
3489
        adapt(element);
3490
        formElement.addElement(element);
3491
        return element;
3492
    }
3493

    
3494
    /**
3495
     * @param extendedTimePeriodElement
3496
     * @param twistie
3497
     * @return
3498
     */
3499
    public ExtendedTimeDetailSection createExtendedTimeDetailSection(
3500
            ExtendedTimePeriodElement parentElement, int style) {
3501
        ExtendedTimeDetailSection section = new ExtendedTimeDetailSection(this, parentElement,  style);
3502
        parentElement.addElement(section);
3503
        adapt(section);
3504
        return section;
3505
    }
3506
    public ExtendedTimePeriodElement createExtendedTimePeriodElement(
3507
            ICdmFormElement parentElement, String labelString, ExtendedTimePeriod timePeriod, int style) {
3508
        ExtendedTimePeriodElement section = new ExtendedTimePeriodElement(this, parentElement, labelString, timePeriod, style);
3509
        parentElement.addElement(section);
3510
        adapt(section);
3511
        return section;
3512
    }
3513

    
3514

    
3515

    
3516

    
3517
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3518
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3519
//				 initialText, textHeight, style);
3520
//	        adapt(element);
3521
//	        parentElement.addElement(element);
3522
//	        return element;
3523
//	}
3524

    
3525

    
3526

    
3527

    
3528

    
3529

    
3530

    
3531
}
(8-8/53)