Project

General

Profile

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

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

    
314
    private BoldFontHolder2 boldFontHolder2;
315
    private MouseListener selectionMouseHandler;
316
    private FocusListener selectionFocusHandler;
317

    
318
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
319

    
320
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
321

    
322
    private final int orientation = Window.getDefaultOrientation();
323
    private ISelectionProvider selectionProvider;
324

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

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

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

    
359
    private void notifySelectionListeners(TypedEvent e) {
360
        Event event = new Event();
361
        event.widget = e.widget;
362
        SelectionEvent selectionEvent = new SelectionEvent(event);
363

    
364
        for (SelectionListener listener : selectionListenerList) {
365
            listener.widgetSelected(selectionEvent);
366
        }
367
    }
368

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

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

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

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

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

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

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

    
471
    /** {@inheritDoc} */
472
    @Override
473
    public void adapt(Composite composite) {
474
        composite.addMouseListener(selectionMouseHandler);
475
        super.adapt(composite);
476
    }
477

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

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

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

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

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

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

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

    
655
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null, textLimit, style);
656
        adapt(element);
657
        parentElement.addElement(element);
658
        return element;
659
    }
660

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

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

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

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

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

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

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

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

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

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

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

    
901
    /**
902
     * <p>
903
     * createEnumComboElement
904
     * </p>
905
     *
906
     * @param enumComboType
907
     *            a
908
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType}
909
     *            object.
910
     * @param parentElement
911
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
912
     *            object.
913
     * @param style
914
     *            a int.
915
     * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
916
     *         object.
917
     */
918
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
919
			Class<T> enumComboType, ICdmFormElement parentElement,
920
			int style) {
921
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
922
        adapt(element);
923
        parentElement.addElement(element);
924
        return element;
925
    }
926

    
927
    /**
928
     * <p>
929
     * createBrowserElement
930
     * </p>
931
     *
932
     * @param imageUri
933
     *            a {@link java.net.URI} object.
934
     * @param style
935
     *            a int.
936
     * @param parentElement
937
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
938
     *            object.
939
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
940
     *         object.
941
     */
942
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
943
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
944
        adapt(element);
945
        parentElement.addElement(element);
946
        return element;
947
    }
948

    
949
    /**
950
     * <p>
951
     * createImageElement
952
     * </p>
953
     *
954
     * @param parentElement
955
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
956
     *            object.
957
     * @param imageUri
958
     *            a {@link java.net.URI} object.
959
     * @param style
960
     *            a int.
961
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
962
     */
963
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
964
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
965
        adapt(element);
966
        parentElement.addElement(element);
967
        return element;
968
    }
969

    
970
    /**
971
     * <p>
972
     * createTextActionElement
973
     * </p>
974
     *
975
     * @param labelString
976
     *            a {@link java.lang.String} object.
977
     * @param initialText
978
     *            a {@link java.lang.String} object.
979
     * @param style
980
     *            a int.
981
     * @param parentElement
982
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
983
     *            object.
984
     * @param buttonLabel
985
     *            a {@link java.lang.String} object.
986
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
987
     *         object.
988
     */
989
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
990
            String buttonLabel, String initialText, int style) {
991
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
992
                style);
993
        adapt(element);
994
        parentElement.addElement(element);
995
        return element;
996
    }
997

    
998
    /**
999
     * <p>
1000
     * createCheckbox
1001
     * </p>
1002
     *
1003
     * @param parentElement
1004
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1005
     *            object.
1006
     * @param label
1007
     *            a {@link java.lang.String} object.
1008
     * @param initialState
1009
     *            a boolean.
1010
     * @param style
1011
     *            a int.
1012
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1013
     *         object.
1014
     */
1015
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1016
        if(initialState==null){
1017
            initialState = Boolean.FALSE;
1018
        }
1019
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1020
        adapt(element);
1021
        parentElement.addElement(element);
1022
        return element;
1023
    }
1024

    
1025
    /**
1026
     * Creates a section as a part of the form.
1027
     *
1028
     * @return the section widget
1029
     * @param section
1030
     *            a
1031
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1032
     *            object.
1033
     */
1034
    public Section adapt(AbstractFormSection section) {
1035
        section.setMenu(section.getLayoutComposite().getMenu());
1036
        adapt(section, true, true);
1037

    
1038
        // handle focus and property change events for cdm use
1039
        section.addFocusListener(selectionFocusHandler);
1040
        section.setPropertyChangeListeners(propertyChangeListeners);
1041

    
1042
        if (section.getToggle() != null) {
1043
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1044
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1045
        }
1046

    
1047
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1048

    
1049
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1050
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1051
            getColors().initializeSectionToolBarColors();
1052
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1053
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1054
        }
1055
        // call setTitleBarForeground regardless as it also sets the label color
1056
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1057
        return section;
1058
    }
1059

    
1060
    private class BoldFontHolder2 {
1061
        private Font normalFont;
1062

    
1063
        private Font boldFont;
1064

    
1065
        public BoldFontHolder2() {
1066
        }
1067

    
1068
        public Font getBoldFont(Font font) {
1069
            createBoldFont(font);
1070
            return boldFont;
1071
        }
1072

    
1073
        private void createBoldFont(Font font) {
1074
            if (normalFont == null || !normalFont.equals(font)) {
1075
                normalFont = font;
1076
                dispose();
1077
            }
1078
            if (boldFont == null) {
1079
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1080
            }
1081
        }
1082

    
1083
        public void dispose() {
1084
            if (boldFont != null) {
1085
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1086
                boldFont = null;
1087
            }
1088
        }
1089
    }
1090

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

    
1119
    /**
1120
     * <p>
1121
     * createTimePeriodElement
1122
     * </p>
1123
     *
1124
     * @param parentElement
1125
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1126
     *            object.
1127
     * @param labelString
1128
     *            a {@link java.lang.String} object.
1129
     * @param timePeriod
1130
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1131
     * @param style
1132
     *            a int.
1133
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1134
     *         object.
1135
     */
1136
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1137
            TimePeriod timePeriod, int style) {
1138
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1139
        adapt(element);
1140
        parentElement.addElement(element);
1141
        return element;
1142
    }
1143

    
1144
	/**
1145
	 * <p>
1146
	 * createGatheringEventUnitElement
1147
	 * </p>
1148
	 *
1149
	 * @param parentElement
1150
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1151
	 *            object.
1152
	 * @param labelString
1153
	 *            a {@link java.lang.String} object.
1154
	 * @param timePeriod
1155
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1156
	 * @param style
1157
	 *            a int.
1158
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1159
	 *         object.
1160
	 */
1161
	public GatheringEventUnitElement createGatheringEventUnitElement(
1162
			ICdmFormElement parentElement,
1163
			String labelString,
1164
			DerivedUnitFacade gatheringEvent,
1165
			MinMaxTextSection.UnitType unitType,
1166
			int style) {
1167
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1168
				parentElement,
1169
				labelString,
1170
				gatheringEvent,
1171
				unitType,
1172
				style);
1173
		adapt(element);
1174
		parentElement.addElement(element);
1175
		return element;
1176
	}
1177

    
1178
    /**
1179
     * <p>
1180
     * createPointElement
1181
     * </p>
1182
     *
1183
     * @param style
1184
     *            a int.
1185
     * @param parentElement
1186
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1187
     *            object.
1188
     * @param point
1189
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1190
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1191
     */
1192
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1193
        PointElement element = new PointElement(this, parentElement, point, style);
1194
        adapt(element);
1195
        parentElement.addElement(element);
1196
        return element;
1197
    }
1198

    
1199

    
1200

    
1201
    /**
1202
     * @param conversationHolder
1203
     * @param parent
1204
     * @param detailsViewer
1205
     * @param i
1206
     * @return
1207
     */
1208
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1209
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1210
        parentElement.addElement(section);
1211
        adapt(section);
1212
        return section;
1213
    }
1214

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

    
1235
	/**
1236
	 * <p>
1237
	 * createDateDetailSection
1238
	 * </p>
1239
	 *
1240
	 * @param parentElement
1241
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1242
	 *            object.
1243
	 * @param style
1244
	 *            a int.
1245
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1246
	 *         object.
1247
	 */
1248
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1249
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1250
		parentElement.addElement(section);
1251
		adapt(section);
1252
		return section;
1253
	}
1254

    
1255
    /**
1256
     * <p>
1257
     * createPartialElement
1258
     * </p>
1259
     *
1260
     * @param parentElement
1261
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1262
     *            object.
1263
     * @param labelString
1264
     *            a {@link java.lang.String} object.
1265
     * @param partial
1266
     *            a {@link org.joda.time.Partial} object.
1267
     * @param style
1268
     *            a int.
1269
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1270
     *         object.
1271
     */
1272
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1273
            int style) {
1274
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1275
        adapt(element);
1276
        parentElement.addElement(element);
1277
        return element;
1278
    }
1279

    
1280
    /**
1281
     * <p>
1282
     * addSelectionListener
1283
     * </p>
1284
     *
1285
     * @param listener
1286
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1287
     */
1288
    public void addSelectionListener(SelectionListener listener) {
1289
        selectionListenerList.add(listener);
1290
    }
1291

    
1292
    /**
1293
     * <p>
1294
     * removeSelectionListener
1295
     * </p>
1296
     *
1297
     * @param listener
1298
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1299
     */
1300
    public void removeSelectionListener(SelectionListener listener) {
1301
        if (listener == null) {
1302
            AbstractUtility.error(this.getClass(),
1303
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1304
        } else {
1305
            selectionListenerList.remove(listener);
1306
        }
1307
    }
1308

    
1309
    /**
1310
     * <p>
1311
     * addPropertyChangeListener
1312
     * </p>
1313
     *
1314
     * @param listener
1315
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1316
     *            object.
1317
     */
1318
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1319
        if (propertyChangeListeners.contains(listener)) {
1320
            return;
1321
        }
1322
        propertyChangeListeners.add(0, listener);
1323
    }
1324

    
1325
    /**
1326
     * <p>
1327
     * removePropertyChangeListener
1328
     * </p>
1329
     *
1330
     * @param listener
1331
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1332
     *            object.
1333
     */
1334
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1335
        propertyChangeListeners.remove(listener);
1336
    }
1337

    
1338
    /**
1339
     * @return the propertyChangeListeners
1340
     */
1341
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1342
        return propertyChangeListeners;
1343
    }
1344

    
1345
    /**
1346
     * <p>
1347
     * createHorizontalSeparator
1348
     * </p>
1349
     *
1350
     * @param parentElement
1351
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1352
     *            object.
1353
     * @param style
1354
     *            a int.
1355
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1356
     */
1357
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1358
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1359
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1360
        return separator;
1361
    }
1362

    
1363
    /**
1364
     * <p>
1365
     * createVersionElement
1366
     * </p>
1367
     *
1368
     * @param parentElement
1369
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1370
     *            object.
1371
     * @param entity
1372
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1373
     *            object.
1374
     * @param style
1375
     *            a int.
1376
     * @return a
1377
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1378
     *         object.
1379
     */
1380
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1381
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1382
        adapt(element);
1383
        parentElement.addElement(element);
1384
        return element;
1385
    }
1386

    
1387
    /**
1388
     * @param cdmBaseSection
1389
     * @param object
1390
     * @param style
1391
     * @return
1392
     */
1393
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1394
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1395
        adapt(element);
1396
        parentElement.addElement(element);
1397
        return element;
1398
    }
1399

    
1400
    /**
1401
     * <p>
1402
     * createVersionSection
1403
     * </p>
1404
     *
1405
     * @param parentElement
1406
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1407
     *            object.
1408
     * @param style
1409
     *            a int.
1410
     * @return a
1411
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1412
     *         object.
1413
     */
1414
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1415
        VersionSection section = new VersionSection(this, parentElement, style);
1416
        parentElement.addElement(section);
1417
        adapt(section);
1418
        return section;
1419
    }
1420

    
1421
    /**
1422
     * @param parent
1423
     * @param i
1424
     * @return
1425
     */
1426
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1427
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1428
        parentElement.addElement(section);
1429
        adapt(section);
1430
        return section;
1431
    }
1432

    
1433
    /**
1434
     * <p>
1435
     * createEmptyElement
1436
     * </p>
1437
     *
1438
     * @param parentElement
1439
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1440
     *            object.
1441
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1442
     */
1443
    public EmptyElement createEmptyElement(ICdmFormElement parentElement) {
1444
        EmptyElement element = new EmptyElement(this, parentElement, null, SWT.NULL);
1445
        adapt(element);
1446
        parentElement.addElement(element);
1447
        return element;
1448
    }
1449

    
1450
    /**
1451
     * <p>
1452
     * createHeadlineSection
1453
     * </p>
1454
     *
1455
     * @param parentElement
1456
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1457
     *            object.
1458
     * @return a
1459
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1460
     *         object.
1461
     */
1462
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1463
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1464
        parentElement.addElement(section);
1465
        adapt(section);
1466
        return section;
1467
    }
1468

    
1469
    /**
1470
     * <p>
1471
     * createParsingMessageElement
1472
     * </p>
1473
     *
1474
     * @param parentElement
1475
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1476
     *            object.
1477
     * @param parserProblem
1478
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1479
     *            object.
1480
     * @param style
1481
     *            a int.
1482
     * @return a
1483
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1484
     *         object.
1485
     */
1486
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1487
            ParserProblem parserProblem, int style) {
1488
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1489
        adapt(element);
1490
        parentElement.addElement(element);
1491
        return element;
1492
    }
1493

    
1494
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1495
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1496

    
1497
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1498
                selectionProvider, style);
1499

    
1500
        parentElement.addElement(section);
1501
        adapt(section);
1502
        return section;
1503

    
1504
    }
1505

    
1506
    /**
1507
     * @param definedTermClass
1508
     * @param formElement
1509
     * @param style
1510
     * @return
1511
     */
1512
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1513
            AbstractCdmDetailSection parentElement, int style) {
1514
        AbstractCdmDetailElement element = null;
1515

    
1516
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1517
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1518
        } else if (definedTermClass.equals(Feature.class)) {
1519
            element = new FeatureDetailElement(this, parentElement);
1520
        } else {
1521
            element = new DefinedTermDetailElement(this, parentElement);
1522
        }
1523

    
1524
        adapt(element);
1525
        parentElement.addElement(element);
1526
        return element;
1527
    }
1528

    
1529

    
1530
    //--------DetailSections---------
1531
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1532
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1533
        addAndAdaptSection(parentElement, section);
1534
        return section;
1535
    }
1536

    
1537
    public ReferenceDetailSection createReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1538
        ReferenceDetailSection section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1539
        addAndAdaptSection(parentElement, section);
1540
        return section;
1541
    }
1542

    
1543
    public NomenclaturalReferenceDetailSection createNomenclaturalReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1544
        NomenclaturalReferenceDetailSection section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1545
        addAndAdaptSection(parentElement, section);
1546
        return section;
1547
    }
1548

    
1549
    public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1550
        TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1551
        addAndAdaptSection(parentElement, section);
1552
        return section;
1553
    }
1554

    
1555
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1556
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1557
        addAndAdaptSection(parentElement, section);
1558
        return section;
1559
    }
1560

    
1561
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1562
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1563
        addAndAdaptSection(parentElement, section);
1564
        return section;
1565
    }
1566

    
1567
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1568
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1569
        addAndAdaptSection(parentElement, section);
1570
        return section;
1571
    }
1572

    
1573
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1574
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1575
        addAndAdaptSection(parentElement, section);
1576
        return section;
1577
    }
1578

    
1579
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1580
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1581
        addAndAdaptSection(parentElement, section);
1582
        return section;
1583
    }
1584

    
1585
    public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1586
        DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1587
        addAndAdaptSection(parentElement, section);
1588
        return section;
1589
    }
1590

    
1591
    public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1592
        ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1593
        addAndAdaptSection(parentElement, section);
1594
        return section;
1595
    }
1596

    
1597
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1598
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, style);
1599
        addAndAdaptSection(parentElement, section);
1600
        return section;
1601
    }
1602

    
1603
    public MediaDetailsSection createMediaDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1604
        MediaDetailsSection section = new MediaDetailsSection(this, conversation, parentElement, selectionProvider, style);
1605
        addAndAdaptSection(parentElement, section);
1606
        return section;
1607
    }
1608

    
1609
    public DerivedUnitFacadeDetailSection createDerivedUnitFacadeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1610
        DerivedUnitFacadeDetailSection section = new DerivedUnitFacadeDetailSection(this, conversation, parentElement, selectionProvider, style);
1611
        addAndAdaptSection(parentElement, section);
1612
        return section;
1613
    }
1614

    
1615
    public FieldUnitDetailSection createFieldUnitDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1616
        FieldUnitDetailSection section = new FieldUnitDetailSection(this, conversation, parentElement, selectionProvider, style);
1617
        addAndAdaptSection(parentElement, section);
1618
        return section;
1619
    }
1620

    
1621
    public GatheringEventDetailSection createGatheringEventDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1622
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1623
        addAndAdaptSection(parentElement, section);
1624
        return section;
1625
    }
1626

    
1627
    public DerivedUnitBaseDetailSection createDerivedUnitBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1628
        DerivedUnitBaseDetailSection section = new DerivedUnitBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1629
        addAndAdaptSection(parentElement, section);
1630
        return section;
1631
    }
1632

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

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

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

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

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

    
1663
    public PolytomousKeyDetailSection createPolytomousKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1664
        PolytomousKeyDetailSection section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
1665
        addAndAdaptSection(parentElement, section);
1666
        return section;
1667
    }
1668

    
1669
    public PolytomousKeyNodeDetailSection createPolytomousKeyNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1670
        PolytomousKeyNodeDetailSection section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1671
        addAndAdaptSection(parentElement, section);
1672
        return section;
1673
    }
1674

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1855
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1856
        parentElement.addElement(section);
1857
        adapt(section);
1858
    }
1859

    
1860
    //--------DetailElements------------
1861

    
1862
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1863
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1864
        addAndAdaptElement(parentElement, element);
1865
        return element;
1866
    }
1867

    
1868
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1869
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1870
        addAndAdaptElement(parentElement, element);
1871
        return element;
1872
    }
1873

    
1874
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1875
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1876
        addAndAdaptElement(parentElement, element);
1877
        return element;
1878
    }
1879

    
1880
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1881
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1882
        addAndAdaptElement(parentElement, element);
1883
        return element;
1884
    }
1885

    
1886
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1887
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1888
        addAndAdaptElement(parentElement, element);
1889
        return element;
1890
    }
1891

    
1892
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1893
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1894
        addAndAdaptElement(parentElement, element);
1895
        return element;
1896
    }
1897

    
1898
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1899
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
1900
        addAndAdaptElement(parentElement, element);
1901
        return element;
1902
    }
1903

    
1904
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
1905
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
1906
        addAndAdaptElement(parentElement, element);
1907
        return element;
1908
    }
1909

    
1910
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
1911
        UserDetailElement element = new UserDetailElement(this, parentElement);
1912
        addAndAdaptElement(parentElement, element);
1913
        return element;
1914
    }
1915

    
1916
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
1917
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
1918
        addAndAdaptElement(parentElement, element);
1919
        return element;
1920
    }
1921

    
1922
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
1923
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
1924
        addAndAdaptElement(parentElement, element);
1925
        return element;
1926
    }
1927

    
1928
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
1929
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
1930
        addAndAdaptElement(parentElement, element);
1931
        return element;
1932
    }
1933

    
1934
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
1935
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
1936
        addAndAdaptElement(parentElement, element);
1937
        return element;
1938
    }
1939

    
1940
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
1941
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
1942
        addAndAdaptElement(parentElement, element);
1943
        return element;
1944
    }
1945

    
1946
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement){
1947
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement);
1948
        addAndAdaptElement(parentElement, element);
1949
        return element;
1950
    }
1951

    
1952
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
1953
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
1954
        addAndAdaptElement(parentElement, element);
1955
        return element;
1956
    }
1957

    
1958
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
1959
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
1960
        addAndAdaptElement(parentElement, element);
1961
        return element;
1962
    }
1963

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

    
1970
    public DerivedUnitFacadeDetailElement createDerivedUnitFacadeDetailElement(ICdmFormElement parentElement){
1971
        DerivedUnitFacadeDetailElement element = new DerivedUnitFacadeDetailElement(this, parentElement);
1972
        addAndAdaptElement(parentElement, element);
1973
        return element;
1974
    }
1975

    
1976
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
1977
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
1978
        addAndAdaptElement(parentElement, element);
1979
        return element;
1980
    }
1981

    
1982
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
1983
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
1984
        addAndAdaptElement(parentElement, element);
1985
        return element;
1986
    }
1987

    
1988
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
1989
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
1990
        addAndAdaptElement(parentElement, element);
1991
        return element;
1992
    }
1993

    
1994
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
1995
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
1996
        addAndAdaptElement(parentElement, element);
1997
        return element;
1998
    }
1999

    
2000
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style){
2001
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style);
2002
        addAndAdaptElement(parentElement, element);
2003
        return element;
2004
    }
2005

    
2006
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2007
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2008
        addAndAdaptElement(parentElement, element);
2009
        return element;
2010
    }
2011

    
2012
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2013
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2014
        addAndAdaptElement(parentElement, element);
2015
        return element;
2016
    }
2017

    
2018
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2019
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2020
        addAndAdaptElement(parentElement, element);
2021
        return element;
2022
    }
2023

    
2024
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
2025
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
2026
        addAndAdaptElement(parentElement, element);
2027
        return element;
2028
    }
2029

    
2030
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2031
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2032
        addAndAdaptElement(parentElement, element);
2033
        return element;
2034
    }
2035

    
2036

    
2037
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2038
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2039
        addAndAdaptElement(parentElement, element);
2040
        return element;
2041
    }
2042

    
2043
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2044
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2045
        addAndAdaptElement(parentElement, element);
2046
        return element;
2047
    }
2048

    
2049
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2050
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2051
        addAndAdaptElement(parentElement, element);
2052
        return element;
2053
    }
2054

    
2055
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2056
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2057
        addAndAdaptElement(parentElement, element);
2058
        return element;
2059
    }
2060

    
2061
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2062
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2063
        addAndAdaptElement(parentElement, element);
2064
        return element;
2065
    }
2066

    
2067
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2068
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2069
        addAndAdaptElement(parentElement, element);
2070
        return element;
2071
    }
2072

    
2073
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2074
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2075
        addAndAdaptElement(parentElement, element);
2076
        return element;
2077
    }
2078

    
2079
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2080
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2081
        addAndAdaptElement(parentElement, element);
2082
        return element;
2083
    }
2084

    
2085
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2086
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2087
        addAndAdaptElement(parentElement, element);
2088
        return element;
2089
    }
2090

    
2091
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2092
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2093
        addAndAdaptElement(parentElement, element);
2094
        return element;
2095
    }
2096

    
2097
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2098
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2099
        addAndAdaptElement(parentElement, element);
2100
        return element;
2101
    }
2102

    
2103
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2104
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2105
        addAndAdaptElement(parentElement, element);
2106
        return element;
2107
    }
2108

    
2109
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2110
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2111
        addAndAdaptElement(parentElement, element);
2112
        return element;
2113
    }
2114

    
2115
    public SpecimenScanGeneralDetailElement createSpecimenScanGeneralDetailElement(ICdmFormElement parentElement){
2116
        SpecimenScanGeneralDetailElement element = new SpecimenScanGeneralDetailElement(this, parentElement);
2117
        addAndAdaptElement(parentElement, element);
2118
        return element;
2119
    }
2120

    
2121
    public LivingPlantPhotoGeneralDetailElement createLivingPlantPhotoGeneralDetailElement(ICdmFormElement parentElement){
2122
        LivingPlantPhotoGeneralDetailElement element = new LivingPlantPhotoGeneralDetailElement(this, parentElement);
2123
        addAndAdaptElement(parentElement, element);
2124
        return element;
2125
    }
2126

    
2127
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2128
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2129
        addAndAdaptElement(parentElement, element);
2130
        return element;
2131
    }
2132

    
2133

    
2134
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2135
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2136
        addAndAdaptElement(parentElement, element);
2137
        return element;
2138
    }
2139

    
2140
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2141
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2142
        addAndAdaptElement(parentElement, element);
2143
        return element;
2144
    }
2145

    
2146

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

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

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

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

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

    
2177
    /**
2178
     * @param parentElement
2179
     * @param element
2180
     */
2181
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2182
        adapt(element);
2183
        parentElement.addElement(element);
2184
    }
2185

    
2186
    //--------EntityCollectionSection----------
2187
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2188
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style);
2189
        addAndAdaptSection(parentElement, section);
2190
        return section;
2191
    }
2192

    
2193
    public AnnotationSection createAnnotationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2194
        AnnotationSection section = new AnnotationSection(this, conversation, parentElement, style);
2195
        addAndAdaptSection(parentElement, section);
2196
        return section;
2197
    }
2198

    
2199
    public CreditSection createCreditSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2200
        CreditSection section = new CreditSection(this, conversation, parentElement, style);
2201
        addAndAdaptSection(parentElement, section);
2202
        return section;
2203
    }
2204

    
2205
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2206
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2207
        addAndAdaptSection(parentElement, section);
2208
        return section;
2209
    }
2210

    
2211
    public ExtensionSection createExtensionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2212
        ExtensionSection section = new ExtensionSection(this, conversation, parentElement, style);
2213
        addAndAdaptSection(parentElement, section);
2214
        return section;
2215
    }
2216

    
2217
    public MarkerSection createMarkerSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2218
        MarkerSection section = new MarkerSection(this, conversation, parentElement, style);
2219
        addAndAdaptSection(parentElement, section);
2220
        return section;
2221
    }
2222

    
2223
    public MediaSection createMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2224
        MediaSection section = new MediaSection(this, conversation, parentElement, style);
2225
        addAndAdaptSection(parentElement, section);
2226
        return section;
2227
    }
2228

    
2229
    public DescriptionElementMediaSection createDescriptionElementMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2230
        DescriptionElementMediaSection section = new DescriptionElementMediaSection(this, conversation, parentElement, style);
2231
        addAndAdaptSection(parentElement, section);
2232
        return section;
2233
    }
2234

    
2235
    public MediaRepresentationSection createMediaRepresentationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2236
        MediaRepresentationSection section = new MediaRepresentationSection(this, conversation, parentElement, style);
2237
        addAndAdaptSection(parentElement, section);
2238
        return section;
2239
    }
2240

    
2241
    public MediaRepresentationPartSection createMediaRepresentationPartSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2242
        MediaRepresentationPartSection section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
2243
        addAndAdaptSection(parentElement, section);
2244
        return section;
2245
    }
2246

    
2247
    public ModifierSection createModifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2248
        ModifierSection section = new ModifierSection(this, conversation, parentElement, style);
2249
        addAndAdaptSection(parentElement, section);
2250
        return section;
2251
    }
2252

    
2253
    public NomenclaturalStatusSection createNomenclaturalStatusSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2254
        NomenclaturalStatusSection section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
2255
        addAndAdaptSection(parentElement, section);
2256
        return section;
2257
    }
2258

    
2259
    public NameRelationshipDetailSection createNameRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2260
        NameRelationshipDetailSection section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
2261
        addAndAdaptSection(parentElement, section);
2262
        return section;
2263
    }
2264

    
2265
    public SynonymRelationshipDetailSection createSynonymRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2266
        SynonymRelationshipDetailSection section = new SynonymRelationshipDetailSection(this, conversation, parentElement, style);
2267
        addAndAdaptSection(parentElement, section);
2268
        return section;
2269
    }
2270

    
2271
    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2272
        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2273
        addAndAdaptSection(parentElement, section);
2274
        return section;
2275
    }
2276

    
2277
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2278
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2279
        addAndAdaptSection(parentElement, section);
2280
        return section;
2281
    }
2282

    
2283
    public SourceSection createSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2284
        SourceSection section = new SourceSection(this, conversation, parentElement, style);
2285
        addAndAdaptSection(parentElement, section);
2286
        return section;
2287
    }
2288

    
2289
    public ScopeSection createScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2290
        ScopeSection section = new ScopeSection(this, conversation, parentElement, style);
2291
        addAndAdaptSection(parentElement, section);
2292
        return section;
2293
    }
2294

    
2295
    public DescriptionSourceSection createDescriptionSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2296
        DescriptionSourceSection section = new DescriptionSourceSection(this, conversation, parentElement, style);
2297
        addAndAdaptSection(parentElement, section);
2298
        return section;
2299
    }
2300

    
2301
    public TypeDesignationSection createTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2302
        TypeDesignationSection section = new TypeDesignationSection(this, conversation, parentElement, style);
2303
        addAndAdaptSection(parentElement, section);
2304
        return section;
2305
    }
2306

    
2307
    public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2308
        StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
2309
        addAndAdaptSection(parentElement, section);
2310
        return section;
2311
    }
2312

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2409
    /**
2410
     * <p>
2411
     * createEntityCollectionElement
2412
     * </p>
2413
     *
2414
     * @param removeListener
2415
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
2416
     * @param style
2417
     *            a int.
2418
     * @param parentElement
2419
     *            a
2420
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
2421
     *            object.
2422
     * @param versionableEntity
2423
     *            a {@link eu.etaxonomy.cdm.model.common.IVersionableEntity}
2424
     *            object.
2425
     * @param backgroundColor
2426
     *            a {@link org.eclipse.swt.graphics.Color} object.
2427
     * @return a
2428
     *         {@link eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement}
2429
     *         object.
2430
     */
2431
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2432
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2433
        AbstractEntityCollectionElement element = null;
2434

    
2435
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2436

    
2437
        if (entity instanceof Annotation) {
2438
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2439
        } else if (entity instanceof Person) {
2440
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
2441
        } else if (entity instanceof Credit) {
2442
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2443
        } else if (entity instanceof Extension) {
2444
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2445
        } else if (entity instanceof Marker) {
2446
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2447
        } else if (entity instanceof Media) {
2448
            element = new MediaElement(this, parentElement, (Media) entity, removeListener, style);
2449
        } else if (entity instanceof MediaRepresentation) {
2450
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2451
                    style);
2452
        } else if (entity instanceof ImageFile) {
2453
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2454
        } else if (entity instanceof MediaRepresentationPart) {
2455
            element = new MediaRepresentationPartElement(this, parentElement, (MediaRepresentationPart) entity,
2456
                    removeListener, style);
2457
        } else if (entity instanceof NomenclaturalStatus) {
2458
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2459
                    style);
2460
        } else if (entity instanceof Rights) {
2461
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2462
        } else if (entity instanceof DescriptionElementSource) {
2463
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2464
                    removeListener, style);
2465
        } else if (entity instanceof IdentifiableSource) {
2466
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2467
                    style);
2468
		} else if (entity instanceof DefinedTerm) {
2469
			switch(((DefinedTerm)entity).getTermType()) {
2470
				case Scope:
2471
					element = new ScopeElement(this,
2472
							parentElement,
2473
							(DefinedTerm) entity,
2474
							removeListener,
2475
							style);
2476
					break;
2477
				case Modifier:
2478
					element = new ModifierElement(this,
2479
							parentElement,
2480
							(DefinedTerm) entity,
2481
							removeListener,
2482
							style);
2483
					break;
2484
				default:
2485
					//FIXME : Actually we should through an exception here
2486
					element = null;
2487
					break;
2488

    
2489
			}
2490
        } else if (entity instanceof Reference) {
2491
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2492
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2493
            }
2494
            else{
2495
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2496
            }
2497
        } else if (entity instanceof NameTypeDesignation) {
2498
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2499
                    style);
2500
        } else if (entity instanceof NameRelationship) {
2501
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2502
                    style);
2503
        } else if (entity instanceof SynonymRelationship) {
2504
            element = new SynonymRelationshipDetailElement(this, parentElement, (SynonymRelationship) entity, removeListener,
2505
                    style);
2506
        } else if (entity instanceof SpecimenTypeDesignation) {
2507
            element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2508
                    removeListener, style);
2509
        } else if (entity instanceof StateData) {
2510
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2511
        } else if (entity instanceof StatisticalMeasurementValue) {
2512
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2513
                    removeListener, style);
2514
        } else if (entity instanceof DerivedUnit) {
2515
        	switch(((DerivedUnit)entity).getRecordBasis()) {
2516
				case LivingSpecimen:
2517
				case PreservedSpecimen:
2518
				case OtherSpecimen:
2519
					element = new SpecimenCollectionDetailElement(this,
2520
								parentElement,
2521
								(DerivedUnit) entity,
2522
								removeListener,
2523
								style);
2524
					break;
2525
				default:
2526
					element = new DerivedUnitElement(this,
2527
								parentElement,
2528
								(DerivedUnit) entity,
2529
								removeListener,
2530
								style);
2531
			}
2532

    
2533
        } else if (entity instanceof NamedArea) {
2534
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2535
        } else if (entity instanceof DeterminationEvent) {
2536
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2537
        } else if (entity instanceof User) {
2538
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2539
        } else if (entity instanceof GrantedAuthority) {
2540
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity,
2541
                    removeListener, style);
2542
        } else if (entity instanceof Group) {
2543
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2544
        } else if (entity instanceof Taxon) {
2545
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2546
        } else if (entity instanceof DescriptionElementBase) {
2547
            // this is the special case for protologs, maybe we can do this
2548
            // differently when API improves
2549
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2550
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2551
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2552
            }
2553
        }
2554

    
2555
        if (element == null) {
2556
            AbstractUtility.errorDialog("No element for entity", this,
2557
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2558
                            + entity, null);
2559
        }
2560

    
2561
        else if (backgroundColor != null && !backgroundColor.isDisposed()) {
2562
            element.setPersistentBackground(backgroundColor);
2563
            adapt(element);
2564
            parentElement.addElement(element);
2565
        }
2566

    
2567
        return element;
2568
    }
2569

    
2570
    /**
2571
     * <p>
2572
     * Creates a selection element for the given type T.
2573
     * </p>
2574
     * <p>
2575
     * <strong>Selection elements not handled by this method:</strong>
2576
     * <ul>
2577
     * <li>{@link TaxonNodeSelectionElement} see
2578
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2579
     * </li>
2580
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2581
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2582
     * </li>
2583
     * </ul>
2584
     * </p>
2585
     *
2586
     * @param clazz
2587
     *            a {@link Class} object of the type that you want the selection
2588
     *            element to handle
2589
     * @param parentElement
2590
     *            a {@link ICdmFormElement} object.
2591
     * @param labelString
2592
     *            a {@link String} object.
2593
     * @param selectionType
2594
     * @param selection
2595
     *            a {@link ICdmBase} object.
2596
     * @param style
2597
     *            a int.
2598
     * @param conversation
2599
     *            a {@link ConversationHolder} object.
2600
     * @return a {@link EntitySelectionElement} object.
2601
     */
2602
    public <T extends ICdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2603
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2604
            int style) {
2605
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2606
                labelString, selection, mode, style);
2607
        adapt(element);
2608
        parentElement.addElement(element);
2609
        return element;
2610
    }
2611

    
2612
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2613
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2614
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2615
                labelString, selection, mode, style);
2616
        adapt(element);
2617
        parentElement.addElement(element);
2618
        return element;
2619
    }
2620

    
2621
    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2622
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2623
            int mode, int style) {
2624
        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2625
                conversation, parentElement, labelString, selection, mode, style);
2626
        adapt(element);
2627
        parentElement.addElement(element);
2628
        return element;
2629
    }
2630

    
2631
    /** {@inheritDoc} */
2632
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2633
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2634
        adapt(labelElement);
2635
        parentElement.addElement(labelElement);
2636
        return labelElement;
2637
    }
2638

    
2639
    /**
2640
     * <p>
2641
     * Getter for the field <code>selectionProvider</code>.
2642
     * </p>
2643
     *
2644
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2645
     */
2646
    public ISelectionProvider getSelectionProvider() {
2647
        return selectionProvider;
2648
    }
2649

    
2650
    /**
2651
     * <p>
2652
     * createDetailedDescriptionDetailElement
2653
     * </p>
2654
     *
2655
     * @param parentElement
2656
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2657
     *            object.
2658
     * @param entity
2659
     *            a
2660
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2661
     *            object.
2662
     * @param style
2663
     *            a int.
2664
     * @return a
2665
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2666
     *         object.
2667
     */
2668
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2669
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2670
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2671

    
2672
        if (entity instanceof CategoricalData) {
2673
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2674
                    (CategoricalData) entity, style);
2675
        } else if (entity instanceof CommonTaxonName) {
2676
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2677
                    style);
2678
        } else if (entity instanceof Distribution) {
2679
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2680
                    style);
2681
        } else if (entity instanceof IndividualsAssociation) {
2682
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2683
                    (IndividualsAssociation) entity, style);
2684
        } else if (entity instanceof QuantitativeData) {
2685
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2686
                    (QuantitativeData) entity, style);
2687
        } else if (entity instanceof TaxonInteraction) {
2688
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2689
                    (TaxonInteraction) entity, style);
2690
        } else if (entity instanceof TextData) {
2691
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2692
        } else {
2693
            throw new IllegalStateException("There is no interface for the given description element");
2694
        }
2695
        adapt(detailedDescriptionElement);
2696
        parentElement.addElement(detailedDescriptionElement);
2697
        return detailedDescriptionElement;
2698

    
2699
    }
2700

    
2701
    /**
2702
     * Creates a styled text as a part of the form.
2703
     *
2704
     * @param parent
2705
     *            the text parent
2706
     * @param value
2707
     *            the text initial value
2708
     * @param style
2709
     *            the text style
2710
     * @return the text widget
2711
     */
2712
    public StyledText createStyledText(Composite parent, String value, int style) {
2713
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2714
        if (value != null) {
2715
            text.setText(value);
2716
        }
2717
        text.setForeground(getColors().getForeground());
2718
        text.setBackground(getColors().getBackground());
2719
        // text.addFocusListener(visibilityHandler);
2720
        return text;
2721
    }
2722

    
2723
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2724
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2725
        addAndAdaptSection(parentElement, section);
2726
        return section;
2727
    }
2728

    
2729
}
(6-6/40)