Project

General

Profile

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

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

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

    
364
    @Inject
365
    private IEclipseContext context;
366

    
367
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
368

    
369
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
370

    
371
    private final int orientation = Window.getDefaultOrientation();
372
    private ISelectionProvider selectionProvider;
373

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

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

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

    
408
    private void notifySelectionListeners(TypedEvent e) {
409
        Event event = new Event();
410
        event.widget = e.widget;
411
        SelectionEvent selectionEvent = new SelectionEvent(event);
412

    
413
        for (SelectionListener listener : selectionListenerList) {
414
            listener.widgetSelected(selectionEvent);
415
        }
416
    }
417

    
418
    public CdmFormFactory(Display display) {
419
        this(display, null);
420
    }
421

    
422
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
423
        super(display);
424
        this.selectionProvider = selectionProvider;
425
        init();
426
    }
427

    
428
    private void init() {
429
        boldFontHolder2 = new BoldFontHolder2();
430
        selectionMouseHandler = new SelectionMouseHandler();
431
        selectionFocusHandler = new SelectionFocusHandler();
432
    }
433

    
434
    public IEclipseContext getContext() {
435
        return context;
436
    }
437

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

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

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

    
493
    /** {@inheritDoc} */
494
    @Override
495
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
496
        if (trackFocus) {
497
            control.addFocusListener(selectionFocusHandler);
498
        }
499
        super.adapt(control, trackFocus, trackKeyboard);
500
    }
501

    
502
    /** {@inheritDoc} */
503
    @Override
504
    public void adapt(Composite composite) {
505
        composite.addMouseListener(selectionMouseHandler);
506

    
507
        super.adapt(composite);
508
    }
509

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

    
553
    /**
554
     * <p>
555
     * createEmptyCell
556
     * </p>
557
     *
558
     * @param parent
559
     *            a {@link org.eclipse.swt.widgets.Composite} object.
560
     * @return a {@link org.eclipse.swt.widgets.Label} object.
561
     */
562
    public Label createEmptyCell(Composite parent) {
563
        return this.createLabel(parent, null);
564
    }
565

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

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

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

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

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

    
699
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
700
            KeyStatement keyStatement, int textHeight, int style) {
701
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
702
                textHeight, style);
703
        adapt(element);
704
        parentElement.addElement(element);
705
        return element;
706
    }
707

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

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

    
768
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
769
                textLimit, style);
770
        adapt(element);
771
        parentElement.addElement(element);
772
        return element;
773
    }
774

    
775
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
776
            int textHeight, int style) {
777
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
778
        adapt(element);
779
        parentElement.addElement(element);
780
        return element;
781
    }
782

    
783
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
784
            LSID initialLsid, int style) {
785
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
786
        adapt(element);
787
        parentElement.addElement(element);
788
        return element;
789
    }
790

    
791
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
792
            URI initialUri, int style) {
793
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
794
        adapt(element);
795
        parentElement.addElement(element);
796
        return element;
797
    }
798

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

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

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

    
860
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
861
            String labelString, LanguageString languageString, int style) {
862
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
863
    }
864

    
865
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
866
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
867
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
868
                languageString, height, isMultiLine, style);
869
        adapt(element);
870
        parentElement.addElement(element);
871
        return element;
872
    }
873

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

    
910
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
911
            TermType termType,
912
            ICdmFormElement parentElement,
913
            String labelString,
914
            T selection,
915
            int style,
916
            Comparator<T> comparator) {
917
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false, comparator);
918
    }
919

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

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

    
949

    
950
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
951
            TermVocabulary<?> termVocabulary,
952
            ICdmFormElement parentElement,
953
            String labelString,
954
            T selection,
955
            int style) {
956
        return this.createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, true, style, false, null);
957
    }
958

    
959
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
960
	        TermVocabulary<?> termVocabulary,
961
	        ICdmFormElement parentElement,
962
	        String labelString,
963
	        T selection,
964
	        boolean addEmptyElement,
965
	        int style,
966
	        boolean useAbbrevLabel) {
967
	    return createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
968
	}
969

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1167
    private class BoldFontHolder2 {
1168
        private Font normalFont;
1169

    
1170
        private Font boldFont;
1171

    
1172
        public BoldFontHolder2() {
1173
        }
1174

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

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

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

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

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

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

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

    
1306

    
1307

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1611
    }
1612

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

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

    
1633

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

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

    
1645
    public CharacterDetailElement createCharacterDetailElement(ICdmFormElement parentElement, int style){
1646
        CharacterDetailElement element = new CharacterDetailElement(this, parentElement);
1647
        addAndAdaptElement(parentElement, element);
1648
        return element;
1649
    }
1650

    
1651

    
1652
    //--------DetailSections---------
1653
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1654
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1655
        addAndAdaptSection(parentElement, section);
1656
        return section;
1657
    }
1658

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

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

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

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

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

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

    
1695
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1696
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1697
        addAndAdaptSection(parentElement, section);
1698
        return section;
1699
    }
1700

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

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

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

    
1719

    
1720

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1979
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1980
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
1981
        addAndAdaptSection(parentElement, section);
1982
        return section;
1983
    }
1984

    
1985
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1986
        parentElement.addElement(section);
1987
        adapt(section);
1988
    }
1989

    
1990
    //--------DetailElements------------
1991

    
1992
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1993
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1994
        addAndAdaptElement(parentElement, element);
1995
        return element;
1996
    }
1997

    
1998
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1999
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
2000
        addAndAdaptElement(parentElement, element);
2001
        return element;
2002
    }
2003

    
2004
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
2005
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
2006
        addAndAdaptElement(parentElement, element);
2007
        return element;
2008
    }
2009

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

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

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

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

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

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

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

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

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

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

    
2070
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2071
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2072
        addAndAdaptElement(parentElement, element);
2073
        return element;
2074
    }
2075

    
2076
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2077
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2078
        adapt(element);
2079
        parentElement.addElement(element);
2080

    
2081
        return element;
2082
    }
2083

    
2084
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2085
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2086
        addAndAdaptElement(parentElement, element);
2087
        return element;
2088
    }
2089

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

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

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

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

    
2114
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2115
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2116
        addAndAdaptElement(parentElement, element);
2117
        return element;
2118
    }
2119

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

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

    
2132
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2133
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2134
        addAndAdaptElement(parentElement, element);
2135
        return element;
2136
    }
2137

    
2138
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2139
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2140
        addAndAdaptElement(parentElement, element);
2141
        return element;
2142
    }
2143

    
2144
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2145
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2146
        addAndAdaptElement(parentElement, element);
2147
        return element;
2148
    }
2149

    
2150
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2151
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2152
        addAndAdaptElement(parentElement, element);
2153
        return element;
2154
    }
2155

    
2156
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2157
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2158
        addAndAdaptElement(parentElement, element);
2159
        return element;
2160
    }
2161

    
2162
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2163
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2164
        addAndAdaptElement(parentElement, element);
2165
        return element;
2166
    }
2167

    
2168
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2169
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2170
        addAndAdaptElement(parentElement, element);
2171
        return element;
2172
    }
2173

    
2174

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2265
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2266
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2267
        addAndAdaptElement(parentElement, element);
2268
        return element;
2269
    }
2270

    
2271
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2272
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2273
        addAndAdaptElement(parentElement, mediaDetailElement);
2274
        return mediaDetailElement;
2275
    }
2276

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

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

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

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

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

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

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

    
2319
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2320
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2321
        addAndAdaptElement(parentElement, element);
2322
        return element;
2323
    }
2324

    
2325
    /**
2326
     * @param parentElement
2327
     * @param element
2328
     */
2329
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2330
        adapt(element);
2331
        parentElement.addElement(element);
2332
    }
2333

    
2334
    //--------EntityCollectionSection----------
2335
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2336
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2337
        addAndAdaptSection(parentElement, section);
2338
        return section;
2339
    }
2340

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2593
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2594
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2595
        addAndAdaptSection(parentElement, section);
2596
        return section;
2597
    }
2598

    
2599

    
2600
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2601
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2602
        AbstractEntityCollectionElement element = null;
2603

    
2604
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2605

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

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

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

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

    
2777

    
2778
        if (element == null) {
2779
            MessagingUtils.messageDialog("No element for entity", this,
2780
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2781
                            + entity, null);
2782
        }
2783

    
2784
        else{
2785
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2786
                element.setPersistentBackground(backgroundColor);
2787
            }
2788
            adapt(element);
2789
            parentElement.addElement(element);
2790
        }
2791

    
2792
        return element;
2793
    }
2794

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

    
2838
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2839
//            ConversationHolder conversation,
2840
            ICdmFormElement parentElement, String labelString, T selection, int mode,
2841
            int style) {
2842
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
2843
                parentElement, clazz,
2844
                labelString, selection, mode, style);
2845
        adapt(element);
2846
        parentElement.addElement(element);
2847
        return element;
2848
    }
2849

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

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

    
2903
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2904
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2905
//            int mode, int style) {
2906
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2907
//                conversation, parentElement, labelString, selection, mode, style);
2908
//        adapt(element);
2909
//        parentElement.addElement(element);
2910
//        return element;
2911
//    }
2912

    
2913
    /** {@inheritDoc} */
2914
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2915
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2916
        adapt(labelElement);
2917
        parentElement.addElement(labelElement);
2918
        return labelElement;
2919
    }
2920

    
2921
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2922
//        Label label = new Label(formElement.getLayoutComposite(), style);
2923
//        label.setText(labelText+" (yyyy-MM-dd)");
2924
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
2925
//        dateElement.initInternalController();
2926
//
2927
//        return dateElement;
2928
//    }
2929

    
2930
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
2931
    	 Label label = new Label(formElement.getLayoutComposite(), style);
2932
         label.setText(labelText);
2933
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2934
         DateElement dateElement = new DateElement(this, formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
2935
         dateElement.initController(this, formElement);
2936
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2937
         return dateElement;
2938
    }
2939

    
2940
    /**
2941
     * <p>
2942
     * Getter for the field <code>selectionProvider</code>.
2943
     * </p>
2944
     *
2945
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2946
     */
2947
    public ISelectionProvider getSelectionProvider() {
2948
        return selectionProvider;
2949
    }
2950

    
2951
    /**
2952
     * <p>
2953
     * createDetailedDescriptionDetailElement
2954
     * </p>
2955
     *
2956
     * @param parentElement
2957
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2958
     *            object.
2959
     * @param entity
2960
     *            a
2961
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2962
     *            object.
2963
     * @param style
2964
     *            a int.
2965
     * @return a
2966
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2967
     *         object.
2968
     */
2969
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2970
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
2971
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2972

    
2973
        if (entity instanceof CategoricalData) {
2974
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2975
                    (CategoricalData) entity, style);
2976
        } else if (entity instanceof CommonTaxonName) {
2977
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2978
                    style);
2979
        } else if (entity instanceof Distribution && !enabled) {
2980
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2981
                    style);
2982
            detailedDescriptionElement.setEnabled(enabled);
2983
        } else if (entity instanceof Distribution) {
2984
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2985
                    style);
2986
        }else if (entity instanceof IndividualsAssociation) {
2987
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2988
                    (IndividualsAssociation) entity, style);
2989
        } else if (entity instanceof QuantitativeData) {
2990
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2991
                    (QuantitativeData) entity, style);
2992
        } else if (entity instanceof TaxonInteraction) {
2993
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2994
                    (TaxonInteraction) entity, style);
2995
        } else if (entity instanceof TextData) {
2996
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2997
        } else {
2998
            throw new IllegalStateException("There is no interface for the given description element");
2999
        }
3000
        adapt(detailedDescriptionElement);
3001
        parentElement.addElement(detailedDescriptionElement);
3002
        return detailedDescriptionElement;
3003

    
3004
    }
3005

    
3006
    /**
3007
     * Creates a styled text as a part of the form.
3008
     *
3009
     * @param parent
3010
     *            the text parent
3011
     * @param value
3012
     *            the text initial value
3013
     * @param style
3014
     *            the text style
3015
     * @return the text widget
3016
     */
3017
    public StyledText createStyledText(Composite parent, String value, int style) {
3018
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3019
        if (value != null) {
3020
            text.setText(value);
3021
        }
3022
        text.setForeground(getColors().getForeground());
3023
        text.setBackground(getColors().getBackground());
3024
        // text.addFocusListener(visibilityHandler);
3025
        return text;
3026
    }
3027

    
3028
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3029
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3030
        addAndAdaptSection(parentElement, section);
3031
        return section;
3032
    }
3033

    
3034
    /**
3035
     * @param formElement
3036
     * @param conversationHolder
3037
     * @param style
3038
     * @return
3039
     */
3040
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3041
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3042
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3043
        addAndAdaptSection(formElement, section);
3044
        return section;
3045
    }
3046

    
3047

    
3048
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3049
			ICdmFormElement parentElement, int style) {
3050
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3051
		addAndAdaptElement(parentElement, section);
3052
        return section;
3053
	}
3054

    
3055
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3056
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3057
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3058
	        addAndAdaptSection(formElement, section);
3059
	        return section;
3060
	}
3061

    
3062

    
3063

    
3064
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3065
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3066
//				 initialText, textHeight, style);
3067
//	        adapt(element);
3068
//	        parentElement.addElement(element);
3069
//	        return element;
3070
//	}
3071

    
3072

    
3073

    
3074

    
3075

    
3076

    
3077

    
3078
}
(7-7/45)