Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
957

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1168
    private class BoldFontHolder2 {
1169
        private Font normalFont;
1170

    
1171
        private Font boldFont;
1172

    
1173
        public BoldFontHolder2() {
1174
        }
1175

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

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

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

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

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

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

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

    
1307

    
1308

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1612
    }
1613

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

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

    
1634

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

    
1640

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

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

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

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

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

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

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

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

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

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

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

    
1708

    
1709

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1979
    //--------DetailElements------------
1980

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2070
        return element;
2071
    }
2072

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2163

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2588

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

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

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

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

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

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

    
2766

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

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

    
2781
        return element;
2782
    }
2783

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

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

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

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

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

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

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

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

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

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

    
2983
    }
2984

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

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

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

    
3026

    
3027

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

    
3036
	
3037

    
3038

    
3039

    
3040

    
3041

    
3042
}
(7-7/45)