Project

General

Profile

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

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

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

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

    
315
/**
316
 * <p>
317
 * CdmFormFactory class.
318
 * </p>
319
 *
320
 * @author n.hoffmann
321
 * @created Feb 24, 2010
322
 * @version 1.0
323
 */
324
public class CdmFormFactory extends FormToolkit {
325

    
326
    private BoldFontHolder2 boldFontHolder2;
327
    private MouseListener selectionMouseHandler;
328
    private FocusListener selectionFocusHandler;
329

    
330
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
331

    
332
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
333

    
334
    private final int orientation = Window.getDefaultOrientation();
335
    private ISelectionProvider selectionProvider;
336

    
337
    /** Constant <code>EMPTY_SELECTION</code> */
338
    public static ISelection EMPTY_SELECTION = new ISelection() {
339
        @Override
340
        public boolean isEmpty() {
341
            return true;
342
        }
343
    };
344

    
345
    /**
346
     *
347
     * @author n.hoffmann
348
     * @date Jan 25, 2010
349
     *
350
     */
351
    private class SelectionMouseHandler extends MouseAdapter {
352
        @Override
353
        public void mouseDown(MouseEvent e) {
354
            notifySelectionListeners(e);
355
        }
356
    }
357

    
358
    /**
359
     *
360
     * @author n.hoffmann
361
     * @date Jan 25, 2010
362
     *
363
     */
364
    private class SelectionFocusHandler extends FocusAdapter {
365
        @Override
366
        public void focusGained(FocusEvent e) {
367
            notifySelectionListeners(e);
368
        }
369
    }
370

    
371
    private void notifySelectionListeners(TypedEvent e) {
372
        Event event = new Event();
373
        event.widget = e.widget;
374
        SelectionEvent selectionEvent = new SelectionEvent(event);
375

    
376
        for (SelectionListener listener : selectionListenerList) {
377
            listener.widgetSelected(selectionEvent);
378
        }
379
    }
380

    
381
    /**
382
     * <p>
383
     * Constructor for CdmFormFactory.
384
     * </p>
385
     *
386
     * @param display
387
     *            a {@link org.eclipse.swt.widgets.Display} object.
388
     * @param selectionProvider
389
     *            a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
390
     */
391
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
392
        super(display);
393
        this.selectionProvider = selectionProvider;
394
        init();
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
     */
405
    public CdmFormFactory(Display display) {
406
        super(display);
407
        init();
408
    }
409

    
410
    /**
411
	 *
412
	 */
413
    private void init() {
414
        boldFontHolder2 = new BoldFontHolder2();
415
        selectionMouseHandler = new SelectionMouseHandler();
416
        selectionFocusHandler = new SelectionFocusHandler();
417
    }
418

    
419
    /**
420
     * Creates an instance initialized with the correct selectionProvider
421
     *
422
     * Make sure to remove the instance when the entityComposite disposes via
423
     * destroySelectionArbitrator(..)
424
     *
425
     * @param entityElement
426
     *            a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
427
     *            object.
428
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
429
     *         object.
430
     */
431
    public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
432
        SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
433
        selectionArbitrator.addSelectionProvider(selectionProvider);
434
        selectionProvider.addSelectionChangedListener(selectionArbitrator);
435
        addSelectionListener(selectionArbitrator);
436
        return selectionArbitrator;
437
    }
438

    
439
    /**
440
     * <p>
441
     * destroySelectionArbitrator
442
     * </p>
443
     *
444
     * @param selectionArbitrator
445
     *            a
446
     *            {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
447
     *            object.
448
     */
449
    public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
450
        removeSelectionListener(selectionArbitrator);
451
        if (selectionProvider != null) {
452
            selectionProvider.removeSelectionChangedListener(selectionArbitrator);
453
        } else {
454
            MessagingUtils.error(this.getClass(),
455
                    "Tried to destroy a selection listener from this factories listeners but was null", null);
456
        }
457
    }
458

    
459
    /**
460
     * <p>
461
     * Adapts the {@link AbstractCdmFormElement}:<br>
462
     * - sets the {@link IPropertyChangeListener}s handled by this class
463
     * </p>
464
     *
465
     * @param formElement
466
     *            a
467
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
468
     *            object.
469
     */
470
    public void adapt(ICdmFormElement formElement) {
471
        formElement.setPropertyChangeListeners(propertyChangeListeners);
472
    }
473

    
474
    /** {@inheritDoc} */
475
    @Override
476
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
477
        if (trackFocus) {
478
            control.addFocusListener(selectionFocusHandler);
479
        }
480
        super.adapt(control, trackFocus, trackKeyboard);
481
    }
482

    
483
    /** {@inheritDoc} */
484
    @Override
485
    public void adapt(Composite composite) {
486
        composite.addMouseListener(selectionMouseHandler);
487
        super.adapt(composite);
488
    }
489

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

    
531
    /**
532
     * <p>
533
     * createEmptyCell
534
     * </p>
535
     *
536
     * @param parent
537
     *            a {@link org.eclipse.swt.widgets.Composite} object.
538
     * @return a {@link org.eclipse.swt.widgets.Label} object.
539
     */
540
    public Label createEmptyCell(Composite parent) {
541
        return this.createLabel(parent, null);
542
    }
543

    
544
    /**
545
     * <p>
546
     * createMultiLanguageTextElement
547
     * </p>
548
     *
549
     * @param parentElement
550
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
551
     *            object.
552
     * @param labelString
553
     *            a {@link java.lang.String} object.
554
     * @param multilanguageText
555
     *            a {@link java.util.Map} object.
556
     * @param textHeight
557
     *            a int.
558
     * @param style
559
     *            a int.
560
     * @return a
561
     *         {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
562
     *         object.
563
     */
564
    public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
565
            Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
566
        MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
567
                multilanguageText, textHeight, style);
568
        adapt(element);
569
        parentElement.addElement(element);
570
        return element;
571
    }
572

    
573
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
574
            KeyStatement keyStatement, int textHeight, int style) {
575
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
576
                textHeight, style);
577
        adapt(element);
578
        parentElement.addElement(element);
579
        return element;
580
    }
581

    
582
    /**
583
     * Creates a text field with a label. The initial content will be the return value of the initalObject's {@link #toString()}
584
     * method.<br>
585
     * <b>Note</b>: if initialObject is <code>null</code> then an empty string is used.
586
     * @param parentElement the parent container
587
     * @param labelString the label name
588
     * @param initialObject the object from which the <code>toString()</code> method is called
589
     * @param style {@link SWT} style constant
590
     * @return the created textfield with label
591
     */
592
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
593
            Object initialObject, int style) {
594
        return createTextWithLabelElement(parentElement, labelString, initialObject==null?"":initialObject.toString(), style);
595
    }
596

    
597
    /**
598
     * <p>
599
     * createTextWithLabelElement
600
     * </p>
601
     *
602
     * @param parentElement
603
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
604
     *            object.
605
     * @param labelString
606
     *            a {@link java.lang.String} object.
607
     * @param initialText
608
     *            a {@link java.lang.String} object.
609
     * @param style
610
     *            a int.
611
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
612
     *         object.
613
     */
614
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
615
            String initialText, int style) {
616
        return createTextWithLabelElement(parentElement, labelString, initialText, null, style);
617
    }
618
    /**
619
     * <p>
620
     * createTextWithLabelElement
621
     * </p>
622
     *
623
     * @param parentElement
624
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
625
     *            object.
626
     * @param labelString
627
     *            a {@link java.lang.String} object.
628
     * @param initialText
629
     *            a {@link java.lang.String} object.
630
     * @param textLimit maximal number of characters allowed
631
     * @param style
632
     *            a int.
633
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
634
     *         object.
635
     */
636
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
637
            String initialText, Integer textLimit, int style) {
638
        if(initialText==null){
639
            initialText = "";
640
        }
641

    
642
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
643
                textLimit, style);
644
        adapt(element);
645
        parentElement.addElement(element);
646
        return element;
647
    }
648

    
649
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
650
            int textHeight, int style) {
651
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
652
        adapt(element);
653
        parentElement.addElement(element);
654
        return element;
655
    }
656

    
657
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
658
            URI initialUri, int style) {
659
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
660
        adapt(element);
661
        parentElement.addElement(element);
662
        return element;
663
    }
664

    
665
    /**
666
     * @param element
667
     * @param string
668
     * @param uri
669
     * @param style
670
     * @return
671
     */
672
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
673
            IOpenUrlEnabled openUrlEnabled, int style) {
674
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
675
                style);
676
        adapt(element);
677
        parentElement.addElement(element);
678
        return element;
679
    }
680

    
681
    /**
682
     *
683
     * @param parentElement
684
     * @param labelString
685
     * @param conversationEnabled
686
     * @param user
687
     * @param style
688
     * @return
689
     */
690
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
691
            ConversationHolder conversation, User user, int style) {
692
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
693
        adapt(element);
694
        parentElement.addElement(element);
695
        return element;
696
    }
697

    
698
    /**
699
     * <p>
700
     * createIntegerTextWithLabelElement
701
     * </p>
702
     *
703
     * @param parentElement
704
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
705
     *            object.
706
     * @param labelString
707
     *            a {@link java.lang.String} object.
708
     * @param initialInteger
709
     *            a {@link java.lang.Integer} object.
710
     * @param style
711
     *            a int.
712
     * @return a
713
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
714
     *         object.
715
     */
716
	public NumberWithLabelElement createNumberTextWithLabelElement(
717
			ICdmFormElement parentElement, String labelString,
718
			Number initialNumber, int style) {
719
		NumberWithLabelElement element = new NumberWithLabelElement(this,
720
				parentElement, labelString, initialNumber, style);
721
		adapt(element);
722
		parentElement.addElement(element);
723
		return element;
724
	}
725

    
726
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
727
            String labelString, LanguageString languageString, int style) {
728
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
729
    }
730

    
731
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
732
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
733
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
734
                languageString, height, isMultiLine, style);
735
        adapt(element);
736
        parentElement.addElement(element);
737
        return element;
738
    }
739

    
740
    /**
741
     * <p>
742
     * createKeyValueViewerElement
743
     * </p>
744
     *
745
     * @param parentElement
746
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
747
     *            object.
748
     * @param keyHeading
749
     *            a {@link java.lang.String} object.
750
     * @param valueHeading
751
     *            a {@link java.lang.String} object.
752
     * @param map
753
     *            a {@link java.util.Map} object.
754
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
755
     *         object.
756
     */
757
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
758
            String valueHeading, Map<Object, Object> map) {
759
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
760
        adapt(element);
761
        parentElement.addElement(element);
762
        return element;
763
    }
764

    
765
    /**
766
     * <p>
767
     * createTermComboElement
768
     * </p>
769
     *
770
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
771
     * @param termComboType
772
     *            a
773
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
774
     *            object.
775
     * @param parentElement
776
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
777
     *            object.
778
     * @param labelString
779
     *            a {@link java.lang.String} object.
780
     * @param selection
781
     *            a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
782
     *            object.
783
     * @param style
784
     *            a int.
785
     * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
786
     *         object.
787
     */
788
    @Deprecated
789
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
790
            ICdmFormElement parentElement, String labelString, T selection, int style) {
791
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString,
792
                selection, style);
793
        adapt(element);
794
        parentElement.addElement(element);
795
        return element;
796
    }
797

    
798
	/**
799
	 * <p>
800
	 * createTermComboElement
801
	 * </p>
802
	 *
803
	 * @param termComboType
804
	 *            a
805
	 *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
806
	 *            object.
807
	 * @param parentElement
808
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
809
	 *            object.
810
	 * @param labelString
811
	 *            a {@link java.lang.String} object.
812
	 * @param selection
813
	 *            a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
814
	 *            object.
815
	 * @param style
816
	 *            a int.
817
	 * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
818
	 *         object.
819
	 */
820

    
821
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
822
			TermType termType,
823
			ICdmFormElement parentElement,
824
			String labelString,
825
			T selection,
826
			int style) {
827
		TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, style);
828
		adapt(element);
829
		parentElement.addElement(element);
830
		return element;
831
	}
832

    
833
	/**
834
	 * <p>
835
	 * createTermComboElement
836
	 * </p>
837
	 *
838
	 * @param termComboType
839
	 *            a
840
	 *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
841
	 *            object.
842
	 * @param parentElement
843
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
844
	 *            object.
845
	 * @param labelString
846
	 *            a {@link java.lang.String} object.
847
	 * @param selection
848
	 *            a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
849
	 *            object.
850
	 * @param style
851
	 *            a int.
852
	 * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
853
	 *         object.
854
	 */
855

    
856
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
857
	        TermVocabulary<?> termVocabulary,
858
	        ICdmFormElement parentElement,
859
	        String labelString,
860
	        T selection,
861
	        int style) {
862
	    TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, style);
863
	    adapt(element);
864
	    parentElement.addElement(element);
865
	    return element;
866
	}
867

    
868
    /**
869
     * <p>
870
     * createEnumComboElement
871
     * </p>
872
     *
873
     * @param enumComboType
874
     *            a
875
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType}
876
     *            object.
877
     * @param parentElement
878
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
879
     *            object.
880
     * @param style
881
     *            a int.
882
     * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
883
     *         object.
884
     */
885
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
886
			Class<T> enumComboType, ICdmFormElement parentElement,
887
			int style) {
888
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
889
        adapt(element);
890
        parentElement.addElement(element);
891
        return element;
892
    }
893

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

    
916
    /**
917
     * <p>
918
     * createImageElement
919
     * </p>
920
     *
921
     * @param parentElement
922
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
923
     *            object.
924
     * @param imageUri
925
     *            a {@link java.net.URI} object.
926
     * @param style
927
     *            a int.
928
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
929
     */
930
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
931
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
932
        adapt(element);
933
        parentElement.addElement(element);
934
        return element;
935
    }
936

    
937
    /**
938
     * <p>
939
     * createTextActionElement
940
     * </p>
941
     *
942
     * @param labelString
943
     *            a {@link java.lang.String} object.
944
     * @param initialText
945
     *            a {@link java.lang.String} object.
946
     * @param style
947
     *            a int.
948
     * @param parentElement
949
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
950
     *            object.
951
     * @param buttonLabel
952
     *            a {@link java.lang.String} object.
953
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
954
     *         object.
955
     */
956
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
957
            String buttonLabel, String initialText, int style) {
958
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
959
                style);
960
        adapt(element);
961
        parentElement.addElement(element);
962
        return element;
963
    }
964

    
965
    /**
966
     * <p>
967
     * createCheckbox
968
     * </p>
969
     *
970
     * @param parentElement
971
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
972
     *            object.
973
     * @param label
974
     *            a {@link java.lang.String} object.
975
     * @param initialState
976
     *            a boolean.
977
     * @param style
978
     *            a int.
979
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
980
     *         object.
981
     */
982
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
983
        if(initialState==null){
984
            initialState = Boolean.FALSE;
985
        }
986
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
987
        adapt(element);
988
        parentElement.addElement(element);
989
        return element;
990
    }
991

    
992
    /**
993
     * Creates a section as a part of the form.
994
     *
995
     * @return the section widget
996
     * @param section
997
     *            a
998
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
999
     *            object.
1000
     */
1001
    public Section adapt(AbstractFormSection section) {
1002
        section.setMenu(section.getLayoutComposite().getMenu());
1003
        adapt(section, true, true);
1004

    
1005
        // handle focus and property change events for cdm use
1006
        section.addFocusListener(selectionFocusHandler);
1007
        section.setPropertyChangeListeners(propertyChangeListeners);
1008

    
1009
        if (section.getToggle() != null) {
1010
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1011
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1012
        }
1013

    
1014
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1015

    
1016
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1017
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1018
            getColors().initializeSectionToolBarColors();
1019
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1020
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1021
        }
1022
        // call setTitleBarForeground regardless as it also sets the label color
1023
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1024
        return section;
1025
    }
1026

    
1027
    private class BoldFontHolder2 {
1028
        private Font normalFont;
1029

    
1030
        private Font boldFont;
1031

    
1032
        public BoldFontHolder2() {
1033
        }
1034

    
1035
        public Font getBoldFont(Font font) {
1036
            createBoldFont(font);
1037
            return boldFont;
1038
        }
1039

    
1040
        private void createBoldFont(Font font) {
1041
            if (normalFont == null || !normalFont.equals(font)) {
1042
                normalFont = font;
1043
                dispose();
1044
            }
1045
            if (boldFont == null) {
1046
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1047
            }
1048
        }
1049

    
1050
        public void dispose() {
1051
            if (boldFont != null) {
1052
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1053
                boldFont = null;
1054
            }
1055
        }
1056
    }
1057

    
1058
    /**
1059
     * <p>
1060
     * createToggleableTextField
1061
     * </p>
1062
     *
1063
     * @param parentElement
1064
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1065
     *            object.
1066
     * @param labelString
1067
     *            a {@link java.lang.String} object.
1068
     * @param initialText
1069
     *            a {@link java.lang.String} object.
1070
     * @param initialState
1071
     *            a boolean.
1072
     * @param style
1073
     *            a int.
1074
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1075
     *         object.
1076
     */
1077
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1078
            String initialText, boolean initialState, int style) {
1079
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1080
                initialState, style | orientation);
1081
        adapt(element);
1082
        parentElement.addElement(element);
1083
        return element;
1084
    }
1085

    
1086
    /**
1087
     * <p>
1088
     * createTimePeriodElement
1089
     * </p>
1090
     *
1091
     * @param parentElement
1092
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1093
     *            object.
1094
     * @param labelString
1095
     *            a {@link java.lang.String} object.
1096
     * @param timePeriod
1097
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1098
     * @param style
1099
     *            a int.
1100
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1101
     *         object.
1102
     */
1103
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1104
            TimePeriod timePeriod, int style) {
1105
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1106
        adapt(element);
1107
        parentElement.addElement(element);
1108
        return element;
1109
    }
1110

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

    
1145
    /**
1146
     * <p>
1147
     * createPointElement
1148
     * </p>
1149
     *
1150
     * @param style
1151
     *            a int.
1152
     * @param parentElement
1153
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1154
     *            object.
1155
     * @param point
1156
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1157
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1158
     */
1159
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1160
        PointElement element = new PointElement(this, parentElement, point, style);
1161
        adapt(element);
1162
        parentElement.addElement(element);
1163
        return element;
1164
    }
1165

    
1166

    
1167

    
1168
    /**
1169
     * @param conversationHolder
1170
     * @param parent
1171
     * @param detailsViewer
1172
     * @param i
1173
     * @return
1174
     */
1175
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1176
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1177
        parentElement.addElement(section);
1178
        adapt(section);
1179
        return section;
1180
    }
1181

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

    
1202
	/**
1203
	 * <p>
1204
	 * createDateDetailSection
1205
	 * </p>
1206
	 *
1207
	 * @param parentElement
1208
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1209
	 *            object.
1210
	 * @param style
1211
	 *            a int.
1212
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1213
	 *         object.
1214
	 */
1215
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1216
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1217
		parentElement.addElement(section);
1218
		adapt(section);
1219
		return section;
1220
	}
1221

    
1222
    /**
1223
     * <p>
1224
     * createPartialElement
1225
     * </p>
1226
     *
1227
     * @param parentElement
1228
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1229
     *            object.
1230
     * @param labelString
1231
     *            a {@link java.lang.String} object.
1232
     * @param partial
1233
     *            a {@link org.joda.time.Partial} object.
1234
     * @param style
1235
     *            a int.
1236
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1237
     *         object.
1238
     */
1239
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1240
            int style) {
1241
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1242
        adapt(element);
1243
        parentElement.addElement(element);
1244
        return element;
1245
    }
1246

    
1247
    /**
1248
     * <p>
1249
     * addSelectionListener
1250
     * </p>
1251
     *
1252
     * @param listener
1253
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1254
     */
1255
    public void addSelectionListener(SelectionListener listener) {
1256
        selectionListenerList.add(listener);
1257
    }
1258

    
1259
    /**
1260
     * <p>
1261
     * removeSelectionListener
1262
     * </p>
1263
     *
1264
     * @param listener
1265
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1266
     */
1267
    public void removeSelectionListener(SelectionListener listener) {
1268
        if (listener == null) {
1269
            MessagingUtils.error(this.getClass(),
1270
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1271
        } else {
1272
            selectionListenerList.remove(listener);
1273
        }
1274
    }
1275

    
1276
    /**
1277
     * <p>
1278
     * addPropertyChangeListener
1279
     * </p>
1280
     *
1281
     * @param listener
1282
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1283
     *            object.
1284
     */
1285
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1286
        if (propertyChangeListeners.contains(listener)) {
1287
            return;
1288
        }
1289
        propertyChangeListeners.add(0, listener);
1290
    }
1291

    
1292
    /**
1293
     * <p>
1294
     * removePropertyChangeListener
1295
     * </p>
1296
     *
1297
     * @param listener
1298
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1299
     *            object.
1300
     */
1301
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1302
        propertyChangeListeners.remove(listener);
1303
    }
1304

    
1305
    /**
1306
     * @return the propertyChangeListeners
1307
     */
1308
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1309
        return propertyChangeListeners;
1310
    }
1311

    
1312
    /**
1313
     * <p>
1314
     * createHorizontalSeparator
1315
     * </p>
1316
     *
1317
     * @param parentElement
1318
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1319
     *            object.
1320
     * @param style
1321
     *            a int.
1322
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1323
     */
1324
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1325
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1326
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1327
        return separator;
1328
    }
1329

    
1330
    /**
1331
     * <p>
1332
     * createVersionElement
1333
     * </p>
1334
     *
1335
     * @param parentElement
1336
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1337
     *            object.
1338
     * @param entity
1339
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1340
     *            object.
1341
     * @param style
1342
     *            a int.
1343
     * @return a
1344
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1345
     *         object.
1346
     */
1347
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1348
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1349
        adapt(element);
1350
        parentElement.addElement(element);
1351
        return element;
1352
    }
1353

    
1354
    /**
1355
     * @param cdmBaseSection
1356
     * @param object
1357
     * @param style
1358
     * @return
1359
     */
1360
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1361
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1362
        adapt(element);
1363
        parentElement.addElement(element);
1364
        return element;
1365
    }
1366

    
1367
    /**
1368
     * <p>
1369
     * createVersionSection
1370
     * </p>
1371
     *
1372
     * @param parentElement
1373
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1374
     *            object.
1375
     * @param style
1376
     *            a int.
1377
     * @return a
1378
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1379
     *         object.
1380
     */
1381
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1382
        VersionSection section = new VersionSection(this, parentElement, style);
1383
        parentElement.addElement(section);
1384
        adapt(section);
1385
        return section;
1386
    }
1387

    
1388
    /**
1389
     * @param parent
1390
     * @param i
1391
     * @return
1392
     */
1393
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1394
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1395
        parentElement.addElement(section);
1396
        adapt(section);
1397
        return section;
1398
    }
1399

    
1400
    /**
1401
     * <p>
1402
     * createEmptyElement
1403
     * </p>
1404
     *
1405
     * @param parentElement
1406
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1407
     *            object.
1408
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1409
     */
1410
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1411
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1412
        adapt(element);
1413
        parentElement.addElement(element);
1414
        return element;
1415
    }
1416

    
1417
    /**
1418
     * <p>
1419
     * createHeadlineSection
1420
     * </p>
1421
     *
1422
     * @param parentElement
1423
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1424
     *            object.
1425
     * @return a
1426
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1427
     *         object.
1428
     */
1429
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1430
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1431
        parentElement.addElement(section);
1432
        adapt(section);
1433
        return section;
1434
    }
1435

    
1436
    /**
1437
     * <p>
1438
     * createParsingMessageElement
1439
     * </p>
1440
     *
1441
     * @param parentElement
1442
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1443
     *            object.
1444
     * @param parserProblem
1445
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1446
     *            object.
1447
     * @param style
1448
     *            a int.
1449
     * @return a
1450
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1451
     *         object.
1452
     */
1453
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1454
            ParserProblem parserProblem, int style) {
1455
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1456
        adapt(element);
1457
        parentElement.addElement(element);
1458
        return element;
1459
    }
1460

    
1461
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1462
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1463

    
1464
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1465
                selectionProvider, style);
1466

    
1467
        parentElement.addElement(section);
1468
        adapt(section);
1469
        return section;
1470

    
1471
    }
1472

    
1473
    /**
1474
     * @param definedTermClass
1475
     * @param formElement
1476
     * @param style
1477
     * @return
1478
     */
1479
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1480
            AbstractCdmDetailSection parentElement, int style) {
1481
        AbstractCdmDetailElement element = null;
1482

    
1483
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1484
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1485
        } else if (definedTermClass.equals(Feature.class)) {
1486
            element = new FeatureDetailElement(this, parentElement);
1487
        } else {
1488
            element = new DefinedTermDetailElement(this, parentElement);
1489
        }
1490

    
1491
        adapt(element);
1492
        parentElement.addElement(element);
1493
        return element;
1494
    }
1495

    
1496

    
1497
    //--------DetailSections---------
1498
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1499
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1500
        addAndAdaptSection(parentElement, section);
1501
        return section;
1502
    }
1503

    
1504
    public ReferenceDetailSection createReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1505
        ReferenceDetailSection section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1506
        addAndAdaptSection(parentElement, section);
1507
        return section;
1508
    }
1509

    
1510
    public NomenclaturalReferenceDetailSection createNomenclaturalReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1511
        NomenclaturalReferenceDetailSection section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1512
        addAndAdaptSection(parentElement, section);
1513
        return section;
1514
    }
1515

    
1516
    public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1517
        TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1518
        addAndAdaptSection(parentElement, section);
1519
        return section;
1520
    }
1521

    
1522
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1523
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1524
        addAndAdaptSection(parentElement, section);
1525
        return section;
1526
    }
1527

    
1528
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1529
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1530
        addAndAdaptSection(parentElement, section);
1531
        return section;
1532
    }
1533

    
1534
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1535
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1536
        addAndAdaptSection(parentElement, section);
1537
        return section;
1538
    }
1539

    
1540
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1541
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1542
        addAndAdaptSection(parentElement, section);
1543
        return section;
1544
    }
1545

    
1546
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1547
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1548
        addAndAdaptSection(parentElement, section);
1549
        return section;
1550
    }
1551

    
1552
    public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1553
        DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1554
        addAndAdaptSection(parentElement, section);
1555
        return section;
1556
    }
1557

    
1558
    public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1559
        ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1560
        addAndAdaptSection(parentElement, section);
1561
        return section;
1562
    }
1563

    
1564
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1565
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, style);
1566
        addAndAdaptSection(parentElement, section);
1567
        return section;
1568
    }
1569

    
1570
    public MediaDetailsSection createMediaDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1571
        MediaDetailsSection section = new MediaDetailsSection(this, conversation, parentElement, selectionProvider, style);
1572
        addAndAdaptSection(parentElement, section);
1573
        return section;
1574
    }
1575

    
1576
    public FieldUnitDetailSection createFieldUnitDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1577
        FieldUnitDetailSection section = new FieldUnitDetailSection(this, conversation, parentElement, selectionProvider, style);
1578
        addAndAdaptSection(parentElement, section);
1579
        return section;
1580
    }
1581

    
1582
    public GatheringEventDetailSection createGatheringEventDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1583
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1584
        addAndAdaptSection(parentElement, section);
1585
        return section;
1586
    }
1587

    
1588
    public SpecimenHierarchyDetailSection createSpecimenHierarchyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1589
        SpecimenHierarchyDetailSection section = new SpecimenHierarchyDetailSection(this, conversation, parentElement, selectionProvider, style);
1590
        addAndAdaptSection(parentElement, section);
1591
        return section;
1592
    }
1593

    
1594
    public DerivedUnitBaseDetailSection createDerivedUnitBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1595
        DerivedUnitBaseDetailSection section = new DerivedUnitBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1596
        addAndAdaptSection(parentElement, section);
1597
        return section;
1598
    }
1599

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1780
    public PreservedSpecimenDeterminationDetailSection createPreservedSpecimenDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1781
        PreservedSpecimenDeterminationDetailSection section = new PreservedSpecimenDeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1782
        addAndAdaptSection(parentElement, section);
1783
        return section;
1784
    }
1785

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

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

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

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

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

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

    
1822
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1823
        parentElement.addElement(section);
1824
        adapt(section);
1825
    }
1826

    
1827
    //--------DetailElements------------
1828

    
1829
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1830
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1831
        addAndAdaptElement(parentElement, element);
1832
        return element;
1833
    }
1834

    
1835
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1836
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1837
        addAndAdaptElement(parentElement, element);
1838
        return element;
1839
    }
1840

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

    
1847
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1848
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1849
        addAndAdaptElement(parentElement, element);
1850
        return element;
1851
    }
1852

    
1853
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1854
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1855
        addAndAdaptElement(parentElement, element);
1856
        return element;
1857
    }
1858

    
1859
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1860
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1861
        addAndAdaptElement(parentElement, element);
1862
        return element;
1863
    }
1864

    
1865
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1866
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
1867
        addAndAdaptElement(parentElement, element);
1868
        return element;
1869
    }
1870

    
1871
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
1872
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
1873
        addAndAdaptElement(parentElement, element);
1874
        return element;
1875
    }
1876

    
1877
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
1878
        UserDetailElement element = new UserDetailElement(this, parentElement);
1879
        addAndAdaptElement(parentElement, element);
1880
        return element;
1881
    }
1882

    
1883
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
1884
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
1885
        addAndAdaptElement(parentElement, element);
1886
        return element;
1887
    }
1888

    
1889
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
1890
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
1891
        addAndAdaptElement(parentElement, element);
1892
        return element;
1893
    }
1894

    
1895
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
1896
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
1897
        addAndAdaptElement(parentElement, element);
1898
        return element;
1899
    }
1900

    
1901
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
1902
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
1903
        addAndAdaptElement(parentElement, element);
1904
        return element;
1905
    }
1906

    
1907
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
1908
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
1909
        addAndAdaptElement(parentElement, element);
1910
        return element;
1911
    }
1912

    
1913
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement){
1914
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement);
1915
        addAndAdaptElement(parentElement, element);
1916
        return element;
1917
    }
1918

    
1919
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
1920
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
1921
        addAndAdaptElement(parentElement, element);
1922
        return element;
1923
    }
1924

    
1925
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
1926
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
1927
        addAndAdaptElement(parentElement, element);
1928
        return element;
1929
    }
1930

    
1931
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
1932
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
1933
        addAndAdaptElement(parentElement, element);
1934
        return element;
1935
    }
1936

    
1937
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
1938
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
1939
        addAndAdaptElement(parentElement, element);
1940
        return element;
1941
    }
1942

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

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

    
1955
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
1956
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
1957
        addAndAdaptElement(parentElement, element);
1958
        return element;
1959
    }
1960

    
1961
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style){
1962
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style);
1963
        addAndAdaptElement(parentElement, element);
1964
        return element;
1965
    }
1966

    
1967
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
1968
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
1969
        addAndAdaptElement(parentElement, element);
1970
        return element;
1971
    }
1972

    
1973
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
1974
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
1975
        addAndAdaptElement(parentElement, element);
1976
        return element;
1977
    }
1978

    
1979
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
1980
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
1981
        addAndAdaptElement(parentElement, element);
1982
        return element;
1983
    }
1984

    
1985
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
1986
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
1987
        addAndAdaptElement(parentElement, element);
1988
        return element;
1989
    }
1990

    
1991
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
1992
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
1993
        addAndAdaptElement(parentElement, element);
1994
        return element;
1995
    }
1996

    
1997

    
1998
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
1999
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2000
        addAndAdaptElement(parentElement, element);
2001
        return element;
2002
    }
2003

    
2004
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2005
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2006
        addAndAdaptElement(parentElement, element);
2007
        return element;
2008
    }
2009

    
2010
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2011
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2012
        addAndAdaptElement(parentElement, element);
2013
        return element;
2014
    }
2015

    
2016
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2017
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2018
        addAndAdaptElement(parentElement, element);
2019
        return element;
2020
    }
2021

    
2022
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2023
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2024
        addAndAdaptElement(parentElement, element);
2025
        return element;
2026
    }
2027

    
2028
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2029
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2030
        addAndAdaptElement(parentElement, element);
2031
        return element;
2032
    }
2033

    
2034
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2035
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2036
        addAndAdaptElement(parentElement, element);
2037
        return element;
2038
    }
2039

    
2040
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2041
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2042
        addAndAdaptElement(parentElement, element);
2043
        return element;
2044
    }
2045

    
2046
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2047
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2048
        addAndAdaptElement(parentElement, element);
2049
        return element;
2050
    }
2051

    
2052
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2053
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2054
        addAndAdaptElement(parentElement, element);
2055
        return element;
2056
    }
2057

    
2058
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2059
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2060
        addAndAdaptElement(parentElement, element);
2061
        return element;
2062
    }
2063

    
2064
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2065
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2066
        addAndAdaptElement(parentElement, element);
2067
        return element;
2068
    }
2069

    
2070
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2071
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2072
        addAndAdaptElement(parentElement, element);
2073
        return element;
2074
    }
2075

    
2076
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2077
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2078
        addAndAdaptElement(parentElement, element);
2079
        return element;
2080
    }
2081

    
2082
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2083
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2084
        addAndAdaptElement(parentElement, element);
2085
        return element;
2086
    }
2087

    
2088
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2089
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2090
        addAndAdaptElement(parentElement, mediaDetailElement);
2091
        return mediaDetailElement;
2092
    }
2093

    
2094
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2095
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2096
        addAndAdaptElement(parentElement, element);
2097
        return element;
2098
    }
2099

    
2100
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2101
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2102
        addAndAdaptElement(parentElement, element);
2103
        return element;
2104
    }
2105

    
2106
    public SpecimenHierarchyDetailElement createSpecimenHierarchyDetailElement(ICdmFormElement parentElement) {
2107
        SpecimenHierarchyDetailElement element = new SpecimenHierarchyDetailElement(this, parentElement);
2108
        addAndAdaptElement(parentElement, element);
2109
        return element;
2110
    }
2111

    
2112
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2113
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2114
        addAndAdaptElement(parentElement, element);
2115
        return element;
2116
    }
2117

    
2118
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2119
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2120
        addAndAdaptElement(parentElement, element);
2121
        return element;
2122
    }
2123

    
2124
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2125
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2126
        addAndAdaptElement(parentElement, element);
2127
        return element;
2128
    }
2129

    
2130
    public PreservedSpecimenDeterminationDetailElement createPreservedSpecimenDeterminationDetailElement(ICdmFormElement parentElement) {
2131
        PreservedSpecimenDeterminationDetailElement element = new PreservedSpecimenDeterminationDetailElement(this, parentElement);
2132
        addAndAdaptElement(parentElement, element);
2133
        return element;
2134
    }
2135

    
2136
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2137
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2138
        addAndAdaptElement(parentElement, element);
2139
        return element;
2140
    }
2141

    
2142
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2143
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2144
        addAndAdaptElement(parentElement, element);
2145
        return element;
2146
    }
2147

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2302
    public IdentifierDetailSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2303
        IdentifierDetailSection section = new IdentifierDetailSection(this, conversation, parentElement, style);
2304
        addAndAdaptSection(parentElement, section);
2305
        return section;
2306
    }
2307

    
2308
    public CurrentSampleDesignationDetailSection createCurrentSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2309
        CurrentSampleDesignationDetailSection section = new CurrentSampleDesignationDetailSection(this, conversation, parentElement, style);
2310
        addAndAdaptSection(parentElement, section);
2311
        return section;
2312
    }
2313

    
2314
    public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2315
        CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
2316
        addAndAdaptSection(parentElement, section);
2317
        return section;
2318
    }
2319

    
2320
    public PreservedSpecimenCurrentDeterminationDetailSection createPreservedSpecimenCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2321
        PreservedSpecimenCurrentDeterminationDetailSection section = new PreservedSpecimenCurrentDeterminationDetailSection(this, conversation, parentElement, style);
2322
        addAndAdaptSection(parentElement, section);
2323
        return section;
2324
    }
2325

    
2326
    public SampleDesignationHistoryDetailSection createSampleDesignationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2327
        SampleDesignationHistoryDetailSection section = new SampleDesignationHistoryDetailSection(this, conversation, parentElement, style);
2328
        addAndAdaptSection(parentElement, section);
2329
        return section;
2330
    }
2331

    
2332
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2333
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
2334
        addAndAdaptSection(parentElement, section);
2335
        return section;
2336
    }
2337

    
2338
    public PreservedSpecimenDeterminationHistoryDetailSection createPreservedSpecimenDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2339
        PreservedSpecimenDeterminationHistoryDetailSection section = new PreservedSpecimenDeterminationHistoryDetailSection(this, conversation, parentElement, style);
2340
        addAndAdaptSection(parentElement, section);
2341
        return section;
2342
    }
2343

    
2344
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2345
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
2346
        addAndAdaptSection(parentElement, section);
2347
        return section;
2348
    }
2349

    
2350
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2351
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2352
        addAndAdaptSection(parentElement, section);
2353
        return section;
2354
    }
2355

    
2356
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2357
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2358
        addAndAdaptSection(parentElement, section);
2359
        return section;
2360
    }
2361

    
2362
    public GeographicalScopeDetailSection createGeographicalScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2363
        GeographicalScopeDetailSection section = new GeographicalScopeDetailSection(this, conversation, parentElement, style);
2364
        addAndAdaptSection(parentElement, section);
2365
        return section;
2366
    }
2367

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

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

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

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

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

    
2398
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2399
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2400
        AbstractEntityCollectionElement element = null;
2401

    
2402
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2403

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

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

    
2500
        } else if (entity instanceof NamedArea) {
2501
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2502
        } else if (entity instanceof DeterminationEvent) {
2503
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2504
        } else if (entity instanceof User) {
2505
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2506
        } else if (entity instanceof GrantedAuthority) {
2507
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity,
2508
                    removeListener, style);
2509
        } else if (entity instanceof Group) {
2510
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2511
        } else if (entity instanceof Taxon) {
2512
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2513
        } else if (entity instanceof DescriptionElementBase) {
2514
            // this is the special case for protologs, maybe we can do this
2515
            // differently when API improves
2516
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2517
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2518
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2519
            }
2520
        } else if (entity instanceof Identifier) {
2521
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2522
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2523
            }
2524
            else{
2525
                element = new IdentifierDetailElement(this, parentElement, (Identifier) entity, removeListener, style);
2526
            }
2527
        }
2528

    
2529
        if (element == null) {
2530
            MessagingUtils.messageDialog("No element for entity", this,
2531
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2532
                            + entity, null);
2533
        }
2534

    
2535
        else{
2536
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2537
                element.setPersistentBackground(backgroundColor);
2538
            }
2539
            adapt(element);
2540
            parentElement.addElement(element);
2541
        }
2542

    
2543
        return element;
2544
    }
2545

    
2546
    /**
2547
     * <p>
2548
     * Creates a selection element for the given type T.
2549
     * </p>
2550
     * <p>
2551
     * <strong>Selection elements not handled by this method:</strong>
2552
     * <ul>
2553
     * <li>{@link TaxonNodeSelectionElement} see
2554
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2555
     * </li>
2556
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2557
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2558
     * </li>
2559
     * </ul>
2560
     * </p>
2561
     *
2562
     * @param clazz
2563
     *            a {@link Class} object of the type that you want the selection
2564
     *            element to handle
2565
     * @param parentElement
2566
     *            a {@link ICdmFormElement} object.
2567
     * @param labelString
2568
     *            a {@link String} object.
2569
     * @param selectionType
2570
     * @param selection
2571
     *            a {@link ICdmBase} object.
2572
     * @param style
2573
     *            a int.
2574
     * @param conversation
2575
     *            a {@link ConversationHolder} object.
2576
     * @return a {@link EntitySelectionElement} object.
2577
     */
2578
    public <T extends ICdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2579
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2580
            int style) {
2581
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2582
                labelString, selection, mode, style);
2583
        adapt(element);
2584
        parentElement.addElement(element);
2585
        return element;
2586
    }
2587

    
2588
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2589
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2590
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2591
                labelString, selection, mode, style);
2592
        adapt(element);
2593
        parentElement.addElement(element);
2594
        return element;
2595
    }
2596

    
2597
    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2598
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2599
            int mode, int style) {
2600
        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2601
                conversation, parentElement, labelString, selection, mode, style);
2602
        adapt(element);
2603
        parentElement.addElement(element);
2604
        return element;
2605
    }
2606

    
2607
    /** {@inheritDoc} */
2608
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2609
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2610
        adapt(labelElement);
2611
        parentElement.addElement(labelElement);
2612
        return labelElement;
2613
    }
2614

    
2615
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2616
        Label label = new Label(formElement.getLayoutComposite(), style);
2617
        label.setText(labelText+" (yyyy-MM-dd)");
2618
        DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, style);
2619
        dateElement.initController(this, formElement);
2620
        return dateElement;
2621
    }
2622

    
2623
    /**
2624
     * <p>
2625
     * Getter for the field <code>selectionProvider</code>.
2626
     * </p>
2627
     *
2628
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2629
     */
2630
    public ISelectionProvider getSelectionProvider() {
2631
        return selectionProvider;
2632
    }
2633

    
2634
    /**
2635
     * <p>
2636
     * createDetailedDescriptionDetailElement
2637
     * </p>
2638
     *
2639
     * @param parentElement
2640
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2641
     *            object.
2642
     * @param entity
2643
     *            a
2644
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2645
     *            object.
2646
     * @param style
2647
     *            a int.
2648
     * @return a
2649
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2650
     *         object.
2651
     */
2652
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2653
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2654
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2655

    
2656
        if (entity instanceof CategoricalData) {
2657
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2658
                    (CategoricalData) entity, style);
2659
        } else if (entity instanceof CommonTaxonName) {
2660
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2661
                    style);
2662
        } else if (entity instanceof Distribution) {
2663
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2664
                    style);
2665
        } else if (entity instanceof IndividualsAssociation) {
2666
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2667
                    (IndividualsAssociation) entity, style);
2668
        } else if (entity instanceof QuantitativeData) {
2669
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2670
                    (QuantitativeData) entity, style);
2671
        } else if (entity instanceof TaxonInteraction) {
2672
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2673
                    (TaxonInteraction) entity, style);
2674
        } else if (entity instanceof TextData) {
2675
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2676
        } else {
2677
            throw new IllegalStateException("There is no interface for the given description element");
2678
        }
2679
        adapt(detailedDescriptionElement);
2680
        parentElement.addElement(detailedDescriptionElement);
2681
        return detailedDescriptionElement;
2682

    
2683
    }
2684

    
2685
    /**
2686
     * Creates a styled text as a part of the form.
2687
     *
2688
     * @param parent
2689
     *            the text parent
2690
     * @param value
2691
     *            the text initial value
2692
     * @param style
2693
     *            the text style
2694
     * @return the text widget
2695
     */
2696
    public StyledText createStyledText(Composite parent, String value, int style) {
2697
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2698
        if (value != null) {
2699
            text.setText(value);
2700
        }
2701
        text.setForeground(getColors().getForeground());
2702
        text.setBackground(getColors().getBackground());
2703
        // text.addFocusListener(visibilityHandler);
2704
        return text;
2705
    }
2706

    
2707
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2708
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2709
        addAndAdaptSection(parentElement, section);
2710
        return section;
2711
    }
2712

    
2713
}
(6-6/40)