Project

General

Profile

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

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

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

    
44
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
45
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
46
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
47
import eu.etaxonomy.cdm.model.agent.Person;
48
import eu.etaxonomy.cdm.model.agent.Team;
49
import eu.etaxonomy.cdm.model.common.Annotation;
50
import eu.etaxonomy.cdm.model.common.CdmBase;
51
import eu.etaxonomy.cdm.model.common.Credit;
52
import eu.etaxonomy.cdm.model.common.DefinedTerm;
53
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
54
import eu.etaxonomy.cdm.model.common.Extension;
55
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
56
import eu.etaxonomy.cdm.model.common.Group;
57
import eu.etaxonomy.cdm.model.common.ICdmBase;
58
import eu.etaxonomy.cdm.model.common.IEnumTerm;
59
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
60
import eu.etaxonomy.cdm.model.common.Identifier;
61
import eu.etaxonomy.cdm.model.common.LSID;
62
import eu.etaxonomy.cdm.model.common.Language;
63
import eu.etaxonomy.cdm.model.common.LanguageString;
64
import eu.etaxonomy.cdm.model.common.Marker;
65
import eu.etaxonomy.cdm.model.common.Representation;
66
import eu.etaxonomy.cdm.model.common.TermBase;
67
import eu.etaxonomy.cdm.model.common.TermType;
68
import eu.etaxonomy.cdm.model.common.TermVocabulary;
69
import eu.etaxonomy.cdm.model.common.TimePeriod;
70
import eu.etaxonomy.cdm.model.common.User;
71
import eu.etaxonomy.cdm.model.common.VersionableEntity;
72
import eu.etaxonomy.cdm.model.description.CategoricalData;
73
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
74
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
75
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
76
import eu.etaxonomy.cdm.model.description.Distribution;
77
import eu.etaxonomy.cdm.model.description.Feature;
78
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
79
import eu.etaxonomy.cdm.model.description.KeyStatement;
80
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
81
import eu.etaxonomy.cdm.model.description.QuantitativeData;
82
import eu.etaxonomy.cdm.model.description.State;
83
import eu.etaxonomy.cdm.model.description.StateData;
84
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
85
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
86
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
87
import eu.etaxonomy.cdm.model.description.TextData;
88
import eu.etaxonomy.cdm.model.location.NamedArea;
89
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
90
import eu.etaxonomy.cdm.model.location.Point;
91
import eu.etaxonomy.cdm.model.media.ImageFile;
92
import eu.etaxonomy.cdm.model.media.Media;
93
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
94
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
95
import eu.etaxonomy.cdm.model.media.Rights;
96
import eu.etaxonomy.cdm.model.molecular.DnaSample;
97
import eu.etaxonomy.cdm.model.name.NameRelationship;
98
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
99
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
100
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
101
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
102
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
103
import eu.etaxonomy.cdm.model.reference.Reference;
104
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
105
import eu.etaxonomy.cdm.model.taxon.Taxon;
106
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
107
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
108
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
109
import eu.etaxonomy.taxeditor.model.MessagingUtils;
110
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
111
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
112
import eu.etaxonomy.taxeditor.ui.combo.VocabularyComboElement;
113
import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection.UnitType;
114
import eu.etaxonomy.taxeditor.ui.mvc.element.DateElement;
115
import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
116
import eu.etaxonomy.taxeditor.ui.openurl.OpenUrlSelectorElement;
117
import eu.etaxonomy.taxeditor.ui.password.EditPasswordElement;
118
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
119
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
120
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
121
import eu.etaxonomy.taxeditor.ui.section.EmptyElement;
122
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement;
123
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection;
124
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailElement;
125
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
126
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailElement;
127
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
128
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
129
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberSection;
130
import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
131
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailElement;
132
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailSection;
133
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeAgentRelationCollectionElement;
134
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeAgentRelationCollectionSection;
135
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailElement;
136
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailSection;
137
import eu.etaxonomy.taxeditor.ui.section.common.ReferenceEntityDetailElement;
138
import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
139
import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
140
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
141
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailElement;
142
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
143
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
144
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
145
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
146
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceElement;
147
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
148
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceElement;
149
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
150
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
151
import eu.etaxonomy.taxeditor.ui.section.description.ModifierElement;
152
import eu.etaxonomy.taxeditor.ui.section.description.ModifierSection;
153
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageDetailElement;
154
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
155
import eu.etaxonomy.taxeditor.ui.section.description.ScopeElement;
156
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
157
import eu.etaxonomy.taxeditor.ui.section.description.StateDataElement;
158
import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;
159
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueElement;
160
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueSection;
161
import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;
162
import eu.etaxonomy.taxeditor.ui.section.description.detail.CategoricalDataDetailElement;
163
import eu.etaxonomy.taxeditor.ui.section.description.detail.CommonNameDetailElement;
164
import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
165
import eu.etaxonomy.taxeditor.ui.section.description.detail.IndividualsAssociationDetailElement;
166
import eu.etaxonomy.taxeditor.ui.section.description.detail.QuantitativeDataDetailElement;
167
import eu.etaxonomy.taxeditor.ui.section.description.detail.TaxonInteractionDetailElement;
168
import eu.etaxonomy.taxeditor.ui.section.description.detail.TextDataDetailElement;
169
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement;
170
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
171
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityCollectionElement;
172
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailElement;
173
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
174
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailElement;
175
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
176
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailElement;
177
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
178
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailElement;
179
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
180
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailElement;
181
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
182
import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
183
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
184
import eu.etaxonomy.taxeditor.ui.section.media.ImageFileElement;
185
import eu.etaxonomy.taxeditor.ui.section.media.MediaDetailElement;
186
import eu.etaxonomy.taxeditor.ui.section.media.MediaMetaElement;
187
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationElement;
188
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartElement;
189
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartSection;
190
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationSection;
191
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
192
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
193
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailSection;
194
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailElement;
195
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailSection;
196
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailElement;
197
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailSection;
198
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailElement;
199
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
200
import eu.etaxonomy.taxeditor.ui.section.name.NameTypeDesignationElement;
201
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusElement;
202
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
203
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailElement;
204
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
205
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueElement;
206
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
207
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
208
import eu.etaxonomy.taxeditor.ui.section.name.SynonymRelationshipDetailElement;
209
import eu.etaxonomy.taxeditor.ui.section.name.SynonymRelationshipDetailSection;
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.RecommendedModifierVocabulariesCollectionSection;
325
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesElement;
326
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionElement;
327
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionSection;
328
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionElement;
329
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionSection;
330
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailElement;
331
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
332
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
333
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementWithAbbreviatedTitle;
334
import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
335
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
336

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
923
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
924
			TermType termType,
925
			ICdmFormElement parentElement,
926
			String labelString,
927
			T selection,
928
			boolean addEmptyElement,
929
			int style) {
930
		TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, false);
931
		adapt(element);
932
		parentElement.addElement(element);
933
		return element;
934
	}
935
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
936
			TermType termType,
937
			ICdmFormElement parentElement,
938
			String labelString,
939
			T selection,
940
			boolean addEmptyElement,
941
			int style, boolean useAbbrevLabel) {
942
		TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel);
943
		adapt(element);
944
		parentElement.addElement(element);
945
		return element;
946
	}
947
    
948

    
949
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
950
            TermVocabulary<?> termVocabulary,
951
            ICdmFormElement parentElement,
952
            String labelString,
953
            T selection,
954
            int style) {
955
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, true, style);
956
        adapt(element);
957
        parentElement.addElement(element);
958
        return element;
959
    }
960

    
961
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
962
	        TermVocabulary<?> termVocabulary,
963
	        ICdmFormElement parentElement,
964
	        String labelString,
965
	        T selection,
966
	        boolean addEmptyElement,
967
	        int style) {
968
	    TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style);
969
	    adapt(element);
970
	    parentElement.addElement(element);
971
	    return element;
972
	}
973

    
974
    /**
975
     * <p>
976
     * createEnumComboElement
977
     * </p>
978
     *
979
     * @param enumComboType
980
     *            a
981
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType}
982
     *            object.
983
     * @param parentElement
984
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
985
     *            object.
986
     * @param style
987
     *            a int.
988
     * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
989
     *         object.
990
     */
991
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
992
			Class<T> enumComboType, ICdmFormElement parentElement,
993
			int style) {
994
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
995
        adapt(element);
996
        parentElement.addElement(element);
997
        return element;
998
    }
999

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

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

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

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

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

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

    
1119
        // handle focus and property change events for cdm use
1120
        section.addFocusListener(selectionFocusHandler);
1121
        section.setPropertyChangeListeners(propertyChangeListeners);
1122

    
1123
        if (section.getToggle() != null) {
1124
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1125
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1126
        }
1127

    
1128
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1129

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

    
1141
    private class BoldFontHolder2 {
1142
        private Font normalFont;
1143

    
1144
        private Font boldFont;
1145

    
1146
        public BoldFontHolder2() {
1147
        }
1148

    
1149
        public Font getBoldFont(Font font) {
1150
            createBoldFont(font);
1151
            return boldFont;
1152
        }
1153

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

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

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

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

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

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

    
1280

    
1281

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

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

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

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

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

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

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

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

    
1419
    /**
1420
     * @return the propertyChangeListeners
1421
     */
1422
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1423
        return propertyChangeListeners;
1424
    }
1425

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

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

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

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

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

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

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

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

    
1575
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1576
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1577

    
1578
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1579
                selectionProvider, style);
1580

    
1581
        parentElement.addElement(section);
1582
        adapt(section);
1583
        return section;
1584

    
1585
    }
1586

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

    
1597
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1598
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1599
        } else if (definedTermClass.equals(Feature.class)) {
1600
            element = new FeatureDetailElement(this, parentElement);
1601
        } else {
1602
            element = new DefinedTermDetailElement(this, parentElement);
1603
        }
1604

    
1605
        adapt(element);
1606
        parentElement.addElement(element);
1607
        return element;
1608
    }
1609

    
1610

    
1611
    //--------DetailSections---------
1612
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1613
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1614
        addAndAdaptSection(parentElement, section);
1615
        return section;
1616
    }
1617

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

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

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

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

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

    
1648
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1649
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1650
        addAndAdaptSection(parentElement, section);
1651
        return section;
1652
    }
1653

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1822
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1823
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
1824
        addAndAdaptSection(parentElement, section);
1825
        return section;
1826
    }
1827

    
1828
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1829
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
1830
        addAndAdaptSection(parentElement, section);
1831
        return section;
1832
    }
1833

    
1834
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1835
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1836
        addAndAdaptSection(parentElement, section);
1837
        return section;
1838
    }
1839

    
1840
    public SingleReadGeneralDetailSection createSingleReadGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1841
        SingleReadGeneralDetailSection section = new SingleReadGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1842
        addAndAdaptSection(parentElement, section);
1843
        return section;
1844
    }
1845

    
1846
    public AmplificationGeneralDetailSection createAmplificationGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1847
        AmplificationGeneralDetailSection section = new AmplificationGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1848
        addAndAdaptSection(parentElement, section);
1849
        return section;
1850
    }
1851

    
1852
    public AmplificationPrimerDetailSection createAmplificationPrimerDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1853
        AmplificationPrimerDetailSection section = new AmplificationPrimerDetailSection(this, conversation, parentElement, selectionProvider, style);
1854
        addAndAdaptSection(parentElement, section);
1855
        return section;
1856
    }
1857

    
1858
    public AmplificationCloningDetailSection createAmplificationCloningDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1859
        AmplificationCloningDetailSection section = new AmplificationCloningDetailSection(this, conversation, parentElement, selectionProvider, style);
1860
        addAndAdaptSection(parentElement, section);
1861
        return section;
1862
    }
1863

    
1864
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1865
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1866
        addAndAdaptSection(parentElement, section);
1867
        return section;
1868
    }
1869

    
1870
    public MediaSpecimenGeneralDetailSection createMediaSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1871
        MediaSpecimenGeneralDetailSection section = new MediaSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1872
        addAndAdaptSection(parentElement, section);
1873
        return section;
1874
    }
1875

    
1876
    public HybridDetailSection createHybridDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1877
        HybridDetailSection section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
1878
        addAndAdaptSection(parentElement, section);
1879
        return section;
1880
    }
1881

    
1882
    public UserDetailSection createUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1883
        UserDetailSection section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
1884
        addAndAdaptSection(parentElement, section);
1885
        return section;
1886
    }
1887

    
1888
    public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1889
        GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
1890
        addAndAdaptSection(parentElement, section);
1891
        return section;
1892
    }
1893

    
1894
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1895
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1896
        addAndAdaptSection(parentElement, section);
1897
        return section;
1898
    }
1899

    
1900
    public SampleDesignationDetailSection createSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1901
        SampleDesignationDetailSection section = new SampleDesignationDetailSection(this, conversation, parentElement, selectionProvider, style);
1902
        addAndAdaptSection(parentElement, section);
1903
        return section;
1904
    }
1905

    
1906
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1907
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1908
        addAndAdaptSection(parentElement, section);
1909
        return section;
1910
    }
1911

    
1912
    public ReferencedEntityDetailSection createReferencedEntityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1913
        ReferencedEntityDetailSection section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
1914
        addAndAdaptSection(parentElement, section);
1915
        return section;
1916
    }
1917

    
1918
    public TermVocabularyDetailSection createTermVocabularyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1919
        TermVocabularyDetailSection section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
1920
        addAndAdaptSection(parentElement, section);
1921
        return section;
1922
    }
1923

    
1924
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1925
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1926
        addAndAdaptSection(parentElement, section);
1927
        return section;
1928
    }
1929

    
1930
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1931
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
1932
        addAndAdaptSection(parentElement, section);
1933
        return section;
1934
    }
1935

    
1936
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1937
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
1938
        addAndAdaptSection(parentElement, section);
1939
        return section;
1940
    }
1941

    
1942
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1943
        parentElement.addElement(section);
1944
        adapt(section);
1945
    }
1946

    
1947
    //--------DetailElements------------
1948

    
1949
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1950
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1951
        addAndAdaptElement(parentElement, element);
1952
        return element;
1953
    }
1954

    
1955
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1956
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1957
        addAndAdaptElement(parentElement, element);
1958
        return element;
1959
    }
1960

    
1961
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1962
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1963
        addAndAdaptElement(parentElement, element);
1964
        return element;
1965
    }
1966

    
1967
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1968
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1969
        addAndAdaptElement(parentElement, element);
1970
        return element;
1971
    }
1972

    
1973
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1974
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1975
        addAndAdaptElement(parentElement, element);
1976
        return element;
1977
    }
1978

    
1979
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1980
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1981
        addAndAdaptElement(parentElement, element);
1982
        return element;
1983
    }
1984

    
1985
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1986
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
1987
        addAndAdaptElement(parentElement, element);
1988
        return element;
1989
    }
1990

    
1991
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
1992
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
1993
        addAndAdaptElement(parentElement, element);
1994
        return element;
1995
    }
1996

    
1997
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
1998
        UserDetailElement element = new UserDetailElement(this, parentElement);
1999
        addAndAdaptElement(parentElement, element);
2000
        return element;
2001
    }
2002

    
2003
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2004
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2005
        addAndAdaptElement(parentElement, element);
2006
        return element;
2007
    }
2008

    
2009
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2010
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2011
        addAndAdaptElement(parentElement, element);
2012
        return element;
2013
    }
2014

    
2015
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2016
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2017
        addAndAdaptElement(parentElement, element);
2018
        return element;
2019
    }
2020

    
2021
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2022
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2023
        addAndAdaptElement(parentElement, element);
2024
        return element;
2025
    }
2026

    
2027
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2028
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2029
        addAndAdaptElement(parentElement, element);
2030
        return element;
2031
    }
2032

    
2033
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2034
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2035
        adapt(element);
2036
        parentElement.addElement(element);
2037

    
2038
        return element;
2039
    }
2040

    
2041
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2042
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2043
        addAndAdaptElement(parentElement, element);
2044
        return element;
2045
    }
2046

    
2047
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
2048
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
2049
        addAndAdaptElement(parentElement, element);
2050
        return element;
2051
    }
2052

    
2053
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2054
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2055
        addAndAdaptElement(parentElement, element);
2056
        return element;
2057
    }
2058

    
2059
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2060
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2061
        addAndAdaptElement(parentElement, element);
2062
        return element;
2063
    }
2064

    
2065
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2066
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2067
        addAndAdaptElement(parentElement, element);
2068
        return element;
2069
    }
2070

    
2071
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2072
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2073
        addAndAdaptElement(parentElement, element);
2074
        return element;
2075
    }
2076

    
2077
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2078
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2079
        addAndAdaptElement(parentElement, element);
2080
        return element;
2081
    }
2082

    
2083
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2084
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2085
        addAndAdaptElement(parentElement, element);
2086
        return element;
2087
    }
2088

    
2089
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2090
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2091
        addAndAdaptElement(parentElement, element);
2092
        return element;
2093
    }
2094

    
2095
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2096
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2097
        addAndAdaptElement(parentElement, element);
2098
        return element;
2099
    }
2100

    
2101
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2102
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2103
        addAndAdaptElement(parentElement, element);
2104
        return element;
2105
    }
2106

    
2107
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2108
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2109
        addAndAdaptElement(parentElement, element);
2110
        return element;
2111
    }
2112

    
2113
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
2114
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
2115
        addAndAdaptElement(parentElement, element);
2116
        return element;
2117
    }
2118

    
2119
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2120
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2121
        addAndAdaptElement(parentElement, element);
2122
        return element;
2123
    }
2124

    
2125

    
2126
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2127
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2128
        addAndAdaptElement(parentElement, element);
2129
        return element;
2130
    }
2131

    
2132
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2133
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2134
        addAndAdaptElement(parentElement, element);
2135
        return element;
2136
    }
2137

    
2138
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2139
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2140
        addAndAdaptElement(parentElement, element);
2141
        return element;
2142
    }
2143

    
2144
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2145
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2146
        addAndAdaptElement(parentElement, element);
2147
        return element;
2148
    }
2149

    
2150
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2151
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2152
        addAndAdaptElement(parentElement, element);
2153
        return element;
2154
    }
2155

    
2156
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2157
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2158
        addAndAdaptElement(parentElement, element);
2159
        return element;
2160
    }
2161

    
2162
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2163
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2164
        addAndAdaptElement(parentElement, element);
2165
        return element;
2166
    }
2167

    
2168
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2169
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2170
        addAndAdaptElement(parentElement, element);
2171
        return element;
2172
    }
2173

    
2174
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2175
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2176
        addAndAdaptElement(parentElement, element);
2177
        return element;
2178
    }
2179

    
2180
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2181
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2182
        addAndAdaptElement(parentElement, element);
2183
        return element;
2184
    }
2185

    
2186
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2187
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2188
        addAndAdaptElement(parentElement, element);
2189
        return element;
2190
    }
2191

    
2192
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2193
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2194
        addAndAdaptElement(parentElement, element);
2195
        return element;
2196
    }
2197

    
2198
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2199
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2200
        addAndAdaptElement(parentElement, element);
2201
        return element;
2202
    }
2203

    
2204
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2205
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2206
        addAndAdaptElement(parentElement, element);
2207
        return element;
2208
    }
2209

    
2210
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2211
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2212
        addAndAdaptElement(parentElement, element);
2213
        return element;
2214
    }
2215

    
2216
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2217
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2218
        addAndAdaptElement(parentElement, element);
2219
        return element;
2220
    }
2221

    
2222
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2223
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2224
        addAndAdaptElement(parentElement, mediaDetailElement);
2225
        return mediaDetailElement;
2226
    }
2227

    
2228
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2229
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2230
        addAndAdaptElement(parentElement, element);
2231
        return element;
2232
    }
2233

    
2234
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2235
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2236
        addAndAdaptElement(parentElement, element);
2237
        return element;
2238
    }
2239

    
2240
    public SpecimenHierarchyDetailElement createSpecimenHierarchyDetailElement(ICdmFormElement parentElement) {
2241
        SpecimenHierarchyDetailElement element = new SpecimenHierarchyDetailElement(this, parentElement);
2242
        addAndAdaptElement(parentElement, element);
2243
        return element;
2244
    }
2245

    
2246
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2247
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2248
        addAndAdaptElement(parentElement, element);
2249
        return element;
2250
    }
2251

    
2252
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2253
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2254
        addAndAdaptElement(parentElement, element);
2255
        return element;
2256
    }
2257

    
2258
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2259
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2260
        addAndAdaptElement(parentElement, element);
2261
        return element;
2262
    }
2263

    
2264
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2265
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2266
        addAndAdaptElement(parentElement, element);
2267
        return element;
2268
    }
2269

    
2270
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2271
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2272
        addAndAdaptElement(parentElement, element);
2273
        return element;
2274
    }
2275

    
2276
    /**
2277
     * @param parentElement
2278
     * @param element
2279
     */
2280
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2281
        adapt(element);
2282
        parentElement.addElement(element);
2283
    }
2284

    
2285
    //--------EntityCollectionSection----------
2286
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2287
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2288
        addAndAdaptSection(parentElement, section);
2289
        return section;
2290
    }
2291

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2436
    public MeasurementUnitCollectionSection createMeasurementUnitCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2437
        MeasurementUnitCollectionSection section = new MeasurementUnitCollectionSection(this, conversation, parentElement, style);
2438
        addAndAdaptSection(parentElement, section);
2439
        return section;
2440
    }
2441

    
2442
    public StatisticalMeasureCollectionSection createStatisticalMeasureCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2443
        StatisticalMeasureCollectionSection section = new StatisticalMeasureCollectionSection(this, conversation, parentElement, style);
2444
        addAndAdaptSection(parentElement, section);
2445
        return section;
2446
    }
2447

    
2448
    public CollectingAreasDetailSection createCollectingAreasDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2449
        CollectingAreasDetailSection section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
2450
        addAndAdaptSection(parentElement, section);
2451
        return section;
2452
    }
2453

    
2454
    public GeoScopeDetailSection createGeoScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2455
        GeoScopeDetailSection section = new GeoScopeDetailSection(this, conversation, parentElement, style);
2456
        addAndAdaptSection(parentElement, section);
2457
        return section;
2458
    }
2459

    
2460
    public GeoScopePolyKeyDetailSection createGeoScopePolyKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2461
        GeoScopePolyKeyDetailSection section = new GeoScopePolyKeyDetailSection(this, conversation, parentElement, style);
2462
        addAndAdaptSection(parentElement, section);
2463
        return section;
2464
    }
2465

    
2466
    public IdentifierSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2467
        IdentifierSection section = new IdentifierSection(this, conversation, parentElement, style);
2468
        addAndAdaptSection(parentElement, section);
2469
        return section;
2470
    }
2471

    
2472
    public DerivedUnitFacadeIdentifierSection createDerivedUnitFacadeIdentifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2473
    	DerivedUnitFacadeIdentifierSection section = new DerivedUnitFacadeIdentifierSection(this, conversation, parentElement, style);
2474
    	addAndAdaptSection(parentElement, section);
2475
    	return section;
2476
    }
2477

    
2478
    public CurrentSampleDesignationDetailSection createCurrentSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2479
        CurrentSampleDesignationDetailSection section = new CurrentSampleDesignationDetailSection(this, conversation, parentElement, style);
2480
        addAndAdaptSection(parentElement, section);
2481
        return section;
2482
    }
2483

    
2484
    public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2485
        CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
2486
        addAndAdaptSection(parentElement, section);
2487
        return section;
2488
    }
2489

    
2490
    public PreservedSpecimenCurrentDeterminationDetailSection createPreservedSpecimenCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2491
        PreservedSpecimenCurrentDeterminationDetailSection section = new PreservedSpecimenCurrentDeterminationDetailSection(this, conversation, parentElement, style);
2492
        addAndAdaptSection(parentElement, section);
2493
        return section;
2494
    }
2495

    
2496
    public SampleDesignationHistoryDetailSection createSampleDesignationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2497
        SampleDesignationHistoryDetailSection section = new SampleDesignationHistoryDetailSection(this, conversation, parentElement, style);
2498
        addAndAdaptSection(parentElement, section);
2499
        return section;
2500
    }
2501

    
2502
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2503
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
2504
        addAndAdaptSection(parentElement, section);
2505
        return section;
2506
    }
2507

    
2508
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2509
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
2510
        addAndAdaptSection(parentElement, section);
2511
        return section;
2512
    }
2513

    
2514
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2515
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2516
        addAndAdaptSection(parentElement, section);
2517
        return section;
2518
    }
2519

    
2520
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2521
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2522
        addAndAdaptSection(parentElement, section);
2523
        return section;
2524
    }
2525

    
2526
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2527
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2528
        addAndAdaptSection(parentElement, section);
2529
        return section;
2530
    }
2531

    
2532
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2533
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2534
        addAndAdaptSection(parentElement, section);
2535
        return section;
2536
    }
2537

    
2538
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2539
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2540
        addAndAdaptSection(parentElement, section);
2541
        return section;
2542
    }
2543

    
2544
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2545
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2546
        addAndAdaptSection(parentElement, section);
2547
        return section;
2548
    }
2549

    
2550
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2551
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2552
        addAndAdaptSection(parentElement, section);
2553
        return section;
2554
    }
2555

    
2556

    
2557
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2558
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2559
        AbstractEntityCollectionElement element = null;
2560

    
2561
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2562

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

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

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

    
2718

    
2719
        if (element == null) {
2720
            MessagingUtils.messageDialog("No element for entity", this,
2721
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2722
                            + entity, null);
2723
        }
2724

    
2725
        else{
2726
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2727
                element.setPersistentBackground(backgroundColor);
2728
            }
2729
            adapt(element);
2730
            parentElement.addElement(element);
2731
        }
2732

    
2733
        return element;
2734
    }
2735

    
2736
    /**
2737
     * <p>
2738
     * Creates a selection element for the given type T.
2739
     * </p>
2740
     * <p>
2741
     * <strong>Selection elements not handled by this method:</strong>
2742
     * <ul>
2743
     * <li>{@link TaxonNodeSelectionElement} see
2744
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2745
     * </li>
2746
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2747
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2748
     * </li>
2749
     * </ul>
2750
     * </p>
2751
     *
2752
     * @param clazz
2753
     *            a {@link Class} object of the type that you want the selection
2754
     *            element to handle
2755
     * @param parentElement
2756
     *            a {@link ICdmFormElement} object.
2757
     * @param labelString
2758
     *            a {@link String} object.
2759
     * @param selectionType
2760
     * @param selection
2761
     *            a {@link ICdmBase} object.
2762
     * @param style
2763
     *            a int.
2764
     * @param conversation
2765
     *            a {@link ConversationHolder} object.
2766
     * @return a {@link EntitySelectionElement} object.
2767
     */
2768
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2769
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2770
            int style) {
2771
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2772
                labelString, selection, mode, style);
2773
        adapt(element);
2774
        parentElement.addElement(element);
2775
        return element;
2776
    }
2777

    
2778
    /**
2779
     * <p>
2780
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
2781
     * </p>
2782
     * <p>
2783
     * <strong>Selection elements not handled by this method:</strong>
2784
     * <ul>
2785
     * <li>{@link TaxonNodeSelectionElement} see
2786
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2787
     * </li>
2788
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2789
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2790
     * </li>
2791
     * </ul>
2792
     * </p>
2793
     *
2794
     * @param clazz
2795
     *            a {@link Class} object of the type that you want the selection
2796
     *            element to handle
2797
     * @param parentElement
2798
     *            a {@link ICdmFormElement} object.
2799
     * @param labelString
2800
     *            a {@link String} object.
2801
     * @param selectionType
2802
     * @param selection
2803
     *            a {@link ICdmBase} object.
2804
     * @param style
2805
     *            a int.
2806
     * @param conversation
2807
     *            a {@link ConversationHolder} object.
2808
     * @return a {@link EntitySelectionElement} object.
2809
     */
2810
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
2811
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
2812
            T selection, int mode, int style) {
2813
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, conversation, parentElement, clazz,
2814
                labelString, selection, mode, style);
2815
        adapt(element);
2816
        parentElement.addElement(element);
2817
        return element;
2818
    }
2819

    
2820
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2821
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2822
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2823
                labelString, selection, mode, style);
2824
        adapt(element);
2825
        parentElement.addElement(element);
2826
        return element;
2827
    }
2828

    
2829
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2830
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2831
//            int mode, int style) {
2832
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2833
//                conversation, parentElement, labelString, selection, mode, style);
2834
//        adapt(element);
2835
//        parentElement.addElement(element);
2836
//        return element;
2837
//    }
2838

    
2839
    /** {@inheritDoc} */
2840
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2841
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2842
        adapt(labelElement);
2843
        parentElement.addElement(labelElement);
2844
        return labelElement;
2845
    }
2846

    
2847
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2848
        Label label = new Label(formElement.getLayoutComposite(), style);
2849
        label.setText(labelText+" (yyyy-MM-dd)");
2850
        DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, style);
2851
        dateElement.initController(this, formElement);
2852
        return dateElement;
2853
    }
2854

    
2855
    /**
2856
     * <p>
2857
     * Getter for the field <code>selectionProvider</code>.
2858
     * </p>
2859
     *
2860
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2861
     */
2862
    public ISelectionProvider getSelectionProvider() {
2863
        return selectionProvider;
2864
    }
2865

    
2866
    /**
2867
     * <p>
2868
     * createDetailedDescriptionDetailElement
2869
     * </p>
2870
     *
2871
     * @param parentElement
2872
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2873
     *            object.
2874
     * @param entity
2875
     *            a
2876
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2877
     *            object.
2878
     * @param style
2879
     *            a int.
2880
     * @return a
2881
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2882
     *         object.
2883
     */
2884
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2885
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2886
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2887

    
2888
        if (entity instanceof CategoricalData) {
2889
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2890
                    (CategoricalData) entity, style);
2891
        } else if (entity instanceof CommonTaxonName) {
2892
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2893
                    style);
2894
        } else if (entity instanceof Distribution) {
2895
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2896
                    style);
2897
        } else if (entity instanceof IndividualsAssociation) {
2898
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2899
                    (IndividualsAssociation) entity, style);
2900
        } else if (entity instanceof QuantitativeData) {
2901
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2902
                    (QuantitativeData) entity, style);
2903
        } else if (entity instanceof TaxonInteraction) {
2904
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2905
                    (TaxonInteraction) entity, style);
2906
        } else if (entity instanceof TextData) {
2907
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2908
        } else {
2909
            throw new IllegalStateException("There is no interface for the given description element");
2910
        }
2911
        adapt(detailedDescriptionElement);
2912
        parentElement.addElement(detailedDescriptionElement);
2913
        return detailedDescriptionElement;
2914

    
2915
    }
2916

    
2917
    /**
2918
     * Creates a styled text as a part of the form.
2919
     *
2920
     * @param parent
2921
     *            the text parent
2922
     * @param value
2923
     *            the text initial value
2924
     * @param style
2925
     *            the text style
2926
     * @return the text widget
2927
     */
2928
    public StyledText createStyledText(Composite parent, String value, int style) {
2929
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2930
        if (value != null) {
2931
            text.setText(value);
2932
        }
2933
        text.setForeground(getColors().getForeground());
2934
        text.setBackground(getColors().getBackground());
2935
        // text.addFocusListener(visibilityHandler);
2936
        return text;
2937
    }
2938

    
2939
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2940
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2941
        addAndAdaptSection(parentElement, section);
2942
        return section;
2943
    }
2944

    
2945
    /**
2946
     * @param formElement
2947
     * @param conversationHolder
2948
     * @param style
2949
     * @return
2950
     */
2951
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
2952
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
2953
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
2954
        addAndAdaptSection(formElement, section);
2955
        return section;
2956
    }
2957

    
2958
    /**
2959
     * @param conversationHolder
2960
     * @param formElement
2961
     * @param expanded
2962
     * @return
2963
     */
2964
    public TeamMemberSection createNomenclaturalTeamMemberSection(ConversationHolder conversationHolder,
2965
            ICdmFormElement formElement, int expanded) {
2966
        // TODO Auto-generated method stub
2967
        return null;
2968
    }
2969

    
2970
}
(7-7/44)