Project

General

Profile

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

    
422
/**
423
 * CdmFormFactory class.
424
 *
425
 * @author n.hoffmann
426
 * @created Feb 24, 2010
427
 */
428
public class CdmFormFactory extends FormToolkit {
429

    
430
    private BoldFontHolder2 boldFontHolder2;
431
    private MouseListener selectionMouseHandler;
432
    private FocusListener selectionFocusHandler;
433

    
434
    @Inject
435
    private IEclipseContext context;
436

    
437
    private final Set<SelectionListener> selectionListenerList = new HashSet<>();
438

    
439
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<>();
440

    
441
    private final int orientation = Window.getDefaultOrientation();
442
    private ISelectionProvider selectionProvider;
443

    
444
    /** Constant <code>EMPTY_SELECTION</code> */
445
    public static ISelection EMPTY_SELECTION = new ISelection() {
446
        @Override
447
        public boolean isEmpty() {
448
            return true;
449
        }
450
    };
451

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

    
463
    /**
464
     * @author n.hoffmann
465
     * @date Jan 25, 2010
466
     */
467
    private class SelectionFocusHandler extends FocusAdapter {
468
        @Override
469
        public void focusGained(FocusEvent e) {
470
            notifySelectionListeners(e);
471
        }
472
    }
473

    
474
    private void notifySelectionListeners(TypedEvent e) {
475
        Event event = new Event();
476
        event.widget = e.widget;
477
        SelectionEvent selectionEvent = new SelectionEvent(event);
478

    
479
        for (SelectionListener listener : selectionListenerList) {
480
            listener.widgetSelected(selectionEvent);
481
        }
482
    }
483

    
484
    public CdmFormFactory(Display display) {
485
        this(display, null);
486
    }
487

    
488
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
489
        super(display);
490
        this.selectionProvider = selectionProvider;
491
        init();
492
    }
493

    
494
    private void init() {
495
        boldFontHolder2 = new BoldFontHolder2();
496
        selectionMouseHandler = new SelectionMouseHandler();
497
        selectionFocusHandler = new SelectionFocusHandler();
498
    }
499

    
500
    public IEclipseContext getContext() {
501
        return context;
502
    }
503

    
504
    /**
505
     * Creates an instance initialized with the correct selectionProvider
506
     *
507
     * Make sure to remove the instance when the entityComposite disposes via
508
     * destroySelectionArbitrator(..)
509
     *
510
     * @param entityElement
511
     *            a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
512
     *            object.
513
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
514
     *         object.
515
     */
516
    public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
517
        SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
518
        selectionArbitrator.addSelectionProvider(selectionProvider);
519
        selectionProvider.addSelectionChangedListener(selectionArbitrator);
520
        addSelectionListener(selectionArbitrator);
521
        return selectionArbitrator;
522
    }
523

    
524
    /**
525
     * <p>
526
     * destroySelectionArbitrator
527
     * </p>
528
     *
529
     * @param selectionArbitrator
530
     *            a
531
     *            {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
532
     *            object.
533
     */
534
    public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
535
        if(selectionArbitrator==null){
536
            return;
537
        }
538
        removeSelectionListener(selectionArbitrator);
539
        if (selectionProvider != null) {
540
            selectionProvider.removeSelectionChangedListener(selectionArbitrator);
541
        } else {
542
            MessagingUtils.error(this.getClass(),
543
                    "Tried to destroy a selection listener from this factories listeners but was null", null);
544
        }
545
    }
546

    
547
    /**
548
     * <p>
549
     * Adapts the {@link AbstractCdmFormElement}:<br>
550
     * - sets the {@link IPropertyChangeListener}s handled by this class
551
     * </p>
552
     *
553
     * @param formElement
554
     *            a
555
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
556
     *            object.
557
     */
558
    public void adapt(ICdmFormElement formElement) {
559
        formElement.setPropertyChangeListeners(propertyChangeListeners);
560
    }
561

    
562
    @Override
563
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
564
        if (trackFocus) {
565
            control.addFocusListener(selectionFocusHandler);
566
        }
567
        super.adapt(control, trackFocus, trackKeyboard);
568
    }
569

    
570
    @Override
571
    public void adapt(Composite composite) {
572
        composite.addMouseListener(selectionMouseHandler);
573

    
574
        super.adapt(composite);
575
    }
576

    
577
    /**
578
     * destroyElement
579
     *
580
     * @param formElement
581
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
582
     *            object.
583
     */
584
    public void destroyElement(ICdmFormElement formElement) {
585
        // return if element was not initialized
586
        if (formElement == null) {
587
            return;
588
        }
589
        // destroy selection arbitrator, if any
590
        if (formElement instanceof ISelectableElement) {
591
            destroySelectionArbitrator(((ISelectableElement) formElement).getSelectionArbitrator());
592
        }
593
        // remove this element form its parents list of elements
594
        // ICdmFormElement parentElement = formElement.getParentElement();
595
        // if(parentElement != null){
596
        // parentElement.removeElement(formElement);
597
        // }
598
        // call destroy on child elements recursively
599

    
600
        Set<ICdmFormElement> tempFormElements = new HashSet<>();
601
        tempFormElements.addAll(formElement.getElements());
602
        for(ICdmFormElement childElement: tempFormElements) {
603
            destroyElement(childElement);
604
        }
605
        // dispose of the controls
606
        for (Control control : formElement.getControls()) {
607
            // we added the layoutComposite of the parental element as the
608
            // layout composite to this formElement
609
            // but we do not want to destroy it.
610
            if (control.equals(formElement.getLayoutComposite())) {
611
                continue;
612
            } else {
613
                if (!control.isDisposed()){
614
                    control.dispose();
615
                }
616
                control = null; //needed?
617
            }
618
        }
619
    }
620

    
621
    /**
622
     * createEmptyCell
623
     *
624
     * @param parent
625
     *            a {@link org.eclipse.swt.widgets.Composite} object.
626
     * @return a {@link org.eclipse.swt.widgets.Label} object.
627
     */
628
    public Label createEmptyCell(Composite parent) {
629
        return this.createLabel(parent, null);
630
    }
631

    
632
    /**
633
     * createMultiLanguageTextElement
634
     *
635
     * @param parentElement
636
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
637
     *            object.
638
     * @param labelString
639
     *            a {@link java.lang.String} object.
640
     * @param multilanguageText
641
     *            a {@link java.util.Map} object.
642
     * @param textHeight
643
     *            a int.
644
     * @param style
645
     *            a int.
646
     * @return a
647
     *         {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
648
     *         object.
649
     */
650
    public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
651
            Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
652
        MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
653
                multilanguageText, textHeight, style);
654
        adapt(element);
655
        parentElement.addElement(element);
656
        return element;
657
    }
658

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

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

    
707
    public TranslatableRepresentationElement createTranslatableRepresentationElementDto(ICdmFormElement parentElement, Representation representation, TermDto term,int textHeight, int style, boolean fillDetails) {
708
        TranslatableRepresentationElement element = new TranslatableRepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
709
        adapt(element);
710
        parentElement.addElement(element);
711
        return element;
712
    }
713

    
714

    
715
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
716
            KeyStatement keyStatement, int textHeight, int style) {
717
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
718
                textHeight, style);
719
        adapt(element);
720
        parentElement.addElement(element);
721
        return element;
722
    }
723

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

    
739
    /**
740
     * <p>
741
     * createTextWithLabelElement
742
     * </p>
743
     *
744
     * @param parentElement
745
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
746
     *            object.
747
     * @param labelString
748
     *            a {@link java.lang.String} object.
749
     * @param initialText
750
     *            a {@link java.lang.String} object.
751
     * @param style
752
     *            a int.
753
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
754
     *         object.
755
     */
756
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
757
            String initialText, int style) {
758
        return createTextWithLabelElement(parentElement, labelString, initialText, null, style);
759
    }
760

    
761
    /**
762
     * createTextWithLabelElement
763
     *
764
     * @param parentElement
765
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
766
     *            object.
767
     * @param labelString
768
     *            a {@link java.lang.String} object.
769
     * @param initialText
770
     *            a {@link java.lang.String} object.
771
     * @param textLimit maximal number of characters allowed
772
     * @param style
773
     *            a int.
774
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
775
     *         object.
776
     */
777
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
778
            String initialText, Integer textLimit, int style) {
779
        if(initialText==null){
780
            initialText = "";
781
        }
782

    
783
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
784
                textLimit, style);
785
        adapt(element);
786
        parentElement.addElement(element);
787
        return element;
788
    }
789

    
790
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
791
            int textHeight, int style) {
792
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
793
        adapt(element);
794
        parentElement.addElement(element);
795
        return element;
796
    }
797

    
798
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
799
            LSID initialLsid, int style) {
800
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
801
        adapt(element);
802
        parentElement.addElement(element);
803
        return element;
804
    }
805

    
806
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
807
            URI initialUri, int style) {
808
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
809
        adapt(element);
810
        parentElement.addElement(element);
811
        return element;
812
    }
813
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
814
            URI initialUri,Integer textHeight, int style) {
815
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, textHeight, style);
816
        adapt(element);
817
        parentElement.addElement(element);
818
        return element;
819
    }
820

    
821

    
822
    public DoiWithLabelElement createDoiWithLabelElement(ICdmFormElement parentElement, String labelString,
823
            DOI initialDoi, int style) {
824
        DoiWithLabelElement element = new DoiWithLabelElement(this, parentElement, labelString, initialDoi, null, style);
825
        adapt(element);
826
        parentElement.addElement(element);
827
        return element;
828
    }
829
    public DoiWithLabelElement createDoiWithLabelElement(ICdmFormElement parentElement, String labelString,
830
            DOI initialDoi,Integer textHeight, int style) {
831
        DoiWithLabelElement element = new DoiWithLabelElement(this, parentElement, labelString, initialDoi, textHeight, style);
832
        adapt(element);
833
        parentElement.addElement(element);
834
        return element;
835
    }
836

    
837
    public OrcidWithLabelElement createOrcidWithLabelElement(ICdmFormElement parentElement, String labelString,
838
            ORCID initialDoi, int style) {
839
        OrcidWithLabelElement element = new OrcidWithLabelElement(this, parentElement, labelString, initialDoi, null, style);
840
        adapt(element);
841
        parentElement.addElement(element);
842
        return element;
843
    }
844
    public OrcidWithLabelElement createDoiWithLabelElement(ICdmFormElement parentElement, String labelString,
845
            ORCID initialDoi,Integer textHeight, int style) {
846
        OrcidWithLabelElement element = new OrcidWithLabelElement(this, parentElement, labelString, initialDoi, textHeight, style);
847
        adapt(element);
848
        parentElement.addElement(element);
849
        return element;
850
    }
851

    
852
    /**
853
     * @param element
854
     * @param string
855
     * @param uri
856
     * @param style
857
     * @return
858
     */
859
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
860
            IOpenUrlEnabled openUrlEnabled, int style) {
861
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
862
                style);
863
        adapt(element);
864
        parentElement.addElement(element);
865
        return element;
866
    }
867

    
868
    /**
869
     *
870
     * @param parentElement
871
     * @param labelString
872
     * @param conversationEnabled
873
     * @param user
874
     * @param style
875
     * @return
876
     */
877
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
878
            ConversationHolder conversation, User user, int style) {
879
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
880
        adapt(element);
881
        parentElement.addElement(element);
882
        return element;
883
    }
884

    
885
    /**
886
     * <p>
887
     * createIntegerTextWithLabelElement
888
     * </p>
889
     *
890
     * @param parentElement
891
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
892
     *            object.
893
     * @param labelString
894
     *            a {@link java.lang.String} object.
895
     * @param initialInteger
896
     *            a {@link java.lang.Integer} object.
897
     * @param style
898
     *            a int.
899
     * @return a
900
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
901
     *         object.
902
     */
903
	public FloatWithLabelElement createFloatTextWithLabelElement(
904
			ICdmFormElement parentElement, String labelString,
905
			Number initialNumber, int style) {
906
		FloatWithLabelElement element = new FloatWithLabelElement(this,
907
				parentElement, labelString, initialNumber, style);
908
		adapt(element);
909
		parentElement.addElement(element);
910
		return element;
911
	}
912

    
913
	public BigDecimalWithLabelElement createBigDecimalTextWithLabelElement(
914
            ICdmFormElement parentElement, String labelString,
915
            Number initialNumber, int style) {
916
	    BigDecimalWithLabelElement element = new BigDecimalWithLabelElement(this,
917
                parentElement, labelString, initialNumber, style);
918
        adapt(element);
919
        parentElement.addElement(element);
920
        return element;
921
    }
922

    
923
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
924
            String labelString, LanguageString languageString, int style) {
925
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
926
    }
927

    
928
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
929
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
930
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
931
                languageString, height, isMultiLine, style);
932
        adapt(element);
933
        parentElement.addElement(element);
934
        return element;
935
    }
936

    
937
    /**
938
     * <p>
939
     * createKeyValueViewerElement
940
     * </p>
941
     *
942
     * @param parentElement
943
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
944
     *            object.
945
     * @param keyHeading
946
     *            a {@link java.lang.String} object.
947
     * @param valueHeading
948
     *            a {@link java.lang.String} object.
949
     * @param map
950
     *            a {@link java.util.Map} object.
951
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
952
     *         object.
953
     */
954
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
955
            String valueHeading, Map<Object, Object> map) {
956
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
957
        adapt(element);
958
        parentElement.addElement(element);
959
        return element;
960
    }
961

    
962
    /**
963
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
964
     */
965
    @Deprecated
966
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
967
            ICdmFormElement parentElement, String labelString, T selection, int style) {
968
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString, selection, true, style);
969
        adapt(element);
970
        parentElement.addElement(element);
971
        return element;
972
    }
973

    
974
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
975
            TermType termType,
976
            ICdmFormElement parentElement,
977
            String labelString,
978
            T selection,
979
            int style,
980
            Comparator<T> comparator) {
981
        return this.createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, true, style, false, comparator);
982
    }
983
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
984
            List<T> terms,
985
            ICdmFormElement parentElement,
986
            String labelString,
987
            T selection,
988
            int style,
989
            Comparator<T> comparator) {
990
        return this.createDefinedTermComboElement(null, null, terms, parentElement, labelString, selection, true, style, false, comparator);
991
    }
992

    
993
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
994
			TermType termType,
995
			ICdmFormElement parentElement,
996
			String labelString,
997
			T selection,
998
			boolean addEmptyElement,
999
			int style) {
1000
        return this.createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, addEmptyElement, style, false, null);
1001
	}
1002

    
1003
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1004
			TermType termType,
1005
			ICdmFormElement parentElement,
1006
			String labelString,
1007
			T selection,
1008
			int style) {
1009
		return  this.createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, true, style, false, null);
1010
	}
1011
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElementDto(
1012
            TermType termType,
1013
            ICdmFormElement parentElement,
1014
            String labelString,
1015
            TermDto selection,
1016
            int style) {
1017
        return  this.createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, true, style, false, null);
1018
    }
1019

    
1020
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1021
            List<T> terms,
1022
            ICdmFormElement parentElement,
1023
            String labelString,
1024
            T selection,
1025
            int style) {
1026
        return  this.createDefinedTermComboElement(null, null, terms, parentElement, labelString, selection, true, style, false, null);
1027
    }
1028

    
1029
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1030
	        List<T> terms,
1031
	        ICdmFormElement parentElement,
1032
	        String labelString,
1033
	        T selection,
1034
	        boolean addEmptyElement,
1035
	        int style) {
1036
	    return  this.createDefinedTermComboElement(null, null, terms, parentElement, labelString, selection, addEmptyElement, style, false, null);
1037
	}
1038

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

    
1050

    
1051
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1052
            TermVocabulary<?> termVocabulary,
1053
            ICdmFormElement parentElement,
1054
            String labelString,
1055
            T selection,
1056
            int style) {
1057
        return this.createDefinedTermComboElement(null, termVocabulary, null, parentElement, labelString, selection, true, style, false, null);
1058
    }
1059

    
1060
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1061
	        TermVocabulary<?> termVocabulary,
1062
	        ICdmFormElement parentElement,
1063
	        String labelString,
1064
	        T selection,
1065
	        boolean addEmptyElement,
1066
	        int style,
1067
	        boolean useAbbrevLabel) {
1068
	    return createDefinedTermComboElement(null, termVocabulary, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
1069
	}
1070

    
1071
	private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1072
	        TermType termType,
1073
	        TermVocabulary<?> termVocabulary,
1074
	        List<T> terms,
1075
	        ICdmFormElement parentElement,
1076
	        String labelString,
1077
	        T selection,
1078
	        boolean addEmptyElement,
1079
	        int style,
1080
	        boolean useAbbrevLabel,
1081
	        Comparator<T> comparator) {
1082

    
1083
	    if(termType!=null){
1084
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1085
	        adapt(element);
1086
	        parentElement.addElement(element);
1087
	        return element;
1088
	    }
1089
	    else if(termVocabulary!=null){
1090
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1091
//	        if (comparator!= null){
1092
//	        	element.setTermComparator(comparator);
1093
//	        }
1094
	        adapt(element);
1095
	        parentElement.addElement(element);
1096
	        return element;
1097
	    }else if (terms != null){
1098

    
1099
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, terms, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1100

    
1101
            adapt(element);
1102
            parentElement.addElement(element);
1103
            return element;
1104
	    }
1105
	    else {
1106
	        //this should never happen
1107
	        return null;
1108
	    }
1109
	}
1110

    
1111
	   private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1112
	            TermType termType,
1113
	            TermVocabulary<?> termVocabulary,
1114
	            List<T> terms,
1115
	            ICdmFormElement parentElement,
1116
	            String labelString,
1117
	            TermDto selection,
1118
	            boolean addEmptyElement,
1119
	            int style,
1120
	            boolean useAbbrevLabel,
1121
	            Comparator<T> comparator) {
1122
	        if(termType!=null){
1123
	            TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1124
	            adapt(element);
1125
	            parentElement.addElement(element);
1126
	            return element;
1127
	        }
1128

    
1129
	        else {
1130
	            //this should never happen
1131
	            return null;
1132
	        }
1133
	    }
1134

    
1135
	public NameRelationshipTypeCombo createNameRelationshipTypeCombo(ICdmFormElement parentElement,
1136
            String labelString,
1137
            int style,
1138
            boolean useAbbrevLabel,
1139
            Comparator<NameRelationshipType> comparator) {
1140

    
1141
        NameRelationshipTypeCombo<InverseTermWrapper> element = new NameRelationshipTypeCombo(this, parentElement, labelString, true, style, useAbbrevLabel, comparator);
1142
        adapt(element);
1143
        parentElement.addElement(element);
1144
        return element;
1145
    }
1146

    
1147
	public MisappliedRelationshipComboElement createMisappliedRelationshipComboElement(
1148
	        ICdmFormElement parentElement,
1149
            String labelString,
1150
            TaxonRelationshipType selection,
1151
            int style) {
1152
	    MisappliedRelationshipComboElement combo = new MisappliedRelationshipComboElement(this, parentElement, labelString, selection, false, style, false);
1153
	    adapt(combo);
1154
        parentElement.addElement(combo);
1155
        return combo;
1156
    }
1157

    
1158
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1159
	        Class<T> enumComboType, ICdmFormElement parentElement,
1160
	        int style, boolean hasNullValue) {
1161
	    return createEnumComboElement(enumComboType, parentElement, null, style, hasNullValue);
1162
	}
1163
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1164
            Class<T> enumComboType, ICdmFormElement parentElement,
1165
            int style) {
1166
        return createEnumComboElement(enumComboType, parentElement, null, style, false);
1167
    }
1168

    
1169
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1170
			Class<T> enumComboType, ICdmFormElement parentElement, Comparator<T> comparator,
1171
			int style, boolean hasNullValue) {
1172
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, comparator, style, hasNullValue);
1173
        adapt(element);
1174
        parentElement.addElement(element);
1175
        return element;
1176
    }
1177

    
1178
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
1179
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
1180
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1181
	    adapt(element);
1182
	    parentElement.addElement(element);
1183
	    return element;
1184
	}
1185

    
1186
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyDtoComboElement(
1187
            TermType termType, String label, TermVocabularyDto selection, ICdmFormElement parentElement, int style) {
1188
        VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1189
        adapt(element);
1190
        parentElement.addElement(element);
1191
        return element;
1192
    }
1193

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

    
1216
    /**
1217
     * <p>
1218
     * createImageElement
1219
     * </p>
1220
     *
1221
     * @param parentElement
1222
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1223
     *            object.
1224
     * @param imageUri
1225
     *            a {@link eu.etaxonomy.cdm.common.URI} object.
1226
     * @param style
1227
     *            a int.
1228
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1229
     */
1230
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1231
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1232
        adapt(element);
1233
        parentElement.addElement(element);
1234
        return element;
1235
    }
1236

    
1237
    /**
1238
     * <p>
1239
     * createTextActionElement
1240
     * </p>
1241
     *
1242
     * @param labelString
1243
     *            a {@link java.lang.String} object.
1244
     * @param initialText
1245
     *            a {@link java.lang.String} object.
1246
     * @param style
1247
     *            a int.
1248
     * @param parentElement
1249
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1250
     *            object.
1251
     * @param buttonLabel
1252
     *            a {@link java.lang.String} object.
1253
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
1254
     *         object.
1255
     */
1256
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
1257
            String buttonLabel, String initialText, int style) {
1258
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
1259
                style);
1260
        adapt(element);
1261
        parentElement.addElement(element);
1262
        return element;
1263
    }
1264

    
1265
    /**
1266
     * <p>
1267
     * createCheckbox
1268
     * </p>
1269
     *
1270
     * @param parentElement
1271
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1272
     *            object.
1273
     * @param label
1274
     *            a {@link java.lang.String} object.
1275
     * @param initialState
1276
     *            a boolean.
1277
     * @param style
1278
     *            a int.
1279
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1280
     *         object.
1281
     */
1282
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1283
        if(initialState==null){
1284
            initialState = Boolean.FALSE;
1285
        }
1286
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1287
        adapt(element);
1288
        parentElement.addElement(element);
1289
        return element;
1290
    }
1291

    
1292
    /**
1293
     * Creates a section as a part of the form.
1294
     *
1295
     * @return the section widget
1296
     */
1297
    public Section adapt(AbstractFormSection section) {
1298
        section.setMenu(section.getLayoutComposite().getMenu());
1299
        adapt(section, true, true);
1300

    
1301
        // handle focus and property change events for cdm use
1302
        section.addFocusListener(selectionFocusHandler);
1303
        section.setPropertyChangeListeners(propertyChangeListeners);
1304

    
1305
        section.addExpansionListener(new ExpansionAdapter(){
1306
            @Override
1307
            public void expansionStateChanged(ExpansionEvent e) {
1308
                super.expansionStateChanged(e);
1309
                if(section.getEntity()!=null){
1310
                    PreferencesUtil.setStringValue(StoreUtil.getPrefKey(section.getClass(), section.getEntity().getClass().getCanonicalName()), e.getState()?CdmSectionPart.EXPANDED:CdmSectionPart.COLLAPSED);
1311
                }
1312
            }
1313
        });
1314

    
1315
        if (section.getToggle() != null) {
1316
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1317
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1318
        }
1319

    
1320
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1321

    
1322
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1323
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1324
            getColors().initializeSectionToolBarColors();
1325
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1326
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1327
        }
1328
        // call setTitleBarForeground regardless as it also sets the label color
1329
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1330
        return section;
1331
    }
1332

    
1333
    private class BoldFontHolder2 {
1334
        private Font normalFont;
1335

    
1336
        private Font boldFont;
1337

    
1338
        public BoldFontHolder2() {
1339
        }
1340

    
1341
        public Font getBoldFont(Font font) {
1342
            createBoldFont(font);
1343
            return boldFont;
1344
        }
1345

    
1346
        private void createBoldFont(Font font) {
1347
            if (normalFont == null || !normalFont.equals(font)) {
1348
                normalFont = font;
1349
                dispose();
1350
            }
1351
            if (boldFont == null) {
1352
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1353
            }
1354
        }
1355

    
1356
        public void dispose() {
1357
            if (boldFont != null) {
1358
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1359
                boldFont = null;
1360
            }
1361
        }
1362
    }
1363

    
1364
    /**
1365
     * createToggleableTextField with relevance
1366
     */
1367
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1368
            String initialText, boolean initialState, CacheRelevance relevance, int style) {
1369

    
1370
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1371
                initialState, relevance, style | orientation);
1372
        adapt(element);
1373
        parentElement.addElement(element);
1374
        return element;
1375
    }
1376

    
1377
    /**
1378
     * like {@link #createToggleableTextField(ICdmFormElement, String, String, boolean, CacheRelevance, int)}
1379
     * but with predefined cache relevance == 1
1380
     */
1381
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1382
            String initialText, boolean initialState, int style) {
1383
        return createToggleableTextField(parentElement, labelString, initialText, initialState, CacheRelevance.CACHE1, style);
1384
    }
1385

    
1386
    /**
1387
     * like {@link #createToggleableTextField(ICdmFormElement, String, String, boolean, CacheRelevance, int)}
1388
     * but with predefined cache relevance == 1
1389
     */
1390
    public RemovableTextElement createRemovableTextField(ICdmFormElement parentElement, String labelString,
1391
            String initialText, int style) {
1392
        RemovableTextElement element = new RemovableTextElement(this, parentElement, labelString, initialText,
1393
                style | orientation);
1394

    
1395
        adapt(element);
1396
        parentElement.addElement(element);
1397
        return element;
1398
    }
1399

    
1400

    
1401
    /**
1402
     * createTimePeriodElement
1403
     */
1404
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1405
            TimePeriod timePeriod, int style) {
1406
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1407
        adapt(element);
1408
        parentElement.addElement(element);
1409
        return element;
1410
    }
1411

    
1412
    /**
1413
     * createVerbatimTimePeriodElement
1414
     */
1415
    public VerbatimTimePeriodElement createVerbatimTimePeriodElement(ICdmFormElement parentElement, String labelString,
1416
            VerbatimTimePeriod timePeriod, int style) {
1417
        VerbatimTimePeriodElement element = new VerbatimTimePeriodElement(this, parentElement, labelString, timePeriod, style);
1418
        adapt(element);
1419
        parentElement.addElement(element);
1420
        return element;
1421
    }
1422

    
1423
	/**
1424
	 * createGatheringEventUnitElement
1425
	 */
1426
	public GatheringEventUnitElement createGatheringEventUnitElement(
1427
			ICdmFormElement parentElement,
1428
			String labelString,
1429
			DerivedUnitFacade gatheringEvent,
1430
			MinMaxTextSection.UnitType unitType,
1431
			int style) {
1432
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1433
				parentElement,
1434
				labelString,
1435
				gatheringEvent,
1436
				unitType,
1437
				style);
1438
		adapt(element);
1439
		parentElement.addElement(element);
1440
		return element;
1441
	}
1442

    
1443
    /**
1444
     * createPointElement
1445
     */
1446
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1447
        PointElement element = new PointElement(this, parentElement, point, style);
1448
        adapt(element);
1449
        parentElement.addElement(element);
1450
        return element;
1451
    }
1452

    
1453
    /**
1454
     * Creates an empty section with the given message.<br>
1455
     * If message is <code>null</code> a default message will be displayed.
1456
     */
1457
    public EmptySection createEmptySection(String message, CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1458
        EmptySection section = new EmptySection(message, formFactory, parentElement, style);
1459
        parentElement.addElement(section);
1460
        adapt(section);
1461
        return section;
1462
    }
1463

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

    
1484
    /**
1485
     * <p>
1486
     * createVerbatimDateDetailSection
1487
     * </p>
1488
     *
1489
     * @param parentElement
1490
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1491
     *            object.
1492
     * @param style
1493
     *            a int.
1494
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.VerbatimDateDetailSection}
1495
     *         object.
1496
     */
1497
    public DateDetailSection<VerbatimTimePeriod> createVerbatimDateDetailSection(ICdmFormElement parentElement, int style) {
1498
        DateDetailSection<VerbatimTimePeriod> section
1499
        	= new DateDetailSection<VerbatimTimePeriod>(this, parentElement, true, style);
1500
        parentElement.addElement(section);
1501
        adapt(section);
1502
        return section;
1503
    }
1504

    
1505
	/**
1506
	 * <p>
1507
	 * createDateDetailSection
1508
	 * </p>
1509
	 *
1510
	 * @param parentElement
1511
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1512
	 *            object.
1513
	 * @param style
1514
	 *            a int.
1515
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1516
	 *         object.
1517
	 */
1518
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1519
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1520
		parentElement.addElement(section);
1521
		adapt(section);
1522
		return section;
1523
	}
1524

    
1525
    /**
1526
     * <p>
1527
     * createPartialElement
1528
     * </p>
1529
     *
1530
     * @param parentElement
1531
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1532
     *            object.
1533
     * @param labelString
1534
     *            a {@link java.lang.String} object.
1535
     * @param partial
1536
     *            a {@link org.joda.time.Partial} object.
1537
     * @param style
1538
     *            a int.
1539
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1540
     *         object.
1541
     */
1542
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1543
            int style) {
1544
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1545
        adapt(element);
1546
        parentElement.addElement(element);
1547
        return element;
1548
    }
1549

    
1550
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial, boolean showYear,
1551
            int style) {
1552
        PartialElement element = new PartialElement(this, parentElement, labelString, style, showYear);
1553
        adapt(element);
1554
        parentElement.addElement(element);
1555
        return element;
1556
    }
1557

    
1558
    /**
1559
     * <p>
1560
     * addSelectionListener
1561
     * </p>
1562
     *
1563
     * @param listener
1564
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1565
     */
1566
    public void addSelectionListener(SelectionListener listener) {
1567
        selectionListenerList.add(listener);
1568
    }
1569

    
1570
    /**
1571
     * <p>
1572
     * removeSelectionListener
1573
     * </p>
1574
     *
1575
     * @param listener
1576
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1577
     */
1578
    public void removeSelectionListener(SelectionListener listener) {
1579
        if (listener == null) {
1580
            MessagingUtils.error(this.getClass(),
1581
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1582
        } else {
1583
            selectionListenerList.remove(listener);
1584
        }
1585
    }
1586

    
1587
    /**
1588
     * <p>
1589
     * addPropertyChangeListener
1590
     * </p>
1591
     *
1592
     * @param listener
1593
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1594
     *            object.
1595
     */
1596
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1597
        if (propertyChangeListeners.contains(listener)) {
1598
            return;
1599
        }
1600
        propertyChangeListeners.add(0, listener);
1601
    }
1602

    
1603
    /**
1604
     * <p>
1605
     * removePropertyChangeListener
1606
     * </p>
1607
     *
1608
     * @param listener
1609
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1610
     *            object.
1611
     */
1612
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1613
        propertyChangeListeners.remove(listener);
1614
    }
1615

    
1616
    /**
1617
     * @return the propertyChangeListeners
1618
     */
1619
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1620
        return propertyChangeListeners;
1621
    }
1622

    
1623
    /**
1624
     * <p>
1625
     * createHorizontalSeparator
1626
     * </p>
1627
     *
1628
     * @param parentElement
1629
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1630
     *            object.
1631
     * @param style
1632
     *            a int.
1633
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1634
     */
1635
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1636
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1637
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1638
        return separator;
1639
    }
1640

    
1641
    /**
1642
     * <p>
1643
     * createVersionElement
1644
     * </p>
1645
     *
1646
     * @param parentElement
1647
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1648
     *            object.
1649
     * @param entity
1650
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1651
     *            object.
1652
     * @param style
1653
     *            a int.
1654
     * @return a
1655
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1656
     *         object.
1657
     */
1658
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1659
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1660
        adapt(element);
1661
        parentElement.addElement(element);
1662
        return element;
1663
    }
1664

    
1665
    /**
1666
     * @param cdmBaseSection
1667
     * @param object
1668
     * @param style
1669
     * @return
1670
     */
1671
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1672
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1673
        adapt(element);
1674
        parentElement.addElement(element);
1675
        return element;
1676
    }
1677

    
1678
    /**
1679
     * <p>
1680
     * createVersionSection
1681
     * </p>
1682
     *
1683
     * @param parentElement
1684
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1685
     *            object.
1686
     * @param style
1687
     *            a int.
1688
     * @return a
1689
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1690
     *         object.
1691
     */
1692
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1693
        VersionSection section = new VersionSection(this, parentElement, style);
1694
        parentElement.addElement(section);
1695
        adapt(section);
1696
        return section;
1697
    }
1698

    
1699
    /**
1700
     * @param parent
1701
     * @param i
1702
     * @return
1703
     */
1704
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1705
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1706
        parentElement.addElement(section);
1707
        adapt(section);
1708
        return section;
1709
    }
1710

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

    
1728
    /**
1729
     * <p>
1730
     * createHeadlineSection
1731
     * </p>
1732
     *
1733
     * @param parentElement
1734
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1735
     *            object.
1736
     * @return a
1737
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1738
     *         object.
1739
     */
1740
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1741
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1742
        parentElement.addElement(section);
1743
        adapt(section);
1744
        return section;
1745
    }
1746

    
1747
    /**
1748
     * <p>
1749
     * createParsingMessageElement
1750
     * </p>
1751
     *
1752
     * @param parentElement
1753
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1754
     *            object.
1755
     * @param parserProblem
1756
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1757
     *            object.
1758
     * @param style
1759
     *            a int.
1760
     * @return a
1761
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1762
     *         object.
1763
     */
1764
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1765
            ParserProblem parserProblem, int style) {
1766
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1767
        adapt(element);
1768
        parentElement.addElement(element);
1769
        return element;
1770
    }
1771

    
1772
    public DefinedTermDetailSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1773
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1774

    
1775
        DefinedTermDetailSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1776
                selectionProvider, style);
1777

    
1778
        parentElement.addElement(section);
1779
        adapt(section);
1780
        return section;
1781

    
1782
    }
1783

    
1784
    public TermMediaSection createTermMediaSection(ConversationHolder conversation,
1785
            ICdmFormElement parentElement, int style) {
1786
        TermMediaSection section = new TermMediaSection(this, conversation, parentElement, style);
1787
        parentElement.addElement(section);
1788
        adapt(section);
1789
        return section;
1790

    
1791
    }
1792

    
1793
    public DerivedUnitMediaSection createDerivedUnitMediaSection(ConversationHolder conversation,
1794
            ICdmFormElement parentElement, int style) {
1795
        DerivedUnitMediaSection section = new DerivedUnitMediaSection(this, conversation, parentElement, style);
1796
        parentElement.addElement(section);
1797
        adapt(section);
1798
        return section;
1799

    
1800
    }
1801

    
1802
    /**
1803
     * @param definedTermClass
1804
     * @param formElement
1805
     * @param style
1806
     * @return
1807
     */
1808
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1809
            ICdmFormElement parentElement, int style) {
1810
        AbstractCdmDetailElement element = null;
1811

    
1812
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1813
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1814
        } else if (definedTermClass.equals(Feature.class)) {
1815
            element = new FeatureDetailElement(this, parentElement);
1816
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1817
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1818
        } else if(definedTermClass.equals(Language.class)){
1819
            element = new LanguageDetailElement(this, parentElement);
1820
        } else {
1821
            element = new DefinedTermDetailElement(this, parentElement);
1822
        }
1823

    
1824

    
1825
        adapt(element);
1826
        parentElement.addElement(element);
1827
        return element;
1828
    }
1829

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

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

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

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

    
1854
    public CharacterNodeDetailElement createCharacterNodeDetailElement(ICdmFormElement parentElement, int style){
1855
        CharacterNodeDetailElement element = new CharacterNodeDetailElement(this, parentElement);
1856
        addAndAdaptElement(parentElement, element);
1857
        return element;
1858
    }
1859
    public CharacterNodeDtoDetailElement createCharacterNodeDtoDetailElement(ICdmFormElement parentElement, int style){
1860
        CharacterNodeDtoDetailElement element = new CharacterNodeDtoDetailElement(this, parentElement);
1861
        addAndAdaptElement(parentElement, element);
1862
        return element;
1863
    }
1864

    
1865
    public CharacterDetailElement createCharacterDetailElement(ICdmFormElement parentElement, int style){
1866
        CharacterDetailElement element = new CharacterDetailElement(this, parentElement);
1867
        addAndAdaptElement(parentElement, element);
1868
        return element;
1869
    }
1870
    public CharacterDtoDetailElement createCharacterDtoDetailElement(ICdmFormElement parentElement, int style){
1871
        CharacterDtoDetailElement element = new CharacterDtoDetailElement(this, parentElement);
1872
        addAndAdaptElement(parentElement, element);
1873
        return element;
1874
    }
1875

    
1876
    public TermTreeDetailElement createFeatureTreeDetailElement(ICdmFormElement parentElement, int style){
1877
        TermTreeDetailElement element = new TermTreeDetailElement(this, parentElement);
1878
        addAndAdaptElement(parentElement, element);
1879
        return element;
1880
    }
1881

    
1882
    /**
1883
     * @param parentElement
1884
     * @param style
1885
     * @return
1886
     */
1887
    public AbstractCdmDetailElement<TermTree> createFeatureTreeDetailElementForTree(
1888
            AbstractCdmDetailSection<TermTree> parentElement, int style) {
1889
        TermTreeDetailElementForNode element = new TermTreeDetailElementForNode(this, parentElement);
1890
        addAndAdaptElement(parentElement, element);
1891
        return element;
1892
    }
1893

    
1894
    public TermNodeDetailElement createFeatureNodeDetailElement(ICdmFormElement parentElement, int style){
1895
        TermNodeDetailElement element = new TermNodeDetailElement(this, parentElement);
1896
        addAndAdaptElement(parentElement, element);
1897
        return element;
1898
    }
1899

    
1900

    
1901
    //--------DetailSections---------
1902
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1903
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1904
        addAndAdaptSection(parentElement, section);
1905
        return section;
1906
    }
1907

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

    
1914
    public TermTreeDetailSection createFeatureTreeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1915
        TermTreeDetailSection section = new TermTreeDetailSection(this, conversation, parentElement, selectionProvider, style);
1916
        addAndAdaptSection(parentElement, section);
1917
        return section;
1918
    }
1919
    public TermTreeDetailSectionForNode createFeatureTreeDetailSectionForTree(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1920
        TermTreeDetailSectionForNode section = new TermTreeDetailSectionForNode(this, conversation, parentElement, selectionProvider, style);
1921
        addAndAdaptSection(parentElement, section);
1922
        return section;
1923
    }
1924

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

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

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

    
1943
    public AdvancedSourceElement createAdvancedSourceDetailElement(ICdmFormElement parentElement, int style){
1944
        AdvancedSourceElement element = new AdvancedSourceElement(this, parentElement);
1945
        addAndAdaptElement(parentElement, element);
1946
        return element;
1947
    }
1948

    
1949
    public AdvancedSourceElement createAdvancedNomenclaturalSourceDetailElement(ICdmFormElement parentElement, int style){
1950
        AdvancedNomenclaturalSourceElement element = new AdvancedNomenclaturalSourceElement(this, parentElement);
1951
        addAndAdaptElement(parentElement, element);
1952
        return element;
1953
    }
1954

    
1955
    public SingleSourceSection createSingleSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, CdmBase cdmEntity, ISelectionProvider selectionProvider, String label, int style){
1956
        SingleSourceSection section = new SingleSourceSection(this, conversation, parentElement, cdmEntity, selectionProvider, style, label);
1957
        addAndAdaptSection(parentElement, section);
1958
        return section;
1959
    }
1960

    
1961
    public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1962
        TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1963
        addAndAdaptSection(parentElement, section);
1964
        return section;
1965
    }
1966
    
1967
    public SecundumSourceSection createSecundumDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1968
    	SecundumSourceSection section = new SecundumSourceSection(this, conversation, parentElement, selectionProvider, style);
1969
        addAndAdaptSection(parentElement, section);
1970
        return section;
1971
    }
1972

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

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

    
1985
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1986
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1987
        addAndAdaptSection(parentElement, section);
1988
        return section;
1989
    }
1990

    
1991
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1992
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1993
        addAndAdaptSection(parentElement, section);
1994
        return section;
1995
    }
1996

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

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

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

    
2015

    
2016

    
2017
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, boolean nameChoosable, int style){
2018
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, nameChoosable, style);
2019
        addAndAdaptSection(parentElement, section);
2020
        return section;
2021
    }
2022

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2119
    public PreservedSpecimenGeneralDetailSection createPreservedSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2120
        PreservedSpecimenGeneralDetailSection section = new PreservedSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2121
        addAndAdaptSection(parentElement, section);
2122
        return section;
2123
    }
2124

    
2125
    public TissueSampleGeneralDetailSection createTissueSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2126
        TissueSampleGeneralDetailSection section = new TissueSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2127
        addAndAdaptSection(parentElement, section);
2128
        return section;
2129
    }
2130

    
2131
    public DnaSampleGeneralDetailSection createDnaSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2132
        DnaSampleGeneralDetailSection section = new DnaSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2133
        addAndAdaptSection(parentElement, section);
2134
        return section;
2135
    }
2136

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

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

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

    
2155
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2156
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
2157
        addAndAdaptSection(parentElement, section);
2158
        return section;
2159
    }
2160

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

    
2167
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2168
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
2169
        addAndAdaptSection(parentElement, section);
2170
        return section;
2171
    }
2172

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

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

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

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

    
2197
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2198
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
2199
        addAndAdaptSection(parentElement, section);
2200
        return section;
2201
    }
2202

    
2203
    public MediaSpecimenGeneralDetailSection createMediaSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2204
        MediaSpecimenGeneralDetailSection section = new MediaSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2205
        addAndAdaptSection(parentElement, section);
2206
        return section;
2207
    }
2208

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

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

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

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

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

    
2239
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2240
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style, true);
2241
        addAndAdaptSection(parentElement, section);
2242
        return section;
2243
    }
2244

    
2245
    public ReferencedEntityDetailSection createReferencedEntityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2246
        ReferencedEntityDetailSection section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
2247
        addAndAdaptSection(parentElement, section);
2248
        return section;
2249
    }
2250

    
2251
    public TermVocabularyDetailSection createTermVocabularyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2252
        TermVocabularyDetailSection section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
2253
        addAndAdaptSection(parentElement, section);
2254
        return section;
2255
    }
2256

    
2257
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2258
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
2259
        addAndAdaptSection(parentElement, section);
2260
        return section;
2261
    }
2262

    
2263
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2264
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
2265
        addAndAdaptSection(parentElement, section);
2266
        return section;
2267
    }
2268

    
2269
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2270
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
2271
        addAndAdaptSection(parentElement, section);
2272
        return section;
2273
    }
2274

    
2275
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
2276
        parentElement.addElement(section);
2277
        adapt(section);
2278
    }
2279

    
2280
    //--------DetailElements------------
2281

    
2282
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
2283
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
2284
        addAndAdaptElement(parentElement, element);
2285
        return element;
2286
    }
2287

    
2288
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
2289
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
2290
        addAndAdaptElement(parentElement, element);
2291
        return element;
2292
    }
2293

    
2294
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
2295
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
2296
        addAndAdaptElement(parentElement, element);
2297
        return element;
2298
    }
2299

    
2300
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
2301
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
2302
        addAndAdaptElement(parentElement, element);
2303
        return element;
2304
    }
2305

    
2306
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
2307
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
2308
        addAndAdaptElement(parentElement, element);
2309
        return element;
2310
    }
2311
    public OriginalSourceElement createOriginalSourceElement(ICdmFormElement parentElement, CdmBase cdmEntity, String label){
2312
        OriginalSourceElement element = new OriginalSourceElement(this, parentElement, cdmEntity, label);
2313
        addAndAdaptElement(parentElement, element);
2314
        return element;
2315
    }
2316

    
2317
    public SecundumSourceDetailElement createSecundumSourceDetailElement(ICdmFormElement parentElement){
2318
    	SecundumSourceDetailElement element = new SecundumSourceDetailElement(this, parentElement);
2319
        addAndAdaptElement(parentElement, element);
2320
        return element;
2321
    }
2322
    
2323
    public SecundumSourceElement createSecundumSourceElement(ICdmFormElement parentElement, CdmBase cdmEntity, String label){
2324
        SecundumSourceElement element = new SecundumSourceElement(this, parentElement, cdmEntity, label);
2325
        addAndAdaptElement(parentElement, element);
2326
        return element;
2327
    }
2328
    public NomenclaturalSourceElement createNomenclaturalSourceElement(ICdmFormElement parentElement, CdmBase cdmEntity, String label){
2329
        NomenclaturalSourceElement element = new NomenclaturalSourceElement(this, parentElement, cdmEntity, label);
2330
        addAndAdaptElement(parentElement, element);
2331
        return element;
2332
    }
2333

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

    
2340
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
2341
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2342
        addAndAdaptElement(parentElement, element);
2343
        return element;
2344
    }
2345

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

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

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

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

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

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

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

    
2388
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2389
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2390
        adapt(element);
2391
        parentElement.addElement(element);
2392

    
2393
        return element;
2394
    }
2395

    
2396
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2397
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2398
        addAndAdaptElement(parentElement, element);
2399
        return element;
2400
    }
2401

    
2402
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
2403
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
2404
        addAndAdaptElement(parentElement, element);
2405
        return element;
2406
    }
2407

    
2408
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2409
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2410
        addAndAdaptElement(parentElement, element);
2411
        return element;
2412
    }
2413

    
2414
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2415
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2416
        addAndAdaptElement(parentElement, element);
2417
        return element;
2418
    }
2419

    
2420
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2421
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2422
        addAndAdaptElement(parentElement, element);
2423
        return element;
2424
    }
2425

    
2426
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2427
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2428
        addAndAdaptElement(parentElement, element);
2429
        return element;
2430
    }
2431

    
2432
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2433
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2434
        addAndAdaptElement(parentElement, element);
2435
        return element;
2436
    }
2437

    
2438
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2439
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2440
        addAndAdaptElement(parentElement, element);
2441
        return element;
2442
    }
2443

    
2444
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2445
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2446
        addAndAdaptElement(parentElement, element);
2447
        return element;
2448
    }
2449

    
2450
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2451
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2452
        addAndAdaptElement(parentElement, element);
2453
        return element;
2454
    }
2455

    
2456
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2457
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2458
        addAndAdaptElement(parentElement, element);
2459
        return element;
2460
    }
2461

    
2462
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2463
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2464
        addAndAdaptElement(parentElement, element);
2465
        return element;
2466
    }
2467

    
2468
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2469
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2470
        addAndAdaptElement(parentElement, element);
2471
        return element;
2472
    }
2473

    
2474
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
2475
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
2476
        addAndAdaptElement(parentElement, element);
2477
        return element;
2478
    }
2479
    public ReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2480
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, true, style);
2481
        addAndAdaptElement(parentElement, element);
2482
        return element;
2483
    }
2484

    
2485
    public NomenclaturalSourceDetailElement createNomenclaturalSourceDetailElement(ICdmFormElement parentElement, int style){
2486
        NomenclaturalSourceDetailElement element = new NomenclaturalSourceDetailElement(this, parentElement, style);
2487
        addAndAdaptElement(parentElement, element);
2488
        return element;
2489
    }
2490

    
2491

    
2492
    public FieldUnitFacadeGeneralDetailElement createFieldUnitFacadeGeneralDetailElement(ICdmFormElement parentElement){
2493
        FieldUnitFacadeGeneralDetailElement element = new FieldUnitFacadeGeneralDetailElement(this, parentElement);
2494
        addAndAdaptElement(parentElement, element);
2495
        return element;
2496
    }
2497

    
2498
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2499
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2500
        addAndAdaptElement(parentElement, element);
2501
        return element;
2502
    }
2503

    
2504
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2505
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2506
        addAndAdaptElement(parentElement, element);
2507
        return element;
2508
    }
2509

    
2510
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2511
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2512
        addAndAdaptElement(parentElement, element);
2513
        return element;
2514
    }
2515

    
2516
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2517
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2518
        addAndAdaptElement(parentElement, element);
2519
        return element;
2520
    }
2521

    
2522
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2523
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2524
        addAndAdaptElement(parentElement, element);
2525
        return element;
2526
    }
2527

    
2528
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2529
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2530
        addAndAdaptElement(parentElement, element);
2531
        return element;
2532
    }
2533

    
2534
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2535
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2536
        addAndAdaptElement(parentElement, element);
2537
        return element;
2538
    }
2539

    
2540
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2541
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2542
        addAndAdaptElement(parentElement, element);
2543
        return element;
2544
    }
2545

    
2546
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2547
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2548
        addAndAdaptElement(parentElement, element);
2549
        return element;
2550
    }
2551

    
2552
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2553
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2554
        addAndAdaptElement(parentElement, element);
2555
        return element;
2556
    }
2557

    
2558
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2559
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2560
        addAndAdaptElement(parentElement, element);
2561
        return element;
2562
    }
2563

    
2564
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2565
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2566
        addAndAdaptElement(parentElement, element);
2567
        return element;
2568
    }
2569

    
2570
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2571
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2572
        addAndAdaptElement(parentElement, element);
2573
        return element;
2574
    }
2575

    
2576
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2577
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2578
        addAndAdaptElement(parentElement, element);
2579
        return element;
2580
    }
2581

    
2582
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2583
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2584
        addAndAdaptElement(parentElement, element);
2585
        return element;
2586
    }
2587

    
2588
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2589
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2590
        addAndAdaptElement(parentElement, mediaDetailElement);
2591
        return mediaDetailElement;
2592
    }
2593

    
2594
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2595
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2596
        addAndAdaptElement(parentElement, element);
2597
        return element;
2598
    }
2599

    
2600
    public FieldUnitFacadeDetailElement createFieldUnitFacadeDetailElement(ICdmFormElement parentElement) {
2601
        FieldUnitFacadeDetailElement element = new FieldUnitFacadeDetailElement(this, parentElement);
2602
        addAndAdaptElement(parentElement, element);
2603
        return element;
2604
    }
2605

    
2606
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2607
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2608
        addAndAdaptElement(parentElement, element);
2609
        return element;
2610
    }
2611

    
2612
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2613
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2614
        addAndAdaptElement(parentElement, element);
2615
        return element;
2616
    }
2617

    
2618
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2619
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2620
        addAndAdaptElement(parentElement, element);
2621
        return element;
2622
    }
2623

    
2624
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2625
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2626
        addAndAdaptElement(parentElement, element);
2627
        return element;
2628
    }
2629

    
2630
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2631
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2632
        addAndAdaptElement(parentElement, element);
2633
        return element;
2634
    }
2635

    
2636
    /**
2637
     * @param parentElement
2638
     * @param element
2639
     */
2640
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2641
        adapt(element);
2642
        parentElement.addElement(element);
2643
    }
2644

    
2645
    //--------EntityCollectionSection----------
2646
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2647
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2648
        addAndAdaptSection(parentElement, section);
2649
        return section;
2650
    }
2651

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

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

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

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

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

    
2682
    public CreditSection createCreditSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2683
        CreditSection section = new CreditSection(this, conversation, parentElement, style);
2684
        addAndAdaptSection(parentElement, section);
2685
        return section;
2686
    }
2687
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2688
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2689
        addAndAdaptSection(parentElement, section);
2690
        return section;
2691
    }
2692
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, Reference defaultSource, int style){
2693
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, defaultSource, style);
2694
        addAndAdaptSection(parentElement, section);
2695
        return section;
2696
    }
2697

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

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

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

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

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

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

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

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

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

    
2752
//    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2753
//        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2754
//        addAndAdaptSection(parentElement, section);
2755
//        return section;
2756
//    }
2757
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2758
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, style);
2759
        addAndAdaptSection(parentElement, section);
2760
        return section;
2761
    }
2762

    
2763
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, String label, int style){
2764
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, true, label, style);
2765
        addAndAdaptSection(parentElement, section);
2766
        return section;
2767
    }
2768

    
2769
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, String label, boolean isWithTypeAndDesc, int style){
2770
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, isWithTypeAndDesc, label, style);
2771
        addAndAdaptSection(parentElement, section);
2772
        return section;
2773
    }
2774

    
2775
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2776
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2777

    
2778
        addAndAdaptSection(parentElement, section);
2779
        return section;
2780
    }
2781

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

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

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

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

    
2806
    public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2807
        StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
2808
        addAndAdaptSection(parentElement, section);
2809
        return section;
2810
    }
2811

    
2812
    public StatisticalMeasurementValueSection createStatisticalMeasurementValueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2813
        StatisticalMeasurementValueSection section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
2814
        addAndAdaptSection(parentElement, section);
2815
        return section;
2816
    }
2817

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

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

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

    
2836
    public RecommendedModifierVocabulariesCollectionSection createRecommendedModifierVocabulariesCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2837
        RecommendedModifierVocabulariesCollectionSection section = new RecommendedModifierVocabulariesCollectionSection(this, conversation, parentElement, style);
2838
        addAndAdaptSection(parentElement, section);
2839
        return section;
2840
    }
2841
    public RecommendedModifierVocabulariesDtoCollectionSection createRecommendedModifierVocabulariesDtoCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2842
        RecommendedModifierVocabulariesDtoCollectionSection section = new RecommendedModifierVocabulariesDtoCollectionSection(this, conversation, parentElement, style);
2843
        addAndAdaptSection(parentElement, section);
2844
        return section;
2845
    }
2846

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

    
2853
    public MeasurementUnitDtoCollectionSection createMeasurementUnitDtoCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2854
        MeasurementUnitDtoCollectionSection section = new MeasurementUnitDtoCollectionSection(this, conversation, parentElement, style);
2855
        addAndAdaptSection(parentElement, section);
2856
        return section;
2857
    }
2858
    public StatisticalMeasureCollectionSection createStatisticalMeasureCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2859
        StatisticalMeasureCollectionSection section = new StatisticalMeasureCollectionSection(this, conversation, parentElement, style);
2860
        addAndAdaptSection(parentElement, section);
2861
        return section;
2862
    }
2863

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2942
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2943
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2944
        addAndAdaptSection(parentElement, section);
2945
        return section;
2946
    }
2947

    
2948
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2949
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2950
        addAndAdaptSection(parentElement, section);
2951
        return section;
2952
    }
2953

    
2954
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2955
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2956
        addAndAdaptSection(parentElement, section);
2957
        return section;
2958
    }
2959

    
2960
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2961
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2962
        addAndAdaptSection(parentElement, section);
2963
        return section;
2964
    }
2965

    
2966
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2967
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2968
        addAndAdaptSection(parentElement, section);
2969
        return section;
2970
    }
2971

    
2972
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2973
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2974
        addAndAdaptSection(parentElement, section);
2975
        return section;
2976
    }
2977

    
2978
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2979
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2980
        AbstractEntityCollectionElement<?> element = null;
2981

    
2982
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2983

    
2984
        if (entity instanceof Annotation) {
2985
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2986
        }else if (entity instanceof Person ) {
2987
            boolean isNomenclatural = false;
2988
            if (parentElement instanceof TeamMemberSection){
2989
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2990
            }
2991
            if (isNomenclatural){
2992
            	element = new NomenclaturalTeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
2993
            }else{
2994
            	element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
2995
            }
2996
        } else if (entity instanceof Credit) {
2997
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2998
        } else if (entity instanceof Extension) {
2999
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
3000
        } else if (entity instanceof ExternalLink) {
3001
            boolean isAdvanced = true;
3002
            if(parentElement instanceof ExternalLinksSection){
3003
                isAdvanced = ((ExternalLinksSection)parentElement).isAdvanced();
3004
            }
3005
            element = new ExternalLinksElement(this, parentElement, (ExternalLink) entity, isAdvanced, removeListener, style);
3006
        } else if (entity instanceof Marker) {
3007
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
3008
        } else if (entity instanceof TaxonNodeAgentRelation) {
3009
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
3010
        }else if (entity instanceof Media) {
3011
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
3012
        } else if (entity instanceof MediaRepresentation) {
3013
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
3014
                    style);
3015
        } else if (entity instanceof ImageFile) {
3016
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
3017
        } else if (entity instanceof MediaRepresentationPart) {
3018
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
3019
                    removeListener, style);
3020
        } else if (entity instanceof NomenclaturalStatus) {
3021
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
3022
                    style);
3023
        } else if (entity instanceof Rights) {
3024
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
3025
        } else if (entity instanceof DescriptionElementSource && parentElement.getEntity() instanceof CommonTaxonName) {
3026
            element = new CommonNameSourceElement(this, parentElement, (DescriptionElementSource) entity,
3027
                    removeListener, style);
3028
        } else if (entity instanceof DescriptionElementSource  && parentElement.getEntity() instanceof Distribution) {
3029
            Composite parent = null;
3030
            if (parentElement instanceof DescriptionElementSourceSection){
3031
               parent = ((DescriptionElementSourceSection)parentElement).getParent();
3032
            }
3033
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
3034
                    removeListener, style, false);
3035
        } else if (entity instanceof DescriptionElementSource) {
3036
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
3037
                    removeListener, style, false);
3038
        }else if (entity instanceof TaxonNodeAgentRelation) {
3039
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
3040
                    removeListener,backgroundColor, style);
3041
        }else if (entity instanceof IdentifiableSource && parentElement.getEntity() instanceof DescriptionElementBase) {
3042
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
3043
                    style, true);
3044
        } else if (entity instanceof IdentifiableSource ) {
3045
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
3046
                    style, true);
3047
        } else if (entity instanceof DefinedTerm) {
3048
            switch(((DefinedTerm)entity).getTermType()) {
3049
            case Scope:
3050
                element = new ScopeElement(this,
3051
                        parentElement,
3052
                        (DefinedTerm) entity,
3053
                        removeListener,
3054
                        style);
3055
                break;
3056
            case Modifier:
3057
                element = new ModifierElement(this,
3058
                        parentElement,
3059
                        (DefinedTerm) entity,
3060
                        removeListener,
3061
                        style);
3062
                break;
3063
            default:
3064
                break;
3065

    
3066
            }
3067
        } else if (entity instanceof Reference) {
3068
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
3069
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
3070
            }
3071
            else{
3072
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
3073
            }
3074
        } else if (entity instanceof NameTypeDesignation) {
3075
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
3076
                    style);
3077
        } else if (entity instanceof TextualTypeDesignation) {
3078
            element = new TextTypeDesignationElement(this, parentElement, (TextualTypeDesignation) entity, removeListener,
3079
                    style);
3080
        } else if (entity instanceof NameRelationship) {
3081
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
3082
                    style);
3083
        } else if (entity instanceof SpecimenTypeDesignation) {
3084
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
3085
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
3086
                        removeListener, style);
3087
            }
3088
            else{
3089
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
3090
                        removeListener, style);
3091
            }
3092
        } else if (entity instanceof StateData) {
3093
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
3094
        } else if (entity instanceof StatisticalMeasurementValue) {
3095
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
3096
                    removeListener, style);
3097
        } else if (entity instanceof DerivedUnit) {
3098
            switch(((DerivedUnit)entity).getRecordBasis()) {
3099
            case LivingSpecimen:
3100
            case PreservedSpecimen:
3101
            case OtherSpecimen:
3102
                element = new SpecimenCollectionDetailElement(this,
3103
                        parentElement,
3104
                        (DerivedUnit) entity,
3105
                        removeListener,
3106
                        style);
3107
                break;
3108
            default:
3109
                element = new DerivedUnitElement(this,
3110
                        parentElement,
3111
                        (DerivedUnit) entity,
3112
                        removeListener,
3113
                        style);
3114
            }
3115
        } else if (entity instanceof NamedArea) {
3116
            element = new CollectingAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
3117
        } else if (entity instanceof DeterminationEvent) {
3118
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
3119
        } else if (entity instanceof User) {
3120
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
3121
        } else if (entity instanceof GrantedAuthority) {
3122
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
3123
                    removeListener, style);
3124
        } else if (entity instanceof Group) {
3125
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
3126
        } else if (entity instanceof Taxon) {
3127
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
3128
        } else if (entity instanceof DescriptionElementBase) {
3129
            // this is the special case for protologs, maybe we can do this
3130
            // differently when API improves
3131
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
3132
//            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
3133
//                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
3134
//            }
3135
        } else if (entity instanceof Identifier) {
3136
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
3137
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier) entity, removeListener, backgroundColor, style);
3138
            }
3139
            else{
3140
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
3141
            }
3142
        } else if (entity instanceof TermVocabulary) {
3143
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
3144
            switch (termVocabulary.getTermType()) {
3145
            case State:
3146
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
3147
                break;
3148
            case Modifier:
3149
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
3150
                break;
3151
            default:
3152
                break;
3153
            }
3154
        }else if (entity instanceof TermVocabularyDto) {
3155
            TermVocabularyDto termVocabulary = (TermVocabularyDto)entity;
3156
            switch (termVocabulary.getTermType()) {
3157
            case State:
3158
                element = new StateVocabularyDtoCollectionElement(this, parentElement, termVocabulary, removeListener, backgroundColor, style);
3159
                break;
3160
            case Modifier:
3161
                element = new RecommendedModifierDtoVocabulariesElement(this, parentElement, termVocabulary, removeListener, backgroundColor, style);
3162
                break;
3163
            default:
3164
                break;
3165
            }
3166
        }else if (entity instanceof MeasurementUnit) {
3167
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
3168
        }else if (entity instanceof TermDto) {
3169
            if(((TermDto)entity).getTermType().equals(TermType.MeasurementUnit)){
3170
                element = new MeasurementUnitDtoCollectionElement(this, parentElement, (TermDto) entity, removeListener, backgroundColor, style);
3171
            }else if (((TermDto)entity).getTermType().equals(TermType.StatisticalMeasure)){
3172
                element = new StatisticalMeasureDtoCollectionElement(this, parentElement, (TermDto) entity, removeListener, backgroundColor, style);
3173
            }
3174
        }else if (entity instanceof StatisticalMeasure) {
3175
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
3176
        } else if (entity instanceof FeatureState && parentElement instanceof InapplicableIfEntityCollectionSection) {
3177
            element = new InapplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
3178
        } else if (entity instanceof FeatureState && parentElement instanceof OnlyApplicableIfEntityCollectionSection) {
3179
            element = new OnlyApplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
3180
        } else if (entity instanceof FeatureState && parentElement instanceof InapplicableIfEntityCollectionSectionForNode) {
3181
            element = new InapplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
3182
        } else if (entity instanceof FeatureState && parentElement instanceof OnlyApplicableIfEntityCollectionSectionForNode) {
3183
            element = new OnlyApplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
3184
        } else if (entity instanceof FeatureStateDto && parentElement instanceof InapplicableIfEntityCollectionSection) {
3185
        	element = new InapplicableIfCollectionElementForDto(this, parentElement, (FeatureStateDto) entity, removeListener, backgroundColor, style);
3186
	    } else if (entity instanceof FeatureStateDto && parentElement instanceof OnlyApplicableIfEntityCollectionSection) {
3187
	        element = new OnlyApplicableIfCollectionElementForDto(this, parentElement, (FeatureStateDto) entity, removeListener, backgroundColor, style);
3188
	    }
3189

    
3190
        //check for parent section when entity is null
3191
        //this happens when AbstractUnboundEntityCollectionSection is used
3192
        if(element==null){
3193
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
3194
                element = new ScopeElement(this,
3195
                        parentElement,
3196
                        (DefinedTerm) entity,
3197
                        removeListener,
3198
                        style);
3199
            }
3200
            else if(parentElement instanceof ModifierSection){
3201
                element = new ModifierElement(this,
3202
                        parentElement,
3203
                        (DefinedTerm) entity,
3204
                        removeListener,
3205
                        style);
3206
            }
3207
        }
3208

    
3209

    
3210
        if (element == null) {
3211
            MessagingUtils.messageDialog(
3212
                    String.format("Error when creating section %s",
3213
                            parentElement.getClass().getSimpleName()),
3214
                    this,
3215
                    String.format("Could not generate collection element for entity of class %s."
3216
                            + " Looks like the case is not yet handled. Check implementation.\n"
3217
                            + "Entity: %s", entity.getClass(), entity.toString()), null);
3218
        }
3219

    
3220
        else{
3221
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
3222
                element.setPersistentBackground(backgroundColor);
3223
            }
3224
            adapt(element);
3225
            parentElement.addElement(element);
3226
        }
3227

    
3228
        return element;
3229
    }
3230

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

    
3274
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3275
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3276
            int style, boolean filterElement) {
3277
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
3278
                parentElement, clazz,
3279
                labelString, selection, mode, style, filterElement);
3280
        adapt(element);
3281
        parentElement.addElement(element);
3282
        return element;
3283
    }
3284

    
3285
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3286
//            ConversationHolder conversation,
3287
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3288
            int style) {
3289
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this,
3290
                parentElement, clazz,
3291
                labelString, selection, mode, style);
3292
        adapt(element);
3293
        parentElement.addElement(element);
3294
        return element;
3295
    }
3296
    public CollectorSelectionElement createCollectorSelectionElement(ICdmFormElement parentElement, String labelString, AgentBase selection, int mode,
3297
          int style) {
3298
    	CollectorSelectionElement element = new CollectorSelectionElement(this, parentElement, 
3299
              labelString, selection, mode, style);
3300
      adapt(element);
3301
      parentElement.addElement(element);
3302
      return element;
3303
  }
3304

    
3305
    public CommonNameReferenceSelectionElement createCommonNameReferenceSelectionElement(ICdmFormElement parentElement, String labelString, Reference selection, int mode,
3306
          int style) {
3307
        CommonNameReferenceSelectionElement element = new CommonNameReferenceSelectionElement(this,
3308
              parentElement, labelString, selection, mode, style);
3309
      adapt(element);
3310
      parentElement.addElement(element);
3311
      return element;
3312
  }
3313

    
3314
    /**
3315
     * <p>
3316
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
3317
     * </p>
3318
     * <p>
3319
     * <strong>Selection elements not handled by this method:</strong>
3320
     * <ul>
3321
     * <li>{@link TaxonNodeSelectionElement} see
3322
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
3323
     * </li>
3324
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
3325
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
3326
     * </li>
3327
     * </ul>
3328
     * </p>
3329
     *
3330
     * @param clazz
3331
     *            a {@link Class} object of the type that you want the selection
3332
     *            element to handle
3333
     * @param parentElement
3334
     *            a {@link ICdmFormElement} object.
3335
     * @param labelString
3336
     *            a {@link String} object.
3337
     * @param selectionType
3338
     * @param selection
3339
     *            a {@link ICdmBase} object.
3340
     * @param style
3341
     *            a int.
3342
     * @param conversation
3343
     *            a {@link ConversationHolder} object.
3344
     * @return a {@link EntitySelectionElement} object.
3345
     */
3346
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
3347
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
3348
            T selection, int mode, int style) {
3349
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, //conversation,
3350
                parentElement, clazz,
3351
                labelString, selection, mode, style);
3352
        adapt(element);
3353
        parentElement.addElement(element);
3354
        return element;
3355
    }
3356

    
3357
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3358
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
3359
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this,
3360
                parentElement,
3361
                labelString, selection, mode, style, null);
3362
        adapt(element);
3363
        parentElement.addElement(element);
3364
        return element;
3365
    }
3366
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3367
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style, Integer limit) {
3368
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
3369
                parentElement,
3370
                labelString, selection, mode, style, limit);
3371
        adapt(element);
3372
        parentElement.addElement(element);
3373
        return element;
3374
    }
3375

    
3376

    
3377
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
3378
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
3379
//            int mode, int style) {
3380
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
3381
//                conversation, parentElement, labelString, selection, mode, style);
3382
//        adapt(element);
3383
//        parentElement.addElement(element);
3384
//        return element;
3385
//    }
3386

    
3387
    /** {@inheritDoc} */
3388
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
3389
        LabelElement labelElement = new LabelElement(this, parentElement, text);
3390
        adapt(labelElement);
3391
        parentElement.addElement(labelElement);
3392
        return labelElement;
3393
    }
3394

    
3395

    
3396

    
3397
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
3398
//        Label label = new Label(formElement.getLayoutComposite(), style);
3399
//        label.setText(labelText+" (yyyy-MM-dd)");
3400
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
3401
//        dateElement.initInternalController();
3402
//
3403
//        return dateElement;
3404
//    }
3405

    
3406
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
3407
    	 Label label = new Label(formElement.getLayoutComposite(), style);
3408
         label.setText(labelText);
3409
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3410
         DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
3411
         dateElement.initController(this, formElement);
3412
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3413
         return dateElement;
3414
    }
3415

    
3416
    /**
3417
     * <p>
3418
     * Getter for the field <code>selectionProvider</code>.
3419
     * </p>
3420
     *
3421
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
3422
     */
3423
    public ISelectionProvider getSelectionProvider() {
3424
        return selectionProvider;
3425
    }
3426

    
3427
    /**
3428
     * <p>
3429
     * createDetailedDescriptionDetailElement
3430
     * </p>
3431
     *
3432
     * @param parentElement
3433
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3434
     *            object.
3435
     * @param entity
3436
     *            a
3437
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
3438
     *            object.
3439
     * @param style
3440
     *            a int.
3441
     * @return a
3442
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
3443
     *         object.
3444
     */
3445
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
3446
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
3447
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
3448

    
3449
        if (entity instanceof CategoricalData) {
3450
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
3451
                    (CategoricalData) entity, enabled, style);
3452
        } else if (entity instanceof CommonTaxonName) {
3453
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity, enabled, style);
3454
        } else if (entity instanceof Distribution && !enabled) {
3455
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3456
                    enabled, style);
3457
        } else if (entity instanceof Distribution) {
3458
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3459
                    true, style);
3460
        }else if (entity instanceof IndividualsAssociation) {
3461
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
3462
                    (IndividualsAssociation) entity, enabled, style);
3463
        } else if (entity instanceof QuantitativeData) {
3464
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
3465
                    (QuantitativeData) entity, enabled, style);
3466
        } else if (entity instanceof TaxonInteraction) {
3467
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
3468
                    (TaxonInteraction) entity, enabled, style);
3469
        } else if (entity instanceof TemporalData) {
3470
            detailedDescriptionElement = new TemporalDataDetailElement(this, parentElement, (TemporalData) entity, enabled, style);
3471
        } else if (entity instanceof TextData) {
3472
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, enabled, style);
3473
        }
3474
        else {
3475
            throw new IllegalStateException("There is no interface for the given description element");
3476
        }
3477
//        detailedDescriptionElement.setEnabled(enabled);
3478
        adapt(detailedDescriptionElement);
3479
        parentElement.addElement(detailedDescriptionElement);
3480
        return detailedDescriptionElement;
3481

    
3482
    }
3483

    
3484
    /**
3485
     * Creates a styled text as a part of the form.
3486
     *
3487
     * @param parent
3488
     *            the text parent
3489
     * @param value
3490
     *            the text initial value
3491
     * @param style
3492
     *            the text style
3493
     * @return the text widget
3494
     */
3495
    public StyledText createStyledText(Composite parent, String value, int style) {
3496
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3497
        if (value != null) {
3498
            text.setText(value);
3499
        }
3500
        text.setForeground(getColors().getForeground());
3501
        text.setBackground(getColors().getBackground());
3502
        // text.addFocusListener(visibilityHandler);
3503
        return text;
3504
    }
3505

    
3506
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3507
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3508
        addAndAdaptSection(parentElement, section);
3509
        return section;
3510
    }
3511

    
3512
    /**
3513
     * @param formElement
3514
     * @param conversationHolder
3515
     * @param style
3516
     * @return
3517
     */
3518
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3519
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3520
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3521
        addAndAdaptSection(formElement, section);
3522
        return section;
3523
    }
3524

    
3525

    
3526
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3527
			ICdmFormElement parentElement, int style) {
3528
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3529
		addAndAdaptElement(parentElement, section);
3530
        return section;
3531
	}
3532

    
3533
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3534
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3535
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3536
	        addAndAdaptSection(formElement, section);
3537
	        return section;
3538
	}
3539

    
3540

    
3541
    /**
3542
     * <p>
3543
     * createTextWithLabelElement
3544
     * </p>
3545
     *
3546
     * @param parentElement
3547
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3548
     *            object.
3549
     * @param labelString
3550
     *            a {@link java.lang.String} object.
3551
     * @param initialText
3552
     *            a {@link java.lang.String} object.
3553
     * @param textLimit maximal number of characters allowed
3554
     * @param style
3555
     *            a int.
3556
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
3557
     *         object.
3558
     */
3559
    public RuleConsideredElement createRuleConsideredElement(ICdmFormElement parentElement, String labelString, boolean isShowCodeEdition, int style) {
3560
        RuleConsideredElement element = new RuleConsideredElement(this, parentElement, labelString, isShowCodeEdition, style);
3561
        adapt(element);
3562
        parentElement.addElement(element);
3563
        return element;
3564
    }
3565

    
3566
    /**
3567
     * @param class1
3568
     * @param formElement
3569
     * @param string
3570
     * @param area
3571
     * @param nothing
3572
     * @param style
3573
     * @return
3574
     */
3575
    public EntitySelectionElementWithIdInVocabulary createSelectionElementWithIdInVocabulary(Class<NamedArea> clazz,
3576
            ICdmFormElement formElement, String labelString, NamedArea area, int mode, int style) {
3577
        EntitySelectionElementWithIdInVocabulary element = new EntitySelectionElementWithIdInVocabulary(this,
3578
                formElement, clazz, labelString, area, mode, style);
3579
        adapt(element);
3580
        formElement.addElement(element);
3581
        return element;
3582
    }
3583

    
3584
    /**
3585
     * @param extendedTimePeriodElement
3586
     * @param twistie
3587
     * @return
3588
     */
3589
    public ExtendedTimeDetailSection createExtendedTimeDetailSection(
3590
            ExtendedTimePeriodElement parentElement, int style) {
3591
        ExtendedTimeDetailSection section = new ExtendedTimeDetailSection(this, parentElement,  style);
3592
        parentElement.addElement(section);
3593
        adapt(section);
3594
        return section;
3595
    }
3596
    public ExtendedTimePeriodElement createExtendedTimePeriodElement(
3597
            ICdmFormElement parentElement, String labelString, ExtendedTimePeriod timePeriod, int style) {
3598
        ExtendedTimePeriodElement section = new ExtendedTimePeriodElement(this, parentElement, labelString, timePeriod, style);
3599
        parentElement.addElement(section);
3600
        adapt(section);
3601
        return section;
3602
    }
3603

    
3604

    
3605

    
3606

    
3607
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3608
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3609
//				 initialText, textHeight, style);
3610
//	        adapt(element);
3611
//	        parentElement.addElement(element);
3612
//	        return element;
3613
//	}
3614

    
3615

    
3616

    
3617

    
3618

    
3619

    
3620

    
3621
}
(11-11/57)