Project

General

Profile

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

    
331
/**
332
 * <p>
333
 * CdmFormFactory class.
334
 * </p>
335
 *
336
 * @author n.hoffmann
337
 * @created Feb 24, 2010
338
 * @version 1.0
339
 */
340
public class CdmFormFactory extends FormToolkit {
341

    
342
    private BoldFontHolder2 boldFontHolder2;
343
    private MouseListener selectionMouseHandler;
344
    private FocusListener selectionFocusHandler;
345

    
346
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
347

    
348
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
349

    
350
    private final int orientation = Window.getDefaultOrientation();
351
    private ISelectionProvider selectionProvider;
352

    
353
    /** Constant <code>EMPTY_SELECTION</code> */
354
    public static ISelection EMPTY_SELECTION = new ISelection() {
355
        @Override
356
        public boolean isEmpty() {
357
            return true;
358
        }
359
    };
360

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

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

    
387
    private void notifySelectionListeners(TypedEvent e) {
388
        Event event = new Event();
389
        event.widget = e.widget;
390
        SelectionEvent selectionEvent = new SelectionEvent(event);
391

    
392
        for (SelectionListener listener : selectionListenerList) {
393
            listener.widgetSelected(selectionEvent);
394
        }
395
    }
396

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

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

    
426
    /**
427
	 *
428
	 */
429
    private void init() {
430
        boldFontHolder2 = new BoldFontHolder2();
431
        selectionMouseHandler = new SelectionMouseHandler();
432
        selectionFocusHandler = new SelectionFocusHandler();
433
    }
434

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

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

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

    
490
    /** {@inheritDoc} */
491
    @Override
492
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
493
        if (trackFocus) {
494
            control.addFocusListener(selectionFocusHandler);
495
        }
496
        super.adapt(control, trackFocus, trackKeyboard);
497
    }
498

    
499
    /** {@inheritDoc} */
500
    @Override
501
    public void adapt(Composite composite) {
502
        composite.addMouseListener(selectionMouseHandler);
503
        super.adapt(composite);
504
    }
505

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

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

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

    
589
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
590
            KeyStatement keyStatement, int textHeight, int style) {
591
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
592
                textHeight, style);
593
        adapt(element);
594
        parentElement.addElement(element);
595
        return element;
596
    }
597

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

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

    
658
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
659
                textLimit, style);
660
        adapt(element);
661
        parentElement.addElement(element);
662
        return element;
663
    }
664

    
665
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
666
            int textHeight, int style) {
667
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
668
        adapt(element);
669
        parentElement.addElement(element);
670
        return element;
671
    }
672

    
673
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
674
            LSID initialLsid, int style) {
675
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
676
        adapt(element);
677
        parentElement.addElement(element);
678
        return element;
679
    }
680

    
681
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
682
            URI initialUri, int style) {
683
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
684
        adapt(element);
685
        parentElement.addElement(element);
686
        return element;
687
    }
688

    
689
    /**
690
     * @param element
691
     * @param string
692
     * @param uri
693
     * @param style
694
     * @return
695
     */
696
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
697
            IOpenUrlEnabled openUrlEnabled, int style) {
698
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
699
                style);
700
        adapt(element);
701
        parentElement.addElement(element);
702
        return element;
703
    }
704

    
705
    /**
706
     *
707
     * @param parentElement
708
     * @param labelString
709
     * @param conversationEnabled
710
     * @param user
711
     * @param style
712
     * @return
713
     */
714
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
715
            ConversationHolder conversation, User user, int style) {
716
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
717
        adapt(element);
718
        parentElement.addElement(element);
719
        return element;
720
    }
721

    
722
    /**
723
     * <p>
724
     * createIntegerTextWithLabelElement
725
     * </p>
726
     *
727
     * @param parentElement
728
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
729
     *            object.
730
     * @param labelString
731
     *            a {@link java.lang.String} object.
732
     * @param initialInteger
733
     *            a {@link java.lang.Integer} object.
734
     * @param style
735
     *            a int.
736
     * @return a
737
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
738
     *         object.
739
     */
740
	public NumberWithLabelElement createNumberTextWithLabelElement(
741
			ICdmFormElement parentElement, String labelString,
742
			Number initialNumber, int style) {
743
		NumberWithLabelElement element = new NumberWithLabelElement(this,
744
				parentElement, labelString, initialNumber, style);
745
		adapt(element);
746
		parentElement.addElement(element);
747
		return element;
748
	}
749

    
750
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
751
            String labelString, LanguageString languageString, int style) {
752
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
753
    }
754

    
755
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
756
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
757
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
758
                languageString, height, isMultiLine, style);
759
        adapt(element);
760
        parentElement.addElement(element);
761
        return element;
762
    }
763

    
764
    /**
765
     * <p>
766
     * createKeyValueViewerElement
767
     * </p>
768
     *
769
     * @param parentElement
770
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
771
     *            object.
772
     * @param keyHeading
773
     *            a {@link java.lang.String} object.
774
     * @param valueHeading
775
     *            a {@link java.lang.String} object.
776
     * @param map
777
     *            a {@link java.util.Map} object.
778
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
779
     *         object.
780
     */
781
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
782
            String valueHeading, Map<Object, Object> map) {
783
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
784
        adapt(element);
785
        parentElement.addElement(element);
786
        return element;
787
    }
788
    /**
789
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
790
     */
791
    @Deprecated
792
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
793
            ICdmFormElement parentElement, String labelString, T selection, int style) {
794
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString,
795
                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
            int style) {
807
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, true, style);
808
        adapt(element);
809
        parentElement.addElement(element);
810
        return element;
811
    }
812

    
813
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
814
			TermType termType,
815
			ICdmFormElement parentElement,
816
			String labelString,
817
			T selection,
818
			boolean addEmptyElement,
819
			int style) {
820
		TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, 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
            int style) {
832
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, true, style);
833
        adapt(element);
834
        parentElement.addElement(element);
835
        return element;
836
    }
837

    
838
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
839
	        TermVocabulary<?> termVocabulary,
840
	        ICdmFormElement parentElement,
841
	        String labelString,
842
	        T selection,
843
	        boolean addEmptyElement,
844
	        int style) {
845
	    TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style);
846
	    adapt(element);
847
	    parentElement.addElement(element);
848
	    return element;
849
	}
850

    
851
    /**
852
     * <p>
853
     * createEnumComboElement
854
     * </p>
855
     *
856
     * @param enumComboType
857
     *            a
858
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType}
859
     *            object.
860
     * @param parentElement
861
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
862
     *            object.
863
     * @param style
864
     *            a int.
865
     * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
866
     *         object.
867
     */
868
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
869
			Class<T> enumComboType, ICdmFormElement parentElement,
870
			int style) {
871
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
872
        adapt(element);
873
        parentElement.addElement(element);
874
        return element;
875
    }
876

    
877
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
878
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
879
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
880
	    adapt(element);
881
	    parentElement.addElement(element);
882
	    return element;
883
	}
884

    
885
    /**
886
     * <p>
887
     * createBrowserElement
888
     * </p>
889
     *
890
     * @param imageUri
891
     *            a {@link java.net.URI} object.
892
     * @param style
893
     *            a int.
894
     * @param parentElement
895
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
896
     *            object.
897
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
898
     *         object.
899
     */
900
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
901
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
902
        adapt(element);
903
        parentElement.addElement(element);
904
        return element;
905
    }
906

    
907
    /**
908
     * <p>
909
     * createImageElement
910
     * </p>
911
     *
912
     * @param parentElement
913
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
914
     *            object.
915
     * @param imageUri
916
     *            a {@link java.net.URI} object.
917
     * @param style
918
     *            a int.
919
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
920
     */
921
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
922
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
923
        adapt(element);
924
        parentElement.addElement(element);
925
        return element;
926
    }
927

    
928
    /**
929
     * <p>
930
     * createTextActionElement
931
     * </p>
932
     *
933
     * @param labelString
934
     *            a {@link java.lang.String} object.
935
     * @param initialText
936
     *            a {@link java.lang.String} object.
937
     * @param style
938
     *            a int.
939
     * @param parentElement
940
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
941
     *            object.
942
     * @param buttonLabel
943
     *            a {@link java.lang.String} object.
944
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
945
     *         object.
946
     */
947
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
948
            String buttonLabel, String initialText, int style) {
949
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
950
                style);
951
        adapt(element);
952
        parentElement.addElement(element);
953
        return element;
954
    }
955

    
956
    /**
957
     * <p>
958
     * createCheckbox
959
     * </p>
960
     *
961
     * @param parentElement
962
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
963
     *            object.
964
     * @param label
965
     *            a {@link java.lang.String} object.
966
     * @param initialState
967
     *            a boolean.
968
     * @param style
969
     *            a int.
970
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
971
     *         object.
972
     */
973
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
974
        if(initialState==null){
975
            initialState = Boolean.FALSE;
976
        }
977
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
978
        adapt(element);
979
        parentElement.addElement(element);
980
        return element;
981
    }
982

    
983
    /**
984
     * Creates a section as a part of the form.
985
     *
986
     * @return the section widget
987
     * @param section
988
     *            a
989
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
990
     *            object.
991
     */
992
    public Section adapt(AbstractFormSection section) {
993
        section.setMenu(section.getLayoutComposite().getMenu());
994
        adapt(section, true, true);
995

    
996
        // handle focus and property change events for cdm use
997
        section.addFocusListener(selectionFocusHandler);
998
        section.setPropertyChangeListeners(propertyChangeListeners);
999

    
1000
        if (section.getToggle() != null) {
1001
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1002
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1003
        }
1004

    
1005
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1006

    
1007
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1008
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1009
            getColors().initializeSectionToolBarColors();
1010
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1011
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1012
        }
1013
        // call setTitleBarForeground regardless as it also sets the label color
1014
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1015
        return section;
1016
    }
1017

    
1018
    private class BoldFontHolder2 {
1019
        private Font normalFont;
1020

    
1021
        private Font boldFont;
1022

    
1023
        public BoldFontHolder2() {
1024
        }
1025

    
1026
        public Font getBoldFont(Font font) {
1027
            createBoldFont(font);
1028
            return boldFont;
1029
        }
1030

    
1031
        private void createBoldFont(Font font) {
1032
            if (normalFont == null || !normalFont.equals(font)) {
1033
                normalFont = font;
1034
                dispose();
1035
            }
1036
            if (boldFont == null) {
1037
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1038
            }
1039
        }
1040

    
1041
        public void dispose() {
1042
            if (boldFont != null) {
1043
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1044
                boldFont = null;
1045
            }
1046
        }
1047
    }
1048

    
1049
    /**
1050
     * <p>
1051
     * createToggleableTextField
1052
     * </p>
1053
     *
1054
     * @param parentElement
1055
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1056
     *            object.
1057
     * @param labelString
1058
     *            a {@link java.lang.String} object.
1059
     * @param initialText
1060
     *            a {@link java.lang.String} object.
1061
     * @param initialState
1062
     *            a boolean.
1063
     * @param style
1064
     *            a int.
1065
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1066
     *         object.
1067
     */
1068
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1069
            String initialText, boolean initialState, int style) {
1070
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1071
                initialState, style | orientation);
1072
        adapt(element);
1073
        parentElement.addElement(element);
1074
        return element;
1075
    }
1076

    
1077
    /**
1078
     * <p>
1079
     * createTimePeriodElement
1080
     * </p>
1081
     *
1082
     * @param parentElement
1083
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1084
     *            object.
1085
     * @param labelString
1086
     *            a {@link java.lang.String} object.
1087
     * @param timePeriod
1088
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1089
     * @param style
1090
     *            a int.
1091
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1092
     *         object.
1093
     */
1094
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1095
            TimePeriod timePeriod, int style) {
1096
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1097
        adapt(element);
1098
        parentElement.addElement(element);
1099
        return element;
1100
    }
1101

    
1102
	/**
1103
	 * <p>
1104
	 * createGatheringEventUnitElement
1105
	 * </p>
1106
	 *
1107
	 * @param parentElement
1108
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1109
	 *            object.
1110
	 * @param labelString
1111
	 *            a {@link java.lang.String} object.
1112
	 * @param timePeriod
1113
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1114
	 * @param style
1115
	 *            a int.
1116
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1117
	 *         object.
1118
	 */
1119
	public GatheringEventUnitElement createGatheringEventUnitElement(
1120
			ICdmFormElement parentElement,
1121
			String labelString,
1122
			DerivedUnitFacade gatheringEvent,
1123
			MinMaxTextSection.UnitType unitType,
1124
			int style) {
1125
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1126
				parentElement,
1127
				labelString,
1128
				gatheringEvent,
1129
				unitType,
1130
				style);
1131
		adapt(element);
1132
		parentElement.addElement(element);
1133
		return element;
1134
	}
1135

    
1136
    /**
1137
     * <p>
1138
     * createPointElement
1139
     * </p>
1140
     *
1141
     * @param style
1142
     *            a int.
1143
     * @param parentElement
1144
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1145
     *            object.
1146
     * @param point
1147
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1148
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1149
     */
1150
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1151
        PointElement element = new PointElement(this, parentElement, point, style);
1152
        adapt(element);
1153
        parentElement.addElement(element);
1154
        return element;
1155
    }
1156

    
1157

    
1158

    
1159
    /**
1160
     * @param conversationHolder
1161
     * @param parent
1162
     * @param detailsViewer
1163
     * @param i
1164
     * @return
1165
     */
1166
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1167
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1168
        parentElement.addElement(section);
1169
        adapt(section);
1170
        return section;
1171
    }
1172

    
1173
    /**
1174
     * <p>
1175
     * createDateDetailSection
1176
     * </p>
1177
     *
1178
     * @param parentElement
1179
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1180
     *            object.
1181
     * @param style
1182
     *            a int.
1183
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1184
     *         object.
1185
     */
1186
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1187
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1188
        parentElement.addElement(section);
1189
        adapt(section);
1190
        return section;
1191
    }
1192

    
1193
	/**
1194
	 * <p>
1195
	 * createDateDetailSection
1196
	 * </p>
1197
	 *
1198
	 * @param parentElement
1199
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1200
	 *            object.
1201
	 * @param style
1202
	 *            a int.
1203
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1204
	 *         object.
1205
	 */
1206
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1207
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1208
		parentElement.addElement(section);
1209
		adapt(section);
1210
		return section;
1211
	}
1212

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

    
1238
    /**
1239
     * <p>
1240
     * addSelectionListener
1241
     * </p>
1242
     *
1243
     * @param listener
1244
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1245
     */
1246
    public void addSelectionListener(SelectionListener listener) {
1247
        selectionListenerList.add(listener);
1248
    }
1249

    
1250
    /**
1251
     * <p>
1252
     * removeSelectionListener
1253
     * </p>
1254
     *
1255
     * @param listener
1256
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1257
     */
1258
    public void removeSelectionListener(SelectionListener listener) {
1259
        if (listener == null) {
1260
            MessagingUtils.error(this.getClass(),
1261
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1262
        } else {
1263
            selectionListenerList.remove(listener);
1264
        }
1265
    }
1266

    
1267
    /**
1268
     * <p>
1269
     * addPropertyChangeListener
1270
     * </p>
1271
     *
1272
     * @param listener
1273
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1274
     *            object.
1275
     */
1276
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1277
        if (propertyChangeListeners.contains(listener)) {
1278
            return;
1279
        }
1280
        propertyChangeListeners.add(0, listener);
1281
    }
1282

    
1283
    /**
1284
     * <p>
1285
     * removePropertyChangeListener
1286
     * </p>
1287
     *
1288
     * @param listener
1289
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1290
     *            object.
1291
     */
1292
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1293
        propertyChangeListeners.remove(listener);
1294
    }
1295

    
1296
    /**
1297
     * @return the propertyChangeListeners
1298
     */
1299
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1300
        return propertyChangeListeners;
1301
    }
1302

    
1303
    /**
1304
     * <p>
1305
     * createHorizontalSeparator
1306
     * </p>
1307
     *
1308
     * @param parentElement
1309
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1310
     *            object.
1311
     * @param style
1312
     *            a int.
1313
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1314
     */
1315
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1316
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1317
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1318
        return separator;
1319
    }
1320

    
1321
    /**
1322
     * <p>
1323
     * createVersionElement
1324
     * </p>
1325
     *
1326
     * @param parentElement
1327
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1328
     *            object.
1329
     * @param entity
1330
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1331
     *            object.
1332
     * @param style
1333
     *            a int.
1334
     * @return a
1335
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1336
     *         object.
1337
     */
1338
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1339
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1340
        adapt(element);
1341
        parentElement.addElement(element);
1342
        return element;
1343
    }
1344

    
1345
    /**
1346
     * @param cdmBaseSection
1347
     * @param object
1348
     * @param style
1349
     * @return
1350
     */
1351
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1352
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1353
        adapt(element);
1354
        parentElement.addElement(element);
1355
        return element;
1356
    }
1357

    
1358
    /**
1359
     * <p>
1360
     * createVersionSection
1361
     * </p>
1362
     *
1363
     * @param parentElement
1364
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1365
     *            object.
1366
     * @param style
1367
     *            a int.
1368
     * @return a
1369
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1370
     *         object.
1371
     */
1372
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1373
        VersionSection section = new VersionSection(this, parentElement, style);
1374
        parentElement.addElement(section);
1375
        adapt(section);
1376
        return section;
1377
    }
1378

    
1379
    /**
1380
     * @param parent
1381
     * @param i
1382
     * @return
1383
     */
1384
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1385
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1386
        parentElement.addElement(section);
1387
        adapt(section);
1388
        return section;
1389
    }
1390

    
1391
    /**
1392
     * <p>
1393
     * createEmptyElement
1394
     * </p>
1395
     *
1396
     * @param parentElement
1397
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1398
     *            object.
1399
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1400
     */
1401
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1402
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1403
        adapt(element);
1404
        parentElement.addElement(element);
1405
        return element;
1406
    }
1407

    
1408
    /**
1409
     * <p>
1410
     * createHeadlineSection
1411
     * </p>
1412
     *
1413
     * @param parentElement
1414
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1415
     *            object.
1416
     * @return a
1417
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1418
     *         object.
1419
     */
1420
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1421
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1422
        parentElement.addElement(section);
1423
        adapt(section);
1424
        return section;
1425
    }
1426

    
1427
    /**
1428
     * <p>
1429
     * createParsingMessageElement
1430
     * </p>
1431
     *
1432
     * @param parentElement
1433
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1434
     *            object.
1435
     * @param parserProblem
1436
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1437
     *            object.
1438
     * @param style
1439
     *            a int.
1440
     * @return a
1441
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1442
     *         object.
1443
     */
1444
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1445
            ParserProblem parserProblem, int style) {
1446
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1447
        adapt(element);
1448
        parentElement.addElement(element);
1449
        return element;
1450
    }
1451

    
1452
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1453
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1454

    
1455
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1456
                selectionProvider, style);
1457

    
1458
        parentElement.addElement(section);
1459
        adapt(section);
1460
        return section;
1461

    
1462
    }
1463

    
1464
    /**
1465
     * @param definedTermClass
1466
     * @param formElement
1467
     * @param style
1468
     * @return
1469
     */
1470
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1471
            AbstractCdmDetailSection parentElement, int style) {
1472
        AbstractCdmDetailElement element = null;
1473

    
1474
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1475
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1476
        } else if (definedTermClass.equals(Feature.class)) {
1477
            element = new FeatureDetailElement(this, parentElement);
1478
        } else {
1479
            element = new DefinedTermDetailElement(this, parentElement);
1480
        }
1481

    
1482
        adapt(element);
1483
        parentElement.addElement(element);
1484
        return element;
1485
    }
1486

    
1487

    
1488
    //--------DetailSections---------
1489
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1490
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1491
        addAndAdaptSection(parentElement, section);
1492
        return section;
1493
    }
1494

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

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

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

    
1513
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1514
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1515
        addAndAdaptSection(parentElement, section);
1516
        return section;
1517
    }
1518

    
1519
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1520
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1521
        addAndAdaptSection(parentElement, section);
1522
        return section;
1523
    }
1524

    
1525
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1526
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1527
        addAndAdaptSection(parentElement, section);
1528
        return section;
1529
    }
1530

    
1531
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1532
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1533
        addAndAdaptSection(parentElement, section);
1534
        return section;
1535
    }
1536

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1819
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1820
        parentElement.addElement(section);
1821
        adapt(section);
1822
    }
1823

    
1824
    //--------DetailElements------------
1825

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

    
1832
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1833
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1834
        addAndAdaptElement(parentElement, element);
1835
        return element;
1836
    }
1837

    
1838
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1839
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1840
        addAndAdaptElement(parentElement, element);
1841
        return element;
1842
    }
1843

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1922
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
1923
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
1924
        addAndAdaptElement(parentElement, element);
1925
        return element;
1926
    }
1927

    
1928
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
1929
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
1930
        addAndAdaptElement(parentElement, element);
1931
        return element;
1932
    }
1933

    
1934
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
1935
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
1936
        addAndAdaptElement(parentElement, element);
1937
        return element;
1938
    }
1939

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

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

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

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

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

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

    
1976
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
1977
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
1978
        addAndAdaptElement(parentElement, element);
1979
        return element;
1980
    }
1981

    
1982
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
1983
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
1984
        addAndAdaptElement(parentElement, element);
1985
        return element;
1986
    }
1987

    
1988
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
1989
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
1990
        addAndAdaptElement(parentElement, element);
1991
        return element;
1992
    }
1993

    
1994

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

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

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

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

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

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

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

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

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

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

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

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

    
2067
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2068
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2069
        addAndAdaptElement(parentElement, element);
2070
        return element;
2071
    }
2072

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

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

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

    
2091
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2092
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2093
        addAndAdaptElement(parentElement, mediaDetailElement);
2094
        return mediaDetailElement;
2095
    }
2096

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

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

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

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

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

    
2127
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2128
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2129
        addAndAdaptElement(parentElement, element);
2130
        return element;
2131
    }
2132

    
2133
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2134
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2135
        addAndAdaptElement(parentElement, element);
2136
        return element;
2137
    }
2138

    
2139
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2140
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2141
        addAndAdaptElement(parentElement, element);
2142
        return element;
2143
    }
2144

    
2145
    /**
2146
     * @param parentElement
2147
     * @param element
2148
     */
2149
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2150
        adapt(element);
2151
        parentElement.addElement(element);
2152
    }
2153

    
2154
    //--------EntityCollectionSection----------
2155
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2156
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style);
2157
        addAndAdaptSection(parentElement, section);
2158
        return section;
2159
    }
2160

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2401
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2402
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2403
        addAndAdaptSection(parentElement, section);
2404
        return section;
2405
    }
2406

    
2407
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2408
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2409
        addAndAdaptSection(parentElement, section);
2410
        return section;
2411
    }
2412

    
2413
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2414
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2415
        addAndAdaptSection(parentElement, section);
2416
        return section;
2417
    }
2418

    
2419
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2420
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2421
        AbstractEntityCollectionElement element = null;
2422

    
2423
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2424

    
2425
        if (entity instanceof Annotation) {
2426
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2427
        } else if (entity instanceof Person) {
2428
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
2429
        } else if (entity instanceof Credit) {
2430
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2431
        } else if (entity instanceof Extension) {
2432
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2433
        } else if (entity instanceof Marker) {
2434
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2435
        } else if (entity instanceof Media) {
2436
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, true, style);
2437
        } else if (entity instanceof MediaRepresentation) {
2438
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2439
                    style);
2440
        } else if (entity instanceof ImageFile) {
2441
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2442
        } else if (entity instanceof MediaRepresentationPart) {
2443
            element = new MediaRepresentationPartElement(this, parentElement, (MediaRepresentationPart) entity,
2444
                    removeListener, style);
2445
        } else if (entity instanceof NomenclaturalStatus) {
2446
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2447
                    style);
2448
        } else if (entity instanceof Rights) {
2449
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2450
        } else if (entity instanceof DescriptionElementSource) {
2451
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2452
                    removeListener, style);
2453
        } else if (entity instanceof IdentifiableSource) {
2454
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2455
                    style);
2456
        } else if (entity instanceof DefinedTerm) {
2457
            switch(((DefinedTerm)entity).getTermType()) {
2458
            case Scope:
2459
                element = new ScopeElement(this,
2460
                        parentElement,
2461
                        (DefinedTerm) entity,
2462
                        removeListener,
2463
                        style);
2464
                break;
2465
            case Modifier:
2466
                element = new ModifierElement(this,
2467
                        parentElement,
2468
                        (DefinedTerm) entity,
2469
                        removeListener,
2470
                        style);
2471
                break;
2472
            default:
2473
                break;
2474

    
2475
            }
2476
        } else if (entity instanceof Reference) {
2477
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2478
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2479
            }
2480
            else{
2481
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2482
            }
2483
        } else if (entity instanceof NameTypeDesignation) {
2484
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2485
                    style);
2486
        } else if (entity instanceof NameRelationship) {
2487
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2488
                    style);
2489
        } else if (entity instanceof SynonymRelationship) {
2490
            element = new SynonymRelationshipDetailElement(this, parentElement, (SynonymRelationship) entity, removeListener,
2491
                    style);
2492
        } else if (entity instanceof SpecimenTypeDesignation) {
2493
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
2494
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2495
                        removeListener, style);
2496
            }
2497
            else{
2498
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2499
                        removeListener, style);
2500
            }
2501
        } else if (entity instanceof StateData) {
2502
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2503
        } else if (entity instanceof StatisticalMeasurementValue) {
2504
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2505
                    removeListener, style);
2506
        } else if (entity instanceof DerivedUnit) {
2507
            switch(((DerivedUnit)entity).getRecordBasis()) {
2508
            case LivingSpecimen:
2509
            case PreservedSpecimen:
2510
            case OtherSpecimen:
2511
                element = new SpecimenCollectionDetailElement(this,
2512
                        parentElement,
2513
                        (DerivedUnit) entity,
2514
                        removeListener,
2515
                        style);
2516
                break;
2517
            default:
2518
                element = new DerivedUnitElement(this,
2519
                        parentElement,
2520
                        (DerivedUnit) entity,
2521
                        removeListener,
2522
                        style);
2523
            }
2524

    
2525
        } else if (entity instanceof NamedArea) {
2526
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2527
        } else if (entity instanceof DeterminationEvent) {
2528
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2529
        } else if (entity instanceof User) {
2530
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2531
        } else if (entity instanceof GrantedAuthority) {
2532
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity,
2533
                    removeListener, style);
2534
        } else if (entity instanceof Group) {
2535
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2536
        } else if (entity instanceof Taxon) {
2537
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2538
        } else if (entity instanceof DescriptionElementBase) {
2539
            // this is the special case for protologs, maybe we can do this
2540
            // differently when API improves
2541
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2542
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2543
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2544
            }
2545
        } else if (entity instanceof Identifier) {
2546
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2547
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2548
            }
2549
            else{
2550
                element = new IdentifierDetailElement(this, parentElement, (Identifier) entity, removeListener, style);
2551
            }
2552
        } else if (entity instanceof TermVocabulary) {
2553
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
2554
            switch (termVocabulary.getTermType()) {
2555
            case State:
2556
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
2557
                break;
2558
            case Modifier:
2559
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
2560
                break;
2561
            default:
2562
                break;
2563
            }
2564
        } else if (entity instanceof MeasurementUnit) {
2565
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2566
        } else if (entity instanceof StatisticalMeasure) {
2567
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2568
        }
2569

    
2570
        if (element == null) {
2571
            MessagingUtils.messageDialog("No element for entity", this,
2572
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2573
                            + entity, null);
2574
        }
2575

    
2576
        else{
2577
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2578
                element.setPersistentBackground(backgroundColor);
2579
            }
2580
            adapt(element);
2581
            parentElement.addElement(element);
2582
        }
2583

    
2584
        return element;
2585
    }
2586

    
2587
    /**
2588
     * <p>
2589
     * Creates a selection element for the given type T.
2590
     * </p>
2591
     * <p>
2592
     * <strong>Selection elements not handled by this method:</strong>
2593
     * <ul>
2594
     * <li>{@link TaxonNodeSelectionElement} see
2595
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2596
     * </li>
2597
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2598
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2599
     * </li>
2600
     * </ul>
2601
     * </p>
2602
     *
2603
     * @param clazz
2604
     *            a {@link Class} object of the type that you want the selection
2605
     *            element to handle
2606
     * @param parentElement
2607
     *            a {@link ICdmFormElement} object.
2608
     * @param labelString
2609
     *            a {@link String} object.
2610
     * @param selectionType
2611
     * @param selection
2612
     *            a {@link ICdmBase} object.
2613
     * @param style
2614
     *            a int.
2615
     * @param conversation
2616
     *            a {@link ConversationHolder} object.
2617
     * @return a {@link EntitySelectionElement} object.
2618
     */
2619
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2620
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2621
            int style) {
2622
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2623
                labelString, selection, mode, style);
2624
        adapt(element);
2625
        parentElement.addElement(element);
2626
        return element;
2627
    }
2628

    
2629
    /**
2630
     * <p>
2631
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
2632
     * </p>
2633
     * <p>
2634
     * <strong>Selection elements not handled by this method:</strong>
2635
     * <ul>
2636
     * <li>{@link TaxonNodeSelectionElement} see
2637
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2638
     * </li>
2639
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2640
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2641
     * </li>
2642
     * </ul>
2643
     * </p>
2644
     *
2645
     * @param clazz
2646
     *            a {@link Class} object of the type that you want the selection
2647
     *            element to handle
2648
     * @param parentElement
2649
     *            a {@link ICdmFormElement} object.
2650
     * @param labelString
2651
     *            a {@link String} object.
2652
     * @param selectionType
2653
     * @param selection
2654
     *            a {@link ICdmBase} object.
2655
     * @param style
2656
     *            a int.
2657
     * @param conversation
2658
     *            a {@link ConversationHolder} object.
2659
     * @return a {@link EntitySelectionElement} object.
2660
     */
2661
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
2662
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
2663
            T selection, int mode, int style) {
2664
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, conversation, parentElement, clazz,
2665
                labelString, selection, mode, style);
2666
        adapt(element);
2667
        parentElement.addElement(element);
2668
        return element;
2669
    }
2670

    
2671
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2672
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2673
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2674
                labelString, selection, mode, style);
2675
        adapt(element);
2676
        parentElement.addElement(element);
2677
        return element;
2678
    }
2679

    
2680
    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2681
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2682
            int mode, int style) {
2683
        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2684
                conversation, parentElement, labelString, selection, mode, style);
2685
        adapt(element);
2686
        parentElement.addElement(element);
2687
        return element;
2688
    }
2689

    
2690
    /** {@inheritDoc} */
2691
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2692
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2693
        adapt(labelElement);
2694
        parentElement.addElement(labelElement);
2695
        return labelElement;
2696
    }
2697

    
2698
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2699
        Label label = new Label(formElement.getLayoutComposite(), style);
2700
        label.setText(labelText+" (yyyy-MM-dd)");
2701
        DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, style);
2702
        dateElement.initController(this, formElement);
2703
        return dateElement;
2704
    }
2705

    
2706
    /**
2707
     * <p>
2708
     * Getter for the field <code>selectionProvider</code>.
2709
     * </p>
2710
     *
2711
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2712
     */
2713
    public ISelectionProvider getSelectionProvider() {
2714
        return selectionProvider;
2715
    }
2716

    
2717
    /**
2718
     * <p>
2719
     * createDetailedDescriptionDetailElement
2720
     * </p>
2721
     *
2722
     * @param parentElement
2723
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2724
     *            object.
2725
     * @param entity
2726
     *            a
2727
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2728
     *            object.
2729
     * @param style
2730
     *            a int.
2731
     * @return a
2732
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2733
     *         object.
2734
     */
2735
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2736
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2737
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2738

    
2739
        if (entity instanceof CategoricalData) {
2740
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2741
                    (CategoricalData) entity, style);
2742
        } else if (entity instanceof CommonTaxonName) {
2743
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2744
                    style);
2745
        } else if (entity instanceof Distribution) {
2746
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2747
                    style);
2748
        } else if (entity instanceof IndividualsAssociation) {
2749
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2750
                    (IndividualsAssociation) entity, style);
2751
        } else if (entity instanceof QuantitativeData) {
2752
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2753
                    (QuantitativeData) entity, style);
2754
        } else if (entity instanceof TaxonInteraction) {
2755
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2756
                    (TaxonInteraction) entity, style);
2757
        } else if (entity instanceof TextData) {
2758
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2759
        } else {
2760
            throw new IllegalStateException("There is no interface for the given description element");
2761
        }
2762
        adapt(detailedDescriptionElement);
2763
        parentElement.addElement(detailedDescriptionElement);
2764
        return detailedDescriptionElement;
2765

    
2766
    }
2767

    
2768
    /**
2769
     * Creates a styled text as a part of the form.
2770
     *
2771
     * @param parent
2772
     *            the text parent
2773
     * @param value
2774
     *            the text initial value
2775
     * @param style
2776
     *            the text style
2777
     * @return the text widget
2778
     */
2779
    public StyledText createStyledText(Composite parent, String value, int style) {
2780
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2781
        if (value != null) {
2782
            text.setText(value);
2783
        }
2784
        text.setForeground(getColors().getForeground());
2785
        text.setBackground(getColors().getBackground());
2786
        // text.addFocusListener(visibilityHandler);
2787
        return text;
2788
    }
2789

    
2790
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2791
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2792
        addAndAdaptSection(parentElement, section);
2793
        return section;
2794
    }
2795

    
2796
}
(7-7/42)