Project

General

Profile

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

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

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

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

    
335
/**
336
 * <p>
337
 * CdmFormFactory class.
338
 * </p>
339
 *
340
 * @author n.hoffmann
341
 * @created Feb 24, 2010
342
 * @version 1.0
343
 */
344
public class CdmFormFactory extends FormToolkit {
345

    
346
    private BoldFontHolder2 boldFontHolder2;
347
    private MouseListener selectionMouseHandler;
348
    private FocusListener selectionFocusHandler;
349

    
350
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
351

    
352
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
353

    
354
    private final int orientation = Window.getDefaultOrientation();
355
    private ISelectionProvider selectionProvider;
356

    
357
    /** Constant <code>EMPTY_SELECTION</code> */
358
    public static ISelection EMPTY_SELECTION = new ISelection() {
359
        @Override
360
        public boolean isEmpty() {
361
            return true;
362
        }
363
    };
364

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

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

    
391
    private void notifySelectionListeners(TypedEvent e) {
392
        Event event = new Event();
393
        event.widget = e.widget;
394
        SelectionEvent selectionEvent = new SelectionEvent(event);
395

    
396
        for (SelectionListener listener : selectionListenerList) {
397
            listener.widgetSelected(selectionEvent);
398
        }
399
    }
400

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

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

    
430
    /**
431
	 *
432
	 */
433
    private void init() {
434
        boldFontHolder2 = new BoldFontHolder2();
435
        selectionMouseHandler = new SelectionMouseHandler();
436
        selectionFocusHandler = new SelectionFocusHandler();
437
    }
438

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

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

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

    
494
    /** {@inheritDoc} */
495
    @Override
496
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
497
        if (trackFocus) {
498
            control.addFocusListener(selectionFocusHandler);
499
        }
500
        super.adapt(control, trackFocus, trackKeyboard);
501
    }
502

    
503
    /** {@inheritDoc} */
504
    @Override
505
    public void adapt(Composite composite) {
506
        composite.addMouseListener(selectionMouseHandler);
507
        super.adapt(composite);
508
    }
509

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

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

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

    
593
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
594
            KeyStatement keyStatement, int textHeight, int style) {
595
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
596
                textHeight, style);
597
        adapt(element);
598
        parentElement.addElement(element);
599
        return element;
600
    }
601

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

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

    
662
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
663
                textLimit, style);
664
        adapt(element);
665
        parentElement.addElement(element);
666
        return element;
667
    }
668

    
669
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
670
            int textHeight, int style) {
671
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
672
        adapt(element);
673
        parentElement.addElement(element);
674
        return element;
675
    }
676

    
677
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
678
            LSID initialLsid, int style) {
679
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
680
        adapt(element);
681
        parentElement.addElement(element);
682
        return element;
683
    }
684

    
685
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
686
            URI initialUri, int style) {
687
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
688
        adapt(element);
689
        parentElement.addElement(element);
690
        return element;
691
    }
692

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

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

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

    
754
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
755
            String labelString, LanguageString languageString, int style) {
756
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
757
    }
758

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

    
768
    /**
769
     * <p>
770
     * createKeyValueViewerElement
771
     * </p>
772
     *
773
     * @param parentElement
774
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
775
     *            object.
776
     * @param keyHeading
777
     *            a {@link java.lang.String} object.
778
     * @param valueHeading
779
     *            a {@link java.lang.String} object.
780
     * @param map
781
     *            a {@link java.util.Map} object.
782
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
783
     *         object.
784
     */
785
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
786
            String valueHeading, Map<Object, Object> map) {
787
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
788
        adapt(element);
789
        parentElement.addElement(element);
790
        return element;
791
    }
792
    /**
793
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
794
     */
795
    @Deprecated
796
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
797
            ICdmFormElement parentElement, String labelString, T selection, int style) {
798
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString,
799
                selection, true,  style);
800
        adapt(element);
801
        parentElement.addElement(element);
802
        return element;
803
    }
804

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

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

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

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

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

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

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

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

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

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

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

    
1000
        // handle focus and property change events for cdm use
1001
        section.addFocusListener(selectionFocusHandler);
1002
        section.setPropertyChangeListeners(propertyChangeListeners);
1003

    
1004
        if (section.getToggle() != null) {
1005
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1006
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1007
        }
1008

    
1009
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1010

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

    
1022
    private class BoldFontHolder2 {
1023
        private Font normalFont;
1024

    
1025
        private Font boldFont;
1026

    
1027
        public BoldFontHolder2() {
1028
        }
1029

    
1030
        public Font getBoldFont(Font font) {
1031
            createBoldFont(font);
1032
            return boldFont;
1033
        }
1034

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

    
1045
        public void dispose() {
1046
            if (boldFont != null) {
1047
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1048
                boldFont = null;
1049
            }
1050
        }
1051
    }
1052

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

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

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

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

    
1161

    
1162

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

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

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

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

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

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

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

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

    
1300
    /**
1301
     * @return the propertyChangeListeners
1302
     */
1303
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1304
        return propertyChangeListeners;
1305
    }
1306

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

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

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

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

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

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

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

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

    
1456
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1457
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1458

    
1459
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1460
                selectionProvider, style);
1461

    
1462
        parentElement.addElement(section);
1463
        adapt(section);
1464
        return section;
1465

    
1466
    }
1467

    
1468
    /**
1469
     * @param definedTermClass
1470
     * @param formElement
1471
     * @param style
1472
     * @return
1473
     */
1474
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1475
            AbstractCdmDetailSection parentElement, int style) {
1476
        AbstractCdmDetailElement element = null;
1477

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

    
1486
        adapt(element);
1487
        parentElement.addElement(element);
1488
        return element;
1489
    }
1490

    
1491

    
1492
    //--------DetailSections---------
1493
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1494
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1495
        addAndAdaptSection(parentElement, section);
1496
        return section;
1497
    }
1498

    
1499
    public ReferenceDetailSection createReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1500
        ReferenceDetailSection section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1501
        addAndAdaptSection(parentElement, section);
1502
        return section;
1503
    }
1504

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

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

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

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

    
1529
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1530
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1531
        addAndAdaptSection(parentElement, section);
1532
        return section;
1533
    }
1534

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

    
1541
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1542
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1543
        addAndAdaptSection(parentElement, section);
1544
        return section;
1545
    }
1546

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

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

    
1559
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, boolean nameChoosable, int style){
1560
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, nameChoosable, style);
1561
        addAndAdaptSection(parentElement, section);
1562
        return section;
1563
    }
1564

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1697
    public SequenceGeneralDetailSection createSequenceGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1698
        SequenceGeneralDetailSection section = new SequenceGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1699
        addAndAdaptSection(parentElement, section);
1700
        return section;
1701
    }
1702

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

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

    
1715
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1716
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1717
        addAndAdaptSection(parentElement, section);
1718
        return section;
1719
    }
1720

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

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

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

    
1739
    public AmplificationCloningDetailSection createAmplificationCloningDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1740
        AmplificationCloningDetailSection section = new AmplificationCloningDetailSection(this, conversation, parentElement, selectionProvider, style);
1741
        addAndAdaptSection(parentElement, section);
1742
        return section;
1743
    }
1744

    
1745
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1746
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1747
        addAndAdaptSection(parentElement, section);
1748
        return section;
1749
    }
1750

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1828
    //--------DetailElements------------
1829

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1914
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
1915
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
1916
        adapt(element);
1917
        parentElement.addElement(element);
1918

    
1919
        return element;
1920
    }
1921

    
1922
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
1923
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
1924
        addAndAdaptElement(parentElement, element);
1925
        return element;
1926
    }
1927

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

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

    
1940
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
1941
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
1942
        addAndAdaptElement(parentElement, element);
1943
        return element;
1944
    }
1945

    
1946
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
1947
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
1948
        addAndAdaptElement(parentElement, element);
1949
        return element;
1950
    }
1951

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

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

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

    
1970
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
1971
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
1972
        addAndAdaptElement(parentElement, element);
1973
        return element;
1974
    }
1975

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

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

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

    
1994
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
1995
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
1996
        addAndAdaptElement(parentElement, element);
1997
        return element;
1998
    }
1999

    
2000
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2001
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2002
        addAndAdaptElement(parentElement, element);
2003
        return element;
2004
    }
2005

    
2006

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2103
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2104
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2105
        addAndAdaptElement(parentElement, mediaDetailElement);
2106
        return mediaDetailElement;
2107
    }
2108

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

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

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

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

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

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

    
2145
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2146
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2147
        addAndAdaptElement(parentElement, element);
2148
        return element;
2149
    }
2150

    
2151
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2152
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2153
        addAndAdaptElement(parentElement, element);
2154
        return element;
2155
    }
2156

    
2157
    /**
2158
     * @param parentElement
2159
     * @param element
2160
     */
2161
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2162
        adapt(element);
2163
        parentElement.addElement(element);
2164
    }
2165

    
2166
    //--------EntityCollectionSection----------
2167
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2168
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2169
        addAndAdaptSection(parentElement, section);
2170
        return section;
2171
    }
2172

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2347
    public IdentifierSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2348
        IdentifierSection section = new IdentifierSection(this, conversation, parentElement, style);
2349
        addAndAdaptSection(parentElement, section);
2350
        return section;
2351
    }
2352
    
2353
    public DerivedUnitFacadeIdentifierSection createDerivedUnitFacadeIdentifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2354
    	DerivedUnitFacadeIdentifierSection section = new DerivedUnitFacadeIdentifierSection(this, conversation, parentElement, style);
2355
    	addAndAdaptSection(parentElement, section);
2356
    	return section;
2357
    }
2358

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

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

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

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

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

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

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

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

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

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

    
2419
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2420
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2421
        addAndAdaptSection(parentElement, section);
2422
        return section;
2423
    }
2424

    
2425
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2426
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2427
        addAndAdaptSection(parentElement, section);
2428
        return section;
2429
    }
2430

    
2431
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2432
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2433
        addAndAdaptSection(parentElement, section);
2434
        return section;
2435
    }
2436

    
2437

    
2438
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2439
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2440
        AbstractEntityCollectionElement element = null;
2441

    
2442
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2443

    
2444
        if (entity instanceof Annotation) {
2445
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2446
        }else if (entity instanceof Person ) {
2447
            boolean isNomenclatural = false;
2448
            if (parentElement instanceof TeamMemberSection){
2449
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2450
            }
2451
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2452
        } else if (entity instanceof Credit) {
2453
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2454
        } else if (entity instanceof Extension) {
2455
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2456
        } else if (entity instanceof Marker) {
2457
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2458
        } else if (entity instanceof TaxonNodeAgentRelation) {
2459
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2460
        }else if (entity instanceof Media) {
2461
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, true, style);
2462
        } else if (entity instanceof MediaRepresentation) {
2463
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2464
                    style);
2465
        } else if (entity instanceof ImageFile) {
2466
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2467
        } else if (entity instanceof MediaRepresentationPart) {
2468
            element = new MediaRepresentationPartElement(this, parentElement, (MediaRepresentationPart) entity,
2469
                    removeListener, style);
2470
        } else if (entity instanceof NomenclaturalStatus) {
2471
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2472
                    style);
2473
        } else if (entity instanceof Rights) {
2474
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2475
        } else if (entity instanceof DescriptionElementSource) {
2476
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2477
                    removeListener, style);
2478
        } else if (entity instanceof TaxonNodeAgentRelation) {
2479
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2480
                    removeListener,backgroundColor, style);
2481
        }
2482
        else if (entity instanceof IdentifiableSource) {
2483
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2484
                    style);
2485
        } else if (entity instanceof DefinedTerm) {
2486
            switch(((DefinedTerm)entity).getTermType()) {
2487
            case Scope:
2488
                element = new ScopeElement(this,
2489
                        parentElement,
2490
                        (DefinedTerm) entity,
2491
                        removeListener,
2492
                        style);
2493
                break;
2494
            case Modifier:
2495
                element = new ModifierElement(this,
2496
                        parentElement,
2497
                        (DefinedTerm) entity,
2498
                        removeListener,
2499
                        style);
2500
                break;
2501
            default:
2502
                break;
2503

    
2504
            }
2505
        } else if (entity instanceof Reference) {
2506
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2507
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2508
            }
2509
            else{
2510
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2511
            }
2512
        } else if (entity instanceof NameTypeDesignation) {
2513
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2514
                    style);
2515
        } else if (entity instanceof NameRelationship) {
2516
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2517
                    style);
2518
        } else if (entity instanceof SynonymRelationship) {
2519
            element = new SynonymRelationshipDetailElement(this, parentElement, (SynonymRelationship) entity, removeListener,
2520
                    style);
2521
        } else if (entity instanceof SpecimenTypeDesignation) {
2522
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
2523
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2524
                        removeListener, style);
2525
            }
2526
            else{
2527
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2528
                        removeListener, style);
2529
            }
2530
        } else if (entity instanceof StateData) {
2531
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2532
        } else if (entity instanceof StatisticalMeasurementValue) {
2533
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2534
                    removeListener, style);
2535
        } else if (entity instanceof DerivedUnit) {
2536
            switch(((DerivedUnit)entity).getRecordBasis()) {
2537
            case LivingSpecimen:
2538
            case PreservedSpecimen:
2539
            case OtherSpecimen:
2540
                element = new SpecimenCollectionDetailElement(this,
2541
                        parentElement,
2542
                        (DerivedUnit) entity,
2543
                        removeListener,
2544
                        style);
2545
                break;
2546
            default:
2547
                element = new DerivedUnitElement(this,
2548
                        parentElement,
2549
                        (DerivedUnit) entity,
2550
                        removeListener,
2551
                        style);
2552
            }
2553

    
2554
        } else if (entity instanceof NamedArea) {
2555
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2556
        } else if (entity instanceof DeterminationEvent) {
2557
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2558
        } else if (entity instanceof User) {
2559
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2560
        } else if (entity instanceof GrantedAuthority) {
2561
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity,
2562
                    removeListener, style);
2563
        } else if (entity instanceof Group) {
2564
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2565
        } else if (entity instanceof Taxon) {
2566
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2567
        } else if (entity instanceof DescriptionElementBase) {
2568
            // this is the special case for protologs, maybe we can do this
2569
            // differently when API improves
2570
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2571
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2572
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2573
            }
2574
        } else if (entity instanceof Identifier) {
2575
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2576
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2577
            }
2578
            else{
2579
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
2580
            }
2581
        } else if (entity instanceof TermVocabulary) {
2582
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
2583
            switch (termVocabulary.getTermType()) {
2584
            case State:
2585
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
2586
                break;
2587
            case Modifier:
2588
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
2589
                break;
2590
            default:
2591
                break;
2592
            }
2593
        } else if (entity instanceof MeasurementUnit) {
2594
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2595
        } else if (entity instanceof StatisticalMeasure) {
2596
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2597
        }
2598

    
2599

    
2600
        if (element == null) {
2601
            MessagingUtils.messageDialog("No element for entity", this,
2602
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2603
                            + entity, null);
2604
        }
2605

    
2606
        else{
2607
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2608
                element.setPersistentBackground(backgroundColor);
2609
            }
2610
            adapt(element);
2611
            parentElement.addElement(element);
2612
        }
2613

    
2614
        return element;
2615
    }
2616

    
2617
    /**
2618
     * <p>
2619
     * Creates a selection element for the given type T.
2620
     * </p>
2621
     * <p>
2622
     * <strong>Selection elements not handled by this method:</strong>
2623
     * <ul>
2624
     * <li>{@link TaxonNodeSelectionElement} see
2625
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2626
     * </li>
2627
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2628
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2629
     * </li>
2630
     * </ul>
2631
     * </p>
2632
     *
2633
     * @param clazz
2634
     *            a {@link Class} object of the type that you want the selection
2635
     *            element to handle
2636
     * @param parentElement
2637
     *            a {@link ICdmFormElement} object.
2638
     * @param labelString
2639
     *            a {@link String} object.
2640
     * @param selectionType
2641
     * @param selection
2642
     *            a {@link ICdmBase} object.
2643
     * @param style
2644
     *            a int.
2645
     * @param conversation
2646
     *            a {@link ConversationHolder} object.
2647
     * @return a {@link EntitySelectionElement} object.
2648
     */
2649
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2650
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2651
            int style) {
2652
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2653
                labelString, selection, mode, style);
2654
        adapt(element);
2655
        parentElement.addElement(element);
2656
        return element;
2657
    }
2658

    
2659
    /**
2660
     * <p>
2661
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
2662
     * </p>
2663
     * <p>
2664
     * <strong>Selection elements not handled by this method:</strong>
2665
     * <ul>
2666
     * <li>{@link TaxonNodeSelectionElement} see
2667
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2668
     * </li>
2669
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2670
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2671
     * </li>
2672
     * </ul>
2673
     * </p>
2674
     *
2675
     * @param clazz
2676
     *            a {@link Class} object of the type that you want the selection
2677
     *            element to handle
2678
     * @param parentElement
2679
     *            a {@link ICdmFormElement} object.
2680
     * @param labelString
2681
     *            a {@link String} object.
2682
     * @param selectionType
2683
     * @param selection
2684
     *            a {@link ICdmBase} object.
2685
     * @param style
2686
     *            a int.
2687
     * @param conversation
2688
     *            a {@link ConversationHolder} object.
2689
     * @return a {@link EntitySelectionElement} object.
2690
     */
2691
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
2692
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
2693
            T selection, int mode, int style) {
2694
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, conversation, parentElement, clazz,
2695
                labelString, selection, mode, style);
2696
        adapt(element);
2697
        parentElement.addElement(element);
2698
        return element;
2699
    }
2700

    
2701
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2702
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2703
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2704
                labelString, selection, mode, style);
2705
        adapt(element);
2706
        parentElement.addElement(element);
2707
        return element;
2708
    }
2709

    
2710
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2711
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2712
//            int mode, int style) {
2713
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2714
//                conversation, parentElement, labelString, selection, mode, style);
2715
//        adapt(element);
2716
//        parentElement.addElement(element);
2717
//        return element;
2718
//    }
2719

    
2720
    /** {@inheritDoc} */
2721
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2722
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2723
        adapt(labelElement);
2724
        parentElement.addElement(labelElement);
2725
        return labelElement;
2726
    }
2727

    
2728
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2729
        Label label = new Label(formElement.getLayoutComposite(), style);
2730
        label.setText(labelText+" (yyyy-MM-dd)");
2731
        DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, style);
2732
        dateElement.initController(this, formElement);
2733
        return dateElement;
2734
    }
2735

    
2736
    /**
2737
     * <p>
2738
     * Getter for the field <code>selectionProvider</code>.
2739
     * </p>
2740
     *
2741
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2742
     */
2743
    public ISelectionProvider getSelectionProvider() {
2744
        return selectionProvider;
2745
    }
2746

    
2747
    /**
2748
     * <p>
2749
     * createDetailedDescriptionDetailElement
2750
     * </p>
2751
     *
2752
     * @param parentElement
2753
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2754
     *            object.
2755
     * @param entity
2756
     *            a
2757
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2758
     *            object.
2759
     * @param style
2760
     *            a int.
2761
     * @return a
2762
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2763
     *         object.
2764
     */
2765
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2766
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2767
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2768

    
2769
        if (entity instanceof CategoricalData) {
2770
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2771
                    (CategoricalData) entity, style);
2772
        } else if (entity instanceof CommonTaxonName) {
2773
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2774
                    style);
2775
        } else if (entity instanceof Distribution) {
2776
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2777
                    style);
2778
        } else if (entity instanceof IndividualsAssociation) {
2779
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2780
                    (IndividualsAssociation) entity, style);
2781
        } else if (entity instanceof QuantitativeData) {
2782
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2783
                    (QuantitativeData) entity, style);
2784
        } else if (entity instanceof TaxonInteraction) {
2785
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2786
                    (TaxonInteraction) entity, style);
2787
        } else if (entity instanceof TextData) {
2788
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2789
        } else {
2790
            throw new IllegalStateException("There is no interface for the given description element");
2791
        }
2792
        adapt(detailedDescriptionElement);
2793
        parentElement.addElement(detailedDescriptionElement);
2794
        return detailedDescriptionElement;
2795

    
2796
    }
2797

    
2798
    /**
2799
     * Creates a styled text as a part of the form.
2800
     *
2801
     * @param parent
2802
     *            the text parent
2803
     * @param value
2804
     *            the text initial value
2805
     * @param style
2806
     *            the text style
2807
     * @return the text widget
2808
     */
2809
    public StyledText createStyledText(Composite parent, String value, int style) {
2810
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2811
        if (value != null) {
2812
            text.setText(value);
2813
        }
2814
        text.setForeground(getColors().getForeground());
2815
        text.setBackground(getColors().getBackground());
2816
        // text.addFocusListener(visibilityHandler);
2817
        return text;
2818
    }
2819

    
2820
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2821
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2822
        addAndAdaptSection(parentElement, section);
2823
        return section;
2824
    }
2825

    
2826
    /**
2827
     * @param formElement
2828
     * @param conversationHolder
2829
     * @param style
2830
     * @return
2831
     */
2832
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
2833
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
2834
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
2835
        addAndAdaptSection(formElement, section);
2836
        return section;
2837
    }
2838

    
2839
    /**
2840
     * @param conversationHolder
2841
     * @param formElement
2842
     * @param expanded
2843
     * @return
2844
     */
2845
    public TeamMemberSection createNomenclaturalTeamMemberSection(ConversationHolder conversationHolder,
2846
            ICdmFormElement formElement, int expanded) {
2847
        // TODO Auto-generated method stub
2848
        return null;
2849
    }
2850

    
2851
}
(7-7/42)