Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
514
        super.adapt(composite);
515
    }
516

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
925
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
926
			TermType termType,
927
			ICdmFormElement parentElement,
928
			String labelString,
929
			T selection,
930
			boolean addEmptyElement,
931
			int style) {
932
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, false, null);
933
	}
934

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

    
954

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

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

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

    
1009
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1010
	        Class<T> enumComboType, ICdmFormElement parentElement,
1011
	        int style) {
1012
	    return createEnumComboElement(enumComboType, parentElement, null, style);
1013
	}
1014

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

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

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

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

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

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

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

    
1143
        // handle focus and property change events for cdm use
1144
        section.addFocusListener(selectionFocusHandler);
1145
        section.setPropertyChangeListeners(propertyChangeListeners);
1146

    
1147
        if (section.getToggle() != null) {
1148
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1149
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1150
        }
1151

    
1152
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1153

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

    
1165
    private class BoldFontHolder2 {
1166
        private Font normalFont;
1167

    
1168
        private Font boldFont;
1169

    
1170
        public BoldFontHolder2() {
1171
        }
1172

    
1173
        public Font getBoldFont(Font font) {
1174
            createBoldFont(font);
1175
            return boldFont;
1176
        }
1177

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

    
1188
        public void dispose() {
1189
            if (boldFont != null) {
1190
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1191
                boldFont = null;
1192
            }
1193
        }
1194
    }
1195

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

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

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

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

    
1304

    
1305

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

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

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

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

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

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

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

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

    
1443
    /**
1444
     * @return the propertyChangeListeners
1445
     */
1446
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1447
        return propertyChangeListeners;
1448
    }
1449

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

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

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

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

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

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

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

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

    
1599
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1600
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1601

    
1602
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1603
                selectionProvider, style);
1604

    
1605
        parentElement.addElement(section);
1606
        adapt(section);
1607
        return section;
1608

    
1609
    }
1610

    
1611
    /**
1612
     * @param definedTermClass
1613
     * @param formElement
1614
     * @param style
1615
     * @return
1616
     */
1617
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1618
            AbstractCdmDetailSection parentElement, int style) {
1619
        AbstractCdmDetailElement element = null;
1620

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

    
1631

    
1632
        adapt(element);
1633
        parentElement.addElement(element);
1634
        return element;
1635
    }
1636

    
1637

    
1638
    //--------DetailSections---------
1639
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1640
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1641
        addAndAdaptSection(parentElement, section);
1642
        return section;
1643
    }
1644

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

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

    
1657
    public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1658
        TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1659
        addAndAdaptSection(parentElement, section);
1660
        return section;
1661
    }
1662

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

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

    
1675
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1676
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1677
        addAndAdaptSection(parentElement, section);
1678
        return section;
1679
    }
1680

    
1681
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1682
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1683
        addAndAdaptSection(parentElement, section);
1684
        return section;
1685
    }
1686

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

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

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

    
1705

    
1706

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1953
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1954
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1955
        addAndAdaptSection(parentElement, section);
1956
        return section;
1957
    }
1958

    
1959
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1960
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
1961
        addAndAdaptSection(parentElement, section);
1962
        return section;
1963
    }
1964

    
1965
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1966
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
1967
        addAndAdaptSection(parentElement, section);
1968
        return section;
1969
    }
1970

    
1971
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1972
        parentElement.addElement(section);
1973
        adapt(section);
1974
    }
1975

    
1976
    //--------DetailElements------------
1977

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

    
1984
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1985
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1986
        addAndAdaptElement(parentElement, element);
1987
        return element;
1988
    }
1989

    
1990
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1991
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1992
        addAndAdaptElement(parentElement, element);
1993
        return element;
1994
    }
1995

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

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

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

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

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

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

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

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

    
2044
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2045
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2046
        addAndAdaptElement(parentElement, element);
2047
        return element;
2048
    }
2049

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

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

    
2062
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2063
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2064
        adapt(element);
2065
        parentElement.addElement(element);
2066

    
2067
        return element;
2068
    }
2069

    
2070
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2071
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2072
        addAndAdaptElement(parentElement, element);
2073
        return element;
2074
    }
2075

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

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

    
2088
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2089
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2090
        addAndAdaptElement(parentElement, element);
2091
        return element;
2092
    }
2093

    
2094
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2095
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2096
        addAndAdaptElement(parentElement, element);
2097
        return element;
2098
    }
2099

    
2100
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2101
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2102
        addAndAdaptElement(parentElement, element);
2103
        return element;
2104
    }
2105

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

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

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

    
2124
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2125
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2126
        addAndAdaptElement(parentElement, element);
2127
        return element;
2128
    }
2129

    
2130
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2131
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2132
        addAndAdaptElement(parentElement, element);
2133
        return element;
2134
    }
2135

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

    
2142
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2143
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2144
        addAndAdaptElement(parentElement, element);
2145
        return element;
2146
    }
2147

    
2148
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2149
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2150
        addAndAdaptElement(parentElement, element);
2151
        return element;
2152
    }
2153

    
2154
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2155
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2156
        addAndAdaptElement(parentElement, element);
2157
        return element;
2158
    }
2159

    
2160

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2257
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2258
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2259
        addAndAdaptElement(parentElement, mediaDetailElement);
2260
        return mediaDetailElement;
2261
    }
2262

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

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

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

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

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

    
2293
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2294
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2295
        addAndAdaptElement(parentElement, element);
2296
        return element;
2297
    }
2298

    
2299
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2300
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2301
        addAndAdaptElement(parentElement, element);
2302
        return element;
2303
    }
2304

    
2305
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2306
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2307
        addAndAdaptElement(parentElement, element);
2308
        return element;
2309
    }
2310

    
2311
    /**
2312
     * @param parentElement
2313
     * @param element
2314
     */
2315
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2316
        adapt(element);
2317
        parentElement.addElement(element);
2318
    }
2319

    
2320
    //--------EntityCollectionSection----------
2321
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2322
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2323
        addAndAdaptSection(parentElement, section);
2324
        return section;
2325
    }
2326

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2567
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2568
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2569
        addAndAdaptSection(parentElement, section);
2570
        return section;
2571
    }
2572

    
2573
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2574
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2575
        addAndAdaptSection(parentElement, section);
2576
        return section;
2577
    }
2578

    
2579
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2580
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2581
        addAndAdaptSection(parentElement, section);
2582
        return section;
2583
    }
2584

    
2585

    
2586
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2587
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2588
        AbstractEntityCollectionElement element = null;
2589

    
2590
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2591

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

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

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

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

    
2763

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

    
2770
        else{
2771
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2772
                element.setPersistentBackground(backgroundColor);
2773
            }
2774
            adapt(element);
2775
            parentElement.addElement(element);
2776
        }
2777

    
2778
        return element;
2779
    }
2780

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

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

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

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

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

    
2894
    /** {@inheritDoc} */
2895
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2896
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2897
        adapt(labelElement);
2898
        parentElement.addElement(labelElement);
2899
        return labelElement;
2900
    }
2901

    
2902
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2903
//        Label label = new Label(formElement.getLayoutComposite(), style);
2904
//        label.setText(labelText+" (yyyy-MM-dd)");
2905
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
2906
//        dateElement.initInternalController();
2907
//
2908
//        return dateElement;
2909
//    }
2910

    
2911
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
2912
    	 Label label = new Label(formElement.getLayoutComposite(), style);
2913
         label.setText(labelText);
2914
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2915
         DateElement dateElement = new DateElement(this, formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
2916
         dateElement.initController(this, formElement);
2917
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2918
         return dateElement;
2919
    }
2920

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

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

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

    
2981
    }
2982

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

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

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

    
3024

    
3025
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3026
			ICdmFormElement parentElement, int style) {
3027
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3028
		addAndAdaptElement(parentElement, section);
3029
        return section;
3030
	}
3031

    
3032
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3033
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3034
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3035
	        addAndAdaptSection(formElement, section);
3036
	        return section;
3037
	}
3038

    
3039

    
3040

    
3041
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3042
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3043
//				 initialText, textHeight, style);
3044
//	        adapt(element);
3045
//	        parentElement.addElement(element);
3046
//	        return element;
3047
//	}
3048

    
3049

    
3050

    
3051

    
3052

    
3053

    
3054

    
3055
}
(7-7/45)