Project

General

Profile

Download (126 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.HashSet;
9
import java.util.List;
10
import java.util.Map;
11
import java.util.Set;
12

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

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

    
306
/**
307
 * <p>
308
 * CdmFormFactory class.
309
 * </p>
310
 *
311
 * @author n.hoffmann
312
 * @created Feb 24, 2010
313
 * @version 1.0
314
 */
315
public class CdmFormFactory extends FormToolkit {
316

    
317
    private BoldFontHolder2 boldFontHolder2;
318
    private MouseListener selectionMouseHandler;
319
    private FocusListener selectionFocusHandler;
320

    
321
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
322

    
323
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
324

    
325
    private final int orientation = Window.getDefaultOrientation();
326
    private ISelectionProvider selectionProvider;
327

    
328
    /** Constant <code>EMPTY_SELECTION</code> */
329
    public static ISelection EMPTY_SELECTION = new ISelection() {
330
        @Override
331
        public boolean isEmpty() {
332
            return true;
333
        }
334
    };
335

    
336
    /**
337
     *
338
     * @author n.hoffmann
339
     * @date Jan 25, 2010
340
     *
341
     */
342
    private class SelectionMouseHandler extends MouseAdapter {
343
        @Override
344
        public void mouseDown(MouseEvent e) {
345
            notifySelectionListeners(e);
346
        }
347
    }
348

    
349
    /**
350
     *
351
     * @author n.hoffmann
352
     * @date Jan 25, 2010
353
     *
354
     */
355
    private class SelectionFocusHandler extends FocusAdapter {
356
        @Override
357
        public void focusGained(FocusEvent e) {
358
            notifySelectionListeners(e);
359
        }
360
    }
361

    
362
    private void notifySelectionListeners(TypedEvent e) {
363
        Event event = new Event();
364
        event.widget = e.widget;
365
        SelectionEvent selectionEvent = new SelectionEvent(event);
366

    
367
        for (SelectionListener listener : selectionListenerList) {
368
            listener.widgetSelected(selectionEvent);
369
        }
370
    }
371

    
372
    /**
373
     * <p>
374
     * Constructor for CdmFormFactory.
375
     * </p>
376
     *
377
     * @param display
378
     *            a {@link org.eclipse.swt.widgets.Display} object.
379
     * @param selectionProvider
380
     *            a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
381
     */
382
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
383
        super(display);
384
        this.selectionProvider = selectionProvider;
385
        init();
386
    }
387

    
388
    /**
389
     * <p>
390
     * Constructor for CdmFormFactory.
391
     * </p>
392
     *
393
     * @param display
394
     *            a {@link org.eclipse.swt.widgets.Display} object.
395
     */
396
    public CdmFormFactory(Display display) {
397
        super(display);
398
        init();
399
    }
400

    
401
    /**
402
	 *
403
	 */
404
    private void init() {
405
        boldFontHolder2 = new BoldFontHolder2();
406
        selectionMouseHandler = new SelectionMouseHandler();
407
        selectionFocusHandler = new SelectionFocusHandler();
408
    }
409

    
410
    /**
411
     * Creates an instance initialized with the correct selectionProvider
412
     *
413
     * Make sure to remove the instance when the entityComposite disposes via
414
     * destroySelectionArbitrator(..)
415
     *
416
     * @param entityElement
417
     *            a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
418
     *            object.
419
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
420
     *         object.
421
     */
422
    public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
423
        SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
424
        selectionArbitrator.addSelectionProvider(selectionProvider);
425
        selectionProvider.addSelectionChangedListener(selectionArbitrator);
426
        addSelectionListener(selectionArbitrator);
427
        return selectionArbitrator;
428
    }
429

    
430
    /**
431
     * <p>
432
     * destroySelectionArbitrator
433
     * </p>
434
     *
435
     * @param selectionArbitrator
436
     *            a
437
     *            {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
438
     *            object.
439
     */
440
    public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
441
        removeSelectionListener(selectionArbitrator);
442
        if (selectionProvider != null) {
443
            selectionProvider.removeSelectionChangedListener(selectionArbitrator);
444
        } else {
445
            MessagingUtils.error(this.getClass(),
446
                    "Tried to destroy a selection listener from this factories listeners but was null", null);
447
        }
448
    }
449

    
450
    /**
451
     * <p>
452
     * Adapts the {@link AbstractCdmFormElement}:<br>
453
     * - sets the {@link IPropertyChangeListener}s handled by this class
454
     * </p>
455
     *
456
     * @param formElement
457
     *            a
458
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
459
     *            object.
460
     */
461
    public void adapt(ICdmFormElement formElement) {
462
        formElement.setPropertyChangeListeners(propertyChangeListeners);
463
    }
464

    
465
    /** {@inheritDoc} */
466
    @Override
467
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
468
        if (trackFocus) {
469
            control.addFocusListener(selectionFocusHandler);
470
        }
471
        super.adapt(control, trackFocus, trackKeyboard);
472
    }
473

    
474
    /** {@inheritDoc} */
475
    @Override
476
    public void adapt(Composite composite) {
477
        composite.addMouseListener(selectionMouseHandler);
478
        super.adapt(composite);
479
    }
480

    
481
    /**
482
     * <p>
483
     * destroyElement
484
     * </p>
485
     *
486
     * @param formElement
487
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
488
     *            object.
489
     */
490
    public void destroyElement(ICdmFormElement formElement) {
491
        // return if element was not initialized
492
        if (formElement == null) {
493
            return;
494
        }
495
        // destroy selection arbitrator, if any
496
        if (formElement instanceof ISelectableElement) {
497
            destroySelectionArbitrator(((ISelectableElement) formElement).getSelectionArbitrator());
498
        }
499
        // remove this element form its parents list of elements
500
        // ICdmFormElement parentElement = formElement.getParentElement();
501
        // if(parentElement != null){
502
        // parentElement.removeElement(formElement);
503
        // }
504
        // call destroy on child elements recursively
505
        for (ICdmFormElement childElement : formElement.getElements()) {
506
            destroyElement(childElement);
507
        }
508
        // dispose of the controls
509
        for (Control control : formElement.getControls()) {
510
            // we added the layoutComposite of the parental element as the
511
            // layout composite to this formElement
512
            // but we do not want to destroy it.
513
            if (control.equals(formElement.getLayoutComposite())) {
514
                continue;
515
            } else {
516
                control.dispose();
517
                control = null;
518
            }
519
        }
520
    }
521

    
522
    /**
523
     * <p>
524
     * createEmptyCell
525
     * </p>
526
     *
527
     * @param parent
528
     *            a {@link org.eclipse.swt.widgets.Composite} object.
529
     * @return a {@link org.eclipse.swt.widgets.Label} object.
530
     */
531
    public Label createEmptyCell(Composite parent) {
532
        return this.createLabel(parent, null);
533
    }
534

    
535
    /**
536
     * <p>
537
     * createMultilineTextWithLabel
538
     * </p>
539
     *
540
     * @param labelString
541
     *            a {@link java.lang.String} object.
542
     * @param textHeight
543
     *            a int.
544
     * @param style
545
     *            a int.
546
     * @param parentElement
547
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
548
     *            object.
549
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
550
     *         object.
551
     */
552
    public TextWithLabelElement createMultilineTextWithLabel(ICdmFormElement parentElement, String labelString,
553
            int textHeight, int style) {
554
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, style);
555
        adapt(element);
556
        parentElement.addElement(element);
557
        return element;
558
    }
559

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

    
589
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
590
            KeyStatement keyStatement, int textHeight, int style) {
591
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
592
                textHeight, style);
593
        adapt(element);
594
        parentElement.addElement(element);
595
        return element;
596
    }
597

    
598
    /**
599
     * Creates a text field with a label. The initial content will be the return value of the initalObject's {@link #toString()}
600
     * method.<br>
601
     * <b>Note</b>: if initialObject is <code>null</code> then an empty string is used.
602
     * @param parentElement the parent container
603
     * @param labelString the label name
604
     * @param initialObject the object from which the <code>toString()</code> method is called
605
     * @param style {@link SWT} style constant
606
     * @return the created textfield with label
607
     */
608
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
609
            Object initialObject, int style) {
610
        return createTextWithLabelElement(parentElement, labelString, initialObject==null?"":initialObject.toString(), style);
611
    }
612

    
613
    /**
614
     * <p>
615
     * createTextWithLabelElement
616
     * </p>
617
     *
618
     * @param parentElement
619
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
620
     *            object.
621
     * @param labelString
622
     *            a {@link java.lang.String} object.
623
     * @param initialText
624
     *            a {@link java.lang.String} object.
625
     * @param style
626
     *            a int.
627
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
628
     *         object.
629
     */
630
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
631
            String initialText, int style) {
632
        return createTextWithLabelElement(parentElement, labelString, initialText, null, style);
633
    }
634
    /**
635
     * <p>
636
     * createTextWithLabelElement
637
     * </p>
638
     *
639
     * @param parentElement
640
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
641
     *            object.
642
     * @param labelString
643
     *            a {@link java.lang.String} object.
644
     * @param initialText
645
     *            a {@link java.lang.String} object.
646
     * @param textLimit maximal number of characters allowed
647
     * @param style
648
     *            a int.
649
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
650
     *         object.
651
     */
652
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
653
            String initialText, Integer textLimit, int style) {
654
        if(initialText==null){
655
            initialText = "";
656
        }
657

    
658
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null, textLimit, style);
659
        adapt(element);
660
        parentElement.addElement(element);
661
        return element;
662
    }
663

    
664
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
665
            URI initialUri, int style) {
666
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
667
        adapt(element);
668
        parentElement.addElement(element);
669
        return element;
670
    }
671

    
672
    /**
673
     * @param element
674
     * @param string
675
     * @param uri
676
     * @param style
677
     * @return
678
     */
679
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
680
            IOpenUrlEnabled openUrlEnabled, int style) {
681
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
682
                style);
683
        adapt(element);
684
        parentElement.addElement(element);
685
        return element;
686
    }
687

    
688
    /**
689
     *
690
     * @param parentElement
691
     * @param labelString
692
     * @param conversationEnabled
693
     * @param user
694
     * @param style
695
     * @return
696
     */
697
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
698
            ConversationHolder conversation, User user, int style) {
699
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
700
        adapt(element);
701
        parentElement.addElement(element);
702
        return element;
703
    }
704

    
705
    /**
706
     * <p>
707
     * createIntegerTextWithLabelElement
708
     * </p>
709
     *
710
     * @param parentElement
711
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
712
     *            object.
713
     * @param labelString
714
     *            a {@link java.lang.String} object.
715
     * @param initialInteger
716
     *            a {@link java.lang.Integer} object.
717
     * @param style
718
     *            a int.
719
     * @return a
720
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
721
     *         object.
722
     */
723
	public NumberWithLabelElement createNumberTextWithLabelElement(
724
			ICdmFormElement parentElement, String labelString,
725
			Number initialNumber, int style) {
726
		NumberWithLabelElement element = new NumberWithLabelElement(this,
727
				parentElement, labelString, initialNumber, style);
728
		adapt(element);
729
		parentElement.addElement(element);
730
		return element;
731
	}
732

    
733
    /**
734
     * <p>
735
     * createLanguageStringWithLabelElement
736
     * </p>
737
     *
738
     * @param parentElement
739
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
740
     *            object.
741
     * @param labelString
742
     *            a {@link java.lang.String} object.
743
     * @param languageString
744
     *            a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
745
     * @param style
746
     *            a int.
747
     * @return a
748
     *         {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement}
749
     *         object.
750
     */
751
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
752
            String labelString, LanguageString languageString, int style) {
753
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
754
                languageString, style);
755
        adapt(element);
756
        parentElement.addElement(element);
757
        return element;
758
    }
759

    
760
    /**
761
     * <p>
762
     * createLanguageStringWithLabelElement
763
     * </p>
764
     *
765
     * @param parentElement
766
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
767
     *            object.
768
     * @param labelString
769
     *            a {@link java.lang.String} object.
770
     * @param languageString
771
     *            a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
772
     * @param height
773
     *            a int.
774
     * @param style
775
     *            a int.
776
     * @return a
777
     *         {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement}
778
     *         object.
779
     */
780
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
781
            String labelString, LanguageString languageString, int height, int style) {
782
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
783
                languageString, height, style);
784
        adapt(element);
785
        parentElement.addElement(element);
786
        return element;
787
    }
788

    
789
    /**
790
     * <p>
791
     * createTextElement
792
     * </p>
793
     *
794
     * @param parentElement
795
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
796
     *            object.
797
     * @param initialText
798
     *            a {@link java.lang.String} object.
799
     * @param style
800
     *            a int.
801
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
802
     *         object.
803
     */
804
    public TextWithLabelElement createTextElement(ICdmFormElement parentElement, String initialText, int style) {
805
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, null, initialText, null, style);
806
        adapt(element);
807
        parentElement.addElement(element);
808
        return element;
809
    }
810

    
811
    /**
812
     * <p>
813
     * createKeyValueViewerElement
814
     * </p>
815
     *
816
     * @param parentElement
817
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
818
     *            object.
819
     * @param keyHeading
820
     *            a {@link java.lang.String} object.
821
     * @param valueHeading
822
     *            a {@link java.lang.String} object.
823
     * @param map
824
     *            a {@link java.util.Map} object.
825
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
826
     *         object.
827
     */
828
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
829
            String valueHeading, Map<Object, Object> map) {
830
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
831
        adapt(element);
832
        parentElement.addElement(element);
833
        return element;
834
    }
835

    
836
    /**
837
     * <p>
838
     * createTermComboElement
839
     * </p>
840
     *
841
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
842
     * @param termComboType
843
     *            a
844
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
845
     *            object.
846
     * @param parentElement
847
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
848
     *            object.
849
     * @param labelString
850
     *            a {@link java.lang.String} object.
851
     * @param selection
852
     *            a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
853
     *            object.
854
     * @param style
855
     *            a int.
856
     * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
857
     *         object.
858
     */
859
    @Deprecated
860
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
861
            ICdmFormElement parentElement, String labelString, T selection, int style) {
862
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString,
863
                selection, style);
864
        adapt(element);
865
        parentElement.addElement(element);
866
        return element;
867
    }
868

    
869
	/**
870
	 * <p>
871
	 * createTermComboElement
872
	 * </p>
873
	 *
874
	 * @param termComboType
875
	 *            a
876
	 *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
877
	 *            object.
878
	 * @param parentElement
879
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
880
	 *            object.
881
	 * @param labelString
882
	 *            a {@link java.lang.String} object.
883
	 * @param selection
884
	 *            a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
885
	 *            object.
886
	 * @param style
887
	 *            a int.
888
	 * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
889
	 *         object.
890
	 */
891

    
892
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
893
			TermType termType,
894
			ICdmFormElement parentElement,
895
			String labelString,
896
			T selection,
897
			int style) {
898
		TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, style);
899
		adapt(element);
900
		parentElement.addElement(element);
901
		return element;
902
	}
903

    
904
	/**
905
	 * <p>
906
	 * createTermComboElement
907
	 * </p>
908
	 *
909
	 * @param termComboType
910
	 *            a
911
	 *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
912
	 *            object.
913
	 * @param parentElement
914
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
915
	 *            object.
916
	 * @param labelString
917
	 *            a {@link java.lang.String} object.
918
	 * @param selection
919
	 *            a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
920
	 *            object.
921
	 * @param style
922
	 *            a int.
923
	 * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
924
	 *         object.
925
	 */
926

    
927
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
928
	        TermVocabulary<?> termVocabulary,
929
	        ICdmFormElement parentElement,
930
	        String labelString,
931
	        T selection,
932
	        int style) {
933
	    TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, style);
934
	    adapt(element);
935
	    parentElement.addElement(element);
936
	    return element;
937
	}
938

    
939
    /**
940
     * <p>
941
     * createEnumComboElement
942
     * </p>
943
     *
944
     * @param enumComboType
945
     *            a
946
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType}
947
     *            object.
948
     * @param parentElement
949
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
950
     *            object.
951
     * @param style
952
     *            a int.
953
     * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
954
     *         object.
955
     */
956
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
957
			Class<T> enumComboType, ICdmFormElement parentElement,
958
			int style) {
959
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
960
        adapt(element);
961
        parentElement.addElement(element);
962
        return element;
963
    }
964

    
965
    /**
966
     * <p>
967
     * createBrowserElement
968
     * </p>
969
     *
970
     * @param imageUri
971
     *            a {@link java.net.URI} object.
972
     * @param style
973
     *            a int.
974
     * @param parentElement
975
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
976
     *            object.
977
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
978
     *         object.
979
     */
980
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
981
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
982
        adapt(element);
983
        parentElement.addElement(element);
984
        return element;
985
    }
986

    
987
    /**
988
     * <p>
989
     * createImageElement
990
     * </p>
991
     *
992
     * @param parentElement
993
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
994
     *            object.
995
     * @param imageUri
996
     *            a {@link java.net.URI} object.
997
     * @param style
998
     *            a int.
999
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1000
     */
1001
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1002
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1003
        adapt(element);
1004
        parentElement.addElement(element);
1005
        return element;
1006
    }
1007

    
1008
    /**
1009
     * <p>
1010
     * createTextActionElement
1011
     * </p>
1012
     *
1013
     * @param labelString
1014
     *            a {@link java.lang.String} object.
1015
     * @param initialText
1016
     *            a {@link java.lang.String} object.
1017
     * @param style
1018
     *            a int.
1019
     * @param parentElement
1020
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1021
     *            object.
1022
     * @param buttonLabel
1023
     *            a {@link java.lang.String} object.
1024
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
1025
     *         object.
1026
     */
1027
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
1028
            String buttonLabel, String initialText, int style) {
1029
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
1030
                style);
1031
        adapt(element);
1032
        parentElement.addElement(element);
1033
        return element;
1034
    }
1035

    
1036
    /**
1037
     * <p>
1038
     * createCheckbox
1039
     * </p>
1040
     *
1041
     * @param parentElement
1042
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1043
     *            object.
1044
     * @param label
1045
     *            a {@link java.lang.String} object.
1046
     * @param initialState
1047
     *            a boolean.
1048
     * @param style
1049
     *            a int.
1050
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1051
     *         object.
1052
     */
1053
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1054
        if(initialState==null){
1055
            initialState = Boolean.FALSE;
1056
        }
1057
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1058
        adapt(element);
1059
        parentElement.addElement(element);
1060
        return element;
1061
    }
1062

    
1063
    /**
1064
     * Creates a section as a part of the form.
1065
     *
1066
     * @return the section widget
1067
     * @param section
1068
     *            a
1069
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1070
     *            object.
1071
     */
1072
    public Section adapt(AbstractFormSection section) {
1073
        section.setMenu(section.getLayoutComposite().getMenu());
1074
        adapt(section, true, true);
1075

    
1076
        // handle focus and property change events for cdm use
1077
        section.addFocusListener(selectionFocusHandler);
1078
        section.setPropertyChangeListeners(propertyChangeListeners);
1079

    
1080
        if (section.getToggle() != null) {
1081
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1082
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1083
        }
1084

    
1085
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1086

    
1087
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1088
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1089
            getColors().initializeSectionToolBarColors();
1090
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1091
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1092
        }
1093
        // call setTitleBarForeground regardless as it also sets the label color
1094
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1095
        return section;
1096
    }
1097

    
1098
    private class BoldFontHolder2 {
1099
        private Font normalFont;
1100

    
1101
        private Font boldFont;
1102

    
1103
        public BoldFontHolder2() {
1104
        }
1105

    
1106
        public Font getBoldFont(Font font) {
1107
            createBoldFont(font);
1108
            return boldFont;
1109
        }
1110

    
1111
        private void createBoldFont(Font font) {
1112
            if (normalFont == null || !normalFont.equals(font)) {
1113
                normalFont = font;
1114
                dispose();
1115
            }
1116
            if (boldFont == null) {
1117
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1118
            }
1119
        }
1120

    
1121
        public void dispose() {
1122
            if (boldFont != null) {
1123
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1124
                boldFont = null;
1125
            }
1126
        }
1127
    }
1128

    
1129
    /**
1130
     * <p>
1131
     * createToggleableTextField
1132
     * </p>
1133
     *
1134
     * @param parentElement
1135
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1136
     *            object.
1137
     * @param labelString
1138
     *            a {@link java.lang.String} object.
1139
     * @param initialText
1140
     *            a {@link java.lang.String} object.
1141
     * @param initialState
1142
     *            a boolean.
1143
     * @param style
1144
     *            a int.
1145
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1146
     *         object.
1147
     */
1148
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1149
            String initialText, boolean initialState, int style) {
1150
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1151
                initialState, style | orientation);
1152
        adapt(element);
1153
        parentElement.addElement(element);
1154
        return element;
1155
    }
1156

    
1157
    /**
1158
     * <p>
1159
     * createTimePeriodElement
1160
     * </p>
1161
     *
1162
     * @param parentElement
1163
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1164
     *            object.
1165
     * @param labelString
1166
     *            a {@link java.lang.String} object.
1167
     * @param timePeriod
1168
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1169
     * @param style
1170
     *            a int.
1171
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1172
     *         object.
1173
     */
1174
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1175
            TimePeriod timePeriod, int style) {
1176
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1177
        adapt(element);
1178
        parentElement.addElement(element);
1179
        return element;
1180
    }
1181

    
1182
	/**
1183
	 * <p>
1184
	 * createGatheringEventUnitElement
1185
	 * </p>
1186
	 *
1187
	 * @param parentElement
1188
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1189
	 *            object.
1190
	 * @param labelString
1191
	 *            a {@link java.lang.String} object.
1192
	 * @param timePeriod
1193
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1194
	 * @param style
1195
	 *            a int.
1196
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1197
	 *         object.
1198
	 */
1199
	public GatheringEventUnitElement createGatheringEventUnitElement(
1200
			ICdmFormElement parentElement,
1201
			String labelString,
1202
			DerivedUnitFacade gatheringEvent,
1203
			MinMaxTextSection.UnitType unitType,
1204
			int style) {
1205
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1206
				parentElement,
1207
				labelString,
1208
				gatheringEvent,
1209
				unitType,
1210
				style);
1211
		adapt(element);
1212
		parentElement.addElement(element);
1213
		return element;
1214
	}
1215

    
1216
    /**
1217
     * <p>
1218
     * createPointElement
1219
     * </p>
1220
     *
1221
     * @param style
1222
     *            a int.
1223
     * @param parentElement
1224
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1225
     *            object.
1226
     * @param point
1227
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1228
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1229
     */
1230
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1231
        PointElement element = new PointElement(this, parentElement, point, style);
1232
        adapt(element);
1233
        parentElement.addElement(element);
1234
        return element;
1235
    }
1236

    
1237

    
1238

    
1239
    /**
1240
     * @param conversationHolder
1241
     * @param parent
1242
     * @param detailsViewer
1243
     * @param i
1244
     * @return
1245
     */
1246
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1247
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1248
        parentElement.addElement(section);
1249
        adapt(section);
1250
        return section;
1251
    }
1252

    
1253
    /**
1254
     * <p>
1255
     * createDateDetailSection
1256
     * </p>
1257
     *
1258
     * @param parentElement
1259
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1260
     *            object.
1261
     * @param style
1262
     *            a int.
1263
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1264
     *         object.
1265
     */
1266
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1267
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1268
        parentElement.addElement(section);
1269
        adapt(section);
1270
        return section;
1271
    }
1272

    
1273
	/**
1274
	 * <p>
1275
	 * createDateDetailSection
1276
	 * </p>
1277
	 *
1278
	 * @param parentElement
1279
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1280
	 *            object.
1281
	 * @param style
1282
	 *            a int.
1283
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1284
	 *         object.
1285
	 */
1286
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1287
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1288
		parentElement.addElement(section);
1289
		adapt(section);
1290
		return section;
1291
	}
1292

    
1293
    /**
1294
     * <p>
1295
     * createPartialElement
1296
     * </p>
1297
     *
1298
     * @param parentElement
1299
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1300
     *            object.
1301
     * @param labelString
1302
     *            a {@link java.lang.String} object.
1303
     * @param partial
1304
     *            a {@link org.joda.time.Partial} object.
1305
     * @param style
1306
     *            a int.
1307
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1308
     *         object.
1309
     */
1310
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1311
            int style) {
1312
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1313
        adapt(element);
1314
        parentElement.addElement(element);
1315
        return element;
1316
    }
1317

    
1318
    /**
1319
     * <p>
1320
     * addSelectionListener
1321
     * </p>
1322
     *
1323
     * @param listener
1324
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1325
     */
1326
    public void addSelectionListener(SelectionListener listener) {
1327
        selectionListenerList.add(listener);
1328
    }
1329

    
1330
    /**
1331
     * <p>
1332
     * removeSelectionListener
1333
     * </p>
1334
     *
1335
     * @param listener
1336
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1337
     */
1338
    public void removeSelectionListener(SelectionListener listener) {
1339
        if (listener == null) {
1340
            MessagingUtils.error(this.getClass(),
1341
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1342
        } else {
1343
            selectionListenerList.remove(listener);
1344
        }
1345
    }
1346

    
1347
    /**
1348
     * <p>
1349
     * addPropertyChangeListener
1350
     * </p>
1351
     *
1352
     * @param listener
1353
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1354
     *            object.
1355
     */
1356
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1357
        if (propertyChangeListeners.contains(listener)) {
1358
            return;
1359
        }
1360
        propertyChangeListeners.add(0, listener);
1361
    }
1362

    
1363
    /**
1364
     * <p>
1365
     * removePropertyChangeListener
1366
     * </p>
1367
     *
1368
     * @param listener
1369
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1370
     *            object.
1371
     */
1372
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1373
        propertyChangeListeners.remove(listener);
1374
    }
1375

    
1376
    /**
1377
     * @return the propertyChangeListeners
1378
     */
1379
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1380
        return propertyChangeListeners;
1381
    }
1382

    
1383
    /**
1384
     * <p>
1385
     * createHorizontalSeparator
1386
     * </p>
1387
     *
1388
     * @param parentElement
1389
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1390
     *            object.
1391
     * @param style
1392
     *            a int.
1393
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1394
     */
1395
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1396
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1397
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1398
        return separator;
1399
    }
1400

    
1401
    /**
1402
     * <p>
1403
     * createVersionElement
1404
     * </p>
1405
     *
1406
     * @param parentElement
1407
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1408
     *            object.
1409
     * @param entity
1410
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1411
     *            object.
1412
     * @param style
1413
     *            a int.
1414
     * @return a
1415
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1416
     *         object.
1417
     */
1418
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1419
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1420
        adapt(element);
1421
        parentElement.addElement(element);
1422
        return element;
1423
    }
1424

    
1425
    /**
1426
     * @param cdmBaseSection
1427
     * @param object
1428
     * @param style
1429
     * @return
1430
     */
1431
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1432
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1433
        adapt(element);
1434
        parentElement.addElement(element);
1435
        return element;
1436
    }
1437

    
1438
    /**
1439
     * <p>
1440
     * createVersionSection
1441
     * </p>
1442
     *
1443
     * @param parentElement
1444
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1445
     *            object.
1446
     * @param style
1447
     *            a int.
1448
     * @return a
1449
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1450
     *         object.
1451
     */
1452
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1453
        VersionSection section = new VersionSection(this, parentElement, style);
1454
        parentElement.addElement(section);
1455
        adapt(section);
1456
        return section;
1457
    }
1458

    
1459
    /**
1460
     * @param parent
1461
     * @param i
1462
     * @return
1463
     */
1464
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1465
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1466
        parentElement.addElement(section);
1467
        adapt(section);
1468
        return section;
1469
    }
1470

    
1471
    /**
1472
     * <p>
1473
     * createEmptyElement
1474
     * </p>
1475
     *
1476
     * @param parentElement
1477
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1478
     *            object.
1479
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1480
     */
1481
    public EmptyElement createEmptyElement(ICdmFormElement parentElement) {
1482
        EmptyElement element = new EmptyElement(this, parentElement, null, SWT.NULL);
1483
        adapt(element);
1484
        parentElement.addElement(element);
1485
        return element;
1486
    }
1487

    
1488
    /**
1489
     * <p>
1490
     * createHeadlineSection
1491
     * </p>
1492
     *
1493
     * @param parentElement
1494
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1495
     *            object.
1496
     * @return a
1497
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1498
     *         object.
1499
     */
1500
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1501
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1502
        parentElement.addElement(section);
1503
        adapt(section);
1504
        return section;
1505
    }
1506

    
1507
    /**
1508
     * <p>
1509
     * createParsingMessageElement
1510
     * </p>
1511
     *
1512
     * @param parentElement
1513
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1514
     *            object.
1515
     * @param parserProblem
1516
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1517
     *            object.
1518
     * @param style
1519
     *            a int.
1520
     * @return a
1521
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1522
     *         object.
1523
     */
1524
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1525
            ParserProblem parserProblem, int style) {
1526
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1527
        adapt(element);
1528
        parentElement.addElement(element);
1529
        return element;
1530
    }
1531

    
1532
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1533
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1534

    
1535
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1536
                selectionProvider, style);
1537

    
1538
        parentElement.addElement(section);
1539
        adapt(section);
1540
        return section;
1541

    
1542
    }
1543

    
1544
    /**
1545
     * @param definedTermClass
1546
     * @param formElement
1547
     * @param style
1548
     * @return
1549
     */
1550
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1551
            AbstractCdmDetailSection parentElement, int style) {
1552
        AbstractCdmDetailElement element = null;
1553

    
1554
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1555
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1556
        } else if (definedTermClass.equals(Feature.class)) {
1557
            element = new FeatureDetailElement(this, parentElement);
1558
        } else {
1559
            element = new DefinedTermDetailElement(this, parentElement);
1560
        }
1561

    
1562
        adapt(element);
1563
        parentElement.addElement(element);
1564
        return element;
1565
    }
1566

    
1567

    
1568
    //--------DetailSections---------
1569
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1570
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1571
        addAndAdaptSection(parentElement, section);
1572
        return section;
1573
    }
1574

    
1575
    public ReferenceDetailSection createReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1576
        ReferenceDetailSection section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1577
        addAndAdaptSection(parentElement, section);
1578
        return section;
1579
    }
1580

    
1581
    public NomenclaturalReferenceDetailSection createNomenclaturalReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1582
        NomenclaturalReferenceDetailSection section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1583
        addAndAdaptSection(parentElement, section);
1584
        return section;
1585
    }
1586

    
1587
    public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1588
        TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1589
        addAndAdaptSection(parentElement, section);
1590
        return section;
1591
    }
1592

    
1593
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1594
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1595
        addAndAdaptSection(parentElement, section);
1596
        return section;
1597
    }
1598

    
1599
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1600
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1601
        addAndAdaptSection(parentElement, section);
1602
        return section;
1603
    }
1604

    
1605
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1606
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1607
        addAndAdaptSection(parentElement, section);
1608
        return section;
1609
    }
1610

    
1611
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1612
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1613
        addAndAdaptSection(parentElement, section);
1614
        return section;
1615
    }
1616

    
1617
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1618
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1619
        addAndAdaptSection(parentElement, section);
1620
        return section;
1621
    }
1622

    
1623
    public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1624
        DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1625
        addAndAdaptSection(parentElement, section);
1626
        return section;
1627
    }
1628

    
1629
    public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1630
        ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1631
        addAndAdaptSection(parentElement, section);
1632
        return section;
1633
    }
1634

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1761
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1762
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
1763
        addAndAdaptSection(parentElement, section);
1764
        return section;
1765
    }
1766

    
1767
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1768
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
1769
        addAndAdaptSection(parentElement, section);
1770
        return section;
1771
    }
1772

    
1773
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1774
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1775
        addAndAdaptSection(parentElement, section);
1776
        return section;
1777
    }
1778

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

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

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

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

    
1803
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1804
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1805
        addAndAdaptSection(parentElement, section);
1806
        return section;
1807
    }
1808

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

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

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

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

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

    
1839
    public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1840
        GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
1841
        addAndAdaptSection(parentElement, section);
1842
        return section;
1843
    }
1844

    
1845
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1846
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1847
        addAndAdaptSection(parentElement, section);
1848
        return section;
1849
    }
1850

    
1851
    public PreservedSpecimenDeterminationDetailSection createPreservedSpecimenDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1852
        PreservedSpecimenDeterminationDetailSection section = new PreservedSpecimenDeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1853
        addAndAdaptSection(parentElement, section);
1854
        return section;
1855
    }
1856

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

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

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

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

    
1881
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1882
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
1883
        addAndAdaptSection(parentElement, section);
1884
        return section;
1885
    }
1886

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

    
1893
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1894
        parentElement.addElement(section);
1895
        adapt(section);
1896
    }
1897

    
1898
    //--------DetailElements------------
1899

    
1900
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1901
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1902
        addAndAdaptElement(parentElement, element);
1903
        return element;
1904
    }
1905

    
1906
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1907
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1908
        addAndAdaptElement(parentElement, element);
1909
        return element;
1910
    }
1911

    
1912
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1913
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1914
        addAndAdaptElement(parentElement, element);
1915
        return element;
1916
    }
1917

    
1918
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1919
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1920
        addAndAdaptElement(parentElement, element);
1921
        return element;
1922
    }
1923

    
1924
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1925
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1926
        addAndAdaptElement(parentElement, element);
1927
        return element;
1928
    }
1929

    
1930
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1931
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1932
        addAndAdaptElement(parentElement, element);
1933
        return element;
1934
    }
1935

    
1936
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1937
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
1938
        addAndAdaptElement(parentElement, element);
1939
        return element;
1940
    }
1941

    
1942
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
1943
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
1944
        addAndAdaptElement(parentElement, element);
1945
        return element;
1946
    }
1947

    
1948
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
1949
        UserDetailElement element = new UserDetailElement(this, parentElement);
1950
        addAndAdaptElement(parentElement, element);
1951
        return element;
1952
    }
1953

    
1954
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
1955
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
1956
        addAndAdaptElement(parentElement, element);
1957
        return element;
1958
    }
1959

    
1960
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
1961
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
1962
        addAndAdaptElement(parentElement, element);
1963
        return element;
1964
    }
1965

    
1966
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
1967
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
1968
        addAndAdaptElement(parentElement, element);
1969
        return element;
1970
    }
1971

    
1972
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
1973
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
1974
        addAndAdaptElement(parentElement, element);
1975
        return element;
1976
    }
1977

    
1978
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
1979
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
1980
        addAndAdaptElement(parentElement, element);
1981
        return element;
1982
    }
1983

    
1984
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement){
1985
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement);
1986
        addAndAdaptElement(parentElement, element);
1987
        return element;
1988
    }
1989

    
1990
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
1991
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
1992
        addAndAdaptElement(parentElement, element);
1993
        return element;
1994
    }
1995

    
1996
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
1997
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
1998
        addAndAdaptElement(parentElement, element);
1999
        return element;
2000
    }
2001

    
2002
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2003
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2004
        addAndAdaptElement(parentElement, element);
2005
        return element;
2006
    }
2007

    
2008
    public DerivedUnitFacadeDetailElement createDerivedUnitFacadeDetailElement(ICdmFormElement parentElement){
2009
        DerivedUnitFacadeDetailElement element = new DerivedUnitFacadeDetailElement(this, parentElement);
2010
        addAndAdaptElement(parentElement, element);
2011
        return element;
2012
    }
2013

    
2014
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2015
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2016
        addAndAdaptElement(parentElement, element);
2017
        return element;
2018
    }
2019

    
2020
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2021
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2022
        addAndAdaptElement(parentElement, element);
2023
        return element;
2024
    }
2025

    
2026
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2027
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2028
        addAndAdaptElement(parentElement, element);
2029
        return element;
2030
    }
2031

    
2032
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2033
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2034
        addAndAdaptElement(parentElement, element);
2035
        return element;
2036
    }
2037

    
2038
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style){
2039
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style);
2040
        addAndAdaptElement(parentElement, element);
2041
        return element;
2042
    }
2043

    
2044
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2045
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2046
        addAndAdaptElement(parentElement, element);
2047
        return element;
2048
    }
2049

    
2050
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2051
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2052
        addAndAdaptElement(parentElement, element);
2053
        return element;
2054
    }
2055

    
2056
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2057
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2058
        addAndAdaptElement(parentElement, element);
2059
        return element;
2060
    }
2061

    
2062
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
2063
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
2064
        addAndAdaptElement(parentElement, element);
2065
        return element;
2066
    }
2067

    
2068
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2069
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2070
        addAndAdaptElement(parentElement, element);
2071
        return element;
2072
    }
2073

    
2074

    
2075
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2076
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2077
        addAndAdaptElement(parentElement, element);
2078
        return element;
2079
    }
2080

    
2081
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2082
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2083
        addAndAdaptElement(parentElement, element);
2084
        return element;
2085
    }
2086

    
2087
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2088
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2089
        addAndAdaptElement(parentElement, element);
2090
        return element;
2091
    }
2092

    
2093
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2094
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2095
        addAndAdaptElement(parentElement, element);
2096
        return element;
2097
    }
2098

    
2099
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2100
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2101
        addAndAdaptElement(parentElement, element);
2102
        return element;
2103
    }
2104

    
2105
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2106
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2107
        addAndAdaptElement(parentElement, element);
2108
        return element;
2109
    }
2110

    
2111
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2112
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2113
        addAndAdaptElement(parentElement, element);
2114
        return element;
2115
    }
2116

    
2117
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2118
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2119
        addAndAdaptElement(parentElement, element);
2120
        return element;
2121
    }
2122

    
2123
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2124
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2125
        addAndAdaptElement(parentElement, element);
2126
        return element;
2127
    }
2128

    
2129
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2130
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2131
        addAndAdaptElement(parentElement, element);
2132
        return element;
2133
    }
2134

    
2135
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2136
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2137
        addAndAdaptElement(parentElement, element);
2138
        return element;
2139
    }
2140

    
2141
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2142
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2143
        addAndAdaptElement(parentElement, element);
2144
        return element;
2145
    }
2146

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

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

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

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

    
2171

    
2172
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2173
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2174
        addAndAdaptElement(parentElement, element);
2175
        return element;
2176
    }
2177

    
2178
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2179
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2180
        addAndAdaptElement(parentElement, element);
2181
        return element;
2182
    }
2183

    
2184

    
2185
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2186
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2187
        addAndAdaptElement(parentElement, element);
2188
        return element;
2189
    }
2190

    
2191
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2192
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2193
        addAndAdaptElement(parentElement, element);
2194
        return element;
2195
    }
2196

    
2197
    public PreservedSpecimenDeterminationDetailElement createPreservedSpecimenDeterminationDetailElement(ICdmFormElement parentElement) {
2198
        PreservedSpecimenDeterminationDetailElement element = new PreservedSpecimenDeterminationDetailElement(this, parentElement);
2199
        addAndAdaptElement(parentElement, element);
2200
        return element;
2201
    }
2202

    
2203
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2204
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2205
        addAndAdaptElement(parentElement, element);
2206
        return element;
2207
    }
2208

    
2209
    /**
2210
     * @param parentElement
2211
     * @param element
2212
     */
2213
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2214
        adapt(element);
2215
        parentElement.addElement(element);
2216
    }
2217

    
2218
    //--------EntityCollectionSection----------
2219
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2220
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style);
2221
        addAndAdaptSection(parentElement, section);
2222
        return section;
2223
    }
2224

    
2225
    public AnnotationSection createAnnotationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2226
        AnnotationSection section = new AnnotationSection(this, conversation, parentElement, style);
2227
        addAndAdaptSection(parentElement, section);
2228
        return section;
2229
    }
2230

    
2231
    public CreditSection createCreditSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2232
        CreditSection section = new CreditSection(this, conversation, parentElement, style);
2233
        addAndAdaptSection(parentElement, section);
2234
        return section;
2235
    }
2236

    
2237
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2238
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2239
        addAndAdaptSection(parentElement, section);
2240
        return section;
2241
    }
2242

    
2243
    public ExtensionSection createExtensionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2244
        ExtensionSection section = new ExtensionSection(this, conversation, parentElement, style);
2245
        addAndAdaptSection(parentElement, section);
2246
        return section;
2247
    }
2248

    
2249
    public MarkerSection createMarkerSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2250
        MarkerSection section = new MarkerSection(this, conversation, parentElement, style);
2251
        addAndAdaptSection(parentElement, section);
2252
        return section;
2253
    }
2254

    
2255
    public MediaSection createMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2256
        MediaSection section = new MediaSection(this, conversation, parentElement, style);
2257
        addAndAdaptSection(parentElement, section);
2258
        return section;
2259
    }
2260

    
2261
    public DescriptionElementMediaSection createDescriptionElementMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2262
        DescriptionElementMediaSection section = new DescriptionElementMediaSection(this, conversation, parentElement, style);
2263
        addAndAdaptSection(parentElement, section);
2264
        return section;
2265
    }
2266

    
2267
    public MediaRepresentationSection createMediaRepresentationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2268
        MediaRepresentationSection section = new MediaRepresentationSection(this, conversation, parentElement, style);
2269
        addAndAdaptSection(parentElement, section);
2270
        return section;
2271
    }
2272

    
2273
    public MediaRepresentationPartSection createMediaRepresentationPartSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2274
        MediaRepresentationPartSection section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
2275
        addAndAdaptSection(parentElement, section);
2276
        return section;
2277
    }
2278

    
2279
    public ModifierSection createModifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2280
        ModifierSection section = new ModifierSection(this, conversation, parentElement, style);
2281
        addAndAdaptSection(parentElement, section);
2282
        return section;
2283
    }
2284

    
2285
    public NomenclaturalStatusSection createNomenclaturalStatusSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2286
        NomenclaturalStatusSection section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
2287
        addAndAdaptSection(parentElement, section);
2288
        return section;
2289
    }
2290

    
2291
    public NameRelationshipDetailSection createNameRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2292
        NameRelationshipDetailSection section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
2293
        addAndAdaptSection(parentElement, section);
2294
        return section;
2295
    }
2296

    
2297
    public SynonymRelationshipDetailSection createSynonymRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2298
        SynonymRelationshipDetailSection section = new SynonymRelationshipDetailSection(this, conversation, parentElement, style);
2299
        addAndAdaptSection(parentElement, section);
2300
        return section;
2301
    }
2302

    
2303
    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2304
        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2305
        addAndAdaptSection(parentElement, section);
2306
        return section;
2307
    }
2308

    
2309
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2310
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2311
        addAndAdaptSection(parentElement, section);
2312
        return section;
2313
    }
2314

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2441
    /**
2442
     * <p>
2443
     * createEntityCollectionElement
2444
     * </p>
2445
     *
2446
     * @param removeListener
2447
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
2448
     * @param style
2449
     *            a int.
2450
     * @param parentElement
2451
     *            a
2452
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
2453
     *            object.
2454
     * @param versionableEntity
2455
     *            a {@link eu.etaxonomy.cdm.model.common.IVersionableEntity}
2456
     *            object.
2457
     * @param backgroundColor
2458
     *            a {@link org.eclipse.swt.graphics.Color} object.
2459
     * @return a
2460
     *         {@link eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement}
2461
     *         object.
2462
     */
2463
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2464
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2465
        AbstractEntityCollectionElement element = null;
2466

    
2467
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2468

    
2469
        if (entity instanceof Annotation) {
2470
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2471
        } else if (entity instanceof Person) {
2472
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
2473
        } else if (entity instanceof Credit) {
2474
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2475
        } else if (entity instanceof Extension) {
2476
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2477
        } else if (entity instanceof Marker) {
2478
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2479
        } else if (entity instanceof Media) {
2480
            element = new MediaElement(this, parentElement, (Media) entity, removeListener, style);
2481
        } else if (entity instanceof MediaRepresentation) {
2482
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2483
                    style);
2484
        } else if (entity instanceof ImageFile) {
2485
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2486
        } else if (entity instanceof MediaRepresentationPart) {
2487
            element = new MediaRepresentationPartElement(this, parentElement, (MediaRepresentationPart) entity,
2488
                    removeListener, style);
2489
        } else if (entity instanceof NomenclaturalStatus) {
2490
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2491
                    style);
2492
        } else if (entity instanceof Rights) {
2493
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2494
        } else if (entity instanceof DescriptionElementSource) {
2495
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2496
                    removeListener, style);
2497
        } else if (entity instanceof IdentifiableSource) {
2498
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2499
                    style);
2500
		} else if (entity instanceof DefinedTerm) {
2501
			switch(((DefinedTerm)entity).getTermType()) {
2502
				case Scope:
2503
					element = new ScopeElement(this,
2504
							parentElement,
2505
							(DefinedTerm) entity,
2506
							removeListener,
2507
							style);
2508
					break;
2509
				case Modifier:
2510
					element = new ModifierElement(this,
2511
							parentElement,
2512
							(DefinedTerm) entity,
2513
							removeListener,
2514
							style);
2515
					break;
2516
				default:
2517
					//FIXME : Actually we should through an exception here
2518
					element = null;
2519
					break;
2520

    
2521
			}
2522
        } else if (entity instanceof Reference) {
2523
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2524
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2525
            }
2526
            else{
2527
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2528
            }
2529
        } else if (entity instanceof NameTypeDesignation) {
2530
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2531
                    style);
2532
        } else if (entity instanceof NameRelationship) {
2533
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2534
                    style);
2535
        } else if (entity instanceof SynonymRelationship) {
2536
            element = new SynonymRelationshipDetailElement(this, parentElement, (SynonymRelationship) entity, removeListener,
2537
                    style);
2538
        } else if (entity instanceof SpecimenTypeDesignation) {
2539
            element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2540
                    removeListener, style);
2541
        } else if (entity instanceof StateData) {
2542
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2543
        } else if (entity instanceof StatisticalMeasurementValue) {
2544
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2545
                    removeListener, style);
2546
        } else if (entity instanceof DerivedUnit) {
2547
        	switch(((DerivedUnit)entity).getRecordBasis()) {
2548
				case LivingSpecimen:
2549
				case PreservedSpecimen:
2550
				case OtherSpecimen:
2551
					element = new SpecimenCollectionDetailElement(this,
2552
								parentElement,
2553
								(DerivedUnit) entity,
2554
								removeListener,
2555
								style);
2556
					break;
2557
				default:
2558
					element = new DerivedUnitElement(this,
2559
								parentElement,
2560
								(DerivedUnit) entity,
2561
								removeListener,
2562
								style);
2563
			}
2564

    
2565
        } else if (entity instanceof NamedArea) {
2566
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2567
        } else if (entity instanceof DeterminationEvent) {
2568
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2569
        } else if (entity instanceof User) {
2570
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2571
        } else if (entity instanceof GrantedAuthority) {
2572
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity,
2573
                    removeListener, style);
2574
        } else if (entity instanceof Group) {
2575
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2576
        } else if (entity instanceof Taxon) {
2577
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2578
        } else if (entity instanceof DescriptionElementBase) {
2579
            // this is the special case for protologs, maybe we can do this
2580
            // differently when API improves
2581
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2582
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2583
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2584
            }
2585
        }
2586

    
2587
        if (element == null) {
2588
            MessagingUtils.messageDialog("No element for entity", this,
2589
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2590
                            + entity, null);
2591
        }
2592

    
2593
        else if (backgroundColor != null && !backgroundColor.isDisposed()) {
2594
            element.setPersistentBackground(backgroundColor);
2595
            adapt(element);
2596
            parentElement.addElement(element);
2597
        }
2598

    
2599
        return element;
2600
    }
2601

    
2602
    /**
2603
     * <p>
2604
     * Creates a selection element for the given type T.
2605
     * </p>
2606
     * <p>
2607
     * <strong>Selection elements not handled by this method:</strong>
2608
     * <ul>
2609
     * <li>{@link TaxonNodeSelectionElement} see
2610
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2611
     * </li>
2612
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2613
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2614
     * </li>
2615
     * </ul>
2616
     * </p>
2617
     *
2618
     * @param clazz
2619
     *            a {@link Class} object of the type that you want the selection
2620
     *            element to handle
2621
     * @param parentElement
2622
     *            a {@link ICdmFormElement} object.
2623
     * @param labelString
2624
     *            a {@link String} object.
2625
     * @param selectionType
2626
     * @param selection
2627
     *            a {@link ICdmBase} object.
2628
     * @param style
2629
     *            a int.
2630
     * @param conversation
2631
     *            a {@link ConversationHolder} object.
2632
     * @return a {@link EntitySelectionElement} object.
2633
     */
2634
    public <T extends ICdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2635
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2636
            int style) {
2637
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2638
                labelString, selection, mode, style);
2639
        adapt(element);
2640
        parentElement.addElement(element);
2641
        return element;
2642
    }
2643

    
2644
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2645
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2646
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2647
                labelString, selection, mode, style);
2648
        adapt(element);
2649
        parentElement.addElement(element);
2650
        return element;
2651
    }
2652

    
2653
    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2654
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2655
            int mode, int style) {
2656
        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2657
                conversation, parentElement, labelString, selection, mode, style);
2658
        adapt(element);
2659
        parentElement.addElement(element);
2660
        return element;
2661
    }
2662

    
2663
    /** {@inheritDoc} */
2664
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2665
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2666
        adapt(labelElement);
2667
        parentElement.addElement(labelElement);
2668
        return labelElement;
2669
    }
2670

    
2671
    /**
2672
     * <p>
2673
     * Getter for the field <code>selectionProvider</code>.
2674
     * </p>
2675
     *
2676
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2677
     */
2678
    public ISelectionProvider getSelectionProvider() {
2679
        return selectionProvider;
2680
    }
2681

    
2682
    /**
2683
     * <p>
2684
     * createDetailedDescriptionDetailElement
2685
     * </p>
2686
     *
2687
     * @param parentElement
2688
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2689
     *            object.
2690
     * @param entity
2691
     *            a
2692
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2693
     *            object.
2694
     * @param style
2695
     *            a int.
2696
     * @return a
2697
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2698
     *         object.
2699
     */
2700
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2701
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2702
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2703

    
2704
        if (entity instanceof CategoricalData) {
2705
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2706
                    (CategoricalData) entity, style);
2707
        } else if (entity instanceof CommonTaxonName) {
2708
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2709
                    style);
2710
        } else if (entity instanceof Distribution) {
2711
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2712
                    style);
2713
        } else if (entity instanceof IndividualsAssociation) {
2714
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2715
                    (IndividualsAssociation) entity, style);
2716
        } else if (entity instanceof QuantitativeData) {
2717
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2718
                    (QuantitativeData) entity, style);
2719
        } else if (entity instanceof TaxonInteraction) {
2720
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2721
                    (TaxonInteraction) entity, style);
2722
        } else if (entity instanceof TextData) {
2723
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2724
        } else {
2725
            throw new IllegalStateException("There is no interface for the given description element");
2726
        }
2727
        adapt(detailedDescriptionElement);
2728
        parentElement.addElement(detailedDescriptionElement);
2729
        return detailedDescriptionElement;
2730

    
2731
    }
2732

    
2733
    /**
2734
     * Creates a styled text as a part of the form.
2735
     *
2736
     * @param parent
2737
     *            the text parent
2738
     * @param value
2739
     *            the text initial value
2740
     * @param style
2741
     *            the text style
2742
     * @return the text widget
2743
     */
2744
    public StyledText createStyledText(Composite parent, String value, int style) {
2745
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2746
        if (value != null) {
2747
            text.setText(value);
2748
        }
2749
        text.setForeground(getColors().getForeground());
2750
        text.setBackground(getColors().getBackground());
2751
        // text.addFocusListener(visibilityHandler);
2752
        return text;
2753
    }
2754

    
2755
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2756
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2757
        addAndAdaptSection(parentElement, section);
2758
        return section;
2759
    }
2760

    
2761
    /**
2762
     * @param parentElement
2763
     * @return
2764
     */
2765
    public OriginalLabelDataController createOriginalLabelDataController(AbstractCdmDetailSection<DerivedUnitFacade> parentElement) {
2766
        OriginalLabelDataElement originalLabelDataElement = new OriginalLabelDataElement(parentElement.getLayoutComposite(), SWT.NONE);
2767
        originalLabelDataElement.initController(this, parentElement);
2768
        return originalLabelDataElement.getController();
2769
    }
2770

    
2771
}
(6-6/39)