Project

General

Profile

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

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

    
14
import javax.inject.Inject;
15

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

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

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

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

    
360
    @Inject
361
    private IEclipseContext context;
362

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

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

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

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

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

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

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

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

    
414
    public CdmFormFactory(Display display) {
415
        this(display, null);
416
    }
417

    
418
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
419
        super(display);
420
        this.selectionProvider = selectionProvider;
421
        init();
422
    }
423

    
424
    private void init() {
425
        boldFontHolder2 = new BoldFontHolder2();
426
        selectionMouseHandler = new SelectionMouseHandler();
427
        selectionFocusHandler = new SelectionFocusHandler();
428
    }
429

    
430
    public IEclipseContext getContext() {
431
        return context;
432
    }
433

    
434
    /**
435
     * Creates an instance initialized with the correct selectionProvider
436
     *
437
     * Make sure to remove the instance when the entityComposite disposes via
438
     * destroySelectionArbitrator(..)
439
     *
440
     * @param entityElement
441
     *            a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
442
     *            object.
443
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
444
     *         object.
445
     */
446
    public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
447
        SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
448
        selectionArbitrator.addSelectionProvider(selectionProvider);
449
        selectionProvider.addSelectionChangedListener(selectionArbitrator);
450
        addSelectionListener(selectionArbitrator);
451
        return selectionArbitrator;
452
    }
453

    
454
    /**
455
     * <p>
456
     * destroySelectionArbitrator
457
     * </p>
458
     *
459
     * @param selectionArbitrator
460
     *            a
461
     *            {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
462
     *            object.
463
     */
464
    public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
465
        removeSelectionListener(selectionArbitrator);
466
        if (selectionProvider != null) {
467
            selectionProvider.removeSelectionChangedListener(selectionArbitrator);
468
        } else {
469
            MessagingUtils.error(this.getClass(),
470
                    "Tried to destroy a selection listener from this factories listeners but was null", null);
471
        }
472
    }
473

    
474
    /**
475
     * <p>
476
     * Adapts the {@link AbstractCdmFormElement}:<br>
477
     * - sets the {@link IPropertyChangeListener}s handled by this class
478
     * </p>
479
     *
480
     * @param formElement
481
     *            a
482
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
483
     *            object.
484
     */
485
    public void adapt(ICdmFormElement formElement) {
486
        formElement.setPropertyChangeListeners(propertyChangeListeners);
487
    }
488

    
489
    /** {@inheritDoc} */
490
    @Override
491
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
492
        if (trackFocus) {
493
            control.addFocusListener(selectionFocusHandler);
494
        }
495
        super.adapt(control, trackFocus, trackKeyboard);
496
    }
497

    
498
    /** {@inheritDoc} */
499
    @Override
500
    public void adapt(Composite composite) {
501
        composite.addMouseListener(selectionMouseHandler);
502

    
503
        super.adapt(composite);
504
    }
505

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

    
547
    /**
548
     * <p>
549
     * createEmptyCell
550
     * </p>
551
     *
552
     * @param parent
553
     *            a {@link org.eclipse.swt.widgets.Composite} object.
554
     * @return a {@link org.eclipse.swt.widgets.Label} object.
555
     */
556
    public Label createEmptyCell(Composite parent) {
557
        return this.createLabel(parent, null);
558
    }
559

    
560
    /**
561
     * <p>
562
     * createMultiLanguageTextElement
563
     * </p>
564
     *
565
     * @param parentElement
566
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
567
     *            object.
568
     * @param labelString
569
     *            a {@link java.lang.String} object.
570
     * @param multilanguageText
571
     *            a {@link java.util.Map} object.
572
     * @param textHeight
573
     *            a int.
574
     * @param style
575
     *            a int.
576
     * @return a
577
     *         {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
578
     *         object.
579
     */
580
    public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
581
            Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
582
        MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
583
                multilanguageText, textHeight, style);
584
        adapt(element);
585
        parentElement.addElement(element);
586
        return element;
587
    }
588

    
589
    /**
590
     * <p>
591
     * createMultiLanguageTextElement
592
     * </p>
593
     *
594
     * @param parentElement
595
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
596
     *            object.
597
     *
598
     * @param Representation
599
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
600
     * @param textHeight
601
     *            a int.
602
     * @param style
603
     *            a int.
604
     * @return a
605
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
606
     *         object.
607
     */
608
    public RepresentationElement createRepresentationElement(ICdmFormElement parentElement, Representation representation, TermBase term,int textHeight, int style, boolean fillDetails) {
609
        RepresentationElement element = new RepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
610
        adapt(element);
611
        parentElement.addElement(element);
612
        return element;
613
    }
614

    
615
    /**
616
     * <p>
617
     * createMultiLanguageTextElement
618
     * </p>
619
     *
620
     * @param parentElement
621
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
622
     *            object.
623
     *
624
     * @param Representation
625
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
626
     * @param textHeight
627
     *            a int.
628
     * @param style
629
     *            a int.
630
     * @return a
631
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
632
     *         object.
633
     */
634
    public TranslatableRepresentationElement createTranslatableRepresentationElement(ICdmFormElement parentElement, Representation representation, TermBase term,int textHeight, int style, boolean fillDetails) {
635
        TranslatableRepresentationElement element = new TranslatableRepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
636
        adapt(element);
637
        parentElement.addElement(element);
638
        return element;
639
    }
640

    
641
    /**
642
     * <p>
643
     * createMultiLanguageTextElement
644
     * </p>
645
     *
646
     * @param parentElement
647
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
648
     *            object.
649
     *
650
     * @param term
651
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
652
     * @param textHeight
653
     *            a int.
654
     * @param style
655
     *            a int.
656
     * @return a
657
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
658
     *         object.
659
     */
660
    public RepresentationElement createRepresentationElement(ICdmFormElement parentElement, TermBase term, int textHeight, int style, boolean fillDetails) {
661
        RepresentationElement element = new RepresentationElement(this, parentElement, term, textHeight, style, fillDetails);
662
        adapt(element);
663
        parentElement.addElement(element);
664
        return element;
665
    }
666

    
667
    /**
668
     * <p>
669
     * createMultiLanguageTextElement
670
     * </p>
671
     *
672
     * @param parentElement
673
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
674
     *            object.
675
     *
676
     * @param term
677
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
678
     * @param textHeight
679
     *            a int.
680
     * @param style
681
     *            a int.
682
     * @return a
683
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
684
     *         object.
685
     */
686
    public TranslatableRepresentationElement createTranslatableRepresentationElement(ICdmFormElement parentElement, TermBase term, int textHeight, int style, boolean fillDetails) {
687
        TranslatableRepresentationElement element = new TranslatableRepresentationElement(this, parentElement, term, textHeight, style, fillDetails);
688
        adapt(element);
689
        parentElement.addElement(element);
690
        return element;
691
    }
692

    
693
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
694
            KeyStatement keyStatement, int textHeight, int style) {
695
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
696
                textHeight, style);
697
        adapt(element);
698
        parentElement.addElement(element);
699
        return element;
700
    }
701

    
702
    /**
703
     * Creates a text field with a label. The initial content will be the return value of the initalObject's {@link #toString()}
704
     * method.<br>
705
     * <b>Note</b>: if initialObject is <code>null</code> then an empty string is used.
706
     * @param parentElement the parent container
707
     * @param labelString the label name
708
     * @param initialObject the object from which the <code>toString()</code> method is called
709
     * @param style {@link SWT} style constant
710
     * @return the created textfield with label
711
     */
712
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
713
            Object initialObject, int style) {
714
        return createTextWithLabelElement(parentElement, labelString, initialObject==null?"":initialObject.toString(), style);
715
    }
716

    
717
    /**
718
     * <p>
719
     * createTextWithLabelElement
720
     * </p>
721
     *
722
     * @param parentElement
723
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
724
     *            object.
725
     * @param labelString
726
     *            a {@link java.lang.String} object.
727
     * @param initialText
728
     *            a {@link java.lang.String} object.
729
     * @param style
730
     *            a int.
731
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
732
     *         object.
733
     */
734
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
735
            String initialText, int style) {
736
        return createTextWithLabelElement(parentElement, labelString, initialText, null, style);
737
    }
738
    /**
739
     * <p>
740
     * createTextWithLabelElement
741
     * </p>
742
     *
743
     * @param parentElement
744
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
745
     *            object.
746
     * @param labelString
747
     *            a {@link java.lang.String} object.
748
     * @param initialText
749
     *            a {@link java.lang.String} object.
750
     * @param textLimit maximal number of characters allowed
751
     * @param style
752
     *            a int.
753
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
754
     *         object.
755
     */
756
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
757
            String initialText, Integer textLimit, int style) {
758
        if(initialText==null){
759
            initialText = "";
760
        }
761

    
762
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
763
                textLimit, style);
764
        adapt(element);
765
        parentElement.addElement(element);
766
        return element;
767
    }
768

    
769
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
770
            int textHeight, int style) {
771
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
772
        adapt(element);
773
        parentElement.addElement(element);
774
        return element;
775
    }
776

    
777
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
778
            LSID initialLsid, int style) {
779
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
780
        adapt(element);
781
        parentElement.addElement(element);
782
        return element;
783
    }
784

    
785
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
786
            URI initialUri, int style) {
787
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
788
        adapt(element);
789
        parentElement.addElement(element);
790
        return element;
791
    }
792

    
793
    /**
794
     * @param element
795
     * @param string
796
     * @param uri
797
     * @param style
798
     * @return
799
     */
800
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
801
            IOpenUrlEnabled openUrlEnabled, int style) {
802
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
803
                style);
804
        adapt(element);
805
        parentElement.addElement(element);
806
        return element;
807
    }
808

    
809
    /**
810
     *
811
     * @param parentElement
812
     * @param labelString
813
     * @param conversationEnabled
814
     * @param user
815
     * @param style
816
     * @return
817
     */
818
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
819
            ConversationHolder conversation, User user, int style) {
820
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
821
        adapt(element);
822
        parentElement.addElement(element);
823
        return element;
824
    }
825

    
826
    /**
827
     * <p>
828
     * createIntegerTextWithLabelElement
829
     * </p>
830
     *
831
     * @param parentElement
832
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
833
     *            object.
834
     * @param labelString
835
     *            a {@link java.lang.String} object.
836
     * @param initialInteger
837
     *            a {@link java.lang.Integer} object.
838
     * @param style
839
     *            a int.
840
     * @return a
841
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
842
     *         object.
843
     */
844
	public NumberWithLabelElement createNumberTextWithLabelElement(
845
			ICdmFormElement parentElement, String labelString,
846
			Number initialNumber, int style) {
847
		NumberWithLabelElement element = new NumberWithLabelElement(this,
848
				parentElement, labelString, initialNumber, style);
849
		adapt(element);
850
		parentElement.addElement(element);
851
		return element;
852
	}
853

    
854
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
855
            String labelString, LanguageString languageString, int style) {
856
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
857
    }
858

    
859
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
860
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
861
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
862
                languageString, height, isMultiLine, style);
863
        adapt(element);
864
        parentElement.addElement(element);
865
        return element;
866
    }
867

    
868
    /**
869
     * <p>
870
     * createKeyValueViewerElement
871
     * </p>
872
     *
873
     * @param parentElement
874
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
875
     *            object.
876
     * @param keyHeading
877
     *            a {@link java.lang.String} object.
878
     * @param valueHeading
879
     *            a {@link java.lang.String} object.
880
     * @param map
881
     *            a {@link java.util.Map} object.
882
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
883
     *         object.
884
     */
885
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
886
            String valueHeading, Map<Object, Object> map) {
887
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
888
        adapt(element);
889
        parentElement.addElement(element);
890
        return element;
891
    }
892
    /**
893
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
894
     */
895
    @Deprecated
896
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
897
            ICdmFormElement parentElement, String labelString, T selection, int style) {
898
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString, selection, true, style);
899
        adapt(element);
900
        parentElement.addElement(element);
901
        return element;
902
    }
903

    
904
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
905
            TermType termType,
906
            ICdmFormElement parentElement,
907
            String labelString,
908
            T selection,
909
            int style,
910
            Comparator<T> comparator) {
911
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false, comparator);
912
    }
913

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

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

    
943

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1151
    private class BoldFontHolder2 {
1152
        private Font normalFont;
1153

    
1154
        private Font boldFont;
1155

    
1156
        public BoldFontHolder2() {
1157
        }
1158

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

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

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

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

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

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

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

    
1290

    
1291

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1595
    }
1596

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

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

    
1617

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

    
1623

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

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

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

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

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

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

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

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

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

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

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

    
1691

    
1692

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1962
    //--------DetailElements------------
1963

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2053
        return element;
2054
    }
2055

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2146

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2571

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

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

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

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

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

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

    
2749

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

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

    
2764
        return element;
2765
    }
2766

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

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

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

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

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

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

    
2888
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2889
//        Label label = new Label(formElement.getLayoutComposite(), style);
2890
//        label.setText(labelText+" (yyyy-MM-dd)");
2891
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
2892
//        dateElement.initInternalController();
2893
//
2894
//        return dateElement;
2895
//    }
2896

    
2897
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
2898
    	 Label label = new Label(formElement.getLayoutComposite(), style);
2899
         label.setText(labelText);
2900
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2901
         DateElement dateElement = new DateElement(this, formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
2902
         dateElement.initController(this, formElement);
2903
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2904
         return dateElement;
2905
    }
2906

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

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

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

    
2967
    }
2968

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

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

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

    
3010

    
3011
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3012
			ICdmFormElement parentElement, int style) {
3013
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3014
		addAndAdaptElement(parentElement, section);
3015
        return section;
3016
	}
3017

    
3018
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3019
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3020
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3021
	        addAndAdaptSection(formElement, section);
3022
	        return section;
3023
	}
3024

    
3025

    
3026

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

    
3035

    
3036

    
3037

    
3038

    
3039

    
3040

    
3041
}
(7-7/45)