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
	        if (comparator!= null){
977
	        	element.setTermComparator(comparator);
978
	        }
979
	        adapt(element);
980
	        parentElement.addElement(element);
981
	        return element;
982
	    }
983
	    else if(termVocabulary!=null){
984
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
985
	        if (comparator!= null){
986
	        	element.setTermComparator(comparator);
987
	        }
988
	        adapt(element);
989
	        parentElement.addElement(element);
990
	        return element;
991
	    }
992
	    else{
993
	        //this should never happen
994
	        return null;
995
	    }
996
	}
997

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

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

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

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

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

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

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

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

    
1132
        // handle focus and property change events for cdm use
1133
        section.addFocusListener(selectionFocusHandler);
1134
        section.setPropertyChangeListeners(propertyChangeListeners);
1135

    
1136
        if (section.getToggle() != null) {
1137
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1138
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1139
        }
1140

    
1141
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1142

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

    
1154
    private class BoldFontHolder2 {
1155
        private Font normalFont;
1156

    
1157
        private Font boldFont;
1158

    
1159
        public BoldFontHolder2() {
1160
        }
1161

    
1162
        public Font getBoldFont(Font font) {
1163
            createBoldFont(font);
1164
            return boldFont;
1165
        }
1166

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

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

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

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

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

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

    
1293

    
1294

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

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

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

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

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

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

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

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

    
1432
    /**
1433
     * @return the propertyChangeListeners
1434
     */
1435
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1436
        return propertyChangeListeners;
1437
    }
1438

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

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

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

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

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

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

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

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

    
1588
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1589
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1590

    
1591
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1592
                selectionProvider, style);
1593

    
1594
        parentElement.addElement(section);
1595
        adapt(section);
1596
        return section;
1597

    
1598
    }
1599

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

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

    
1620

    
1621
        adapt(element);
1622
        parentElement.addElement(element);
1623
        return element;
1624
    }
1625

    
1626

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

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

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

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

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

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

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

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

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

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

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

    
1694

    
1695

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1960
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1961
        parentElement.addElement(section);
1962
        adapt(section);
1963
    }
1964

    
1965
    //--------DetailElements------------
1966

    
1967
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1968
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1969
        addAndAdaptElement(parentElement, element);
1970
        return element;
1971
    }
1972

    
1973
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1974
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1975
        addAndAdaptElement(parentElement, element);
1976
        return element;
1977
    }
1978

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

    
1985
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1986
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1987
        addAndAdaptElement(parentElement, element);
1988
        return element;
1989
    }
1990

    
1991
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1992
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1993
        addAndAdaptElement(parentElement, element);
1994
        return element;
1995
    }
1996

    
1997
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1998
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1999
        addAndAdaptElement(parentElement, element);
2000
        return element;
2001
    }
2002

    
2003
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
2004
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2005
        addAndAdaptElement(parentElement, element);
2006
        return element;
2007
    }
2008

    
2009
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2010
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2011
        addAndAdaptElement(parentElement, element);
2012
        return element;
2013
    }
2014

    
2015
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2016
        UserDetailElement element = new UserDetailElement(this, parentElement);
2017
        addAndAdaptElement(parentElement, element);
2018
        return element;
2019
    }
2020

    
2021
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2022
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2023
        addAndAdaptElement(parentElement, element);
2024
        return element;
2025
    }
2026

    
2027
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2028
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2029
        addAndAdaptElement(parentElement, element);
2030
        return element;
2031
    }
2032

    
2033
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2034
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2035
        addAndAdaptElement(parentElement, element);
2036
        return element;
2037
    }
2038

    
2039
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2040
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2041
        addAndAdaptElement(parentElement, element);
2042
        return element;
2043
    }
2044

    
2045
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2046
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2047
        addAndAdaptElement(parentElement, element);
2048
        return element;
2049
    }
2050

    
2051
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2052
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2053
        adapt(element);
2054
        parentElement.addElement(element);
2055

    
2056
        return element;
2057
    }
2058

    
2059
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2060
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2061
        addAndAdaptElement(parentElement, element);
2062
        return element;
2063
    }
2064

    
2065
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
2066
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
2067
        addAndAdaptElement(parentElement, element);
2068
        return element;
2069
    }
2070

    
2071
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2072
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2073
        addAndAdaptElement(parentElement, element);
2074
        return element;
2075
    }
2076

    
2077
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2078
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2079
        addAndAdaptElement(parentElement, element);
2080
        return element;
2081
    }
2082

    
2083
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2084
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2085
        addAndAdaptElement(parentElement, element);
2086
        return element;
2087
    }
2088

    
2089
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2090
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2091
        addAndAdaptElement(parentElement, element);
2092
        return element;
2093
    }
2094

    
2095
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2096
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2097
        addAndAdaptElement(parentElement, element);
2098
        return element;
2099
    }
2100

    
2101
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2102
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2103
        addAndAdaptElement(parentElement, element);
2104
        return element;
2105
    }
2106

    
2107
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2108
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2109
        addAndAdaptElement(parentElement, element);
2110
        return element;
2111
    }
2112

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

    
2119
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2120
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2121
        addAndAdaptElement(parentElement, element);
2122
        return element;
2123
    }
2124

    
2125
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2126
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2127
        addAndAdaptElement(parentElement, element);
2128
        return element;
2129
    }
2130

    
2131
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2132
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2133
        addAndAdaptElement(parentElement, element);
2134
        return element;
2135
    }
2136

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

    
2143
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2144
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2145
        addAndAdaptElement(parentElement, element);
2146
        return element;
2147
    }
2148

    
2149

    
2150
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2151
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2152
        addAndAdaptElement(parentElement, element);
2153
        return element;
2154
    }
2155

    
2156
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2157
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2158
        addAndAdaptElement(parentElement, element);
2159
        return element;
2160
    }
2161

    
2162
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2163
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2164
        addAndAdaptElement(parentElement, element);
2165
        return element;
2166
    }
2167

    
2168
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2169
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2170
        addAndAdaptElement(parentElement, element);
2171
        return element;
2172
    }
2173

    
2174
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2175
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2176
        addAndAdaptElement(parentElement, element);
2177
        return element;
2178
    }
2179

    
2180
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2181
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2182
        addAndAdaptElement(parentElement, element);
2183
        return element;
2184
    }
2185

    
2186
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2187
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2188
        addAndAdaptElement(parentElement, element);
2189
        return element;
2190
    }
2191

    
2192
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2193
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2194
        addAndAdaptElement(parentElement, element);
2195
        return element;
2196
    }
2197

    
2198
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2199
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2200
        addAndAdaptElement(parentElement, element);
2201
        return element;
2202
    }
2203

    
2204
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2205
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2206
        addAndAdaptElement(parentElement, element);
2207
        return element;
2208
    }
2209

    
2210
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2211
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2212
        addAndAdaptElement(parentElement, element);
2213
        return element;
2214
    }
2215

    
2216
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2217
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2218
        addAndAdaptElement(parentElement, element);
2219
        return element;
2220
    }
2221

    
2222
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2223
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2224
        addAndAdaptElement(parentElement, element);
2225
        return element;
2226
    }
2227

    
2228
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2229
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2230
        addAndAdaptElement(parentElement, element);
2231
        return element;
2232
    }
2233

    
2234
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2235
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2236
        addAndAdaptElement(parentElement, element);
2237
        return element;
2238
    }
2239

    
2240
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2241
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2242
        addAndAdaptElement(parentElement, element);
2243
        return element;
2244
    }
2245

    
2246
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2247
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2248
        addAndAdaptElement(parentElement, mediaDetailElement);
2249
        return mediaDetailElement;
2250
    }
2251

    
2252
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2253
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2254
        addAndAdaptElement(parentElement, element);
2255
        return element;
2256
    }
2257

    
2258
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2259
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2260
        addAndAdaptElement(parentElement, element);
2261
        return element;
2262
    }
2263

    
2264
    public SpecimenHierarchyDetailElement createSpecimenHierarchyDetailElement(ICdmFormElement parentElement) {
2265
        SpecimenHierarchyDetailElement element = new SpecimenHierarchyDetailElement(this, parentElement);
2266
        addAndAdaptElement(parentElement, element);
2267
        return element;
2268
    }
2269

    
2270
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2271
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2272
        addAndAdaptElement(parentElement, element);
2273
        return element;
2274
    }
2275

    
2276
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2277
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2278
        addAndAdaptElement(parentElement, element);
2279
        return element;
2280
    }
2281

    
2282
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2283
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2284
        addAndAdaptElement(parentElement, element);
2285
        return element;
2286
    }
2287

    
2288
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2289
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2290
        addAndAdaptElement(parentElement, element);
2291
        return element;
2292
    }
2293

    
2294
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2295
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2296
        addAndAdaptElement(parentElement, element);
2297
        return element;
2298
    }
2299

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2574

    
2575
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2576
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2577
        AbstractEntityCollectionElement element = null;
2578

    
2579
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2580

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

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

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

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

    
2752

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

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

    
2767
        return element;
2768
    }
2769

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

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

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

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

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

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

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

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

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

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

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

    
2970
    }
2971

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

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

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

    
3013

    
3014
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3015
			ICdmFormElement parentElement, int style) {
3016
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3017
		addAndAdaptElement(parentElement, section);
3018
        return section;
3019
	}
3020

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

    
3028

    
3029

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

    
3038

    
3039

    
3040

    
3041

    
3042

    
3043

    
3044
}
(7-7/45)