Project

General

Profile

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

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

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

    
349
    private BoldFontHolder2 boldFontHolder2;
350
    private MouseListener selectionMouseHandler;
351
    private FocusListener selectionFocusHandler;
352

    
353
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
354

    
355
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
356

    
357
    private final int orientation = Window.getDefaultOrientation();
358
    private ISelectionProvider selectionProvider;
359

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

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

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

    
394
    private void notifySelectionListeners(TypedEvent e) {
395
        Event event = new Event();
396
        event.widget = e.widget;
397
        SelectionEvent selectionEvent = new SelectionEvent(event);
398

    
399
        for (SelectionListener listener : selectionListenerList) {
400
            listener.widgetSelected(selectionEvent);
401
        }
402
    }
403

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

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

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

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

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

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

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

    
506
    /** {@inheritDoc} */
507
    @Override
508
    public void adapt(Composite composite) {
509
        composite.addMouseListener(selectionMouseHandler);
510
        super.adapt(composite);
511
    }
512

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

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

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

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

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

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

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

    
700
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
701
            KeyStatement keyStatement, int textHeight, int style) {
702
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
703
                textHeight, style);
704
        adapt(element);
705
        parentElement.addElement(element);
706
        return element;
707
    }
708

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

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

    
769
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
770
                textLimit, style);
771
        adapt(element);
772
        parentElement.addElement(element);
773
        return element;
774
    }
775

    
776
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
777
            int textHeight, int style) {
778
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
779
        adapt(element);
780
        parentElement.addElement(element);
781
        return element;
782
    }
783

    
784
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
785
            LSID initialLsid, int style) {
786
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
787
        adapt(element);
788
        parentElement.addElement(element);
789
        return element;
790
    }
791

    
792
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
793
            URI initialUri, int style) {
794
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
795
        adapt(element);
796
        parentElement.addElement(element);
797
        return element;
798
    }
799

    
800
    /**
801
     * @param element
802
     * @param string
803
     * @param uri
804
     * @param style
805
     * @return
806
     */
807
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
808
            IOpenUrlEnabled openUrlEnabled, int style) {
809
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
810
                style);
811
        adapt(element);
812
        parentElement.addElement(element);
813
        return element;
814
    }
815

    
816
    /**
817
     *
818
     * @param parentElement
819
     * @param labelString
820
     * @param conversationEnabled
821
     * @param user
822
     * @param style
823
     * @return
824
     */
825
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
826
            ConversationHolder conversation, User user, int style) {
827
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
828
        adapt(element);
829
        parentElement.addElement(element);
830
        return element;
831
    }
832

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

    
861
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
862
            String labelString, LanguageString languageString, int style) {
863
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
864
    }
865

    
866
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
867
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
868
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
869
                languageString, height, isMultiLine, style);
870
        adapt(element);
871
        parentElement.addElement(element);
872
        return element;
873
    }
874

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

    
911
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
912
            TermType termType,
913
            ICdmFormElement parentElement,
914
            String labelString,
915
            T selection,
916
            int style) {
917
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false);
918
    }
919

    
920
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
921
			TermType termType,
922
			ICdmFormElement parentElement,
923
			String labelString,
924
			T selection,
925
			boolean addEmptyElement,
926
			int style) {
927
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, false);
928
	}
929
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
930
			TermType termType,
931
			ICdmFormElement parentElement,
932
			String labelString,
933
			T selection,
934
			boolean addEmptyElement,
935
			int style,
936
			boolean useAbbrevLabel) {
937
		return createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel);
938
	}
939

    
940

    
941
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
942
            TermVocabulary<?> termVocabulary,
943
            ICdmFormElement parentElement,
944
            String labelString,
945
            T selection,
946
            int style) {
947
        return this.createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, true, style, false);
948
    }
949

    
950
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
951
	        TermVocabulary<?> termVocabulary,
952
	        ICdmFormElement parentElement,
953
	        String labelString,
954
	        T selection,
955
	        boolean addEmptyElement,
956
	        int style,
957
	        boolean useAbbrevLabel) {
958
	    return createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel);
959
	}
960

    
961
	private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
962
	        TermType termType,
963
	        TermVocabulary<?> termVocabulary,
964
	        ICdmFormElement parentElement,
965
	        String labelString,
966
	        T selection,
967
	        boolean addEmptyElement,
968
	        int style,
969
	        boolean useAbbrevLabel) {
970
	    if(termType!=null){
971
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel);
972
	        adapt(element);
973
	        parentElement.addElement(element);
974
	        return element;
975
	    }
976
	    else if(termVocabulary!=null){
977
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style, useAbbrevLabel);
978
	        adapt(element);
979
	        parentElement.addElement(element);
980
	        return element;
981
	    }
982
	    else{
983
	        //this should never happen
984
	        return null;
985
	    }
986
	}
987

    
988
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
989
	        Class<T> enumComboType, ICdmFormElement parentElement,
990
	        int style) {
991
	    return createEnumComboElement(enumComboType, parentElement, null, style);
992
	}
993

    
994
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
995
			Class<T> enumComboType, ICdmFormElement parentElement, Comparator<T> comparator,
996
			int style) {
997
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, comparator, style);
998
        adapt(element);
999
        parentElement.addElement(element);
1000
        return element;
1001
    }
1002

    
1003
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
1004
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
1005
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1006
	    adapt(element);
1007
	    parentElement.addElement(element);
1008
	    return element;
1009
	}
1010

    
1011
    /**
1012
     * <p>
1013
     * createBrowserElement
1014
     * </p>
1015
     *
1016
     * @param imageUri
1017
     *            a {@link java.net.URI} object.
1018
     * @param style
1019
     *            a int.
1020
     * @param parentElement
1021
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1022
     *            object.
1023
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
1024
     *         object.
1025
     */
1026
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
1027
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
1028
        adapt(element);
1029
        parentElement.addElement(element);
1030
        return element;
1031
    }
1032

    
1033
    /**
1034
     * <p>
1035
     * createImageElement
1036
     * </p>
1037
     *
1038
     * @param parentElement
1039
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1040
     *            object.
1041
     * @param imageUri
1042
     *            a {@link java.net.URI} object.
1043
     * @param style
1044
     *            a int.
1045
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1046
     */
1047
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1048
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1049
        adapt(element);
1050
        parentElement.addElement(element);
1051
        return element;
1052
    }
1053

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

    
1082
    /**
1083
     * <p>
1084
     * createCheckbox
1085
     * </p>
1086
     *
1087
     * @param parentElement
1088
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1089
     *            object.
1090
     * @param label
1091
     *            a {@link java.lang.String} object.
1092
     * @param initialState
1093
     *            a boolean.
1094
     * @param style
1095
     *            a int.
1096
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1097
     *         object.
1098
     */
1099
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1100
        if(initialState==null){
1101
            initialState = Boolean.FALSE;
1102
        }
1103
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1104
        adapt(element);
1105
        parentElement.addElement(element);
1106
        return element;
1107
    }
1108

    
1109
    /**
1110
     * Creates a section as a part of the form.
1111
     *
1112
     * @return the section widget
1113
     * @param section
1114
     *            a
1115
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1116
     *            object.
1117
     */
1118
    public Section adapt(AbstractFormSection section) {
1119
        section.setMenu(section.getLayoutComposite().getMenu());
1120
        adapt(section, true, true);
1121

    
1122
        // handle focus and property change events for cdm use
1123
        section.addFocusListener(selectionFocusHandler);
1124
        section.setPropertyChangeListeners(propertyChangeListeners);
1125

    
1126
        if (section.getToggle() != null) {
1127
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1128
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1129
        }
1130

    
1131
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1132

    
1133
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1134
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1135
            getColors().initializeSectionToolBarColors();
1136
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1137
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1138
        }
1139
        // call setTitleBarForeground regardless as it also sets the label color
1140
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1141
        return section;
1142
    }
1143

    
1144
    private class BoldFontHolder2 {
1145
        private Font normalFont;
1146

    
1147
        private Font boldFont;
1148

    
1149
        public BoldFontHolder2() {
1150
        }
1151

    
1152
        public Font getBoldFont(Font font) {
1153
            createBoldFont(font);
1154
            return boldFont;
1155
        }
1156

    
1157
        private void createBoldFont(Font font) {
1158
            if (normalFont == null || !normalFont.equals(font)) {
1159
                normalFont = font;
1160
                dispose();
1161
            }
1162
            if (boldFont == null) {
1163
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1164
            }
1165
        }
1166

    
1167
        public void dispose() {
1168
            if (boldFont != null) {
1169
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1170
                boldFont = null;
1171
            }
1172
        }
1173
    }
1174

    
1175
    /**
1176
     * <p>
1177
     * createToggleableTextField
1178
     * </p>
1179
     *
1180
     * @param parentElement
1181
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1182
     *            object.
1183
     * @param labelString
1184
     *            a {@link java.lang.String} object.
1185
     * @param initialText
1186
     *            a {@link java.lang.String} object.
1187
     * @param initialState
1188
     *            a boolean.
1189
     * @param style
1190
     *            a int.
1191
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1192
     *         object.
1193
     */
1194
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1195
            String initialText, boolean initialState, int style) {
1196
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1197
                initialState, style | orientation);
1198
        adapt(element);
1199
        parentElement.addElement(element);
1200
        return element;
1201
    }
1202

    
1203
    /**
1204
     * <p>
1205
     * createTimePeriodElement
1206
     * </p>
1207
     *
1208
     * @param parentElement
1209
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1210
     *            object.
1211
     * @param labelString
1212
     *            a {@link java.lang.String} object.
1213
     * @param timePeriod
1214
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1215
     * @param style
1216
     *            a int.
1217
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1218
     *         object.
1219
     */
1220
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1221
            TimePeriod timePeriod, int style) {
1222
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1223
        adapt(element);
1224
        parentElement.addElement(element);
1225
        return element;
1226
    }
1227

    
1228
	/**
1229
	 * <p>
1230
	 * createGatheringEventUnitElement
1231
	 * </p>
1232
	 *
1233
	 * @param parentElement
1234
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1235
	 *            object.
1236
	 * @param labelString
1237
	 *            a {@link java.lang.String} object.
1238
	 * @param timePeriod
1239
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1240
	 * @param style
1241
	 *            a int.
1242
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1243
	 *         object.
1244
	 */
1245
	public GatheringEventUnitElement createGatheringEventUnitElement(
1246
			ICdmFormElement parentElement,
1247
			String labelString,
1248
			DerivedUnitFacade gatheringEvent,
1249
			MinMaxTextSection.UnitType unitType,
1250
			int style) {
1251
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1252
				parentElement,
1253
				labelString,
1254
				gatheringEvent,
1255
				unitType,
1256
				style);
1257
		adapt(element);
1258
		parentElement.addElement(element);
1259
		return element;
1260
	}
1261

    
1262
    /**
1263
     * <p>
1264
     * createPointElement
1265
     * </p>
1266
     *
1267
     * @param style
1268
     *            a int.
1269
     * @param parentElement
1270
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1271
     *            object.
1272
     * @param point
1273
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1274
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1275
     */
1276
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1277
        PointElement element = new PointElement(this, parentElement, point, style);
1278
        adapt(element);
1279
        parentElement.addElement(element);
1280
        return element;
1281
    }
1282

    
1283

    
1284

    
1285
    /**
1286
     * @param conversationHolder
1287
     * @param parent
1288
     * @param detailsViewer
1289
     * @param i
1290
     * @return
1291
     */
1292
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1293
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1294
        parentElement.addElement(section);
1295
        adapt(section);
1296
        return section;
1297
    }
1298

    
1299
    /**
1300
     * <p>
1301
     * createDateDetailSection
1302
     * </p>
1303
     *
1304
     * @param parentElement
1305
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1306
     *            object.
1307
     * @param style
1308
     *            a int.
1309
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1310
     *         object.
1311
     */
1312
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1313
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1314
        parentElement.addElement(section);
1315
        adapt(section);
1316
        return section;
1317
    }
1318

    
1319
	/**
1320
	 * <p>
1321
	 * createDateDetailSection
1322
	 * </p>
1323
	 *
1324
	 * @param parentElement
1325
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1326
	 *            object.
1327
	 * @param style
1328
	 *            a int.
1329
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1330
	 *         object.
1331
	 */
1332
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1333
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1334
		parentElement.addElement(section);
1335
		adapt(section);
1336
		return section;
1337
	}
1338

    
1339
    /**
1340
     * <p>
1341
     * createPartialElement
1342
     * </p>
1343
     *
1344
     * @param parentElement
1345
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1346
     *            object.
1347
     * @param labelString
1348
     *            a {@link java.lang.String} object.
1349
     * @param partial
1350
     *            a {@link org.joda.time.Partial} object.
1351
     * @param style
1352
     *            a int.
1353
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1354
     *         object.
1355
     */
1356
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1357
            int style) {
1358
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1359
        adapt(element);
1360
        parentElement.addElement(element);
1361
        return element;
1362
    }
1363

    
1364
    /**
1365
     * <p>
1366
     * addSelectionListener
1367
     * </p>
1368
     *
1369
     * @param listener
1370
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1371
     */
1372
    public void addSelectionListener(SelectionListener listener) {
1373
        selectionListenerList.add(listener);
1374
    }
1375

    
1376
    /**
1377
     * <p>
1378
     * removeSelectionListener
1379
     * </p>
1380
     *
1381
     * @param listener
1382
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1383
     */
1384
    public void removeSelectionListener(SelectionListener listener) {
1385
        if (listener == null) {
1386
            MessagingUtils.error(this.getClass(),
1387
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1388
        } else {
1389
            selectionListenerList.remove(listener);
1390
        }
1391
    }
1392

    
1393
    /**
1394
     * <p>
1395
     * addPropertyChangeListener
1396
     * </p>
1397
     *
1398
     * @param listener
1399
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1400
     *            object.
1401
     */
1402
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1403
        if (propertyChangeListeners.contains(listener)) {
1404
            return;
1405
        }
1406
        propertyChangeListeners.add(0, listener);
1407
    }
1408

    
1409
    /**
1410
     * <p>
1411
     * removePropertyChangeListener
1412
     * </p>
1413
     *
1414
     * @param listener
1415
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1416
     *            object.
1417
     */
1418
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1419
        propertyChangeListeners.remove(listener);
1420
    }
1421

    
1422
    /**
1423
     * @return the propertyChangeListeners
1424
     */
1425
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1426
        return propertyChangeListeners;
1427
    }
1428

    
1429
    /**
1430
     * <p>
1431
     * createHorizontalSeparator
1432
     * </p>
1433
     *
1434
     * @param parentElement
1435
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1436
     *            object.
1437
     * @param style
1438
     *            a int.
1439
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1440
     */
1441
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1442
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1443
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1444
        return separator;
1445
    }
1446

    
1447
    /**
1448
     * <p>
1449
     * createVersionElement
1450
     * </p>
1451
     *
1452
     * @param parentElement
1453
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1454
     *            object.
1455
     * @param entity
1456
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1457
     *            object.
1458
     * @param style
1459
     *            a int.
1460
     * @return a
1461
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1462
     *         object.
1463
     */
1464
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1465
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1466
        adapt(element);
1467
        parentElement.addElement(element);
1468
        return element;
1469
    }
1470

    
1471
    /**
1472
     * @param cdmBaseSection
1473
     * @param object
1474
     * @param style
1475
     * @return
1476
     */
1477
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1478
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1479
        adapt(element);
1480
        parentElement.addElement(element);
1481
        return element;
1482
    }
1483

    
1484
    /**
1485
     * <p>
1486
     * createVersionSection
1487
     * </p>
1488
     *
1489
     * @param parentElement
1490
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1491
     *            object.
1492
     * @param style
1493
     *            a int.
1494
     * @return a
1495
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1496
     *         object.
1497
     */
1498
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1499
        VersionSection section = new VersionSection(this, parentElement, style);
1500
        parentElement.addElement(section);
1501
        adapt(section);
1502
        return section;
1503
    }
1504

    
1505
    /**
1506
     * @param parent
1507
     * @param i
1508
     * @return
1509
     */
1510
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1511
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1512
        parentElement.addElement(section);
1513
        adapt(section);
1514
        return section;
1515
    }
1516

    
1517
    /**
1518
     * <p>
1519
     * createEmptyElement
1520
     * </p>
1521
     *
1522
     * @param parentElement
1523
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1524
     *            object.
1525
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1526
     */
1527
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1528
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1529
        adapt(element);
1530
        parentElement.addElement(element);
1531
        return element;
1532
    }
1533

    
1534
    /**
1535
     * <p>
1536
     * createHeadlineSection
1537
     * </p>
1538
     *
1539
     * @param parentElement
1540
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1541
     *            object.
1542
     * @return a
1543
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1544
     *         object.
1545
     */
1546
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1547
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1548
        parentElement.addElement(section);
1549
        adapt(section);
1550
        return section;
1551
    }
1552

    
1553
    /**
1554
     * <p>
1555
     * createParsingMessageElement
1556
     * </p>
1557
     *
1558
     * @param parentElement
1559
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1560
     *            object.
1561
     * @param parserProblem
1562
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1563
     *            object.
1564
     * @param style
1565
     *            a int.
1566
     * @return a
1567
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1568
     *         object.
1569
     */
1570
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1571
            ParserProblem parserProblem, int style) {
1572
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1573
        adapt(element);
1574
        parentElement.addElement(element);
1575
        return element;
1576
    }
1577

    
1578
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1579
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1580

    
1581
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1582
                selectionProvider, style);
1583

    
1584
        parentElement.addElement(section);
1585
        adapt(section);
1586
        return section;
1587

    
1588
    }
1589

    
1590
    /**
1591
     * @param definedTermClass
1592
     * @param formElement
1593
     * @param style
1594
     * @return
1595
     */
1596
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1597
            AbstractCdmDetailSection parentElement, int style) {
1598
        AbstractCdmDetailElement element = null;
1599

    
1600
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1601
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1602
        } else if (definedTermClass.equals(Feature.class)) {
1603
            element = new FeatureDetailElement(this, parentElement);
1604
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1605
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1606
        } else {
1607
            element = new DefinedTermDetailElement(this, parentElement);
1608
        }
1609

    
1610

    
1611
        adapt(element);
1612
        parentElement.addElement(element);
1613
        return element;
1614
    }
1615

    
1616

    
1617
    //--------DetailSections---------
1618
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1619
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1620
        addAndAdaptSection(parentElement, section);
1621
        return section;
1622
    }
1623

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

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

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

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

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

    
1654
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1655
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1656
        addAndAdaptSection(parentElement, section);
1657
        return section;
1658
    }
1659

    
1660
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1661
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1662
        addAndAdaptSection(parentElement, section);
1663
        return section;
1664
    }
1665

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

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

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

    
1684

    
1685

    
1686
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, boolean nameChoosable, int style){
1687
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, nameChoosable, style);
1688
        addAndAdaptSection(parentElement, section);
1689
        return section;
1690
    }
1691

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1830
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1831
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
1832
        addAndAdaptSection(parentElement, section);
1833
        return section;
1834
    }
1835

    
1836
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1837
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
1838
        addAndAdaptSection(parentElement, section);
1839
        return section;
1840
    }
1841

    
1842
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1843
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1844
        addAndAdaptSection(parentElement, section);
1845
        return section;
1846
    }
1847

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

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

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

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

    
1872
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1873
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1874
        addAndAdaptSection(parentElement, section);
1875
        return section;
1876
    }
1877

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

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

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

    
1896
    public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1897
        GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
1898
        addAndAdaptSection(parentElement, section);
1899
        return section;
1900
    }
1901

    
1902
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1903
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1904
        addAndAdaptSection(parentElement, section);
1905
        return section;
1906
    }
1907

    
1908
    public SampleDesignationDetailSection createSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1909
        SampleDesignationDetailSection section = new SampleDesignationDetailSection(this, conversation, parentElement, selectionProvider, style);
1910
        addAndAdaptSection(parentElement, section);
1911
        return section;
1912
    }
1913

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

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

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

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

    
1938
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1939
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
1940
        addAndAdaptSection(parentElement, section);
1941
        return section;
1942
    }
1943

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

    
1950
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1951
        parentElement.addElement(section);
1952
        adapt(section);
1953
    }
1954

    
1955
    //--------DetailElements------------
1956

    
1957
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1958
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1959
        addAndAdaptElement(parentElement, element);
1960
        return element;
1961
    }
1962

    
1963
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1964
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1965
        addAndAdaptElement(parentElement, element);
1966
        return element;
1967
    }
1968

    
1969
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1970
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1971
        addAndAdaptElement(parentElement, element);
1972
        return element;
1973
    }
1974

    
1975
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1976
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1977
        addAndAdaptElement(parentElement, element);
1978
        return element;
1979
    }
1980

    
1981
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1982
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1983
        addAndAdaptElement(parentElement, element);
1984
        return element;
1985
    }
1986

    
1987
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1988
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1989
        addAndAdaptElement(parentElement, element);
1990
        return element;
1991
    }
1992

    
1993
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1994
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
1995
        addAndAdaptElement(parentElement, element);
1996
        return element;
1997
    }
1998

    
1999
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2000
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2001
        addAndAdaptElement(parentElement, element);
2002
        return element;
2003
    }
2004

    
2005
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2006
        UserDetailElement element = new UserDetailElement(this, parentElement);
2007
        addAndAdaptElement(parentElement, element);
2008
        return element;
2009
    }
2010

    
2011
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2012
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2013
        addAndAdaptElement(parentElement, element);
2014
        return element;
2015
    }
2016

    
2017
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2018
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2019
        addAndAdaptElement(parentElement, element);
2020
        return element;
2021
    }
2022

    
2023
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2024
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2025
        addAndAdaptElement(parentElement, element);
2026
        return element;
2027
    }
2028

    
2029
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2030
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2031
        addAndAdaptElement(parentElement, element);
2032
        return element;
2033
    }
2034

    
2035
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2036
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2037
        addAndAdaptElement(parentElement, element);
2038
        return element;
2039
    }
2040

    
2041
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2042
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2043
        adapt(element);
2044
        parentElement.addElement(element);
2045

    
2046
        return element;
2047
    }
2048

    
2049
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2050
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2051
        addAndAdaptElement(parentElement, element);
2052
        return element;
2053
    }
2054

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

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

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

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

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

    
2085
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2086
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2087
        addAndAdaptElement(parentElement, element);
2088
        return element;
2089
    }
2090

    
2091
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2092
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2093
        addAndAdaptElement(parentElement, element);
2094
        return element;
2095
    }
2096

    
2097
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2098
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2099
        addAndAdaptElement(parentElement, element);
2100
        return element;
2101
    }
2102

    
2103
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2104
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2105
        addAndAdaptElement(parentElement, element);
2106
        return element;
2107
    }
2108

    
2109
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2110
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2111
        addAndAdaptElement(parentElement, element);
2112
        return element;
2113
    }
2114

    
2115
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2116
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2117
        addAndAdaptElement(parentElement, element);
2118
        return element;
2119
    }
2120

    
2121
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2122
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2123
        addAndAdaptElement(parentElement, element);
2124
        return element;
2125
    }
2126

    
2127
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2128
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2129
        addAndAdaptElement(parentElement, element);
2130
        return element;
2131
    }
2132

    
2133
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2134
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2135
        addAndAdaptElement(parentElement, element);
2136
        return element;
2137
    }
2138

    
2139

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

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

    
2152
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2153
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2154
        addAndAdaptElement(parentElement, element);
2155
        return element;
2156
    }
2157

    
2158
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2159
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2160
        addAndAdaptElement(parentElement, element);
2161
        return element;
2162
    }
2163

    
2164
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2165
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2166
        addAndAdaptElement(parentElement, element);
2167
        return element;
2168
    }
2169

    
2170
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2171
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2172
        addAndAdaptElement(parentElement, element);
2173
        return element;
2174
    }
2175

    
2176
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2177
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2178
        addAndAdaptElement(parentElement, element);
2179
        return element;
2180
    }
2181

    
2182
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2183
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2184
        addAndAdaptElement(parentElement, element);
2185
        return element;
2186
    }
2187

    
2188
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2189
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2190
        addAndAdaptElement(parentElement, element);
2191
        return element;
2192
    }
2193

    
2194
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2195
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2196
        addAndAdaptElement(parentElement, element);
2197
        return element;
2198
    }
2199

    
2200
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2201
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2202
        addAndAdaptElement(parentElement, element);
2203
        return element;
2204
    }
2205

    
2206
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2207
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2208
        addAndAdaptElement(parentElement, element);
2209
        return element;
2210
    }
2211

    
2212
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2213
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2214
        addAndAdaptElement(parentElement, element);
2215
        return element;
2216
    }
2217

    
2218
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2219
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2220
        addAndAdaptElement(parentElement, element);
2221
        return element;
2222
    }
2223

    
2224
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2225
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2226
        addAndAdaptElement(parentElement, element);
2227
        return element;
2228
    }
2229

    
2230
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2231
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2232
        addAndAdaptElement(parentElement, element);
2233
        return element;
2234
    }
2235

    
2236
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2237
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2238
        addAndAdaptElement(parentElement, mediaDetailElement);
2239
        return mediaDetailElement;
2240
    }
2241

    
2242
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2243
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2244
        addAndAdaptElement(parentElement, element);
2245
        return element;
2246
    }
2247

    
2248
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2249
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2250
        addAndAdaptElement(parentElement, element);
2251
        return element;
2252
    }
2253

    
2254
    public SpecimenHierarchyDetailElement createSpecimenHierarchyDetailElement(ICdmFormElement parentElement) {
2255
        SpecimenHierarchyDetailElement element = new SpecimenHierarchyDetailElement(this, parentElement);
2256
        addAndAdaptElement(parentElement, element);
2257
        return element;
2258
    }
2259

    
2260
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2261
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2262
        addAndAdaptElement(parentElement, element);
2263
        return element;
2264
    }
2265

    
2266
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2267
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2268
        addAndAdaptElement(parentElement, element);
2269
        return element;
2270
    }
2271

    
2272
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2273
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2274
        addAndAdaptElement(parentElement, element);
2275
        return element;
2276
    }
2277

    
2278
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2279
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2280
        addAndAdaptElement(parentElement, element);
2281
        return element;
2282
    }
2283

    
2284
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2285
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2286
        addAndAdaptElement(parentElement, element);
2287
        return element;
2288
    }
2289

    
2290
    /**
2291
     * @param parentElement
2292
     * @param element
2293
     */
2294
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2295
        adapt(element);
2296
        parentElement.addElement(element);
2297
    }
2298

    
2299
    //--------EntityCollectionSection----------
2300
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2301
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2302
        addAndAdaptSection(parentElement, section);
2303
        return section;
2304
    }
2305

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2564

    
2565
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2566
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2567
        AbstractEntityCollectionElement element = null;
2568

    
2569
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2570

    
2571
        if (entity instanceof Annotation) {
2572
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2573
        }else if (entity instanceof Person ) {
2574
            boolean isNomenclatural = false;
2575
            if (parentElement instanceof TeamMemberSection){
2576
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2577
            }
2578
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2579
        } else if (entity instanceof Credit) {
2580
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2581
        } else if (entity instanceof Extension) {
2582
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2583
        } else if (entity instanceof Marker) {
2584
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2585
        } else if (entity instanceof TaxonNodeAgentRelation) {
2586
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2587
        }else if (entity instanceof Media) {
2588
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2589
        } else if (entity instanceof MediaRepresentation) {
2590
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2591
                    style);
2592
        } else if (entity instanceof ImageFile) {
2593
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2594
        } else if (entity instanceof MediaRepresentationPart) {
2595
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2596
                    removeListener, style);
2597
        } else if (entity instanceof NomenclaturalStatus) {
2598
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2599
                    style);
2600
        } else if (entity instanceof Rights) {
2601
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2602
        } else if (entity instanceof DescriptionElementSource) {
2603
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2604
                    removeListener, style);
2605
        } else if (entity instanceof TaxonNodeAgentRelation) {
2606
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2607
                    removeListener,backgroundColor, style);
2608
        }
2609
        else if (entity instanceof IdentifiableSource) {
2610
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2611
                    style);
2612
        } else if (entity instanceof DefinedTerm) {
2613
            switch(((DefinedTerm)entity).getTermType()) {
2614
            case Scope:
2615
                element = new ScopeElement(this,
2616
                        parentElement,
2617
                        (DefinedTerm) entity,
2618
                        removeListener,
2619
                        style);
2620
                break;
2621
            case Modifier:
2622
                element = new ModifierElement(this,
2623
                        parentElement,
2624
                        (DefinedTerm) entity,
2625
                        removeListener,
2626
                        style);
2627
                break;
2628
            default:
2629
                break;
2630

    
2631
            }
2632
        } else if (entity instanceof Reference) {
2633
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2634
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2635
            }
2636
            else{
2637
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2638
            }
2639
        } else if (entity instanceof NameTypeDesignation) {
2640
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2641
                    style);
2642
        } else if (entity instanceof NameRelationship) {
2643
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2644
                    style);
2645
        } else if (entity instanceof SpecimenTypeDesignation) {
2646
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
2647
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2648
                        removeListener, style);
2649
            }
2650
            else{
2651
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2652
                        removeListener, style);
2653
            }
2654
        } else if (entity instanceof StateData) {
2655
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2656
        } else if (entity instanceof StatisticalMeasurementValue) {
2657
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2658
                    removeListener, style);
2659
        } else if (entity instanceof DerivedUnit) {
2660
            switch(((DerivedUnit)entity).getRecordBasis()) {
2661
            case LivingSpecimen:
2662
            case PreservedSpecimen:
2663
            case OtherSpecimen:
2664
                element = new SpecimenCollectionDetailElement(this,
2665
                        parentElement,
2666
                        (DerivedUnit) entity,
2667
                        removeListener,
2668
                        style);
2669
                break;
2670
            default:
2671
                element = new DerivedUnitElement(this,
2672
                        parentElement,
2673
                        (DerivedUnit) entity,
2674
                        removeListener,
2675
                        style);
2676
            }
2677

    
2678
        } else if (entity instanceof NamedArea) {
2679
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2680
        } else if (entity instanceof DeterminationEvent) {
2681
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2682
        } else if (entity instanceof User) {
2683
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2684
        } else if (entity instanceof GrantedAuthority) {
2685
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
2686
                    removeListener, style);
2687
        } else if (entity instanceof Group) {
2688
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2689
        } else if (entity instanceof Taxon) {
2690
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2691
        } else if (entity instanceof DescriptionElementBase) {
2692
            // this is the special case for protologs, maybe we can do this
2693
            // differently when API improves
2694
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2695
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2696
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2697
            }
2698
        } else if (entity instanceof Identifier) {
2699
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2700
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2701
            }
2702
            else{
2703
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
2704
            }
2705
        } else if (entity instanceof TermVocabulary) {
2706
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
2707
            switch (termVocabulary.getTermType()) {
2708
            case State:
2709
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
2710
                break;
2711
            case Modifier:
2712
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
2713
                break;
2714
            default:
2715
                break;
2716
            }
2717
        } else if (entity instanceof MeasurementUnit) {
2718
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2719
        } else if (entity instanceof StatisticalMeasure) {
2720
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2721
        }
2722

    
2723
        //check for parent section when entity is null
2724
        //this happens when AbstractUnboundEntityCollectionSection is used
2725
        if(entity==null){
2726
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
2727
                element = new ScopeElement(this,
2728
                        parentElement,
2729
                        (DefinedTerm) entity,
2730
                        removeListener,
2731
                        style);
2732
            }
2733
            else if(parentElement instanceof ModifierSection){
2734
                element = new ModifierElement(this,
2735
                        parentElement,
2736
                        (DefinedTerm) entity,
2737
                        removeListener,
2738
                        style);
2739
            }
2740
        }
2741

    
2742

    
2743
        if (element == null) {
2744
            MessagingUtils.messageDialog("No element for entity", this,
2745
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2746
                            + entity, null);
2747
        }
2748

    
2749
        else{
2750
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2751
                element.setPersistentBackground(backgroundColor);
2752
            }
2753
            adapt(element);
2754
            parentElement.addElement(element);
2755
        }
2756

    
2757
        return element;
2758
    }
2759

    
2760
    /**
2761
     * <p>
2762
     * Creates a selection element for the given type T.
2763
     * </p>
2764
     * <p>
2765
     * <strong>Selection elements not handled by this method:</strong>
2766
     * <ul>
2767
     * <li>{@link TaxonNodeSelectionElement} see
2768
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2769
     * </li>
2770
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2771
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2772
     * </li>
2773
     * </ul>
2774
     * </p>
2775
     *
2776
     * @param clazz
2777
     *            a {@link Class} object of the type that you want the selection
2778
     *            element to handle
2779
     * @param parentElement
2780
     *            a {@link ICdmFormElement} object.
2781
     * @param labelString
2782
     *            a {@link String} object.
2783
     * @param selectionType
2784
     * @param selection
2785
     *            a {@link ICdmBase} object.
2786
     * @param style
2787
     *            a int.
2788
     * @param conversation
2789
     *            a {@link ConversationHolder} object.
2790
     * @return a {@link EntitySelectionElement} object.
2791
     */
2792
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2793
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2794
            int style, boolean filterElement) {
2795
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2796
                labelString, selection, mode, style, filterElement);
2797
        adapt(element);
2798
        parentElement.addElement(element);
2799
        return element;
2800
    }
2801

    
2802
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2803
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2804
            int style) {
2805
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2806
                labelString, selection, mode, style);
2807
        adapt(element);
2808
        parentElement.addElement(element);
2809
        return element;
2810
    }
2811

    
2812
    /**
2813
     * <p>
2814
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
2815
     * </p>
2816
     * <p>
2817
     * <strong>Selection elements not handled by this method:</strong>
2818
     * <ul>
2819
     * <li>{@link TaxonNodeSelectionElement} see
2820
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2821
     * </li>
2822
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2823
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2824
     * </li>
2825
     * </ul>
2826
     * </p>
2827
     *
2828
     * @param clazz
2829
     *            a {@link Class} object of the type that you want the selection
2830
     *            element to handle
2831
     * @param parentElement
2832
     *            a {@link ICdmFormElement} object.
2833
     * @param labelString
2834
     *            a {@link String} object.
2835
     * @param selectionType
2836
     * @param selection
2837
     *            a {@link ICdmBase} object.
2838
     * @param style
2839
     *            a int.
2840
     * @param conversation
2841
     *            a {@link ConversationHolder} object.
2842
     * @return a {@link EntitySelectionElement} object.
2843
     */
2844
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
2845
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
2846
            T selection, int mode, int style) {
2847
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, conversation, parentElement, clazz,
2848
                labelString, selection, mode, style);
2849
        adapt(element);
2850
        parentElement.addElement(element);
2851
        return element;
2852
    }
2853

    
2854
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2855
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2856
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2857
                labelString, selection, mode, style);
2858
        adapt(element);
2859
        parentElement.addElement(element);
2860
        return element;
2861
    }
2862

    
2863
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2864
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2865
//            int mode, int style) {
2866
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2867
//                conversation, parentElement, labelString, selection, mode, style);
2868
//        adapt(element);
2869
//        parentElement.addElement(element);
2870
//        return element;
2871
//    }
2872

    
2873
    /** {@inheritDoc} */
2874
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2875
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2876
        adapt(labelElement);
2877
        parentElement.addElement(labelElement);
2878
        return labelElement;
2879
    }
2880

    
2881
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2882
        Label label = new Label(formElement.getLayoutComposite(), style);
2883
        label.setText(labelText+" (yyyy-MM-dd)");
2884
        DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, style);
2885
        dateElement.initController(this, formElement);
2886
        return dateElement;
2887
    }
2888

    
2889
    /**
2890
     * <p>
2891
     * Getter for the field <code>selectionProvider</code>.
2892
     * </p>
2893
     *
2894
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2895
     */
2896
    public ISelectionProvider getSelectionProvider() {
2897
        return selectionProvider;
2898
    }
2899

    
2900
    /**
2901
     * <p>
2902
     * createDetailedDescriptionDetailElement
2903
     * </p>
2904
     *
2905
     * @param parentElement
2906
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2907
     *            object.
2908
     * @param entity
2909
     *            a
2910
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2911
     *            object.
2912
     * @param style
2913
     *            a int.
2914
     * @return a
2915
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2916
     *         object.
2917
     */
2918
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2919
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2920
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2921

    
2922
        if (entity instanceof CategoricalData) {
2923
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2924
                    (CategoricalData) entity, style);
2925
        } else if (entity instanceof CommonTaxonName) {
2926
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2927
                    style);
2928
        } else if (entity instanceof Distribution) {
2929
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2930
                    style);
2931
        } else if (entity instanceof IndividualsAssociation) {
2932
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2933
                    (IndividualsAssociation) entity, style);
2934
        } else if (entity instanceof QuantitativeData) {
2935
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2936
                    (QuantitativeData) entity, style);
2937
        } else if (entity instanceof TaxonInteraction) {
2938
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2939
                    (TaxonInteraction) entity, style);
2940
        } else if (entity instanceof TextData) {
2941
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2942
        } else {
2943
            throw new IllegalStateException("There is no interface for the given description element");
2944
        }
2945
        adapt(detailedDescriptionElement);
2946
        parentElement.addElement(detailedDescriptionElement);
2947
        return detailedDescriptionElement;
2948

    
2949
    }
2950

    
2951
    /**
2952
     * Creates a styled text as a part of the form.
2953
     *
2954
     * @param parent
2955
     *            the text parent
2956
     * @param value
2957
     *            the text initial value
2958
     * @param style
2959
     *            the text style
2960
     * @return the text widget
2961
     */
2962
    public StyledText createStyledText(Composite parent, String value, int style) {
2963
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2964
        if (value != null) {
2965
            text.setText(value);
2966
        }
2967
        text.setForeground(getColors().getForeground());
2968
        text.setBackground(getColors().getBackground());
2969
        // text.addFocusListener(visibilityHandler);
2970
        return text;
2971
    }
2972

    
2973
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2974
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2975
        addAndAdaptSection(parentElement, section);
2976
        return section;
2977
    }
2978

    
2979
    /**
2980
     * @param formElement
2981
     * @param conversationHolder
2982
     * @param style
2983
     * @return
2984
     */
2985
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
2986
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
2987
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
2988
        addAndAdaptSection(formElement, section);
2989
        return section;
2990
    }
2991

    
2992

    
2993

    
2994

    
2995

    
2996
}
(7-7/44)