Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
948

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1141
    private class BoldFontHolder2 {
1142
        private Font normalFont;
1143

    
1144
        private Font boldFont;
1145

    
1146
        public BoldFontHolder2() {
1147
        }
1148

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

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

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

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

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

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

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

    
1280

    
1281

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1585
    }
1586

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

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

    
1607

    
1608
        adapt(element);
1609
        parentElement.addElement(element);
1610
        return element;
1611
    }
1612

    
1613

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1945
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1946
        parentElement.addElement(section);
1947
        adapt(section);
1948
    }
1949

    
1950
    //--------DetailElements------------
1951

    
1952
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1953
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1954
        addAndAdaptElement(parentElement, element);
1955
        return element;
1956
    }
1957

    
1958
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1959
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1960
        addAndAdaptElement(parentElement, element);
1961
        return element;
1962
    }
1963

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

    
1970
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1971
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1972
        addAndAdaptElement(parentElement, element);
1973
        return element;
1974
    }
1975

    
1976
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1977
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1978
        addAndAdaptElement(parentElement, element);
1979
        return element;
1980
    }
1981

    
1982
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1983
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1984
        addAndAdaptElement(parentElement, element);
1985
        return element;
1986
    }
1987

    
1988
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1989
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
1990
        addAndAdaptElement(parentElement, element);
1991
        return element;
1992
    }
1993

    
1994
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
1995
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
1996
        addAndAdaptElement(parentElement, element);
1997
        return element;
1998
    }
1999

    
2000
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2001
        UserDetailElement element = new UserDetailElement(this, parentElement);
2002
        addAndAdaptElement(parentElement, element);
2003
        return element;
2004
    }
2005

    
2006
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2007
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2008
        addAndAdaptElement(parentElement, element);
2009
        return element;
2010
    }
2011

    
2012
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2013
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2014
        addAndAdaptElement(parentElement, element);
2015
        return element;
2016
    }
2017

    
2018
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2019
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2020
        addAndAdaptElement(parentElement, element);
2021
        return element;
2022
    }
2023

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

    
2030
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2031
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2032
        addAndAdaptElement(parentElement, element);
2033
        return element;
2034
    }
2035

    
2036
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2037
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2038
        adapt(element);
2039
        parentElement.addElement(element);
2040

    
2041
        return element;
2042
    }
2043

    
2044
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2045
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2046
        addAndAdaptElement(parentElement, element);
2047
        return element;
2048
    }
2049

    
2050
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
2051
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
2052
        addAndAdaptElement(parentElement, element);
2053
        return element;
2054
    }
2055

    
2056
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2057
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2058
        addAndAdaptElement(parentElement, element);
2059
        return element;
2060
    }
2061

    
2062
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2063
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2064
        addAndAdaptElement(parentElement, element);
2065
        return element;
2066
    }
2067

    
2068
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2069
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2070
        addAndAdaptElement(parentElement, element);
2071
        return element;
2072
    }
2073

    
2074
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2075
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2076
        addAndAdaptElement(parentElement, element);
2077
        return element;
2078
    }
2079

    
2080
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2081
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2082
        addAndAdaptElement(parentElement, element);
2083
        return element;
2084
    }
2085

    
2086
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2087
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2088
        addAndAdaptElement(parentElement, element);
2089
        return element;
2090
    }
2091

    
2092
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2093
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2094
        addAndAdaptElement(parentElement, element);
2095
        return element;
2096
    }
2097

    
2098
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2099
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2100
        addAndAdaptElement(parentElement, element);
2101
        return element;
2102
    }
2103

    
2104
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2105
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2106
        addAndAdaptElement(parentElement, element);
2107
        return element;
2108
    }
2109

    
2110
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2111
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2112
        addAndAdaptElement(parentElement, element);
2113
        return element;
2114
    }
2115

    
2116
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2117
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2118
        addAndAdaptElement(parentElement, element);
2119
        return element;
2120
    }
2121

    
2122
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2123
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2124
        addAndAdaptElement(parentElement, element);
2125
        return element;
2126
    }
2127

    
2128
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2129
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2130
        addAndAdaptElement(parentElement, element);
2131
        return element;
2132
    }
2133

    
2134

    
2135
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2136
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2137
        addAndAdaptElement(parentElement, element);
2138
        return element;
2139
    }
2140

    
2141
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2142
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2143
        addAndAdaptElement(parentElement, element);
2144
        return element;
2145
    }
2146

    
2147
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2148
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2149
        addAndAdaptElement(parentElement, element);
2150
        return element;
2151
    }
2152

    
2153
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2154
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2155
        addAndAdaptElement(parentElement, element);
2156
        return element;
2157
    }
2158

    
2159
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2160
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2161
        addAndAdaptElement(parentElement, element);
2162
        return element;
2163
    }
2164

    
2165
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2166
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2167
        addAndAdaptElement(parentElement, element);
2168
        return element;
2169
    }
2170

    
2171
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2172
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2173
        addAndAdaptElement(parentElement, element);
2174
        return element;
2175
    }
2176

    
2177
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2178
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2179
        addAndAdaptElement(parentElement, element);
2180
        return element;
2181
    }
2182

    
2183
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2184
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2185
        addAndAdaptElement(parentElement, element);
2186
        return element;
2187
    }
2188

    
2189
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2190
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2191
        addAndAdaptElement(parentElement, element);
2192
        return element;
2193
    }
2194

    
2195
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2196
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2197
        addAndAdaptElement(parentElement, element);
2198
        return element;
2199
    }
2200

    
2201
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2202
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2203
        addAndAdaptElement(parentElement, element);
2204
        return element;
2205
    }
2206

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

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

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

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

    
2231
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2232
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2233
        addAndAdaptElement(parentElement, mediaDetailElement);
2234
        return mediaDetailElement;
2235
    }
2236

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

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

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

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

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

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

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

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

    
2285
    /**
2286
     * @param parentElement
2287
     * @param element
2288
     */
2289
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2290
        adapt(element);
2291
        parentElement.addElement(element);
2292
    }
2293

    
2294
    //--------EntityCollectionSection----------
2295
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2296
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2297
        addAndAdaptSection(parentElement, section);
2298
        return section;
2299
    }
2300

    
2301
    public AnnotationSection createAnnotationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2302
        AnnotationSection section = new AnnotationSection(this, conversation, parentElement, style);
2303
        addAndAdaptSection(parentElement, section);
2304
        return section;
2305
    }
2306

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2559

    
2560
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2561
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2562
        AbstractEntityCollectionElement element = null;
2563

    
2564
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2565

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

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

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

    
2718

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

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

    
2733
        return element;
2734
    }
2735

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

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

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

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

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

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

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

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

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

    
2915
    }
2916

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

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

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

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

    
2970
}
(7-7/44)