Project

General

Profile

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

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

    
14
import javax.inject.Inject;
15

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

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

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

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

    
361
    @Inject
362
    private IEclipseContext context;
363

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
504
        super.adapt(composite);
505
    }
506

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
857
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
858
            String labelString, LanguageString languageString, int style) {
859
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
860
    }
861

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

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

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

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

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

    
946

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1154
    private class BoldFontHolder2 {
1155
        private Font normalFont;
1156

    
1157
        private Font boldFont;
1158

    
1159
        public BoldFontHolder2() {
1160
        }
1161

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

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

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

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

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

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

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

    
1293

    
1294

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1598
    }
1599

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

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

    
1620

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

    
1626

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

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

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

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

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

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

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

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

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

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

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

    
1694

    
1695

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2056
        return element;
2057
    }
2058

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2149

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2574

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

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

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

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

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

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

    
2752

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

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

    
2767
        return element;
2768
    }
2769

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

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

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

    
2868
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2869
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2870
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
2871
                parentElement,
2872
                labelString, selection, mode, style);
2873
        adapt(element);
2874
        parentElement.addElement(element);
2875
        return element;
2876
    }
2877

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

    
2888
    /** {@inheritDoc} */
2889
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2890
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2891
        adapt(labelElement);
2892
        parentElement.addElement(labelElement);
2893
        return labelElement;
2894
    }
2895

    
2896
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2897
//        Label label = new Label(formElement.getLayoutComposite(), style);
2898
//        label.setText(labelText+" (yyyy-MM-dd)");
2899
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
2900
//        dateElement.initInternalController();
2901
//
2902
//        return dateElement;
2903
//    }
2904

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

    
2915
    /**
2916
     * <p>
2917
     * Getter for the field <code>selectionProvider</code>.
2918
     * </p>
2919
     *
2920
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2921
     */
2922
    public ISelectionProvider getSelectionProvider() {
2923
        return selectionProvider;
2924
    }
2925

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

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

    
2979
    }
2980

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

    
3003
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3004
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3005
        addAndAdaptSection(parentElement, section);
3006
        return section;
3007
    }
3008

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

    
3022

    
3023
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3024
			ICdmFormElement parentElement, int style) {
3025
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3026
		addAndAdaptElement(parentElement, section);
3027
        return section;
3028
	}
3029

    
3030
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3031
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3032
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3033
	        addAndAdaptSection(formElement, section);
3034
	        return section;
3035
	}
3036

    
3037

    
3038

    
3039
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3040
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3041
//				 initialText, textHeight, style);
3042
//	        adapt(element);
3043
//	        parentElement.addElement(element);
3044
//	        return element;
3045
//	}
3046

    
3047

    
3048

    
3049

    
3050

    
3051

    
3052

    
3053
}
(7-7/45)