Project

General

Profile

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

    
6
import java.net.URI;
7

    
8
import java.util.ArrayList;
9
import java.util.Comparator;
10
import java.util.HashSet;
11
import java.util.List;
12
import java.util.Map;
13
import java.util.Set;
14

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

    
49
import org.joda.time.Partial;
50
import org.springframework.security.core.GrantedAuthority;
51

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

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

    
349
/**
350
 * <p>
351
 * CdmFormFactory class.
352
 * </p>
353
 *
354
 * @author n.hoffmann
355
 * @created Feb 24, 2010
356
 * @version 1.0
357
 */
358
public class CdmFormFactory extends FormToolkit {
359

    
360
    private BoldFontHolder2 boldFontHolder2;
361
    private MouseListener selectionMouseHandler;
362
    private FocusListener selectionFocusHandler;
363

    
364
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
365

    
366
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
367

    
368
    private final int orientation = Window.getDefaultOrientation();
369
    private ISelectionProvider selectionProvider;
370

    
371
    /** Constant <code>EMPTY_SELECTION</code> */
372
    public static ISelection EMPTY_SELECTION = new ISelection() {
373
        @Override
374
        public boolean isEmpty() {
375
            return true;
376
        }
377
    };
378

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

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

    
405
    private void notifySelectionListeners(TypedEvent e) {
406
        Event event = new Event();
407
        event.widget = e.widget;
408
        SelectionEvent selectionEvent = new SelectionEvent(event);
409

    
410
        for (SelectionListener listener : selectionListenerList) {
411
            listener.widgetSelected(selectionEvent);
412
        }
413
    }
414

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

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

    
444
    /**
445
	 *
446
	 */
447
    private void init() {
448
        boldFontHolder2 = new BoldFontHolder2();
449
        selectionMouseHandler = new SelectionMouseHandler();
450
        selectionFocusHandler = new SelectionFocusHandler();
451
    }
452

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

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

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

    
508
    /** {@inheritDoc} */
509
    @Override
510
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
511
        if (trackFocus) {
512
            control.addFocusListener(selectionFocusHandler);
513
        }
514
        super.adapt(control, trackFocus, trackKeyboard);
515
    }
516

    
517
    /** {@inheritDoc} */
518
    @Override
519
    public void adapt(Composite composite) {
520
        composite.addMouseListener(selectionMouseHandler);
521
       
522
        super.adapt(composite);
523
    }
524

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

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

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

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

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

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

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

    
712
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
713
            KeyStatement keyStatement, int textHeight, int style) {
714
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
715
                textHeight, style);
716
        adapt(element);
717
        parentElement.addElement(element);
718
        return element;
719
    }
720

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

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

    
781
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
782
                textLimit, style);
783
        adapt(element);
784
        parentElement.addElement(element);
785
        return element;
786
    }
787

    
788
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
789
            int textHeight, int style) {
790
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
791
        adapt(element);
792
        parentElement.addElement(element);
793
        return element;
794
    }
795

    
796
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
797
            LSID initialLsid, int style) {
798
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
799
        adapt(element);
800
        parentElement.addElement(element);
801
        return element;
802
    }
803

    
804
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
805
            URI initialUri, int style) {
806
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
807
        adapt(element);
808
        parentElement.addElement(element);
809
        return element;
810
    }
811

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

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

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

    
873
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
874
            String labelString, LanguageString languageString, int style) {
875
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
876
    }
877

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

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

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

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

    
962

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

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

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

    
1017
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1018
	        Class<T> enumComboType, ICdmFormElement parentElement,
1019
	        int style) {
1020
	    return createEnumComboElement(enumComboType, parentElement, null, style);
1021
	}
1022

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

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

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

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

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

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

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

    
1151
        // handle focus and property change events for cdm use
1152
        section.addFocusListener(selectionFocusHandler);
1153
        section.setPropertyChangeListeners(propertyChangeListeners);
1154

    
1155
        if (section.getToggle() != null) {
1156
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1157
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1158
        }
1159

    
1160
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1161

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

    
1173
    private class BoldFontHolder2 {
1174
        private Font normalFont;
1175

    
1176
        private Font boldFont;
1177

    
1178
        public BoldFontHolder2() {
1179
        }
1180

    
1181
        public Font getBoldFont(Font font) {
1182
            createBoldFont(font);
1183
            return boldFont;
1184
        }
1185

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

    
1196
        public void dispose() {
1197
            if (boldFont != null) {
1198
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1199
                boldFont = null;
1200
            }
1201
        }
1202
    }
1203

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

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

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

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

    
1312

    
1313

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

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

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

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

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

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

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

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

    
1451
    /**
1452
     * @return the propertyChangeListeners
1453
     */
1454
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1455
        return propertyChangeListeners;
1456
    }
1457

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

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

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

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

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

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

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

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

    
1607
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1608
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1609

    
1610
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1611
                selectionProvider, style);
1612

    
1613
        parentElement.addElement(section);
1614
        adapt(section);
1615
        return section;
1616

    
1617
    }
1618

    
1619
    /**
1620
     * @param definedTermClass
1621
     * @param formElement
1622
     * @param style
1623
     * @return
1624
     */
1625
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1626
            AbstractCdmDetailSection parentElement, int style) {
1627
        AbstractCdmDetailElement element = null;
1628

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

    
1639

    
1640
        adapt(element);
1641
        parentElement.addElement(element);
1642
        return element;
1643
    }
1644

    
1645

    
1646
    //--------DetailSections---------
1647
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1648
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1649
        addAndAdaptSection(parentElement, section);
1650
        return section;
1651
    }
1652

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

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

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

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

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

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

    
1689
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1690
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1691
        addAndAdaptSection(parentElement, section);
1692
        return section;
1693
    }
1694

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

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

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

    
1713

    
1714

    
1715
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, boolean nameChoosable, int style){
1716
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, nameChoosable, style);
1717
        addAndAdaptSection(parentElement, section);
1718
        return section;
1719
    }
1720

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1871
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1872
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1873
        addAndAdaptSection(parentElement, section);
1874
        return section;
1875
    }
1876

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

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

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

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

    
1901
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1902
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1903
        addAndAdaptSection(parentElement, section);
1904
        return section;
1905
    }
1906

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

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

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

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

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

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

    
1943
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1944
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style, true);
1945
        addAndAdaptSection(parentElement, section);
1946
        return section;
1947
    }
1948

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

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

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

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

    
1973
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1974
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
1975
        addAndAdaptSection(parentElement, section);
1976
        return section;
1977
    }
1978

    
1979
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1980
        parentElement.addElement(section);
1981
        adapt(section);
1982
    }
1983

    
1984
    //--------DetailElements------------
1985

    
1986
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1987
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1988
        addAndAdaptElement(parentElement, element);
1989
        return element;
1990
    }
1991

    
1992
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1993
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1994
        addAndAdaptElement(parentElement, element);
1995
        return element;
1996
    }
1997

    
1998
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1999
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
2000
        addAndAdaptElement(parentElement, element);
2001
        return element;
2002
    }
2003

    
2004
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
2005
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
2006
        addAndAdaptElement(parentElement, element);
2007
        return element;
2008
    }
2009

    
2010
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
2011
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
2012
        addAndAdaptElement(parentElement, element);
2013
        return element;
2014
    }
2015

    
2016
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
2017
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
2018
        addAndAdaptElement(parentElement, element);
2019
        return element;
2020
    }
2021

    
2022
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
2023
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2024
        addAndAdaptElement(parentElement, element);
2025
        return element;
2026
    }
2027

    
2028
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2029
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2030
        addAndAdaptElement(parentElement, element);
2031
        return element;
2032
    }
2033

    
2034
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2035
        UserDetailElement element = new UserDetailElement(this, parentElement);
2036
        addAndAdaptElement(parentElement, element);
2037
        return element;
2038
    }
2039

    
2040
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2041
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2042
        addAndAdaptElement(parentElement, element);
2043
        return element;
2044
    }
2045

    
2046
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2047
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2048
        addAndAdaptElement(parentElement, element);
2049
        return element;
2050
    }
2051

    
2052
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2053
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2054
        addAndAdaptElement(parentElement, element);
2055
        return element;
2056
    }
2057

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

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

    
2070
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2071
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2072
        adapt(element);
2073
        parentElement.addElement(element);
2074

    
2075
        return element;
2076
    }
2077

    
2078
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2079
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2080
        addAndAdaptElement(parentElement, element);
2081
        return element;
2082
    }
2083

    
2084
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
2085
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
2086
        addAndAdaptElement(parentElement, element);
2087
        return element;
2088
    }
2089

    
2090
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2091
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2092
        addAndAdaptElement(parentElement, element);
2093
        return element;
2094
    }
2095

    
2096
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2097
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2098
        addAndAdaptElement(parentElement, element);
2099
        return element;
2100
    }
2101

    
2102
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2103
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2104
        addAndAdaptElement(parentElement, element);
2105
        return element;
2106
    }
2107

    
2108
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2109
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2110
        addAndAdaptElement(parentElement, element);
2111
        return element;
2112
    }
2113

    
2114
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2115
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2116
        addAndAdaptElement(parentElement, element);
2117
        return element;
2118
    }
2119

    
2120
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2121
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2122
        addAndAdaptElement(parentElement, element);
2123
        return element;
2124
    }
2125

    
2126
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2127
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2128
        addAndAdaptElement(parentElement, element);
2129
        return element;
2130
    }
2131

    
2132
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2133
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2134
        addAndAdaptElement(parentElement, element);
2135
        return element;
2136
    }
2137

    
2138
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2139
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2140
        addAndAdaptElement(parentElement, element);
2141
        return element;
2142
    }
2143

    
2144
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2145
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2146
        addAndAdaptElement(parentElement, element);
2147
        return element;
2148
    }
2149
  
2150
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2151
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2152
        addAndAdaptElement(parentElement, element);
2153
        return element;
2154
    }
2155

    
2156
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2157
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2158
        addAndAdaptElement(parentElement, element);
2159
        return element;
2160
    }
2161

    
2162
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2163
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2164
        addAndAdaptElement(parentElement, element);
2165
        return element;
2166
    }
2167

    
2168

    
2169
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2170
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2171
        addAndAdaptElement(parentElement, element);
2172
        return element;
2173
    }
2174

    
2175
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2176
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2177
        addAndAdaptElement(parentElement, element);
2178
        return element;
2179
    }
2180

    
2181
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2182
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2183
        addAndAdaptElement(parentElement, element);
2184
        return element;
2185
    }
2186

    
2187
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2188
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2189
        addAndAdaptElement(parentElement, element);
2190
        return element;
2191
    }
2192

    
2193
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2194
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2195
        addAndAdaptElement(parentElement, element);
2196
        return element;
2197
    }
2198

    
2199
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2200
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2201
        addAndAdaptElement(parentElement, element);
2202
        return element;
2203
    }
2204

    
2205
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2206
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2207
        addAndAdaptElement(parentElement, element);
2208
        return element;
2209
    }
2210

    
2211
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2212
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2213
        addAndAdaptElement(parentElement, element);
2214
        return element;
2215
    }
2216

    
2217
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2218
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2219
        addAndAdaptElement(parentElement, element);
2220
        return element;
2221
    }
2222

    
2223
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2224
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2225
        addAndAdaptElement(parentElement, element);
2226
        return element;
2227
    }
2228

    
2229
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2230
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2231
        addAndAdaptElement(parentElement, element);
2232
        return element;
2233
    }
2234

    
2235
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2236
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2237
        addAndAdaptElement(parentElement, element);
2238
        return element;
2239
    }
2240

    
2241
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2242
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2243
        addAndAdaptElement(parentElement, element);
2244
        return element;
2245
    }
2246

    
2247
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2248
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2249
        addAndAdaptElement(parentElement, element);
2250
        return element;
2251
    }
2252

    
2253
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2254
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2255
        addAndAdaptElement(parentElement, element);
2256
        return element;
2257
    }
2258

    
2259
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2260
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2261
        addAndAdaptElement(parentElement, element);
2262
        return element;
2263
    }
2264

    
2265
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2266
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2267
        addAndAdaptElement(parentElement, mediaDetailElement);
2268
        return mediaDetailElement;
2269
    }
2270

    
2271
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2272
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2273
        addAndAdaptElement(parentElement, element);
2274
        return element;
2275
    }
2276

    
2277
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2278
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2279
        addAndAdaptElement(parentElement, element);
2280
        return element;
2281
    }
2282

    
2283
    public SpecimenHierarchyDetailElement createSpecimenHierarchyDetailElement(ICdmFormElement parentElement) {
2284
        SpecimenHierarchyDetailElement element = new SpecimenHierarchyDetailElement(this, parentElement);
2285
        addAndAdaptElement(parentElement, element);
2286
        return element;
2287
    }
2288

    
2289
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2290
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2291
        addAndAdaptElement(parentElement, element);
2292
        return element;
2293
    }
2294

    
2295
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2296
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2297
        addAndAdaptElement(parentElement, element);
2298
        return element;
2299
    }
2300

    
2301
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2302
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2303
        addAndAdaptElement(parentElement, element);
2304
        return element;
2305
    }
2306

    
2307
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2308
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2309
        addAndAdaptElement(parentElement, element);
2310
        return element;
2311
    }
2312

    
2313
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2314
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2315
        addAndAdaptElement(parentElement, element);
2316
        return element;
2317
    }
2318

    
2319
    /**
2320
     * @param parentElement
2321
     * @param element
2322
     */
2323
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2324
        adapt(element);
2325
        parentElement.addElement(element);
2326
    }
2327

    
2328
    //--------EntityCollectionSection----------
2329
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2330
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2331
        addAndAdaptSection(parentElement, section);
2332
        return section;
2333
    }
2334

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2587
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2588
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2589
        addAndAdaptSection(parentElement, section);
2590
        return section;
2591
    }
2592

    
2593

    
2594
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2595
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2596
        AbstractEntityCollectionElement element = null;
2597

    
2598
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2599

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

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

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

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

    
2771

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

    
2778
        else{
2779
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2780
                element.setPersistentBackground(backgroundColor);
2781
            }
2782
            adapt(element);
2783
            parentElement.addElement(element);
2784
        }
2785

    
2786
        return element;
2787
    }
2788

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

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

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

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

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

    
2902
    /** {@inheritDoc} */
2903
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2904
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2905
        adapt(labelElement);
2906
        parentElement.addElement(labelElement);
2907
        return labelElement;
2908
    }
2909

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

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

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

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

    
2988
    }
2989

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

    
3012
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3013
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3014
        addAndAdaptSection(parentElement, section);
3015
        return section;
3016
    }
3017

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

    
3031
	
3032
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3033
			ICdmFormElement parentElement, int style) {
3034
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3035
		addAndAdaptElement(parentElement, section);
3036
        return section;
3037
	}
3038

    
3039
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3040
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3041
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3042
	        addAndAdaptSection(formElement, section);
3043
	        return section;
3044
	}
3045

    
3046

    
3047

    
3048
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3049
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3050
//				 initialText, textHeight, style);
3051
//	        adapt(element);
3052
//	        parentElement.addElement(element);
3053
//	        return element;
3054
//	}
3055

    
3056
	
3057

    
3058

    
3059

    
3060

    
3061

    
3062
}
(7-7/45)