Project

General

Profile

Download (176 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.PersonDetailElement;
160
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
161
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailElement;
162
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
163
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
164
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberSection;
165
import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
166
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailElement;
167
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailSection;
168
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeAgentRelationCollectionElement;
169
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeAgentRelationCollectionSection;
170
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailElement;
171
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailSection;
172
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksElement;
173
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
174
import eu.etaxonomy.taxeditor.ui.section.common.ReferenceEntityDetailElement;
175
import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
176
import eu.etaxonomy.taxeditor.ui.section.description.CommonNameSourceElement;
177
import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
178
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
179
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailElement;
180
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
181
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
182
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
183
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
184
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceElement;
185
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
186
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceElement;
187
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
188
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
189
import eu.etaxonomy.taxeditor.ui.section.description.ModifierElement;
190
import eu.etaxonomy.taxeditor.ui.section.description.ModifierSection;
191
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageDetailElement;
192
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
193
import eu.etaxonomy.taxeditor.ui.section.description.ScopeElement;
194
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
195
import eu.etaxonomy.taxeditor.ui.section.description.StateDataElement;
196
import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;
197
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueElement;
198
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueSection;
199
import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;
200
import eu.etaxonomy.taxeditor.ui.section.description.detail.CategoricalDataDetailElement;
201
import eu.etaxonomy.taxeditor.ui.section.description.detail.CommonNameDetailElement;
202
import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
203
import eu.etaxonomy.taxeditor.ui.section.description.detail.IndividualsAssociationDetailElement;
204
import eu.etaxonomy.taxeditor.ui.section.description.detail.QuantitativeDataDetailElement;
205
import eu.etaxonomy.taxeditor.ui.section.description.detail.TaxonInteractionDetailElement;
206
import eu.etaxonomy.taxeditor.ui.section.description.detail.TemporalDataDetailElement;
207
import eu.etaxonomy.taxeditor.ui.section.description.detail.TextDataDetailElement;
208
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDetailElement;
209
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDetailSection;
210
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDtoDetailElement;
211
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDtoDetailSection;
212
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDetailElement;
213
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDetailSection;
214
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDtoDetailElement;
215
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDtoDetailSection;
216
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement;
217
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
218
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfCollectionElement;
219
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfCollectionElementForDto;
220
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfEntityCollectionSection;
221
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfEntityCollectionSectionForNode;
222
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfCollectionElement;
223
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfCollectionElementForDto;
224
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfEntityCollectionSection;
225
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfEntityCollectionSectionForNode;
226
import eu.etaxonomy.taxeditor.ui.section.feature.TermNodeDetailElement;
227
import eu.etaxonomy.taxeditor.ui.section.feature.TermNodeDetailSection;
228
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailElement;
229
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailElementForNode;
230
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailSection;
231
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailSectionForNode;
232
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityCollectionElement;
233
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailElement;
234
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
235
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailElement;
236
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
237
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailElement;
238
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
239
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailElement;
240
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
241
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailElement;
242
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
243
import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
244
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
245
import eu.etaxonomy.taxeditor.ui.section.media.ImageFileElement;
246
import eu.etaxonomy.taxeditor.ui.section.media.MediaDetailElement;
247
import eu.etaxonomy.taxeditor.ui.section.media.MediaMetaElement;
248
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationElement;
249
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartElement;
250
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartSection;
251
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationSection;
252
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
253
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
254
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailSection;
255
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailElement;
256
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailSection;
257
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailElement;
258
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailSection;
259
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailElement;
260
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
261
import eu.etaxonomy.taxeditor.ui.section.name.NameTypeDesignationElement;
262
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusElement;
263
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
264
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailElement;
265
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
266
import eu.etaxonomy.taxeditor.ui.section.name.RuleConsideredElement;
267
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
268
import eu.etaxonomy.taxeditor.ui.section.name.TextTypeDesignationElement;
269
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
270
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreaDetailElement;
271
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
272
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
273
import eu.etaxonomy.taxeditor.ui.section.occurrence.CurrentDeterminationDetailSection;
274
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailElement;
275
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
276
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailElement;
277
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
278
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitMediaSection;
279
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement;
280
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
281
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement;
282
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection;
283
import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
284
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitFacadeDetailElement;
285
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitFacadeDetailSection;
286
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitFacadeGeneralDetailElement;
287
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitFacadeGeneralDetailSection;
288
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailElement;
289
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
290
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopeDetailSection;
291
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopePolyKeyDetailSection;
292
import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
293
import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
294
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElement;
295
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailSection;
296
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationElement;
297
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationSection;
298
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailElement;
299
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
300
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenCurrentDeterminationDetailSection;
301
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailElement;
302
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailSection;
303
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailElement;
304
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailSection;
305
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenSourceCollectionDetailSection;
306
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractSampleDesignationDetailSection;
307
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailElement;
308
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailSection;
309
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoCollectionDetailSection;
310
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoDetailElement;
311
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailElement;
312
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailSection;
313
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailElement;
314
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailSection;
315
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.CurrentSampleDesignationDetailSection;
316
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailElement;
317
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
318
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailElement;
319
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
320
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationDetailElement;
321
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationSection;
322
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.PrimerGeneralDetailElement;
323
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailElement;
324
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailSection;
325
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationHistoryDetailSection;
326
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationTextDetailElement;
327
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceContigFileCollectionDetailSection;
328
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailElement;
329
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
330
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailElement;
331
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
332
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailElement;
333
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
334
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadPherogramCollectionDetailSection;
335
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailElement;
336
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
337
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailElement;
338
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
339
import eu.etaxonomy.taxeditor.ui.section.reference.AdvancedNomenclaturalSourceElement;
340
import eu.etaxonomy.taxeditor.ui.section.reference.AdvancedSourceElement;
341
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
342
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
343
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalSourceElement;
344
import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceAdvancedSection;
345
import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceElement;
346
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement;
347
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
348
import eu.etaxonomy.taxeditor.ui.section.reference.SecundumSourceDetailElement;
349
import eu.etaxonomy.taxeditor.ui.section.reference.SecundumSourceElement;
350
import eu.etaxonomy.taxeditor.ui.section.reference.SecundumSourceSection;
351
import eu.etaxonomy.taxeditor.ui.section.reference.SingleSourceSection;
352
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationElement;
353
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
354
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseElement;
355
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
356
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditElement;
357
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
358
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionElement;
359
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
360
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
361
import eu.etaxonomy.taxeditor.ui.section.supplemental.IdentifiableSourceElement;
362
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerElement;
363
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
364
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsElement;
365
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
366
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
367
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement;
368
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
369
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.DerivedUnitFacadeIdentifierSection;
370
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierElement;
371
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierSection;
372
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement;
373
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
374
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailElement;
375
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
376
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailElement;
377
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailSection;
378
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonOfRelationshipElement;
379
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailElement;
380
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
381
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailElement;
382
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
383
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailElement;
384
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
385
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailElement;
386
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
387
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement;
388
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailSection;
389
import eu.etaxonomy.taxeditor.ui.section.vocabulary.FeatureDetailElement;
390
import eu.etaxonomy.taxeditor.ui.section.vocabulary.LanguageDetailElement;
391
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionElement;
392
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionSection;
393
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitDtoCollectionElement;
394
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitDtoCollectionSection;
395
import eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailSection;
396
import eu.etaxonomy.taxeditor.ui.section.vocabulary.PresenceAbsenceTermDetailElement;
397
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierDtoVocabulariesElement;
398
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesCollectionSection;
399
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesDtoCollectionSection;
400
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesElement;
401
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionElement;
402
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionSection;
403
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyDtoCollectionElement;
404
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyDtoCollectionSection;
405
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionElement;
406
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionSection;
407
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureDtoCollectionElement;
408
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureDtoCollectionSection;
409
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermMediaSection;
410
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailElement;
411
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
412
import eu.etaxonomy.taxeditor.ui.selection.CollectorSelectionElement;
413
import eu.etaxonomy.taxeditor.ui.selection.CommonNameReferenceSelectionElement;
414
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
415
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementWithAbbreviatedTitle;
416
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementWithIdInVocabulary;
417
import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
418
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
419
import eu.etaxonomy.taxeditor.view.detail.CdmSectionPart;
420

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

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

    
433
    @Inject
434
    private IEclipseContext context;
435

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
573
        super.adapt(composite);
574
    }
575

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

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

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

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

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

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

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

    
713

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

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

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

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

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

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

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

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

    
820

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1049

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1332
    private class BoldFontHolder2 {
1333
        private Font normalFont;
1334

    
1335
        private Font boldFont;
1336

    
1337
        public BoldFontHolder2() {
1338
        }
1339

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

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

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

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

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

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

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

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

    
1399

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1781
    }
1782

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

    
1790
    }
1791

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

    
1799
    }
1800

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

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

    
1823

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

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

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

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

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

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

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

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

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

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

    
1899

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2014

    
2015

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2279
    //--------DetailElements------------
2280

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2392
        return element;
2393
    }
2394

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2473
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
2474
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
2475
        addAndAdaptElement(parentElement, element);
2476
        return element;
2477
    }
2478

    
2479
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2480
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2481
        addAndAdaptElement(parentElement, element);
2482
        return element;
2483
    }
2484

    
2485

    
2486
    public FieldUnitFacadeGeneralDetailElement createFieldUnitFacadeGeneralDetailElement(ICdmFormElement parentElement){
2487
        FieldUnitFacadeGeneralDetailElement element = new FieldUnitFacadeGeneralDetailElement(this, parentElement);
2488
        addAndAdaptElement(parentElement, element);
2489
        return element;
2490
    }
2491

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2582
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2583
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2584
        addAndAdaptElement(parentElement, mediaDetailElement);
2585
        return mediaDetailElement;
2586
    }
2587

    
2588
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2589
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2590
        addAndAdaptElement(parentElement, element);
2591
        return element;
2592
    }
2593

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

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

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

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

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

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

    
2630
    /**
2631
     * @param parentElement
2632
     * @param element
2633
     */
2634
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2635
        adapt(element);
2636
        parentElement.addElement(element);
2637
    }
2638

    
2639
    //--------EntityCollectionSection----------
2640
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2641
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2642
        addAndAdaptSection(parentElement, section);
2643
        return section;
2644
    }
2645

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

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

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

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

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

    
2676
    public CreditSection createCreditSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2677
        CreditSection section = new CreditSection(this, conversation, parentElement, style);
2678
        addAndAdaptSection(parentElement, section);
2679
        return section;
2680
    }
2681
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2682
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2683
        addAndAdaptSection(parentElement, section);
2684
        return section;
2685
    }
2686
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, Reference defaultSource, int style){
2687
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, defaultSource, style);
2688
        addAndAdaptSection(parentElement, section);
2689
        return section;
2690
    }
2691

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

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

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

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

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

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

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

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

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

    
2746
//    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2747
//        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2748
//        addAndAdaptSection(parentElement, section);
2749
//        return section;
2750
//    }
2751
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2752
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, style);
2753
        addAndAdaptSection(parentElement, section);
2754
        return section;
2755
    }
2756

    
2757
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, String label, int style){
2758
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, true, label, style);
2759
        addAndAdaptSection(parentElement, section);
2760
        return section;
2761
    }
2762

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

    
2769
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2770
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2771

    
2772
        addAndAdaptSection(parentElement, section);
2773
        return section;
2774
    }
2775

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

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

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

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

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

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

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

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

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

    
2830
    public RecommendedModifierVocabulariesCollectionSection createRecommendedModifierVocabulariesCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2831
        RecommendedModifierVocabulariesCollectionSection section = new RecommendedModifierVocabulariesCollectionSection(this, conversation, parentElement, style);
2832
        addAndAdaptSection(parentElement, section);
2833
        return section;
2834
    }
2835
    public RecommendedModifierVocabulariesDtoCollectionSection createRecommendedModifierVocabulariesDtoCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2836
        RecommendedModifierVocabulariesDtoCollectionSection section = new RecommendedModifierVocabulariesDtoCollectionSection(this, conversation, parentElement, style);
2837
        addAndAdaptSection(parentElement, section);
2838
        return section;
2839
    }
2840

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

    
2847
    public MeasurementUnitDtoCollectionSection createMeasurementUnitDtoCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2848
        MeasurementUnitDtoCollectionSection section = new MeasurementUnitDtoCollectionSection(this, conversation, parentElement, style);
2849
        addAndAdaptSection(parentElement, section);
2850
        return section;
2851
    }
2852
    public StatisticalMeasureCollectionSection createStatisticalMeasureCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2853
        StatisticalMeasureCollectionSection section = new StatisticalMeasureCollectionSection(this, conversation, parentElement, style);
2854
        addAndAdaptSection(parentElement, section);
2855
        return section;
2856
    }
2857

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2972
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2973
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2974
        AbstractEntityCollectionElement<?> element = null;
2975

    
2976
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2977

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

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

    
3180
        //check for parent section when entity is null
3181
        //this happens when AbstractUnboundEntityCollectionSection is used
3182
        if(element==null){
3183
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
3184
                element = new ScopeElement(this,
3185
                        parentElement,
3186
                        (DefinedTerm) entity,
3187
                        removeListener,
3188
                        style);
3189
            }
3190
            else if(parentElement instanceof ModifierSection){
3191
                element = new ModifierElement(this,
3192
                        parentElement,
3193
                        (DefinedTerm) entity,
3194
                        removeListener,
3195
                        style);
3196
            }
3197
        }
3198

    
3199

    
3200
        if (element == null) {
3201
            MessagingUtils.messageDialog(
3202
                    String.format("Error when creating section %s",
3203
                            parentElement.getClass().getSimpleName()),
3204
                    this,
3205
                    String.format("Could not generate collection element for entity of class %s."
3206
                            + " Looks like the case is not yet handled. Check implementation.\n"
3207
                            + "Entity: %s", entity.getClass(), entity.toString()), null);
3208
        }
3209

    
3210
        else{
3211
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
3212
                element.setPersistentBackground(backgroundColor);
3213
            }
3214
            adapt(element);
3215
            parentElement.addElement(element);
3216
        }
3217

    
3218
        return element;
3219
    }
3220

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

    
3264
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3265
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3266
            int style, boolean filterElement) {
3267
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
3268
                parentElement, clazz,
3269
                labelString, selection, mode, style, filterElement);
3270
        adapt(element);
3271
        parentElement.addElement(element);
3272
        return element;
3273
    }
3274

    
3275
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3276
//            ConversationHolder conversation,
3277
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3278
            int style) {
3279
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this,
3280
                parentElement, clazz,
3281
                labelString, selection, mode, style);
3282
        adapt(element);
3283
        parentElement.addElement(element);
3284
        return element;
3285
    }
3286
    public CollectorSelectionElement createCollectorSelectionElement(ICdmFormElement parentElement, String labelString, AgentBase selection, int mode,
3287
          int style) {
3288
    	CollectorSelectionElement element = new CollectorSelectionElement(this, parentElement, 
3289
              labelString, selection, mode, style);
3290
      adapt(element);
3291
      parentElement.addElement(element);
3292
      return element;
3293
  }
3294

    
3295
    public CommonNameReferenceSelectionElement createCommonNameReferenceSelectionElement(ICdmFormElement parentElement, String labelString, Reference selection, int mode,
3296
          int style) {
3297
        CommonNameReferenceSelectionElement element = new CommonNameReferenceSelectionElement(this,
3298
              parentElement, labelString, selection, mode, style);
3299
      adapt(element);
3300
      parentElement.addElement(element);
3301
      return element;
3302
  }
3303

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

    
3347
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3348
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
3349
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this,
3350
                parentElement,
3351
                labelString, selection, mode, style, null);
3352
        adapt(element);
3353
        parentElement.addElement(element);
3354
        return element;
3355
    }
3356
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3357
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style, Integer limit) {
3358
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
3359
                parentElement,
3360
                labelString, selection, mode, style, limit);
3361
        adapt(element);
3362
        parentElement.addElement(element);
3363
        return element;
3364
    }
3365

    
3366

    
3367
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
3368
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
3369
//            int mode, int style) {
3370
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
3371
//                conversation, parentElement, labelString, selection, mode, style);
3372
//        adapt(element);
3373
//        parentElement.addElement(element);
3374
//        return element;
3375
//    }
3376

    
3377
    /** {@inheritDoc} */
3378
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
3379
        LabelElement labelElement = new LabelElement(this, parentElement, text);
3380
        adapt(labelElement);
3381
        parentElement.addElement(labelElement);
3382
        return labelElement;
3383
    }
3384

    
3385

    
3386

    
3387
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
3388
//        Label label = new Label(formElement.getLayoutComposite(), style);
3389
//        label.setText(labelText+" (yyyy-MM-dd)");
3390
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
3391
//        dateElement.initInternalController();
3392
//
3393
//        return dateElement;
3394
//    }
3395

    
3396
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
3397
    	 Label label = new Label(formElement.getLayoutComposite(), style);
3398
         label.setText(labelText);
3399
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3400
         DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
3401
         dateElement.initController(this, formElement);
3402
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3403
         return dateElement;
3404
    }
3405

    
3406
    /**
3407
     * <p>
3408
     * Getter for the field <code>selectionProvider</code>.
3409
     * </p>
3410
     *
3411
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
3412
     */
3413
    public ISelectionProvider getSelectionProvider() {
3414
        return selectionProvider;
3415
    }
3416

    
3417
    /**
3418
     * <p>
3419
     * createDetailedDescriptionDetailElement
3420
     * </p>
3421
     *
3422
     * @param parentElement
3423
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3424
     *            object.
3425
     * @param entity
3426
     *            a
3427
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
3428
     *            object.
3429
     * @param style
3430
     *            a int.
3431
     * @return a
3432
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
3433
     *         object.
3434
     */
3435
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
3436
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
3437
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
3438

    
3439
        if (entity instanceof CategoricalData) {
3440
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
3441
                    (CategoricalData) entity, enabled, style);
3442
        } else if (entity instanceof CommonTaxonName) {
3443
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity, enabled, style);
3444
        } else if (entity instanceof Distribution && !enabled) {
3445
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3446
                    enabled, style);
3447
        } else if (entity instanceof Distribution) {
3448
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3449
                    true, style);
3450
        }else if (entity instanceof IndividualsAssociation) {
3451
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
3452
                    (IndividualsAssociation) entity, enabled, style);
3453
        } else if (entity instanceof QuantitativeData) {
3454
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
3455
                    (QuantitativeData) entity, enabled, style);
3456
        } else if (entity instanceof TaxonInteraction) {
3457
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
3458
                    (TaxonInteraction) entity, enabled, style);
3459
        } else if (entity instanceof TemporalData) {
3460
            detailedDescriptionElement = new TemporalDataDetailElement(this, parentElement, (TemporalData) entity, enabled, style);
3461
        } else if (entity instanceof TextData) {
3462
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, enabled, style);
3463
        }
3464
        else {
3465
            throw new IllegalStateException("There is no interface for the given description element");
3466
        }
3467
//        detailedDescriptionElement.setEnabled(enabled);
3468
        adapt(detailedDescriptionElement);
3469
        parentElement.addElement(detailedDescriptionElement);
3470
        return detailedDescriptionElement;
3471

    
3472
    }
3473

    
3474
    /**
3475
     * Creates a styled text as a part of the form.
3476
     *
3477
     * @param parent
3478
     *            the text parent
3479
     * @param value
3480
     *            the text initial value
3481
     * @param style
3482
     *            the text style
3483
     * @return the text widget
3484
     */
3485
    public StyledText createStyledText(Composite parent, String value, int style) {
3486
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3487
        if (value != null) {
3488
            text.setText(value);
3489
        }
3490
        text.setForeground(getColors().getForeground());
3491
        text.setBackground(getColors().getBackground());
3492
        // text.addFocusListener(visibilityHandler);
3493
        return text;
3494
    }
3495

    
3496
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3497
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3498
        addAndAdaptSection(parentElement, section);
3499
        return section;
3500
    }
3501

    
3502
    /**
3503
     * @param formElement
3504
     * @param conversationHolder
3505
     * @param style
3506
     * @return
3507
     */
3508
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3509
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3510
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3511
        addAndAdaptSection(formElement, section);
3512
        return section;
3513
    }
3514

    
3515

    
3516
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3517
			ICdmFormElement parentElement, int style) {
3518
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3519
		addAndAdaptElement(parentElement, section);
3520
        return section;
3521
	}
3522

    
3523
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3524
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3525
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3526
	        addAndAdaptSection(formElement, section);
3527
	        return section;
3528
	}
3529

    
3530

    
3531
    /**
3532
     * <p>
3533
     * createTextWithLabelElement
3534
     * </p>
3535
     *
3536
     * @param parentElement
3537
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3538
     *            object.
3539
     * @param labelString
3540
     *            a {@link java.lang.String} object.
3541
     * @param initialText
3542
     *            a {@link java.lang.String} object.
3543
     * @param textLimit maximal number of characters allowed
3544
     * @param style
3545
     *            a int.
3546
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
3547
     *         object.
3548
     */
3549
    public RuleConsideredElement createRuleConsideredElement(ICdmFormElement parentElement, String labelString, boolean isShowCodeEdition, int style) {
3550
        RuleConsideredElement element = new RuleConsideredElement(this, parentElement, labelString, isShowCodeEdition, style);
3551
        adapt(element);
3552
        parentElement.addElement(element);
3553
        return element;
3554
    }
3555

    
3556
    /**
3557
     * @param class1
3558
     * @param formElement
3559
     * @param string
3560
     * @param area
3561
     * @param nothing
3562
     * @param style
3563
     * @return
3564
     */
3565
    public EntitySelectionElementWithIdInVocabulary createSelectionElementWithIdInVocabulary(Class<NamedArea> clazz,
3566
            ICdmFormElement formElement, String labelString, NamedArea area, int mode, int style) {
3567
        EntitySelectionElementWithIdInVocabulary element = new EntitySelectionElementWithIdInVocabulary(this,
3568
                formElement, clazz, labelString, area, mode, style);
3569
        adapt(element);
3570
        formElement.addElement(element);
3571
        return element;
3572
    }
3573

    
3574
    /**
3575
     * @param extendedTimePeriodElement
3576
     * @param twistie
3577
     * @return
3578
     */
3579
    public ExtendedTimeDetailSection createExtendedTimeDetailSection(
3580
            ExtendedTimePeriodElement parentElement, int style) {
3581
        ExtendedTimeDetailSection section = new ExtendedTimeDetailSection(this, parentElement,  style);
3582
        parentElement.addElement(section);
3583
        adapt(section);
3584
        return section;
3585
    }
3586
    public ExtendedTimePeriodElement createExtendedTimePeriodElement(
3587
            ICdmFormElement parentElement, String labelString, ExtendedTimePeriod timePeriod, int style) {
3588
        ExtendedTimePeriodElement section = new ExtendedTimePeriodElement(this, parentElement, labelString, timePeriod, style);
3589
        parentElement.addElement(section);
3590
        adapt(section);
3591
        return section;
3592
    }
3593

    
3594

    
3595

    
3596

    
3597
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3598
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3599
//				 initialText, textHeight, style);
3600
//	        adapt(element);
3601
//	        parentElement.addElement(element);
3602
//	        return element;
3603
//	}
3604

    
3605

    
3606

    
3607

    
3608

    
3609

    
3610

    
3611
}
(11-11/57)