Project

General

Profile

Download (147 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.Comparator;
9
import java.util.HashSet;
10
import java.util.List;
11
import java.util.Map;
12
import java.util.Set;
13

    
14
import javax.inject.Inject;
15

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

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

    
357
/**
358
 * <p>
359
 * CdmFormFactory class.
360
 * </p>
361
 *
362
 * @author n.hoffmann
363
 * @created Feb 24, 2010
364
 * @version 1.0
365
 */
366
public class CdmFormFactory extends FormToolkit {
367

    
368
    private BoldFontHolder2 boldFontHolder2;
369
    private MouseListener selectionMouseHandler;
370
    private FocusListener selectionFocusHandler;
371

    
372
    @Inject
373
    private IEclipseContext context;
374

    
375
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
376

    
377
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
378

    
379
    private final int orientation = Window.getDefaultOrientation();
380
    private ISelectionProvider selectionProvider;
381

    
382
    /** Constant <code>EMPTY_SELECTION</code> */
383
    public static ISelection EMPTY_SELECTION = new ISelection() {
384
        @Override
385
        public boolean isEmpty() {
386
            return true;
387
        }
388
    };
389

    
390
    /**
391
     *
392
     * @author n.hoffmann
393
     * @date Jan 25, 2010
394
     *
395
     */
396
    private class SelectionMouseHandler extends MouseAdapter {
397
        @Override
398
        public void mouseDown(MouseEvent e) {
399
            notifySelectionListeners(e);
400
        }
401
    }
402

    
403
    /**
404
     *
405
     * @author n.hoffmann
406
     * @date Jan 25, 2010
407
     *
408
     */
409
    private class SelectionFocusHandler extends FocusAdapter {
410
        @Override
411
        public void focusGained(FocusEvent e) {
412
            notifySelectionListeners(e);
413
        }
414
    }
415

    
416
    private void notifySelectionListeners(TypedEvent e) {
417
        Event event = new Event();
418
        event.widget = e.widget;
419
        SelectionEvent selectionEvent = new SelectionEvent(event);
420

    
421
        for (SelectionListener listener : selectionListenerList) {
422
            listener.widgetSelected(selectionEvent);
423
        }
424
    }
425

    
426
    public CdmFormFactory(Display display) {
427
        this(display, null);
428
    }
429

    
430
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
431
        super(display);
432
        this.selectionProvider = selectionProvider;
433
        init();
434
    }
435

    
436
    private void init() {
437
        boldFontHolder2 = new BoldFontHolder2();
438
        selectionMouseHandler = new SelectionMouseHandler();
439
        selectionFocusHandler = new SelectionFocusHandler();
440
    }
441

    
442
    public IEclipseContext getContext() {
443
        return context;
444
    }
445

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

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

    
486
    /**
487
     * <p>
488
     * Adapts the {@link AbstractCdmFormElement}:<br>
489
     * - sets the {@link IPropertyChangeListener}s handled by this class
490
     * </p>
491
     *
492
     * @param formElement
493
     *            a
494
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
495
     *            object.
496
     */
497
    public void adapt(ICdmFormElement formElement) {
498
        formElement.setPropertyChangeListeners(propertyChangeListeners);
499
    }
500

    
501
    /** {@inheritDoc} */
502
    @Override
503
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
504
        if (trackFocus) {
505
            control.addFocusListener(selectionFocusHandler);
506
        }
507
        super.adapt(control, trackFocus, trackKeyboard);
508
    }
509

    
510
    /** {@inheritDoc} */
511
    @Override
512
    public void adapt(Composite composite) {
513
        composite.addMouseListener(selectionMouseHandler);
514

    
515
        super.adapt(composite);
516
    }
517

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

    
561
    /**
562
     * <p>
563
     * createEmptyCell
564
     * </p>
565
     *
566
     * @param parent
567
     *            a {@link org.eclipse.swt.widgets.Composite} object.
568
     * @return a {@link org.eclipse.swt.widgets.Label} object.
569
     */
570
    public Label createEmptyCell(Composite parent) {
571
        return this.createLabel(parent, null);
572
    }
573

    
574
    /**
575
     * <p>
576
     * createMultiLanguageTextElement
577
     * </p>
578
     *
579
     * @param parentElement
580
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
581
     *            object.
582
     * @param labelString
583
     *            a {@link java.lang.String} object.
584
     * @param multilanguageText
585
     *            a {@link java.util.Map} object.
586
     * @param textHeight
587
     *            a int.
588
     * @param style
589
     *            a int.
590
     * @return a
591
     *         {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
592
     *         object.
593
     */
594
    public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
595
            Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
596
        MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
597
                multilanguageText, textHeight, style);
598
        adapt(element);
599
        parentElement.addElement(element);
600
        return element;
601
    }
602

    
603
    /**
604
     * <p>
605
     * createMultiLanguageTextElement
606
     * </p>
607
     *
608
     * @param parentElement
609
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
610
     *            object.
611
     *
612
     * @param Representation
613
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
614
     * @param textHeight
615
     *            a int.
616
     * @param style
617
     *            a int.
618
     * @return a
619
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
620
     *         object.
621
     */
622
    public RepresentationElement createRepresentationElement(ICdmFormElement parentElement, Representation representation, TermBase term,int textHeight, int style, boolean fillDetails) {
623
        RepresentationElement element = new RepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
624
        adapt(element);
625
        parentElement.addElement(element);
626
        return element;
627
    }
628

    
629
    /**
630
     * <p>
631
     * createMultiLanguageTextElement
632
     * </p>
633
     *
634
     * @param parentElement
635
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
636
     *            object.
637
     *
638
     * @param Representation
639
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
640
     * @param textHeight
641
     *            a int.
642
     * @param style
643
     *            a int.
644
     * @return a
645
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
646
     *         object.
647
     */
648
    public TranslatableRepresentationElement createTranslatableRepresentationElement(ICdmFormElement parentElement, Representation representation, TermBase term,int textHeight, int style, boolean fillDetails) {
649
        TranslatableRepresentationElement element = new TranslatableRepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
650
        adapt(element);
651
        parentElement.addElement(element);
652
        return element;
653
    }
654

    
655
    /**
656
     * <p>
657
     * createMultiLanguageTextElement
658
     * </p>
659
     *
660
     * @param parentElement
661
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
662
     *            object.
663
     *
664
     * @param term
665
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
666
     * @param textHeight
667
     *            a int.
668
     * @param style
669
     *            a int.
670
     * @return a
671
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
672
     *         object.
673
     */
674
    public RepresentationElement createRepresentationElement(ICdmFormElement parentElement, TermBase term, int textHeight, int style, boolean fillDetails) {
675
        RepresentationElement element = new RepresentationElement(this, parentElement, term, textHeight, style, fillDetails);
676
        adapt(element);
677
        parentElement.addElement(element);
678
        return element;
679
    }
680

    
681
    /**
682
     * <p>
683
     * createMultiLanguageTextElement
684
     * </p>
685
     *
686
     * @param parentElement
687
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
688
     *            object.
689
     *
690
     * @param term
691
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
692
     * @param textHeight
693
     *            a int.
694
     * @param style
695
     *            a int.
696
     * @return a
697
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
698
     *         object.
699
     */
700
    public TranslatableRepresentationElement createTranslatableRepresentationElement(ICdmFormElement parentElement, TermBase term, int textHeight, int style, boolean fillDetails) {
701
        TranslatableRepresentationElement element = new TranslatableRepresentationElement(this, parentElement, term, textHeight, style, fillDetails);
702
        adapt(element);
703
        parentElement.addElement(element);
704
        return element;
705
    }
706

    
707
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
708
            KeyStatement keyStatement, int textHeight, int style) {
709
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
710
                textHeight, style);
711
        adapt(element);
712
        parentElement.addElement(element);
713
        return element;
714
    }
715

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

    
731
    /**
732
     * <p>
733
     * createTextWithLabelElement
734
     * </p>
735
     *
736
     * @param parentElement
737
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
738
     *            object.
739
     * @param labelString
740
     *            a {@link java.lang.String} object.
741
     * @param initialText
742
     *            a {@link java.lang.String} object.
743
     * @param style
744
     *            a int.
745
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
746
     *         object.
747
     */
748
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
749
            String initialText, int style) {
750
        return createTextWithLabelElement(parentElement, labelString, initialText, null, style);
751
    }
752
    /**
753
     * <p>
754
     * createTextWithLabelElement
755
     * </p>
756
     *
757
     * @param parentElement
758
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
759
     *            object.
760
     * @param labelString
761
     *            a {@link java.lang.String} object.
762
     * @param initialText
763
     *            a {@link java.lang.String} object.
764
     * @param textLimit maximal number of characters allowed
765
     * @param style
766
     *            a int.
767
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
768
     *         object.
769
     */
770
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
771
            String initialText, Integer textLimit, int style) {
772
        if(initialText==null){
773
            initialText = "";
774
        }
775

    
776
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
777
                textLimit, style);
778
        adapt(element);
779
        parentElement.addElement(element);
780
        return element;
781
    }
782

    
783
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
784
            int textHeight, int style) {
785
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
786
        adapt(element);
787
        parentElement.addElement(element);
788
        return element;
789
    }
790

    
791
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
792
            LSID initialLsid, int style) {
793
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
794
        adapt(element);
795
        parentElement.addElement(element);
796
        return element;
797
    }
798

    
799
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
800
            URI initialUri, int style) {
801
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
802
        adapt(element);
803
        parentElement.addElement(element);
804
        return element;
805
    }
806

    
807
    /**
808
     * @param element
809
     * @param string
810
     * @param uri
811
     * @param style
812
     * @return
813
     */
814
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
815
            IOpenUrlEnabled openUrlEnabled, int style) {
816
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
817
                style);
818
        adapt(element);
819
        parentElement.addElement(element);
820
        return element;
821
    }
822

    
823
    /**
824
     *
825
     * @param parentElement
826
     * @param labelString
827
     * @param conversationEnabled
828
     * @param user
829
     * @param style
830
     * @return
831
     */
832
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
833
            ConversationHolder conversation, User user, int style) {
834
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
835
        adapt(element);
836
        parentElement.addElement(element);
837
        return element;
838
    }
839

    
840
    /**
841
     * <p>
842
     * createIntegerTextWithLabelElement
843
     * </p>
844
     *
845
     * @param parentElement
846
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
847
     *            object.
848
     * @param labelString
849
     *            a {@link java.lang.String} object.
850
     * @param initialInteger
851
     *            a {@link java.lang.Integer} object.
852
     * @param style
853
     *            a int.
854
     * @return a
855
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
856
     *         object.
857
     */
858
	public NumberWithLabelElement createNumberTextWithLabelElement(
859
			ICdmFormElement parentElement, String labelString,
860
			Number initialNumber, int style) {
861
		NumberWithLabelElement element = new NumberWithLabelElement(this,
862
				parentElement, labelString, initialNumber, style);
863
		adapt(element);
864
		parentElement.addElement(element);
865
		return element;
866
	}
867

    
868
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
869
            String labelString, LanguageString languageString, int style) {
870
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
871
    }
872

    
873
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
874
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
875
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
876
                languageString, height, isMultiLine, style);
877
        adapt(element);
878
        parentElement.addElement(element);
879
        return element;
880
    }
881

    
882
    /**
883
     * <p>
884
     * createKeyValueViewerElement
885
     * </p>
886
     *
887
     * @param parentElement
888
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
889
     *            object.
890
     * @param keyHeading
891
     *            a {@link java.lang.String} object.
892
     * @param valueHeading
893
     *            a {@link java.lang.String} object.
894
     * @param map
895
     *            a {@link java.util.Map} object.
896
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
897
     *         object.
898
     */
899
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
900
            String valueHeading, Map<Object, Object> map) {
901
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
902
        adapt(element);
903
        parentElement.addElement(element);
904
        return element;
905
    }
906
    /**
907
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
908
     */
909
    @Deprecated
910
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
911
            ICdmFormElement parentElement, String labelString, T selection, int style) {
912
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString, selection, true, style);
913
        adapt(element);
914
        parentElement.addElement(element);
915
        return element;
916
    }
917

    
918
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
919
            TermType termType,
920
            ICdmFormElement parentElement,
921
            String labelString,
922
            T selection,
923
            int style,
924
            Comparator<T> comparator) {
925
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false, comparator);
926
    }
927

    
928
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
929
			TermType termType,
930
			ICdmFormElement parentElement,
931
			String labelString,
932
			T selection,
933
			boolean addEmptyElement,
934
			int style) {
935
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, false, null);
936
	}
937

    
938
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
939
			TermType termType,
940
			ICdmFormElement parentElement,
941
			String labelString,
942
			T selection,
943
			int style) {
944
		return  this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false, null);
945
	}
946
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
947
			TermType termType,
948
			ICdmFormElement parentElement,
949
			String labelString,
950
			T selection,
951
			boolean addEmptyElement,
952
			int style,
953
			boolean useAbbrevLabel) {
954
		return createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
955
	}
956

    
957

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

    
967
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
968
	        TermVocabulary<?> termVocabulary,
969
	        ICdmFormElement parentElement,
970
	        String labelString,
971
	        T selection,
972
	        boolean addEmptyElement,
973
	        int style,
974
	        boolean useAbbrevLabel) {
975
	    return createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
976
	}
977

    
978
	private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
979
	        TermType termType,
980
	        TermVocabulary<?> termVocabulary,
981
	        ICdmFormElement parentElement,
982
	        String labelString,
983
	        T selection,
984
	        boolean addEmptyElement,
985
	        int style,
986
	        boolean useAbbrevLabel,
987
	        Comparator<T> comparator) {
988
	    if(termType!=null){
989
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
990
	        adapt(element);
991
	        parentElement.addElement(element);
992
	        return element;
993
	    }
994
	    else if(termVocabulary!=null){
995
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
996
	        if (comparator!= null){
997
	        	element.setTermComparator(comparator);
998
	        }
999
	        adapt(element);
1000
	        parentElement.addElement(element);
1001
	        return element;
1002
	    }
1003
	    else{
1004
	        //this should never happen
1005
	        return null;
1006
	    }
1007
	}
1008
	public MisappliedRelationshipComboElement createMisappliedRelationshipComboElement(
1009
	        ICdmFormElement parentElement,
1010
            String labelString,
1011
            TaxonRelationshipType selection,
1012
            int style) {
1013
	    MisappliedRelationshipComboElement combo = new MisappliedRelationshipComboElement(this, parentElement, labelString, selection, false, style, false);
1014
	    adapt(combo);
1015
        parentElement.addElement(combo);
1016
        return combo;
1017
    }
1018

    
1019
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1020
	        Class<T> enumComboType, ICdmFormElement parentElement,
1021
	        int style) {
1022
	    return createEnumComboElement(enumComboType, parentElement, null, style);
1023
	}
1024

    
1025
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1026
			Class<T> enumComboType, ICdmFormElement parentElement, Comparator<T> comparator,
1027
			int style) {
1028
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, comparator, style);
1029
        adapt(element);
1030
        parentElement.addElement(element);
1031
        return element;
1032
    }
1033

    
1034
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
1035
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
1036
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1037
	    adapt(element);
1038
	    parentElement.addElement(element);
1039
	    return element;
1040
	}
1041

    
1042
    /**
1043
     * <p>
1044
     * createBrowserElement
1045
     * </p>
1046
     *
1047
     * @param imageUri
1048
     *            a {@link java.net.URI} object.
1049
     * @param style
1050
     *            a int.
1051
     * @param parentElement
1052
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1053
     *            object.
1054
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
1055
     *         object.
1056
     */
1057
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
1058
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
1059
        adapt(element);
1060
        parentElement.addElement(element);
1061
        return element;
1062
    }
1063

    
1064
    /**
1065
     * <p>
1066
     * createImageElement
1067
     * </p>
1068
     *
1069
     * @param parentElement
1070
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1071
     *            object.
1072
     * @param imageUri
1073
     *            a {@link java.net.URI} object.
1074
     * @param style
1075
     *            a int.
1076
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1077
     */
1078
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1079
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1080
        adapt(element);
1081
        parentElement.addElement(element);
1082
        return element;
1083
    }
1084

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

    
1113
    /**
1114
     * <p>
1115
     * createCheckbox
1116
     * </p>
1117
     *
1118
     * @param parentElement
1119
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1120
     *            object.
1121
     * @param label
1122
     *            a {@link java.lang.String} object.
1123
     * @param initialState
1124
     *            a boolean.
1125
     * @param style
1126
     *            a int.
1127
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1128
     *         object.
1129
     */
1130
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1131
        if(initialState==null){
1132
            initialState = Boolean.FALSE;
1133
        }
1134
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1135
        adapt(element);
1136
        parentElement.addElement(element);
1137
        return element;
1138
    }
1139

    
1140
    /**
1141
     * Creates a section as a part of the form.
1142
     *
1143
     * @return the section widget
1144
     * @param section
1145
     *            a
1146
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1147
     *            object.
1148
     */
1149
    public Section adapt(AbstractFormSection section) {
1150
        section.setMenu(section.getLayoutComposite().getMenu());
1151
        adapt(section, true, true);
1152

    
1153
        // handle focus and property change events for cdm use
1154
        section.addFocusListener(selectionFocusHandler);
1155
        section.setPropertyChangeListeners(propertyChangeListeners);
1156

    
1157
        if (section.getToggle() != null) {
1158
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1159
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1160
        }
1161

    
1162
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1163

    
1164
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1165
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1166
            getColors().initializeSectionToolBarColors();
1167
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1168
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1169
        }
1170
        // call setTitleBarForeground regardless as it also sets the label color
1171
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1172
        return section;
1173
    }
1174

    
1175
    private class BoldFontHolder2 {
1176
        private Font normalFont;
1177

    
1178
        private Font boldFont;
1179

    
1180
        public BoldFontHolder2() {
1181
        }
1182

    
1183
        public Font getBoldFont(Font font) {
1184
            createBoldFont(font);
1185
            return boldFont;
1186
        }
1187

    
1188
        private void createBoldFont(Font font) {
1189
            if (normalFont == null || !normalFont.equals(font)) {
1190
                normalFont = font;
1191
                dispose();
1192
            }
1193
            if (boldFont == null) {
1194
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1195
            }
1196
        }
1197

    
1198
        public void dispose() {
1199
            if (boldFont != null) {
1200
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1201
                boldFont = null;
1202
            }
1203
        }
1204
    }
1205

    
1206
    /**
1207
     * <p>
1208
     * createToggleableTextField
1209
     * </p>
1210
     *
1211
     * @param parentElement
1212
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1213
     *            object.
1214
     * @param labelString
1215
     *            a {@link java.lang.String} object.
1216
     * @param initialText
1217
     *            a {@link java.lang.String} object.
1218
     * @param initialState
1219
     *            a boolean.
1220
     * @param style
1221
     *            a int.
1222
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1223
     *         object.
1224
     */
1225
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1226
            String initialText, boolean initialState, int style) {
1227
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1228
                initialState, style | orientation);
1229
        adapt(element);
1230
        parentElement.addElement(element);
1231
        return element;
1232
    }
1233

    
1234
    /**
1235
     * <p>
1236
     * createTimePeriodElement
1237
     * </p>
1238
     *
1239
     * @param parentElement
1240
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1241
     *            object.
1242
     * @param labelString
1243
     *            a {@link java.lang.String} object.
1244
     * @param timePeriod
1245
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1246
     * @param style
1247
     *            a int.
1248
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1249
     *         object.
1250
     */
1251
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1252
            TimePeriod timePeriod, int style) {
1253
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1254
        adapt(element);
1255
        parentElement.addElement(element);
1256
        return element;
1257
    }
1258

    
1259
	/**
1260
	 * <p>
1261
	 * createGatheringEventUnitElement
1262
	 * </p>
1263
	 *
1264
	 * @param parentElement
1265
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1266
	 *            object.
1267
	 * @param labelString
1268
	 *            a {@link java.lang.String} object.
1269
	 * @param timePeriod
1270
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1271
	 * @param style
1272
	 *            a int.
1273
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1274
	 *         object.
1275
	 */
1276
	public GatheringEventUnitElement createGatheringEventUnitElement(
1277
			ICdmFormElement parentElement,
1278
			String labelString,
1279
			DerivedUnitFacade gatheringEvent,
1280
			MinMaxTextSection.UnitType unitType,
1281
			int style) {
1282
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1283
				parentElement,
1284
				labelString,
1285
				gatheringEvent,
1286
				unitType,
1287
				style);
1288
		adapt(element);
1289
		parentElement.addElement(element);
1290
		return element;
1291
	}
1292

    
1293
    /**
1294
     * <p>
1295
     * createPointElement
1296
     * </p>
1297
     *
1298
     * @param style
1299
     *            a int.
1300
     * @param parentElement
1301
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1302
     *            object.
1303
     * @param point
1304
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1305
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1306
     */
1307
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1308
        PointElement element = new PointElement(this, parentElement, point, style);
1309
        adapt(element);
1310
        parentElement.addElement(element);
1311
        return element;
1312
    }
1313

    
1314

    
1315

    
1316
    /**
1317
     * @param conversationHolder
1318
     * @param parent
1319
     * @param detailsViewer
1320
     * @param i
1321
     * @return
1322
     */
1323
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1324
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1325
        parentElement.addElement(section);
1326
        adapt(section);
1327
        return section;
1328
    }
1329

    
1330
    /**
1331
     * <p>
1332
     * createDateDetailSection
1333
     * </p>
1334
     *
1335
     * @param parentElement
1336
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1337
     *            object.
1338
     * @param style
1339
     *            a int.
1340
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1341
     *         object.
1342
     */
1343
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1344
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1345
        parentElement.addElement(section);
1346
        adapt(section);
1347
        return section;
1348
    }
1349

    
1350
	/**
1351
	 * <p>
1352
	 * createDateDetailSection
1353
	 * </p>
1354
	 *
1355
	 * @param parentElement
1356
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1357
	 *            object.
1358
	 * @param style
1359
	 *            a int.
1360
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1361
	 *         object.
1362
	 */
1363
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1364
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1365
		parentElement.addElement(section);
1366
		adapt(section);
1367
		return section;
1368
	}
1369

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

    
1395
    /**
1396
     * <p>
1397
     * addSelectionListener
1398
     * </p>
1399
     *
1400
     * @param listener
1401
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1402
     */
1403
    public void addSelectionListener(SelectionListener listener) {
1404
        selectionListenerList.add(listener);
1405
    }
1406

    
1407
    /**
1408
     * <p>
1409
     * removeSelectionListener
1410
     * </p>
1411
     *
1412
     * @param listener
1413
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1414
     */
1415
    public void removeSelectionListener(SelectionListener listener) {
1416
        if (listener == null) {
1417
            MessagingUtils.error(this.getClass(),
1418
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1419
        } else {
1420
            selectionListenerList.remove(listener);
1421
        }
1422
    }
1423

    
1424
    /**
1425
     * <p>
1426
     * addPropertyChangeListener
1427
     * </p>
1428
     *
1429
     * @param listener
1430
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1431
     *            object.
1432
     */
1433
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1434
        if (propertyChangeListeners.contains(listener)) {
1435
            return;
1436
        }
1437
        propertyChangeListeners.add(0, listener);
1438
    }
1439

    
1440
    /**
1441
     * <p>
1442
     * removePropertyChangeListener
1443
     * </p>
1444
     *
1445
     * @param listener
1446
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1447
     *            object.
1448
     */
1449
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1450
        propertyChangeListeners.remove(listener);
1451
    }
1452

    
1453
    /**
1454
     * @return the propertyChangeListeners
1455
     */
1456
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1457
        return propertyChangeListeners;
1458
    }
1459

    
1460
    /**
1461
     * <p>
1462
     * createHorizontalSeparator
1463
     * </p>
1464
     *
1465
     * @param parentElement
1466
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1467
     *            object.
1468
     * @param style
1469
     *            a int.
1470
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1471
     */
1472
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1473
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1474
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1475
        return separator;
1476
    }
1477

    
1478
    /**
1479
     * <p>
1480
     * createVersionElement
1481
     * </p>
1482
     *
1483
     * @param parentElement
1484
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1485
     *            object.
1486
     * @param entity
1487
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1488
     *            object.
1489
     * @param style
1490
     *            a int.
1491
     * @return a
1492
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1493
     *         object.
1494
     */
1495
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1496
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1497
        adapt(element);
1498
        parentElement.addElement(element);
1499
        return element;
1500
    }
1501

    
1502
    /**
1503
     * @param cdmBaseSection
1504
     * @param object
1505
     * @param style
1506
     * @return
1507
     */
1508
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1509
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1510
        adapt(element);
1511
        parentElement.addElement(element);
1512
        return element;
1513
    }
1514

    
1515
    /**
1516
     * <p>
1517
     * createVersionSection
1518
     * </p>
1519
     *
1520
     * @param parentElement
1521
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1522
     *            object.
1523
     * @param style
1524
     *            a int.
1525
     * @return a
1526
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1527
     *         object.
1528
     */
1529
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1530
        VersionSection section = new VersionSection(this, parentElement, style);
1531
        parentElement.addElement(section);
1532
        adapt(section);
1533
        return section;
1534
    }
1535

    
1536
    /**
1537
     * @param parent
1538
     * @param i
1539
     * @return
1540
     */
1541
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1542
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1543
        parentElement.addElement(section);
1544
        adapt(section);
1545
        return section;
1546
    }
1547

    
1548
    /**
1549
     * <p>
1550
     * createEmptyElement
1551
     * </p>
1552
     *
1553
     * @param parentElement
1554
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1555
     *            object.
1556
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1557
     */
1558
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1559
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1560
        adapt(element);
1561
        parentElement.addElement(element);
1562
        return element;
1563
    }
1564

    
1565
    /**
1566
     * <p>
1567
     * createHeadlineSection
1568
     * </p>
1569
     *
1570
     * @param parentElement
1571
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1572
     *            object.
1573
     * @return a
1574
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1575
     *         object.
1576
     */
1577
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1578
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1579
        parentElement.addElement(section);
1580
        adapt(section);
1581
        return section;
1582
    }
1583

    
1584
    /**
1585
     * <p>
1586
     * createParsingMessageElement
1587
     * </p>
1588
     *
1589
     * @param parentElement
1590
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1591
     *            object.
1592
     * @param parserProblem
1593
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1594
     *            object.
1595
     * @param style
1596
     *            a int.
1597
     * @return a
1598
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1599
     *         object.
1600
     */
1601
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1602
            ParserProblem parserProblem, int style) {
1603
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1604
        adapt(element);
1605
        parentElement.addElement(element);
1606
        return element;
1607
    }
1608

    
1609
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1610
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1611

    
1612
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1613
                selectionProvider, style);
1614

    
1615
        parentElement.addElement(section);
1616
        adapt(section);
1617
        return section;
1618

    
1619
    }
1620

    
1621
    /**
1622
     * @param definedTermClass
1623
     * @param formElement
1624
     * @param style
1625
     * @return
1626
     */
1627
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1628
            AbstractCdmDetailSection parentElement, int style) {
1629
        AbstractCdmDetailElement element = null;
1630

    
1631
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1632
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1633
        } else if (definedTermClass.equals(Feature.class)) {
1634
            element = new FeatureDetailElement(this, parentElement);
1635
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1636
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1637
        } else {
1638
            element = new DefinedTermDetailElement(this, parentElement);
1639
        }
1640

    
1641

    
1642
        adapt(element);
1643
        parentElement.addElement(element);
1644
        return element;
1645
    }
1646

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

    
1653
    public CharacterDetailElement createCharacterDetailElement(ICdmFormElement parentElement, int style){
1654
        CharacterDetailElement element = new CharacterDetailElement(this, parentElement);
1655
        addAndAdaptElement(parentElement, element);
1656
        return element;
1657
    }
1658

    
1659
    public FeatureTreeDetailElement createFeatureTreeDetailElement(ICdmFormElement parentElement, int style){
1660
        FeatureTreeDetailElement element = new FeatureTreeDetailElement(this, parentElement);
1661
        addAndAdaptElement(parentElement, element);
1662
        return element;
1663
    }
1664

    
1665
    public FeatureNodeDetailElement createFeatureNodeDetailElement(ICdmFormElement parentElement, int style){
1666
        FeatureNodeDetailElement element = new FeatureNodeDetailElement(this, parentElement);
1667
        addAndAdaptElement(parentElement, element);
1668
        return element;
1669
    }
1670

    
1671

    
1672
    //--------DetailSections---------
1673
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1674
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1675
        addAndAdaptSection(parentElement, section);
1676
        return section;
1677
    }
1678

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

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

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

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

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

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

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

    
1721
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1722
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1723
        addAndAdaptSection(parentElement, section);
1724
        return section;
1725
    }
1726

    
1727
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1728
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1729
        addAndAdaptSection(parentElement, section);
1730
        return section;
1731
    }
1732

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

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

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

    
1751

    
1752

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

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

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

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

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

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

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

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

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

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

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

    
1819
    public ClassificationDetailSection createClassificationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1820
        ClassificationDetailSection section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style);
1821
        addAndAdaptSection(parentElement, section);
1822
        return section;
1823
    }
1824

    
1825
    public TaxonNodeDetailSection createTaxonNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1826
        TaxonNodeDetailSection section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1827
        addAndAdaptSection(parentElement, section);
1828
        return section;
1829
    }
1830

    
1831
    public PolytomousKeyDetailSection createPolytomousKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1832
        PolytomousKeyDetailSection section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
1833
        addAndAdaptSection(parentElement, section);
1834
        return section;
1835
    }
1836

    
1837
    public PolytomousKeyNodeDetailSection createPolytomousKeyNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1838
        PolytomousKeyNodeDetailSection section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1839
        addAndAdaptSection(parentElement, section);
1840
        return section;
1841
    }
1842

    
1843
    public InstitutionDetailSection createInstitutionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1844
        InstitutionDetailSection section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
1845
        addAndAdaptSection(parentElement, section);
1846
        return section;
1847
    }
1848

    
1849
    public FieldUnitGeneralDetailSection createFieldUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1850
        FieldUnitGeneralDetailSection section = new FieldUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1851
        addAndAdaptSection(parentElement, section);
1852
        return section;
1853
    }
1854

    
1855
    public DerivedUnitGeneralDetailSection createDerivedUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1856
        DerivedUnitGeneralDetailSection section = new DerivedUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1857
        addAndAdaptSection(parentElement, section);
1858
        return section;
1859
    }
1860

    
1861
    public PreservedSpecimenGeneralDetailSection createPreservedSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1862
        PreservedSpecimenGeneralDetailSection section = new PreservedSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1863
        addAndAdaptSection(parentElement, section);
1864
        return section;
1865
    }
1866

    
1867
    public TissueSampleGeneralDetailSection createTissueSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1868
        TissueSampleGeneralDetailSection section = new TissueSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1869
        addAndAdaptSection(parentElement, section);
1870
        return section;
1871
    }
1872

    
1873
    public DnaSampleGeneralDetailSection createDnaSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1874
        DnaSampleGeneralDetailSection section = new DnaSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1875
        addAndAdaptSection(parentElement, section);
1876
        return section;
1877
    }
1878

    
1879
    public DnaSamplePreparationPreservationSection createDnaSamplePreparationPreservationSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1880
        DnaSamplePreparationPreservationSection section = new DnaSamplePreparationPreservationSection(this, conversation, parentElement, selectionProvider, style);
1881
        addAndAdaptSection(parentElement, section);
1882
        return section;
1883
    }
1884

    
1885
    public DnaQualityDetailSection createDnaQualityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1886
        DnaQualityDetailSection section = new DnaQualityDetailSection(this, conversation, parentElement, selectionProvider, style);
1887
        addAndAdaptSection(parentElement, section);
1888
        return section;
1889
    }
1890

    
1891
    public SequenceGeneralDetailSection createSequenceGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1892
        SequenceGeneralDetailSection section = new SequenceGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1893
        addAndAdaptSection(parentElement, section);
1894
        return section;
1895
    }
1896

    
1897
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1898
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
1899
        addAndAdaptSection(parentElement, section);
1900
        return section;
1901
    }
1902

    
1903
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1904
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
1905
        addAndAdaptSection(parentElement, section);
1906
        return section;
1907
    }
1908

    
1909
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1910
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1911
        addAndAdaptSection(parentElement, section);
1912
        return section;
1913
    }
1914

    
1915
    public SingleReadGeneralDetailSection createSingleReadGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1916
        SingleReadGeneralDetailSection section = new SingleReadGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1917
        addAndAdaptSection(parentElement, section);
1918
        return section;
1919
    }
1920

    
1921
    public AmplificationGeneralDetailSection createAmplificationGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1922
        AmplificationGeneralDetailSection section = new AmplificationGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1923
        addAndAdaptSection(parentElement, section);
1924
        return section;
1925
    }
1926

    
1927
    public AmplificationPrimerDetailSection createAmplificationPrimerDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1928
        AmplificationPrimerDetailSection section = new AmplificationPrimerDetailSection(this, conversation, parentElement, selectionProvider, style);
1929
        addAndAdaptSection(parentElement, section);
1930
        return section;
1931
    }
1932

    
1933
    public AmplificationCloningDetailSection createAmplificationCloningDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1934
        AmplificationCloningDetailSection section = new AmplificationCloningDetailSection(this, conversation, parentElement, selectionProvider, style);
1935
        addAndAdaptSection(parentElement, section);
1936
        return section;
1937
    }
1938

    
1939
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1940
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1941
        addAndAdaptSection(parentElement, section);
1942
        return section;
1943
    }
1944

    
1945
    public MediaSpecimenGeneralDetailSection createMediaSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1946
        MediaSpecimenGeneralDetailSection section = new MediaSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1947
        addAndAdaptSection(parentElement, section);
1948
        return section;
1949
    }
1950

    
1951
    public HybridDetailSection createHybridDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1952
        HybridDetailSection section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
1953
        addAndAdaptSection(parentElement, section);
1954
        return section;
1955
    }
1956

    
1957
    public UserDetailSection createUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1958
        UserDetailSection section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
1959
        addAndAdaptSection(parentElement, section);
1960
        return section;
1961
    }
1962

    
1963
    public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1964
        GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
1965
        addAndAdaptSection(parentElement, section);
1966
        return section;
1967
    }
1968

    
1969
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1970
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1971
        addAndAdaptSection(parentElement, section);
1972
        return section;
1973
    }
1974

    
1975
    public SampleDesignationDetailSection createSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1976
        SampleDesignationDetailSection section = new SampleDesignationDetailSection(this, conversation, parentElement, selectionProvider, style);
1977
        addAndAdaptSection(parentElement, section);
1978
        return section;
1979
    }
1980

    
1981
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1982
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style, true);
1983
        addAndAdaptSection(parentElement, section);
1984
        return section;
1985
    }
1986

    
1987
    public ReferencedEntityDetailSection createReferencedEntityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1988
        ReferencedEntityDetailSection section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
1989
        addAndAdaptSection(parentElement, section);
1990
        return section;
1991
    }
1992

    
1993
    public TermVocabularyDetailSection createTermVocabularyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1994
        TermVocabularyDetailSection section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
1995
        addAndAdaptSection(parentElement, section);
1996
        return section;
1997
    }
1998

    
1999
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2000
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
2001
        addAndAdaptSection(parentElement, section);
2002
        return section;
2003
    }
2004

    
2005
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2006
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
2007
        addAndAdaptSection(parentElement, section);
2008
        return section;
2009
    }
2010

    
2011
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2012
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
2013
        addAndAdaptSection(parentElement, section);
2014
        return section;
2015
    }
2016

    
2017
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
2018
        parentElement.addElement(section);
2019
        adapt(section);
2020
    }
2021

    
2022
    //--------DetailElements------------
2023

    
2024
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
2025
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
2026
        addAndAdaptElement(parentElement, element);
2027
        return element;
2028
    }
2029

    
2030
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
2031
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
2032
        addAndAdaptElement(parentElement, element);
2033
        return element;
2034
    }
2035

    
2036
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
2037
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
2038
        addAndAdaptElement(parentElement, element);
2039
        return element;
2040
    }
2041

    
2042
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
2043
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
2044
        addAndAdaptElement(parentElement, element);
2045
        return element;
2046
    }
2047

    
2048
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
2049
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
2050
        addAndAdaptElement(parentElement, element);
2051
        return element;
2052
    }
2053

    
2054
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
2055
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
2056
        addAndAdaptElement(parentElement, element);
2057
        return element;
2058
    }
2059

    
2060
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
2061
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2062
        addAndAdaptElement(parentElement, element);
2063
        return element;
2064
    }
2065

    
2066
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2067
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2068
        addAndAdaptElement(parentElement, element);
2069
        return element;
2070
    }
2071

    
2072
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2073
        UserDetailElement element = new UserDetailElement(this, parentElement);
2074
        addAndAdaptElement(parentElement, element);
2075
        return element;
2076
    }
2077

    
2078
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2079
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2080
        addAndAdaptElement(parentElement, element);
2081
        return element;
2082
    }
2083

    
2084
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2085
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2086
        addAndAdaptElement(parentElement, element);
2087
        return element;
2088
    }
2089

    
2090
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2091
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2092
        addAndAdaptElement(parentElement, element);
2093
        return element;
2094
    }
2095

    
2096
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2097
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2098
        addAndAdaptElement(parentElement, element);
2099
        return element;
2100
    }
2101

    
2102
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2103
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2104
        addAndAdaptElement(parentElement, element);
2105
        return element;
2106
    }
2107

    
2108
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2109
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2110
        adapt(element);
2111
        parentElement.addElement(element);
2112

    
2113
        return element;
2114
    }
2115

    
2116
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2117
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2118
        addAndAdaptElement(parentElement, element);
2119
        return element;
2120
    }
2121

    
2122
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
2123
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
2124
        addAndAdaptElement(parentElement, element);
2125
        return element;
2126
    }
2127

    
2128
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2129
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2130
        addAndAdaptElement(parentElement, element);
2131
        return element;
2132
    }
2133

    
2134
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2135
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2136
        addAndAdaptElement(parentElement, element);
2137
        return element;
2138
    }
2139

    
2140
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2141
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2142
        addAndAdaptElement(parentElement, element);
2143
        return element;
2144
    }
2145

    
2146
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2147
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2148
        addAndAdaptElement(parentElement, element);
2149
        return element;
2150
    }
2151

    
2152
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2153
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2154
        addAndAdaptElement(parentElement, element);
2155
        return element;
2156
    }
2157

    
2158
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2159
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2160
        addAndAdaptElement(parentElement, element);
2161
        return element;
2162
    }
2163

    
2164
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2165
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2166
        addAndAdaptElement(parentElement, element);
2167
        return element;
2168
    }
2169

    
2170
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2171
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2172
        addAndAdaptElement(parentElement, element);
2173
        return element;
2174
    }
2175

    
2176
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2177
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2178
        addAndAdaptElement(parentElement, element);
2179
        return element;
2180
    }
2181

    
2182
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2183
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2184
        addAndAdaptElement(parentElement, element);
2185
        return element;
2186
    }
2187

    
2188
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2189
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2190
        addAndAdaptElement(parentElement, element);
2191
        return element;
2192
    }
2193

    
2194
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2195
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2196
        addAndAdaptElement(parentElement, element);
2197
        return element;
2198
    }
2199

    
2200
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2201
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2202
        addAndAdaptElement(parentElement, element);
2203
        return element;
2204
    }
2205

    
2206

    
2207
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2208
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2209
        addAndAdaptElement(parentElement, element);
2210
        return element;
2211
    }
2212

    
2213
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2214
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2215
        addAndAdaptElement(parentElement, element);
2216
        return element;
2217
    }
2218

    
2219
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2220
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2221
        addAndAdaptElement(parentElement, element);
2222
        return element;
2223
    }
2224

    
2225
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2226
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2227
        addAndAdaptElement(parentElement, element);
2228
        return element;
2229
    }
2230

    
2231
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2232
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2233
        addAndAdaptElement(parentElement, element);
2234
        return element;
2235
    }
2236

    
2237
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2238
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2239
        addAndAdaptElement(parentElement, element);
2240
        return element;
2241
    }
2242

    
2243
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2244
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2245
        addAndAdaptElement(parentElement, element);
2246
        return element;
2247
    }
2248

    
2249
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2250
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2251
        addAndAdaptElement(parentElement, element);
2252
        return element;
2253
    }
2254

    
2255
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2256
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2257
        addAndAdaptElement(parentElement, element);
2258
        return element;
2259
    }
2260

    
2261
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2262
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2263
        addAndAdaptElement(parentElement, element);
2264
        return element;
2265
    }
2266

    
2267
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2268
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2269
        addAndAdaptElement(parentElement, element);
2270
        return element;
2271
    }
2272

    
2273
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2274
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2275
        addAndAdaptElement(parentElement, element);
2276
        return element;
2277
    }
2278

    
2279
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2280
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2281
        addAndAdaptElement(parentElement, element);
2282
        return element;
2283
    }
2284

    
2285
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2286
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2287
        addAndAdaptElement(parentElement, element);
2288
        return element;
2289
    }
2290

    
2291
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2292
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2293
        addAndAdaptElement(parentElement, element);
2294
        return element;
2295
    }
2296

    
2297
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2298
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2299
        addAndAdaptElement(parentElement, element);
2300
        return element;
2301
    }
2302

    
2303
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2304
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2305
        addAndAdaptElement(parentElement, mediaDetailElement);
2306
        return mediaDetailElement;
2307
    }
2308

    
2309
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2310
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2311
        addAndAdaptElement(parentElement, element);
2312
        return element;
2313
    }
2314

    
2315
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2316
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2317
        addAndAdaptElement(parentElement, element);
2318
        return element;
2319
    }
2320

    
2321
    public SpecimenHierarchyDetailElement createSpecimenHierarchyDetailElement(ICdmFormElement parentElement) {
2322
        SpecimenHierarchyDetailElement element = new SpecimenHierarchyDetailElement(this, parentElement);
2323
        addAndAdaptElement(parentElement, element);
2324
        return element;
2325
    }
2326

    
2327
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2328
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2329
        addAndAdaptElement(parentElement, element);
2330
        return element;
2331
    }
2332

    
2333
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2334
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2335
        addAndAdaptElement(parentElement, element);
2336
        return element;
2337
    }
2338

    
2339
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2340
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2341
        addAndAdaptElement(parentElement, element);
2342
        return element;
2343
    }
2344

    
2345
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2346
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2347
        addAndAdaptElement(parentElement, element);
2348
        return element;
2349
    }
2350

    
2351
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2352
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2353
        addAndAdaptElement(parentElement, element);
2354
        return element;
2355
    }
2356

    
2357
    /**
2358
     * @param parentElement
2359
     * @param element
2360
     */
2361
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2362
        adapt(element);
2363
        parentElement.addElement(element);
2364
    }
2365

    
2366
    //--------EntityCollectionSection----------
2367
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2368
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2369
        addAndAdaptSection(parentElement, section);
2370
        return section;
2371
    }
2372

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

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

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

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

    
2397
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2398
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2399
        addAndAdaptSection(parentElement, section);
2400
        return section;
2401
    }
2402

    
2403
    public ExtensionSection createExtensionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2404
        ExtensionSection section = new ExtensionSection(this, conversation, parentElement, style);
2405
        addAndAdaptSection(parentElement, section);
2406
        return section;
2407
    }
2408

    
2409
    public MarkerSection createMarkerSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2410
        MarkerSection section = new MarkerSection(this, conversation, parentElement, style);
2411
        addAndAdaptSection(parentElement, section);
2412
        return section;
2413
    }
2414

    
2415
    public MediaSection createMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2416
        MediaSection section = new MediaSection(this, conversation, parentElement, style);
2417
        addAndAdaptSection(parentElement, section);
2418
        return section;
2419
    }
2420

    
2421
    public DescriptionElementMediaSection createDescriptionElementMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2422
        DescriptionElementMediaSection section = new DescriptionElementMediaSection(this, conversation, parentElement, style);
2423
        addAndAdaptSection(parentElement, section);
2424
        return section;
2425
    }
2426

    
2427
    public MediaRepresentationSection createMediaRepresentationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2428
        MediaRepresentationSection section = new MediaRepresentationSection(this, conversation, parentElement, style);
2429
        addAndAdaptSection(parentElement, section);
2430
        return section;
2431
    }
2432

    
2433
    public MediaRepresentationPartSection createMediaRepresentationPartSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2434
        MediaRepresentationPartSection section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
2435
        addAndAdaptSection(parentElement, section);
2436
        return section;
2437
    }
2438

    
2439
    public ModifierSection createModifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2440
        ModifierSection section = new ModifierSection(this, conversation, parentElement, style);
2441
        addAndAdaptSection(parentElement, section);
2442
        return section;
2443
    }
2444

    
2445
    public NomenclaturalStatusSection createNomenclaturalStatusSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2446
        NomenclaturalStatusSection section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
2447
        addAndAdaptSection(parentElement, section);
2448
        return section;
2449
    }
2450

    
2451
    public NameRelationshipDetailSection createNameRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2452
        NameRelationshipDetailSection section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
2453
        addAndAdaptSection(parentElement, section);
2454
        return section;
2455
    }
2456

    
2457
    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2458
        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2459
        addAndAdaptSection(parentElement, section);
2460
        return section;
2461
    }
2462

    
2463
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2464
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2465
        addAndAdaptSection(parentElement, section);
2466
        return section;
2467
    }
2468

    
2469
    public SourceSection createSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2470
        SourceSection section = new SourceSection(this, conversation, parentElement, style);
2471
        addAndAdaptSection(parentElement, section);
2472
        return section;
2473
    }
2474

    
2475
    public ScopeSection createScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2476
        ScopeSection section = new ScopeSection(this, conversation, parentElement, style);
2477
        addAndAdaptSection(parentElement, section);
2478
        return section;
2479
    }
2480

    
2481
    public DescriptionSourceSection createDescriptionSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2482
        DescriptionSourceSection section = new DescriptionSourceSection(this, conversation, parentElement, style);
2483
        addAndAdaptSection(parentElement, section);
2484
        return section;
2485
    }
2486

    
2487
    public TypeDesignationSection createTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2488
        TypeDesignationSection section = new TypeDesignationSection(this, conversation, parentElement, style);
2489
        addAndAdaptSection(parentElement, section);
2490
        return section;
2491
    }
2492

    
2493
    public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2494
        StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
2495
        addAndAdaptSection(parentElement, section);
2496
        return section;
2497
    }
2498

    
2499
    public StatisticalMeasurementValueSection createStatisticalMeasurementValueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2500
        StatisticalMeasurementValueSection section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
2501
        addAndAdaptSection(parentElement, section);
2502
        return section;
2503
    }
2504

    
2505
    public DescribedSpecimenSection createDescribedSpecimenSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2506
        DescribedSpecimenSection section = new DescribedSpecimenSection(this, conversation, parentElement, style);
2507
        addAndAdaptSection(parentElement, section);
2508
        return section;
2509
    }
2510

    
2511
    public StateVocabularyCollectionSection createStateVocabulariesSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2512
        StateVocabularyCollectionSection section = new StateVocabularyCollectionSection(this, conversation, parentElement, style);
2513
        addAndAdaptSection(parentElement, section);
2514
        return section;
2515
    }
2516

    
2517
    public RecommendedModifierVocabulariesCollectionSection createRecommendedModifierVocabulariesCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2518
        RecommendedModifierVocabulariesCollectionSection section = new RecommendedModifierVocabulariesCollectionSection(this, conversation, parentElement, style);
2519
        addAndAdaptSection(parentElement, section);
2520
        return section;
2521
    }
2522

    
2523
    public MeasurementUnitCollectionSection createMeasurementUnitCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2524
        MeasurementUnitCollectionSection section = new MeasurementUnitCollectionSection(this, conversation, parentElement, style);
2525
        addAndAdaptSection(parentElement, section);
2526
        return section;
2527
    }
2528

    
2529
    public StatisticalMeasureCollectionSection createStatisticalMeasureCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2530
        StatisticalMeasureCollectionSection section = new StatisticalMeasureCollectionSection(this, conversation, parentElement, style);
2531
        addAndAdaptSection(parentElement, section);
2532
        return section;
2533
    }
2534

    
2535
    public CollectingAreasDetailSection createCollectingAreasDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2536
        CollectingAreasDetailSection section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
2537
        addAndAdaptSection(parentElement, section);
2538
        return section;
2539
    }
2540

    
2541
    public GeoScopeDetailSection createGeoScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2542
        GeoScopeDetailSection section = new GeoScopeDetailSection(this, conversation, parentElement, style);
2543
        addAndAdaptSection(parentElement, section);
2544
        return section;
2545
    }
2546

    
2547
    public GeoScopePolyKeyDetailSection createGeoScopePolyKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2548
        GeoScopePolyKeyDetailSection section = new GeoScopePolyKeyDetailSection(this, conversation, parentElement, style);
2549
        addAndAdaptSection(parentElement, section);
2550
        return section;
2551
    }
2552

    
2553
    public IdentifierSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2554
        IdentifierSection section = new IdentifierSection(this, conversation, parentElement, style);
2555
        addAndAdaptSection(parentElement, section);
2556
        return section;
2557
    }
2558

    
2559
    public DerivedUnitFacadeIdentifierSection createDerivedUnitFacadeIdentifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2560
    	DerivedUnitFacadeIdentifierSection section = new DerivedUnitFacadeIdentifierSection(this, conversation, parentElement, style);
2561
    	addAndAdaptSection(parentElement, section);
2562
    	return section;
2563
    }
2564

    
2565
    public CurrentSampleDesignationDetailSection createCurrentSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2566
        CurrentSampleDesignationDetailSection section = new CurrentSampleDesignationDetailSection(this, conversation, parentElement, style);
2567
        addAndAdaptSection(parentElement, section);
2568
        return section;
2569
    }
2570

    
2571
    public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2572
        CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
2573
        addAndAdaptSection(parentElement, section);
2574
        return section;
2575
    }
2576

    
2577
    public PreservedSpecimenCurrentDeterminationDetailSection createPreservedSpecimenCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2578
        PreservedSpecimenCurrentDeterminationDetailSection section = new PreservedSpecimenCurrentDeterminationDetailSection(this, conversation, parentElement, style);
2579
        addAndAdaptSection(parentElement, section);
2580
        return section;
2581
    }
2582

    
2583
    public SampleDesignationHistoryDetailSection createSampleDesignationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2584
        SampleDesignationHistoryDetailSection section = new SampleDesignationHistoryDetailSection(this, conversation, parentElement, style);
2585
        addAndAdaptSection(parentElement, section);
2586
        return section;
2587
    }
2588

    
2589
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2590
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
2591
        addAndAdaptSection(parentElement, section);
2592
        return section;
2593
    }
2594

    
2595
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2596
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
2597
        addAndAdaptSection(parentElement, section);
2598
        return section;
2599
    }
2600

    
2601
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2602
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2603
        addAndAdaptSection(parentElement, section);
2604
        return section;
2605
    }
2606

    
2607
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2608
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2609
        addAndAdaptSection(parentElement, section);
2610
        return section;
2611
    }
2612

    
2613
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2614
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2615
        addAndAdaptSection(parentElement, section);
2616
        return section;
2617
    }
2618

    
2619
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2620
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2621
        addAndAdaptSection(parentElement, section);
2622
        return section;
2623
    }
2624

    
2625
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2626
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2627
        addAndAdaptSection(parentElement, section);
2628
        return section;
2629
    }
2630

    
2631
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2632
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2633
        addAndAdaptSection(parentElement, section);
2634
        return section;
2635
    }
2636

    
2637
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2638
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2639
        addAndAdaptSection(parentElement, section);
2640
        return section;
2641
    }
2642

    
2643

    
2644
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2645
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2646
        AbstractEntityCollectionElement element = null;
2647

    
2648
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2649

    
2650
        if (entity instanceof Annotation) {
2651
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2652
        }else if (entity instanceof Person ) {
2653
            boolean isNomenclatural = false;
2654
            if (parentElement instanceof TeamMemberSection){
2655
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2656
            }
2657
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2658
        } else if (entity instanceof Credit) {
2659
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2660
        } else if (entity instanceof Extension) {
2661
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2662
        } else if (entity instanceof Marker) {
2663
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2664
        } else if (entity instanceof TaxonNodeAgentRelation) {
2665
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2666
        }else if (entity instanceof Media) {
2667
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2668
        } else if (entity instanceof MediaRepresentation) {
2669
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2670
                    style);
2671
        } else if (entity instanceof ImageFile) {
2672
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2673
        } else if (entity instanceof MediaRepresentationPart) {
2674
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2675
                    removeListener, style);
2676
        } else if (entity instanceof NomenclaturalStatus) {
2677
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2678
                    style);
2679
        } else if (entity instanceof Rights) {
2680
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2681
        } else if (entity instanceof DescriptionElementSource) {
2682
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2683
                    removeListener, style);
2684
        } else if (entity instanceof TaxonNodeAgentRelation) {
2685
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2686
                    removeListener,backgroundColor, style);
2687
        }
2688
        else if (entity instanceof IdentifiableSource) {
2689
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2690
                    style);
2691
        } else if (entity instanceof DefinedTerm) {
2692
            switch(((DefinedTerm)entity).getTermType()) {
2693
            case Scope:
2694
                element = new ScopeElement(this,
2695
                        parentElement,
2696
                        (DefinedTerm) entity,
2697
                        removeListener,
2698
                        style);
2699
                break;
2700
            case Modifier:
2701
                element = new ModifierElement(this,
2702
                        parentElement,
2703
                        (DefinedTerm) entity,
2704
                        removeListener,
2705
                        style);
2706
                break;
2707
            default:
2708
                break;
2709

    
2710
            }
2711
        } else if (entity instanceof Reference) {
2712
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2713
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2714
            }
2715
            else{
2716
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2717
            }
2718
        } else if (entity instanceof NameTypeDesignation) {
2719
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2720
                    style);
2721
        } else if (entity instanceof NameRelationship) {
2722
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2723
                    style);
2724
        } else if (entity instanceof SpecimenTypeDesignation) {
2725
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
2726
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2727
                        removeListener, style);
2728
            }
2729
            else{
2730
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2731
                        removeListener, style);
2732
            }
2733
        } else if (entity instanceof StateData) {
2734
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2735
        } else if (entity instanceof StatisticalMeasurementValue) {
2736
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2737
                    removeListener, style);
2738
        } else if (entity instanceof DerivedUnit) {
2739
            switch(((DerivedUnit)entity).getRecordBasis()) {
2740
            case LivingSpecimen:
2741
            case PreservedSpecimen:
2742
            case OtherSpecimen:
2743
                element = new SpecimenCollectionDetailElement(this,
2744
                        parentElement,
2745
                        (DerivedUnit) entity,
2746
                        removeListener,
2747
                        style);
2748
                break;
2749
            default:
2750
                element = new DerivedUnitElement(this,
2751
                        parentElement,
2752
                        (DerivedUnit) entity,
2753
                        removeListener,
2754
                        style);
2755
            }
2756

    
2757
        } else if (entity instanceof NamedArea) {
2758
            element = new CollectingAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2759
        } else if (entity instanceof DeterminationEvent) {
2760
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2761
        } else if (entity instanceof User) {
2762
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2763
        } else if (entity instanceof GrantedAuthority) {
2764
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
2765
                    removeListener, style);
2766
        } else if (entity instanceof Group) {
2767
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2768
        } else if (entity instanceof Taxon) {
2769
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2770
        } else if (entity instanceof DescriptionElementBase) {
2771
            // this is the special case for protologs, maybe we can do this
2772
            // differently when API improves
2773
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2774
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2775
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2776
            }
2777
        } else if (entity instanceof Identifier) {
2778
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2779
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2780
            }
2781
            else{
2782
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
2783
            }
2784
        } else if (entity instanceof TermVocabulary) {
2785
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
2786
            switch (termVocabulary.getTermType()) {
2787
            case State:
2788
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
2789
                break;
2790
            case Modifier:
2791
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
2792
                break;
2793
            default:
2794
                break;
2795
            }
2796
        } else if (entity instanceof MeasurementUnit) {
2797
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2798
        } else if (entity instanceof StatisticalMeasure) {
2799
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2800
        } else if (entity instanceof State && parentElement instanceof InapplicableIfEntityCollectionSection) {
2801
            element = new InapplicableIfCollectionElement(this, parentElement, (State) entity, removeListener, backgroundColor, style);
2802
        } else if (entity instanceof State && parentElement instanceof OnlyApplicableIfEntityCollectionSection) {
2803
            element = new OnlyApplicableIfCollectionElement(this, parentElement, (State) entity, removeListener, backgroundColor, style);
2804
        }
2805

    
2806
        //check for parent section when entity is null
2807
        //this happens when AbstractUnboundEntityCollectionSection is used
2808
        if(entity==null){
2809
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
2810
                element = new ScopeElement(this,
2811
                        parentElement,
2812
                        (DefinedTerm) entity,
2813
                        removeListener,
2814
                        style);
2815
            }
2816
            else if(parentElement instanceof ModifierSection){
2817
                element = new ModifierElement(this,
2818
                        parentElement,
2819
                        (DefinedTerm) entity,
2820
                        removeListener,
2821
                        style);
2822
            }
2823
        }
2824

    
2825

    
2826
        if (element == null) {
2827
            MessagingUtils.messageDialog("No element for entity", this,
2828
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2829
                            + entity, null);
2830
        }
2831

    
2832
        else{
2833
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2834
                element.setPersistentBackground(backgroundColor);
2835
            }
2836
            adapt(element);
2837
            parentElement.addElement(element);
2838
        }
2839

    
2840
        return element;
2841
    }
2842

    
2843
    /**
2844
     * <p>
2845
     * Creates a selection element for the given type T.
2846
     * </p>
2847
     * <p>
2848
     * <strong>Selection elements not handled by this method:</strong>
2849
     * <ul>
2850
     * <li>{@link TaxonNodeSelectionElement} see
2851
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2852
     * </li>
2853
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2854
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2855
     * </li>
2856
     * </ul>
2857
     * </p>
2858
     *
2859
     * @param clazz
2860
     *            a {@link Class} object of the type that you want the selection
2861
     *            element to handle
2862
     * @param parentElement
2863
     *            a {@link ICdmFormElement} object.
2864
     * @param labelString
2865
     *            a {@link String} object.
2866
     * @param selectionType
2867
     * @param selection
2868
     *            a {@link ICdmBase} object.
2869
     * @param style
2870
     *            a int.
2871
     * @param conversation
2872
     *            a {@link ConversationHolder} object.
2873
     * @return a {@link EntitySelectionElement} object.
2874
     */
2875
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2876
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2877
            int style, boolean filterElement) {
2878
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
2879
                parentElement, clazz,
2880
                labelString, selection, mode, style, filterElement);
2881
        adapt(element);
2882
        parentElement.addElement(element);
2883
        return element;
2884
    }
2885

    
2886
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2887
//            ConversationHolder conversation,
2888
            ICdmFormElement parentElement, String labelString, T selection, int mode,
2889
            int style) {
2890
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
2891
                parentElement, clazz,
2892
                labelString, selection, mode, style);
2893
        adapt(element);
2894
        parentElement.addElement(element);
2895
        return element;
2896
    }
2897

    
2898
    /**
2899
     * <p>
2900
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
2901
     * </p>
2902
     * <p>
2903
     * <strong>Selection elements not handled by this method:</strong>
2904
     * <ul>
2905
     * <li>{@link TaxonNodeSelectionElement} see
2906
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2907
     * </li>
2908
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2909
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2910
     * </li>
2911
     * </ul>
2912
     * </p>
2913
     *
2914
     * @param clazz
2915
     *            a {@link Class} object of the type that you want the selection
2916
     *            element to handle
2917
     * @param parentElement
2918
     *            a {@link ICdmFormElement} object.
2919
     * @param labelString
2920
     *            a {@link String} object.
2921
     * @param selectionType
2922
     * @param selection
2923
     *            a {@link ICdmBase} object.
2924
     * @param style
2925
     *            a int.
2926
     * @param conversation
2927
     *            a {@link ConversationHolder} object.
2928
     * @return a {@link EntitySelectionElement} object.
2929
     */
2930
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
2931
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
2932
            T selection, int mode, int style) {
2933
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, //conversation,
2934
                parentElement, clazz,
2935
                labelString, selection, mode, style);
2936
        adapt(element);
2937
        parentElement.addElement(element);
2938
        return element;
2939
    }
2940

    
2941
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2942
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2943
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
2944
                parentElement,
2945
                labelString, selection, mode, style);
2946
        adapt(element);
2947
        parentElement.addElement(element);
2948
        return element;
2949
    }
2950

    
2951

    
2952

    
2953
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2954
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2955
//            int mode, int style) {
2956
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2957
//                conversation, parentElement, labelString, selection, mode, style);
2958
//        adapt(element);
2959
//        parentElement.addElement(element);
2960
//        return element;
2961
//    }
2962

    
2963
    /** {@inheritDoc} */
2964
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2965
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2966
        adapt(labelElement);
2967
        parentElement.addElement(labelElement);
2968
        return labelElement;
2969
    }
2970

    
2971
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2972
//        Label label = new Label(formElement.getLayoutComposite(), style);
2973
//        label.setText(labelText+" (yyyy-MM-dd)");
2974
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
2975
//        dateElement.initInternalController();
2976
//
2977
//        return dateElement;
2978
//    }
2979

    
2980
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
2981
    	 Label label = new Label(formElement.getLayoutComposite(), style);
2982
         label.setText(labelText);
2983
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2984
         DateElement dateElement = new DateElement(this, formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
2985
         dateElement.initController(this, formElement);
2986
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2987
         return dateElement;
2988
    }
2989

    
2990
    /**
2991
     * <p>
2992
     * Getter for the field <code>selectionProvider</code>.
2993
     * </p>
2994
     *
2995
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2996
     */
2997
    public ISelectionProvider getSelectionProvider() {
2998
        return selectionProvider;
2999
    }
3000

    
3001
    /**
3002
     * <p>
3003
     * createDetailedDescriptionDetailElement
3004
     * </p>
3005
     *
3006
     * @param parentElement
3007
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3008
     *            object.
3009
     * @param entity
3010
     *            a
3011
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
3012
     *            object.
3013
     * @param style
3014
     *            a int.
3015
     * @return a
3016
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
3017
     *         object.
3018
     */
3019
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
3020
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
3021
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
3022

    
3023
        if (entity instanceof CategoricalData) {
3024
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
3025
                    (CategoricalData) entity, style);
3026
        } else if (entity instanceof CommonTaxonName) {
3027
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
3028
                    style);
3029
        } else if (entity instanceof Distribution && !enabled) {
3030
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3031
                    enabled, style);
3032
        } else if (entity instanceof Distribution) {
3033
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3034
                    true, style);
3035
        }else if (entity instanceof IndividualsAssociation) {
3036
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
3037
                    (IndividualsAssociation) entity, style);
3038
        } else if (entity instanceof QuantitativeData) {
3039
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
3040
                    (QuantitativeData) entity, style);
3041
        } else if (entity instanceof TaxonInteraction) {
3042
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
3043
                    (TaxonInteraction) entity, style);
3044
        } else if (entity instanceof TextData) {
3045
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
3046
        } else {
3047
            throw new IllegalStateException("There is no interface for the given description element");
3048
        }
3049
        adapt(detailedDescriptionElement);
3050
        parentElement.addElement(detailedDescriptionElement);
3051
        return detailedDescriptionElement;
3052

    
3053
    }
3054

    
3055
    /**
3056
     * Creates a styled text as a part of the form.
3057
     *
3058
     * @param parent
3059
     *            the text parent
3060
     * @param value
3061
     *            the text initial value
3062
     * @param style
3063
     *            the text style
3064
     * @return the text widget
3065
     */
3066
    public StyledText createStyledText(Composite parent, String value, int style) {
3067
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3068
        if (value != null) {
3069
            text.setText(value);
3070
        }
3071
        text.setForeground(getColors().getForeground());
3072
        text.setBackground(getColors().getBackground());
3073
        // text.addFocusListener(visibilityHandler);
3074
        return text;
3075
    }
3076

    
3077
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3078
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3079
        addAndAdaptSection(parentElement, section);
3080
        return section;
3081
    }
3082

    
3083
    /**
3084
     * @param formElement
3085
     * @param conversationHolder
3086
     * @param style
3087
     * @return
3088
     */
3089
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3090
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3091
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3092
        addAndAdaptSection(formElement, section);
3093
        return section;
3094
    }
3095

    
3096

    
3097
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3098
			ICdmFormElement parentElement, int style) {
3099
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3100
		addAndAdaptElement(parentElement, section);
3101
        return section;
3102
	}
3103

    
3104
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3105
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3106
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3107
	        addAndAdaptSection(formElement, section);
3108
	        return section;
3109
	}
3110

    
3111

    
3112

    
3113
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3114
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3115
//				 initialText, textHeight, style);
3116
//	        adapt(element);
3117
//	        parentElement.addElement(element);
3118
//	        return element;
3119
//	}
3120

    
3121

    
3122

    
3123

    
3124

    
3125

    
3126

    
3127
}
(7-7/45)