Project

General

Profile

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

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

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

    
44
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
45
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
46
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
47
import eu.etaxonomy.cdm.model.agent.Person;
48
import eu.etaxonomy.cdm.model.agent.Team;
49
import eu.etaxonomy.cdm.model.common.Annotation;
50
import eu.etaxonomy.cdm.model.common.CdmBase;
51
import eu.etaxonomy.cdm.model.common.Credit;
52
import eu.etaxonomy.cdm.model.common.DefinedTerm;
53
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
54
import eu.etaxonomy.cdm.model.common.Extension;
55
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
56
import eu.etaxonomy.cdm.model.common.Group;
57
import eu.etaxonomy.cdm.model.common.ICdmBase;
58
import eu.etaxonomy.cdm.model.common.IEnumTerm;
59
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
60
import eu.etaxonomy.cdm.model.common.Identifier;
61
import eu.etaxonomy.cdm.model.common.Language;
62
import eu.etaxonomy.cdm.model.common.LanguageString;
63
import eu.etaxonomy.cdm.model.common.Marker;
64
import eu.etaxonomy.cdm.model.common.TermType;
65
import eu.etaxonomy.cdm.model.common.TermVocabulary;
66
import eu.etaxonomy.cdm.model.common.TimePeriod;
67
import eu.etaxonomy.cdm.model.common.User;
68
import eu.etaxonomy.cdm.model.common.VersionableEntity;
69
import eu.etaxonomy.cdm.model.description.CategoricalData;
70
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
71
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
72
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
73
import eu.etaxonomy.cdm.model.description.Distribution;
74
import eu.etaxonomy.cdm.model.description.Feature;
75
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
76
import eu.etaxonomy.cdm.model.description.KeyStatement;
77
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
78
import eu.etaxonomy.cdm.model.description.QuantitativeData;
79
import eu.etaxonomy.cdm.model.description.State;
80
import eu.etaxonomy.cdm.model.description.StateData;
81
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
82
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
83
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
84
import eu.etaxonomy.cdm.model.description.TextData;
85
import eu.etaxonomy.cdm.model.location.NamedArea;
86
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
87
import eu.etaxonomy.cdm.model.location.Point;
88
import eu.etaxonomy.cdm.model.media.ImageFile;
89
import eu.etaxonomy.cdm.model.media.Media;
90
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
91
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
92
import eu.etaxonomy.cdm.model.media.Rights;
93
import eu.etaxonomy.cdm.model.molecular.DnaSample;
94
import eu.etaxonomy.cdm.model.name.NameRelationship;
95
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
96
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
97
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
98
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
99
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
100
import eu.etaxonomy.cdm.model.reference.Reference;
101
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
102
import eu.etaxonomy.cdm.model.taxon.Taxon;
103
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
104
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
105
import eu.etaxonomy.taxeditor.model.MessagingUtils;
106
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
107
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
108
import eu.etaxonomy.taxeditor.ui.combo.VocabularyComboElement;
109
import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection.UnitType;
110
import eu.etaxonomy.taxeditor.ui.mvc.element.DateElement;
111
import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
112
import eu.etaxonomy.taxeditor.ui.openurl.OpenUrlSelectorElement;
113
import eu.etaxonomy.taxeditor.ui.password.EditPasswordElement;
114
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
115
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
116
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
117
import eu.etaxonomy.taxeditor.ui.section.EmptyElement;
118
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement;
119
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection;
120
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailElement;
121
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
122
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailElement;
123
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
124
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
125
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberSection;
126
import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
127
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailElement;
128
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailSection;
129
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailElement;
130
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailSection;
131
import eu.etaxonomy.taxeditor.ui.section.common.ReferenceEntityDetailElement;
132
import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
133
import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
134
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
135
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailElement;
136
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
137
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
138
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
139
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
140
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceElement;
141
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
142
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceElement;
143
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
144
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
145
import eu.etaxonomy.taxeditor.ui.section.description.ModifierElement;
146
import eu.etaxonomy.taxeditor.ui.section.description.ModifierSection;
147
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageDetailElement;
148
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
149
import eu.etaxonomy.taxeditor.ui.section.description.ScopeElement;
150
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
151
import eu.etaxonomy.taxeditor.ui.section.description.StateDataElement;
152
import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;
153
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueElement;
154
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueSection;
155
import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;
156
import eu.etaxonomy.taxeditor.ui.section.description.detail.CategoricalDataDetailElement;
157
import eu.etaxonomy.taxeditor.ui.section.description.detail.CommonNameDetailElement;
158
import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
159
import eu.etaxonomy.taxeditor.ui.section.description.detail.IndividualsAssociationDetailElement;
160
import eu.etaxonomy.taxeditor.ui.section.description.detail.QuantitativeDataDetailElement;
161
import eu.etaxonomy.taxeditor.ui.section.description.detail.TaxonInteractionDetailElement;
162
import eu.etaxonomy.taxeditor.ui.section.description.detail.TextDataDetailElement;
163
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement;
164
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
165
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityCollectionElement;
166
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailElement;
167
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
168
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailElement;
169
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
170
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailElement;
171
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
172
import eu.etaxonomy.taxeditor.ui.section.identifier.IdentifierDetailElement;
173
import eu.etaxonomy.taxeditor.ui.section.identifier.IdentifierDetailSection;
174
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailElement;
175
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
176
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailElement;
177
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
178
import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
179
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
180
import eu.etaxonomy.taxeditor.ui.section.media.ImageFileElement;
181
import eu.etaxonomy.taxeditor.ui.section.media.MediaDetailElement;
182
import eu.etaxonomy.taxeditor.ui.section.media.MediaMetaElement;
183
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationElement;
184
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartElement;
185
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartSection;
186
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationSection;
187
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
188
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
189
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailSection;
190
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailElement;
191
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailSection;
192
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailElement;
193
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailSection;
194
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailElement;
195
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
196
import eu.etaxonomy.taxeditor.ui.section.name.NameTypeDesignationElement;
197
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusElement;
198
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
199
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailElement;
200
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
201
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueElement;
202
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
203
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
204
import eu.etaxonomy.taxeditor.ui.section.name.SynonymRelationshipDetailElement;
205
import eu.etaxonomy.taxeditor.ui.section.name.SynonymRelationshipDetailSection;
206
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
207
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
208
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
209
import eu.etaxonomy.taxeditor.ui.section.occurrence.CurrentDeterminationDetailSection;
210
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailElement;
211
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
212
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailElement;
213
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
214
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement;
215
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
216
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement;
217
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection;
218
import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
219
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailElement;
220
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailSection;
221
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailElement;
222
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSection;
223
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailElement;
224
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
225
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopeDetailSection;
226
import eu.etaxonomy.taxeditor.ui.section.occurrence.NamedAreaDetailElement;
227
import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
228
import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
229
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElement;
230
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailSection;
231
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenHierarchyDetailElement;
232
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenHierarchyDetailSection;
233
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailElement;
234
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
235
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenCurrentDeterminationDetailSection;
236
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailElement;
237
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailSection;
238
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDeterminationDetailElement;
239
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDeterminationDetailSection;
240
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDeterminationHistoryDetailSection;
241
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailElement;
242
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailSection;
243
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenSourceCollectionDetailSection;
244
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractSampleDesignationDetailSection;
245
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailElement;
246
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailSection;
247
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoCollectionDetailSection;
248
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoDetailElement;
249
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailElement;
250
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailSection;
251
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailElement;
252
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailSection;
253
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.CurrentSampleDesignationDetailSection;
254
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailElement;
255
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
256
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailElement;
257
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
258
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.PrimerGeneralDetailElement;
259
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailElement;
260
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailSection;
261
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationHistoryDetailSection;
262
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationTextDetailElement;
263
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceContigFileCollectionDetailSection;
264
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailElement;
265
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
266
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailElement;
267
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
268
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailElement;
269
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
270
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadPherogramCollectionDetailSection;
271
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailElement;
272
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
273
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailElement;
274
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
275
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
276
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
277
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement;
278
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
279
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationElement;
280
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
281
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseElement;
282
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
283
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditElement;
284
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
285
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionElement;
286
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
287
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
288
import eu.etaxonomy.taxeditor.ui.section.supplemental.IdentifiableSourceElement;
289
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerElement;
290
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
291
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsElement;
292
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
293
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
294
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement;
295
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
296
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement;
297
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
298
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailElement;
299
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
300
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailElement;
301
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailElement;
302
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
303
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailElement;
304
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
305
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailElement;
306
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
307
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailElement;
308
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
309
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement;
310
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailSection;
311
import eu.etaxonomy.taxeditor.ui.section.vocabulary.FeatureDetailElement;
312
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionElement;
313
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionSection;
314
import eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailSection;
315
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesCollectionSection;
316
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesElement;
317
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionElement;
318
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionSection;
319
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionElement;
320
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionSection;
321
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailElement;
322
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
323
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
324
import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
325
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
326

    
327
/**
328
 * <p>
329
 * CdmFormFactory class.
330
 * </p>
331
 *
332
 * @author n.hoffmann
333
 * @created Feb 24, 2010
334
 * @version 1.0
335
 */
336
public class CdmFormFactory extends FormToolkit {
337

    
338
    private BoldFontHolder2 boldFontHolder2;
339
    private MouseListener selectionMouseHandler;
340
    private FocusListener selectionFocusHandler;
341

    
342
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
343

    
344
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
345

    
346
    private final int orientation = Window.getDefaultOrientation();
347
    private ISelectionProvider selectionProvider;
348

    
349
    /** Constant <code>EMPTY_SELECTION</code> */
350
    public static ISelection EMPTY_SELECTION = new ISelection() {
351
        @Override
352
        public boolean isEmpty() {
353
            return true;
354
        }
355
    };
356

    
357
    /**
358
     *
359
     * @author n.hoffmann
360
     * @date Jan 25, 2010
361
     *
362
     */
363
    private class SelectionMouseHandler extends MouseAdapter {
364
        @Override
365
        public void mouseDown(MouseEvent e) {
366
            notifySelectionListeners(e);
367
        }
368
    }
369

    
370
    /**
371
     *
372
     * @author n.hoffmann
373
     * @date Jan 25, 2010
374
     *
375
     */
376
    private class SelectionFocusHandler extends FocusAdapter {
377
        @Override
378
        public void focusGained(FocusEvent e) {
379
            notifySelectionListeners(e);
380
        }
381
    }
382

    
383
    private void notifySelectionListeners(TypedEvent e) {
384
        Event event = new Event();
385
        event.widget = e.widget;
386
        SelectionEvent selectionEvent = new SelectionEvent(event);
387

    
388
        for (SelectionListener listener : selectionListenerList) {
389
            listener.widgetSelected(selectionEvent);
390
        }
391
    }
392

    
393
    /**
394
     * <p>
395
     * Constructor for CdmFormFactory.
396
     * </p>
397
     *
398
     * @param display
399
     *            a {@link org.eclipse.swt.widgets.Display} object.
400
     * @param selectionProvider
401
     *            a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
402
     */
403
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
404
        super(display);
405
        this.selectionProvider = selectionProvider;
406
        init();
407
    }
408

    
409
    /**
410
     * <p>
411
     * Constructor for CdmFormFactory.
412
     * </p>
413
     *
414
     * @param display
415
     *            a {@link org.eclipse.swt.widgets.Display} object.
416
     */
417
    public CdmFormFactory(Display display) {
418
        super(display);
419
        init();
420
    }
421

    
422
    /**
423
	 *
424
	 */
425
    private void init() {
426
        boldFontHolder2 = new BoldFontHolder2();
427
        selectionMouseHandler = new SelectionMouseHandler();
428
        selectionFocusHandler = new SelectionFocusHandler();
429
    }
430

    
431
    /**
432
     * Creates an instance initialized with the correct selectionProvider
433
     *
434
     * Make sure to remove the instance when the entityComposite disposes via
435
     * destroySelectionArbitrator(..)
436
     *
437
     * @param entityElement
438
     *            a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
439
     *            object.
440
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
441
     *         object.
442
     */
443
    public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
444
        SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
445
        selectionArbitrator.addSelectionProvider(selectionProvider);
446
        selectionProvider.addSelectionChangedListener(selectionArbitrator);
447
        addSelectionListener(selectionArbitrator);
448
        return selectionArbitrator;
449
    }
450

    
451
    /**
452
     * <p>
453
     * destroySelectionArbitrator
454
     * </p>
455
     *
456
     * @param selectionArbitrator
457
     *            a
458
     *            {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
459
     *            object.
460
     */
461
    public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
462
        removeSelectionListener(selectionArbitrator);
463
        if (selectionProvider != null) {
464
            selectionProvider.removeSelectionChangedListener(selectionArbitrator);
465
        } else {
466
            MessagingUtils.error(this.getClass(),
467
                    "Tried to destroy a selection listener from this factories listeners but was null", null);
468
        }
469
    }
470

    
471
    /**
472
     * <p>
473
     * Adapts the {@link AbstractCdmFormElement}:<br>
474
     * - sets the {@link IPropertyChangeListener}s handled by this class
475
     * </p>
476
     *
477
     * @param formElement
478
     *            a
479
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
480
     *            object.
481
     */
482
    public void adapt(ICdmFormElement formElement) {
483
        formElement.setPropertyChangeListeners(propertyChangeListeners);
484
    }
485

    
486
    /** {@inheritDoc} */
487
    @Override
488
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
489
        if (trackFocus) {
490
            control.addFocusListener(selectionFocusHandler);
491
        }
492
        super.adapt(control, trackFocus, trackKeyboard);
493
    }
494

    
495
    /** {@inheritDoc} */
496
    @Override
497
    public void adapt(Composite composite) {
498
        composite.addMouseListener(selectionMouseHandler);
499
        super.adapt(composite);
500
    }
501

    
502
    /**
503
     * <p>
504
     * destroyElement
505
     * </p>
506
     *
507
     * @param formElement
508
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
509
     *            object.
510
     */
511
    public void destroyElement(ICdmFormElement formElement) {
512
        // return if element was not initialized
513
        if (formElement == null) {
514
            return;
515
        }
516
        // destroy selection arbitrator, if any
517
        if (formElement instanceof ISelectableElement) {
518
            destroySelectionArbitrator(((ISelectableElement) formElement).getSelectionArbitrator());
519
        }
520
        // remove this element form its parents list of elements
521
        // ICdmFormElement parentElement = formElement.getParentElement();
522
        // if(parentElement != null){
523
        // parentElement.removeElement(formElement);
524
        // }
525
        // call destroy on child elements recursively
526
        for (ICdmFormElement childElement : formElement.getElements()) {
527
            destroyElement(childElement);
528
        }
529
        // dispose of the controls
530
        for (Control control : formElement.getControls()) {
531
            // we added the layoutComposite of the parental element as the
532
            // layout composite to this formElement
533
            // but we do not want to destroy it.
534
            if (control.equals(formElement.getLayoutComposite())) {
535
                continue;
536
            } else {
537
                control.dispose();
538
                control = null;
539
            }
540
        }
541
    }
542

    
543
    /**
544
     * <p>
545
     * createEmptyCell
546
     * </p>
547
     *
548
     * @param parent
549
     *            a {@link org.eclipse.swt.widgets.Composite} object.
550
     * @return a {@link org.eclipse.swt.widgets.Label} object.
551
     */
552
    public Label createEmptyCell(Composite parent) {
553
        return this.createLabel(parent, null);
554
    }
555

    
556
    /**
557
     * <p>
558
     * createMultiLanguageTextElement
559
     * </p>
560
     *
561
     * @param parentElement
562
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
563
     *            object.
564
     * @param labelString
565
     *            a {@link java.lang.String} object.
566
     * @param multilanguageText
567
     *            a {@link java.util.Map} object.
568
     * @param textHeight
569
     *            a int.
570
     * @param style
571
     *            a int.
572
     * @return a
573
     *         {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
574
     *         object.
575
     */
576
    public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
577
            Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
578
        MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
579
                multilanguageText, textHeight, style);
580
        adapt(element);
581
        parentElement.addElement(element);
582
        return element;
583
    }
584

    
585
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
586
            KeyStatement keyStatement, int textHeight, int style) {
587
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
588
                textHeight, style);
589
        adapt(element);
590
        parentElement.addElement(element);
591
        return element;
592
    }
593

    
594
    /**
595
     * Creates a text field with a label. The initial content will be the return value of the initalObject's {@link #toString()}
596
     * method.<br>
597
     * <b>Note</b>: if initialObject is <code>null</code> then an empty string is used.
598
     * @param parentElement the parent container
599
     * @param labelString the label name
600
     * @param initialObject the object from which the <code>toString()</code> method is called
601
     * @param style {@link SWT} style constant
602
     * @return the created textfield with label
603
     */
604
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
605
            Object initialObject, int style) {
606
        return createTextWithLabelElement(parentElement, labelString, initialObject==null?"":initialObject.toString(), style);
607
    }
608

    
609
    /**
610
     * <p>
611
     * createTextWithLabelElement
612
     * </p>
613
     *
614
     * @param parentElement
615
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
616
     *            object.
617
     * @param labelString
618
     *            a {@link java.lang.String} object.
619
     * @param initialText
620
     *            a {@link java.lang.String} object.
621
     * @param style
622
     *            a int.
623
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
624
     *         object.
625
     */
626
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
627
            String initialText, int style) {
628
        return createTextWithLabelElement(parentElement, labelString, initialText, null, style);
629
    }
630
    /**
631
     * <p>
632
     * createTextWithLabelElement
633
     * </p>
634
     *
635
     * @param parentElement
636
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
637
     *            object.
638
     * @param labelString
639
     *            a {@link java.lang.String} object.
640
     * @param initialText
641
     *            a {@link java.lang.String} object.
642
     * @param textLimit maximal number of characters allowed
643
     * @param style
644
     *            a int.
645
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
646
     *         object.
647
     */
648
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
649
            String initialText, Integer textLimit, int style) {
650
        if(initialText==null){
651
            initialText = "";
652
        }
653

    
654
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
655
                textLimit, style);
656
        adapt(element);
657
        parentElement.addElement(element);
658
        return element;
659
    }
660

    
661
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
662
            int textHeight, int style) {
663
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
664
        adapt(element);
665
        parentElement.addElement(element);
666
        return element;
667
    }
668

    
669
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
670
            URI initialUri, int style) {
671
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
672
        adapt(element);
673
        parentElement.addElement(element);
674
        return element;
675
    }
676

    
677
    /**
678
     * @param element
679
     * @param string
680
     * @param uri
681
     * @param style
682
     * @return
683
     */
684
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
685
            IOpenUrlEnabled openUrlEnabled, int style) {
686
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
687
                style);
688
        adapt(element);
689
        parentElement.addElement(element);
690
        return element;
691
    }
692

    
693
    /**
694
     *
695
     * @param parentElement
696
     * @param labelString
697
     * @param conversationEnabled
698
     * @param user
699
     * @param style
700
     * @return
701
     */
702
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
703
            ConversationHolder conversation, User user, int style) {
704
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
705
        adapt(element);
706
        parentElement.addElement(element);
707
        return element;
708
    }
709

    
710
    /**
711
     * <p>
712
     * createIntegerTextWithLabelElement
713
     * </p>
714
     *
715
     * @param parentElement
716
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
717
     *            object.
718
     * @param labelString
719
     *            a {@link java.lang.String} object.
720
     * @param initialInteger
721
     *            a {@link java.lang.Integer} object.
722
     * @param style
723
     *            a int.
724
     * @return a
725
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
726
     *         object.
727
     */
728
	public NumberWithLabelElement createNumberTextWithLabelElement(
729
			ICdmFormElement parentElement, String labelString,
730
			Number initialNumber, int style) {
731
		NumberWithLabelElement element = new NumberWithLabelElement(this,
732
				parentElement, labelString, initialNumber, style);
733
		adapt(element);
734
		parentElement.addElement(element);
735
		return element;
736
	}
737

    
738
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
739
            String labelString, LanguageString languageString, int style) {
740
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
741
    }
742

    
743
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
744
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
745
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
746
                languageString, height, isMultiLine, style);
747
        adapt(element);
748
        parentElement.addElement(element);
749
        return element;
750
    }
751

    
752
    /**
753
     * <p>
754
     * createKeyValueViewerElement
755
     * </p>
756
     *
757
     * @param parentElement
758
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
759
     *            object.
760
     * @param keyHeading
761
     *            a {@link java.lang.String} object.
762
     * @param valueHeading
763
     *            a {@link java.lang.String} object.
764
     * @param map
765
     *            a {@link java.util.Map} object.
766
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
767
     *         object.
768
     */
769
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
770
            String valueHeading, Map<Object, Object> map) {
771
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
772
        adapt(element);
773
        parentElement.addElement(element);
774
        return element;
775
    }
776
    /**
777
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
778
     */
779
    @Deprecated
780
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
781
            ICdmFormElement parentElement, String labelString, T selection, int style) {
782
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString,
783
                selection, true,  style);
784
        adapt(element);
785
        parentElement.addElement(element);
786
        return element;
787
    }
788

    
789
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
790
            TermType termType,
791
            ICdmFormElement parentElement,
792
            String labelString,
793
            T selection,
794
            int style) {
795
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, true, style);
796
        adapt(element);
797
        parentElement.addElement(element);
798
        return element;
799
    }
800

    
801
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
802
			TermType termType,
803
			ICdmFormElement parentElement,
804
			String labelString,
805
			T selection,
806
			boolean addEmptyElement,
807
			int style) {
808
		TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style);
809
		adapt(element);
810
		parentElement.addElement(element);
811
		return element;
812
	}
813

    
814
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
815
            TermVocabulary<?> termVocabulary,
816
            ICdmFormElement parentElement,
817
            String labelString,
818
            T selection,
819
            int style) {
820
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, true, style);
821
        adapt(element);
822
        parentElement.addElement(element);
823
        return element;
824
    }
825

    
826
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
827
	        TermVocabulary<?> termVocabulary,
828
	        ICdmFormElement parentElement,
829
	        String labelString,
830
	        T selection,
831
	        boolean addEmptyElement,
832
	        int style) {
833
	    TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style);
834
	    adapt(element);
835
	    parentElement.addElement(element);
836
	    return element;
837
	}
838

    
839
    /**
840
     * <p>
841
     * createEnumComboElement
842
     * </p>
843
     *
844
     * @param enumComboType
845
     *            a
846
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType}
847
     *            object.
848
     * @param parentElement
849
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
850
     *            object.
851
     * @param style
852
     *            a int.
853
     * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
854
     *         object.
855
     */
856
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
857
			Class<T> enumComboType, ICdmFormElement parentElement,
858
			int style) {
859
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
860
        adapt(element);
861
        parentElement.addElement(element);
862
        return element;
863
    }
864

    
865
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
866
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
867
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
868
	    adapt(element);
869
	    parentElement.addElement(element);
870
	    return element;
871
	}
872

    
873
    /**
874
     * <p>
875
     * createBrowserElement
876
     * </p>
877
     *
878
     * @param imageUri
879
     *            a {@link java.net.URI} object.
880
     * @param style
881
     *            a int.
882
     * @param parentElement
883
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
884
     *            object.
885
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
886
     *         object.
887
     */
888
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
889
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
890
        adapt(element);
891
        parentElement.addElement(element);
892
        return element;
893
    }
894

    
895
    /**
896
     * <p>
897
     * createImageElement
898
     * </p>
899
     *
900
     * @param parentElement
901
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
902
     *            object.
903
     * @param imageUri
904
     *            a {@link java.net.URI} object.
905
     * @param style
906
     *            a int.
907
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
908
     */
909
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
910
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
911
        adapt(element);
912
        parentElement.addElement(element);
913
        return element;
914
    }
915

    
916
    /**
917
     * <p>
918
     * createTextActionElement
919
     * </p>
920
     *
921
     * @param labelString
922
     *            a {@link java.lang.String} object.
923
     * @param initialText
924
     *            a {@link java.lang.String} object.
925
     * @param style
926
     *            a int.
927
     * @param parentElement
928
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
929
     *            object.
930
     * @param buttonLabel
931
     *            a {@link java.lang.String} object.
932
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
933
     *         object.
934
     */
935
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
936
            String buttonLabel, String initialText, int style) {
937
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
938
                style);
939
        adapt(element);
940
        parentElement.addElement(element);
941
        return element;
942
    }
943

    
944
    /**
945
     * <p>
946
     * createCheckbox
947
     * </p>
948
     *
949
     * @param parentElement
950
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
951
     *            object.
952
     * @param label
953
     *            a {@link java.lang.String} object.
954
     * @param initialState
955
     *            a boolean.
956
     * @param style
957
     *            a int.
958
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
959
     *         object.
960
     */
961
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
962
        if(initialState==null){
963
            initialState = Boolean.FALSE;
964
        }
965
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
966
        adapt(element);
967
        parentElement.addElement(element);
968
        return element;
969
    }
970

    
971
    /**
972
     * Creates a section as a part of the form.
973
     *
974
     * @return the section widget
975
     * @param section
976
     *            a
977
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
978
     *            object.
979
     */
980
    public Section adapt(AbstractFormSection section) {
981
        section.setMenu(section.getLayoutComposite().getMenu());
982
        adapt(section, true, true);
983

    
984
        // handle focus and property change events for cdm use
985
        section.addFocusListener(selectionFocusHandler);
986
        section.setPropertyChangeListeners(propertyChangeListeners);
987

    
988
        if (section.getToggle() != null) {
989
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
990
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
991
        }
992

    
993
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
994

    
995
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
996
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
997
            getColors().initializeSectionToolBarColors();
998
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
999
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1000
        }
1001
        // call setTitleBarForeground regardless as it also sets the label color
1002
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1003
        return section;
1004
    }
1005

    
1006
    private class BoldFontHolder2 {
1007
        private Font normalFont;
1008

    
1009
        private Font boldFont;
1010

    
1011
        public BoldFontHolder2() {
1012
        }
1013

    
1014
        public Font getBoldFont(Font font) {
1015
            createBoldFont(font);
1016
            return boldFont;
1017
        }
1018

    
1019
        private void createBoldFont(Font font) {
1020
            if (normalFont == null || !normalFont.equals(font)) {
1021
                normalFont = font;
1022
                dispose();
1023
            }
1024
            if (boldFont == null) {
1025
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1026
            }
1027
        }
1028

    
1029
        public void dispose() {
1030
            if (boldFont != null) {
1031
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1032
                boldFont = null;
1033
            }
1034
        }
1035
    }
1036

    
1037
    /**
1038
     * <p>
1039
     * createToggleableTextField
1040
     * </p>
1041
     *
1042
     * @param parentElement
1043
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1044
     *            object.
1045
     * @param labelString
1046
     *            a {@link java.lang.String} object.
1047
     * @param initialText
1048
     *            a {@link java.lang.String} object.
1049
     * @param initialState
1050
     *            a boolean.
1051
     * @param style
1052
     *            a int.
1053
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1054
     *         object.
1055
     */
1056
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1057
            String initialText, boolean initialState, int style) {
1058
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1059
                initialState, style | orientation);
1060
        adapt(element);
1061
        parentElement.addElement(element);
1062
        return element;
1063
    }
1064

    
1065
    /**
1066
     * <p>
1067
     * createTimePeriodElement
1068
     * </p>
1069
     *
1070
     * @param parentElement
1071
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1072
     *            object.
1073
     * @param labelString
1074
     *            a {@link java.lang.String} object.
1075
     * @param timePeriod
1076
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1077
     * @param style
1078
     *            a int.
1079
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1080
     *         object.
1081
     */
1082
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1083
            TimePeriod timePeriod, int style) {
1084
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1085
        adapt(element);
1086
        parentElement.addElement(element);
1087
        return element;
1088
    }
1089

    
1090
	/**
1091
	 * <p>
1092
	 * createGatheringEventUnitElement
1093
	 * </p>
1094
	 *
1095
	 * @param parentElement
1096
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1097
	 *            object.
1098
	 * @param labelString
1099
	 *            a {@link java.lang.String} object.
1100
	 * @param timePeriod
1101
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1102
	 * @param style
1103
	 *            a int.
1104
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1105
	 *         object.
1106
	 */
1107
	public GatheringEventUnitElement createGatheringEventUnitElement(
1108
			ICdmFormElement parentElement,
1109
			String labelString,
1110
			DerivedUnitFacade gatheringEvent,
1111
			MinMaxTextSection.UnitType unitType,
1112
			int style) {
1113
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1114
				parentElement,
1115
				labelString,
1116
				gatheringEvent,
1117
				unitType,
1118
				style);
1119
		adapt(element);
1120
		parentElement.addElement(element);
1121
		return element;
1122
	}
1123

    
1124
    /**
1125
     * <p>
1126
     * createPointElement
1127
     * </p>
1128
     *
1129
     * @param style
1130
     *            a int.
1131
     * @param parentElement
1132
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1133
     *            object.
1134
     * @param point
1135
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1136
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1137
     */
1138
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1139
        PointElement element = new PointElement(this, parentElement, point, style);
1140
        adapt(element);
1141
        parentElement.addElement(element);
1142
        return element;
1143
    }
1144

    
1145

    
1146

    
1147
    /**
1148
     * @param conversationHolder
1149
     * @param parent
1150
     * @param detailsViewer
1151
     * @param i
1152
     * @return
1153
     */
1154
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1155
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1156
        parentElement.addElement(section);
1157
        adapt(section);
1158
        return section;
1159
    }
1160

    
1161
    /**
1162
     * <p>
1163
     * createDateDetailSection
1164
     * </p>
1165
     *
1166
     * @param parentElement
1167
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1168
     *            object.
1169
     * @param style
1170
     *            a int.
1171
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1172
     *         object.
1173
     */
1174
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1175
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1176
        parentElement.addElement(section);
1177
        adapt(section);
1178
        return section;
1179
    }
1180

    
1181
	/**
1182
	 * <p>
1183
	 * createDateDetailSection
1184
	 * </p>
1185
	 *
1186
	 * @param parentElement
1187
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1188
	 *            object.
1189
	 * @param style
1190
	 *            a int.
1191
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1192
	 *         object.
1193
	 */
1194
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1195
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1196
		parentElement.addElement(section);
1197
		adapt(section);
1198
		return section;
1199
	}
1200

    
1201
    /**
1202
     * <p>
1203
     * createPartialElement
1204
     * </p>
1205
     *
1206
     * @param parentElement
1207
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1208
     *            object.
1209
     * @param labelString
1210
     *            a {@link java.lang.String} object.
1211
     * @param partial
1212
     *            a {@link org.joda.time.Partial} object.
1213
     * @param style
1214
     *            a int.
1215
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1216
     *         object.
1217
     */
1218
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1219
            int style) {
1220
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1221
        adapt(element);
1222
        parentElement.addElement(element);
1223
        return element;
1224
    }
1225

    
1226
    /**
1227
     * <p>
1228
     * addSelectionListener
1229
     * </p>
1230
     *
1231
     * @param listener
1232
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1233
     */
1234
    public void addSelectionListener(SelectionListener listener) {
1235
        selectionListenerList.add(listener);
1236
    }
1237

    
1238
    /**
1239
     * <p>
1240
     * removeSelectionListener
1241
     * </p>
1242
     *
1243
     * @param listener
1244
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1245
     */
1246
    public void removeSelectionListener(SelectionListener listener) {
1247
        if (listener == null) {
1248
            MessagingUtils.error(this.getClass(),
1249
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1250
        } else {
1251
            selectionListenerList.remove(listener);
1252
        }
1253
    }
1254

    
1255
    /**
1256
     * <p>
1257
     * addPropertyChangeListener
1258
     * </p>
1259
     *
1260
     * @param listener
1261
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1262
     *            object.
1263
     */
1264
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1265
        if (propertyChangeListeners.contains(listener)) {
1266
            return;
1267
        }
1268
        propertyChangeListeners.add(0, listener);
1269
    }
1270

    
1271
    /**
1272
     * <p>
1273
     * removePropertyChangeListener
1274
     * </p>
1275
     *
1276
     * @param listener
1277
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1278
     *            object.
1279
     */
1280
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1281
        propertyChangeListeners.remove(listener);
1282
    }
1283

    
1284
    /**
1285
     * @return the propertyChangeListeners
1286
     */
1287
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1288
        return propertyChangeListeners;
1289
    }
1290

    
1291
    /**
1292
     * <p>
1293
     * createHorizontalSeparator
1294
     * </p>
1295
     *
1296
     * @param parentElement
1297
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1298
     *            object.
1299
     * @param style
1300
     *            a int.
1301
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1302
     */
1303
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1304
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1305
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1306
        return separator;
1307
    }
1308

    
1309
    /**
1310
     * <p>
1311
     * createVersionElement
1312
     * </p>
1313
     *
1314
     * @param parentElement
1315
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1316
     *            object.
1317
     * @param entity
1318
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1319
     *            object.
1320
     * @param style
1321
     *            a int.
1322
     * @return a
1323
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1324
     *         object.
1325
     */
1326
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1327
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1328
        adapt(element);
1329
        parentElement.addElement(element);
1330
        return element;
1331
    }
1332

    
1333
    /**
1334
     * @param cdmBaseSection
1335
     * @param object
1336
     * @param style
1337
     * @return
1338
     */
1339
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1340
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1341
        adapt(element);
1342
        parentElement.addElement(element);
1343
        return element;
1344
    }
1345

    
1346
    /**
1347
     * <p>
1348
     * createVersionSection
1349
     * </p>
1350
     *
1351
     * @param parentElement
1352
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1353
     *            object.
1354
     * @param style
1355
     *            a int.
1356
     * @return a
1357
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1358
     *         object.
1359
     */
1360
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1361
        VersionSection section = new VersionSection(this, parentElement, style);
1362
        parentElement.addElement(section);
1363
        adapt(section);
1364
        return section;
1365
    }
1366

    
1367
    /**
1368
     * @param parent
1369
     * @param i
1370
     * @return
1371
     */
1372
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1373
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1374
        parentElement.addElement(section);
1375
        adapt(section);
1376
        return section;
1377
    }
1378

    
1379
    /**
1380
     * <p>
1381
     * createEmptyElement
1382
     * </p>
1383
     *
1384
     * @param parentElement
1385
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1386
     *            object.
1387
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1388
     */
1389
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1390
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1391
        adapt(element);
1392
        parentElement.addElement(element);
1393
        return element;
1394
    }
1395

    
1396
    /**
1397
     * <p>
1398
     * createHeadlineSection
1399
     * </p>
1400
     *
1401
     * @param parentElement
1402
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1403
     *            object.
1404
     * @return a
1405
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1406
     *         object.
1407
     */
1408
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1409
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1410
        parentElement.addElement(section);
1411
        adapt(section);
1412
        return section;
1413
    }
1414

    
1415
    /**
1416
     * <p>
1417
     * createParsingMessageElement
1418
     * </p>
1419
     *
1420
     * @param parentElement
1421
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1422
     *            object.
1423
     * @param parserProblem
1424
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1425
     *            object.
1426
     * @param style
1427
     *            a int.
1428
     * @return a
1429
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1430
     *         object.
1431
     */
1432
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1433
            ParserProblem parserProblem, int style) {
1434
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1435
        adapt(element);
1436
        parentElement.addElement(element);
1437
        return element;
1438
    }
1439

    
1440
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1441
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1442

    
1443
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1444
                selectionProvider, style);
1445

    
1446
        parentElement.addElement(section);
1447
        adapt(section);
1448
        return section;
1449

    
1450
    }
1451

    
1452
    /**
1453
     * @param definedTermClass
1454
     * @param formElement
1455
     * @param style
1456
     * @return
1457
     */
1458
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1459
            AbstractCdmDetailSection parentElement, int style) {
1460
        AbstractCdmDetailElement element = null;
1461

    
1462
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1463
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1464
        } else if (definedTermClass.equals(Feature.class)) {
1465
            element = new FeatureDetailElement(this, parentElement);
1466
        } else {
1467
            element = new DefinedTermDetailElement(this, parentElement);
1468
        }
1469

    
1470
        adapt(element);
1471
        parentElement.addElement(element);
1472
        return element;
1473
    }
1474

    
1475

    
1476
    //--------DetailSections---------
1477
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1478
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1479
        addAndAdaptSection(parentElement, section);
1480
        return section;
1481
    }
1482

    
1483
    public ReferenceDetailSection createReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1484
        ReferenceDetailSection section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1485
        addAndAdaptSection(parentElement, section);
1486
        return section;
1487
    }
1488

    
1489
    public NomenclaturalReferenceDetailSection createNomenclaturalReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1490
        NomenclaturalReferenceDetailSection section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1491
        addAndAdaptSection(parentElement, section);
1492
        return section;
1493
    }
1494

    
1495
    public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1496
        TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1497
        addAndAdaptSection(parentElement, section);
1498
        return section;
1499
    }
1500

    
1501
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1502
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1503
        addAndAdaptSection(parentElement, section);
1504
        return section;
1505
    }
1506

    
1507
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1508
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1509
        addAndAdaptSection(parentElement, section);
1510
        return section;
1511
    }
1512

    
1513
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1514
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1515
        addAndAdaptSection(parentElement, section);
1516
        return section;
1517
    }
1518

    
1519
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1520
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1521
        addAndAdaptSection(parentElement, section);
1522
        return section;
1523
    }
1524

    
1525
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1526
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1527
        addAndAdaptSection(parentElement, section);
1528
        return section;
1529
    }
1530

    
1531
    public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1532
        DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1533
        addAndAdaptSection(parentElement, section);
1534
        return section;
1535
    }
1536

    
1537
    public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1538
        ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1539
        addAndAdaptSection(parentElement, section);
1540
        return section;
1541
    }
1542

    
1543
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1544
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, style);
1545
        addAndAdaptSection(parentElement, section);
1546
        return section;
1547
    }
1548

    
1549
    public MediaDetailsSection createMediaDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1550
        MediaDetailsSection section = new MediaDetailsSection(this, conversation, parentElement, selectionProvider, style);
1551
        addAndAdaptSection(parentElement, section);
1552
        return section;
1553
    }
1554

    
1555
    public FieldUnitDetailSection createFieldUnitDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1556
        FieldUnitDetailSection section = new FieldUnitDetailSection(this, conversation, parentElement, selectionProvider, style);
1557
        addAndAdaptSection(parentElement, section);
1558
        return section;
1559
    }
1560

    
1561
    public GatheringEventDetailSection createGatheringEventDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1562
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1563
        addAndAdaptSection(parentElement, section);
1564
        return section;
1565
    }
1566

    
1567
    public SpecimenHierarchyDetailSection createSpecimenHierarchyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1568
        SpecimenHierarchyDetailSection section = new SpecimenHierarchyDetailSection(this, conversation, parentElement, selectionProvider, style);
1569
        addAndAdaptSection(parentElement, section);
1570
        return section;
1571
    }
1572

    
1573
    public DerivedUnitBaseDetailSection createDerivedUnitBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1574
        DerivedUnitBaseDetailSection section = new DerivedUnitBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1575
        addAndAdaptSection(parentElement, section);
1576
        return section;
1577
    }
1578

    
1579
    public TaxonAssociationDetailSection createTaxonAssociationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1580
        TaxonAssociationDetailSection section = new TaxonAssociationDetailSection(this, conversation, parentElement, selectionProvider, style);
1581
        addAndAdaptSection(parentElement, section);
1582
        return section;
1583
    }
1584

    
1585
    public OriginalLabelDataSection createOriginalLabelDataSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1586
        OriginalLabelDataSection section = new OriginalLabelDataSection(this, conversation, parentElement, selectionProvider, style);
1587
        addAndAdaptSection(parentElement, section);
1588
        return section;
1589
    }
1590

    
1591
    public NaturalLanguageSection createNaturalLanguageSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1592
        NaturalLanguageSection section = new NaturalLanguageSection(this, conversation, parentElement, selectionProvider, style);
1593
        addAndAdaptSection(parentElement, section);
1594
        return section;
1595
    }
1596

    
1597
    public FeatureDistributionDetailSection createFeatureDistributionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1598
        FeatureDistributionDetailSection section = new FeatureDistributionDetailSection(this, conversation, parentElement, selectionProvider, style);
1599
        addAndAdaptSection(parentElement, section);
1600
        return section;
1601
    }
1602

    
1603
    public ClassificationDetailSection createClassificationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1604
        ClassificationDetailSection section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style);
1605
        addAndAdaptSection(parentElement, section);
1606
        return section;
1607
    }
1608

    
1609
    public TaxonNodeDetailSection createTaxonNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1610
        TaxonNodeDetailSection section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1611
        addAndAdaptSection(parentElement, section);
1612
        return section;
1613
    }
1614

    
1615
    public PolytomousKeyDetailSection createPolytomousKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1616
        PolytomousKeyDetailSection section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
1617
        addAndAdaptSection(parentElement, section);
1618
        return section;
1619
    }
1620

    
1621
    public PolytomousKeyNodeDetailSection createPolytomousKeyNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1622
        PolytomousKeyNodeDetailSection section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1623
        addAndAdaptSection(parentElement, section);
1624
        return section;
1625
    }
1626

    
1627
    public InstitutionDetailSection createInstitutionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1628
        InstitutionDetailSection section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
1629
        addAndAdaptSection(parentElement, section);
1630
        return section;
1631
    }
1632

    
1633
    public FieldUnitGeneralDetailSection createFieldUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1634
        FieldUnitGeneralDetailSection section = new FieldUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1635
        addAndAdaptSection(parentElement, section);
1636
        return section;
1637
    }
1638

    
1639
    public DerivedUnitGeneralDetailSection createDerivedUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1640
        DerivedUnitGeneralDetailSection section = new DerivedUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1641
        addAndAdaptSection(parentElement, section);
1642
        return section;
1643
    }
1644

    
1645
    public PreservedSpecimenGeneralDetailSection createPreservedSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1646
        PreservedSpecimenGeneralDetailSection section = new PreservedSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1647
        addAndAdaptSection(parentElement, section);
1648
        return section;
1649
    }
1650

    
1651
    public TissueSampleGeneralDetailSection createTissueSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1652
        TissueSampleGeneralDetailSection section = new TissueSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1653
        addAndAdaptSection(parentElement, section);
1654
        return section;
1655
    }
1656

    
1657
    public DnaSampleGeneralDetailSection createDnaSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1658
        DnaSampleGeneralDetailSection section = new DnaSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1659
        addAndAdaptSection(parentElement, section);
1660
        return section;
1661
    }
1662

    
1663
    public DnaQualityDetailSection createDnaQualityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1664
        DnaQualityDetailSection section = new DnaQualityDetailSection(this, conversation, parentElement, selectionProvider, style);
1665
        addAndAdaptSection(parentElement, section);
1666
        return section;
1667
    }
1668

    
1669
    public SequenceGeneralDetailSection createSequenceGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1670
        SequenceGeneralDetailSection section = new SequenceGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1671
        addAndAdaptSection(parentElement, section);
1672
        return section;
1673
    }
1674

    
1675
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1676
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
1677
        addAndAdaptSection(parentElement, section);
1678
        return section;
1679
    }
1680

    
1681
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1682
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
1683
        addAndAdaptSection(parentElement, section);
1684
        return section;
1685
    }
1686

    
1687
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1688
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1689
        addAndAdaptSection(parentElement, section);
1690
        return section;
1691
    }
1692

    
1693
    public SingleReadGeneralDetailSection createSingleReadGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1694
        SingleReadGeneralDetailSection section = new SingleReadGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1695
        addAndAdaptSection(parentElement, section);
1696
        return section;
1697
    }
1698

    
1699
    public AmplificationGeneralDetailSection createAmplificationGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1700
        AmplificationGeneralDetailSection section = new AmplificationGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1701
        addAndAdaptSection(parentElement, section);
1702
        return section;
1703
    }
1704

    
1705
    public AmplificationPrimerDetailSection createAmplificationPrimerDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1706
        AmplificationPrimerDetailSection section = new AmplificationPrimerDetailSection(this, conversation, parentElement, selectionProvider, style);
1707
        addAndAdaptSection(parentElement, section);
1708
        return section;
1709
    }
1710

    
1711
    public AmplificationCloningDetailSection createAmplificationCloningDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1712
        AmplificationCloningDetailSection section = new AmplificationCloningDetailSection(this, conversation, parentElement, selectionProvider, style);
1713
        addAndAdaptSection(parentElement, section);
1714
        return section;
1715
    }
1716

    
1717
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1718
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1719
        addAndAdaptSection(parentElement, section);
1720
        return section;
1721
    }
1722

    
1723
    public MediaSpecimenGeneralDetailSection createMediaSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1724
        MediaSpecimenGeneralDetailSection section = new MediaSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1725
        addAndAdaptSection(parentElement, section);
1726
        return section;
1727
    }
1728

    
1729
    public HybridDetailSection createHybridDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1730
        HybridDetailSection section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
1731
        addAndAdaptSection(parentElement, section);
1732
        return section;
1733
    }
1734

    
1735
    public UserDetailSection createUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1736
        UserDetailSection section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
1737
        addAndAdaptSection(parentElement, section);
1738
        return section;
1739
    }
1740

    
1741
    public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1742
        GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
1743
        addAndAdaptSection(parentElement, section);
1744
        return section;
1745
    }
1746

    
1747
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1748
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1749
        addAndAdaptSection(parentElement, section);
1750
        return section;
1751
    }
1752

    
1753
    public SampleDesignationDetailSection createSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1754
        SampleDesignationDetailSection section = new SampleDesignationDetailSection(this, conversation, parentElement, selectionProvider, style);
1755
        addAndAdaptSection(parentElement, section);
1756
        return section;
1757
    }
1758

    
1759
    public PreservedSpecimenDeterminationDetailSection createPreservedSpecimenDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1760
        PreservedSpecimenDeterminationDetailSection section = new PreservedSpecimenDeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1761
        addAndAdaptSection(parentElement, section);
1762
        return section;
1763
    }
1764

    
1765
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1766
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1767
        addAndAdaptSection(parentElement, section);
1768
        return section;
1769
    }
1770

    
1771
    public ReferencedEntityDetailSection createReferencedEntityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1772
        ReferencedEntityDetailSection section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
1773
        addAndAdaptSection(parentElement, section);
1774
        return section;
1775
    }
1776

    
1777
    public TermVocabularyDetailSection createTermVocabularyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1778
        TermVocabularyDetailSection section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
1779
        addAndAdaptSection(parentElement, section);
1780
        return section;
1781
    }
1782

    
1783
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1784
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1785
        addAndAdaptSection(parentElement, section);
1786
        return section;
1787
    }
1788

    
1789
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1790
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
1791
        addAndAdaptSection(parentElement, section);
1792
        return section;
1793
    }
1794

    
1795
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1796
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
1797
        addAndAdaptSection(parentElement, section);
1798
        return section;
1799
    }
1800

    
1801
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1802
        parentElement.addElement(section);
1803
        adapt(section);
1804
    }
1805

    
1806
    //--------DetailElements------------
1807

    
1808
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1809
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1810
        addAndAdaptElement(parentElement, element);
1811
        return element;
1812
    }
1813

    
1814
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1815
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1816
        addAndAdaptElement(parentElement, element);
1817
        return element;
1818
    }
1819

    
1820
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1821
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1822
        addAndAdaptElement(parentElement, element);
1823
        return element;
1824
    }
1825

    
1826
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1827
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1828
        addAndAdaptElement(parentElement, element);
1829
        return element;
1830
    }
1831

    
1832
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1833
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1834
        addAndAdaptElement(parentElement, element);
1835
        return element;
1836
    }
1837

    
1838
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1839
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1840
        addAndAdaptElement(parentElement, element);
1841
        return element;
1842
    }
1843

    
1844
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1845
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
1846
        addAndAdaptElement(parentElement, element);
1847
        return element;
1848
    }
1849

    
1850
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
1851
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
1852
        addAndAdaptElement(parentElement, element);
1853
        return element;
1854
    }
1855

    
1856
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
1857
        UserDetailElement element = new UserDetailElement(this, parentElement);
1858
        addAndAdaptElement(parentElement, element);
1859
        return element;
1860
    }
1861

    
1862
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
1863
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
1864
        addAndAdaptElement(parentElement, element);
1865
        return element;
1866
    }
1867

    
1868
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
1869
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
1870
        addAndAdaptElement(parentElement, element);
1871
        return element;
1872
    }
1873

    
1874
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
1875
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
1876
        addAndAdaptElement(parentElement, element);
1877
        return element;
1878
    }
1879

    
1880
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
1881
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
1882
        addAndAdaptElement(parentElement, element);
1883
        return element;
1884
    }
1885

    
1886
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
1887
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
1888
        addAndAdaptElement(parentElement, element);
1889
        return element;
1890
    }
1891

    
1892
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement){
1893
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement);
1894
        addAndAdaptElement(parentElement, element);
1895
        return element;
1896
    }
1897

    
1898
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
1899
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
1900
        addAndAdaptElement(parentElement, element);
1901
        return element;
1902
    }
1903

    
1904
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
1905
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
1906
        addAndAdaptElement(parentElement, element);
1907
        return element;
1908
    }
1909

    
1910
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
1911
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
1912
        addAndAdaptElement(parentElement, element);
1913
        return element;
1914
    }
1915

    
1916
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
1917
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
1918
        addAndAdaptElement(parentElement, element);
1919
        return element;
1920
    }
1921

    
1922
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
1923
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
1924
        addAndAdaptElement(parentElement, element);
1925
        return element;
1926
    }
1927

    
1928
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
1929
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
1930
        addAndAdaptElement(parentElement, element);
1931
        return element;
1932
    }
1933

    
1934
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
1935
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
1936
        addAndAdaptElement(parentElement, element);
1937
        return element;
1938
    }
1939

    
1940
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style){
1941
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style);
1942
        addAndAdaptElement(parentElement, element);
1943
        return element;
1944
    }
1945

    
1946
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
1947
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
1948
        addAndAdaptElement(parentElement, element);
1949
        return element;
1950
    }
1951

    
1952
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
1953
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
1954
        addAndAdaptElement(parentElement, element);
1955
        return element;
1956
    }
1957

    
1958
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
1959
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
1960
        addAndAdaptElement(parentElement, element);
1961
        return element;
1962
    }
1963

    
1964
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
1965
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
1966
        addAndAdaptElement(parentElement, element);
1967
        return element;
1968
    }
1969

    
1970
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
1971
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
1972
        addAndAdaptElement(parentElement, element);
1973
        return element;
1974
    }
1975

    
1976

    
1977
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
1978
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
1979
        addAndAdaptElement(parentElement, element);
1980
        return element;
1981
    }
1982

    
1983
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
1984
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
1985
        addAndAdaptElement(parentElement, element);
1986
        return element;
1987
    }
1988

    
1989
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
1990
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
1991
        addAndAdaptElement(parentElement, element);
1992
        return element;
1993
    }
1994

    
1995
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
1996
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
1997
        addAndAdaptElement(parentElement, element);
1998
        return element;
1999
    }
2000

    
2001
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2002
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2003
        addAndAdaptElement(parentElement, element);
2004
        return element;
2005
    }
2006

    
2007
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2008
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2009
        addAndAdaptElement(parentElement, element);
2010
        return element;
2011
    }
2012

    
2013
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2014
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2015
        addAndAdaptElement(parentElement, element);
2016
        return element;
2017
    }
2018

    
2019
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2020
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2021
        addAndAdaptElement(parentElement, element);
2022
        return element;
2023
    }
2024

    
2025
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2026
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2027
        addAndAdaptElement(parentElement, element);
2028
        return element;
2029
    }
2030

    
2031
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2032
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2033
        addAndAdaptElement(parentElement, element);
2034
        return element;
2035
    }
2036

    
2037
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2038
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2039
        addAndAdaptElement(parentElement, element);
2040
        return element;
2041
    }
2042

    
2043
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2044
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2045
        addAndAdaptElement(parentElement, element);
2046
        return element;
2047
    }
2048

    
2049
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2050
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2051
        addAndAdaptElement(parentElement, element);
2052
        return element;
2053
    }
2054

    
2055
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2056
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2057
        addAndAdaptElement(parentElement, element);
2058
        return element;
2059
    }
2060

    
2061
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2062
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2063
        addAndAdaptElement(parentElement, element);
2064
        return element;
2065
    }
2066

    
2067
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2068
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2069
        addAndAdaptElement(parentElement, mediaDetailElement);
2070
        return mediaDetailElement;
2071
    }
2072

    
2073
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2074
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2075
        addAndAdaptElement(parentElement, element);
2076
        return element;
2077
    }
2078

    
2079
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2080
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2081
        addAndAdaptElement(parentElement, element);
2082
        return element;
2083
    }
2084

    
2085
    public SpecimenHierarchyDetailElement createSpecimenHierarchyDetailElement(ICdmFormElement parentElement) {
2086
        SpecimenHierarchyDetailElement element = new SpecimenHierarchyDetailElement(this, parentElement);
2087
        addAndAdaptElement(parentElement, element);
2088
        return element;
2089
    }
2090

    
2091
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2092
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2093
        addAndAdaptElement(parentElement, element);
2094
        return element;
2095
    }
2096

    
2097
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2098
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2099
        addAndAdaptElement(parentElement, element);
2100
        return element;
2101
    }
2102

    
2103
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2104
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2105
        addAndAdaptElement(parentElement, element);
2106
        return element;
2107
    }
2108

    
2109
    public PreservedSpecimenDeterminationDetailElement createPreservedSpecimenDeterminationDetailElement(ICdmFormElement parentElement) {
2110
        PreservedSpecimenDeterminationDetailElement element = new PreservedSpecimenDeterminationDetailElement(this, parentElement);
2111
        addAndAdaptElement(parentElement, element);
2112
        return element;
2113
    }
2114

    
2115
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2116
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2117
        addAndAdaptElement(parentElement, element);
2118
        return element;
2119
    }
2120

    
2121
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2122
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2123
        addAndAdaptElement(parentElement, element);
2124
        return element;
2125
    }
2126

    
2127
    /**
2128
     * @param parentElement
2129
     * @param element
2130
     */
2131
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2132
        adapt(element);
2133
        parentElement.addElement(element);
2134
    }
2135

    
2136
    //--------EntityCollectionSection----------
2137
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2138
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style);
2139
        addAndAdaptSection(parentElement, section);
2140
        return section;
2141
    }
2142

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2239
    public ScopeSection createScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2240
        ScopeSection section = new ScopeSection(this, conversation, parentElement, style);
2241
        addAndAdaptSection(parentElement, section);
2242
        return section;
2243
    }
2244

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

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

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

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

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

    
2275
    public StateVocabularyCollectionSection createStateVocabulariesSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2276
        StateVocabularyCollectionSection section = new StateVocabularyCollectionSection(this, conversation, parentElement, style);
2277
        addAndAdaptSection(parentElement, section);
2278
        return section;
2279
    }
2280

    
2281
    public RecommendedModifierVocabulariesCollectionSection createRecommendedModifierVocabulariesCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2282
        RecommendedModifierVocabulariesCollectionSection section = new RecommendedModifierVocabulariesCollectionSection(this, conversation, parentElement, style);
2283
        addAndAdaptSection(parentElement, section);
2284
        return section;
2285
    }
2286

    
2287
    public MeasurementUnitCollectionSection createMeasurementUnitCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2288
        MeasurementUnitCollectionSection section = new MeasurementUnitCollectionSection(this, conversation, parentElement, style);
2289
        addAndAdaptSection(parentElement, section);
2290
        return section;
2291
    }
2292

    
2293
    public StatisticalMeasureCollectionSection createStatisticalMeasureCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2294
        StatisticalMeasureCollectionSection section = new StatisticalMeasureCollectionSection(this, conversation, parentElement, style);
2295
        addAndAdaptSection(parentElement, section);
2296
        return section;
2297
    }
2298

    
2299
    public CollectingAreasDetailSection createCollectingAreasDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2300
        CollectingAreasDetailSection section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
2301
        addAndAdaptSection(parentElement, section);
2302
        return section;
2303
    }
2304

    
2305
    public GeoScopeDetailSection createGeoScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2306
        GeoScopeDetailSection section = new GeoScopeDetailSection(this, conversation, parentElement, style);
2307
        addAndAdaptSection(parentElement, section);
2308
        return section;
2309
    }
2310

    
2311
    public IdentifierDetailSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2312
        IdentifierDetailSection section = new IdentifierDetailSection(this, conversation, parentElement, style);
2313
        addAndAdaptSection(parentElement, section);
2314
        return section;
2315
    }
2316

    
2317
    public CurrentSampleDesignationDetailSection createCurrentSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2318
        CurrentSampleDesignationDetailSection section = new CurrentSampleDesignationDetailSection(this, conversation, parentElement, style);
2319
        addAndAdaptSection(parentElement, section);
2320
        return section;
2321
    }
2322

    
2323
    public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2324
        CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
2325
        addAndAdaptSection(parentElement, section);
2326
        return section;
2327
    }
2328

    
2329
    public PreservedSpecimenCurrentDeterminationDetailSection createPreservedSpecimenCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2330
        PreservedSpecimenCurrentDeterminationDetailSection section = new PreservedSpecimenCurrentDeterminationDetailSection(this, conversation, parentElement, style);
2331
        addAndAdaptSection(parentElement, section);
2332
        return section;
2333
    }
2334

    
2335
    public SampleDesignationHistoryDetailSection createSampleDesignationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2336
        SampleDesignationHistoryDetailSection section = new SampleDesignationHistoryDetailSection(this, conversation, parentElement, style);
2337
        addAndAdaptSection(parentElement, section);
2338
        return section;
2339
    }
2340

    
2341
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2342
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
2343
        addAndAdaptSection(parentElement, section);
2344
        return section;
2345
    }
2346

    
2347
    public PreservedSpecimenDeterminationHistoryDetailSection createPreservedSpecimenDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2348
        PreservedSpecimenDeterminationHistoryDetailSection section = new PreservedSpecimenDeterminationHistoryDetailSection(this, conversation, parentElement, style);
2349
        addAndAdaptSection(parentElement, section);
2350
        return section;
2351
    }
2352

    
2353
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2354
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
2355
        addAndAdaptSection(parentElement, section);
2356
        return section;
2357
    }
2358

    
2359
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2360
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2361
        addAndAdaptSection(parentElement, section);
2362
        return section;
2363
    }
2364

    
2365
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2366
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2367
        addAndAdaptSection(parentElement, section);
2368
        return section;
2369
    }
2370

    
2371
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2372
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2373
        addAndAdaptSection(parentElement, section);
2374
        return section;
2375
    }
2376

    
2377
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2378
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2379
        addAndAdaptSection(parentElement, section);
2380
        return section;
2381
    }
2382

    
2383
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2384
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2385
        addAndAdaptSection(parentElement, section);
2386
        return section;
2387
    }
2388

    
2389
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2390
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2391
        addAndAdaptSection(parentElement, section);
2392
        return section;
2393
    }
2394

    
2395
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2396
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2397
        addAndAdaptSection(parentElement, section);
2398
        return section;
2399
    }
2400

    
2401
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2402
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2403
        AbstractEntityCollectionElement element = null;
2404

    
2405
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2406

    
2407
        if (entity instanceof Annotation) {
2408
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2409
        } else if (entity instanceof Person) {
2410
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
2411
        } else if (entity instanceof Credit) {
2412
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2413
        } else if (entity instanceof Extension) {
2414
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2415
        } else if (entity instanceof Marker) {
2416
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2417
        } else if (entity instanceof Media) {
2418
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, true, style);
2419
        } else if (entity instanceof MediaRepresentation) {
2420
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2421
                    style);
2422
        } else if (entity instanceof ImageFile) {
2423
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2424
        } else if (entity instanceof MediaRepresentationPart) {
2425
            element = new MediaRepresentationPartElement(this, parentElement, (MediaRepresentationPart) entity,
2426
                    removeListener, style);
2427
        } else if (entity instanceof NomenclaturalStatus) {
2428
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2429
                    style);
2430
        } else if (entity instanceof Rights) {
2431
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2432
        } else if (entity instanceof DescriptionElementSource) {
2433
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2434
                    removeListener, style);
2435
        } else if (entity instanceof IdentifiableSource) {
2436
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2437
                    style);
2438
        } else if (entity instanceof DefinedTerm) {
2439
            switch(((DefinedTerm)entity).getTermType()) {
2440
            case Scope:
2441
                element = new ScopeElement(this,
2442
                        parentElement,
2443
                        (DefinedTerm) entity,
2444
                        removeListener,
2445
                        style);
2446
                break;
2447
            case Modifier:
2448
                element = new ModifierElement(this,
2449
                        parentElement,
2450
                        (DefinedTerm) entity,
2451
                        removeListener,
2452
                        style);
2453
                break;
2454
            default:
2455
                break;
2456

    
2457
            }
2458
        } else if (entity instanceof Reference) {
2459
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2460
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2461
            }
2462
            else{
2463
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2464
            }
2465
        } else if (entity instanceof NameTypeDesignation) {
2466
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2467
                    style);
2468
        } else if (entity instanceof NameRelationship) {
2469
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2470
                    style);
2471
        } else if (entity instanceof SynonymRelationship) {
2472
            element = new SynonymRelationshipDetailElement(this, parentElement, (SynonymRelationship) entity, removeListener,
2473
                    style);
2474
        } else if (entity instanceof SpecimenTypeDesignation) {
2475
            element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2476
                    removeListener, style);
2477
        } else if (entity instanceof StateData) {
2478
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2479
        } else if (entity instanceof StatisticalMeasurementValue) {
2480
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2481
                    removeListener, style);
2482
        } else if (entity instanceof DerivedUnit) {
2483
            switch(((DerivedUnit)entity).getRecordBasis()) {
2484
            case LivingSpecimen:
2485
            case PreservedSpecimen:
2486
            case OtherSpecimen:
2487
                element = new SpecimenCollectionDetailElement(this,
2488
                        parentElement,
2489
                        (DerivedUnit) entity,
2490
                        removeListener,
2491
                        style);
2492
                break;
2493
            default:
2494
                element = new DerivedUnitElement(this,
2495
                        parentElement,
2496
                        (DerivedUnit) entity,
2497
                        removeListener,
2498
                        style);
2499
            }
2500

    
2501
        } else if (entity instanceof NamedArea) {
2502
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2503
        } else if (entity instanceof DeterminationEvent) {
2504
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2505
        } else if (entity instanceof User) {
2506
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2507
        } else if (entity instanceof GrantedAuthority) {
2508
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity,
2509
                    removeListener, style);
2510
        } else if (entity instanceof Group) {
2511
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2512
        } else if (entity instanceof Taxon) {
2513
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2514
        } else if (entity instanceof DescriptionElementBase) {
2515
            // this is the special case for protologs, maybe we can do this
2516
            // differently when API improves
2517
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2518
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2519
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2520
            }
2521
        } else if (entity instanceof Identifier) {
2522
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2523
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2524
            }
2525
            else{
2526
                element = new IdentifierDetailElement(this, parentElement, (Identifier) entity, removeListener, style);
2527
            }
2528
        } else if (entity instanceof TermVocabulary) {
2529
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
2530
            switch (termVocabulary.getTermType()) {
2531
            case State:
2532
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
2533
                break;
2534
            case Modifier:
2535
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
2536
                break;
2537
            default:
2538
                break;
2539
            }
2540
        } else if (entity instanceof MeasurementUnit) {
2541
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2542
        } else if (entity instanceof StatisticalMeasure) {
2543
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2544
        }
2545

    
2546
        if (element == null) {
2547
            MessagingUtils.messageDialog("No element for entity", this,
2548
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2549
                            + entity, null);
2550
        }
2551

    
2552
        else{
2553
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2554
                element.setPersistentBackground(backgroundColor);
2555
            }
2556
            adapt(element);
2557
            parentElement.addElement(element);
2558
        }
2559

    
2560
        return element;
2561
    }
2562

    
2563
    /**
2564
     * <p>
2565
     * Creates a selection element for the given type T.
2566
     * </p>
2567
     * <p>
2568
     * <strong>Selection elements not handled by this method:</strong>
2569
     * <ul>
2570
     * <li>{@link TaxonNodeSelectionElement} see
2571
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2572
     * </li>
2573
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2574
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2575
     * </li>
2576
     * </ul>
2577
     * </p>
2578
     *
2579
     * @param clazz
2580
     *            a {@link Class} object of the type that you want the selection
2581
     *            element to handle
2582
     * @param parentElement
2583
     *            a {@link ICdmFormElement} object.
2584
     * @param labelString
2585
     *            a {@link String} object.
2586
     * @param selectionType
2587
     * @param selection
2588
     *            a {@link ICdmBase} object.
2589
     * @param style
2590
     *            a int.
2591
     * @param conversation
2592
     *            a {@link ConversationHolder} object.
2593
     * @return a {@link EntitySelectionElement} object.
2594
     */
2595
    public <T extends ICdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2596
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2597
            int style) {
2598
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2599
                labelString, selection, mode, style);
2600
        adapt(element);
2601
        parentElement.addElement(element);
2602
        return element;
2603
    }
2604

    
2605
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2606
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2607
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2608
                labelString, selection, mode, style);
2609
        adapt(element);
2610
        parentElement.addElement(element);
2611
        return element;
2612
    }
2613

    
2614
    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2615
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2616
            int mode, int style) {
2617
        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2618
                conversation, parentElement, labelString, selection, mode, style);
2619
        adapt(element);
2620
        parentElement.addElement(element);
2621
        return element;
2622
    }
2623

    
2624
    /** {@inheritDoc} */
2625
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2626
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2627
        adapt(labelElement);
2628
        parentElement.addElement(labelElement);
2629
        return labelElement;
2630
    }
2631

    
2632
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2633
        Label label = new Label(formElement.getLayoutComposite(), style);
2634
        label.setText(labelText+" (yyyy-MM-dd)");
2635
        DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, style);
2636
        dateElement.initController(this, formElement);
2637
        return dateElement;
2638
    }
2639

    
2640
    /**
2641
     * <p>
2642
     * Getter for the field <code>selectionProvider</code>.
2643
     * </p>
2644
     *
2645
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2646
     */
2647
    public ISelectionProvider getSelectionProvider() {
2648
        return selectionProvider;
2649
    }
2650

    
2651
    /**
2652
     * <p>
2653
     * createDetailedDescriptionDetailElement
2654
     * </p>
2655
     *
2656
     * @param parentElement
2657
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2658
     *            object.
2659
     * @param entity
2660
     *            a
2661
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2662
     *            object.
2663
     * @param style
2664
     *            a int.
2665
     * @return a
2666
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2667
     *         object.
2668
     */
2669
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2670
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2671
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2672

    
2673
        if (entity instanceof CategoricalData) {
2674
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2675
                    (CategoricalData) entity, style);
2676
        } else if (entity instanceof CommonTaxonName) {
2677
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2678
                    style);
2679
        } else if (entity instanceof Distribution) {
2680
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2681
                    style);
2682
        } else if (entity instanceof IndividualsAssociation) {
2683
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2684
                    (IndividualsAssociation) entity, style);
2685
        } else if (entity instanceof QuantitativeData) {
2686
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2687
                    (QuantitativeData) entity, style);
2688
        } else if (entity instanceof TaxonInteraction) {
2689
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2690
                    (TaxonInteraction) entity, style);
2691
        } else if (entity instanceof TextData) {
2692
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2693
        } else {
2694
            throw new IllegalStateException("There is no interface for the given description element");
2695
        }
2696
        adapt(detailedDescriptionElement);
2697
        parentElement.addElement(detailedDescriptionElement);
2698
        return detailedDescriptionElement;
2699

    
2700
    }
2701

    
2702
    /**
2703
     * Creates a styled text as a part of the form.
2704
     *
2705
     * @param parent
2706
     *            the text parent
2707
     * @param value
2708
     *            the text initial value
2709
     * @param style
2710
     *            the text style
2711
     * @return the text widget
2712
     */
2713
    public StyledText createStyledText(Composite parent, String value, int style) {
2714
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2715
        if (value != null) {
2716
            text.setText(value);
2717
        }
2718
        text.setForeground(getColors().getForeground());
2719
        text.setBackground(getColors().getBackground());
2720
        // text.addFocusListener(visibilityHandler);
2721
        return text;
2722
    }
2723

    
2724
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2725
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2726
        addAndAdaptSection(parentElement, section);
2727
        return section;
2728
    }
2729

    
2730
}
(6-6/40)