Project

General

Profile

Download (173 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 *
3
 */
4
package eu.etaxonomy.taxeditor.ui.element;
5

    
6
import java.util.ArrayList;
7
import java.util.Comparator;
8
import java.util.HashSet;
9
import java.util.List;
10
import java.util.Map;
11
import java.util.Set;
12

    
13
import javax.inject.Inject;
14

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

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

    
406
/**
407
 * CdmFormFactory class.
408
 *
409
 * @author n.hoffmann
410
 * @created Feb 24, 2010
411
 */
412
public class CdmFormFactory extends FormToolkit {
413

    
414
    private BoldFontHolder2 boldFontHolder2;
415
    private MouseListener selectionMouseHandler;
416
    private FocusListener selectionFocusHandler;
417

    
418
    @Inject
419
    private IEclipseContext context;
420

    
421
    private final Set<SelectionListener> selectionListenerList = new HashSet<>();
422

    
423
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<>();
424

    
425
    private final int orientation = Window.getDefaultOrientation();
426
    private ISelectionProvider selectionProvider;
427

    
428
    /** Constant <code>EMPTY_SELECTION</code> */
429
    public static ISelection EMPTY_SELECTION = new ISelection() {
430
        @Override
431
        public boolean isEmpty() {
432
            return true;
433
        }
434
    };
435

    
436
    /**
437
     * @author n.hoffmann
438
     * @date Jan 25, 2010
439
     */
440
    private class SelectionMouseHandler extends MouseAdapter {
441
        @Override
442
        public void mouseDown(MouseEvent e) {
443
            notifySelectionListeners(e);
444
        }
445
    }
446

    
447
    /**
448
     * @author n.hoffmann
449
     * @date Jan 25, 2010
450
     */
451
    private class SelectionFocusHandler extends FocusAdapter {
452
        @Override
453
        public void focusGained(FocusEvent e) {
454
            notifySelectionListeners(e);
455
        }
456
    }
457

    
458
    private void notifySelectionListeners(TypedEvent e) {
459
        Event event = new Event();
460
        event.widget = e.widget;
461
        SelectionEvent selectionEvent = new SelectionEvent(event);
462

    
463
        for (SelectionListener listener : selectionListenerList) {
464
            listener.widgetSelected(selectionEvent);
465
        }
466
    }
467

    
468
    public CdmFormFactory(Display display) {
469
        this(display, null);
470
    }
471

    
472
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
473
        super(display);
474
        this.selectionProvider = selectionProvider;
475
        init();
476
    }
477

    
478
    private void init() {
479
        boldFontHolder2 = new BoldFontHolder2();
480
        selectionMouseHandler = new SelectionMouseHandler();
481
        selectionFocusHandler = new SelectionFocusHandler();
482
    }
483

    
484
    public IEclipseContext getContext() {
485
        return context;
486
    }
487

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

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

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

    
546
    @Override
547
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
548
        if (trackFocus) {
549
            control.addFocusListener(selectionFocusHandler);
550
        }
551
        super.adapt(control, trackFocus, trackKeyboard);
552
    }
553

    
554
    @Override
555
    public void adapt(Composite composite) {
556
        composite.addMouseListener(selectionMouseHandler);
557

    
558
        super.adapt(composite);
559
    }
560

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

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

    
605
    /**
606
     * createEmptyCell
607
     *
608
     * @param parent
609
     *            a {@link org.eclipse.swt.widgets.Composite} object.
610
     * @return a {@link org.eclipse.swt.widgets.Label} object.
611
     */
612
    public Label createEmptyCell(Composite parent) {
613
        return this.createLabel(parent, null);
614
    }
615

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

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

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

    
691
    public TranslatableRepresentationElement createTranslatableRepresentationElementDto(ICdmFormElement parentElement, Representation representation, TermDto term,int textHeight, int style, boolean fillDetails) {
692
        TranslatableRepresentationElement element = new TranslatableRepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
693
        adapt(element);
694
        parentElement.addElement(element);
695
        return element;
696
    }
697

    
698

    
699
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
700
            KeyStatement keyStatement, int textHeight, int style) {
701
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
702
                textHeight, style);
703
        adapt(element);
704
        parentElement.addElement(element);
705
        return element;
706
    }
707

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

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

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

    
767
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
768
                textLimit, style);
769
        adapt(element);
770
        parentElement.addElement(element);
771
        return element;
772
    }
773

    
774
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
775
            int textHeight, int style) {
776
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
777
        adapt(element);
778
        parentElement.addElement(element);
779
        return element;
780
    }
781

    
782
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
783
            LSID initialLsid, int style) {
784
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
785
        adapt(element);
786
        parentElement.addElement(element);
787
        return element;
788
    }
789

    
790
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
791
            URI initialUri, int style) {
792
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
793
        adapt(element);
794
        parentElement.addElement(element);
795
        return element;
796
    }
797
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
798
            URI initialUri,Integer textHeight, int style) {
799
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, textHeight, style);
800
        adapt(element);
801
        parentElement.addElement(element);
802
        return element;
803
    }
804

    
805

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

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

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

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

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

    
897
	public BigDecimalWithLabelElement createBigDecimalTextWithLabelElement(
898
            ICdmFormElement parentElement, String labelString,
899
            Number initialNumber, int style) {
900
	    BigDecimalWithLabelElement element = new BigDecimalWithLabelElement(this,
901
                parentElement, labelString, initialNumber, style);
902
        adapt(element);
903
        parentElement.addElement(element);
904
        return element;
905
    }
906

    
907
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
908
            String labelString, LanguageString languageString, int style) {
909
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
910
    }
911

    
912
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
913
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
914
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
915
                languageString, height, isMultiLine, style);
916
        adapt(element);
917
        parentElement.addElement(element);
918
        return element;
919
    }
920

    
921
    /**
922
     * <p>
923
     * createKeyValueViewerElement
924
     * </p>
925
     *
926
     * @param parentElement
927
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
928
     *            object.
929
     * @param keyHeading
930
     *            a {@link java.lang.String} object.
931
     * @param valueHeading
932
     *            a {@link java.lang.String} object.
933
     * @param map
934
     *            a {@link java.util.Map} object.
935
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
936
     *         object.
937
     */
938
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
939
            String valueHeading, Map<Object, Object> map) {
940
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
941
        adapt(element);
942
        parentElement.addElement(element);
943
        return element;
944
    }
945
    /**
946
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
947
     */
948
    @Deprecated
949
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
950
            ICdmFormElement parentElement, String labelString, T selection, int style) {
951
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString, selection, true, style);
952
        adapt(element);
953
        parentElement.addElement(element);
954
        return element;
955
    }
956

    
957
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
958
            TermType termType,
959
            ICdmFormElement parentElement,
960
            String labelString,
961
            T selection,
962
            int style,
963
            Comparator<T> comparator) {
964
        return this.createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, true, style, false, comparator);
965
    }
966

    
967
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
968
			TermType termType,
969
			ICdmFormElement parentElement,
970
			String labelString,
971
			T selection,
972
			boolean addEmptyElement,
973
			int style) {
974
        return this.createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, addEmptyElement, style, false, null);
975
	}
976

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

    
994
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
995
            List<T> terms,
996
            ICdmFormElement parentElement,
997
            String labelString,
998
            T selection,
999
            int style) {
1000
        return  this.createDefinedTermComboElement(null, null, terms, parentElement, labelString, selection, true, style, false, null);
1001
    }
1002
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1003
	        List<T> terms,
1004
	        ICdmFormElement parentElement,
1005
	        String labelString,
1006
	        T selection,
1007
	        boolean addEmptyElement,
1008
	        int style) {
1009
	    return  this.createDefinedTermComboElement(null, null, terms, parentElement, labelString, selection, addEmptyElement, style, false, null);
1010
	}
1011
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1012
			TermType termType,
1013
			ICdmFormElement parentElement,
1014
			String labelString,
1015
			T selection,
1016
			boolean addEmptyElement,
1017
			int style,
1018
			boolean useAbbrevLabel) {
1019
		return createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
1020
	}
1021

    
1022

    
1023
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1024
            TermVocabulary<?> termVocabulary,
1025
            ICdmFormElement parentElement,
1026
            String labelString,
1027
            T selection,
1028
            int style) {
1029
        return this.createDefinedTermComboElement(null, termVocabulary, null, parentElement, labelString, selection, true, style, false, null);
1030
    }
1031

    
1032
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1033
	        TermVocabulary<?> termVocabulary,
1034
	        ICdmFormElement parentElement,
1035
	        String labelString,
1036
	        T selection,
1037
	        boolean addEmptyElement,
1038
	        int style,
1039
	        boolean useAbbrevLabel) {
1040
	    return createDefinedTermComboElement(null, termVocabulary, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
1041
	}
1042

    
1043
	private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1044
	        TermType termType,
1045
	        TermVocabulary<?> termVocabulary,
1046
	        List<T> terms,
1047
	        ICdmFormElement parentElement,
1048
	        String labelString,
1049
	        T selection,
1050
	        boolean addEmptyElement,
1051
	        int style,
1052
	        boolean useAbbrevLabel,
1053
	        Comparator<T> comparator) {
1054
	    if(termType!=null){
1055
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1056
	        adapt(element);
1057
	        parentElement.addElement(element);
1058
	        return element;
1059
	    }
1060
	    else if(termVocabulary!=null){
1061
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1062
	        if (comparator!= null){
1063
	        	element.setTermComparator(comparator);
1064
	        }
1065
	        adapt(element);
1066
	        parentElement.addElement(element);
1067
	        return element;
1068
	    }else if (terms != null){
1069

    
1070
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, terms, labelString, selection, addEmptyElement, style, useAbbrevLabel);
1071
            if (comparator!= null){
1072
                element.setTermComparator(comparator);
1073
            }
1074
            adapt(element);
1075
            parentElement.addElement(element);
1076
            return element;
1077
	    }
1078
	    else {
1079
	        //this should never happen
1080
	        return null;
1081
	    }
1082
	}
1083

    
1084
	   private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1085
	            TermType termType,
1086
	            TermVocabulary<?> termVocabulary,
1087
	            List<T> terms,
1088
	            ICdmFormElement parentElement,
1089
	            String labelString,
1090
	            TermDto selection,
1091
	            boolean addEmptyElement,
1092
	            int style,
1093
	            boolean useAbbrevLabel,
1094
	            Comparator<T> comparator) {
1095
	        if(termType!=null){
1096
	            TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1097
	            adapt(element);
1098
	            parentElement.addElement(element);
1099
	            return element;
1100
	        }
1101

    
1102
	        else {
1103
	            //this should never happen
1104
	            return null;
1105
	        }
1106
	    }
1107

    
1108
	public NameRelationshipTypeCombo createNameRelationshipTypeCombo(ICdmFormElement parentElement,
1109
            String labelString,
1110
            int style,
1111
            boolean useAbbrevLabel,
1112
            Comparator<NameRelationshipType> comparator) {
1113

    
1114
        NameRelationshipTypeCombo<InverseTermWrapper> element = new NameRelationshipTypeCombo(this, parentElement, labelString, true, style, useAbbrevLabel, comparator);
1115
        adapt(element);
1116
        parentElement.addElement(element);
1117
        return element;
1118
    }
1119

    
1120
	public MisappliedRelationshipComboElement createMisappliedRelationshipComboElement(
1121
	        ICdmFormElement parentElement,
1122
            String labelString,
1123
            TaxonRelationshipType selection,
1124
            int style) {
1125
	    MisappliedRelationshipComboElement combo = new MisappliedRelationshipComboElement(this, parentElement, labelString, selection, false, style, false);
1126
	    adapt(combo);
1127
        parentElement.addElement(combo);
1128
        return combo;
1129
    }
1130

    
1131
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1132
	        Class<T> enumComboType, ICdmFormElement parentElement,
1133
	        int style, boolean hasNullValue) {
1134
	    return createEnumComboElement(enumComboType, parentElement, null, style, hasNullValue);
1135
	}
1136
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1137
            Class<T> enumComboType, ICdmFormElement parentElement,
1138
            int style) {
1139
        return createEnumComboElement(enumComboType, parentElement, null, style, false);
1140
    }
1141

    
1142
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1143
			Class<T> enumComboType, ICdmFormElement parentElement, Comparator<T> comparator,
1144
			int style, boolean hasNullValue) {
1145
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, comparator, style, hasNullValue);
1146
        adapt(element);
1147
        parentElement.addElement(element);
1148
        return element;
1149
    }
1150

    
1151
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
1152
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
1153
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1154
	    adapt(element);
1155
	    parentElement.addElement(element);
1156
	    return element;
1157
	}
1158

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

    
1167
    /**
1168
     * <p>
1169
     * createBrowserElement
1170
     * </p>
1171
     *
1172
     * @param imageUri
1173
     *            a {@link java.net.URI} object.
1174
     * @param style
1175
     *            a int.
1176
     * @param parentElement
1177
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1178
     *            object.
1179
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
1180
     *         object.
1181
     */
1182
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
1183
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
1184
        adapt(element);
1185
        parentElement.addElement(element);
1186
        return element;
1187
    }
1188

    
1189
    /**
1190
     * <p>
1191
     * createImageElement
1192
     * </p>
1193
     *
1194
     * @param parentElement
1195
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1196
     *            object.
1197
     * @param imageUri
1198
     *            a {@link java.net.URI} object.
1199
     * @param style
1200
     *            a int.
1201
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1202
     */
1203
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1204
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1205
        adapt(element);
1206
        parentElement.addElement(element);
1207
        return element;
1208
    }
1209

    
1210
    /**
1211
     * <p>
1212
     * createTextActionElement
1213
     * </p>
1214
     *
1215
     * @param labelString
1216
     *            a {@link java.lang.String} object.
1217
     * @param initialText
1218
     *            a {@link java.lang.String} object.
1219
     * @param style
1220
     *            a int.
1221
     * @param parentElement
1222
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1223
     *            object.
1224
     * @param buttonLabel
1225
     *            a {@link java.lang.String} object.
1226
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
1227
     *         object.
1228
     */
1229
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
1230
            String buttonLabel, String initialText, int style) {
1231
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
1232
                style);
1233
        adapt(element);
1234
        parentElement.addElement(element);
1235
        return element;
1236
    }
1237

    
1238
    /**
1239
     * <p>
1240
     * createCheckbox
1241
     * </p>
1242
     *
1243
     * @param parentElement
1244
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1245
     *            object.
1246
     * @param label
1247
     *            a {@link java.lang.String} object.
1248
     * @param initialState
1249
     *            a boolean.
1250
     * @param style
1251
     *            a int.
1252
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1253
     *         object.
1254
     */
1255
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1256
        if(initialState==null){
1257
            initialState = Boolean.FALSE;
1258
        }
1259
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1260
        adapt(element);
1261
        parentElement.addElement(element);
1262
        return element;
1263
    }
1264

    
1265
    /**
1266
     * Creates a section as a part of the form.
1267
     *
1268
     * @return the section widget
1269
     * @param section
1270
     *            a
1271
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1272
     *            object.
1273
     */
1274
    public Section adapt(AbstractFormSection section) {
1275
        section.setMenu(section.getLayoutComposite().getMenu());
1276
        adapt(section, true, true);
1277

    
1278
        // handle focus and property change events for cdm use
1279
        section.addFocusListener(selectionFocusHandler);
1280
        section.setPropertyChangeListeners(propertyChangeListeners);
1281

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

    
1292
        if (section.getToggle() != null) {
1293
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1294
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1295
        }
1296

    
1297
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1298

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

    
1310
    private class BoldFontHolder2 {
1311
        private Font normalFont;
1312

    
1313
        private Font boldFont;
1314

    
1315
        public BoldFontHolder2() {
1316
        }
1317

    
1318
        public Font getBoldFont(Font font) {
1319
            createBoldFont(font);
1320
            return boldFont;
1321
        }
1322

    
1323
        private void createBoldFont(Font font) {
1324
            if (normalFont == null || !normalFont.equals(font)) {
1325
                normalFont = font;
1326
                dispose();
1327
            }
1328
            if (boldFont == null) {
1329
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1330
            }
1331
        }
1332

    
1333
        public void dispose() {
1334
            if (boldFont != null) {
1335
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1336
                boldFont = null;
1337
            }
1338
        }
1339
    }
1340

    
1341
    /**
1342
     * <p>
1343
     * createToggleableTextField
1344
     * </p>
1345
     *
1346
     * @param parentElement
1347
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1348
     *            object.
1349
     * @param labelString
1350
     *            a {@link java.lang.String} object.
1351
     * @param initialText
1352
     *            a {@link java.lang.String} object.
1353
     * @param initialState
1354
     *            a boolean.
1355
     * @param style
1356
     *            a int.
1357
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1358
     *         object.
1359
     */
1360
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1361
            String initialText, boolean initialState, int style) {
1362
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1363
                initialState, style | orientation);
1364

    
1365
        adapt(element);
1366
        parentElement.addElement(element);
1367
        return element;
1368
    }
1369

    
1370
    /**
1371
     * <p>
1372
     * createTimePeriodElement
1373
     * </p>
1374
     *
1375
     * @param parentElement
1376
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1377
     *            object.
1378
     * @param labelString
1379
     *            a {@link java.lang.String} object.
1380
     * @param timePeriod
1381
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1382
     * @param style
1383
     *            a int.
1384
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1385
     *         object.
1386
     */
1387
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1388
            TimePeriod timePeriod, int style) {
1389
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1390
        adapt(element);
1391
        parentElement.addElement(element);
1392
        return element;
1393
    }
1394

    
1395
    /**
1396
     * <p>
1397
     * createVerbatimTimePeriodElement
1398
     * </p>
1399
     *
1400
     * @param parentElement
1401
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1402
     *            object.
1403
     * @param labelString
1404
     *            a {@link java.lang.String} object.
1405
     * @param timePeriod
1406
     *            a {@link eu.etaxonomy.cdm.model.common.VerbatimTimePeriod} object.
1407
     * @param style
1408
     *            a int.
1409
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.VerbatimTimePeriodElement}
1410
     *         object.
1411
     */
1412
    public VerbatimTimePeriodElement createVerbatimTimePeriodElement(ICdmFormElement parentElement, String labelString,
1413
            VerbatimTimePeriod timePeriod, int style) {
1414
        VerbatimTimePeriodElement element = new VerbatimTimePeriodElement(this, parentElement, labelString, timePeriod, style);
1415
        adapt(element);
1416
        parentElement.addElement(element);
1417
        return element;
1418
    }
1419

    
1420

    
1421

    
1422
	/**
1423
	 * <p>
1424
	 * createGatheringEventUnitElement
1425
	 * </p>
1426
	 *
1427
	 * @param parentElement
1428
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1429
	 *            object.
1430
	 * @param labelString
1431
	 *            a {@link java.lang.String} object.
1432
	 * @param timePeriod
1433
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1434
	 * @param style
1435
	 *            a int.
1436
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1437
	 *         object.
1438
	 */
1439
	public GatheringEventUnitElement createGatheringEventUnitElement(
1440
			ICdmFormElement parentElement,
1441
			String labelString,
1442
			DerivedUnitFacade gatheringEvent,
1443
			MinMaxTextSection.UnitType unitType,
1444
			int style) {
1445
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1446
				parentElement,
1447
				labelString,
1448
				gatheringEvent,
1449
				unitType,
1450
				style);
1451
		adapt(element);
1452
		parentElement.addElement(element);
1453
		return element;
1454
	}
1455

    
1456
    /**
1457
     * <p>
1458
     * createPointElement
1459
     * </p>
1460
     *
1461
     * @param style
1462
     *            a int.
1463
     * @param parentElement
1464
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1465
     *            object.
1466
     * @param point
1467
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1468
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1469
     */
1470
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1471
        PointElement element = new PointElement(this, parentElement, point, style);
1472
        adapt(element);
1473
        parentElement.addElement(element);
1474
        return element;
1475
    }
1476

    
1477
    /**
1478
     * Creates an empty section with the given message.<br>
1479
     * If message is <code>null</code> a default message will be displayed.
1480
     */
1481
    public EmptySection createEmptySection(String message, CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1482
        EmptySection section = new EmptySection(message, formFactory, parentElement, style);
1483
        parentElement.addElement(section);
1484
        adapt(section);
1485
        return section;
1486
    }
1487

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

    
1508
    /**
1509
     * <p>
1510
     * createVerbatimDateDetailSection
1511
     * </p>
1512
     *
1513
     * @param parentElement
1514
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1515
     *            object.
1516
     * @param style
1517
     *            a int.
1518
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.VerbatimDateDetailSection}
1519
     *         object.
1520
     */
1521
    public DateDetailSection<VerbatimTimePeriod> createVerbatimDateDetailSection(ICdmFormElement parentElement, int style) {
1522
        DateDetailSection<VerbatimTimePeriod> section
1523
        	= new DateDetailSection<VerbatimTimePeriod>(this, parentElement, true, style);
1524
        parentElement.addElement(section);
1525
        adapt(section);
1526
        return section;
1527
    }
1528

    
1529
	/**
1530
	 * <p>
1531
	 * createDateDetailSection
1532
	 * </p>
1533
	 *
1534
	 * @param parentElement
1535
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1536
	 *            object.
1537
	 * @param style
1538
	 *            a int.
1539
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1540
	 *         object.
1541
	 */
1542
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1543
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1544
		parentElement.addElement(section);
1545
		adapt(section);
1546
		return section;
1547
	}
1548

    
1549
    /**
1550
     * <p>
1551
     * createPartialElement
1552
     * </p>
1553
     *
1554
     * @param parentElement
1555
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1556
     *            object.
1557
     * @param labelString
1558
     *            a {@link java.lang.String} object.
1559
     * @param partial
1560
     *            a {@link org.joda.time.Partial} object.
1561
     * @param style
1562
     *            a int.
1563
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1564
     *         object.
1565
     */
1566
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1567
            int style) {
1568
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1569
        adapt(element);
1570
        parentElement.addElement(element);
1571
        return element;
1572
    }
1573

    
1574
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial, boolean showYear,
1575
            int style) {
1576
        PartialElement element = new PartialElement(this, parentElement, labelString, style, showYear);
1577
        adapt(element);
1578
        parentElement.addElement(element);
1579
        return element;
1580
    }
1581

    
1582
    /**
1583
     * <p>
1584
     * addSelectionListener
1585
     * </p>
1586
     *
1587
     * @param listener
1588
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1589
     */
1590
    public void addSelectionListener(SelectionListener listener) {
1591
        selectionListenerList.add(listener);
1592
    }
1593

    
1594
    /**
1595
     * <p>
1596
     * removeSelectionListener
1597
     * </p>
1598
     *
1599
     * @param listener
1600
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1601
     */
1602
    public void removeSelectionListener(SelectionListener listener) {
1603
        if (listener == null) {
1604
            MessagingUtils.error(this.getClass(),
1605
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1606
        } else {
1607
            selectionListenerList.remove(listener);
1608
        }
1609
    }
1610

    
1611
    /**
1612
     * <p>
1613
     * addPropertyChangeListener
1614
     * </p>
1615
     *
1616
     * @param listener
1617
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1618
     *            object.
1619
     */
1620
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1621
        if (propertyChangeListeners.contains(listener)) {
1622
            return;
1623
        }
1624
        propertyChangeListeners.add(0, listener);
1625
    }
1626

    
1627
    /**
1628
     * <p>
1629
     * removePropertyChangeListener
1630
     * </p>
1631
     *
1632
     * @param listener
1633
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1634
     *            object.
1635
     */
1636
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1637
        propertyChangeListeners.remove(listener);
1638
    }
1639

    
1640
    /**
1641
     * @return the propertyChangeListeners
1642
     */
1643
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1644
        return propertyChangeListeners;
1645
    }
1646

    
1647
    /**
1648
     * <p>
1649
     * createHorizontalSeparator
1650
     * </p>
1651
     *
1652
     * @param parentElement
1653
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1654
     *            object.
1655
     * @param style
1656
     *            a int.
1657
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1658
     */
1659
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1660
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1661
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1662
        return separator;
1663
    }
1664

    
1665
    /**
1666
     * <p>
1667
     * createVersionElement
1668
     * </p>
1669
     *
1670
     * @param parentElement
1671
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1672
     *            object.
1673
     * @param entity
1674
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1675
     *            object.
1676
     * @param style
1677
     *            a int.
1678
     * @return a
1679
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1680
     *         object.
1681
     */
1682
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1683
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1684
        adapt(element);
1685
        parentElement.addElement(element);
1686
        return element;
1687
    }
1688

    
1689
    /**
1690
     * @param cdmBaseSection
1691
     * @param object
1692
     * @param style
1693
     * @return
1694
     */
1695
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1696
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1697
        adapt(element);
1698
        parentElement.addElement(element);
1699
        return element;
1700
    }
1701

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

    
1723
    /**
1724
     * @param parent
1725
     * @param i
1726
     * @return
1727
     */
1728
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1729
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1730
        parentElement.addElement(section);
1731
        adapt(section);
1732
        return section;
1733
    }
1734

    
1735
    /**
1736
     * <p>
1737
     * createEmptyElement
1738
     * </p>
1739
     *
1740
     * @param parentElement
1741
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1742
     *            object.
1743
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1744
     */
1745
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1746
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1747
        adapt(element);
1748
        parentElement.addElement(element);
1749
        return element;
1750
    }
1751

    
1752
    /**
1753
     * <p>
1754
     * createHeadlineSection
1755
     * </p>
1756
     *
1757
     * @param parentElement
1758
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1759
     *            object.
1760
     * @return a
1761
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1762
     *         object.
1763
     */
1764
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1765
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1766
        parentElement.addElement(section);
1767
        adapt(section);
1768
        return section;
1769
    }
1770

    
1771
    /**
1772
     * <p>
1773
     * createParsingMessageElement
1774
     * </p>
1775
     *
1776
     * @param parentElement
1777
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1778
     *            object.
1779
     * @param parserProblem
1780
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1781
     *            object.
1782
     * @param style
1783
     *            a int.
1784
     * @return a
1785
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1786
     *         object.
1787
     */
1788
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1789
            ParserProblem parserProblem, int style) {
1790
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1791
        adapt(element);
1792
        parentElement.addElement(element);
1793
        return element;
1794
    }
1795

    
1796
    public DefinedTermDetailSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1797
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1798

    
1799
        DefinedTermDetailSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1800
                selectionProvider, style);
1801

    
1802
        parentElement.addElement(section);
1803
        adapt(section);
1804
        return section;
1805

    
1806
    }
1807

    
1808
    public TermMediaSection createTermMediaSection(ConversationHolder conversation,
1809
            ICdmFormElement parentElement, int style) {
1810
        TermMediaSection section = new TermMediaSection(this, conversation, parentElement, style);
1811
        parentElement.addElement(section);
1812
        adapt(section);
1813
        return section;
1814

    
1815
    }
1816

    
1817
    public DerivedUnitMediaSection createDerivedUnitMediaSection(ConversationHolder conversation,
1818
            ICdmFormElement parentElement, int style) {
1819
        DerivedUnitMediaSection section = new DerivedUnitMediaSection(this, conversation, parentElement, style);
1820
        parentElement.addElement(section);
1821
        adapt(section);
1822
        return section;
1823

    
1824
    }
1825

    
1826
    /**
1827
     * @param definedTermClass
1828
     * @param formElement
1829
     * @param style
1830
     * @return
1831
     */
1832
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1833
            AbstractCdmDetailSection parentElement, int style) {
1834
        AbstractCdmDetailElement element = null;
1835

    
1836
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1837
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1838
        } else if (definedTermClass.equals(Feature.class)) {
1839
            element = new FeatureDetailElement(this, parentElement);
1840
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1841
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1842
        } else {
1843
            element = new DefinedTermDetailElement(this, parentElement);
1844
        }
1845

    
1846

    
1847
        adapt(element);
1848
        parentElement.addElement(element);
1849
        return element;
1850
    }
1851

    
1852
    public CharacterNodeDetailSection createCharacterNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1853
        CharacterNodeDetailSection section = new CharacterNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1854
        addAndAdaptSection(parentElement, section);
1855
        return section;
1856
    }
1857

    
1858
    public CharacterNodeDtoDetailSection createCharacterNodeDtoDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1859
        CharacterNodeDtoDetailSection section = new CharacterNodeDtoDetailSection(this, conversation, parentElement, selectionProvider, style);
1860
        addAndAdaptSection(parentElement, section);
1861
        return section;
1862
    }
1863

    
1864
    public CharacterDetailSection createCharacterDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1865
        CharacterDetailSection section = new CharacterDetailSection(this, conversation, parentElement, selectionProvider, style);
1866
        addAndAdaptSection(parentElement, section);
1867
        return section;
1868
    }
1869

    
1870
    public CharacterDtoDetailSection createCharacterDtoDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1871
        CharacterDtoDetailSection section = new CharacterDtoDetailSection(this, conversation, parentElement, selectionProvider, style);
1872
        addAndAdaptSection(parentElement, section);
1873
        return section;
1874
    }
1875

    
1876
    public CharacterNodeDetailElement createCharacterNodeDetailElement(ICdmFormElement parentElement, int style){
1877
        CharacterNodeDetailElement element = new CharacterNodeDetailElement(this, parentElement);
1878
        addAndAdaptElement(parentElement, element);
1879
        return element;
1880
    }
1881
    public CharacterNodeDtoDetailElement createCharacterNodeDtoDetailElement(ICdmFormElement parentElement, int style){
1882
        CharacterNodeDtoDetailElement element = new CharacterNodeDtoDetailElement(this, parentElement);
1883
        addAndAdaptElement(parentElement, element);
1884
        return element;
1885
    }
1886

    
1887
    public CharacterDetailElement createCharacterDetailElement(ICdmFormElement parentElement, int style){
1888
        CharacterDetailElement element = new CharacterDetailElement(this, parentElement);
1889
        addAndAdaptElement(parentElement, element);
1890
        return element;
1891
    }
1892
    public CharacterDtoDetailElement createCharacterDtoDetailElement(ICdmFormElement parentElement, int style){
1893
        CharacterDtoDetailElement element = new CharacterDtoDetailElement(this, parentElement);
1894
        addAndAdaptElement(parentElement, element);
1895
        return element;
1896
    }
1897

    
1898
    public FeatureTreeDetailElement createFeatureTreeDetailElement(ICdmFormElement parentElement, int style){
1899
        FeatureTreeDetailElement element = new FeatureTreeDetailElement(this, parentElement);
1900
        addAndAdaptElement(parentElement, element);
1901
        return element;
1902
    }
1903

    
1904
    /**
1905
     * @param parentElement
1906
     * @param style
1907
     * @return
1908
     */
1909
    public AbstractCdmDetailElement<TermTree> createFeatureTreeDetailElementForTree(
1910
            AbstractCdmDetailSection<TermTree> parentElement, int style) {
1911
        FeatureTreeDetailElementForNode element = new FeatureTreeDetailElementForNode(this, parentElement);
1912
        addAndAdaptElement(parentElement, element);
1913
        return element;
1914
    }
1915

    
1916
    public FeatureNodeDetailElement createFeatureNodeDetailElement(ICdmFormElement parentElement, int style){
1917
        FeatureNodeDetailElement element = new FeatureNodeDetailElement(this, parentElement);
1918
        addAndAdaptElement(parentElement, element);
1919
        return element;
1920
    }
1921

    
1922

    
1923
    //--------DetailSections---------
1924
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1925
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1926
        addAndAdaptSection(parentElement, section);
1927
        return section;
1928
    }
1929

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

    
1936
    public FeatureTreeDetailSection createFeatureTreeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1937
        FeatureTreeDetailSection section = new FeatureTreeDetailSection(this, conversation, parentElement, selectionProvider, style);
1938
        addAndAdaptSection(parentElement, section);
1939
        return section;
1940
    }
1941
    public FeatureTreeDetailSectionForNode createFeatureTreeDetailSectionForTree(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1942
        FeatureTreeDetailSectionForNode section = new FeatureTreeDetailSectionForNode(this, conversation, parentElement, selectionProvider, style);
1943
        addAndAdaptSection(parentElement, section);
1944
        return section;
1945
    }
1946

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

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

    
1959
    public OriginalSourceAdvancedSection createOriginalSourceAdvancedSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1960
        OriginalSourceAdvancedSection section = new OriginalSourceAdvancedSection(this, conversation, parentElement, selectionProvider, style);
1961
        addAndAdaptSection(parentElement, section);
1962
        return section;
1963
    }
1964

    
1965
    public AdvancedSourceElement createAdvancedSourceDetailElement(ICdmFormElement parentElement, int style){
1966
        AdvancedSourceElement element = new AdvancedSourceElement(this, parentElement);
1967
        addAndAdaptElement(parentElement, element);
1968
        return element;
1969
    }
1970

    
1971
    public AdvancedSourceElement createAdvancedNomenclaturalSourceDetailElement(ICdmFormElement parentElement, int style){
1972
        AdvancedNomenclaturalSourceElement element = new AdvancedNomenclaturalSourceElement(this, parentElement);
1973
        addAndAdaptElement(parentElement, element);
1974
        return element;
1975
    }
1976

    
1977
    public SingleSourceSection createSingleSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, CdmBase cdmEntity, ISelectionProvider selectionProvider, String label, int style){
1978
        SingleSourceSection section = new SingleSourceSection(this, conversation, parentElement, cdmEntity, selectionProvider, style, label);
1979
        addAndAdaptSection(parentElement, section);
1980
        return section;
1981
    }
1982

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

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

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

    
2001
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2002
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
2003
        addAndAdaptSection(parentElement, section);
2004
        return section;
2005
    }
2006

    
2007
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2008
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
2009
        addAndAdaptSection(parentElement, section);
2010
        return section;
2011
    }
2012

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

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

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

    
2031

    
2032

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2213
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2214
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
2215
        addAndAdaptSection(parentElement, section);
2216
        return section;
2217
    }
2218

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

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

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

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

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

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

    
2255
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2256
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style, true);
2257
        addAndAdaptSection(parentElement, section);
2258
        return section;
2259
    }
2260

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

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

    
2273
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2274
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
2275
        addAndAdaptSection(parentElement, section);
2276
        return section;
2277
    }
2278

    
2279
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2280
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
2281
        addAndAdaptSection(parentElement, section);
2282
        return section;
2283
    }
2284

    
2285
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2286
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
2287
        addAndAdaptSection(parentElement, section);
2288
        return section;
2289
    }
2290

    
2291
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
2292
        parentElement.addElement(section);
2293
        adapt(section);
2294
    }
2295

    
2296
    //--------DetailElements------------
2297

    
2298
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
2299
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
2300
        addAndAdaptElement(parentElement, element);
2301
        return element;
2302
    }
2303

    
2304
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
2305
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
2306
        addAndAdaptElement(parentElement, element);
2307
        return element;
2308
    }
2309

    
2310
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
2311
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
2312
        addAndAdaptElement(parentElement, element);
2313
        return element;
2314
    }
2315

    
2316
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
2317
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
2318
        addAndAdaptElement(parentElement, element);
2319
        return element;
2320
    }
2321

    
2322
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
2323
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
2324
        addAndAdaptElement(parentElement, element);
2325
        return element;
2326
    }
2327
    public OriginalSourceElement createOriginalSourceElement(ICdmFormElement parentElement, CdmBase cdmEntity, String label){
2328
        OriginalSourceElement element = new OriginalSourceElement(this, parentElement, cdmEntity, label);
2329
        addAndAdaptElement(parentElement, element);
2330
        return element;
2331
    }
2332

    
2333

    
2334
    public NomenclaturalSourceElement createNomenclaturalSourceElement(ICdmFormElement parentElement, CdmBase cdmEntity, String label){
2335
        NomenclaturalSourceElement element = new NomenclaturalSourceElement(this, parentElement, cdmEntity, label);
2336
        addAndAdaptElement(parentElement, element);
2337
        return element;
2338
    }
2339

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

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

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

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

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

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

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

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

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

    
2394
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2395
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2396
        adapt(element);
2397
        parentElement.addElement(element);
2398

    
2399
        return element;
2400
    }
2401

    
2402
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2403
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2404
        addAndAdaptElement(parentElement, element);
2405
        return element;
2406
    }
2407

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

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

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

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

    
2432
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2433
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2434
        addAndAdaptElement(parentElement, element);
2435
        return element;
2436
    }
2437

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

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

    
2450
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2451
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2452
        addAndAdaptElement(parentElement, element);
2453
        return element;
2454
    }
2455

    
2456
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2457
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2458
        addAndAdaptElement(parentElement, element);
2459
        return element;
2460
    }
2461

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

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

    
2474
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2475
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2476
        addAndAdaptElement(parentElement, element);
2477
        return element;
2478
    }
2479

    
2480
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2481
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2482
        addAndAdaptElement(parentElement, element);
2483
        return element;
2484
    }
2485

    
2486
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2487
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2488
        addAndAdaptElement(parentElement, element);
2489
        return element;
2490
    }
2491

    
2492

    
2493
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2494
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2495
        addAndAdaptElement(parentElement, element);
2496
        return element;
2497
    }
2498

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2601
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2602
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2603
        addAndAdaptElement(parentElement, element);
2604
        return element;
2605
    }
2606

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2973

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

    
2978
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2979

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

    
3054
            }
3055
        } else if (entity instanceof Reference) {
3056
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
3057
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
3058
            }
3059
            else{
3060
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
3061
            }
3062
        } else if (entity instanceof NameTypeDesignation) {
3063
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
3064
                    style);
3065
        } else if (entity instanceof TextualTypeDesignation) {
3066
            element = new TextTypeDesignationElement(this, parentElement, (TextualTypeDesignation) entity, removeListener,
3067
                    style);
3068
        } else if (entity instanceof NameRelationship) {
3069
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
3070
                    style);
3071
        } else if (entity instanceof SpecimenTypeDesignation) {
3072
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
3073
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
3074
                        removeListener, style);
3075
            }
3076
            else{
3077
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
3078
                        removeListener, style);
3079
            }
3080
        } else if (entity instanceof StateData) {
3081
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
3082
        } else if (entity instanceof StatisticalMeasurementValue) {
3083
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
3084
                    removeListener, style);
3085
        } else if (entity instanceof DerivedUnit) {
3086
            switch(((DerivedUnit)entity).getRecordBasis()) {
3087
            case LivingSpecimen:
3088
            case PreservedSpecimen:
3089
            case OtherSpecimen:
3090
                element = new SpecimenCollectionDetailElement(this,
3091
                        parentElement,
3092
                        (DerivedUnit) entity,
3093
                        removeListener,
3094
                        style);
3095
                break;
3096
            default:
3097
                element = new DerivedUnitElement(this,
3098
                        parentElement,
3099
                        (DerivedUnit) entity,
3100
                        removeListener,
3101
                        style);
3102
            }
3103

    
3104
        } else if (entity instanceof NamedArea) {
3105
            element = new CollectingAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
3106
        } else if (entity instanceof DeterminationEvent) {
3107
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
3108
        } else if (entity instanceof User) {
3109
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
3110
        } else if (entity instanceof GrantedAuthority) {
3111
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
3112
                    removeListener, style);
3113
        } else if (entity instanceof Group) {
3114
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
3115
        } else if (entity instanceof Taxon) {
3116
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
3117
        } else if (entity instanceof DescriptionElementBase) {
3118
            // this is the special case for protologs, maybe we can do this
3119
            // differently when API improves
3120
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
3121
//            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
3122
//                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
3123
//            }
3124
        } else if (entity instanceof Identifier) {
3125
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
3126
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
3127
            }
3128
            else{
3129
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
3130
            }
3131
        } else if (entity instanceof TermVocabulary) {
3132
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
3133
            switch (termVocabulary.getTermType()) {
3134
            case State:
3135
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
3136
                break;
3137
            case Modifier:
3138
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
3139
                break;
3140
            default:
3141
                break;
3142
            }
3143
        }else if (entity instanceof TermVocabularyDto) {
3144
            TermVocabularyDto termVocabulary = (TermVocabularyDto)entity;
3145
            switch (termVocabulary.getTermType()) {
3146
            case State:
3147
                element = new StateVocabularyDtoCollectionElement(this, parentElement, termVocabulary, removeListener, backgroundColor, style);
3148
                break;
3149
            case Modifier:
3150
                element = new RecommendedModifierDtoVocabulariesElement(this, parentElement, termVocabulary, removeListener, backgroundColor, style);
3151
                break;
3152
            default:
3153
                break;
3154
            }
3155
        }else if (entity instanceof MeasurementUnit) {
3156
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
3157
        }else if (entity instanceof TermDto) {
3158
            if(((TermDto)entity).getTermType().equals(TermType.MeasurementUnit)){
3159
                element = new MeasurementUnitDtoCollectionElement(this, parentElement, (TermDto) entity, removeListener, backgroundColor, style);
3160
            }else if (((TermDto)entity).getTermType().equals(TermType.StatisticalMeasure)){
3161
                element = new StatisticalMeasureDtoCollectionElement(this, parentElement, (TermDto) entity, removeListener, backgroundColor, style);
3162
            }
3163
        }else if (entity instanceof StatisticalMeasure) {
3164
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
3165
        } else if (entity instanceof FeatureState && parentElement instanceof InapplicableIfEntityCollectionSection) {
3166
            element = new InapplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
3167
        } else if (entity instanceof FeatureState && parentElement instanceof OnlyApplicableIfEntityCollectionSection) {
3168
            element = new OnlyApplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
3169
        }
3170

    
3171
        //check for parent section when entity is null
3172
        //this happens when AbstractUnboundEntityCollectionSection is used
3173
        if(element==null){
3174
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
3175
                element = new ScopeElement(this,
3176
                        parentElement,
3177
                        (DefinedTerm) entity,
3178
                        removeListener,
3179
                        style);
3180
            }
3181
            else if(parentElement instanceof ModifierSection){
3182
                element = new ModifierElement(this,
3183
                        parentElement,
3184
                        (DefinedTerm) entity,
3185
                        removeListener,
3186
                        style);
3187
            }
3188
        }
3189

    
3190

    
3191
        if (element == null) {
3192
            MessagingUtils.messageDialog(
3193
                    String.format("Error when creating section %s",
3194
                            parentElement.getClass().getSimpleName()),
3195
                    this,
3196
                    String.format("Could not generate collection element for entity of class %s."
3197
                            + " Looks like the case is not yet handled. Check implementation.\n"
3198
                            + "Entity: %s", entity.getClass(), entity.toString()), null);
3199
        }
3200

    
3201
        else{
3202
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
3203
                element.setPersistentBackground(backgroundColor);
3204
            }
3205
            adapt(element);
3206
            parentElement.addElement(element);
3207
        }
3208

    
3209
        return element;
3210
    }
3211

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

    
3255
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3256
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3257
            int style, boolean filterElement) {
3258
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
3259
                parentElement, clazz,
3260
                labelString, selection, mode, style, filterElement);
3261
        adapt(element);
3262
        parentElement.addElement(element);
3263
        return element;
3264
    }
3265

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

    
3278
    public CommonNameReferenceSelectionElement createCommonNameReferenceSelectionElement(ICdmFormElement parentElement, String labelString, Reference selection, int mode,
3279
          int style) {
3280
        CommonNameReferenceSelectionElement element = new CommonNameReferenceSelectionElement(this,
3281
              parentElement, labelString, selection, mode, style);
3282
      adapt(element);
3283
      parentElement.addElement(element);
3284
      return element;
3285
  }
3286

    
3287
    /**
3288
     * <p>
3289
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
3290
     * </p>
3291
     * <p>
3292
     * <strong>Selection elements not handled by this method:</strong>
3293
     * <ul>
3294
     * <li>{@link TaxonNodeSelectionElement} see
3295
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
3296
     * </li>
3297
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
3298
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
3299
     * </li>
3300
     * </ul>
3301
     * </p>
3302
     *
3303
     * @param clazz
3304
     *            a {@link Class} object of the type that you want the selection
3305
     *            element to handle
3306
     * @param parentElement
3307
     *            a {@link ICdmFormElement} object.
3308
     * @param labelString
3309
     *            a {@link String} object.
3310
     * @param selectionType
3311
     * @param selection
3312
     *            a {@link ICdmBase} object.
3313
     * @param style
3314
     *            a int.
3315
     * @param conversation
3316
     *            a {@link ConversationHolder} object.
3317
     * @return a {@link EntitySelectionElement} object.
3318
     */
3319
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
3320
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
3321
            T selection, int mode, int style) {
3322
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, //conversation,
3323
                parentElement, clazz,
3324
                labelString, selection, mode, style);
3325
        adapt(element);
3326
        parentElement.addElement(element);
3327
        return element;
3328
    }
3329

    
3330
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3331
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
3332
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this,
3333
                parentElement,
3334
                labelString, selection, mode, style, null);
3335
        adapt(element);
3336
        parentElement.addElement(element);
3337
        return element;
3338
    }
3339
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3340
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style, Integer limit) {
3341
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
3342
                parentElement,
3343
                labelString, selection, mode, style, limit);
3344
        adapt(element);
3345
        parentElement.addElement(element);
3346
        return element;
3347
    }
3348

    
3349

    
3350
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
3351
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
3352
//            int mode, int style) {
3353
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
3354
//                conversation, parentElement, labelString, selection, mode, style);
3355
//        adapt(element);
3356
//        parentElement.addElement(element);
3357
//        return element;
3358
//    }
3359

    
3360
    /** {@inheritDoc} */
3361
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
3362
        LabelElement labelElement = new LabelElement(this, parentElement, text);
3363
        adapt(labelElement);
3364
        parentElement.addElement(labelElement);
3365
        return labelElement;
3366
    }
3367

    
3368

    
3369

    
3370
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
3371
//        Label label = new Label(formElement.getLayoutComposite(), style);
3372
//        label.setText(labelText+" (yyyy-MM-dd)");
3373
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
3374
//        dateElement.initInternalController();
3375
//
3376
//        return dateElement;
3377
//    }
3378

    
3379
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
3380
    	 Label label = new Label(formElement.getLayoutComposite(), style);
3381
         label.setText(labelText);
3382
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3383
         DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
3384
         dateElement.initController(this, formElement);
3385
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3386
         return dateElement;
3387
    }
3388

    
3389
    /**
3390
     * <p>
3391
     * Getter for the field <code>selectionProvider</code>.
3392
     * </p>
3393
     *
3394
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
3395
     */
3396
    public ISelectionProvider getSelectionProvider() {
3397
        return selectionProvider;
3398
    }
3399

    
3400
    /**
3401
     * <p>
3402
     * createDetailedDescriptionDetailElement
3403
     * </p>
3404
     *
3405
     * @param parentElement
3406
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3407
     *            object.
3408
     * @param entity
3409
     *            a
3410
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
3411
     *            object.
3412
     * @param style
3413
     *            a int.
3414
     * @return a
3415
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
3416
     *         object.
3417
     */
3418
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
3419
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
3420
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
3421

    
3422
        if (entity instanceof CategoricalData) {
3423
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
3424
                    (CategoricalData) entity, style);
3425
        } else if (entity instanceof CommonTaxonName) {
3426
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
3427
                    style);
3428
        } else if (entity instanceof Distribution && !enabled) {
3429
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3430
                    enabled, style);
3431
        } else if (entity instanceof Distribution) {
3432
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3433
                    true, style);
3434
        }else if (entity instanceof IndividualsAssociation) {
3435
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
3436
                    (IndividualsAssociation) entity, style);
3437
        } else if (entity instanceof QuantitativeData) {
3438
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
3439
                    (QuantitativeData) entity, style);
3440
        } else if (entity instanceof TaxonInteraction) {
3441
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
3442
                    (TaxonInteraction) entity, style);
3443
        } else if (entity instanceof TemporalData) {
3444
            detailedDescriptionElement = new TemporalDataDetailElement(this, parentElement, (TemporalData) entity, style);
3445
        } else if (entity instanceof TextData) {
3446
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
3447
        }
3448
        else {
3449
            throw new IllegalStateException("There is no interface for the given description element");
3450
        }
3451
        adapt(detailedDescriptionElement);
3452
        parentElement.addElement(detailedDescriptionElement);
3453
        return detailedDescriptionElement;
3454

    
3455
    }
3456

    
3457
    /**
3458
     * Creates a styled text as a part of the form.
3459
     *
3460
     * @param parent
3461
     *            the text parent
3462
     * @param value
3463
     *            the text initial value
3464
     * @param style
3465
     *            the text style
3466
     * @return the text widget
3467
     */
3468
    public StyledText createStyledText(Composite parent, String value, int style) {
3469
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3470
        if (value != null) {
3471
            text.setText(value);
3472
        }
3473
        text.setForeground(getColors().getForeground());
3474
        text.setBackground(getColors().getBackground());
3475
        // text.addFocusListener(visibilityHandler);
3476
        return text;
3477
    }
3478

    
3479
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3480
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3481
        addAndAdaptSection(parentElement, section);
3482
        return section;
3483
    }
3484

    
3485
    /**
3486
     * @param formElement
3487
     * @param conversationHolder
3488
     * @param style
3489
     * @return
3490
     */
3491
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3492
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3493
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3494
        addAndAdaptSection(formElement, section);
3495
        return section;
3496
    }
3497

    
3498

    
3499
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3500
			ICdmFormElement parentElement, int style) {
3501
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3502
		addAndAdaptElement(parentElement, section);
3503
        return section;
3504
	}
3505

    
3506
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3507
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3508
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3509
	        addAndAdaptSection(formElement, section);
3510
	        return section;
3511
	}
3512

    
3513

    
3514
    /**
3515
     * <p>
3516
     * createTextWithLabelElement
3517
     * </p>
3518
     *
3519
     * @param parentElement
3520
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3521
     *            object.
3522
     * @param labelString
3523
     *            a {@link java.lang.String} object.
3524
     * @param initialText
3525
     *            a {@link java.lang.String} object.
3526
     * @param textLimit maximal number of characters allowed
3527
     * @param style
3528
     *            a int.
3529
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
3530
     *         object.
3531
     */
3532
    public RuleConsideredElement createRuleConsideredElement(ICdmFormElement parentElement, String labelString, boolean isShowCodeEdition, int style) {
3533
        RuleConsideredElement element = new RuleConsideredElement(this, parentElement, labelString, isShowCodeEdition, style);
3534
        adapt(element);
3535
        parentElement.addElement(element);
3536
        return element;
3537
    }
3538

    
3539
    /**
3540
     * @param class1
3541
     * @param formElement
3542
     * @param string
3543
     * @param area
3544
     * @param nothing
3545
     * @param style
3546
     * @return
3547
     */
3548
    public EntitySelectionElementWithIdInVocabulary createSelectionElementWithIdInVocabulary(Class<NamedArea> clazz,
3549
            ICdmFormElement formElement, String labelString, NamedArea area, int mode, int style) {
3550
        EntitySelectionElementWithIdInVocabulary element = new EntitySelectionElementWithIdInVocabulary(this,
3551
                formElement, clazz, labelString, area, mode, style);
3552
        adapt(element);
3553
        formElement.addElement(element);
3554
        return element;
3555
    }
3556

    
3557
    /**
3558
     * @param extendedTimePeriodElement
3559
     * @param twistie
3560
     * @return
3561
     */
3562
    public ExtendedTimeDetailSection createExtendedTimeDetailSection(
3563
            ExtendedTimePeriodElement parentElement, int style) {
3564
        ExtendedTimeDetailSection section = new ExtendedTimeDetailSection(this, parentElement,  style);
3565
        parentElement.addElement(section);
3566
        adapt(section);
3567
        return section;
3568
    }
3569
    public ExtendedTimePeriodElement createExtendedTimePeriodElement(
3570
            ICdmFormElement parentElement, String labelString, ExtendedTimePeriod timePeriod, int style) {
3571
        ExtendedTimePeriodElement section = new ExtendedTimePeriodElement(this, parentElement, labelString, timePeriod, style);
3572
        parentElement.addElement(section);
3573
        adapt(section);
3574
        return section;
3575
    }
3576

    
3577

    
3578

    
3579

    
3580
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3581
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3582
//				 initialText, textHeight, style);
3583
//	        adapt(element);
3584
//	        parentElement.addElement(element);
3585
//	        return element;
3586
//	}
3587

    
3588

    
3589

    
3590

    
3591

    
3592

    
3593

    
3594
}
(8-8/53)