Project

General

Profile

Download (119 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.Taxon;
95
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
96
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
97
import eu.etaxonomy.taxeditor.model.AbstractUtility;
98
import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
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.TypeDesignationSection;
194
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
195
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
196
import eu.etaxonomy.taxeditor.ui.section.occurrence.CurrentDeterminationDetailSection;
197
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailElement;
198
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
199
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitFacadeDetailElement;
200
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitFacadeDetailSection;
201
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailElement;
202
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
203
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement;
204
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
205
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement;
206
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection;
207
import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
208
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailElement;
209
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailSection;
210
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailElement;
211
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSection;
212
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailElement;
213
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
214
import eu.etaxonomy.taxeditor.ui.section.occurrence.NamedAreaDetailElement;
215
import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
216
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElement;
217
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailSection;
218
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenCurrentDeterminationDetailSection;
219
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailElement;
220
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailSection;
221
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDeterminationDetailElement;
222
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDeterminationDetailSection;
223
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDeterminationHistoryDetailSection;
224
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailElement;
225
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailSection;
226
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenSourceCollectionDetailSection;
227
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailElement;
228
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailSection;
229
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailElement;
230
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailSection;
231
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailElement;
232
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailSection;
233
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailElement;
234
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
235
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailElement;
236
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
237
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailElement;
238
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
239
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailElement;
240
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
241
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailElement;
242
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
243
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.LivingPlantPhotoGeneralDetailElement;
244
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.LivingPlantPhotoGeneralDetailSection;
245
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailElement;
246
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
247
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.SpecimenScanGeneralDetailElement;
248
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.SpecimenScanGeneralDetailSection;
249
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
250
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
251
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement;
252
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
253
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationElement;
254
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
255
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseElement;
256
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
257
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditElement;
258
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
259
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionElement;
260
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
261
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
262
import eu.etaxonomy.taxeditor.ui.section.supplemental.IdentifiableSourceElement;
263
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerElement;
264
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
265
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsElement;
266
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
267
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
268
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement;
269
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
270
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement;
271
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
272
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailElement;
273
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
274
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailElement;
275
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailElement;
276
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
277
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailElement;
278
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
279
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailElement;
280
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
281
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailElement;
282
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
283
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement;
284
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailSection;
285
import eu.etaxonomy.taxeditor.ui.section.vocabulary.FeatureDetailElement;
286
import eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailSection;
287
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailElement;
288
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
289
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
290
import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
291
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
292

    
293
/**
294
 * <p>
295
 * CdmFormFactory class.
296
 * </p>
297
 *
298
 * @author n.hoffmann
299
 * @created Feb 24, 2010
300
 * @version 1.0
301
 */
302
public class CdmFormFactory extends FormToolkit {
303

    
304
    private BoldFontHolder2 boldFontHolder2;
305
    private MouseListener selectionMouseHandler;
306
    private FocusListener selectionFocusHandler;
307

    
308
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
309

    
310
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
311

    
312
    private final int orientation = Window.getDefaultOrientation();
313
    private ISelectionProvider selectionProvider;
314

    
315
    /** Constant <code>EMPTY_SELECTION</code> */
316
    public static ISelection EMPTY_SELECTION = new ISelection() {
317
        @Override
318
        public boolean isEmpty() {
319
            return true;
320
        }
321
    };
322

    
323
    /**
324
     *
325
     * @author n.hoffmann
326
     * @date Jan 25, 2010
327
     *
328
     */
329
    private class SelectionMouseHandler extends MouseAdapter {
330
        @Override
331
        public void mouseDown(MouseEvent e) {
332
            notifySelectionListeners(e);
333
        }
334
    }
335

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

    
349
    private void notifySelectionListeners(TypedEvent e) {
350
        Event event = new Event();
351
        event.widget = e.widget;
352
        SelectionEvent selectionEvent = new SelectionEvent(event);
353

    
354
        for (SelectionListener listener : selectionListenerList) {
355
            listener.widgetSelected(selectionEvent);
356
        }
357
    }
358

    
359
    /**
360
     * <p>
361
     * Constructor for CdmFormFactory.
362
     * </p>
363
     *
364
     * @param display
365
     *            a {@link org.eclipse.swt.widgets.Display} object.
366
     * @param selectionProvider
367
     *            a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
368
     */
369
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
370
        super(display);
371
        this.selectionProvider = selectionProvider;
372
        init();
373
    }
374

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

    
388
    /**
389
	 *
390
	 */
391
    private void init() {
392
        boldFontHolder2 = new BoldFontHolder2();
393
        selectionMouseHandler = new SelectionMouseHandler();
394
        selectionFocusHandler = new SelectionFocusHandler();
395
    }
396

    
397
    /**
398
     * Creates an instance initialized with the correct selectionProvider
399
     *
400
     * Make sure to remove the instance when the entityComposite disposes via
401
     * destroySelectionArbitrator(..)
402
     *
403
     * @param entityElement
404
     *            a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
405
     *            object.
406
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
407
     *         object.
408
     */
409
    public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
410
        SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
411
        selectionArbitrator.addSelectionProvider(selectionProvider);
412
        selectionProvider.addSelectionChangedListener(selectionArbitrator);
413
        addSelectionListener(selectionArbitrator);
414
        return selectionArbitrator;
415
    }
416

    
417
    /**
418
     * <p>
419
     * destroySelectionArbitrator
420
     * </p>
421
     *
422
     * @param selectionArbitrator
423
     *            a
424
     *            {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
425
     *            object.
426
     */
427
    public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
428
        removeSelectionListener(selectionArbitrator);
429
        if (selectionProvider != null) {
430
            selectionProvider.removeSelectionChangedListener(selectionArbitrator);
431
        } else {
432
            AbstractUtility.error(this.getClass(),
433
                    "Tried to destroy a selection listener from this factories listeners but was null", null);
434
        }
435
    }
436

    
437
    /**
438
     * <p>
439
     * Adapts the {@link AbstractCdmFormElement}:<br>
440
     * - sets the {@link IPropertyChangeListener}s handled by this class
441
     * </p>
442
     *
443
     * @param formElement
444
     *            a
445
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
446
     *            object.
447
     */
448
    public void adapt(AbstractCdmFormElement formElement) {
449
        formElement.setPropertyChangeListeners(propertyChangeListeners);
450
    }
451

    
452
    /** {@inheritDoc} */
453
    @Override
454
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
455
        if (trackFocus) {
456
            control.addFocusListener(selectionFocusHandler);
457
        }
458
        super.adapt(control, trackFocus, trackKeyboard);
459
    }
460

    
461
    /** {@inheritDoc} */
462
    @Override
463
    public void adapt(Composite composite) {
464
        composite.addMouseListener(selectionMouseHandler);
465
        super.adapt(composite);
466
    }
467

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

    
509
    /**
510
     * <p>
511
     * createEmptyCell
512
     * </p>
513
     *
514
     * @param parent
515
     *            a {@link org.eclipse.swt.widgets.Composite} object.
516
     * @return a {@link org.eclipse.swt.widgets.Label} object.
517
     */
518
    public Label createEmptyCell(Composite parent) {
519
        return this.createLabel(parent, null);
520
    }
521

    
522
    /**
523
     * <p>
524
     * createMultilineTextWithLabel
525
     * </p>
526
     *
527
     * @param labelString
528
     *            a {@link java.lang.String} object.
529
     * @param textHeight
530
     *            a int.
531
     * @param style
532
     *            a int.
533
     * @param parentElement
534
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
535
     *            object.
536
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
537
     *         object.
538
     */
539
    public TextWithLabelElement createMultilineTextWithLabel(ICdmFormElement parentElement, String labelString,
540
            int textHeight, int style) {
541
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, style);
542
        adapt(element);
543
        parentElement.addElement(element);
544
        return element;
545
    }
546

    
547
    /**
548
     * <p>
549
     * createMultiLanguageTextElement
550
     * </p>
551
     *
552
     * @param parentElement
553
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
554
     *            object.
555
     * @param labelString
556
     *            a {@link java.lang.String} object.
557
     * @param multilanguageText
558
     *            a {@link java.util.Map} object.
559
     * @param textHeight
560
     *            a int.
561
     * @param style
562
     *            a int.
563
     * @return a
564
     *         {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
565
     *         object.
566
     */
567
    public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
568
            Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
569
        MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
570
                multilanguageText, textHeight, style);
571
        adapt(element);
572
        parentElement.addElement(element);
573
        return element;
574
    }
575

    
576
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
577
            KeyStatement keyStatement, int textHeight, int style) {
578
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
579
                textHeight, style);
580
        adapt(element);
581
        parentElement.addElement(element);
582
        return element;
583
    }
584

    
585
    /**
586
     * Creates a text field with a label. The initial content will be the return value of the initalObject's {@link #toString()}
587
     * method.<br>
588
     * <b>Note</b>: if initialObject is <code>null</code> then an empty string is used.
589
     * @param parentElement the parent container
590
     * @param labelString the label name
591
     * @param initialObject the object from which the <code>toString()</code> method is called
592
     * @param style {@link SWT} style constant
593
     * @return the created textfield with label
594
     */
595
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
596
            Object initialObject, int style) {
597
        return createTextWithLabelElement(parentElement, labelString, initialObject==null?"":initialObject.toString(), style);
598
    }
599

    
600
    /**
601
     * <p>
602
     * createTextWithLabelElement
603
     * </p>
604
     *
605
     * @param labelString
606
     *            a {@link java.lang.String} object.
607
     * @param initialText
608
     *            a {@link java.lang.String} object.
609
     * @param style
610
     *            a int.
611
     * @param parentElement
612
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
613
     *            object.
614
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
615
     *         object.
616
     */
617
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
618
            String initialText, int style) {
619
        if(initialText==null){
620
            initialText = "";
621
        }
622

    
623
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
624
                style);
625
        adapt(element);
626
        parentElement.addElement(element);
627
        return element;
628
    }
629

    
630
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
631
            URI initialUri, int style) {
632
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
633
        adapt(element);
634
        parentElement.addElement(element);
635
        return element;
636
    }
637

    
638
    /**
639
     * @param element
640
     * @param string
641
     * @param uri
642
     * @param style
643
     * @return
644
     */
645
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
646
            IOpenUrlEnabled openUrlEnabled, int style) {
647
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
648
                style);
649
        adapt(element);
650
        parentElement.addElement(element);
651
        return element;
652
    }
653

    
654
    /**
655
     *
656
     * @param parentElement
657
     * @param labelString
658
     * @param conversationEnabled
659
     * @param user
660
     * @param style
661
     * @return
662
     */
663
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
664
            ConversationHolder conversation, User user, int style) {
665
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
666
        adapt(element);
667
        parentElement.addElement(element);
668
        return element;
669
    }
670

    
671
    /**
672
     * <p>
673
     * createIntegerTextWithLabelElement
674
     * </p>
675
     *
676
     * @param parentElement
677
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
678
     *            object.
679
     * @param labelString
680
     *            a {@link java.lang.String} object.
681
     * @param initialInteger
682
     *            a {@link java.lang.Integer} object.
683
     * @param style
684
     *            a int.
685
     * @return a
686
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
687
     *         object.
688
     */
689
	public NumberWithLabelElement createNumberTextWithLabelElement(
690
			ICdmFormElement parentElement, String labelString,
691
			Number initialNumber, int style) {
692
		NumberWithLabelElement element = new NumberWithLabelElement(this,
693
				parentElement, labelString, initialNumber, style);
694
		adapt(element);
695
		parentElement.addElement(element);
696
		return element;
697
	}
698

    
699
    /**
700
     * <p>
701
     * createLanguageStringWithLabelElement
702
     * </p>
703
     *
704
     * @param parentElement
705
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
706
     *            object.
707
     * @param labelString
708
     *            a {@link java.lang.String} object.
709
     * @param languageString
710
     *            a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
711
     * @param style
712
     *            a int.
713
     * @return a
714
     *         {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement}
715
     *         object.
716
     */
717
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
718
            String labelString, LanguageString languageString, int style) {
719
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
720
                languageString, style);
721
        adapt(element);
722
        parentElement.addElement(element);
723
        return element;
724
    }
725

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

    
755
    /**
756
     * <p>
757
     * createTextElement
758
     * </p>
759
     *
760
     * @param parentElement
761
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
762
     *            object.
763
     * @param initialText
764
     *            a {@link java.lang.String} object.
765
     * @param style
766
     *            a int.
767
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
768
     *         object.
769
     */
770
    public TextWithLabelElement createTextElement(ICdmFormElement parentElement, String initialText, int style) {
771
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, null, initialText, null, style);
772
        adapt(element);
773
        parentElement.addElement(element);
774
        return element;
775
    }
776

    
777
    /**
778
     * <p>
779
     * createKeyValueViewerElement
780
     * </p>
781
     *
782
     * @param parentElement
783
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
784
     *            object.
785
     * @param keyHeading
786
     *            a {@link java.lang.String} object.
787
     * @param valueHeading
788
     *            a {@link java.lang.String} object.
789
     * @param map
790
     *            a {@link java.util.Map} object.
791
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
792
     *         object.
793
     */
794
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
795
            String valueHeading, Map<Object, Object> map) {
796
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
797
        adapt(element);
798
        parentElement.addElement(element);
799
        return element;
800
    }
801

    
802
    /**
803
     * <p>
804
     * createTermComboElement
805
     * </p>
806
     *
807
     * @param termComboType
808
     *            a
809
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
810
     *            object.
811
     * @param parentElement
812
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
813
     *            object.
814
     * @param labelString
815
     *            a {@link java.lang.String} object.
816
     * @param selection
817
     *            a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
818
     *            object.
819
     * @param style
820
     *            a int.
821
     * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
822
     *         object.
823
     */
824

    
825
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
826
            ICdmFormElement parentElement, String labelString, T selection, int style) {
827
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString,
828
                selection, style);
829
        adapt(element);
830
        parentElement.addElement(element);
831
        return element;
832
    }
833

    
834
	/**
835
	 * <p>
836
	 * createTermComboElement
837
	 * </p>
838
	 *
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

    
857
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
858
			TermType termType,
859
			ICdmFormElement parentElement,
860
			String labelString,
861
			T selection,
862
			int style) {
863
		TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, style);
864
		adapt(element);
865
		parentElement.addElement(element);
866
		return element;
867
	}
868

    
869
    /**
870
     * <p>
871
     * createEnumComboElement
872
     * </p>
873
     *
874
     * @param enumComboType
875
     *            a
876
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType}
877
     *            object.
878
     * @param parentElement
879
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
880
     *            object.
881
     * @param style
882
     *            a int.
883
     * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
884
     *         object.
885
     */
886
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
887
			Class<T> enumComboType, ICdmFormElement parentElement,
888
			int style) {
889
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
890
        adapt(element);
891
        parentElement.addElement(element);
892
        return element;
893
    }
894

    
895
    /**
896
     * <p>
897
     * createBrowserElement
898
     * </p>
899
     *
900
     * @param imageUri
901
     *            a {@link java.net.URI} object.
902
     * @param style
903
     *            a int.
904
     * @param parentElement
905
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
906
     *            object.
907
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
908
     *         object.
909
     */
910
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
911
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
912
        adapt(element);
913
        parentElement.addElement(element);
914
        return element;
915
    }
916

    
917
    /**
918
     * <p>
919
     * createImageElement
920
     * </p>
921
     *
922
     * @param parentElement
923
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
924
     *            object.
925
     * @param imageUri
926
     *            a {@link java.net.URI} object.
927
     * @param style
928
     *            a int.
929
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
930
     */
931
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
932
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
933
        adapt(element);
934
        parentElement.addElement(element);
935
        return element;
936
    }
937

    
938
    /**
939
     * <p>
940
     * createTextActionElement
941
     * </p>
942
     *
943
     * @param labelString
944
     *            a {@link java.lang.String} object.
945
     * @param initialText
946
     *            a {@link java.lang.String} object.
947
     * @param style
948
     *            a int.
949
     * @param parentElement
950
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
951
     *            object.
952
     * @param buttonLabel
953
     *            a {@link java.lang.String} object.
954
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
955
     *         object.
956
     */
957
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
958
            String buttonLabel, String initialText, int style) {
959
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
960
                style);
961
        adapt(element);
962
        parentElement.addElement(element);
963
        return element;
964
    }
965

    
966
    /**
967
     * <p>
968
     * createCheckbox
969
     * </p>
970
     *
971
     * @param parentElement
972
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
973
     *            object.
974
     * @param label
975
     *            a {@link java.lang.String} object.
976
     * @param initialState
977
     *            a boolean.
978
     * @param style
979
     *            a int.
980
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
981
     *         object.
982
     */
983
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
984
        if(initialState==null){
985
            initialState = Boolean.FALSE;
986
        }
987
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
988
        adapt(element);
989
        parentElement.addElement(element);
990
        return element;
991
    }
992

    
993
    /**
994
     * Creates a section as a part of the form.
995
     *
996
     * @return the section widget
997
     * @param section
998
     *            a
999
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1000
     *            object.
1001
     */
1002
    public Section adapt(AbstractFormSection section) {
1003
        section.setMenu(section.getLayoutComposite().getMenu());
1004
        adapt(section, true, true);
1005

    
1006
        // handle focus and property change events for cdm use
1007
        section.addFocusListener(selectionFocusHandler);
1008
        section.setPropertyChangeListeners(propertyChangeListeners);
1009

    
1010
        if (section.getToggle() != null) {
1011
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1012
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1013
        }
1014

    
1015
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1016

    
1017
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1018
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1019
            getColors().initializeSectionToolBarColors();
1020
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1021
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1022
        }
1023
        // call setTitleBarForeground regardless as it also sets the label color
1024
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1025
        return section;
1026
    }
1027

    
1028
    private class BoldFontHolder2 {
1029
        private Font normalFont;
1030

    
1031
        private Font boldFont;
1032

    
1033
        public BoldFontHolder2() {
1034
        }
1035

    
1036
        public Font getBoldFont(Font font) {
1037
            createBoldFont(font);
1038
            return boldFont;
1039
        }
1040

    
1041
        private void createBoldFont(Font font) {
1042
            if (normalFont == null || !normalFont.equals(font)) {
1043
                normalFont = font;
1044
                dispose();
1045
            }
1046
            if (boldFont == null) {
1047
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1048
            }
1049
        }
1050

    
1051
        public void dispose() {
1052
            if (boldFont != null) {
1053
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1054
                boldFont = null;
1055
            }
1056
        }
1057
    }
1058

    
1059
    /**
1060
     * <p>
1061
     * createToggleableTextField
1062
     * </p>
1063
     *
1064
     * @param parentElement
1065
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1066
     *            object.
1067
     * @param labelString
1068
     *            a {@link java.lang.String} object.
1069
     * @param initialText
1070
     *            a {@link java.lang.String} object.
1071
     * @param initialState
1072
     *            a boolean.
1073
     * @param style
1074
     *            a int.
1075
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1076
     *         object.
1077
     */
1078
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1079
            String initialText, boolean initialState, int style) {
1080
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1081
                initialState, style | orientation);
1082
        adapt(element);
1083
        parentElement.addElement(element);
1084
        return element;
1085
    }
1086

    
1087
    /**
1088
     * <p>
1089
     * createTimePeriodElement
1090
     * </p>
1091
     *
1092
     * @param parentElement
1093
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1094
     *            object.
1095
     * @param labelString
1096
     *            a {@link java.lang.String} object.
1097
     * @param timePeriod
1098
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1099
     * @param style
1100
     *            a int.
1101
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1102
     *         object.
1103
     */
1104
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1105
            TimePeriod timePeriod, int style) {
1106
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1107
        adapt(element);
1108
        parentElement.addElement(element);
1109
        return element;
1110
    }
1111

    
1112
	/**
1113
	 * <p>
1114
	 * createGatheringEventUnitElement
1115
	 * </p>
1116
	 *
1117
	 * @param parentElement
1118
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1119
	 *            object.
1120
	 * @param labelString
1121
	 *            a {@link java.lang.String} object.
1122
	 * @param timePeriod
1123
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1124
	 * @param style
1125
	 *            a int.
1126
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1127
	 *         object.
1128
	 */
1129
	public GatheringEventUnitElement createGatheringEventUnitElement(
1130
			ICdmFormElement parentElement,
1131
			String labelString,
1132
			DerivedUnitFacade gatheringEvent,
1133
			MinMaxTextSection.UnitType unitType,
1134
			int style) {
1135
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1136
				parentElement,
1137
				labelString,
1138
				gatheringEvent,
1139
				unitType,
1140
				style);
1141
		adapt(element);
1142
		parentElement.addElement(element);
1143
		return element;
1144
	}
1145

    
1146
    /**
1147
     * <p>
1148
     * createPointElement
1149
     * </p>
1150
     *
1151
     * @param style
1152
     *            a int.
1153
     * @param parentElement
1154
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1155
     *            object.
1156
     * @param point
1157
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1158
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1159
     */
1160
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1161
        PointElement element = new PointElement(this, parentElement, point, style);
1162
        adapt(element);
1163
        parentElement.addElement(element);
1164
        return element;
1165
    }
1166

    
1167

    
1168

    
1169
    /**
1170
     * @param conversationHolder
1171
     * @param parent
1172
     * @param detailsViewer
1173
     * @param i
1174
     * @return
1175
     */
1176
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1177
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1178
        parentElement.addElement(section);
1179
        adapt(section);
1180
        return section;
1181
    }
1182

    
1183
    /**
1184
     * <p>
1185
     * createDateDetailSection
1186
     * </p>
1187
     *
1188
     * @param parentElement
1189
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1190
     *            object.
1191
     * @param style
1192
     *            a int.
1193
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1194
     *         object.
1195
     */
1196
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1197
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1198
        parentElement.addElement(section);
1199
        adapt(section);
1200
        return section;
1201
    }
1202

    
1203
	/**
1204
	 * <p>
1205
	 * createDateDetailSection
1206
	 * </p>
1207
	 *
1208
	 * @param parentElement
1209
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1210
	 *            object.
1211
	 * @param style
1212
	 *            a int.
1213
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1214
	 *         object.
1215
	 */
1216
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1217
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1218
		parentElement.addElement(section);
1219
		adapt(section);
1220
		return section;
1221
	}
1222

    
1223
    /**
1224
     * <p>
1225
     * createPartialElement
1226
     * </p>
1227
     *
1228
     * @param parentElement
1229
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1230
     *            object.
1231
     * @param labelString
1232
     *            a {@link java.lang.String} object.
1233
     * @param partial
1234
     *            a {@link org.joda.time.Partial} object.
1235
     * @param style
1236
     *            a int.
1237
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1238
     *         object.
1239
     */
1240
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1241
            int style) {
1242
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1243
        adapt(element);
1244
        parentElement.addElement(element);
1245
        return element;
1246
    }
1247

    
1248
    /**
1249
     * <p>
1250
     * addSelectionListener
1251
     * </p>
1252
     *
1253
     * @param listener
1254
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1255
     */
1256
    public void addSelectionListener(SelectionListener listener) {
1257
        selectionListenerList.add(listener);
1258
    }
1259

    
1260
    /**
1261
     * <p>
1262
     * removeSelectionListener
1263
     * </p>
1264
     *
1265
     * @param listener
1266
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1267
     */
1268
    public void removeSelectionListener(SelectionListener listener) {
1269
        if (listener == null) {
1270
            AbstractUtility.error(this.getClass(),
1271
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1272
        } else {
1273
            selectionListenerList.remove(listener);
1274
        }
1275
    }
1276

    
1277
    /**
1278
     * <p>
1279
     * addPropertyChangeListener
1280
     * </p>
1281
     *
1282
     * @param listener
1283
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1284
     *            object.
1285
     */
1286
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1287
        if (propertyChangeListeners.contains(listener)) {
1288
            return;
1289
        }
1290
        propertyChangeListeners.add(0, listener);
1291
    }
1292

    
1293
    /**
1294
     * <p>
1295
     * removePropertyChangeListener
1296
     * </p>
1297
     *
1298
     * @param listener
1299
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1300
     *            object.
1301
     */
1302
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1303
        propertyChangeListeners.remove(listener);
1304
    }
1305

    
1306
    /**
1307
     * @return the propertyChangeListeners
1308
     */
1309
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1310
        return propertyChangeListeners;
1311
    }
1312

    
1313
    /**
1314
     * <p>
1315
     * createHorizontalSeparator
1316
     * </p>
1317
     *
1318
     * @param parentElement
1319
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1320
     *            object.
1321
     * @param style
1322
     *            a int.
1323
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1324
     */
1325
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1326
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1327
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1328
        return separator;
1329
    }
1330

    
1331
    /**
1332
     * <p>
1333
     * createVersionElement
1334
     * </p>
1335
     *
1336
     * @param parentElement
1337
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1338
     *            object.
1339
     * @param entity
1340
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1341
     *            object.
1342
     * @param style
1343
     *            a int.
1344
     * @return a
1345
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1346
     *         object.
1347
     */
1348
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1349
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1350
        adapt(element);
1351
        parentElement.addElement(element);
1352
        return element;
1353
    }
1354

    
1355
    /**
1356
     * @param cdmBaseSection
1357
     * @param object
1358
     * @param style
1359
     * @return
1360
     */
1361
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1362
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1363
        adapt(element);
1364
        parentElement.addElement(element);
1365
        return element;
1366
    }
1367

    
1368
    /**
1369
     * <p>
1370
     * createVersionSection
1371
     * </p>
1372
     *
1373
     * @param parentElement
1374
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1375
     *            object.
1376
     * @param style
1377
     *            a int.
1378
     * @return a
1379
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1380
     *         object.
1381
     */
1382
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1383
        VersionSection section = new VersionSection(this, parentElement, style);
1384
        parentElement.addElement(section);
1385
        adapt(section);
1386
        return section;
1387
    }
1388

    
1389
    /**
1390
     * @param parent
1391
     * @param i
1392
     * @return
1393
     */
1394
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1395
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1396
        parentElement.addElement(section);
1397
        adapt(section);
1398
        return section;
1399
    }
1400

    
1401
    /**
1402
     * <p>
1403
     * createEmptyElement
1404
     * </p>
1405
     *
1406
     * @param parentElement
1407
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1408
     *            object.
1409
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1410
     */
1411
    public EmptyElement createEmptyElement(ICdmFormElement parentElement) {
1412
        EmptyElement element = new EmptyElement(this, parentElement, null, SWT.NULL);
1413
        adapt(element);
1414
        parentElement.addElement(element);
1415
        return element;
1416
    }
1417

    
1418
    /**
1419
     * <p>
1420
     * createHeadlineSection
1421
     * </p>
1422
     *
1423
     * @param parentElement
1424
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1425
     *            object.
1426
     * @return a
1427
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1428
     *         object.
1429
     */
1430
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1431
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1432
        parentElement.addElement(section);
1433
        adapt(section);
1434
        return section;
1435
    }
1436

    
1437
    /**
1438
     * <p>
1439
     * createParsingMessageElement
1440
     * </p>
1441
     *
1442
     * @param parentElement
1443
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1444
     *            object.
1445
     * @param parserProblem
1446
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1447
     *            object.
1448
     * @param style
1449
     *            a int.
1450
     * @return a
1451
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1452
     *         object.
1453
     */
1454
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1455
            ParserProblem parserProblem, int style) {
1456
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1457
        adapt(element);
1458
        parentElement.addElement(element);
1459
        return element;
1460
    }
1461

    
1462
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1463
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1464

    
1465
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1466
                selectionProvider, style);
1467

    
1468
        parentElement.addElement(section);
1469
        adapt(section);
1470
        return section;
1471

    
1472
    }
1473

    
1474
    /**
1475
     * @param definedTermClass
1476
     * @param formElement
1477
     * @param style
1478
     * @return
1479
     */
1480
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1481
            AbstractCdmDetailSection parentElement, int style) {
1482
        AbstractCdmDetailElement element = null;
1483

    
1484
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1485
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1486
        } else if (definedTermClass.equals(Feature.class)) {
1487
            element = new FeatureDetailElement(this, parentElement);
1488
        } else {
1489
            element = new DefinedTermDetailElement(this, parentElement);
1490
        }
1491

    
1492
        adapt(element);
1493
        parentElement.addElement(element);
1494
        return element;
1495
    }
1496

    
1497

    
1498
    //--------DetailSections---------
1499
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1500
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1501
        addAndAdaptSection(parentElement, section);
1502
        return section;
1503
    }
1504

    
1505
    public ReferenceDetailSection createReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1506
        ReferenceDetailSection section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1507
        addAndAdaptSection(parentElement, section);
1508
        return section;
1509
    }
1510

    
1511
    public NomenclaturalReferenceDetailSection createNomenclaturalReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1512
        NomenclaturalReferenceDetailSection section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1513
        addAndAdaptSection(parentElement, section);
1514
        return section;
1515
    }
1516

    
1517
    public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1518
        TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1519
        addAndAdaptSection(parentElement, section);
1520
        return section;
1521
    }
1522

    
1523
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1524
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1525
        addAndAdaptSection(parentElement, section);
1526
        return section;
1527
    }
1528

    
1529
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1530
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1531
        addAndAdaptSection(parentElement, section);
1532
        return section;
1533
    }
1534

    
1535
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1536
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1537
        addAndAdaptSection(parentElement, section);
1538
        return section;
1539
    }
1540

    
1541
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1542
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1543
        addAndAdaptSection(parentElement, section);
1544
        return section;
1545
    }
1546

    
1547
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1548
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1549
        addAndAdaptSection(parentElement, section);
1550
        return section;
1551
    }
1552

    
1553
    public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1554
        DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1555
        addAndAdaptSection(parentElement, section);
1556
        return section;
1557
    }
1558

    
1559
    public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1560
        ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1561
        addAndAdaptSection(parentElement, section);
1562
        return section;
1563
    }
1564

    
1565
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1566
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, style);
1567
        addAndAdaptSection(parentElement, section);
1568
        return section;
1569
    }
1570

    
1571
    public MediaDetailsSection createMediaDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1572
        MediaDetailsSection section = new MediaDetailsSection(this, conversation, parentElement, selectionProvider, style);
1573
        addAndAdaptSection(parentElement, section);
1574
        return section;
1575
    }
1576

    
1577
    public DerivedUnitFacadeDetailSection createDerivedUnitFacadeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1578
        DerivedUnitFacadeDetailSection section = new DerivedUnitFacadeDetailSection(this, conversation, parentElement, selectionProvider, style);
1579
        addAndAdaptSection(parentElement, section);
1580
        return section;
1581
    }
1582

    
1583
    public FieldUnitDetailSection createFieldUnitDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1584
        FieldUnitDetailSection section = new FieldUnitDetailSection(this, conversation, parentElement, selectionProvider, style);
1585
        addAndAdaptSection(parentElement, section);
1586
        return section;
1587
    }
1588

    
1589
    public GatheringEventDetailSection createGatheringEventDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1590
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1591
        addAndAdaptSection(parentElement, section);
1592
        return section;
1593
    }
1594

    
1595
    public DerivedUnitBaseDetailSection createDerivedUnitBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1596
        DerivedUnitBaseDetailSection section = new DerivedUnitBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1597
        addAndAdaptSection(parentElement, section);
1598
        return section;
1599
    }
1600

    
1601
    public NaturalLanguageSection createNaturalLanguageSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1602
        NaturalLanguageSection section = new NaturalLanguageSection(this, conversation, parentElement, selectionProvider, style);
1603
        addAndAdaptSection(parentElement, section);
1604
        return section;
1605
    }
1606

    
1607
    public FeatureDistributionDetailSection createFeatureDistributionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1608
        FeatureDistributionDetailSection section = new FeatureDistributionDetailSection(this, conversation, parentElement, selectionProvider, style);
1609
        addAndAdaptSection(parentElement, section);
1610
        return section;
1611
    }
1612

    
1613
    public ClassificationDetailSection createClassificationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1614
        ClassificationDetailSection section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style);
1615
        addAndAdaptSection(parentElement, section);
1616
        return section;
1617
    }
1618

    
1619
    public TaxonNodeDetailSection createTaxonNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1620
        TaxonNodeDetailSection section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1621
        addAndAdaptSection(parentElement, section);
1622
        return section;
1623
    }
1624

    
1625
    public PolytomousKeyDetailSection createPolytomousKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1626
        PolytomousKeyDetailSection section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
1627
        addAndAdaptSection(parentElement, section);
1628
        return section;
1629
    }
1630

    
1631
    public PolytomousKeyNodeDetailSection createPolytomousKeyNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1632
        PolytomousKeyNodeDetailSection section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1633
        addAndAdaptSection(parentElement, section);
1634
        return section;
1635
    }
1636

    
1637
    public InstitutionDetailSection createInstitutionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1638
        InstitutionDetailSection section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
1639
        addAndAdaptSection(parentElement, section);
1640
        return section;
1641
    }
1642

    
1643
    public FieldUnitGeneralDetailSection createFieldUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1644
        FieldUnitGeneralDetailSection section = new FieldUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1645
        addAndAdaptSection(parentElement, section);
1646
        return section;
1647
    }
1648

    
1649
    public DerivedUnitGeneralDetailSection createDerivedUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1650
        DerivedUnitGeneralDetailSection section = new DerivedUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1651
        addAndAdaptSection(parentElement, section);
1652
        return section;
1653
    }
1654

    
1655
    public PreservedSpecimenGeneralDetailSection createPreservedSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1656
        PreservedSpecimenGeneralDetailSection section = new PreservedSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1657
        addAndAdaptSection(parentElement, section);
1658
        return section;
1659
    }
1660

    
1661
    public TissueSampleGeneralDetailSection createTissueSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1662
        TissueSampleGeneralDetailSection section = new TissueSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1663
        addAndAdaptSection(parentElement, section);
1664
        return section;
1665
    }
1666

    
1667
    public DnaSampleGeneralDetailSection createDnaSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1668
        DnaSampleGeneralDetailSection section = new DnaSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1669
        addAndAdaptSection(parentElement, section);
1670
        return section;
1671
    }
1672

    
1673
    public SequenceGeneralDetailSection createSequenceGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1674
        SequenceGeneralDetailSection section = new SequenceGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1675
        addAndAdaptSection(parentElement, section);
1676
        return section;
1677
    }
1678

    
1679
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1680
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1681
        addAndAdaptSection(parentElement, section);
1682
        return section;
1683
    }
1684

    
1685
    public SingleReadGeneralDetailSection createSingleReadGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1686
        SingleReadGeneralDetailSection section = new SingleReadGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1687
        addAndAdaptSection(parentElement, section);
1688
        return section;
1689
    }
1690

    
1691
    public AmplificationGeneralDetailSection createAmplificationGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1692
        AmplificationGeneralDetailSection section = new AmplificationGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1693
        addAndAdaptSection(parentElement, section);
1694
        return section;
1695
    }
1696

    
1697
    public AmplificationPrimerDetailSection createAmplificationPrimerDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1698
        AmplificationPrimerDetailSection section = new AmplificationPrimerDetailSection(this, conversation, parentElement, selectionProvider, style);
1699
        addAndAdaptSection(parentElement, section);
1700
        return section;
1701
    }
1702

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1793
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1794
        parentElement.addElement(section);
1795
        adapt(section);
1796
    }
1797

    
1798
    //--------DetailElements------------
1799

    
1800
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1801
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1802
        addAndAdaptElement(parentElement, element);
1803
        return element;
1804
    }
1805

    
1806
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1807
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1808
        addAndAdaptElement(parentElement, element);
1809
        return element;
1810
    }
1811

    
1812
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1813
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1814
        addAndAdaptElement(parentElement, element);
1815
        return element;
1816
    }
1817

    
1818
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1819
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1820
        addAndAdaptElement(parentElement, element);
1821
        return element;
1822
    }
1823

    
1824
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1825
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1826
        addAndAdaptElement(parentElement, element);
1827
        return element;
1828
    }
1829

    
1830
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1831
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1832
        addAndAdaptElement(parentElement, element);
1833
        return element;
1834
    }
1835

    
1836
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1837
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
1838
        addAndAdaptElement(parentElement, element);
1839
        return element;
1840
    }
1841

    
1842
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
1843
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
1844
        addAndAdaptElement(parentElement, element);
1845
        return element;
1846
    }
1847

    
1848
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
1849
        UserDetailElement element = new UserDetailElement(this, parentElement);
1850
        addAndAdaptElement(parentElement, element);
1851
        return element;
1852
    }
1853

    
1854
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
1855
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
1856
        addAndAdaptElement(parentElement, element);
1857
        return element;
1858
    }
1859

    
1860
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
1861
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
1862
        addAndAdaptElement(parentElement, element);
1863
        return element;
1864
    }
1865

    
1866
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
1867
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
1868
        addAndAdaptElement(parentElement, element);
1869
        return element;
1870
    }
1871

    
1872
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
1873
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
1874
        addAndAdaptElement(parentElement, element);
1875
        return element;
1876
    }
1877

    
1878
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
1879
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
1880
        addAndAdaptElement(parentElement, element);
1881
        return element;
1882
    }
1883

    
1884
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement){
1885
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement);
1886
        addAndAdaptElement(parentElement, element);
1887
        return element;
1888
    }
1889

    
1890
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
1891
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
1892
        addAndAdaptElement(parentElement, element);
1893
        return element;
1894
    }
1895

    
1896
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
1897
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
1898
        addAndAdaptElement(parentElement, element);
1899
        return element;
1900
    }
1901

    
1902
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
1903
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
1904
        addAndAdaptElement(parentElement, element);
1905
        return element;
1906
    }
1907

    
1908
    public DerivedUnitFacadeDetailElement createDerivedUnitFacadeDetailElement(ICdmFormElement parentElement){
1909
        DerivedUnitFacadeDetailElement element = new DerivedUnitFacadeDetailElement(this, parentElement);
1910
        addAndAdaptElement(parentElement, element);
1911
        return element;
1912
    }
1913

    
1914
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
1915
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
1916
        addAndAdaptElement(parentElement, element);
1917
        return element;
1918
    }
1919

    
1920
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
1921
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
1922
        addAndAdaptElement(parentElement, element);
1923
        return element;
1924
    }
1925

    
1926
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
1927
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
1928
        addAndAdaptElement(parentElement, element);
1929
        return element;
1930
    }
1931

    
1932
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
1933
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
1934
        addAndAdaptElement(parentElement, element);
1935
        return element;
1936
    }
1937

    
1938
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style){
1939
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style);
1940
        addAndAdaptElement(parentElement, element);
1941
        return element;
1942
    }
1943

    
1944
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
1945
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
1946
        addAndAdaptElement(parentElement, element);
1947
        return element;
1948
    }
1949

    
1950
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
1951
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
1952
        addAndAdaptElement(parentElement, element);
1953
        return element;
1954
    }
1955

    
1956
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
1957
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
1958
        addAndAdaptElement(parentElement, element);
1959
        return element;
1960
    }
1961

    
1962
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
1963
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
1964
        addAndAdaptElement(parentElement, element);
1965
        return element;
1966
    }
1967

    
1968
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
1969
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
1970
        addAndAdaptElement(parentElement, element);
1971
        return element;
1972
    }
1973

    
1974

    
1975
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
1976
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
1977
        addAndAdaptElement(parentElement, element);
1978
        return element;
1979
    }
1980

    
1981
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
1982
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
1983
        addAndAdaptElement(parentElement, element);
1984
        return element;
1985
    }
1986

    
1987
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
1988
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
1989
        addAndAdaptElement(parentElement, element);
1990
        return element;
1991
    }
1992

    
1993
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
1994
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
1995
        addAndAdaptElement(parentElement, element);
1996
        return element;
1997
    }
1998

    
1999
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2000
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2001
        addAndAdaptElement(parentElement, element);
2002
        return element;
2003
    }
2004

    
2005
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2006
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2007
        addAndAdaptElement(parentElement, element);
2008
        return element;
2009
    }
2010

    
2011
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2012
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2013
        addAndAdaptElement(parentElement, element);
2014
        return element;
2015
    }
2016

    
2017
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2018
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2019
        addAndAdaptElement(parentElement, element);
2020
        return element;
2021
    }
2022

    
2023
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2024
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2025
        addAndAdaptElement(parentElement, element);
2026
        return element;
2027
    }
2028

    
2029
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2030
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2031
        addAndAdaptElement(parentElement, element);
2032
        return element;
2033
    }
2034

    
2035
    public SpecimenScanGeneralDetailElement createSpecimenScanGeneralDetailElement(ICdmFormElement parentElement){
2036
        SpecimenScanGeneralDetailElement element = new SpecimenScanGeneralDetailElement(this, parentElement);
2037
        addAndAdaptElement(parentElement, element);
2038
        return element;
2039
    }
2040

    
2041
    public LivingPlantPhotoGeneralDetailElement createLivingPlantPhotoGeneralDetailElement(ICdmFormElement parentElement){
2042
        LivingPlantPhotoGeneralDetailElement element = new LivingPlantPhotoGeneralDetailElement(this, parentElement);
2043
        addAndAdaptElement(parentElement, element);
2044
        return element;
2045
    }
2046

    
2047
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2048
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2049
        addAndAdaptElement(parentElement, element);
2050
        return element;
2051
    }
2052

    
2053

    
2054
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2055
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2056
        addAndAdaptElement(parentElement, element);
2057
        return element;
2058
    }
2059

    
2060
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2061
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2062
        addAndAdaptElement(parentElement, element);
2063
        return element;
2064
    }
2065

    
2066

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

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

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

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

    
2091
    /**
2092
     * @param parentElement
2093
     * @param element
2094
     */
2095
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2096
        adapt(element);
2097
        parentElement.addElement(element);
2098
    }
2099

    
2100
    //--------EntityCollectionSection----------
2101
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2102
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style);
2103
        addAndAdaptSection(parentElement, section);
2104
        return section;
2105
    }
2106

    
2107
    public AnnotationSection createAnnotationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2108
        AnnotationSection section = new AnnotationSection(this, conversation, parentElement, style);
2109
        addAndAdaptSection(parentElement, section);
2110
        return section;
2111
    }
2112

    
2113
    public CreditSection createCreditSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2114
        CreditSection section = new CreditSection(this, conversation, parentElement, style);
2115
        addAndAdaptSection(parentElement, section);
2116
        return section;
2117
    }
2118

    
2119
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2120
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2121
        addAndAdaptSection(parentElement, section);
2122
        return section;
2123
    }
2124

    
2125
    public ExtensionSection createExtensionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2126
        ExtensionSection section = new ExtensionSection(this, conversation, parentElement, style);
2127
        addAndAdaptSection(parentElement, section);
2128
        return section;
2129
    }
2130

    
2131
    public MarkerSection createMarkerSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2132
        MarkerSection section = new MarkerSection(this, conversation, parentElement, style);
2133
        addAndAdaptSection(parentElement, section);
2134
        return section;
2135
    }
2136

    
2137
    public MediaSection createMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2138
        MediaSection section = new MediaSection(this, conversation, parentElement, style);
2139
        addAndAdaptSection(parentElement, section);
2140
        return section;
2141
    }
2142

    
2143
    public DescriptionElementMediaSection createDescriptionElementMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2144
        DescriptionElementMediaSection section = new DescriptionElementMediaSection(this, conversation, parentElement, style);
2145
        addAndAdaptSection(parentElement, section);
2146
        return section;
2147
    }
2148

    
2149
    public MediaRepresentationSection createMediaRepresentationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2150
        MediaRepresentationSection section = new MediaRepresentationSection(this, conversation, parentElement, style);
2151
        addAndAdaptSection(parentElement, section);
2152
        return section;
2153
    }
2154

    
2155
    public MediaRepresentationPartSection createMediaRepresentationPartSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2156
        MediaRepresentationPartSection section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
2157
        addAndAdaptSection(parentElement, section);
2158
        return section;
2159
    }
2160

    
2161
    public ModifierSection createModifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2162
        ModifierSection section = new ModifierSection(this, conversation, parentElement, style);
2163
        addAndAdaptSection(parentElement, section);
2164
        return section;
2165
    }
2166

    
2167
    public NomenclaturalStatusSection createNomenclaturalStatusSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2168
        NomenclaturalStatusSection section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
2169
        addAndAdaptSection(parentElement, section);
2170
        return section;
2171
    }
2172

    
2173
    public NameRelationshipDetailSection createNameRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2174
        NameRelationshipDetailSection section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
2175
        addAndAdaptSection(parentElement, section);
2176
        return section;
2177
    }
2178

    
2179
//    public SynonymRelationshipDetailSection createSynonymRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2180
//        SynonymRelationshipDetailSection section = new SynonymRelationshipDetailSection(this, conversation, parentElement, style);
2181
//        addAndAdaptSection(parentElement, section);
2182
//        return section;
2183
//    }
2184

    
2185
    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2186
        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2187
        addAndAdaptSection(parentElement, section);
2188
        return section;
2189
    }
2190

    
2191
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2192
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2193
        addAndAdaptSection(parentElement, section);
2194
        return section;
2195
    }
2196

    
2197
    public SourceSection createSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2198
        SourceSection section = new SourceSection(this, conversation, parentElement, style);
2199
        addAndAdaptSection(parentElement, section);
2200
        return section;
2201
    }
2202

    
2203
    public ScopeSection createScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2204
        ScopeSection section = new ScopeSection(this, conversation, parentElement, style);
2205
        addAndAdaptSection(parentElement, section);
2206
        return section;
2207
    }
2208

    
2209
    public DescriptionSourceSection createDescriptionSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2210
        DescriptionSourceSection section = new DescriptionSourceSection(this, conversation, parentElement, style);
2211
        addAndAdaptSection(parentElement, section);
2212
        return section;
2213
    }
2214

    
2215
    public TypeDesignationSection createTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2216
        TypeDesignationSection section = new TypeDesignationSection(this, conversation, parentElement, style);
2217
        addAndAdaptSection(parentElement, section);
2218
        return section;
2219
    }
2220

    
2221
    public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2222
        StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
2223
        addAndAdaptSection(parentElement, section);
2224
        return section;
2225
    }
2226

    
2227
    public StatisticalMeasurementValueSection createStatisticalMeasurementValueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2228
        StatisticalMeasurementValueSection section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
2229
        addAndAdaptSection(parentElement, section);
2230
        return section;
2231
    }
2232

    
2233
    public DescribedSpecimenSection createDescribedSpecimenSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2234
        DescribedSpecimenSection section = new DescribedSpecimenSection(this, conversation, parentElement, style);
2235
        addAndAdaptSection(parentElement, section);
2236
        return section;
2237
    }
2238

    
2239
    public CollectingAreasDetailSection createCollectingAreasDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2240
        CollectingAreasDetailSection section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
2241
        addAndAdaptSection(parentElement, section);
2242
        return section;
2243
    }
2244

    
2245
    public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2246
        CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
2247
        addAndAdaptSection(parentElement, section);
2248
        return section;
2249
    }
2250

    
2251
    public PreservedSpecimenCurrentDeterminationDetailSection createPreservedSpecimenCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2252
        PreservedSpecimenCurrentDeterminationDetailSection section = new PreservedSpecimenCurrentDeterminationDetailSection(this, conversation, parentElement, style);
2253
        addAndAdaptSection(parentElement, section);
2254
        return section;
2255
    }
2256

    
2257
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2258
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
2259
        addAndAdaptSection(parentElement, section);
2260
        return section;
2261
    }
2262

    
2263
    public PreservedSpecimenDeterminationHistoryDetailSection createPreservedSpecimenDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2264
        PreservedSpecimenDeterminationHistoryDetailSection section = new PreservedSpecimenDeterminationHistoryDetailSection(this, conversation, parentElement, style);
2265
        addAndAdaptSection(parentElement, section);
2266
        return section;
2267
    }
2268

    
2269
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2270
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
2271
        addAndAdaptSection(parentElement, section);
2272
        return section;
2273
    }
2274

    
2275
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2276
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2277
        addAndAdaptSection(parentElement, section);
2278
        return section;
2279
    }
2280

    
2281
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2282
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2283
        addAndAdaptSection(parentElement, section);
2284
        return section;
2285
    }
2286

    
2287
    public GeographicalScopeDetailSection createGeographicalScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2288
        GeographicalScopeDetailSection section = new GeographicalScopeDetailSection(this, conversation, parentElement, style);
2289
        addAndAdaptSection(parentElement, section);
2290
        return section;
2291
    }
2292

    
2293
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2294
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2295
        addAndAdaptSection(parentElement, section);
2296
        return section;
2297
    }
2298

    
2299
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2300
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2301
        addAndAdaptSection(parentElement, section);
2302
        return section;
2303
    }
2304

    
2305
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2306
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2307
        addAndAdaptSection(parentElement, section);
2308
        return section;
2309
    }
2310

    
2311
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2312
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2313
        addAndAdaptSection(parentElement, section);
2314
        return section;
2315
    }
2316

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

    
2323
    /**
2324
     * <p>
2325
     * createEntityCollectionElement
2326
     * </p>
2327
     *
2328
     * @param removeListener
2329
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
2330
     * @param style
2331
     *            a int.
2332
     * @param parentElement
2333
     *            a
2334
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
2335
     *            object.
2336
     * @param versionableEntity
2337
     *            a {@link eu.etaxonomy.cdm.model.common.IVersionableEntity}
2338
     *            object.
2339
     * @param backgroundColor
2340
     *            a {@link org.eclipse.swt.graphics.Color} object.
2341
     * @return a
2342
     *         {@link eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement}
2343
     *         object.
2344
     */
2345
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2346
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2347
        AbstractEntityCollectionElement element = null;
2348

    
2349
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2350

    
2351
        if (entity instanceof Annotation) {
2352
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2353
        } else if (entity instanceof Person) {
2354
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
2355
        } else if (entity instanceof Credit) {
2356
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2357
        } else if (entity instanceof Extension) {
2358
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2359
        } else if (entity instanceof Marker) {
2360
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2361
        } else if (entity instanceof Media) {
2362
            element = new MediaElement(this, parentElement, (Media) entity, removeListener, style);
2363
        } else if (entity instanceof MediaRepresentation) {
2364
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2365
                    style);
2366
        } else if (entity instanceof ImageFile) {
2367
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2368
        } else if (entity instanceof MediaRepresentationPart) {
2369
            element = new MediaRepresentationPartElement(this, parentElement, (MediaRepresentationPart) entity,
2370
                    removeListener, style);
2371
        } else if (entity instanceof NomenclaturalStatus) {
2372
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2373
                    style);
2374
        } else if (entity instanceof Rights) {
2375
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2376
        } else if (entity instanceof DescriptionElementSource) {
2377
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2378
                    removeListener, style);
2379
        } else if (entity instanceof IdentifiableSource) {
2380
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2381
                    style);
2382
		} else if (entity instanceof DefinedTerm) {
2383
			switch(((DefinedTerm)entity).getTermType()) {
2384
				case Scope:
2385
					element = new ScopeElement(this,
2386
							parentElement,
2387
							(DefinedTerm) entity,
2388
							removeListener,
2389
							style);
2390
					break;
2391
				case Modifier:
2392
					element = new ModifierElement(this,
2393
							parentElement,
2394
							(DefinedTerm) entity,
2395
							removeListener,
2396
							style);
2397
					break;
2398
				default:
2399
					//FIXME : Actually we should through an exception here
2400
					element = null;
2401
					break;
2402

    
2403
			}
2404
        } else if (entity instanceof Reference) {
2405
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2406
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2407
            }
2408
            else{
2409
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2410
            }
2411
        } else if (entity instanceof NameTypeDesignation) {
2412
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2413
                    style);
2414
        } else if (entity instanceof NameRelationship) {
2415
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2416
                    style);
2417
//        } else if (entity instanceof SynonymRelationship) {
2418
//            element = new SynonymRelationshipDetailElement(this, parentElement, (SynonymRelationship) entity, removeListener,
2419
//                    style);
2420
        } else if (entity instanceof SpecimenTypeDesignation) {
2421
            element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2422
                    removeListener, style);
2423
        } else if (entity instanceof StateData) {
2424
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2425
        } else if (entity instanceof StatisticalMeasurementValue) {
2426
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2427
                    removeListener, style);
2428
        } else if (entity instanceof DerivedUnit) {
2429
        	switch(((DerivedUnit)entity).getRecordBasis()) {
2430
				case LivingSpecimen:
2431
				case PreservedSpecimen:
2432
				case OtherSpecimen:
2433
					element = new SpecimenCollectionDetailElement(this,
2434
								parentElement,
2435
								(DerivedUnit) entity,
2436
								removeListener,
2437
								style);
2438
					break;
2439
				default:
2440
					element = new DerivedUnitElement(this,
2441
								parentElement,
2442
								(DerivedUnit) entity,
2443
								removeListener,
2444
								style);
2445
			}
2446

    
2447
        } else if (entity instanceof NamedArea) {
2448
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2449
        } else if (entity instanceof DeterminationEvent) {
2450
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2451
        } else if (entity instanceof User) {
2452
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2453
        } else if (entity instanceof GrantedAuthority) {
2454
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity,
2455
                    removeListener, style);
2456
        } else if (entity instanceof Group) {
2457
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2458
        } else if (entity instanceof Taxon) {
2459
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2460
        } else if (entity instanceof DescriptionElementBase) {
2461
            // this is the special case for protologs, maybe we can do this
2462
            // differently when API improves
2463
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2464
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2465
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2466
            }
2467
        }
2468

    
2469
        if (element == null) {
2470
            AbstractUtility.errorDialog("No element for entity", this,
2471
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2472
                            + entity, null);
2473
        }
2474

    
2475
        else if (backgroundColor != null && !backgroundColor.isDisposed()) {
2476
            element.setPersistentBackground(backgroundColor);
2477
            adapt(element);
2478
            parentElement.addElement(element);
2479
        }
2480

    
2481
        return element;
2482
    }
2483

    
2484
    /**
2485
     * <p>
2486
     * Creates a selection element for the given type T.
2487
     * </p>
2488
     * <p>
2489
     * <strong>Selection elements not handled by this method:</strong>
2490
     * <ul>
2491
     * <li>{@link TaxonNodeSelectionElement} see
2492
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2493
     * </li>
2494
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2495
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2496
     * </li>
2497
     * </ul>
2498
     * </p>
2499
     *
2500
     * @param clazz
2501
     *            a {@link Class} object of the type that you want the selection
2502
     *            element to handle
2503
     * @param parentElement
2504
     *            a {@link ICdmFormElement} object.
2505
     * @param labelString
2506
     *            a {@link String} object.
2507
     * @param selectionType
2508
     * @param selection
2509
     *            a {@link ICdmBase} object.
2510
     * @param style
2511
     *            a int.
2512
     * @param conversation
2513
     *            a {@link ConversationHolder} object.
2514
     * @return a {@link EntitySelectionElement} object.
2515
     */
2516
    public <T extends ICdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2517
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2518
            int style) {
2519
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2520
                labelString, selection, mode, style);
2521
        adapt(element);
2522
        parentElement.addElement(element);
2523
        return element;
2524
    }
2525

    
2526
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2527
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2528
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2529
                labelString, selection, mode, style);
2530
        adapt(element);
2531
        parentElement.addElement(element);
2532
        return element;
2533
    }
2534

    
2535
    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2536
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2537
            int mode, int style) {
2538
        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2539
                conversation, parentElement, labelString, selection, mode, style);
2540
        adapt(element);
2541
        parentElement.addElement(element);
2542
        return element;
2543
    }
2544

    
2545
    /** {@inheritDoc} */
2546
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2547
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2548
        adapt(labelElement);
2549
        parentElement.addElement(labelElement);
2550
        return labelElement;
2551
    }
2552

    
2553
    /**
2554
     * <p>
2555
     * Getter for the field <code>selectionProvider</code>.
2556
     * </p>
2557
     *
2558
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2559
     */
2560
    public ISelectionProvider getSelectionProvider() {
2561
        return selectionProvider;
2562
    }
2563

    
2564
    /**
2565
     * <p>
2566
     * createDetailedDescriptionDetailElement
2567
     * </p>
2568
     *
2569
     * @param parentElement
2570
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2571
     *            object.
2572
     * @param entity
2573
     *            a
2574
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2575
     *            object.
2576
     * @param style
2577
     *            a int.
2578
     * @return a
2579
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2580
     *         object.
2581
     */
2582
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2583
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2584
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2585

    
2586
        if (entity instanceof CategoricalData) {
2587
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2588
                    (CategoricalData) entity, style);
2589
        } else if (entity instanceof CommonTaxonName) {
2590
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2591
                    style);
2592
        } else if (entity instanceof Distribution) {
2593
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2594
                    style);
2595
        } else if (entity instanceof IndividualsAssociation) {
2596
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2597
                    (IndividualsAssociation) entity, style);
2598
        } else if (entity instanceof QuantitativeData) {
2599
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2600
                    (QuantitativeData) entity, style);
2601
        } else if (entity instanceof TaxonInteraction) {
2602
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2603
                    (TaxonInteraction) entity, style);
2604
        } else if (entity instanceof TextData) {
2605
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2606
        } else {
2607
            throw new IllegalStateException("There is no interface for the given description element");
2608
        }
2609
        adapt(detailedDescriptionElement);
2610
        parentElement.addElement(detailedDescriptionElement);
2611
        return detailedDescriptionElement;
2612

    
2613
    }
2614

    
2615
    /**
2616
     * Creates a styled text as a part of the form.
2617
     *
2618
     * @param parent
2619
     *            the text parent
2620
     * @param value
2621
     *            the text initial value
2622
     * @param style
2623
     *            the text style
2624
     * @return the text widget
2625
     */
2626
    public StyledText createStyledText(Composite parent, String value, int style) {
2627
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2628
        if (value != null) {
2629
            text.setText(value);
2630
        }
2631
        text.setForeground(getColors().getForeground());
2632
        text.setBackground(getColors().getBackground());
2633
        // text.addFocusListener(visibilityHandler);
2634
        return text;
2635
    }
2636

    
2637
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2638
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2639
        addAndAdaptSection(parentElement, section);
2640
        return section;
2641
    }
2642

    
2643
}
(6-6/37)