Project

General

Profile

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

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

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

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

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

    
352
    private BoldFontHolder2 boldFontHolder2;
353
    private MouseListener selectionMouseHandler;
354
    private FocusListener selectionFocusHandler;
355

    
356
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
357

    
358
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
359

    
360
    private final int orientation = Window.getDefaultOrientation();
361
    private ISelectionProvider selectionProvider;
362

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

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

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

    
397
    private void notifySelectionListeners(TypedEvent e) {
398
        Event event = new Event();
399
        event.widget = e.widget;
400
        SelectionEvent selectionEvent = new SelectionEvent(event);
401

    
402
        for (SelectionListener listener : selectionListenerList) {
403
            listener.widgetSelected(selectionEvent);
404
        }
405
    }
406

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
864
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
865
            String labelString, LanguageString languageString, int style) {
866
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
867
    }
868

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

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

    
914
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
915
            TermType termType,
916
            ICdmFormElement parentElement,
917
            String labelString,
918
            T selection,
919
            int style) {
920
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false);
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
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, false);
931
	}
932
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
933
			TermType termType,
934
			ICdmFormElement parentElement,
935
			String labelString,
936
			T selection,
937
			boolean addEmptyElement,
938
			int style,
939
			boolean useAbbrevLabel) {
940
		return createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel);
941
	}
942

    
943

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

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

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

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

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

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

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

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

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

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

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

    
1125
        // handle focus and property change events for cdm use
1126
        section.addFocusListener(selectionFocusHandler);
1127
        section.setPropertyChangeListeners(propertyChangeListeners);
1128

    
1129
        if (section.getToggle() != null) {
1130
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1131
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1132
        }
1133

    
1134
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1135

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

    
1147
    private class BoldFontHolder2 {
1148
        private Font normalFont;
1149

    
1150
        private Font boldFont;
1151

    
1152
        public BoldFontHolder2() {
1153
        }
1154

    
1155
        public Font getBoldFont(Font font) {
1156
            createBoldFont(font);
1157
            return boldFont;
1158
        }
1159

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

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

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

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

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

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

    
1286

    
1287

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

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

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

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

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

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

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

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

    
1425
    /**
1426
     * @return the propertyChangeListeners
1427
     */
1428
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1429
        return propertyChangeListeners;
1430
    }
1431

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

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

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

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

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

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

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

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

    
1581
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1582
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1583

    
1584
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1585
                selectionProvider, style);
1586

    
1587
        parentElement.addElement(section);
1588
        adapt(section);
1589
        return section;
1590

    
1591
    }
1592

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

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

    
1613

    
1614
        adapt(element);
1615
        parentElement.addElement(element);
1616
        return element;
1617
    }
1618

    
1619

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

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

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

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

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

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

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

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

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

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

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

    
1687

    
1688

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1953
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1954
        parentElement.addElement(section);
1955
        adapt(section);
1956
    }
1957

    
1958
    //--------DetailElements------------
1959

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

    
1966
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1967
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1968
        addAndAdaptElement(parentElement, element);
1969
        return element;
1970
    }
1971

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

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

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

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

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

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

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

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

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

    
2026
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2027
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2028
        addAndAdaptElement(parentElement, element);
2029
        return element;
2030
    }
2031

    
2032
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2033
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2034
        addAndAdaptElement(parentElement, element);
2035
        return element;
2036
    }
2037

    
2038
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2039
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2040
        addAndAdaptElement(parentElement, element);
2041
        return element;
2042
    }
2043

    
2044
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2045
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2046
        adapt(element);
2047
        parentElement.addElement(element);
2048

    
2049
        return element;
2050
    }
2051

    
2052
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2053
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2054
        addAndAdaptElement(parentElement, element);
2055
        return element;
2056
    }
2057

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

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

    
2070
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2071
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2072
        addAndAdaptElement(parentElement, element);
2073
        return element;
2074
    }
2075

    
2076
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2077
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2078
        addAndAdaptElement(parentElement, element);
2079
        return element;
2080
    }
2081

    
2082
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2083
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2084
        addAndAdaptElement(parentElement, element);
2085
        return element;
2086
    }
2087

    
2088
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2089
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2090
        addAndAdaptElement(parentElement, element);
2091
        return element;
2092
    }
2093

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

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

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

    
2112
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2113
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2114
        addAndAdaptElement(parentElement, element);
2115
        return element;
2116
    }
2117

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

    
2124
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2125
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2126
        addAndAdaptElement(parentElement, element);
2127
        return element;
2128
    }
2129

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

    
2136
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2137
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2138
        addAndAdaptElement(parentElement, element);
2139
        return element;
2140
    }
2141

    
2142

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2221
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2222
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2223
        addAndAdaptElement(parentElement, element);
2224
        return element;
2225
    }
2226

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

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

    
2239
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2240
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2241
        addAndAdaptElement(parentElement, mediaDetailElement);
2242
        return mediaDetailElement;
2243
    }
2244

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

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

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

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

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

    
2275
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2276
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2277
        addAndAdaptElement(parentElement, element);
2278
        return element;
2279
    }
2280

    
2281
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2282
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2283
        addAndAdaptElement(parentElement, element);
2284
        return element;
2285
    }
2286

    
2287
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2288
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2289
        addAndAdaptElement(parentElement, element);
2290
        return element;
2291
    }
2292

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2567

    
2568
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2569
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2570
        AbstractEntityCollectionElement element = null;
2571

    
2572
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2573

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

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

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

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

    
2745

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

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

    
2760
        return element;
2761
    }
2762

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

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

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

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

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

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

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

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

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

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

    
2952
    }
2953

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

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

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

    
2995
	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
2996
		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
2997
				 initialText, textHeight, style);
2998
	        adapt(element);
2999
	        parentElement.addElement(element);
3000
	        return element;
3001
	}
3002

    
3003
	
3004

    
3005

    
3006

    
3007

    
3008

    
3009
}
(7-7/45)