Project

General

Profile

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

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

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

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

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

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

    
356
    private BoldFontHolder2 boldFontHolder2;
357
    private MouseListener selectionMouseHandler;
358
    private FocusListener selectionFocusHandler;
359

    
360
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
361

    
362
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
363

    
364
    private final int orientation = Window.getDefaultOrientation();
365
    private ISelectionProvider selectionProvider;
366

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
929
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
930
			TermType termType,
931
			ICdmFormElement parentElement,
932
			String labelString,
933
			T selection,
934
			boolean addEmptyElement,
935
			int style) {
936
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, false, null);
937
	}
938
    
939
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
940
			TermType termType,
941
			ICdmFormElement parentElement,
942
			String labelString,
943
			T selection, 
944
			int style) {
945
		return  this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false, null);
946
	}
947
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
948
			TermType termType,
949
			ICdmFormElement parentElement,
950
			String labelString,
951
			T selection,
952
			boolean addEmptyElement,
953
			int style,
954
			boolean useAbbrevLabel) {
955
		return createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
956
	}
957

    
958

    
959
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
960
            TermVocabulary<?> termVocabulary,
961
            ICdmFormElement parentElement,
962
            String labelString,
963
            T selection,
964
            int style) {
965
        return this.createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, true, style, false, null);
966
    }
967

    
968
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
969
	        TermVocabulary<?> termVocabulary,
970
	        ICdmFormElement parentElement,
971
	        String labelString,
972
	        T selection,
973
	        boolean addEmptyElement,
974
	        int style,
975
	        boolean useAbbrevLabel) {
976
	    return createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
977
	}
978

    
979
	private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
980
	        TermType termType,
981
	        TermVocabulary<?> termVocabulary,
982
	        ICdmFormElement parentElement,
983
	        String labelString,
984
	        T selection,
985
	        boolean addEmptyElement,
986
	        int style,
987
	        boolean useAbbrevLabel,
988
	        Comparator<T> comparator) {
989
	    if(termType!=null){
990
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
991
	        if (comparator!= null){
992
	        	element.setTermComparator(comparator);
993
	        }
994
	        adapt(element);
995
	        parentElement.addElement(element);
996
	        return element;
997
	    }
998
	    else if(termVocabulary!=null){
999
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1000
	        if (comparator!= null){
1001
	        	element.setTermComparator(comparator);
1002
	        }
1003
	        adapt(element);
1004
	        parentElement.addElement(element);
1005
	        return element;
1006
	    }
1007
	    else{
1008
	        //this should never happen
1009
	        return null;
1010
	    }
1011
	}
1012

    
1013
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1014
	        Class<T> enumComboType, ICdmFormElement parentElement,
1015
	        int style) {
1016
	    return createEnumComboElement(enumComboType, parentElement, null, style);
1017
	}
1018

    
1019
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1020
			Class<T> enumComboType, ICdmFormElement parentElement, Comparator<T> comparator,
1021
			int style) {
1022
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, comparator, style);
1023
        adapt(element);
1024
        parentElement.addElement(element);
1025
        return element;
1026
    }
1027

    
1028
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
1029
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
1030
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1031
	    adapt(element);
1032
	    parentElement.addElement(element);
1033
	    return element;
1034
	}
1035

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

    
1058
    /**
1059
     * <p>
1060
     * createImageElement
1061
     * </p>
1062
     *
1063
     * @param parentElement
1064
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1065
     *            object.
1066
     * @param imageUri
1067
     *            a {@link java.net.URI} object.
1068
     * @param style
1069
     *            a int.
1070
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1071
     */
1072
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1073
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1074
        adapt(element);
1075
        parentElement.addElement(element);
1076
        return element;
1077
    }
1078

    
1079
    /**
1080
     * <p>
1081
     * createTextActionElement
1082
     * </p>
1083
     *
1084
     * @param labelString
1085
     *            a {@link java.lang.String} object.
1086
     * @param initialText
1087
     *            a {@link java.lang.String} object.
1088
     * @param style
1089
     *            a int.
1090
     * @param parentElement
1091
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1092
     *            object.
1093
     * @param buttonLabel
1094
     *            a {@link java.lang.String} object.
1095
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
1096
     *         object.
1097
     */
1098
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
1099
            String buttonLabel, String initialText, int style) {
1100
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
1101
                style);
1102
        adapt(element);
1103
        parentElement.addElement(element);
1104
        return element;
1105
    }
1106

    
1107
    /**
1108
     * <p>
1109
     * createCheckbox
1110
     * </p>
1111
     *
1112
     * @param parentElement
1113
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1114
     *            object.
1115
     * @param label
1116
     *            a {@link java.lang.String} object.
1117
     * @param initialState
1118
     *            a boolean.
1119
     * @param style
1120
     *            a int.
1121
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1122
     *         object.
1123
     */
1124
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1125
        if(initialState==null){
1126
            initialState = Boolean.FALSE;
1127
        }
1128
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1129
        adapt(element);
1130
        parentElement.addElement(element);
1131
        return element;
1132
    }
1133

    
1134
    /**
1135
     * Creates a section as a part of the form.
1136
     *
1137
     * @return the section widget
1138
     * @param section
1139
     *            a
1140
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1141
     *            object.
1142
     */
1143
    public Section adapt(AbstractFormSection section) {
1144
        section.setMenu(section.getLayoutComposite().getMenu());
1145
        adapt(section, true, true);
1146

    
1147
        // handle focus and property change events for cdm use
1148
        section.addFocusListener(selectionFocusHandler);
1149
        section.setPropertyChangeListeners(propertyChangeListeners);
1150

    
1151
        if (section.getToggle() != null) {
1152
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1153
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1154
        }
1155

    
1156
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1157

    
1158
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1159
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1160
            getColors().initializeSectionToolBarColors();
1161
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1162
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1163
        }
1164
        // call setTitleBarForeground regardless as it also sets the label color
1165
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1166
        return section;
1167
    }
1168

    
1169
    private class BoldFontHolder2 {
1170
        private Font normalFont;
1171

    
1172
        private Font boldFont;
1173

    
1174
        public BoldFontHolder2() {
1175
        }
1176

    
1177
        public Font getBoldFont(Font font) {
1178
            createBoldFont(font);
1179
            return boldFont;
1180
        }
1181

    
1182
        private void createBoldFont(Font font) {
1183
            if (normalFont == null || !normalFont.equals(font)) {
1184
                normalFont = font;
1185
                dispose();
1186
            }
1187
            if (boldFont == null) {
1188
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1189
            }
1190
        }
1191

    
1192
        public void dispose() {
1193
            if (boldFont != null) {
1194
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1195
                boldFont = null;
1196
            }
1197
        }
1198
    }
1199

    
1200
    /**
1201
     * <p>
1202
     * createToggleableTextField
1203
     * </p>
1204
     *
1205
     * @param parentElement
1206
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1207
     *            object.
1208
     * @param labelString
1209
     *            a {@link java.lang.String} object.
1210
     * @param initialText
1211
     *            a {@link java.lang.String} object.
1212
     * @param initialState
1213
     *            a boolean.
1214
     * @param style
1215
     *            a int.
1216
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1217
     *         object.
1218
     */
1219
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1220
            String initialText, boolean initialState, int style) {
1221
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1222
                initialState, style | orientation);
1223
        adapt(element);
1224
        parentElement.addElement(element);
1225
        return element;
1226
    }
1227

    
1228
    /**
1229
     * <p>
1230
     * createTimePeriodElement
1231
     * </p>
1232
     *
1233
     * @param parentElement
1234
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1235
     *            object.
1236
     * @param labelString
1237
     *            a {@link java.lang.String} object.
1238
     * @param timePeriod
1239
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1240
     * @param style
1241
     *            a int.
1242
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1243
     *         object.
1244
     */
1245
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1246
            TimePeriod timePeriod, int style) {
1247
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1248
        adapt(element);
1249
        parentElement.addElement(element);
1250
        return element;
1251
    }
1252

    
1253
	/**
1254
	 * <p>
1255
	 * createGatheringEventUnitElement
1256
	 * </p>
1257
	 *
1258
	 * @param parentElement
1259
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1260
	 *            object.
1261
	 * @param labelString
1262
	 *            a {@link java.lang.String} object.
1263
	 * @param timePeriod
1264
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1265
	 * @param style
1266
	 *            a int.
1267
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1268
	 *         object.
1269
	 */
1270
	public GatheringEventUnitElement createGatheringEventUnitElement(
1271
			ICdmFormElement parentElement,
1272
			String labelString,
1273
			DerivedUnitFacade gatheringEvent,
1274
			MinMaxTextSection.UnitType unitType,
1275
			int style) {
1276
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1277
				parentElement,
1278
				labelString,
1279
				gatheringEvent,
1280
				unitType,
1281
				style);
1282
		adapt(element);
1283
		parentElement.addElement(element);
1284
		return element;
1285
	}
1286

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

    
1308

    
1309

    
1310
    /**
1311
     * @param conversationHolder
1312
     * @param parent
1313
     * @param detailsViewer
1314
     * @param i
1315
     * @return
1316
     */
1317
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1318
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1319
        parentElement.addElement(section);
1320
        adapt(section);
1321
        return section;
1322
    }
1323

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

    
1344
	/**
1345
	 * <p>
1346
	 * createDateDetailSection
1347
	 * </p>
1348
	 *
1349
	 * @param parentElement
1350
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1351
	 *            object.
1352
	 * @param style
1353
	 *            a int.
1354
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1355
	 *         object.
1356
	 */
1357
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1358
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1359
		parentElement.addElement(section);
1360
		adapt(section);
1361
		return section;
1362
	}
1363

    
1364
    /**
1365
     * <p>
1366
     * createPartialElement
1367
     * </p>
1368
     *
1369
     * @param parentElement
1370
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1371
     *            object.
1372
     * @param labelString
1373
     *            a {@link java.lang.String} object.
1374
     * @param partial
1375
     *            a {@link org.joda.time.Partial} object.
1376
     * @param style
1377
     *            a int.
1378
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1379
     *         object.
1380
     */
1381
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1382
            int style) {
1383
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1384
        adapt(element);
1385
        parentElement.addElement(element);
1386
        return element;
1387
    }
1388

    
1389
    /**
1390
     * <p>
1391
     * addSelectionListener
1392
     * </p>
1393
     *
1394
     * @param listener
1395
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1396
     */
1397
    public void addSelectionListener(SelectionListener listener) {
1398
        selectionListenerList.add(listener);
1399
    }
1400

    
1401
    /**
1402
     * <p>
1403
     * removeSelectionListener
1404
     * </p>
1405
     *
1406
     * @param listener
1407
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1408
     */
1409
    public void removeSelectionListener(SelectionListener listener) {
1410
        if (listener == null) {
1411
            MessagingUtils.error(this.getClass(),
1412
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1413
        } else {
1414
            selectionListenerList.remove(listener);
1415
        }
1416
    }
1417

    
1418
    /**
1419
     * <p>
1420
     * addPropertyChangeListener
1421
     * </p>
1422
     *
1423
     * @param listener
1424
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1425
     *            object.
1426
     */
1427
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1428
        if (propertyChangeListeners.contains(listener)) {
1429
            return;
1430
        }
1431
        propertyChangeListeners.add(0, listener);
1432
    }
1433

    
1434
    /**
1435
     * <p>
1436
     * removePropertyChangeListener
1437
     * </p>
1438
     *
1439
     * @param listener
1440
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1441
     *            object.
1442
     */
1443
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1444
        propertyChangeListeners.remove(listener);
1445
    }
1446

    
1447
    /**
1448
     * @return the propertyChangeListeners
1449
     */
1450
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1451
        return propertyChangeListeners;
1452
    }
1453

    
1454
    /**
1455
     * <p>
1456
     * createHorizontalSeparator
1457
     * </p>
1458
     *
1459
     * @param parentElement
1460
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1461
     *            object.
1462
     * @param style
1463
     *            a int.
1464
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1465
     */
1466
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1467
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1468
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1469
        return separator;
1470
    }
1471

    
1472
    /**
1473
     * <p>
1474
     * createVersionElement
1475
     * </p>
1476
     *
1477
     * @param parentElement
1478
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1479
     *            object.
1480
     * @param entity
1481
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1482
     *            object.
1483
     * @param style
1484
     *            a int.
1485
     * @return a
1486
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1487
     *         object.
1488
     */
1489
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1490
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1491
        adapt(element);
1492
        parentElement.addElement(element);
1493
        return element;
1494
    }
1495

    
1496
    /**
1497
     * @param cdmBaseSection
1498
     * @param object
1499
     * @param style
1500
     * @return
1501
     */
1502
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1503
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1504
        adapt(element);
1505
        parentElement.addElement(element);
1506
        return element;
1507
    }
1508

    
1509
    /**
1510
     * <p>
1511
     * createVersionSection
1512
     * </p>
1513
     *
1514
     * @param parentElement
1515
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1516
     *            object.
1517
     * @param style
1518
     *            a int.
1519
     * @return a
1520
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1521
     *         object.
1522
     */
1523
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1524
        VersionSection section = new VersionSection(this, parentElement, style);
1525
        parentElement.addElement(section);
1526
        adapt(section);
1527
        return section;
1528
    }
1529

    
1530
    /**
1531
     * @param parent
1532
     * @param i
1533
     * @return
1534
     */
1535
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1536
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1537
        parentElement.addElement(section);
1538
        adapt(section);
1539
        return section;
1540
    }
1541

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

    
1559
    /**
1560
     * <p>
1561
     * createHeadlineSection
1562
     * </p>
1563
     *
1564
     * @param parentElement
1565
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1566
     *            object.
1567
     * @return a
1568
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1569
     *         object.
1570
     */
1571
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1572
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1573
        parentElement.addElement(section);
1574
        adapt(section);
1575
        return section;
1576
    }
1577

    
1578
    /**
1579
     * <p>
1580
     * createParsingMessageElement
1581
     * </p>
1582
     *
1583
     * @param parentElement
1584
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1585
     *            object.
1586
     * @param parserProblem
1587
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1588
     *            object.
1589
     * @param style
1590
     *            a int.
1591
     * @return a
1592
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1593
     *         object.
1594
     */
1595
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1596
            ParserProblem parserProblem, int style) {
1597
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1598
        adapt(element);
1599
        parentElement.addElement(element);
1600
        return element;
1601
    }
1602

    
1603
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1604
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1605

    
1606
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1607
                selectionProvider, style);
1608

    
1609
        parentElement.addElement(section);
1610
        adapt(section);
1611
        return section;
1612

    
1613
    }
1614

    
1615
    /**
1616
     * @param definedTermClass
1617
     * @param formElement
1618
     * @param style
1619
     * @return
1620
     */
1621
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1622
            AbstractCdmDetailSection parentElement, int style) {
1623
        AbstractCdmDetailElement element = null;
1624

    
1625
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1626
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1627
        } else if (definedTermClass.equals(Feature.class)) {
1628
            element = new FeatureDetailElement(this, parentElement);
1629
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1630
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1631
        } else {
1632
            element = new DefinedTermDetailElement(this, parentElement);
1633
        }
1634

    
1635

    
1636
        adapt(element);
1637
        parentElement.addElement(element);
1638
        return element;
1639
    }
1640

    
1641

    
1642
    //--------DetailSections---------
1643
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1644
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1645
        addAndAdaptSection(parentElement, section);
1646
        return section;
1647
    }
1648

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

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

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

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

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

    
1679
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1680
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1681
        addAndAdaptSection(parentElement, section);
1682
        return section;
1683
    }
1684

    
1685
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1686
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1687
        addAndAdaptSection(parentElement, section);
1688
        return section;
1689
    }
1690

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

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

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

    
1709

    
1710

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1957
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1958
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1959
        addAndAdaptSection(parentElement, section);
1960
        return section;
1961
    }
1962

    
1963
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1964
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
1965
        addAndAdaptSection(parentElement, section);
1966
        return section;
1967
    }
1968

    
1969
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1970
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
1971
        addAndAdaptSection(parentElement, section);
1972
        return section;
1973
    }
1974

    
1975
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1976
        parentElement.addElement(section);
1977
        adapt(section);
1978
    }
1979

    
1980
    //--------DetailElements------------
1981

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

    
1988
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1989
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1990
        addAndAdaptElement(parentElement, element);
1991
        return element;
1992
    }
1993

    
1994
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1995
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1996
        addAndAdaptElement(parentElement, element);
1997
        return element;
1998
    }
1999

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

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

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

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

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

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

    
2036
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2037
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2038
        addAndAdaptElement(parentElement, element);
2039
        return element;
2040
    }
2041

    
2042
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2043
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2044
        addAndAdaptElement(parentElement, element);
2045
        return element;
2046
    }
2047

    
2048
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2049
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2050
        addAndAdaptElement(parentElement, element);
2051
        return element;
2052
    }
2053

    
2054
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2055
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2056
        addAndAdaptElement(parentElement, element);
2057
        return element;
2058
    }
2059

    
2060
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2061
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2062
        addAndAdaptElement(parentElement, element);
2063
        return element;
2064
    }
2065

    
2066
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2067
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2068
        adapt(element);
2069
        parentElement.addElement(element);
2070

    
2071
        return element;
2072
    }
2073

    
2074
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2075
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2076
        addAndAdaptElement(parentElement, element);
2077
        return element;
2078
    }
2079

    
2080
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
2081
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
2082
        addAndAdaptElement(parentElement, element);
2083
        return element;
2084
    }
2085

    
2086
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2087
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2088
        addAndAdaptElement(parentElement, element);
2089
        return element;
2090
    }
2091

    
2092
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2093
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2094
        addAndAdaptElement(parentElement, element);
2095
        return element;
2096
    }
2097

    
2098
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2099
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2100
        addAndAdaptElement(parentElement, element);
2101
        return element;
2102
    }
2103

    
2104
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2105
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2106
        addAndAdaptElement(parentElement, element);
2107
        return element;
2108
    }
2109

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

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

    
2122
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2123
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2124
        addAndAdaptElement(parentElement, element);
2125
        return element;
2126
    }
2127

    
2128
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2129
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2130
        addAndAdaptElement(parentElement, element);
2131
        return element;
2132
    }
2133

    
2134
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2135
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2136
        addAndAdaptElement(parentElement, element);
2137
        return element;
2138
    }
2139

    
2140
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2141
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2142
        addAndAdaptElement(parentElement, element);
2143
        return element;
2144
    }
2145

    
2146
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2147
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2148
        addAndAdaptElement(parentElement, element);
2149
        return element;
2150
    }
2151

    
2152
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2153
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2154
        addAndAdaptElement(parentElement, element);
2155
        return element;
2156
    }
2157

    
2158
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2159
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2160
        addAndAdaptElement(parentElement, element);
2161
        return element;
2162
    }
2163

    
2164

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

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

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

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

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

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

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

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

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

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

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

    
2231
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2232
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2233
        addAndAdaptElement(parentElement, element);
2234
        return element;
2235
    }
2236

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

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

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

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

    
2261
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2262
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2263
        addAndAdaptElement(parentElement, mediaDetailElement);
2264
        return mediaDetailElement;
2265
    }
2266

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

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

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

    
2285
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2286
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2287
        addAndAdaptElement(parentElement, element);
2288
        return element;
2289
    }
2290

    
2291
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2292
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2293
        addAndAdaptElement(parentElement, element);
2294
        return element;
2295
    }
2296

    
2297
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2298
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2299
        addAndAdaptElement(parentElement, element);
2300
        return element;
2301
    }
2302

    
2303
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2304
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2305
        addAndAdaptElement(parentElement, element);
2306
        return element;
2307
    }
2308

    
2309
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2310
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2311
        addAndAdaptElement(parentElement, element);
2312
        return element;
2313
    }
2314

    
2315
    /**
2316
     * @param parentElement
2317
     * @param element
2318
     */
2319
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2320
        adapt(element);
2321
        parentElement.addElement(element);
2322
    }
2323

    
2324
    //--------EntityCollectionSection----------
2325
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2326
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2327
        addAndAdaptSection(parentElement, section);
2328
        return section;
2329
    }
2330

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2571
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2572
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2573
        addAndAdaptSection(parentElement, section);
2574
        return section;
2575
    }
2576

    
2577
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2578
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2579
        addAndAdaptSection(parentElement, section);
2580
        return section;
2581
    }
2582

    
2583
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2584
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2585
        addAndAdaptSection(parentElement, section);
2586
        return section;
2587
    }
2588

    
2589

    
2590
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2591
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2592
        AbstractEntityCollectionElement element = null;
2593

    
2594
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2595

    
2596
        if (entity instanceof Annotation) {
2597
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2598
        }else if (entity instanceof Person ) {
2599
            boolean isNomenclatural = false;
2600
            if (parentElement instanceof TeamMemberSection){
2601
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2602
            }
2603
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2604
        } else if (entity instanceof Credit) {
2605
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2606
        } else if (entity instanceof Extension) {
2607
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2608
        } else if (entity instanceof Marker) {
2609
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2610
        } else if (entity instanceof TaxonNodeAgentRelation) {
2611
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2612
        }else if (entity instanceof Media) {
2613
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2614
        } else if (entity instanceof MediaRepresentation) {
2615
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2616
                    style);
2617
        } else if (entity instanceof ImageFile) {
2618
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2619
        } else if (entity instanceof MediaRepresentationPart) {
2620
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2621
                    removeListener, style);
2622
        } else if (entity instanceof NomenclaturalStatus) {
2623
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2624
                    style);
2625
        } else if (entity instanceof Rights) {
2626
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2627
        } else if (entity instanceof DescriptionElementSource) {
2628
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2629
                    removeListener, style);
2630
        } else if (entity instanceof TaxonNodeAgentRelation) {
2631
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2632
                    removeListener,backgroundColor, style);
2633
        }
2634
        else if (entity instanceof IdentifiableSource) {
2635
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2636
                    style);
2637
        } else if (entity instanceof DefinedTerm) {
2638
            switch(((DefinedTerm)entity).getTermType()) {
2639
            case Scope:
2640
                element = new ScopeElement(this,
2641
                        parentElement,
2642
                        (DefinedTerm) entity,
2643
                        removeListener,
2644
                        style);
2645
                break;
2646
            case Modifier:
2647
                element = new ModifierElement(this,
2648
                        parentElement,
2649
                        (DefinedTerm) entity,
2650
                        removeListener,
2651
                        style);
2652
                break;
2653
            default:
2654
                break;
2655

    
2656
            }
2657
        } else if (entity instanceof Reference) {
2658
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2659
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2660
            }
2661
            else{
2662
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2663
            }
2664
        } else if (entity instanceof NameTypeDesignation) {
2665
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2666
                    style);
2667
        } else if (entity instanceof NameRelationship) {
2668
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2669
                    style);
2670
        } else if (entity instanceof SpecimenTypeDesignation) {
2671
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
2672
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2673
                        removeListener, style);
2674
            }
2675
            else{
2676
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2677
                        removeListener, style);
2678
            }
2679
        } else if (entity instanceof StateData) {
2680
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2681
        } else if (entity instanceof StatisticalMeasurementValue) {
2682
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2683
                    removeListener, style);
2684
        } else if (entity instanceof DerivedUnit) {
2685
            switch(((DerivedUnit)entity).getRecordBasis()) {
2686
            case LivingSpecimen:
2687
            case PreservedSpecimen:
2688
            case OtherSpecimen:
2689
                element = new SpecimenCollectionDetailElement(this,
2690
                        parentElement,
2691
                        (DerivedUnit) entity,
2692
                        removeListener,
2693
                        style);
2694
                break;
2695
            default:
2696
                element = new DerivedUnitElement(this,
2697
                        parentElement,
2698
                        (DerivedUnit) entity,
2699
                        removeListener,
2700
                        style);
2701
            }
2702

    
2703
        } else if (entity instanceof NamedArea) {
2704
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2705
        } else if (entity instanceof DeterminationEvent) {
2706
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2707
        } else if (entity instanceof User) {
2708
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2709
        } else if (entity instanceof GrantedAuthority) {
2710
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
2711
                    removeListener, style);
2712
        } else if (entity instanceof Group) {
2713
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2714
        } else if (entity instanceof Taxon) {
2715
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2716
        } else if (entity instanceof DescriptionElementBase) {
2717
            // this is the special case for protologs, maybe we can do this
2718
            // differently when API improves
2719
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2720
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2721
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2722
            }
2723
        } else if (entity instanceof Identifier) {
2724
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2725
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2726
            }
2727
            else{
2728
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
2729
            }
2730
        } else if (entity instanceof TermVocabulary) {
2731
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
2732
            switch (termVocabulary.getTermType()) {
2733
            case State:
2734
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
2735
                break;
2736
            case Modifier:
2737
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
2738
                break;
2739
            default:
2740
                break;
2741
            }
2742
        } else if (entity instanceof MeasurementUnit) {
2743
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2744
        } else if (entity instanceof StatisticalMeasure) {
2745
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2746
        }
2747

    
2748
        //check for parent section when entity is null
2749
        //this happens when AbstractUnboundEntityCollectionSection is used
2750
        if(entity==null){
2751
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
2752
                element = new ScopeElement(this,
2753
                        parentElement,
2754
                        (DefinedTerm) entity,
2755
                        removeListener,
2756
                        style);
2757
            }
2758
            else if(parentElement instanceof ModifierSection){
2759
                element = new ModifierElement(this,
2760
                        parentElement,
2761
                        (DefinedTerm) entity,
2762
                        removeListener,
2763
                        style);
2764
            }
2765
        }
2766

    
2767

    
2768
        if (element == null) {
2769
            MessagingUtils.messageDialog("No element for entity", this,
2770
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2771
                            + entity, null);
2772
        }
2773

    
2774
        else{
2775
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2776
                element.setPersistentBackground(backgroundColor);
2777
            }
2778
            adapt(element);
2779
            parentElement.addElement(element);
2780
        }
2781

    
2782
        return element;
2783
    }
2784

    
2785
    /**
2786
     * <p>
2787
     * Creates a selection element for the given type T.
2788
     * </p>
2789
     * <p>
2790
     * <strong>Selection elements not handled by this method:</strong>
2791
     * <ul>
2792
     * <li>{@link TaxonNodeSelectionElement} see
2793
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2794
     * </li>
2795
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2796
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2797
     * </li>
2798
     * </ul>
2799
     * </p>
2800
     *
2801
     * @param clazz
2802
     *            a {@link Class} object of the type that you want the selection
2803
     *            element to handle
2804
     * @param parentElement
2805
     *            a {@link ICdmFormElement} object.
2806
     * @param labelString
2807
     *            a {@link String} object.
2808
     * @param selectionType
2809
     * @param selection
2810
     *            a {@link ICdmBase} object.
2811
     * @param style
2812
     *            a int.
2813
     * @param conversation
2814
     *            a {@link ConversationHolder} object.
2815
     * @return a {@link EntitySelectionElement} object.
2816
     */
2817
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2818
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2819
            int style, boolean filterElement) {
2820
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2821
                labelString, selection, mode, style, filterElement);
2822
        adapt(element);
2823
        parentElement.addElement(element);
2824
        return element;
2825
    }
2826

    
2827
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2828
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2829
            int style) {
2830
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2831
                labelString, selection, mode, style);
2832
        adapt(element);
2833
        parentElement.addElement(element);
2834
        return element;
2835
    }
2836

    
2837
    /**
2838
     * <p>
2839
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
2840
     * </p>
2841
     * <p>
2842
     * <strong>Selection elements not handled by this method:</strong>
2843
     * <ul>
2844
     * <li>{@link TaxonNodeSelectionElement} see
2845
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2846
     * </li>
2847
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2848
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2849
     * </li>
2850
     * </ul>
2851
     * </p>
2852
     *
2853
     * @param clazz
2854
     *            a {@link Class} object of the type that you want the selection
2855
     *            element to handle
2856
     * @param parentElement
2857
     *            a {@link ICdmFormElement} object.
2858
     * @param labelString
2859
     *            a {@link String} object.
2860
     * @param selectionType
2861
     * @param selection
2862
     *            a {@link ICdmBase} object.
2863
     * @param style
2864
     *            a int.
2865
     * @param conversation
2866
     *            a {@link ConversationHolder} object.
2867
     * @return a {@link EntitySelectionElement} object.
2868
     */
2869
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
2870
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
2871
            T selection, int mode, int style) {
2872
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, conversation, parentElement, clazz,
2873
                labelString, selection, mode, style);
2874
        adapt(element);
2875
        parentElement.addElement(element);
2876
        return element;
2877
    }
2878

    
2879
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2880
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2881
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2882
                labelString, selection, mode, style);
2883
        adapt(element);
2884
        parentElement.addElement(element);
2885
        return element;
2886
    }
2887

    
2888
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2889
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2890
//            int mode, int style) {
2891
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2892
//                conversation, parentElement, labelString, selection, mode, style);
2893
//        adapt(element);
2894
//        parentElement.addElement(element);
2895
//        return element;
2896
//    }
2897

    
2898
    /** {@inheritDoc} */
2899
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2900
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2901
        adapt(labelElement);
2902
        parentElement.addElement(labelElement);
2903
        return labelElement;
2904
    }
2905

    
2906
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2907
//        Label label = new Label(formElement.getLayoutComposite(), style);
2908
//        label.setText(labelText+" (yyyy-MM-dd)");
2909
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
2910
//        dateElement.initInternalController();
2911
//        
2912
//        return dateElement;
2913
//    }
2914
    
2915
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, ZonedDateTime dateTime, int style, boolean editableText){
2916
    	 Label label = new Label(formElement.getLayoutComposite(), style);
2917
         label.setText(labelText);
2918
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2919
         DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
2920
         dateElement.initController(this, formElement);
2921
         return dateElement;
2922
    }
2923

    
2924
    /**
2925
     * <p>
2926
     * Getter for the field <code>selectionProvider</code>.
2927
     * </p>
2928
     *
2929
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2930
     */
2931
    public ISelectionProvider getSelectionProvider() {
2932
        return selectionProvider;
2933
    }
2934

    
2935
    /**
2936
     * <p>
2937
     * createDetailedDescriptionDetailElement
2938
     * </p>
2939
     *
2940
     * @param parentElement
2941
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2942
     *            object.
2943
     * @param entity
2944
     *            a
2945
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2946
     *            object.
2947
     * @param style
2948
     *            a int.
2949
     * @return a
2950
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2951
     *         object.
2952
     */
2953
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2954
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2955
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2956

    
2957
        if (entity instanceof CategoricalData) {
2958
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2959
                    (CategoricalData) entity, style);
2960
        } else if (entity instanceof CommonTaxonName) {
2961
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2962
                    style);
2963
        } else if (entity instanceof Distribution) {
2964
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2965
                    style);
2966
        } else if (entity instanceof IndividualsAssociation) {
2967
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2968
                    (IndividualsAssociation) entity, style);
2969
        } else if (entity instanceof QuantitativeData) {
2970
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2971
                    (QuantitativeData) entity, style);
2972
        } else if (entity instanceof TaxonInteraction) {
2973
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2974
                    (TaxonInteraction) entity, style);
2975
        } else if (entity instanceof TextData) {
2976
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2977
        } else {
2978
            throw new IllegalStateException("There is no interface for the given description element");
2979
        }
2980
        adapt(detailedDescriptionElement);
2981
        parentElement.addElement(detailedDescriptionElement);
2982
        return detailedDescriptionElement;
2983

    
2984
    }
2985

    
2986
    /**
2987
     * Creates a styled text as a part of the form.
2988
     *
2989
     * @param parent
2990
     *            the text parent
2991
     * @param value
2992
     *            the text initial value
2993
     * @param style
2994
     *            the text style
2995
     * @return the text widget
2996
     */
2997
    public StyledText createStyledText(Composite parent, String value, int style) {
2998
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2999
        if (value != null) {
3000
            text.setText(value);
3001
        }
3002
        text.setForeground(getColors().getForeground());
3003
        text.setBackground(getColors().getBackground());
3004
        // text.addFocusListener(visibilityHandler);
3005
        return text;
3006
    }
3007

    
3008
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3009
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3010
        addAndAdaptSection(parentElement, section);
3011
        return section;
3012
    }
3013

    
3014
    /**
3015
     * @param formElement
3016
     * @param conversationHolder
3017
     * @param style
3018
     * @return
3019
     */
3020
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3021
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3022
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3023
        addAndAdaptSection(formElement, section);
3024
        return section;
3025
    }
3026

    
3027

    
3028

    
3029
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3030
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3031
//				 initialText, textHeight, style);
3032
//	        adapt(element);
3033
//	        parentElement.addElement(element);
3034
//	        return element;
3035
//	}
3036

    
3037
	
3038

    
3039

    
3040

    
3041

    
3042

    
3043
}
(7-7/45)