Project

General

Profile

Download (174 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.name.NameRelationship;
108
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
109
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
110
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
111
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
112
import eu.etaxonomy.cdm.model.name.TextualTypeDesignation;
113
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
114
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
115
import eu.etaxonomy.cdm.model.permission.GrantedAuthorityImpl;
116
import eu.etaxonomy.cdm.model.permission.Group;
117
import eu.etaxonomy.cdm.model.permission.User;
118
import eu.etaxonomy.cdm.model.reference.Reference;
119
import eu.etaxonomy.cdm.model.taxon.Taxon;
120
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
121
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
122
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
123
import eu.etaxonomy.cdm.model.term.DefinedTerm;
124
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
125
import eu.etaxonomy.cdm.model.term.IEnumTerm;
126
import eu.etaxonomy.cdm.model.term.Representation;
127
import eu.etaxonomy.cdm.model.term.TermBase;
128
import eu.etaxonomy.cdm.model.term.TermTree;
129
import eu.etaxonomy.cdm.model.term.TermType;
130
import eu.etaxonomy.cdm.model.term.TermVocabulary;
131
import eu.etaxonomy.cdm.persistence.dto.TermDto;
132
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
133
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
134
import eu.etaxonomy.taxeditor.model.MessagingUtils;
135
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
136
import eu.etaxonomy.taxeditor.store.StoreUtil;
137
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
138
import eu.etaxonomy.taxeditor.ui.combo.InverseTermWrapper;
139
import eu.etaxonomy.taxeditor.ui.combo.MisappliedRelationshipComboElement;
140
import eu.etaxonomy.taxeditor.ui.combo.NameRelationshipTypeCombo;
141
import eu.etaxonomy.taxeditor.ui.combo.VocabularyComboElement;
142
import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
143
import eu.etaxonomy.taxeditor.ui.dialog.CloneClassificationDetailElement;
144
import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection.UnitType;
145
import eu.etaxonomy.taxeditor.ui.mvc.element.DateElement;
146
import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
147
import eu.etaxonomy.taxeditor.ui.openurl.OpenUrlSelectorElement;
148
import eu.etaxonomy.taxeditor.ui.password.EditPasswordElement;
149
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
150
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
151
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
152
import eu.etaxonomy.taxeditor.ui.section.EmptyElement;
153
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement;
154
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection;
155
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailElement;
156
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
157
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailElement;
158
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
159
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
160
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberSection;
161
import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
162
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailElement;
163
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailSection;
164
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeAgentRelationCollectionElement;
165
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeAgentRelationCollectionSection;
166
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailElement;
167
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailSection;
168
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksElement;
169
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
170
import eu.etaxonomy.taxeditor.ui.section.common.ReferenceEntityDetailElement;
171
import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
172
import eu.etaxonomy.taxeditor.ui.section.description.CommonNameSourceElement;
173
import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
174
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
175
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailElement;
176
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
177
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
178
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
179
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
180
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceElement;
181
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
182
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceElement;
183
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
184
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
185
import eu.etaxonomy.taxeditor.ui.section.description.ModifierElement;
186
import eu.etaxonomy.taxeditor.ui.section.description.ModifierSection;
187
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageDetailElement;
188
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
189
import eu.etaxonomy.taxeditor.ui.section.description.ScopeElement;
190
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
191
import eu.etaxonomy.taxeditor.ui.section.description.StateDataElement;
192
import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;
193
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueElement;
194
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueSection;
195
import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;
196
import eu.etaxonomy.taxeditor.ui.section.description.detail.CategoricalDataDetailElement;
197
import eu.etaxonomy.taxeditor.ui.section.description.detail.CommonNameDetailElement;
198
import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
199
import eu.etaxonomy.taxeditor.ui.section.description.detail.IndividualsAssociationDetailElement;
200
import eu.etaxonomy.taxeditor.ui.section.description.detail.QuantitativeDataDetailElement;
201
import eu.etaxonomy.taxeditor.ui.section.description.detail.TaxonInteractionDetailElement;
202
import eu.etaxonomy.taxeditor.ui.section.description.detail.TemporalDataDetailElement;
203
import eu.etaxonomy.taxeditor.ui.section.description.detail.TextDataDetailElement;
204
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDetailElement;
205
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDetailSection;
206
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDtoDetailElement;
207
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDtoDetailSection;
208
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDetailElement;
209
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDetailSection;
210
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDtoDetailElement;
211
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDtoDetailSection;
212
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement;
213
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
214
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfCollectionElement;
215
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfEntityCollectionSection;
216
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfEntityCollectionSectionForNode;
217
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfCollectionElement;
218
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfEntityCollectionSection;
219
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfEntityCollectionSectionForNode;
220
import eu.etaxonomy.taxeditor.ui.section.feature.TermNodeDetailElement;
221
import eu.etaxonomy.taxeditor.ui.section.feature.TermNodeDetailSection;
222
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailElement;
223
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailElementForNode;
224
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailSection;
225
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailSectionForNode;
226
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityCollectionElement;
227
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailElement;
228
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
229
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailElement;
230
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
231
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailElement;
232
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
233
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailElement;
234
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
235
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailElement;
236
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
237
import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
238
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
239
import eu.etaxonomy.taxeditor.ui.section.media.ImageFileElement;
240
import eu.etaxonomy.taxeditor.ui.section.media.MediaDetailElement;
241
import eu.etaxonomy.taxeditor.ui.section.media.MediaMetaElement;
242
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationElement;
243
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartElement;
244
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartSection;
245
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationSection;
246
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
247
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
248
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailSection;
249
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailElement;
250
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailSection;
251
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailElement;
252
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailSection;
253
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailElement;
254
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
255
import eu.etaxonomy.taxeditor.ui.section.name.NameTypeDesignationElement;
256
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusElement;
257
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
258
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailElement;
259
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
260
import eu.etaxonomy.taxeditor.ui.section.name.RuleConsideredElement;
261
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
262
import eu.etaxonomy.taxeditor.ui.section.name.TextTypeDesignationElement;
263
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
264
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreaDetailElement;
265
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
266
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
267
import eu.etaxonomy.taxeditor.ui.section.occurrence.CurrentDeterminationDetailSection;
268
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailElement;
269
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
270
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailElement;
271
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
272
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitMediaSection;
273
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement;
274
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
275
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement;
276
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection;
277
import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
278
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitFacadeDetailElement;
279
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitFacadeDetailSection;
280
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitFacadeGeneralDetailElement;
281
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitFacadeGeneralDetailSection;
282
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailElement;
283
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
284
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopeDetailSection;
285
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopePolyKeyDetailSection;
286
import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
287
import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
288
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElement;
289
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailSection;
290
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationElement;
291
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationSection;
292
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailElement;
293
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
294
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenCurrentDeterminationDetailSection;
295
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailElement;
296
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailSection;
297
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailElement;
298
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailSection;
299
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenSourceCollectionDetailSection;
300
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractSampleDesignationDetailSection;
301
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailElement;
302
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailSection;
303
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoCollectionDetailSection;
304
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoDetailElement;
305
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailElement;
306
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailSection;
307
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailElement;
308
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailSection;
309
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.CurrentSampleDesignationDetailSection;
310
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailElement;
311
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
312
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailElement;
313
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
314
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationDetailElement;
315
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationSection;
316
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.PrimerGeneralDetailElement;
317
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailElement;
318
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailSection;
319
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationHistoryDetailSection;
320
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationTextDetailElement;
321
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceContigFileCollectionDetailSection;
322
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailElement;
323
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
324
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailElement;
325
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
326
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailElement;
327
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
328
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadPherogramCollectionDetailSection;
329
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailElement;
330
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
331
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailElement;
332
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
333
import eu.etaxonomy.taxeditor.ui.section.reference.AdvancedNomenclaturalSourceElement;
334
import eu.etaxonomy.taxeditor.ui.section.reference.AdvancedSourceElement;
335
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
336
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
337
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalSourceElement;
338
import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceAdvancedSection;
339
import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceElement;
340
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement;
341
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
342
import eu.etaxonomy.taxeditor.ui.section.reference.SecundumSourceElement;
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
     */
1279
    public Section adapt(AbstractFormSection section) {
1280
        section.setMenu(section.getLayoutComposite().getMenu());
1281
        adapt(section, true, true);
1282

    
1283
        // handle focus and property change events for cdm use
1284
        section.addFocusListener(selectionFocusHandler);
1285
        section.setPropertyChangeListeners(propertyChangeListeners);
1286

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

    
1297
        if (section.getToggle() != null) {
1298
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1299
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1300
        }
1301

    
1302
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1303

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

    
1315
    private class BoldFontHolder2 {
1316
        private Font normalFont;
1317

    
1318
        private Font boldFont;
1319

    
1320
        public BoldFontHolder2() {
1321
        }
1322

    
1323
        public Font getBoldFont(Font font) {
1324
            createBoldFont(font);
1325
            return boldFont;
1326
        }
1327

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

    
1338
        public void dispose() {
1339
            if (boldFont != null) {
1340
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1341
                boldFont = null;
1342
            }
1343
        }
1344
    }
1345

    
1346
    /**
1347
     * createToggleableTextField with relevance
1348
     */
1349
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1350
            String initialText, boolean initialState, CacheRelevance relevance, int style) {
1351

    
1352
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1353
                initialState, relevance, style | orientation);
1354
        adapt(element);
1355
        parentElement.addElement(element);
1356
        return element;
1357
    }
1358

    
1359
    /**
1360
     * like {@link #createToggleableTextField(ICdmFormElement, String, String, boolean, CacheRelevance, int)}
1361
     * but with predefined cache relevance == 1
1362
     */
1363
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1364
            String initialText, boolean initialState, int style) {
1365
        return createToggleableTextField(parentElement, labelString, initialText, initialState, CacheRelevance.CACHE1, style);
1366
    }
1367

    
1368
    /**
1369
     * like {@link #createToggleableTextField(ICdmFormElement, String, String, boolean, CacheRelevance, int)}
1370
     * but with predefined cache relevance == 1
1371
     */
1372
    public RemovableTextElement createRemovableTextField(ICdmFormElement parentElement, String labelString,
1373
            String initialText, int style) {
1374
        RemovableTextElement element = new RemovableTextElement(this, parentElement, labelString, initialText,
1375
                style | orientation);
1376

    
1377
        adapt(element);
1378
        parentElement.addElement(element);
1379
        return element;
1380
    }
1381

    
1382

    
1383
    /**
1384
     * createTimePeriodElement
1385
     */
1386
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1387
            TimePeriod timePeriod, int style) {
1388
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1389
        adapt(element);
1390
        parentElement.addElement(element);
1391
        return element;
1392
    }
1393

    
1394
    /**
1395
     * createVerbatimTimePeriodElement
1396
     */
1397
    public VerbatimTimePeriodElement createVerbatimTimePeriodElement(ICdmFormElement parentElement, String labelString,
1398
            VerbatimTimePeriod timePeriod, int style) {
1399
        VerbatimTimePeriodElement element = new VerbatimTimePeriodElement(this, parentElement, labelString, timePeriod, style);
1400
        adapt(element);
1401
        parentElement.addElement(element);
1402
        return element;
1403
    }
1404

    
1405
	/**
1406
	 * createGatheringEventUnitElement
1407
	 */
1408
	public GatheringEventUnitElement createGatheringEventUnitElement(
1409
			ICdmFormElement parentElement,
1410
			String labelString,
1411
			DerivedUnitFacade gatheringEvent,
1412
			MinMaxTextSection.UnitType unitType,
1413
			int style) {
1414
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1415
				parentElement,
1416
				labelString,
1417
				gatheringEvent,
1418
				unitType,
1419
				style);
1420
		adapt(element);
1421
		parentElement.addElement(element);
1422
		return element;
1423
	}
1424

    
1425
    /**
1426
     * createPointElement
1427
     */
1428
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1429
        PointElement element = new PointElement(this, parentElement, point, style);
1430
        adapt(element);
1431
        parentElement.addElement(element);
1432
        return element;
1433
    }
1434

    
1435
    /**
1436
     * Creates an empty section with the given message.<br>
1437
     * If message is <code>null</code> a default message will be displayed.
1438
     */
1439
    public EmptySection createEmptySection(String message, CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1440
        EmptySection section = new EmptySection(message, formFactory, parentElement, style);
1441
        parentElement.addElement(section);
1442
        adapt(section);
1443
        return section;
1444
    }
1445

    
1446
    /**
1447
     * <p>
1448
     * createDateDetailSection
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.DateDetailSection}
1457
     *         object.
1458
     */
1459
    public DateDetailSection<TimePeriod> createDateDetailSection(ICdmFormElement parentElement, int style) {
1460
        DateDetailSection<TimePeriod> section = new DateDetailSection<TimePeriod>(this, parentElement, false, style);
1461
        parentElement.addElement(section);
1462
        adapt(section);
1463
        return section;
1464
    }
1465

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

    
1487
	/**
1488
	 * <p>
1489
	 * createDateDetailSection
1490
	 * </p>
1491
	 *
1492
	 * @param parentElement
1493
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1494
	 *            object.
1495
	 * @param style
1496
	 *            a int.
1497
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1498
	 *         object.
1499
	 */
1500
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1501
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1502
		parentElement.addElement(section);
1503
		adapt(section);
1504
		return section;
1505
	}
1506

    
1507
    /**
1508
     * <p>
1509
     * createPartialElement
1510
     * </p>
1511
     *
1512
     * @param parentElement
1513
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1514
     *            object.
1515
     * @param labelString
1516
     *            a {@link java.lang.String} object.
1517
     * @param partial
1518
     *            a {@link org.joda.time.Partial} object.
1519
     * @param style
1520
     *            a int.
1521
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1522
     *         object.
1523
     */
1524
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1525
            int style) {
1526
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1527
        adapt(element);
1528
        parentElement.addElement(element);
1529
        return element;
1530
    }
1531

    
1532
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial, boolean showYear,
1533
            int style) {
1534
        PartialElement element = new PartialElement(this, parentElement, labelString, style, showYear);
1535
        adapt(element);
1536
        parentElement.addElement(element);
1537
        return element;
1538
    }
1539

    
1540
    /**
1541
     * <p>
1542
     * addSelectionListener
1543
     * </p>
1544
     *
1545
     * @param listener
1546
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1547
     */
1548
    public void addSelectionListener(SelectionListener listener) {
1549
        selectionListenerList.add(listener);
1550
    }
1551

    
1552
    /**
1553
     * <p>
1554
     * removeSelectionListener
1555
     * </p>
1556
     *
1557
     * @param listener
1558
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1559
     */
1560
    public void removeSelectionListener(SelectionListener listener) {
1561
        if (listener == null) {
1562
            MessagingUtils.error(this.getClass(),
1563
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1564
        } else {
1565
            selectionListenerList.remove(listener);
1566
        }
1567
    }
1568

    
1569
    /**
1570
     * <p>
1571
     * addPropertyChangeListener
1572
     * </p>
1573
     *
1574
     * @param listener
1575
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1576
     *            object.
1577
     */
1578
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1579
        if (propertyChangeListeners.contains(listener)) {
1580
            return;
1581
        }
1582
        propertyChangeListeners.add(0, listener);
1583
    }
1584

    
1585
    /**
1586
     * <p>
1587
     * removePropertyChangeListener
1588
     * </p>
1589
     *
1590
     * @param listener
1591
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1592
     *            object.
1593
     */
1594
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1595
        propertyChangeListeners.remove(listener);
1596
    }
1597

    
1598
    /**
1599
     * @return the propertyChangeListeners
1600
     */
1601
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1602
        return propertyChangeListeners;
1603
    }
1604

    
1605
    /**
1606
     * <p>
1607
     * createHorizontalSeparator
1608
     * </p>
1609
     *
1610
     * @param parentElement
1611
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1612
     *            object.
1613
     * @param style
1614
     *            a int.
1615
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1616
     */
1617
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1618
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1619
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1620
        return separator;
1621
    }
1622

    
1623
    /**
1624
     * <p>
1625
     * createVersionElement
1626
     * </p>
1627
     *
1628
     * @param parentElement
1629
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1630
     *            object.
1631
     * @param entity
1632
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1633
     *            object.
1634
     * @param style
1635
     *            a int.
1636
     * @return a
1637
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1638
     *         object.
1639
     */
1640
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1641
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1642
        adapt(element);
1643
        parentElement.addElement(element);
1644
        return element;
1645
    }
1646

    
1647
    /**
1648
     * @param cdmBaseSection
1649
     * @param object
1650
     * @param style
1651
     * @return
1652
     */
1653
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1654
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1655
        adapt(element);
1656
        parentElement.addElement(element);
1657
        return element;
1658
    }
1659

    
1660
    /**
1661
     * <p>
1662
     * createVersionSection
1663
     * </p>
1664
     *
1665
     * @param parentElement
1666
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1667
     *            object.
1668
     * @param style
1669
     *            a int.
1670
     * @return a
1671
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1672
     *         object.
1673
     */
1674
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1675
        VersionSection section = new VersionSection(this, parentElement, style);
1676
        parentElement.addElement(section);
1677
        adapt(section);
1678
        return section;
1679
    }
1680

    
1681
    /**
1682
     * @param parent
1683
     * @param i
1684
     * @return
1685
     */
1686
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1687
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1688
        parentElement.addElement(section);
1689
        adapt(section);
1690
        return section;
1691
    }
1692

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

    
1710
    /**
1711
     * <p>
1712
     * createHeadlineSection
1713
     * </p>
1714
     *
1715
     * @param parentElement
1716
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1717
     *            object.
1718
     * @return a
1719
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1720
     *         object.
1721
     */
1722
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1723
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1724
        parentElement.addElement(section);
1725
        adapt(section);
1726
        return section;
1727
    }
1728

    
1729
    /**
1730
     * <p>
1731
     * createParsingMessageElement
1732
     * </p>
1733
     *
1734
     * @param parentElement
1735
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1736
     *            object.
1737
     * @param parserProblem
1738
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1739
     *            object.
1740
     * @param style
1741
     *            a int.
1742
     * @return a
1743
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1744
     *         object.
1745
     */
1746
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1747
            ParserProblem parserProblem, int style) {
1748
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1749
        adapt(element);
1750
        parentElement.addElement(element);
1751
        return element;
1752
    }
1753

    
1754
    public DefinedTermDetailSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1755
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1756

    
1757
        DefinedTermDetailSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1758
                selectionProvider, style);
1759

    
1760
        parentElement.addElement(section);
1761
        adapt(section);
1762
        return section;
1763

    
1764
    }
1765

    
1766
    public TermMediaSection createTermMediaSection(ConversationHolder conversation,
1767
            ICdmFormElement parentElement, int style) {
1768
        TermMediaSection section = new TermMediaSection(this, conversation, parentElement, style);
1769
        parentElement.addElement(section);
1770
        adapt(section);
1771
        return section;
1772

    
1773
    }
1774

    
1775
    public DerivedUnitMediaSection createDerivedUnitMediaSection(ConversationHolder conversation,
1776
            ICdmFormElement parentElement, int style) {
1777
        DerivedUnitMediaSection section = new DerivedUnitMediaSection(this, conversation, parentElement, style);
1778
        parentElement.addElement(section);
1779
        adapt(section);
1780
        return section;
1781

    
1782
    }
1783

    
1784
    /**
1785
     * @param definedTermClass
1786
     * @param formElement
1787
     * @param style
1788
     * @return
1789
     */
1790
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1791
            ICdmFormElement parentElement, int style) {
1792
        AbstractCdmDetailElement element = null;
1793

    
1794
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1795
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1796
        } else if (definedTermClass.equals(Feature.class)) {
1797
            element = new FeatureDetailElement(this, parentElement);
1798
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1799
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1800
        } else {
1801
            element = new DefinedTermDetailElement(this, parentElement);
1802
        }
1803

    
1804

    
1805
        adapt(element);
1806
        parentElement.addElement(element);
1807
        return element;
1808
    }
1809

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

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

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

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

    
1834
    public CharacterNodeDetailElement createCharacterNodeDetailElement(ICdmFormElement parentElement, int style){
1835
        CharacterNodeDetailElement element = new CharacterNodeDetailElement(this, parentElement);
1836
        addAndAdaptElement(parentElement, element);
1837
        return element;
1838
    }
1839
    public CharacterNodeDtoDetailElement createCharacterNodeDtoDetailElement(ICdmFormElement parentElement, int style){
1840
        CharacterNodeDtoDetailElement element = new CharacterNodeDtoDetailElement(this, parentElement);
1841
        addAndAdaptElement(parentElement, element);
1842
        return element;
1843
    }
1844

    
1845
    public CharacterDetailElement createCharacterDetailElement(ICdmFormElement parentElement, int style){
1846
        CharacterDetailElement element = new CharacterDetailElement(this, parentElement);
1847
        addAndAdaptElement(parentElement, element);
1848
        return element;
1849
    }
1850
    public CharacterDtoDetailElement createCharacterDtoDetailElement(ICdmFormElement parentElement, int style){
1851
        CharacterDtoDetailElement element = new CharacterDtoDetailElement(this, parentElement);
1852
        addAndAdaptElement(parentElement, element);
1853
        return element;
1854
    }
1855

    
1856
    public TermTreeDetailElement createFeatureTreeDetailElement(ICdmFormElement parentElement, int style){
1857
        TermTreeDetailElement element = new TermTreeDetailElement(this, parentElement);
1858
        addAndAdaptElement(parentElement, element);
1859
        return element;
1860
    }
1861

    
1862
    /**
1863
     * @param parentElement
1864
     * @param style
1865
     * @return
1866
     */
1867
    public AbstractCdmDetailElement<TermTree> createFeatureTreeDetailElementForTree(
1868
            AbstractCdmDetailSection<TermTree> parentElement, int style) {
1869
        TermTreeDetailElementForNode element = new TermTreeDetailElementForNode(this, parentElement);
1870
        addAndAdaptElement(parentElement, element);
1871
        return element;
1872
    }
1873

    
1874
    public TermNodeDetailElement createFeatureNodeDetailElement(ICdmFormElement parentElement, int style){
1875
        TermNodeDetailElement element = new TermNodeDetailElement(this, parentElement);
1876
        addAndAdaptElement(parentElement, element);
1877
        return element;
1878
    }
1879

    
1880

    
1881
    //--------DetailSections---------
1882
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1883
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1884
        addAndAdaptSection(parentElement, section);
1885
        return section;
1886
    }
1887

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

    
1894
    public TermTreeDetailSection createFeatureTreeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1895
        TermTreeDetailSection section = new TermTreeDetailSection(this, conversation, parentElement, selectionProvider, style);
1896
        addAndAdaptSection(parentElement, section);
1897
        return section;
1898
    }
1899
    public TermTreeDetailSectionForNode createFeatureTreeDetailSectionForTree(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1900
        TermTreeDetailSectionForNode section = new TermTreeDetailSectionForNode(this, conversation, parentElement, selectionProvider, style);
1901
        addAndAdaptSection(parentElement, section);
1902
        return section;
1903
    }
1904

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

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

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

    
1923
    public AdvancedSourceElement createAdvancedSourceDetailElement(ICdmFormElement parentElement, int style){
1924
        AdvancedSourceElement element = new AdvancedSourceElement(this, parentElement);
1925
        addAndAdaptElement(parentElement, element);
1926
        return element;
1927
    }
1928

    
1929
    public AdvancedSourceElement createAdvancedNomenclaturalSourceDetailElement(ICdmFormElement parentElement, int style){
1930
        AdvancedNomenclaturalSourceElement element = new AdvancedNomenclaturalSourceElement(this, parentElement);
1931
        addAndAdaptElement(parentElement, element);
1932
        return element;
1933
    }
1934

    
1935
    public SingleSourceSection createSingleSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, CdmBase cdmEntity, ISelectionProvider selectionProvider, String label, int style){
1936
        SingleSourceSection section = new SingleSourceSection(this, conversation, parentElement, cdmEntity, selectionProvider, style, label);
1937
        addAndAdaptSection(parentElement, section);
1938
        return section;
1939
    }
1940

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

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

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

    
1959
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1960
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1961
        addAndAdaptSection(parentElement, section);
1962
        return section;
1963
    }
1964

    
1965
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1966
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1967
        addAndAdaptSection(parentElement, section);
1968
        return section;
1969
    }
1970

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

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

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

    
1989

    
1990

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

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

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

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

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

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

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

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

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

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

    
2051
    public ClassificationDetailSection createClassificationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2052
        ClassificationDetailSection section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style);
2053
        addAndAdaptSection(parentElement, section);
2054
        return section;
2055
    }
2056

    
2057
    public TaxonNodeDetailSection createTaxonNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2058
        TaxonNodeDetailSection section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
2059
        addAndAdaptSection(parentElement, section);
2060
        return section;
2061
    }
2062

    
2063
    public PolytomousKeyDetailSection createPolytomousKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2064
        PolytomousKeyDetailSection section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
2065
        addAndAdaptSection(parentElement, section);
2066
        return section;
2067
    }
2068

    
2069
    public PolytomousKeyNodeDetailSection createPolytomousKeyNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2070
        PolytomousKeyNodeDetailSection section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
2071
        addAndAdaptSection(parentElement, section);
2072
        return section;
2073
    }
2074

    
2075
    public InstitutionDetailSection createInstitutionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2076
        InstitutionDetailSection section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
2077
        addAndAdaptSection(parentElement, section);
2078
        return section;
2079
    }
2080

    
2081
    public FieldUnitFacadeGeneralDetailSection createFieldUnitFacadeGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2082
        FieldUnitFacadeGeneralDetailSection section = new FieldUnitFacadeGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2083
        addAndAdaptSection(parentElement, section);
2084
        return section;
2085
    }
2086

    
2087
    public DerivedUnitGeneralDetailSection createDerivedUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2088
        DerivedUnitGeneralDetailSection section = new DerivedUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2089
        addAndAdaptSection(parentElement, section);
2090
        return section;
2091
    }
2092

    
2093
    public PreservedSpecimenGeneralDetailSection createPreservedSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2094
        PreservedSpecimenGeneralDetailSection section = new PreservedSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2095
        addAndAdaptSection(parentElement, section);
2096
        return section;
2097
    }
2098

    
2099
    public TissueSampleGeneralDetailSection createTissueSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2100
        TissueSampleGeneralDetailSection section = new TissueSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2101
        addAndAdaptSection(parentElement, section);
2102
        return section;
2103
    }
2104

    
2105
    public DnaSampleGeneralDetailSection createDnaSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2106
        DnaSampleGeneralDetailSection section = new DnaSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2107
        addAndAdaptSection(parentElement, section);
2108
        return section;
2109
    }
2110

    
2111
    public DnaSamplePreparationPreservationSection createDnaSamplePreparationPreservationSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2112
        DnaSamplePreparationPreservationSection section = new DnaSamplePreparationPreservationSection(this, conversation, parentElement, selectionProvider, style);
2113
        addAndAdaptSection(parentElement, section);
2114
        return section;
2115
    }
2116

    
2117
    public DnaQualityDetailSection createDnaQualityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2118
        DnaQualityDetailSection section = new DnaQualityDetailSection(this, conversation, parentElement, selectionProvider, style);
2119
        addAndAdaptSection(parentElement, section);
2120
        return section;
2121
    }
2122

    
2123
    public SequenceGeneralDetailSection createSequenceGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2124
        SequenceGeneralDetailSection section = new SequenceGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2125
        addAndAdaptSection(parentElement, section);
2126
        return section;
2127
    }
2128

    
2129
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2130
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
2131
        addAndAdaptSection(parentElement, section);
2132
        return section;
2133
    }
2134

    
2135
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2136
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
2137
        addAndAdaptSection(parentElement, section);
2138
        return section;
2139
    }
2140

    
2141
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2142
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
2143
        addAndAdaptSection(parentElement, section);
2144
        return section;
2145
    }
2146

    
2147
    public SingleReadGeneralDetailSection createSingleReadGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2148
        SingleReadGeneralDetailSection section = new SingleReadGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2149
        addAndAdaptSection(parentElement, section);
2150
        return section;
2151
    }
2152

    
2153
    public AmplificationGeneralDetailSection createAmplificationGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2154
        AmplificationGeneralDetailSection section = new AmplificationGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2155
        addAndAdaptSection(parentElement, section);
2156
        return section;
2157
    }
2158

    
2159
    public AmplificationPrimerDetailSection createAmplificationPrimerDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2160
        AmplificationPrimerDetailSection section = new AmplificationPrimerDetailSection(this, conversation, parentElement, selectionProvider, style);
2161
        addAndAdaptSection(parentElement, section);
2162
        return section;
2163
    }
2164

    
2165
    public AmplificationCloningDetailSection createAmplificationCloningDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2166
        AmplificationCloningDetailSection section = new AmplificationCloningDetailSection(this, conversation, parentElement, selectionProvider, style);
2167
        addAndAdaptSection(parentElement, section);
2168
        return section;
2169
    }
2170

    
2171
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2172
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
2173
        addAndAdaptSection(parentElement, section);
2174
        return section;
2175
    }
2176

    
2177
    public MediaSpecimenGeneralDetailSection createMediaSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2178
        MediaSpecimenGeneralDetailSection section = new MediaSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2179
        addAndAdaptSection(parentElement, section);
2180
        return section;
2181
    }
2182

    
2183
    public HybridDetailSection createHybridDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2184
        HybridDetailSection section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
2185
        addAndAdaptSection(parentElement, section);
2186
        return section;
2187
    }
2188

    
2189
    public UserDetailSection createUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2190
        UserDetailSection section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
2191
        addAndAdaptSection(parentElement, section);
2192
        return section;
2193
    }
2194

    
2195
    public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2196
        GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
2197
        addAndAdaptSection(parentElement, section);
2198
        return section;
2199
    }
2200

    
2201
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2202
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
2203
        addAndAdaptSection(parentElement, section);
2204
        return section;
2205
    }
2206

    
2207
    public SampleDesignationDetailSection createSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2208
        SampleDesignationDetailSection section = new SampleDesignationDetailSection(this, conversation, parentElement, selectionProvider, style);
2209
        addAndAdaptSection(parentElement, section);
2210
        return section;
2211
    }
2212

    
2213
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2214
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style, true);
2215
        addAndAdaptSection(parentElement, section);
2216
        return section;
2217
    }
2218

    
2219
    public ReferencedEntityDetailSection createReferencedEntityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2220
        ReferencedEntityDetailSection section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
2221
        addAndAdaptSection(parentElement, section);
2222
        return section;
2223
    }
2224

    
2225
    public TermVocabularyDetailSection createTermVocabularyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2226
        TermVocabularyDetailSection section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
2227
        addAndAdaptSection(parentElement, section);
2228
        return section;
2229
    }
2230

    
2231
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2232
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
2233
        addAndAdaptSection(parentElement, section);
2234
        return section;
2235
    }
2236

    
2237
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2238
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
2239
        addAndAdaptSection(parentElement, section);
2240
        return section;
2241
    }
2242

    
2243
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2244
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
2245
        addAndAdaptSection(parentElement, section);
2246
        return section;
2247
    }
2248

    
2249
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
2250
        parentElement.addElement(section);
2251
        adapt(section);
2252
    }
2253

    
2254
    //--------DetailElements------------
2255

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

    
2262
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
2263
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
2264
        addAndAdaptElement(parentElement, element);
2265
        return element;
2266
    }
2267

    
2268
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
2269
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
2270
        addAndAdaptElement(parentElement, element);
2271
        return element;
2272
    }
2273

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

    
2280
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
2281
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
2282
        addAndAdaptElement(parentElement, element);
2283
        return element;
2284
    }
2285
    public OriginalSourceElement createOriginalSourceElement(ICdmFormElement parentElement, CdmBase cdmEntity, String label){
2286
        OriginalSourceElement element = new OriginalSourceElement(this, parentElement, cdmEntity, label);
2287
        addAndAdaptElement(parentElement, element);
2288
        return element;
2289
    }
2290

    
2291
    public SecundumSourceElement createSecundumSourceElement(ICdmFormElement parentElement, CdmBase cdmEntity, String label){
2292
        SecundumSourceElement element = new SecundumSourceElement(this, parentElement, cdmEntity, label);
2293
        addAndAdaptElement(parentElement, element);
2294
        return element;
2295
    }
2296
    public NomenclaturalSourceElement createNomenclaturalSourceElement(ICdmFormElement parentElement, CdmBase cdmEntity, String label){
2297
        NomenclaturalSourceElement element = new NomenclaturalSourceElement(this, parentElement, cdmEntity, label);
2298
        addAndAdaptElement(parentElement, element);
2299
        return element;
2300
    }
2301

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

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

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

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

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

    
2332
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2333
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2334
        addAndAdaptElement(parentElement, element);
2335
        return element;
2336
    }
2337

    
2338
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2339
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2340
        addAndAdaptElement(parentElement, element);
2341
        return element;
2342
    }
2343

    
2344
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2345
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2346
        addAndAdaptElement(parentElement, element);
2347
        return element;
2348
    }
2349

    
2350
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2351
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2352
        addAndAdaptElement(parentElement, element);
2353
        return element;
2354
    }
2355

    
2356
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2357
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2358
        adapt(element);
2359
        parentElement.addElement(element);
2360

    
2361
        return element;
2362
    }
2363

    
2364
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2365
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2366
        addAndAdaptElement(parentElement, element);
2367
        return element;
2368
    }
2369

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

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

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

    
2388
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2389
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2390
        addAndAdaptElement(parentElement, element);
2391
        return element;
2392
    }
2393

    
2394
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2395
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2396
        addAndAdaptElement(parentElement, element);
2397
        return element;
2398
    }
2399

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

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

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

    
2418
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2419
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2420
        addAndAdaptElement(parentElement, element);
2421
        return element;
2422
    }
2423

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

    
2430
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2431
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2432
        addAndAdaptElement(parentElement, element);
2433
        return element;
2434
    }
2435

    
2436
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2437
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2438
        addAndAdaptElement(parentElement, element);
2439
        return element;
2440
    }
2441

    
2442
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
2443
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
2444
        addAndAdaptElement(parentElement, element);
2445
        return element;
2446
    }
2447

    
2448
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2449
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2450
        addAndAdaptElement(parentElement, element);
2451
        return element;
2452
    }
2453

    
2454

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

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

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

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

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

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

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

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

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

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

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

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

    
2527
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2528
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2529
        addAndAdaptElement(parentElement, element);
2530
        return element;
2531
    }
2532

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

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

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

    
2551
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2552
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2553
        addAndAdaptElement(parentElement, mediaDetailElement);
2554
        return mediaDetailElement;
2555
    }
2556

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

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

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

    
2575
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2576
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2577
        addAndAdaptElement(parentElement, element);
2578
        return element;
2579
    }
2580

    
2581
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2582
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2583
        addAndAdaptElement(parentElement, element);
2584
        return element;
2585
    }
2586

    
2587
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2588
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2589
        addAndAdaptElement(parentElement, element);
2590
        return element;
2591
    }
2592

    
2593
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2594
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2595
        addAndAdaptElement(parentElement, element);
2596
        return element;
2597
    }
2598

    
2599
    /**
2600
     * @param parentElement
2601
     * @param element
2602
     */
2603
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2604
        adapt(element);
2605
        parentElement.addElement(element);
2606
    }
2607

    
2608
    //--------EntityCollectionSection----------
2609
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2610
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2611
        addAndAdaptSection(parentElement, section);
2612
        return section;
2613
    }
2614

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

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

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

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

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

    
2645
    public CreditSection createCreditSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2646
        CreditSection section = new CreditSection(this, conversation, parentElement, style);
2647
        addAndAdaptSection(parentElement, section);
2648
        return section;
2649
    }
2650
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2651
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2652
        addAndAdaptSection(parentElement, section);
2653
        return section;
2654
    }
2655
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, Reference defaultSource, int style){
2656
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, defaultSource, style);
2657
        addAndAdaptSection(parentElement, section);
2658
        return section;
2659
    }
2660

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

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

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

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

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

    
2691
    public MediaRepresentationPartSection createMediaRepresentationPartSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2692
        MediaRepresentationPartSection section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
2693
        addAndAdaptSection(parentElement, section);
2694
        return section;
2695
    }
2696

    
2697
    public ModifierSection createModifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2698
        ModifierSection section = new ModifierSection(this, conversation, parentElement, style);
2699
        addAndAdaptSection(parentElement, section);
2700
        return section;
2701
    }
2702

    
2703
    public NomenclaturalStatusSection createNomenclaturalStatusSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2704
        NomenclaturalStatusSection section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
2705
        addAndAdaptSection(parentElement, section);
2706
        return section;
2707
    }
2708

    
2709
    public NameRelationshipDetailSection createNameRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2710
        NameRelationshipDetailSection section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
2711
        addAndAdaptSection(parentElement, section);
2712
        return section;
2713
    }
2714

    
2715
//    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2716
//        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2717
//        addAndAdaptSection(parentElement, section);
2718
//        return section;
2719
//    }
2720
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2721
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, style);
2722
        addAndAdaptSection(parentElement, section);
2723
        return section;
2724
    }
2725

    
2726
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, String label, int style){
2727
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, true, label, style);
2728
        addAndAdaptSection(parentElement, section);
2729
        return section;
2730
    }
2731

    
2732
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, String label, boolean isWithTypeAndDesc, int style){
2733
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, isWithTypeAndDesc, label, style);
2734
        addAndAdaptSection(parentElement, section);
2735
        return section;
2736
    }
2737

    
2738
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2739
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2740

    
2741
        addAndAdaptSection(parentElement, section);
2742
        return section;
2743
    }
2744

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

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

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

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

    
2769
    public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2770
        StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
2771
        addAndAdaptSection(parentElement, section);
2772
        return section;
2773
    }
2774

    
2775
    public StatisticalMeasurementValueSection createStatisticalMeasurementValueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2776
        StatisticalMeasurementValueSection section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
2777
        addAndAdaptSection(parentElement, section);
2778
        return section;
2779
    }
2780

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

    
2787
    public StateVocabularyCollectionSection createStateVocabulariesSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2788
        StateVocabularyCollectionSection section = new StateVocabularyCollectionSection(this, conversation, parentElement, style);
2789
        addAndAdaptSection(parentElement, section);
2790
        return section;
2791
    }
2792

    
2793
    public StateVocabularyDtoCollectionSection createStateVocabulariesDtoSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2794
        StateVocabularyDtoCollectionSection section = new StateVocabularyDtoCollectionSection(this, conversation, parentElement, style);
2795
        addAndAdaptSection(parentElement, section);
2796
        return section;
2797
    }
2798

    
2799
    public RecommendedModifierVocabulariesCollectionSection createRecommendedModifierVocabulariesCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2800
        RecommendedModifierVocabulariesCollectionSection section = new RecommendedModifierVocabulariesCollectionSection(this, conversation, parentElement, style);
2801
        addAndAdaptSection(parentElement, section);
2802
        return section;
2803
    }
2804
    public RecommendedModifierVocabulariesDtoCollectionSection createRecommendedModifierVocabulariesDtoCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2805
        RecommendedModifierVocabulariesDtoCollectionSection section = new RecommendedModifierVocabulariesDtoCollectionSection(this, conversation, parentElement, style);
2806
        addAndAdaptSection(parentElement, section);
2807
        return section;
2808
    }
2809

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

    
2816
    public MeasurementUnitDtoCollectionSection createMeasurementUnitDtoCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2817
        MeasurementUnitDtoCollectionSection section = new MeasurementUnitDtoCollectionSection(this, conversation, parentElement, style);
2818
        addAndAdaptSection(parentElement, section);
2819
        return section;
2820
    }
2821
    public StatisticalMeasureCollectionSection createStatisticalMeasureCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2822
        StatisticalMeasureCollectionSection section = new StatisticalMeasureCollectionSection(this, conversation, parentElement, style);
2823
        addAndAdaptSection(parentElement, section);
2824
        return section;
2825
    }
2826

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2911
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2912
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2913
        addAndAdaptSection(parentElement, section);
2914
        return section;
2915
    }
2916

    
2917
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2918
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2919
        addAndAdaptSection(parentElement, section);
2920
        return section;
2921
    }
2922

    
2923
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2924
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2925
        addAndAdaptSection(parentElement, section);
2926
        return section;
2927
    }
2928

    
2929
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2930
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2931
        addAndAdaptSection(parentElement, section);
2932
        return section;
2933
    }
2934

    
2935
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2936
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2937
        addAndAdaptSection(parentElement, section);
2938
        return section;
2939
    }
2940

    
2941
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2942
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2943
        AbstractEntityCollectionElement<?> element = null;
2944

    
2945
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2946

    
2947
        if (entity instanceof Annotation) {
2948
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2949
        }else if (entity instanceof Person ) {
2950
            boolean isNomenclatural = false;
2951
            if (parentElement instanceof TeamMemberSection){
2952
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2953
            }
2954
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2955
        } else if (entity instanceof Credit) {
2956
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2957
        } else if (entity instanceof Extension) {
2958
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2959
        } else if (entity instanceof ExternalLink) {
2960
            boolean isAdvanced = true;
2961
            if(parentElement instanceof ExternalLinksSection){
2962
                isAdvanced = ((ExternalLinksSection)parentElement).isAdvanced();
2963
            }
2964
            element = new ExternalLinksElement(this, parentElement, (ExternalLink) entity, isAdvanced, removeListener, style);
2965
        } else if (entity instanceof Marker) {
2966
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2967
        } else if (entity instanceof TaxonNodeAgentRelation) {
2968
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2969
        }else if (entity instanceof Media) {
2970
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2971
        } else if (entity instanceof MediaRepresentation) {
2972
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2973
                    style);
2974
        } else if (entity instanceof ImageFile) {
2975
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2976
        } else if (entity instanceof MediaRepresentationPart) {
2977
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2978
                    removeListener, style);
2979
        } else if (entity instanceof NomenclaturalStatus) {
2980
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2981
                    style);
2982
        } else if (entity instanceof Rights) {
2983
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2984
        } else if (entity instanceof DescriptionElementSource && parentElement.getEntity() instanceof CommonTaxonName) {
2985
            element = new CommonNameSourceElement(this, parentElement, (DescriptionElementSource) entity,
2986
                    removeListener, style);
2987
        } else if (entity instanceof DescriptionElementSource  && parentElement.getEntity() instanceof Distribution) {
2988
            Composite parent = null;
2989
            if (parentElement instanceof DescriptionElementSourceSection){
2990
               parent = ((DescriptionElementSourceSection)parentElement).getParent();
2991
            }
2992
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2993
                    removeListener, style, false);
2994
        } else if (entity instanceof DescriptionElementSource) {
2995
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2996
                    removeListener, style, false);
2997
        }else if (entity instanceof TaxonNodeAgentRelation) {
2998
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2999
                    removeListener,backgroundColor, style);
3000
        }else if (entity instanceof IdentifiableSource && parentElement.getEntity() instanceof DescriptionElementBase) {
3001
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
3002
                    style, true);
3003
        } else if (entity instanceof IdentifiableSource ) {
3004
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
3005
                    style, true);
3006
        } else if (entity instanceof DefinedTerm) {
3007
            switch(((DefinedTerm)entity).getTermType()) {
3008
            case Scope:
3009
                element = new ScopeElement(this,
3010
                        parentElement,
3011
                        (DefinedTerm) entity,
3012
                        removeListener,
3013
                        style);
3014
                break;
3015
            case Modifier:
3016
                element = new ModifierElement(this,
3017
                        parentElement,
3018
                        (DefinedTerm) entity,
3019
                        removeListener,
3020
                        style);
3021
                break;
3022
            default:
3023
                break;
3024

    
3025
            }
3026
        } else if (entity instanceof Reference) {
3027
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
3028
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
3029
            }
3030
            else{
3031
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
3032
            }
3033
        } else if (entity instanceof NameTypeDesignation) {
3034
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
3035
                    style);
3036
        } else if (entity instanceof TextualTypeDesignation) {
3037
            element = new TextTypeDesignationElement(this, parentElement, (TextualTypeDesignation) entity, removeListener,
3038
                    style);
3039
        } else if (entity instanceof NameRelationship) {
3040
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
3041
                    style);
3042
        } else if (entity instanceof SpecimenTypeDesignation) {
3043
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
3044
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
3045
                        removeListener, style);
3046
            }
3047
            else{
3048
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
3049
                        removeListener, style);
3050
            }
3051
        } else if (entity instanceof StateData) {
3052
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
3053
        } else if (entity instanceof StatisticalMeasurementValue) {
3054
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
3055
                    removeListener, style);
3056
        } else if (entity instanceof DerivedUnit) {
3057
            switch(((DerivedUnit)entity).getRecordBasis()) {
3058
            case LivingSpecimen:
3059
            case PreservedSpecimen:
3060
            case OtherSpecimen:
3061
                element = new SpecimenCollectionDetailElement(this,
3062
                        parentElement,
3063
                        (DerivedUnit) entity,
3064
                        removeListener,
3065
                        style);
3066
                break;
3067
            default:
3068
                element = new DerivedUnitElement(this,
3069
                        parentElement,
3070
                        (DerivedUnit) entity,
3071
                        removeListener,
3072
                        style);
3073
            }
3074
        } else if (entity instanceof NamedArea) {
3075
            element = new CollectingAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
3076
        } else if (entity instanceof DeterminationEvent) {
3077
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
3078
        } else if (entity instanceof User) {
3079
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
3080
        } else if (entity instanceof GrantedAuthority) {
3081
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
3082
                    removeListener, style);
3083
        } else if (entity instanceof Group) {
3084
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
3085
        } else if (entity instanceof Taxon) {
3086
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
3087
        } else if (entity instanceof DescriptionElementBase) {
3088
            // this is the special case for protologs, maybe we can do this
3089
            // differently when API improves
3090
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
3091
//            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
3092
//                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
3093
//            }
3094
        } else if (entity instanceof Identifier) {
3095
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
3096
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier) entity, removeListener, backgroundColor, style);
3097
            }
3098
            else{
3099
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
3100
            }
3101
        } else if (entity instanceof TermVocabulary) {
3102
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
3103
            switch (termVocabulary.getTermType()) {
3104
            case State:
3105
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
3106
                break;
3107
            case Modifier:
3108
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
3109
                break;
3110
            default:
3111
                break;
3112
            }
3113
        }else if (entity instanceof TermVocabularyDto) {
3114
            TermVocabularyDto termVocabulary = (TermVocabularyDto)entity;
3115
            switch (termVocabulary.getTermType()) {
3116
            case State:
3117
                element = new StateVocabularyDtoCollectionElement(this, parentElement, termVocabulary, removeListener, backgroundColor, style);
3118
                break;
3119
            case Modifier:
3120
                element = new RecommendedModifierDtoVocabulariesElement(this, parentElement, termVocabulary, removeListener, backgroundColor, style);
3121
                break;
3122
            default:
3123
                break;
3124
            }
3125
        }else if (entity instanceof MeasurementUnit) {
3126
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
3127
        }else if (entity instanceof TermDto) {
3128
            if(((TermDto)entity).getTermType().equals(TermType.MeasurementUnit)){
3129
                element = new MeasurementUnitDtoCollectionElement(this, parentElement, (TermDto) entity, removeListener, backgroundColor, style);
3130
            }else if (((TermDto)entity).getTermType().equals(TermType.StatisticalMeasure)){
3131
                element = new StatisticalMeasureDtoCollectionElement(this, parentElement, (TermDto) entity, removeListener, backgroundColor, style);
3132
            }
3133
        }else if (entity instanceof StatisticalMeasure) {
3134
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
3135
        } else if (entity instanceof FeatureState && parentElement instanceof InapplicableIfEntityCollectionSection) {
3136
            element = new InapplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
3137
        } else if (entity instanceof FeatureState && parentElement instanceof OnlyApplicableIfEntityCollectionSection) {
3138
            element = new OnlyApplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
3139
        } else if (entity instanceof FeatureState && parentElement instanceof InapplicableIfEntityCollectionSectionForNode) {
3140
            element = new InapplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
3141
        } else if (entity instanceof FeatureState && parentElement instanceof OnlyApplicableIfEntityCollectionSectionForNode) {
3142
            element = new OnlyApplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
3143
        }
3144

    
3145
        //check for parent section when entity is null
3146
        //this happens when AbstractUnboundEntityCollectionSection is used
3147
        if(element==null){
3148
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
3149
                element = new ScopeElement(this,
3150
                        parentElement,
3151
                        (DefinedTerm) entity,
3152
                        removeListener,
3153
                        style);
3154
            }
3155
            else if(parentElement instanceof ModifierSection){
3156
                element = new ModifierElement(this,
3157
                        parentElement,
3158
                        (DefinedTerm) entity,
3159
                        removeListener,
3160
                        style);
3161
            }
3162
        }
3163

    
3164

    
3165
        if (element == null) {
3166
            MessagingUtils.messageDialog(
3167
                    String.format("Error when creating section %s",
3168
                            parentElement.getClass().getSimpleName()),
3169
                    this,
3170
                    String.format("Could not generate collection element for entity of class %s."
3171
                            + " Looks like the case is not yet handled. Check implementation.\n"
3172
                            + "Entity: %s", entity.getClass(), entity.toString()), null);
3173
        }
3174

    
3175
        else{
3176
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
3177
                element.setPersistentBackground(backgroundColor);
3178
            }
3179
            adapt(element);
3180
            parentElement.addElement(element);
3181
        }
3182

    
3183
        return element;
3184
    }
3185

    
3186
    /**
3187
     * <p>
3188
     * Creates a selection element for the given type T.
3189
     * </p>
3190
     * <p>
3191
     * <strong>Selection elements not handled by this method:</strong>
3192
     * <ul>
3193
     * <li>{@link TaxonNodeSelectionElement} see
3194
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
3195
     * </li>
3196
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
3197
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
3198
     * </li>
3199
     * </ul>
3200
     * </p>
3201
     *
3202
     * @param clazz
3203
     *            a {@link Class} object of the type that you want the selection
3204
     *            element to handle
3205
     * @param parentElement
3206
     *            a {@link ICdmFormElement} object.
3207
     * @param labelString
3208
     *            a {@link String} object.
3209
     * @param selectionType
3210
     * @param selection
3211
     *            a {@link ICdmBase} object.
3212
     * @param style
3213
     *            a int.
3214
     * @param conversation
3215
     *            a {@link ConversationHolder} object.
3216
     * @return a {@link EntitySelectionElement} object.
3217
     */
3218
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3219
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3220
            int style, Integer limit) {
3221
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this,
3222
                parentElement, clazz,
3223
                labelString, selection, mode, style, limit);
3224
        adapt(element);
3225
        parentElement.addElement(element);
3226
        return element;
3227
    }
3228

    
3229
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3230
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3231
            int style, boolean filterElement) {
3232
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
3233
                parentElement, clazz,
3234
                labelString, selection, mode, style, filterElement);
3235
        adapt(element);
3236
        parentElement.addElement(element);
3237
        return element;
3238
    }
3239

    
3240
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3241
//            ConversationHolder conversation,
3242
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3243
            int style) {
3244
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this,
3245
                parentElement, clazz,
3246
                labelString, selection, mode, style);
3247
        adapt(element);
3248
        parentElement.addElement(element);
3249
        return element;
3250
    }
3251

    
3252
    public CommonNameReferenceSelectionElement createCommonNameReferenceSelectionElement(ICdmFormElement parentElement, String labelString, Reference selection, int mode,
3253
          int style) {
3254
        CommonNameReferenceSelectionElement element = new CommonNameReferenceSelectionElement(this,
3255
              parentElement, labelString, selection, mode, style);
3256
      adapt(element);
3257
      parentElement.addElement(element);
3258
      return element;
3259
  }
3260

    
3261
    /**
3262
     * <p>
3263
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
3264
     * </p>
3265
     * <p>
3266
     * <strong>Selection elements not handled by this method:</strong>
3267
     * <ul>
3268
     * <li>{@link TaxonNodeSelectionElement} see
3269
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
3270
     * </li>
3271
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
3272
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
3273
     * </li>
3274
     * </ul>
3275
     * </p>
3276
     *
3277
     * @param clazz
3278
     *            a {@link Class} object of the type that you want the selection
3279
     *            element to handle
3280
     * @param parentElement
3281
     *            a {@link ICdmFormElement} object.
3282
     * @param labelString
3283
     *            a {@link String} object.
3284
     * @param selectionType
3285
     * @param selection
3286
     *            a {@link ICdmBase} object.
3287
     * @param style
3288
     *            a int.
3289
     * @param conversation
3290
     *            a {@link ConversationHolder} object.
3291
     * @return a {@link EntitySelectionElement} object.
3292
     */
3293
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
3294
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
3295
            T selection, int mode, int style) {
3296
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, //conversation,
3297
                parentElement, clazz,
3298
                labelString, selection, mode, style);
3299
        adapt(element);
3300
        parentElement.addElement(element);
3301
        return element;
3302
    }
3303

    
3304
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3305
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
3306
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this,
3307
                parentElement,
3308
                labelString, selection, mode, style, null);
3309
        adapt(element);
3310
        parentElement.addElement(element);
3311
        return element;
3312
    }
3313
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3314
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style, Integer limit) {
3315
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
3316
                parentElement,
3317
                labelString, selection, mode, style, limit);
3318
        adapt(element);
3319
        parentElement.addElement(element);
3320
        return element;
3321
    }
3322

    
3323

    
3324
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
3325
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
3326
//            int mode, int style) {
3327
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
3328
//                conversation, parentElement, labelString, selection, mode, style);
3329
//        adapt(element);
3330
//        parentElement.addElement(element);
3331
//        return element;
3332
//    }
3333

    
3334
    /** {@inheritDoc} */
3335
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
3336
        LabelElement labelElement = new LabelElement(this, parentElement, text);
3337
        adapt(labelElement);
3338
        parentElement.addElement(labelElement);
3339
        return labelElement;
3340
    }
3341

    
3342

    
3343

    
3344
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
3345
//        Label label = new Label(formElement.getLayoutComposite(), style);
3346
//        label.setText(labelText+" (yyyy-MM-dd)");
3347
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
3348
//        dateElement.initInternalController();
3349
//
3350
//        return dateElement;
3351
//    }
3352

    
3353
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
3354
    	 Label label = new Label(formElement.getLayoutComposite(), style);
3355
         label.setText(labelText);
3356
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3357
         DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
3358
         dateElement.initController(this, formElement);
3359
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3360
         return dateElement;
3361
    }
3362

    
3363
    /**
3364
     * <p>
3365
     * Getter for the field <code>selectionProvider</code>.
3366
     * </p>
3367
     *
3368
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
3369
     */
3370
    public ISelectionProvider getSelectionProvider() {
3371
        return selectionProvider;
3372
    }
3373

    
3374
    /**
3375
     * <p>
3376
     * createDetailedDescriptionDetailElement
3377
     * </p>
3378
     *
3379
     * @param parentElement
3380
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3381
     *            object.
3382
     * @param entity
3383
     *            a
3384
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
3385
     *            object.
3386
     * @param style
3387
     *            a int.
3388
     * @return a
3389
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
3390
     *         object.
3391
     */
3392
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
3393
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
3394
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
3395

    
3396
        if (entity instanceof CategoricalData) {
3397
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
3398
                    (CategoricalData) entity, style);
3399
        } else if (entity instanceof CommonTaxonName) {
3400
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
3401
                    style);
3402
        } else if (entity instanceof Distribution && !enabled) {
3403
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3404
                    enabled, style);
3405
        } else if (entity instanceof Distribution) {
3406
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3407
                    true, style);
3408
        }else if (entity instanceof IndividualsAssociation) {
3409
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
3410
                    (IndividualsAssociation) entity, style);
3411
        } else if (entity instanceof QuantitativeData) {
3412
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
3413
                    (QuantitativeData) entity, style);
3414
        } else if (entity instanceof TaxonInteraction) {
3415
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
3416
                    (TaxonInteraction) entity, style);
3417
        } else if (entity instanceof TemporalData) {
3418
            detailedDescriptionElement = new TemporalDataDetailElement(this, parentElement, (TemporalData) entity, style);
3419
        } else if (entity instanceof TextData) {
3420
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
3421
        }
3422
        else {
3423
            throw new IllegalStateException("There is no interface for the given description element");
3424
        }
3425
        adapt(detailedDescriptionElement);
3426
        parentElement.addElement(detailedDescriptionElement);
3427
        return detailedDescriptionElement;
3428

    
3429
    }
3430

    
3431
    /**
3432
     * Creates a styled text as a part of the form.
3433
     *
3434
     * @param parent
3435
     *            the text parent
3436
     * @param value
3437
     *            the text initial value
3438
     * @param style
3439
     *            the text style
3440
     * @return the text widget
3441
     */
3442
    public StyledText createStyledText(Composite parent, String value, int style) {
3443
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3444
        if (value != null) {
3445
            text.setText(value);
3446
        }
3447
        text.setForeground(getColors().getForeground());
3448
        text.setBackground(getColors().getBackground());
3449
        // text.addFocusListener(visibilityHandler);
3450
        return text;
3451
    }
3452

    
3453
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3454
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3455
        addAndAdaptSection(parentElement, section);
3456
        return section;
3457
    }
3458

    
3459
    /**
3460
     * @param formElement
3461
     * @param conversationHolder
3462
     * @param style
3463
     * @return
3464
     */
3465
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3466
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3467
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3468
        addAndAdaptSection(formElement, section);
3469
        return section;
3470
    }
3471

    
3472

    
3473
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3474
			ICdmFormElement parentElement, int style) {
3475
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3476
		addAndAdaptElement(parentElement, section);
3477
        return section;
3478
	}
3479

    
3480
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3481
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3482
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3483
	        addAndAdaptSection(formElement, section);
3484
	        return section;
3485
	}
3486

    
3487

    
3488
    /**
3489
     * <p>
3490
     * createTextWithLabelElement
3491
     * </p>
3492
     *
3493
     * @param parentElement
3494
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3495
     *            object.
3496
     * @param labelString
3497
     *            a {@link java.lang.String} object.
3498
     * @param initialText
3499
     *            a {@link java.lang.String} object.
3500
     * @param textLimit maximal number of characters allowed
3501
     * @param style
3502
     *            a int.
3503
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
3504
     *         object.
3505
     */
3506
    public RuleConsideredElement createRuleConsideredElement(ICdmFormElement parentElement, String labelString, boolean isShowCodeEdition, int style) {
3507
        RuleConsideredElement element = new RuleConsideredElement(this, parentElement, labelString, isShowCodeEdition, style);
3508
        adapt(element);
3509
        parentElement.addElement(element);
3510
        return element;
3511
    }
3512

    
3513
    /**
3514
     * @param class1
3515
     * @param formElement
3516
     * @param string
3517
     * @param area
3518
     * @param nothing
3519
     * @param style
3520
     * @return
3521
     */
3522
    public EntitySelectionElementWithIdInVocabulary createSelectionElementWithIdInVocabulary(Class<NamedArea> clazz,
3523
            ICdmFormElement formElement, String labelString, NamedArea area, int mode, int style) {
3524
        EntitySelectionElementWithIdInVocabulary element = new EntitySelectionElementWithIdInVocabulary(this,
3525
                formElement, clazz, labelString, area, mode, style);
3526
        adapt(element);
3527
        formElement.addElement(element);
3528
        return element;
3529
    }
3530

    
3531
    /**
3532
     * @param extendedTimePeriodElement
3533
     * @param twistie
3534
     * @return
3535
     */
3536
    public ExtendedTimeDetailSection createExtendedTimeDetailSection(
3537
            ExtendedTimePeriodElement parentElement, int style) {
3538
        ExtendedTimeDetailSection section = new ExtendedTimeDetailSection(this, parentElement,  style);
3539
        parentElement.addElement(section);
3540
        adapt(section);
3541
        return section;
3542
    }
3543
    public ExtendedTimePeriodElement createExtendedTimePeriodElement(
3544
            ICdmFormElement parentElement, String labelString, ExtendedTimePeriod timePeriod, int style) {
3545
        ExtendedTimePeriodElement section = new ExtendedTimePeriodElement(this, parentElement, labelString, timePeriod, style);
3546
        parentElement.addElement(section);
3547
        adapt(section);
3548
        return section;
3549
    }
3550

    
3551

    
3552

    
3553

    
3554
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3555
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3556
//				 initialText, textHeight, style);
3557
//	        adapt(element);
3558
//	        parentElement.addElement(element);
3559
//	        return element;
3560
//	}
3561

    
3562

    
3563

    
3564

    
3565

    
3566

    
3567

    
3568
}
(11-11/57)