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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
912
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
913
            TermType termType,
914
            ICdmFormElement parentElement,
915
            String labelString,
916
            T selection,
917
            int style) {
918
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, true, style, false);
919
        adapt(element);
920
        parentElement.addElement(element);
921
        return element;
922
    }
923

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

    
949

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

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

    
975
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
976
	        Class<T> enumComboType, ICdmFormElement parentElement,
977
	        int style) {
978
	    return createEnumComboElement(enumComboType, parentElement, null, style);
979
	}
980

    
981
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
982
			Class<T> enumComboType, ICdmFormElement parentElement, Comparator<T> comparator,
983
			int style) {
984
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, comparator, style);
985
        adapt(element);
986
        parentElement.addElement(element);
987
        return element;
988
    }
989

    
990
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
991
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
992
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
993
	    adapt(element);
994
	    parentElement.addElement(element);
995
	    return element;
996
	}
997

    
998
    /**
999
     * <p>
1000
     * createBrowserElement
1001
     * </p>
1002
     *
1003
     * @param imageUri
1004
     *            a {@link java.net.URI} object.
1005
     * @param style
1006
     *            a int.
1007
     * @param parentElement
1008
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1009
     *            object.
1010
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
1011
     *         object.
1012
     */
1013
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
1014
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
1015
        adapt(element);
1016
        parentElement.addElement(element);
1017
        return element;
1018
    }
1019

    
1020
    /**
1021
     * <p>
1022
     * createImageElement
1023
     * </p>
1024
     *
1025
     * @param parentElement
1026
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1027
     *            object.
1028
     * @param imageUri
1029
     *            a {@link java.net.URI} object.
1030
     * @param style
1031
     *            a int.
1032
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1033
     */
1034
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1035
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1036
        adapt(element);
1037
        parentElement.addElement(element);
1038
        return element;
1039
    }
1040

    
1041
    /**
1042
     * <p>
1043
     * createTextActionElement
1044
     * </p>
1045
     *
1046
     * @param labelString
1047
     *            a {@link java.lang.String} object.
1048
     * @param initialText
1049
     *            a {@link java.lang.String} object.
1050
     * @param style
1051
     *            a int.
1052
     * @param parentElement
1053
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1054
     *            object.
1055
     * @param buttonLabel
1056
     *            a {@link java.lang.String} object.
1057
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
1058
     *         object.
1059
     */
1060
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
1061
            String buttonLabel, String initialText, int style) {
1062
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
1063
                style);
1064
        adapt(element);
1065
        parentElement.addElement(element);
1066
        return element;
1067
    }
1068

    
1069
    /**
1070
     * <p>
1071
     * createCheckbox
1072
     * </p>
1073
     *
1074
     * @param parentElement
1075
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1076
     *            object.
1077
     * @param label
1078
     *            a {@link java.lang.String} object.
1079
     * @param initialState
1080
     *            a boolean.
1081
     * @param style
1082
     *            a int.
1083
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1084
     *         object.
1085
     */
1086
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1087
        if(initialState==null){
1088
            initialState = Boolean.FALSE;
1089
        }
1090
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1091
        adapt(element);
1092
        parentElement.addElement(element);
1093
        return element;
1094
    }
1095

    
1096
    /**
1097
     * Creates a section as a part of the form.
1098
     *
1099
     * @return the section widget
1100
     * @param section
1101
     *            a
1102
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1103
     *            object.
1104
     */
1105
    public Section adapt(AbstractFormSection section) {
1106
        section.setMenu(section.getLayoutComposite().getMenu());
1107
        adapt(section, true, true);
1108

    
1109
        // handle focus and property change events for cdm use
1110
        section.addFocusListener(selectionFocusHandler);
1111
        section.setPropertyChangeListeners(propertyChangeListeners);
1112

    
1113
        if (section.getToggle() != null) {
1114
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1115
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1116
        }
1117

    
1118
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1119

    
1120
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1121
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1122
            getColors().initializeSectionToolBarColors();
1123
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1124
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1125
        }
1126
        // call setTitleBarForeground regardless as it also sets the label color
1127
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1128
        return section;
1129
    }
1130

    
1131
    private class BoldFontHolder2 {
1132
        private Font normalFont;
1133

    
1134
        private Font boldFont;
1135

    
1136
        public BoldFontHolder2() {
1137
        }
1138

    
1139
        public Font getBoldFont(Font font) {
1140
            createBoldFont(font);
1141
            return boldFont;
1142
        }
1143

    
1144
        private void createBoldFont(Font font) {
1145
            if (normalFont == null || !normalFont.equals(font)) {
1146
                normalFont = font;
1147
                dispose();
1148
            }
1149
            if (boldFont == null) {
1150
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1151
            }
1152
        }
1153

    
1154
        public void dispose() {
1155
            if (boldFont != null) {
1156
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1157
                boldFont = null;
1158
            }
1159
        }
1160
    }
1161

    
1162
    /**
1163
     * <p>
1164
     * createToggleableTextField
1165
     * </p>
1166
     *
1167
     * @param parentElement
1168
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1169
     *            object.
1170
     * @param labelString
1171
     *            a {@link java.lang.String} object.
1172
     * @param initialText
1173
     *            a {@link java.lang.String} object.
1174
     * @param initialState
1175
     *            a boolean.
1176
     * @param style
1177
     *            a int.
1178
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1179
     *         object.
1180
     */
1181
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1182
            String initialText, boolean initialState, int style) {
1183
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1184
                initialState, style | orientation);
1185
        adapt(element);
1186
        parentElement.addElement(element);
1187
        return element;
1188
    }
1189

    
1190
    /**
1191
     * <p>
1192
     * createTimePeriodElement
1193
     * </p>
1194
     *
1195
     * @param parentElement
1196
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1197
     *            object.
1198
     * @param labelString
1199
     *            a {@link java.lang.String} object.
1200
     * @param timePeriod
1201
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1202
     * @param style
1203
     *            a int.
1204
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1205
     *         object.
1206
     */
1207
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1208
            TimePeriod timePeriod, int style) {
1209
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1210
        adapt(element);
1211
        parentElement.addElement(element);
1212
        return element;
1213
    }
1214

    
1215
	/**
1216
	 * <p>
1217
	 * createGatheringEventUnitElement
1218
	 * </p>
1219
	 *
1220
	 * @param parentElement
1221
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1222
	 *            object.
1223
	 * @param labelString
1224
	 *            a {@link java.lang.String} object.
1225
	 * @param timePeriod
1226
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1227
	 * @param style
1228
	 *            a int.
1229
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1230
	 *         object.
1231
	 */
1232
	public GatheringEventUnitElement createGatheringEventUnitElement(
1233
			ICdmFormElement parentElement,
1234
			String labelString,
1235
			DerivedUnitFacade gatheringEvent,
1236
			MinMaxTextSection.UnitType unitType,
1237
			int style) {
1238
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1239
				parentElement,
1240
				labelString,
1241
				gatheringEvent,
1242
				unitType,
1243
				style);
1244
		adapt(element);
1245
		parentElement.addElement(element);
1246
		return element;
1247
	}
1248

    
1249
    /**
1250
     * <p>
1251
     * createPointElement
1252
     * </p>
1253
     *
1254
     * @param style
1255
     *            a int.
1256
     * @param parentElement
1257
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1258
     *            object.
1259
     * @param point
1260
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1261
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1262
     */
1263
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1264
        PointElement element = new PointElement(this, parentElement, point, style);
1265
        adapt(element);
1266
        parentElement.addElement(element);
1267
        return element;
1268
    }
1269

    
1270

    
1271

    
1272
    /**
1273
     * @param conversationHolder
1274
     * @param parent
1275
     * @param detailsViewer
1276
     * @param i
1277
     * @return
1278
     */
1279
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1280
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1281
        parentElement.addElement(section);
1282
        adapt(section);
1283
        return section;
1284
    }
1285

    
1286
    /**
1287
     * <p>
1288
     * createDateDetailSection
1289
     * </p>
1290
     *
1291
     * @param parentElement
1292
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1293
     *            object.
1294
     * @param style
1295
     *            a int.
1296
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1297
     *         object.
1298
     */
1299
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1300
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1301
        parentElement.addElement(section);
1302
        adapt(section);
1303
        return section;
1304
    }
1305

    
1306
	/**
1307
	 * <p>
1308
	 * createDateDetailSection
1309
	 * </p>
1310
	 *
1311
	 * @param parentElement
1312
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1313
	 *            object.
1314
	 * @param style
1315
	 *            a int.
1316
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1317
	 *         object.
1318
	 */
1319
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1320
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1321
		parentElement.addElement(section);
1322
		adapt(section);
1323
		return section;
1324
	}
1325

    
1326
    /**
1327
     * <p>
1328
     * createPartialElement
1329
     * </p>
1330
     *
1331
     * @param parentElement
1332
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1333
     *            object.
1334
     * @param labelString
1335
     *            a {@link java.lang.String} object.
1336
     * @param partial
1337
     *            a {@link org.joda.time.Partial} object.
1338
     * @param style
1339
     *            a int.
1340
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1341
     *         object.
1342
     */
1343
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1344
            int style) {
1345
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1346
        adapt(element);
1347
        parentElement.addElement(element);
1348
        return element;
1349
    }
1350

    
1351
    /**
1352
     * <p>
1353
     * addSelectionListener
1354
     * </p>
1355
     *
1356
     * @param listener
1357
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1358
     */
1359
    public void addSelectionListener(SelectionListener listener) {
1360
        selectionListenerList.add(listener);
1361
    }
1362

    
1363
    /**
1364
     * <p>
1365
     * removeSelectionListener
1366
     * </p>
1367
     *
1368
     * @param listener
1369
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1370
     */
1371
    public void removeSelectionListener(SelectionListener listener) {
1372
        if (listener == null) {
1373
            MessagingUtils.error(this.getClass(),
1374
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1375
        } else {
1376
            selectionListenerList.remove(listener);
1377
        }
1378
    }
1379

    
1380
    /**
1381
     * <p>
1382
     * addPropertyChangeListener
1383
     * </p>
1384
     *
1385
     * @param listener
1386
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1387
     *            object.
1388
     */
1389
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1390
        if (propertyChangeListeners.contains(listener)) {
1391
            return;
1392
        }
1393
        propertyChangeListeners.add(0, listener);
1394
    }
1395

    
1396
    /**
1397
     * <p>
1398
     * removePropertyChangeListener
1399
     * </p>
1400
     *
1401
     * @param listener
1402
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1403
     *            object.
1404
     */
1405
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1406
        propertyChangeListeners.remove(listener);
1407
    }
1408

    
1409
    /**
1410
     * @return the propertyChangeListeners
1411
     */
1412
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1413
        return propertyChangeListeners;
1414
    }
1415

    
1416
    /**
1417
     * <p>
1418
     * createHorizontalSeparator
1419
     * </p>
1420
     *
1421
     * @param parentElement
1422
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1423
     *            object.
1424
     * @param style
1425
     *            a int.
1426
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1427
     */
1428
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1429
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1430
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1431
        return separator;
1432
    }
1433

    
1434
    /**
1435
     * <p>
1436
     * createVersionElement
1437
     * </p>
1438
     *
1439
     * @param parentElement
1440
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1441
     *            object.
1442
     * @param entity
1443
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1444
     *            object.
1445
     * @param style
1446
     *            a int.
1447
     * @return a
1448
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1449
     *         object.
1450
     */
1451
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1452
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1453
        adapt(element);
1454
        parentElement.addElement(element);
1455
        return element;
1456
    }
1457

    
1458
    /**
1459
     * @param cdmBaseSection
1460
     * @param object
1461
     * @param style
1462
     * @return
1463
     */
1464
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1465
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1466
        adapt(element);
1467
        parentElement.addElement(element);
1468
        return element;
1469
    }
1470

    
1471
    /**
1472
     * <p>
1473
     * createVersionSection
1474
     * </p>
1475
     *
1476
     * @param parentElement
1477
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1478
     *            object.
1479
     * @param style
1480
     *            a int.
1481
     * @return a
1482
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1483
     *         object.
1484
     */
1485
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1486
        VersionSection section = new VersionSection(this, parentElement, style);
1487
        parentElement.addElement(section);
1488
        adapt(section);
1489
        return section;
1490
    }
1491

    
1492
    /**
1493
     * @param parent
1494
     * @param i
1495
     * @return
1496
     */
1497
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1498
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1499
        parentElement.addElement(section);
1500
        adapt(section);
1501
        return section;
1502
    }
1503

    
1504
    /**
1505
     * <p>
1506
     * createEmptyElement
1507
     * </p>
1508
     *
1509
     * @param parentElement
1510
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1511
     *            object.
1512
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1513
     */
1514
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1515
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1516
        adapt(element);
1517
        parentElement.addElement(element);
1518
        return element;
1519
    }
1520

    
1521
    /**
1522
     * <p>
1523
     * createHeadlineSection
1524
     * </p>
1525
     *
1526
     * @param parentElement
1527
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1528
     *            object.
1529
     * @return a
1530
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1531
     *         object.
1532
     */
1533
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1534
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1535
        parentElement.addElement(section);
1536
        adapt(section);
1537
        return section;
1538
    }
1539

    
1540
    /**
1541
     * <p>
1542
     * createParsingMessageElement
1543
     * </p>
1544
     *
1545
     * @param parentElement
1546
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1547
     *            object.
1548
     * @param parserProblem
1549
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1550
     *            object.
1551
     * @param style
1552
     *            a int.
1553
     * @return a
1554
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1555
     *         object.
1556
     */
1557
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1558
            ParserProblem parserProblem, int style) {
1559
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1560
        adapt(element);
1561
        parentElement.addElement(element);
1562
        return element;
1563
    }
1564

    
1565
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1566
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1567

    
1568
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1569
                selectionProvider, style);
1570

    
1571
        parentElement.addElement(section);
1572
        adapt(section);
1573
        return section;
1574

    
1575
    }
1576

    
1577
    /**
1578
     * @param definedTermClass
1579
     * @param formElement
1580
     * @param style
1581
     * @return
1582
     */
1583
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1584
            AbstractCdmDetailSection parentElement, int style) {
1585
        AbstractCdmDetailElement element = null;
1586

    
1587
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1588
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1589
        } else if (definedTermClass.equals(Feature.class)) {
1590
            element = new FeatureDetailElement(this, parentElement);
1591
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1592
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1593
        } else {
1594
            element = new DefinedTermDetailElement(this, parentElement);
1595
        }
1596

    
1597

    
1598
        adapt(element);
1599
        parentElement.addElement(element);
1600
        return element;
1601
    }
1602

    
1603

    
1604
    //--------DetailSections---------
1605
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1606
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1607
        addAndAdaptSection(parentElement, section);
1608
        return section;
1609
    }
1610

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

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

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

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

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

    
1641
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1642
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1643
        addAndAdaptSection(parentElement, section);
1644
        return section;
1645
    }
1646

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

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

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

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

    
1671
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, boolean nameChoosable, int style){
1672
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, nameChoosable, style);
1673
        addAndAdaptSection(parentElement, section);
1674
        return section;
1675
    }
1676

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1815
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1816
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
1817
        addAndAdaptSection(parentElement, section);
1818
        return section;
1819
    }
1820

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

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

    
1833
    public SingleReadGeneralDetailSection createSingleReadGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1834
        SingleReadGeneralDetailSection section = new SingleReadGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1835
        addAndAdaptSection(parentElement, section);
1836
        return section;
1837
    }
1838

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

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

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

    
1857
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1858
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1859
        addAndAdaptSection(parentElement, section);
1860
        return section;
1861
    }
1862

    
1863
    public MediaSpecimenGeneralDetailSection createMediaSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1864
        MediaSpecimenGeneralDetailSection section = new MediaSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1865
        addAndAdaptSection(parentElement, section);
1866
        return section;
1867
    }
1868

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

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

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

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

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

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

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

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

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

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

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

    
1935
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1936
        parentElement.addElement(section);
1937
        adapt(section);
1938
    }
1939

    
1940
    //--------DetailElements------------
1941

    
1942
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1943
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1944
        addAndAdaptElement(parentElement, element);
1945
        return element;
1946
    }
1947

    
1948
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1949
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1950
        addAndAdaptElement(parentElement, element);
1951
        return element;
1952
    }
1953

    
1954
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1955
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1956
        addAndAdaptElement(parentElement, element);
1957
        return element;
1958
    }
1959

    
1960
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1961
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1962
        addAndAdaptElement(parentElement, element);
1963
        return element;
1964
    }
1965

    
1966
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1967
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1968
        addAndAdaptElement(parentElement, element);
1969
        return element;
1970
    }
1971

    
1972
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1973
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1974
        addAndAdaptElement(parentElement, element);
1975
        return element;
1976
    }
1977

    
1978
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1979
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
1980
        addAndAdaptElement(parentElement, element);
1981
        return element;
1982
    }
1983

    
1984
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
1985
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
1986
        addAndAdaptElement(parentElement, element);
1987
        return element;
1988
    }
1989

    
1990
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
1991
        UserDetailElement element = new UserDetailElement(this, parentElement);
1992
        addAndAdaptElement(parentElement, element);
1993
        return element;
1994
    }
1995

    
1996
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
1997
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
1998
        addAndAdaptElement(parentElement, element);
1999
        return element;
2000
    }
2001

    
2002
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2003
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2004
        addAndAdaptElement(parentElement, element);
2005
        return element;
2006
    }
2007

    
2008
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2009
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2010
        addAndAdaptElement(parentElement, element);
2011
        return element;
2012
    }
2013

    
2014
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2015
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2016
        addAndAdaptElement(parentElement, element);
2017
        return element;
2018
    }
2019

    
2020
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2021
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2022
        addAndAdaptElement(parentElement, element);
2023
        return element;
2024
    }
2025

    
2026
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2027
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2028
        adapt(element);
2029
        parentElement.addElement(element);
2030

    
2031
        return element;
2032
    }
2033

    
2034
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2035
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2036
        addAndAdaptElement(parentElement, element);
2037
        return element;
2038
    }
2039

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2124

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2549

    
2550
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2551
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2552
        AbstractEntityCollectionElement element = null;
2553

    
2554
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2555

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

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

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

    
2708

    
2709
        if (element == null) {
2710
            MessagingUtils.messageDialog("No element for entity", this,
2711
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2712
                            + entity, null);
2713
        }
2714

    
2715
        else{
2716
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2717
                element.setPersistentBackground(backgroundColor);
2718
            }
2719
            adapt(element);
2720
            parentElement.addElement(element);
2721
        }
2722

    
2723
        return element;
2724
    }
2725

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

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

    
2810
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2811
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2812
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2813
                labelString, selection, mode, style);
2814
        adapt(element);
2815
        parentElement.addElement(element);
2816
        return element;
2817
    }
2818

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

    
2829
    /** {@inheritDoc} */
2830
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2831
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2832
        adapt(labelElement);
2833
        parentElement.addElement(labelElement);
2834
        return labelElement;
2835
    }
2836

    
2837
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2838
        Label label = new Label(formElement.getLayoutComposite(), style);
2839
        label.setText(labelText+" (yyyy-MM-dd)");
2840
        DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, style);
2841
        dateElement.initController(this, formElement);
2842
        return dateElement;
2843
    }
2844

    
2845
    /**
2846
     * <p>
2847
     * Getter for the field <code>selectionProvider</code>.
2848
     * </p>
2849
     *
2850
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2851
     */
2852
    public ISelectionProvider getSelectionProvider() {
2853
        return selectionProvider;
2854
    }
2855

    
2856
    /**
2857
     * <p>
2858
     * createDetailedDescriptionDetailElement
2859
     * </p>
2860
     *
2861
     * @param parentElement
2862
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2863
     *            object.
2864
     * @param entity
2865
     *            a
2866
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2867
     *            object.
2868
     * @param style
2869
     *            a int.
2870
     * @return a
2871
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2872
     *         object.
2873
     */
2874
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2875
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2876
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2877

    
2878
        if (entity instanceof CategoricalData) {
2879
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2880
                    (CategoricalData) entity, style);
2881
        } else if (entity instanceof CommonTaxonName) {
2882
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2883
                    style);
2884
        } else if (entity instanceof Distribution) {
2885
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2886
                    style);
2887
        } else if (entity instanceof IndividualsAssociation) {
2888
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2889
                    (IndividualsAssociation) entity, style);
2890
        } else if (entity instanceof QuantitativeData) {
2891
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2892
                    (QuantitativeData) entity, style);
2893
        } else if (entity instanceof TaxonInteraction) {
2894
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2895
                    (TaxonInteraction) entity, style);
2896
        } else if (entity instanceof TextData) {
2897
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2898
        } else {
2899
            throw new IllegalStateException("There is no interface for the given description element");
2900
        }
2901
        adapt(detailedDescriptionElement);
2902
        parentElement.addElement(detailedDescriptionElement);
2903
        return detailedDescriptionElement;
2904

    
2905
    }
2906

    
2907
    /**
2908
     * Creates a styled text as a part of the form.
2909
     *
2910
     * @param parent
2911
     *            the text parent
2912
     * @param value
2913
     *            the text initial value
2914
     * @param style
2915
     *            the text style
2916
     * @return the text widget
2917
     */
2918
    public StyledText createStyledText(Composite parent, String value, int style) {
2919
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2920
        if (value != null) {
2921
            text.setText(value);
2922
        }
2923
        text.setForeground(getColors().getForeground());
2924
        text.setBackground(getColors().getBackground());
2925
        // text.addFocusListener(visibilityHandler);
2926
        return text;
2927
    }
2928

    
2929
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2930
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2931
        addAndAdaptSection(parentElement, section);
2932
        return section;
2933
    }
2934

    
2935
    /**
2936
     * @param formElement
2937
     * @param conversationHolder
2938
     * @param style
2939
     * @return
2940
     */
2941
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
2942
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
2943
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
2944
        addAndAdaptSection(formElement, section);
2945
        return section;
2946
    }
2947

    
2948
    /**
2949
     * @param conversationHolder
2950
     * @param formElement
2951
     * @param expanded
2952
     * @return
2953
     */
2954
    public TeamMemberSection createNomenclaturalTeamMemberSection(ConversationHolder conversationHolder,
2955
            ICdmFormElement formElement, int expanded) {
2956
        // TODO Auto-generated method stub
2957
        return null;
2958
    }
2959

    
2960
}
(7-7/44)