Project

General

Profile

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

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

    
18
import javax.inject.Inject;
19

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

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

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

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

    
424
    @Inject
425
    private IEclipseContext context;
426

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
564
        super.adapt(composite);
565
    }
566

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

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

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

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

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

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

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

    
704

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

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

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

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

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

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

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

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

    
811

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1031

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1320
    private class BoldFontHolder2 {
1321
        private Font normalFont;
1322

    
1323
        private Font boldFont;
1324

    
1325
        public BoldFontHolder2() {
1326
        }
1327

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

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

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

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

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

    
1364
    /**
1365
     * like {@link #createToggleableTextField(ICdmFormElement, String, String, boolean, CacheRelevance, int)}
1366
     * but with predefined cache relevance == 1
1367
     */
1368
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1369
            String initialText, boolean initialState, int style) {
1370
        return createToggleableTextField(parentElement, labelString, initialText, initialState, CacheRelevance.CACHE1, style);
1371
    }
1372

    
1373

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

    
1385
    /**
1386
     * createVerbatimTimePeriodElement
1387
     */
1388
    public VerbatimTimePeriodElement createVerbatimTimePeriodElement(ICdmFormElement parentElement, String labelString,
1389
            VerbatimTimePeriod timePeriod, int style) {
1390
        VerbatimTimePeriodElement element = new VerbatimTimePeriodElement(this, parentElement, labelString, timePeriod, style);
1391
        adapt(element);
1392
        parentElement.addElement(element);
1393
        return element;
1394
    }
1395

    
1396
	/**
1397
	 * createGatheringEventUnitElement
1398
	 */
1399
	public GatheringEventUnitElement createGatheringEventUnitElement(
1400
			ICdmFormElement parentElement,
1401
			String labelString,
1402
			DerivedUnitFacade gatheringEvent,
1403
			MinMaxTextSection.UnitType unitType,
1404
			int style) {
1405
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1406
				parentElement,
1407
				labelString,
1408
				gatheringEvent,
1409
				unitType,
1410
				style);
1411
		adapt(element);
1412
		parentElement.addElement(element);
1413
		return element;
1414
	}
1415

    
1416
    /**
1417
     * createPointElement
1418
     */
1419
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1420
        PointElement element = new PointElement(this, parentElement, point, style);
1421
        adapt(element);
1422
        parentElement.addElement(element);
1423
        return element;
1424
    }
1425

    
1426
    /**
1427
     * Creates an empty section with the given message.<br>
1428
     * If message is <code>null</code> a default message will be displayed.
1429
     */
1430
    public EmptySection createEmptySection(String message, CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1431
        EmptySection section = new EmptySection(message, formFactory, parentElement, style);
1432
        parentElement.addElement(section);
1433
        adapt(section);
1434
        return section;
1435
    }
1436

    
1437
    /**
1438
     * <p>
1439
     * createDateDetailSection
1440
     * </p>
1441
     *
1442
     * @param parentElement
1443
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1444
     *            object.
1445
     * @param style
1446
     *            a int.
1447
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1448
     *         object.
1449
     */
1450
    public DateDetailSection<TimePeriod> createDateDetailSection(ICdmFormElement parentElement, int style) {
1451
        DateDetailSection<TimePeriod> section = new DateDetailSection<TimePeriod>(this, parentElement, false, style);
1452
        parentElement.addElement(section);
1453
        adapt(section);
1454
        return section;
1455
    }
1456

    
1457
    /**
1458
     * <p>
1459
     * createVerbatimDateDetailSection
1460
     * </p>
1461
     *
1462
     * @param parentElement
1463
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1464
     *            object.
1465
     * @param style
1466
     *            a int.
1467
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.VerbatimDateDetailSection}
1468
     *         object.
1469
     */
1470
    public DateDetailSection<VerbatimTimePeriod> createVerbatimDateDetailSection(ICdmFormElement parentElement, int style) {
1471
        DateDetailSection<VerbatimTimePeriod> section
1472
        	= new DateDetailSection<VerbatimTimePeriod>(this, parentElement, true, style);
1473
        parentElement.addElement(section);
1474
        adapt(section);
1475
        return section;
1476
    }
1477

    
1478
	/**
1479
	 * <p>
1480
	 * createDateDetailSection
1481
	 * </p>
1482
	 *
1483
	 * @param parentElement
1484
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1485
	 *            object.
1486
	 * @param style
1487
	 *            a int.
1488
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1489
	 *         object.
1490
	 */
1491
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1492
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1493
		parentElement.addElement(section);
1494
		adapt(section);
1495
		return section;
1496
	}
1497

    
1498
    /**
1499
     * <p>
1500
     * createPartialElement
1501
     * </p>
1502
     *
1503
     * @param parentElement
1504
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1505
     *            object.
1506
     * @param labelString
1507
     *            a {@link java.lang.String} object.
1508
     * @param partial
1509
     *            a {@link org.joda.time.Partial} object.
1510
     * @param style
1511
     *            a int.
1512
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1513
     *         object.
1514
     */
1515
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1516
            int style) {
1517
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1518
        adapt(element);
1519
        parentElement.addElement(element);
1520
        return element;
1521
    }
1522

    
1523
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial, boolean showYear,
1524
            int style) {
1525
        PartialElement element = new PartialElement(this, parentElement, labelString, style, showYear);
1526
        adapt(element);
1527
        parentElement.addElement(element);
1528
        return element;
1529
    }
1530

    
1531
    /**
1532
     * <p>
1533
     * addSelectionListener
1534
     * </p>
1535
     *
1536
     * @param listener
1537
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1538
     */
1539
    public void addSelectionListener(SelectionListener listener) {
1540
        selectionListenerList.add(listener);
1541
    }
1542

    
1543
    /**
1544
     * <p>
1545
     * removeSelectionListener
1546
     * </p>
1547
     *
1548
     * @param listener
1549
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1550
     */
1551
    public void removeSelectionListener(SelectionListener listener) {
1552
        if (listener == null) {
1553
            MessagingUtils.error(this.getClass(),
1554
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1555
        } else {
1556
            selectionListenerList.remove(listener);
1557
        }
1558
    }
1559

    
1560
    /**
1561
     * <p>
1562
     * addPropertyChangeListener
1563
     * </p>
1564
     *
1565
     * @param listener
1566
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1567
     *            object.
1568
     */
1569
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1570
        if (propertyChangeListeners.contains(listener)) {
1571
            return;
1572
        }
1573
        propertyChangeListeners.add(0, listener);
1574
    }
1575

    
1576
    /**
1577
     * <p>
1578
     * removePropertyChangeListener
1579
     * </p>
1580
     *
1581
     * @param listener
1582
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1583
     *            object.
1584
     */
1585
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1586
        propertyChangeListeners.remove(listener);
1587
    }
1588

    
1589
    /**
1590
     * @return the propertyChangeListeners
1591
     */
1592
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1593
        return propertyChangeListeners;
1594
    }
1595

    
1596
    /**
1597
     * <p>
1598
     * createHorizontalSeparator
1599
     * </p>
1600
     *
1601
     * @param parentElement
1602
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1603
     *            object.
1604
     * @param style
1605
     *            a int.
1606
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1607
     */
1608
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1609
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1610
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1611
        return separator;
1612
    }
1613

    
1614
    /**
1615
     * <p>
1616
     * createVersionElement
1617
     * </p>
1618
     *
1619
     * @param parentElement
1620
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1621
     *            object.
1622
     * @param entity
1623
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1624
     *            object.
1625
     * @param style
1626
     *            a int.
1627
     * @return a
1628
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1629
     *         object.
1630
     */
1631
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1632
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1633
        adapt(element);
1634
        parentElement.addElement(element);
1635
        return element;
1636
    }
1637

    
1638
    /**
1639
     * @param cdmBaseSection
1640
     * @param object
1641
     * @param style
1642
     * @return
1643
     */
1644
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1645
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1646
        adapt(element);
1647
        parentElement.addElement(element);
1648
        return element;
1649
    }
1650

    
1651
    /**
1652
     * <p>
1653
     * createVersionSection
1654
     * </p>
1655
     *
1656
     * @param parentElement
1657
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1658
     *            object.
1659
     * @param style
1660
     *            a int.
1661
     * @return a
1662
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1663
     *         object.
1664
     */
1665
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1666
        VersionSection section = new VersionSection(this, parentElement, style);
1667
        parentElement.addElement(section);
1668
        adapt(section);
1669
        return section;
1670
    }
1671

    
1672
    /**
1673
     * @param parent
1674
     * @param i
1675
     * @return
1676
     */
1677
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1678
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1679
        parentElement.addElement(section);
1680
        adapt(section);
1681
        return section;
1682
    }
1683

    
1684
    /**
1685
     * <p>
1686
     * createEmptyElement
1687
     * </p>
1688
     *
1689
     * @param parentElement
1690
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1691
     *            object.
1692
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1693
     */
1694
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1695
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1696
        adapt(element);
1697
        parentElement.addElement(element);
1698
        return element;
1699
    }
1700

    
1701
    /**
1702
     * <p>
1703
     * createHeadlineSection
1704
     * </p>
1705
     *
1706
     * @param parentElement
1707
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1708
     *            object.
1709
     * @return a
1710
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1711
     *         object.
1712
     */
1713
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1714
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1715
        parentElement.addElement(section);
1716
        adapt(section);
1717
        return section;
1718
    }
1719

    
1720
    /**
1721
     * <p>
1722
     * createParsingMessageElement
1723
     * </p>
1724
     *
1725
     * @param parentElement
1726
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1727
     *            object.
1728
     * @param parserProblem
1729
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1730
     *            object.
1731
     * @param style
1732
     *            a int.
1733
     * @return a
1734
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1735
     *         object.
1736
     */
1737
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1738
            ParserProblem parserProblem, int style) {
1739
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1740
        adapt(element);
1741
        parentElement.addElement(element);
1742
        return element;
1743
    }
1744

    
1745
    public DefinedTermDetailSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1746
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1747

    
1748
        DefinedTermDetailSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1749
                selectionProvider, style);
1750

    
1751
        parentElement.addElement(section);
1752
        adapt(section);
1753
        return section;
1754

    
1755
    }
1756

    
1757
    public TermMediaSection createTermMediaSection(ConversationHolder conversation,
1758
            ICdmFormElement parentElement, int style) {
1759
        TermMediaSection section = new TermMediaSection(this, conversation, parentElement, style);
1760
        parentElement.addElement(section);
1761
        adapt(section);
1762
        return section;
1763

    
1764
    }
1765

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

    
1773
    }
1774

    
1775
    /**
1776
     * @param definedTermClass
1777
     * @param formElement
1778
     * @param style
1779
     * @return
1780
     */
1781
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1782
            AbstractCdmDetailSection parentElement, int style) {
1783
        AbstractCdmDetailElement element = null;
1784

    
1785
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1786
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1787
        } else if (definedTermClass.equals(Feature.class)) {
1788
            element = new FeatureDetailElement(this, parentElement);
1789
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1790
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1791
        } else {
1792
            element = new DefinedTermDetailElement(this, parentElement);
1793
        }
1794

    
1795

    
1796
        adapt(element);
1797
        parentElement.addElement(element);
1798
        return element;
1799
    }
1800

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

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

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

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

    
1825
    public CharacterNodeDetailElement createCharacterNodeDetailElement(ICdmFormElement parentElement, int style){
1826
        CharacterNodeDetailElement element = new CharacterNodeDetailElement(this, parentElement);
1827
        addAndAdaptElement(parentElement, element);
1828
        return element;
1829
    }
1830
    public CharacterNodeDtoDetailElement createCharacterNodeDtoDetailElement(ICdmFormElement parentElement, int style){
1831
        CharacterNodeDtoDetailElement element = new CharacterNodeDtoDetailElement(this, parentElement);
1832
        addAndAdaptElement(parentElement, element);
1833
        return element;
1834
    }
1835

    
1836
    public CharacterDetailElement createCharacterDetailElement(ICdmFormElement parentElement, int style){
1837
        CharacterDetailElement element = new CharacterDetailElement(this, parentElement);
1838
        addAndAdaptElement(parentElement, element);
1839
        return element;
1840
    }
1841
    public CharacterDtoDetailElement createCharacterDtoDetailElement(ICdmFormElement parentElement, int style){
1842
        CharacterDtoDetailElement element = new CharacterDtoDetailElement(this, parentElement);
1843
        addAndAdaptElement(parentElement, element);
1844
        return element;
1845
    }
1846

    
1847
    public TermTreeDetailElement createFeatureTreeDetailElement(ICdmFormElement parentElement, int style){
1848
        TermTreeDetailElement element = new TermTreeDetailElement(this, parentElement);
1849
        addAndAdaptElement(parentElement, element);
1850
        return element;
1851
    }
1852

    
1853
    /**
1854
     * @param parentElement
1855
     * @param style
1856
     * @return
1857
     */
1858
    public AbstractCdmDetailElement<TermTree> createFeatureTreeDetailElementForTree(
1859
            AbstractCdmDetailSection<TermTree> parentElement, int style) {
1860
        TermTreeDetailElementForNode element = new TermTreeDetailElementForNode(this, parentElement);
1861
        addAndAdaptElement(parentElement, element);
1862
        return element;
1863
    }
1864

    
1865
    public TermNodeDetailElement createFeatureNodeDetailElement(ICdmFormElement parentElement, int style){
1866
        TermNodeDetailElement element = new TermNodeDetailElement(this, parentElement);
1867
        addAndAdaptElement(parentElement, element);
1868
        return element;
1869
    }
1870

    
1871

    
1872
    //--------DetailSections---------
1873
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1874
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1875
        addAndAdaptSection(parentElement, section);
1876
        return section;
1877
    }
1878

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

    
1885
    public TermTreeDetailSection createFeatureTreeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1886
        TermTreeDetailSection section = new TermTreeDetailSection(this, conversation, parentElement, selectionProvider, style);
1887
        addAndAdaptSection(parentElement, section);
1888
        return section;
1889
    }
1890
    public TermTreeDetailSectionForNode createFeatureTreeDetailSectionForTree(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1891
        TermTreeDetailSectionForNode section = new TermTreeDetailSectionForNode(this, conversation, parentElement, selectionProvider, style);
1892
        addAndAdaptSection(parentElement, section);
1893
        return section;
1894
    }
1895

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

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

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

    
1914
    public AdvancedSourceElement createAdvancedSourceDetailElement(ICdmFormElement parentElement, int style){
1915
        AdvancedSourceElement element = new AdvancedSourceElement(this, parentElement);
1916
        addAndAdaptElement(parentElement, element);
1917
        return element;
1918
    }
1919

    
1920
    public AdvancedSourceElement createAdvancedNomenclaturalSourceDetailElement(ICdmFormElement parentElement, int style){
1921
        AdvancedNomenclaturalSourceElement element = new AdvancedNomenclaturalSourceElement(this, parentElement);
1922
        addAndAdaptElement(parentElement, element);
1923
        return element;
1924
    }
1925

    
1926
    public SingleSourceSection createSingleSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, CdmBase cdmEntity, ISelectionProvider selectionProvider, String label, int style){
1927
        SingleSourceSection section = new SingleSourceSection(this, conversation, parentElement, cdmEntity, selectionProvider, style, label);
1928
        addAndAdaptSection(parentElement, section);
1929
        return section;
1930
    }
1931

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

    
1938
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1939
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1940
        addAndAdaptSection(parentElement, section);
1941
        return section;
1942
    }
1943

    
1944
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1945
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1946
        addAndAdaptSection(parentElement, section);
1947
        return section;
1948
    }
1949

    
1950
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1951
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1952
        addAndAdaptSection(parentElement, section);
1953
        return section;
1954
    }
1955

    
1956
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1957
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1958
        addAndAdaptSection(parentElement, section);
1959
        return section;
1960
    }
1961

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

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

    
1974
    public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1975
        ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1976
        addAndAdaptSection(parentElement, section);
1977
        return section;
1978
    }
1979

    
1980

    
1981

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2108
    public DnaQualityDetailSection createDnaQualityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2109
        DnaQualityDetailSection section = new DnaQualityDetailSection(this, conversation, parentElement, selectionProvider, style);
2110
        addAndAdaptSection(parentElement, section);
2111
        return section;
2112
    }
2113

    
2114
    public SequenceGeneralDetailSection createSequenceGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2115
        SequenceGeneralDetailSection section = new SequenceGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2116
        addAndAdaptSection(parentElement, section);
2117
        return section;
2118
    }
2119

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

    
2126
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2127
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
2128
        addAndAdaptSection(parentElement, section);
2129
        return section;
2130
    }
2131

    
2132
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2133
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
2134
        addAndAdaptSection(parentElement, section);
2135
        return section;
2136
    }
2137

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

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

    
2150
    public AmplificationPrimerDetailSection createAmplificationPrimerDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2151
        AmplificationPrimerDetailSection section = new AmplificationPrimerDetailSection(this, conversation, parentElement, selectionProvider, style);
2152
        addAndAdaptSection(parentElement, section);
2153
        return section;
2154
    }
2155

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

    
2162
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2163
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
2164
        addAndAdaptSection(parentElement, section);
2165
        return section;
2166
    }
2167

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

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

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

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

    
2192
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2193
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
2194
        addAndAdaptSection(parentElement, section);
2195
        return section;
2196
    }
2197

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

    
2204
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2205
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style, true);
2206
        addAndAdaptSection(parentElement, section);
2207
        return section;
2208
    }
2209

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

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

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

    
2228
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2229
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
2230
        addAndAdaptSection(parentElement, section);
2231
        return section;
2232
    }
2233

    
2234
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2235
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
2236
        addAndAdaptSection(parentElement, section);
2237
        return section;
2238
    }
2239

    
2240
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
2241
        parentElement.addElement(section);
2242
        adapt(section);
2243
    }
2244

    
2245
    //--------DetailElements------------
2246

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

    
2253
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
2254
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
2255
        addAndAdaptElement(parentElement, element);
2256
        return element;
2257
    }
2258

    
2259
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
2260
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
2261
        addAndAdaptElement(parentElement, element);
2262
        return element;
2263
    }
2264

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

    
2271
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
2272
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
2273
        addAndAdaptElement(parentElement, element);
2274
        return element;
2275
    }
2276
    public OriginalSourceElement createOriginalSourceElement(ICdmFormElement parentElement, CdmBase cdmEntity, String label){
2277
        OriginalSourceElement element = new OriginalSourceElement(this, parentElement, cdmEntity, label);
2278
        addAndAdaptElement(parentElement, element);
2279
        return element;
2280
    }
2281

    
2282
    public SecundumSourceElement createSecundumSourceElement(ICdmFormElement parentElement, CdmBase cdmEntity, String label){
2283
        SecundumSourceElement element = new SecundumSourceElement(this, parentElement, cdmEntity, label);
2284
        addAndAdaptElement(parentElement, element);
2285
        return element;
2286
    }
2287
    public NomenclaturalSourceElement createNomenclaturalSourceElement(ICdmFormElement parentElement, CdmBase cdmEntity, String label){
2288
        NomenclaturalSourceElement element = new NomenclaturalSourceElement(this, parentElement, cdmEntity, label);
2289
        addAndAdaptElement(parentElement, element);
2290
        return element;
2291
    }
2292

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

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

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

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

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

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

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

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

    
2341
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2342
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2343
        addAndAdaptElement(parentElement, element);
2344
        return element;
2345
    }
2346

    
2347
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2348
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2349
        adapt(element);
2350
        parentElement.addElement(element);
2351

    
2352
        return element;
2353
    }
2354

    
2355
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2356
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2357
        addAndAdaptElement(parentElement, element);
2358
        return element;
2359
    }
2360

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

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

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

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

    
2385
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2386
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2387
        addAndAdaptElement(parentElement, element);
2388
        return element;
2389
    }
2390

    
2391
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2392
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2393
        addAndAdaptElement(parentElement, element);
2394
        return element;
2395
    }
2396

    
2397
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2398
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2399
        addAndAdaptElement(parentElement, element);
2400
        return element;
2401
    }
2402

    
2403
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2404
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2405
        addAndAdaptElement(parentElement, element);
2406
        return element;
2407
    }
2408

    
2409
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2410
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2411
        addAndAdaptElement(parentElement, element);
2412
        return element;
2413
    }
2414

    
2415
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2416
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2417
        addAndAdaptElement(parentElement, element);
2418
        return element;
2419
    }
2420

    
2421
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2422
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2423
        addAndAdaptElement(parentElement, element);
2424
        return element;
2425
    }
2426

    
2427
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2428
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2429
        addAndAdaptElement(parentElement, element);
2430
        return element;
2431
    }
2432

    
2433
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
2434
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
2435
        addAndAdaptElement(parentElement, element);
2436
        return element;
2437
    }
2438

    
2439
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2440
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2441
        addAndAdaptElement(parentElement, element);
2442
        return element;
2443
    }
2444

    
2445

    
2446
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2447
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2448
        addAndAdaptElement(parentElement, element);
2449
        return element;
2450
    }
2451

    
2452
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2453
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2454
        addAndAdaptElement(parentElement, element);
2455
        return element;
2456
    }
2457

    
2458
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2459
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2460
        addAndAdaptElement(parentElement, element);
2461
        return element;
2462
    }
2463

    
2464
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2465
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2466
        addAndAdaptElement(parentElement, element);
2467
        return element;
2468
    }
2469

    
2470
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2471
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2472
        addAndAdaptElement(parentElement, element);
2473
        return element;
2474
    }
2475

    
2476
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2477
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2478
        addAndAdaptElement(parentElement, element);
2479
        return element;
2480
    }
2481

    
2482
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2483
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2484
        addAndAdaptElement(parentElement, element);
2485
        return element;
2486
    }
2487

    
2488
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2489
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2490
        addAndAdaptElement(parentElement, element);
2491
        return element;
2492
    }
2493

    
2494
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2495
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2496
        addAndAdaptElement(parentElement, element);
2497
        return element;
2498
    }
2499

    
2500
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2501
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2502
        addAndAdaptElement(parentElement, element);
2503
        return element;
2504
    }
2505

    
2506
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2507
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2508
        addAndAdaptElement(parentElement, element);
2509
        return element;
2510
    }
2511

    
2512
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2513
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2514
        addAndAdaptElement(parentElement, element);
2515
        return element;
2516
    }
2517

    
2518
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2519
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2520
        addAndAdaptElement(parentElement, element);
2521
        return element;
2522
    }
2523

    
2524
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2525
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2526
        addAndAdaptElement(parentElement, element);
2527
        return element;
2528
    }
2529

    
2530
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2531
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2532
        addAndAdaptElement(parentElement, element);
2533
        return element;
2534
    }
2535

    
2536
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2537
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2538
        addAndAdaptElement(parentElement, element);
2539
        return element;
2540
    }
2541

    
2542
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2543
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2544
        addAndAdaptElement(parentElement, mediaDetailElement);
2545
        return mediaDetailElement;
2546
    }
2547

    
2548
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2549
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2550
        addAndAdaptElement(parentElement, element);
2551
        return element;
2552
    }
2553

    
2554
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2555
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2556
        addAndAdaptElement(parentElement, element);
2557
        return element;
2558
    }
2559

    
2560
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2561
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2562
        addAndAdaptElement(parentElement, element);
2563
        return element;
2564
    }
2565

    
2566
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2567
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2568
        addAndAdaptElement(parentElement, element);
2569
        return element;
2570
    }
2571

    
2572
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2573
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2574
        addAndAdaptElement(parentElement, element);
2575
        return element;
2576
    }
2577

    
2578
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2579
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2580
        addAndAdaptElement(parentElement, element);
2581
        return element;
2582
    }
2583

    
2584
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2585
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2586
        addAndAdaptElement(parentElement, element);
2587
        return element;
2588
    }
2589

    
2590
    /**
2591
     * @param parentElement
2592
     * @param element
2593
     */
2594
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2595
        adapt(element);
2596
        parentElement.addElement(element);
2597
    }
2598

    
2599
    //--------EntityCollectionSection----------
2600
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2601
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2602
        addAndAdaptSection(parentElement, section);
2603
        return section;
2604
    }
2605

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

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

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

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

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

    
2636
    public CreditSection createCreditSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2637
        CreditSection section = new CreditSection(this, conversation, parentElement, style);
2638
        addAndAdaptSection(parentElement, section);
2639
        return section;
2640
    }
2641
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2642
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2643
        addAndAdaptSection(parentElement, section);
2644
        return section;
2645
    }
2646
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, Reference defaultSource, int style){
2647
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, defaultSource, style);
2648
        addAndAdaptSection(parentElement, section);
2649
        return section;
2650
    }
2651

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

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

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

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

    
2676
    public MediaRepresentationSection createMediaRepresentationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2677
        MediaRepresentationSection section = new MediaRepresentationSection(this, conversation, parentElement, style);
2678
        addAndAdaptSection(parentElement, section);
2679
        return section;
2680
    }
2681

    
2682
    public MediaRepresentationPartSection createMediaRepresentationPartSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2683
        MediaRepresentationPartSection section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
2684
        addAndAdaptSection(parentElement, section);
2685
        return section;
2686
    }
2687

    
2688
    public ModifierSection createModifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2689
        ModifierSection section = new ModifierSection(this, conversation, parentElement, style);
2690
        addAndAdaptSection(parentElement, section);
2691
        return section;
2692
    }
2693

    
2694
    public NomenclaturalStatusSection createNomenclaturalStatusSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2695
        NomenclaturalStatusSection section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
2696
        addAndAdaptSection(parentElement, section);
2697
        return section;
2698
    }
2699

    
2700
    public NameRelationshipDetailSection createNameRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2701
        NameRelationshipDetailSection section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
2702
        addAndAdaptSection(parentElement, section);
2703
        return section;
2704
    }
2705

    
2706
//    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2707
//        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2708
//        addAndAdaptSection(parentElement, section);
2709
//        return section;
2710
//    }
2711
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2712
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, style);
2713
        addAndAdaptSection(parentElement, section);
2714
        return section;
2715
    }
2716

    
2717
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, String label, int style){
2718
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, true, label, style);
2719
        addAndAdaptSection(parentElement, section);
2720
        return section;
2721
    }
2722

    
2723
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, String label, boolean isWithTypeAndDesc, int style){
2724
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, isWithTypeAndDesc, label, style);
2725
        addAndAdaptSection(parentElement, section);
2726
        return section;
2727
    }
2728

    
2729
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2730
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2731

    
2732
        addAndAdaptSection(parentElement, section);
2733
        return section;
2734
    }
2735

    
2736
    public SourceSection createSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2737
        SourceSection section = new SourceSection(this, conversation, parentElement, style);
2738
        addAndAdaptSection(parentElement, section);
2739
        return section;
2740
    }
2741

    
2742
    public ScopeSection createScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2743
        ScopeSection section = new ScopeSection(this, conversation, parentElement, style);
2744
        addAndAdaptSection(parentElement, section);
2745
        return section;
2746
    }
2747

    
2748
    public DescriptionSourceSection createDescriptionSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2749
        DescriptionSourceSection section = new DescriptionSourceSection(this, conversation, parentElement, style);
2750
        addAndAdaptSection(parentElement, section);
2751
        return section;
2752
    }
2753

    
2754
    public TypeDesignationSection createTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2755
        TypeDesignationSection section = new TypeDesignationSection(this, conversation, parentElement, style);
2756
        addAndAdaptSection(parentElement, section);
2757
        return section;
2758
    }
2759

    
2760
    public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2761
        StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
2762
        addAndAdaptSection(parentElement, section);
2763
        return section;
2764
    }
2765

    
2766
    public StatisticalMeasurementValueSection createStatisticalMeasurementValueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2767
        StatisticalMeasurementValueSection section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
2768
        addAndAdaptSection(parentElement, section);
2769
        return section;
2770
    }
2771

    
2772
    public DescribedSpecimenSection createDescribedSpecimenSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2773
        DescribedSpecimenSection section = new DescribedSpecimenSection(this, conversation, parentElement, style);
2774
        addAndAdaptSection(parentElement, section);
2775
        return section;
2776
    }
2777

    
2778
    public StateVocabularyCollectionSection createStateVocabulariesSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2779
        StateVocabularyCollectionSection section = new StateVocabularyCollectionSection(this, conversation, parentElement, style);
2780
        addAndAdaptSection(parentElement, section);
2781
        return section;
2782
    }
2783

    
2784
    public StateVocabularyDtoCollectionSection createStateVocabulariesDtoSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2785
        StateVocabularyDtoCollectionSection section = new StateVocabularyDtoCollectionSection(this, conversation, parentElement, style);
2786
        addAndAdaptSection(parentElement, section);
2787
        return section;
2788
    }
2789

    
2790
    public RecommendedModifierVocabulariesCollectionSection createRecommendedModifierVocabulariesCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2791
        RecommendedModifierVocabulariesCollectionSection section = new RecommendedModifierVocabulariesCollectionSection(this, conversation, parentElement, style);
2792
        addAndAdaptSection(parentElement, section);
2793
        return section;
2794
    }
2795
    public RecommendedModifierVocabulariesDtoCollectionSection createRecommendedModifierVocabulariesDtoCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2796
        RecommendedModifierVocabulariesDtoCollectionSection section = new RecommendedModifierVocabulariesDtoCollectionSection(this, conversation, parentElement, style);
2797
        addAndAdaptSection(parentElement, section);
2798
        return section;
2799
    }
2800

    
2801
    public MeasurementUnitCollectionSection createMeasurementUnitCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2802
        MeasurementUnitCollectionSection section = new MeasurementUnitCollectionSection(this, conversation, parentElement, style);
2803
        addAndAdaptSection(parentElement, section);
2804
        return section;
2805
    }
2806

    
2807
    public MeasurementUnitDtoCollectionSection createMeasurementUnitDtoCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2808
        MeasurementUnitDtoCollectionSection section = new MeasurementUnitDtoCollectionSection(this, conversation, parentElement, style);
2809
        addAndAdaptSection(parentElement, section);
2810
        return section;
2811
    }
2812
    public StatisticalMeasureCollectionSection createStatisticalMeasureCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2813
        StatisticalMeasureCollectionSection section = new StatisticalMeasureCollectionSection(this, conversation, parentElement, style);
2814
        addAndAdaptSection(parentElement, section);
2815
        return section;
2816
    }
2817

    
2818
    public StatisticalMeasureDtoCollectionSection createStatisticalMeasureDtoCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2819
        StatisticalMeasureDtoCollectionSection section = new StatisticalMeasureDtoCollectionSection(this, conversation, parentElement, style);
2820
        addAndAdaptSection(parentElement, section);
2821
        return section;
2822
    }
2823

    
2824
    public CollectingAreasDetailSection createCollectingAreasDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2825
        CollectingAreasDetailSection section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
2826
        addAndAdaptSection(parentElement, section);
2827
        return section;
2828
    }
2829

    
2830
    public GeoScopeDetailSection createGeoScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2831
        GeoScopeDetailSection section = new GeoScopeDetailSection(this, conversation, parentElement, style);
2832
        addAndAdaptSection(parentElement, section);
2833
        return section;
2834
    }
2835

    
2836
    public GeoScopePolyKeyDetailSection createGeoScopePolyKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2837
        GeoScopePolyKeyDetailSection section = new GeoScopePolyKeyDetailSection(this, conversation, parentElement, style);
2838
        addAndAdaptSection(parentElement, section);
2839
        return section;
2840
    }
2841

    
2842
    public IdentifierSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2843
        IdentifierSection section = new IdentifierSection(this, conversation, parentElement, style);
2844
        addAndAdaptSection(parentElement, section);
2845
        return section;
2846
    }
2847

    
2848
    public DerivedUnitFacadeIdentifierSection createDerivedUnitFacadeIdentifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2849
    	DerivedUnitFacadeIdentifierSection section = new DerivedUnitFacadeIdentifierSection(this, conversation, parentElement, style);
2850
    	addAndAdaptSection(parentElement, section);
2851
    	return section;
2852
    }
2853

    
2854
    public CurrentSampleDesignationDetailSection createCurrentSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2855
        CurrentSampleDesignationDetailSection section = new CurrentSampleDesignationDetailSection(this, conversation, parentElement, style);
2856
        addAndAdaptSection(parentElement, section);
2857
        return section;
2858
    }
2859

    
2860
    public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2861
        CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
2862
        addAndAdaptSection(parentElement, section);
2863
        return section;
2864
    }
2865

    
2866
    public PreservedSpecimenCurrentDeterminationDetailSection createPreservedSpecimenCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2867
        PreservedSpecimenCurrentDeterminationDetailSection section = new PreservedSpecimenCurrentDeterminationDetailSection(this, conversation, parentElement, style);
2868
        addAndAdaptSection(parentElement, section);
2869
        return section;
2870
    }
2871

    
2872
    public SampleDesignationHistoryDetailSection createSampleDesignationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2873
        SampleDesignationHistoryDetailSection section = new SampleDesignationHistoryDetailSection(this, conversation, parentElement, style);
2874
        addAndAdaptSection(parentElement, section);
2875
        return section;
2876
    }
2877

    
2878
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2879
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
2880
        addAndAdaptSection(parentElement, section);
2881
        return section;
2882
    }
2883

    
2884
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2885
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
2886
        addAndAdaptSection(parentElement, section);
2887
        return section;
2888
    }
2889

    
2890
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2891
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2892
        addAndAdaptSection(parentElement, section);
2893
        return section;
2894
    }
2895

    
2896
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2897
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2898
        addAndAdaptSection(parentElement, section);
2899
        return section;
2900
    }
2901

    
2902
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2903
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2904
        addAndAdaptSection(parentElement, section);
2905
        return section;
2906
    }
2907

    
2908
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2909
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2910
        addAndAdaptSection(parentElement, section);
2911
        return section;
2912
    }
2913

    
2914
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2915
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2916
        addAndAdaptSection(parentElement, section);
2917
        return section;
2918
    }
2919

    
2920
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2921
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2922
        addAndAdaptSection(parentElement, section);
2923
        return section;
2924
    }
2925

    
2926
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2927
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2928
        addAndAdaptSection(parentElement, section);
2929
        return section;
2930
    }
2931

    
2932
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2933
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2934
        AbstractEntityCollectionElement<?> element = null;
2935

    
2936
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2937

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

    
3016
            }
3017
        } else if (entity instanceof Reference) {
3018
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
3019
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
3020
            }
3021
            else{
3022
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
3023
            }
3024
        } else if (entity instanceof NameTypeDesignation) {
3025
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
3026
                    style);
3027
        } else if (entity instanceof TextualTypeDesignation) {
3028
            element = new TextTypeDesignationElement(this, parentElement, (TextualTypeDesignation) entity, removeListener,
3029
                    style);
3030
        } else if (entity instanceof NameRelationship) {
3031
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
3032
                    style);
3033
        } else if (entity instanceof SpecimenTypeDesignation) {
3034
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
3035
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
3036
                        removeListener, style);
3037
            }
3038
            else{
3039
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
3040
                        removeListener, style);
3041
            }
3042
        } else if (entity instanceof StateData) {
3043
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
3044
        } else if (entity instanceof StatisticalMeasurementValue) {
3045
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
3046
                    removeListener, style);
3047
        } else if (entity instanceof DerivedUnit) {
3048
            switch(((DerivedUnit)entity).getRecordBasis()) {
3049
            case LivingSpecimen:
3050
            case PreservedSpecimen:
3051
            case OtherSpecimen:
3052
                element = new SpecimenCollectionDetailElement(this,
3053
                        parentElement,
3054
                        (DerivedUnit) entity,
3055
                        removeListener,
3056
                        style);
3057
                break;
3058
            default:
3059
                element = new DerivedUnitElement(this,
3060
                        parentElement,
3061
                        (DerivedUnit) entity,
3062
                        removeListener,
3063
                        style);
3064
            }
3065

    
3066
        } else if (entity instanceof NamedArea) {
3067
            element = new CollectingAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
3068
        } else if (entity instanceof DeterminationEvent) {
3069
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
3070
        } else if (entity instanceof User) {
3071
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
3072
        } else if (entity instanceof GrantedAuthority) {
3073
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
3074
                    removeListener, style);
3075
        } else if (entity instanceof Group) {
3076
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
3077
        } else if (entity instanceof Taxon) {
3078
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
3079
        } else if (entity instanceof DescriptionElementBase) {
3080
            // this is the special case for protologs, maybe we can do this
3081
            // differently when API improves
3082
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
3083
//            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
3084
//                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
3085
//            }
3086
        } else if (entity instanceof Identifier) {
3087
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
3088
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
3089
            }
3090
            else{
3091
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
3092
            }
3093
        } else if (entity instanceof TermVocabulary) {
3094
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
3095
            switch (termVocabulary.getTermType()) {
3096
            case State:
3097
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
3098
                break;
3099
            case Modifier:
3100
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
3101
                break;
3102
            default:
3103
                break;
3104
            }
3105
        }else if (entity instanceof TermVocabularyDto) {
3106
            TermVocabularyDto termVocabulary = (TermVocabularyDto)entity;
3107
            switch (termVocabulary.getTermType()) {
3108
            case State:
3109
                element = new StateVocabularyDtoCollectionElement(this, parentElement, termVocabulary, removeListener, backgroundColor, style);
3110
                break;
3111
            case Modifier:
3112
                element = new RecommendedModifierDtoVocabulariesElement(this, parentElement, termVocabulary, removeListener, backgroundColor, style);
3113
                break;
3114
            default:
3115
                break;
3116
            }
3117
        }else if (entity instanceof MeasurementUnit) {
3118
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
3119
        }else if (entity instanceof TermDto) {
3120
            if(((TermDto)entity).getTermType().equals(TermType.MeasurementUnit)){
3121
                element = new MeasurementUnitDtoCollectionElement(this, parentElement, (TermDto) entity, removeListener, backgroundColor, style);
3122
            }else if (((TermDto)entity).getTermType().equals(TermType.StatisticalMeasure)){
3123
                element = new StatisticalMeasureDtoCollectionElement(this, parentElement, (TermDto) entity, removeListener, backgroundColor, style);
3124
            }
3125
        }else if (entity instanceof StatisticalMeasure) {
3126
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
3127
        } else if (entity instanceof FeatureState && parentElement instanceof InapplicableIfEntityCollectionSection) {
3128
            element = new InapplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
3129
        } else if (entity instanceof FeatureState && parentElement instanceof OnlyApplicableIfEntityCollectionSection) {
3130
            element = new OnlyApplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
3131
        }
3132

    
3133
        //check for parent section when entity is null
3134
        //this happens when AbstractUnboundEntityCollectionSection is used
3135
        if(element==null){
3136
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
3137
                element = new ScopeElement(this,
3138
                        parentElement,
3139
                        (DefinedTerm) entity,
3140
                        removeListener,
3141
                        style);
3142
            }
3143
            else if(parentElement instanceof ModifierSection){
3144
                element = new ModifierElement(this,
3145
                        parentElement,
3146
                        (DefinedTerm) entity,
3147
                        removeListener,
3148
                        style);
3149
            }
3150
        }
3151

    
3152

    
3153
        if (element == null) {
3154
            MessagingUtils.messageDialog(
3155
                    String.format("Error when creating section %s",
3156
                            parentElement.getClass().getSimpleName()),
3157
                    this,
3158
                    String.format("Could not generate collection element for entity of class %s."
3159
                            + " Looks like the case is not yet handled. Check implementation.\n"
3160
                            + "Entity: %s", entity.getClass(), entity.toString()), null);
3161
        }
3162

    
3163
        else{
3164
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
3165
                element.setPersistentBackground(backgroundColor);
3166
            }
3167
            adapt(element);
3168
            parentElement.addElement(element);
3169
        }
3170

    
3171
        return element;
3172
    }
3173

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

    
3217
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3218
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3219
            int style, boolean filterElement) {
3220
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
3221
                parentElement, clazz,
3222
                labelString, selection, mode, style, filterElement);
3223
        adapt(element);
3224
        parentElement.addElement(element);
3225
        return element;
3226
    }
3227

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

    
3240
    public CommonNameReferenceSelectionElement createCommonNameReferenceSelectionElement(ICdmFormElement parentElement, String labelString, Reference selection, int mode,
3241
          int style) {
3242
        CommonNameReferenceSelectionElement element = new CommonNameReferenceSelectionElement(this,
3243
              parentElement, labelString, selection, mode, style);
3244
      adapt(element);
3245
      parentElement.addElement(element);
3246
      return element;
3247
  }
3248

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

    
3292
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3293
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
3294
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this,
3295
                parentElement,
3296
                labelString, selection, mode, style, null);
3297
        adapt(element);
3298
        parentElement.addElement(element);
3299
        return element;
3300
    }
3301
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3302
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style, Integer limit) {
3303
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
3304
                parentElement,
3305
                labelString, selection, mode, style, limit);
3306
        adapt(element);
3307
        parentElement.addElement(element);
3308
        return element;
3309
    }
3310

    
3311

    
3312
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
3313
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
3314
//            int mode, int style) {
3315
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
3316
//                conversation, parentElement, labelString, selection, mode, style);
3317
//        adapt(element);
3318
//        parentElement.addElement(element);
3319
//        return element;
3320
//    }
3321

    
3322
    /** {@inheritDoc} */
3323
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
3324
        LabelElement labelElement = new LabelElement(this, parentElement, text);
3325
        adapt(labelElement);
3326
        parentElement.addElement(labelElement);
3327
        return labelElement;
3328
    }
3329

    
3330

    
3331

    
3332
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
3333
//        Label label = new Label(formElement.getLayoutComposite(), style);
3334
//        label.setText(labelText+" (yyyy-MM-dd)");
3335
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
3336
//        dateElement.initInternalController();
3337
//
3338
//        return dateElement;
3339
//    }
3340

    
3341
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
3342
    	 Label label = new Label(formElement.getLayoutComposite(), style);
3343
         label.setText(labelText);
3344
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3345
         DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
3346
         dateElement.initController(this, formElement);
3347
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3348
         return dateElement;
3349
    }
3350

    
3351
    /**
3352
     * <p>
3353
     * Getter for the field <code>selectionProvider</code>.
3354
     * </p>
3355
     *
3356
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
3357
     */
3358
    public ISelectionProvider getSelectionProvider() {
3359
        return selectionProvider;
3360
    }
3361

    
3362
    /**
3363
     * <p>
3364
     * createDetailedDescriptionDetailElement
3365
     * </p>
3366
     *
3367
     * @param parentElement
3368
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3369
     *            object.
3370
     * @param entity
3371
     *            a
3372
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
3373
     *            object.
3374
     * @param style
3375
     *            a int.
3376
     * @return a
3377
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
3378
     *         object.
3379
     */
3380
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
3381
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
3382
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
3383

    
3384
        if (entity instanceof CategoricalData) {
3385
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
3386
                    (CategoricalData) entity, style);
3387
        } else if (entity instanceof CommonTaxonName) {
3388
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
3389
                    style);
3390
        } else if (entity instanceof Distribution && !enabled) {
3391
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3392
                    enabled, style);
3393
        } else if (entity instanceof Distribution) {
3394
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3395
                    true, style);
3396
        }else if (entity instanceof IndividualsAssociation) {
3397
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
3398
                    (IndividualsAssociation) entity, style);
3399
        } else if (entity instanceof QuantitativeData) {
3400
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
3401
                    (QuantitativeData) entity, style);
3402
        } else if (entity instanceof TaxonInteraction) {
3403
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
3404
                    (TaxonInteraction) entity, style);
3405
        } else if (entity instanceof TemporalData) {
3406
            detailedDescriptionElement = new TemporalDataDetailElement(this, parentElement, (TemporalData) entity, style);
3407
        } else if (entity instanceof TextData) {
3408
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
3409
        }
3410
        else {
3411
            throw new IllegalStateException("There is no interface for the given description element");
3412
        }
3413
        adapt(detailedDescriptionElement);
3414
        parentElement.addElement(detailedDescriptionElement);
3415
        return detailedDescriptionElement;
3416

    
3417
    }
3418

    
3419
    /**
3420
     * Creates a styled text as a part of the form.
3421
     *
3422
     * @param parent
3423
     *            the text parent
3424
     * @param value
3425
     *            the text initial value
3426
     * @param style
3427
     *            the text style
3428
     * @return the text widget
3429
     */
3430
    public StyledText createStyledText(Composite parent, String value, int style) {
3431
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3432
        if (value != null) {
3433
            text.setText(value);
3434
        }
3435
        text.setForeground(getColors().getForeground());
3436
        text.setBackground(getColors().getBackground());
3437
        // text.addFocusListener(visibilityHandler);
3438
        return text;
3439
    }
3440

    
3441
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3442
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3443
        addAndAdaptSection(parentElement, section);
3444
        return section;
3445
    }
3446

    
3447
    /**
3448
     * @param formElement
3449
     * @param conversationHolder
3450
     * @param style
3451
     * @return
3452
     */
3453
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3454
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3455
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3456
        addAndAdaptSection(formElement, section);
3457
        return section;
3458
    }
3459

    
3460

    
3461
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3462
			ICdmFormElement parentElement, int style) {
3463
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3464
		addAndAdaptElement(parentElement, section);
3465
        return section;
3466
	}
3467

    
3468
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3469
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3470
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3471
	        addAndAdaptSection(formElement, section);
3472
	        return section;
3473
	}
3474

    
3475

    
3476
    /**
3477
     * <p>
3478
     * createTextWithLabelElement
3479
     * </p>
3480
     *
3481
     * @param parentElement
3482
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3483
     *            object.
3484
     * @param labelString
3485
     *            a {@link java.lang.String} object.
3486
     * @param initialText
3487
     *            a {@link java.lang.String} object.
3488
     * @param textLimit maximal number of characters allowed
3489
     * @param style
3490
     *            a int.
3491
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
3492
     *         object.
3493
     */
3494
    public RuleConsideredElement createRuleConsideredElement(ICdmFormElement parentElement, String labelString, boolean isShowCodeEdition, int style) {
3495
        RuleConsideredElement element = new RuleConsideredElement(this, parentElement, labelString, isShowCodeEdition, style);
3496
        adapt(element);
3497
        parentElement.addElement(element);
3498
        return element;
3499
    }
3500

    
3501
    /**
3502
     * @param class1
3503
     * @param formElement
3504
     * @param string
3505
     * @param area
3506
     * @param nothing
3507
     * @param style
3508
     * @return
3509
     */
3510
    public EntitySelectionElementWithIdInVocabulary createSelectionElementWithIdInVocabulary(Class<NamedArea> clazz,
3511
            ICdmFormElement formElement, String labelString, NamedArea area, int mode, int style) {
3512
        EntitySelectionElementWithIdInVocabulary element = new EntitySelectionElementWithIdInVocabulary(this,
3513
                formElement, clazz, labelString, area, mode, style);
3514
        adapt(element);
3515
        formElement.addElement(element);
3516
        return element;
3517
    }
3518

    
3519
    /**
3520
     * @param extendedTimePeriodElement
3521
     * @param twistie
3522
     * @return
3523
     */
3524
    public ExtendedTimeDetailSection createExtendedTimeDetailSection(
3525
            ExtendedTimePeriodElement parentElement, int style) {
3526
        ExtendedTimeDetailSection section = new ExtendedTimeDetailSection(this, parentElement,  style);
3527
        parentElement.addElement(section);
3528
        adapt(section);
3529
        return section;
3530
    }
3531
    public ExtendedTimePeriodElement createExtendedTimePeriodElement(
3532
            ICdmFormElement parentElement, String labelString, ExtendedTimePeriod timePeriod, int style) {
3533
        ExtendedTimePeriodElement section = new ExtendedTimePeriodElement(this, parentElement, labelString, timePeriod, style);
3534
        parentElement.addElement(section);
3535
        adapt(section);
3536
        return section;
3537
    }
3538

    
3539

    
3540

    
3541

    
3542
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3543
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3544
//				 initialText, textHeight, style);
3545
//	        adapt(element);
3546
//	        parentElement.addElement(element);
3547
//	        return element;
3548
//	}
3549

    
3550

    
3551

    
3552

    
3553

    
3554

    
3555

    
3556
}
(11-11/56)