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.forms.widgets.TableWrapData;
44
import org.eclipse.ui.internal.forms.widgets.FormFonts;
45
import org.joda.time.DateTime;
46
import org.joda.time.Partial;
47
import org.springframework.security.core.GrantedAuthority;
48

    
49
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
50
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
51
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
52
import eu.etaxonomy.cdm.model.agent.Person;
53
import eu.etaxonomy.cdm.model.agent.Team;
54
import eu.etaxonomy.cdm.model.common.Annotation;
55
import eu.etaxonomy.cdm.model.common.CdmBase;
56
import eu.etaxonomy.cdm.model.common.Credit;
57
import eu.etaxonomy.cdm.model.common.DefinedTerm;
58
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
59
import eu.etaxonomy.cdm.model.common.Extension;
60
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
61
import eu.etaxonomy.cdm.model.common.Group;
62
import eu.etaxonomy.cdm.model.common.ICdmBase;
63
import eu.etaxonomy.cdm.model.common.IEnumTerm;
64
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
65
import eu.etaxonomy.cdm.model.common.Identifier;
66
import eu.etaxonomy.cdm.model.common.LSID;
67
import eu.etaxonomy.cdm.model.common.Language;
68
import eu.etaxonomy.cdm.model.common.LanguageString;
69
import eu.etaxonomy.cdm.model.common.Marker;
70
import eu.etaxonomy.cdm.model.common.Representation;
71
import eu.etaxonomy.cdm.model.common.TermBase;
72
import eu.etaxonomy.cdm.model.common.TermType;
73
import eu.etaxonomy.cdm.model.common.TermVocabulary;
74
import eu.etaxonomy.cdm.model.common.TimePeriod;
75
import eu.etaxonomy.cdm.model.common.User;
76
import eu.etaxonomy.cdm.model.common.VersionableEntity;
77
import eu.etaxonomy.cdm.model.description.CategoricalData;
78
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
79
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
80
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
81
import eu.etaxonomy.cdm.model.description.Distribution;
82
import eu.etaxonomy.cdm.model.description.Feature;
83
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
84
import eu.etaxonomy.cdm.model.description.KeyStatement;
85
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
86
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
87
import eu.etaxonomy.cdm.model.description.QuantitativeData;
88
import eu.etaxonomy.cdm.model.description.State;
89
import eu.etaxonomy.cdm.model.description.StateData;
90
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
91
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
92
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
93
import eu.etaxonomy.cdm.model.description.TextData;
94
import eu.etaxonomy.cdm.model.location.NamedArea;
95
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
96
import eu.etaxonomy.cdm.model.location.Point;
97
import eu.etaxonomy.cdm.model.media.ImageFile;
98
import eu.etaxonomy.cdm.model.media.Media;
99
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
100
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
101
import eu.etaxonomy.cdm.model.media.Rights;
102
import eu.etaxonomy.cdm.model.molecular.DnaSample;
103
import eu.etaxonomy.cdm.model.name.NameRelationship;
104
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
105
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
106
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
107
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
108
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
109
import eu.etaxonomy.cdm.model.reference.Reference;
110
import eu.etaxonomy.cdm.model.taxon.Taxon;
111
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
112
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
113
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
114
import eu.etaxonomy.taxeditor.model.MessagingUtils;
115
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
116
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
117
import eu.etaxonomy.taxeditor.ui.combo.VocabularyComboElement;
118
import eu.etaxonomy.taxeditor.ui.dialog.CloneClassificationDetailElement;
119
import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection.UnitType;
120
import eu.etaxonomy.taxeditor.ui.mvc.element.DateElement;
121

    
122
import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
123
import eu.etaxonomy.taxeditor.ui.openurl.OpenUrlSelectorElement;
124
import eu.etaxonomy.taxeditor.ui.password.EditPasswordElement;
125
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
126
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
127
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
128
import eu.etaxonomy.taxeditor.ui.section.EmptyElement;
129
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement;
130
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection;
131
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailElement;
132
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
133
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailElement;
134
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
135
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
136
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberSection;
137
import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
138
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailElement;
139
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailSection;
140
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeAgentRelationCollectionElement;
141
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeAgentRelationCollectionSection;
142
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailElement;
143
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailSection;
144
import eu.etaxonomy.taxeditor.ui.section.common.ReferenceEntityDetailElement;
145
import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
146
import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
147
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
148
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailElement;
149
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
150
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
151
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
152
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
153
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceElement;
154
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
155
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceElement;
156
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
157
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
158
import eu.etaxonomy.taxeditor.ui.section.description.ModifierElement;
159
import eu.etaxonomy.taxeditor.ui.section.description.ModifierSection;
160
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageDetailElement;
161
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
162
import eu.etaxonomy.taxeditor.ui.section.description.ScopeElement;
163
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
164
import eu.etaxonomy.taxeditor.ui.section.description.StateDataElement;
165
import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;
166
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueElement;
167
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueSection;
168
import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;
169
import eu.etaxonomy.taxeditor.ui.section.description.detail.CategoricalDataDetailElement;
170
import eu.etaxonomy.taxeditor.ui.section.description.detail.CommonNameDetailElement;
171
import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
172
import eu.etaxonomy.taxeditor.ui.section.description.detail.IndividualsAssociationDetailElement;
173
import eu.etaxonomy.taxeditor.ui.section.description.detail.QuantitativeDataDetailElement;
174
import eu.etaxonomy.taxeditor.ui.section.description.detail.TaxonInteractionDetailElement;
175
import eu.etaxonomy.taxeditor.ui.section.description.detail.TextDataDetailElement;
176
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement;
177
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
178
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityCollectionElement;
179
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailElement;
180
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
181
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailElement;
182
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
183
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailElement;
184
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
185
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailElement;
186
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
187
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailElement;
188
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
189
import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
190
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
191
import eu.etaxonomy.taxeditor.ui.section.media.ImageFileElement;
192
import eu.etaxonomy.taxeditor.ui.section.media.MediaDetailElement;
193
import eu.etaxonomy.taxeditor.ui.section.media.MediaMetaElement;
194
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationElement;
195
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartElement;
196
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartSection;
197
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationSection;
198
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
199
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
200
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailSection;
201
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailElement;
202
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailSection;
203
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailElement;
204
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailSection;
205
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailElement;
206
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
207
import eu.etaxonomy.taxeditor.ui.section.name.NameTypeDesignationElement;
208
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusElement;
209
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
210
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailElement;
211
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
212
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueElement;
213
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
214
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
215
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
216
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
217
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
218
import eu.etaxonomy.taxeditor.ui.section.occurrence.CurrentDeterminationDetailSection;
219
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailElement;
220
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
221
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailElement;
222
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
223
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement;
224
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
225
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement;
226
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection;
227
import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
228
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailElement;
229
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailSection;
230
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailElement;
231
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSection;
232
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailElement;
233
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
234
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopeDetailSection;
235
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopePolyKeyDetailSection;
236
import eu.etaxonomy.taxeditor.ui.section.occurrence.NamedAreaDetailElement;
237
import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
238
import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
239
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElement;
240
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailSection;
241
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenHierarchyDetailElement;
242
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenHierarchyDetailSection;
243
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationElement;
244
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationSection;
245
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailElement;
246
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
247
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenCurrentDeterminationDetailSection;
248
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailElement;
249
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailSection;
250
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailElement;
251
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailSection;
252
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenSourceCollectionDetailSection;
253
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractSampleDesignationDetailSection;
254
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailElement;
255
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailSection;
256
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoCollectionDetailSection;
257
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoDetailElement;
258
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailElement;
259
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailSection;
260
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailElement;
261
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailSection;
262
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.CurrentSampleDesignationDetailSection;
263
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailElement;
264
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
265
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailElement;
266
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
267
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationDetailElement;
268
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationSection;
269
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.PrimerGeneralDetailElement;
270
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailElement;
271
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailSection;
272
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationHistoryDetailSection;
273
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationTextDetailElement;
274
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceContigFileCollectionDetailSection;
275
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailElement;
276
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
277
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailElement;
278
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
279
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailElement;
280
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
281
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadPherogramCollectionDetailSection;
282
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailElement;
283
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
284
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailElement;
285
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
286
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
287
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
288
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement;
289
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
290
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationElement;
291
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
292
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseElement;
293
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
294
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditElement;
295
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
296
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionElement;
297
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
298
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
299
import eu.etaxonomy.taxeditor.ui.section.supplemental.IdentifiableSourceElement;
300
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerElement;
301
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
302
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsElement;
303
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
304
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
305
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement;
306
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
307
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.DerivedUnitFacadeIdentifierSection;
308
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierElement;
309
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierSection;
310
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement;
311
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
312
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailElement;
313
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
314
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailElement;
315
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailElement;
316
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
317
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailElement;
318
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
319
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailElement;
320
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
321
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailElement;
322
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
323
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement;
324
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailSection;
325
import eu.etaxonomy.taxeditor.ui.section.vocabulary.FeatureDetailElement;
326
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionElement;
327
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionSection;
328
import eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailSection;
329
import eu.etaxonomy.taxeditor.ui.section.vocabulary.PresenceAbsenceTermDetailElement;
330
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesCollectionSection;
331
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesElement;
332
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionElement;
333
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionSection;
334
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionElement;
335
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionSection;
336
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailElement;
337
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
338
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
339
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementWithAbbreviatedTitle;
340
import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
341
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
342

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

    
354
    private BoldFontHolder2 boldFontHolder2;
355
    private MouseListener selectionMouseHandler;
356
    private FocusListener selectionFocusHandler;
357

    
358
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
359

    
360
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
361

    
362
    private final int orientation = Window.getDefaultOrientation();
363
    private ISelectionProvider selectionProvider;
364

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
867
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
868
            String labelString, LanguageString languageString, int style) {
869
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
870
    }
871

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

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

    
917
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
918
            TermType termType,
919
            ICdmFormElement parentElement,
920
            String labelString,
921
            T selection,
922
            int style) {
923
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false);
924
    }
925

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

    
946

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

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

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

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

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

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

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

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

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

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

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

    
1128
        // handle focus and property change events for cdm use
1129
        section.addFocusListener(selectionFocusHandler);
1130
        section.setPropertyChangeListeners(propertyChangeListeners);
1131

    
1132
        if (section.getToggle() != null) {
1133
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1134
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1135
        }
1136

    
1137
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1138

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

    
1150
    private class BoldFontHolder2 {
1151
        private Font normalFont;
1152

    
1153
        private Font boldFont;
1154

    
1155
        public BoldFontHolder2() {
1156
        }
1157

    
1158
        public Font getBoldFont(Font font) {
1159
            createBoldFont(font);
1160
            return boldFont;
1161
        }
1162

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

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

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

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

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

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

    
1289

    
1290

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

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

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

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

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

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

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

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

    
1428
    /**
1429
     * @return the propertyChangeListeners
1430
     */
1431
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1432
        return propertyChangeListeners;
1433
    }
1434

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

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

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

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

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

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

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

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

    
1584
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1585
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1586

    
1587
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1588
                selectionProvider, style);
1589

    
1590
        parentElement.addElement(section);
1591
        adapt(section);
1592
        return section;
1593

    
1594
    }
1595

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

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

    
1616

    
1617
        adapt(element);
1618
        parentElement.addElement(element);
1619
        return element;
1620
    }
1621

    
1622

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

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

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

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

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

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

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

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

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

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

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

    
1690

    
1691

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1956
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1957
        parentElement.addElement(section);
1958
        adapt(section);
1959
    }
1960

    
1961
    //--------DetailElements------------
1962

    
1963
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1964
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1965
        addAndAdaptElement(parentElement, element);
1966
        return element;
1967
    }
1968

    
1969
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1970
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1971
        addAndAdaptElement(parentElement, element);
1972
        return element;
1973
    }
1974

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

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

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

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

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

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

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

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

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

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

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

    
2041
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2042
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2043
        addAndAdaptElement(parentElement, element);
2044
        return element;
2045
    }
2046

    
2047
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2048
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2049
        adapt(element);
2050
        parentElement.addElement(element);
2051

    
2052
        return element;
2053
    }
2054

    
2055
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2056
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2057
        addAndAdaptElement(parentElement, element);
2058
        return element;
2059
    }
2060

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

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

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

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

    
2085
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2086
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2087
        addAndAdaptElement(parentElement, element);
2088
        return element;
2089
    }
2090

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

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

    
2103
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2104
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2105
        addAndAdaptElement(parentElement, element);
2106
        return element;
2107
    }
2108

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

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

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

    
2127
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2128
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2129
        addAndAdaptElement(parentElement, element);
2130
        return element;
2131
    }
2132

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

    
2139
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2140
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2141
        addAndAdaptElement(parentElement, element);
2142
        return element;
2143
    }
2144

    
2145

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2236
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2237
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2238
        addAndAdaptElement(parentElement, element);
2239
        return element;
2240
    }
2241

    
2242
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2243
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2244
        addAndAdaptElement(parentElement, mediaDetailElement);
2245
        return mediaDetailElement;
2246
    }
2247

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

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

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

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

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

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

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

    
2290
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2291
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2292
        addAndAdaptElement(parentElement, element);
2293
        return element;
2294
    }
2295

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2570

    
2571
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2572
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2573
        AbstractEntityCollectionElement element = null;
2574

    
2575
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2576

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

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

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

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

    
2748

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

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

    
2763
        return element;
2764
    }
2765

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

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

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

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

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

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

    
2887
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2888
//        Label label = new Label(formElement.getLayoutComposite(), style);
2889
//        label.setText(labelText+" (yyyy-MM-dd)");
2890
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
2891
//        dateElement.initInternalController();
2892
//        
2893
//        return dateElement;
2894
//    }
2895
    
2896
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
2897
    	 Label label = new Label(formElement.getLayoutComposite(), style);
2898
         label.setText(labelText);
2899
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2900
         DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
2901
         dateElement.initController(this, formElement);
2902
         return dateElement;
2903
    }
2904

    
2905
    /**
2906
     * <p>
2907
     * Getter for the field <code>selectionProvider</code>.
2908
     * </p>
2909
     *
2910
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2911
     */
2912
    public ISelectionProvider getSelectionProvider() {
2913
        return selectionProvider;
2914
    }
2915

    
2916
    /**
2917
     * <p>
2918
     * createDetailedDescriptionDetailElement
2919
     * </p>
2920
     *
2921
     * @param parentElement
2922
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2923
     *            object.
2924
     * @param entity
2925
     *            a
2926
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2927
     *            object.
2928
     * @param style
2929
     *            a int.
2930
     * @return a
2931
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2932
     *         object.
2933
     */
2934
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2935
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2936
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2937

    
2938
        if (entity instanceof CategoricalData) {
2939
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2940
                    (CategoricalData) entity, style);
2941
        } else if (entity instanceof CommonTaxonName) {
2942
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2943
                    style);
2944
        } else if (entity instanceof Distribution) {
2945
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2946
                    style);
2947
        } else if (entity instanceof IndividualsAssociation) {
2948
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2949
                    (IndividualsAssociation) entity, style);
2950
        } else if (entity instanceof QuantitativeData) {
2951
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2952
                    (QuantitativeData) entity, style);
2953
        } else if (entity instanceof TaxonInteraction) {
2954
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2955
                    (TaxonInteraction) entity, style);
2956
        } else if (entity instanceof TextData) {
2957
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2958
        } else {
2959
            throw new IllegalStateException("There is no interface for the given description element");
2960
        }
2961
        adapt(detailedDescriptionElement);
2962
        parentElement.addElement(detailedDescriptionElement);
2963
        return detailedDescriptionElement;
2964

    
2965
    }
2966

    
2967
    /**
2968
     * Creates a styled text as a part of the form.
2969
     *
2970
     * @param parent
2971
     *            the text parent
2972
     * @param value
2973
     *            the text initial value
2974
     * @param style
2975
     *            the text style
2976
     * @return the text widget
2977
     */
2978
    public StyledText createStyledText(Composite parent, String value, int style) {
2979
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2980
        if (value != null) {
2981
            text.setText(value);
2982
        }
2983
        text.setForeground(getColors().getForeground());
2984
        text.setBackground(getColors().getBackground());
2985
        // text.addFocusListener(visibilityHandler);
2986
        return text;
2987
    }
2988

    
2989
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2990
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2991
        addAndAdaptSection(parentElement, section);
2992
        return section;
2993
    }
2994

    
2995
    /**
2996
     * @param formElement
2997
     * @param conversationHolder
2998
     * @param style
2999
     * @return
3000
     */
3001
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3002
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3003
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3004
        addAndAdaptSection(formElement, section);
3005
        return section;
3006
    }
3007

    
3008
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3009
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3010
//				 initialText, textHeight, style);
3011
//	        adapt(element);
3012
//	        parentElement.addElement(element);
3013
//	        return element;
3014
//	}
3015

    
3016
	
3017

    
3018

    
3019

    
3020

    
3021

    
3022
}
(7-7/45)