Project

General

Profile

Download (102 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.hibernate.HibernateProxyHelper;
45
import eu.etaxonomy.cdm.model.agent.Person;
46
import eu.etaxonomy.cdm.model.agent.Team;
47
import eu.etaxonomy.cdm.model.common.Annotation;
48
import eu.etaxonomy.cdm.model.common.CdmBase;
49
import eu.etaxonomy.cdm.model.common.Credit;
50
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
51
import eu.etaxonomy.cdm.model.common.DescriptionElementSource;
52
import eu.etaxonomy.cdm.model.common.Extension;
53
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
54
import eu.etaxonomy.cdm.model.common.Group;
55
import eu.etaxonomy.cdm.model.common.ICdmBase;
56
import eu.etaxonomy.cdm.model.common.IDefinedTerm;
57
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
58
import eu.etaxonomy.cdm.model.common.Language;
59
import eu.etaxonomy.cdm.model.common.LanguageString;
60
import eu.etaxonomy.cdm.model.common.Marker;
61
import eu.etaxonomy.cdm.model.common.TimePeriod;
62
import eu.etaxonomy.cdm.model.common.User;
63
import eu.etaxonomy.cdm.model.common.VersionableEntity;
64
import eu.etaxonomy.cdm.model.description.CategoricalData;
65
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
66
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
67
import eu.etaxonomy.cdm.model.description.Distribution;
68
import eu.etaxonomy.cdm.model.description.Feature;
69
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
70
import eu.etaxonomy.cdm.model.description.KeyStatement;
71
import eu.etaxonomy.cdm.model.description.Modifier;
72
import eu.etaxonomy.cdm.model.description.QuantitativeData;
73
import eu.etaxonomy.cdm.model.description.Scope;
74
import eu.etaxonomy.cdm.model.description.StateData;
75
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
76
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
77
import eu.etaxonomy.cdm.model.description.TextData;
78
import eu.etaxonomy.cdm.model.location.NamedArea;
79
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
80
import eu.etaxonomy.cdm.model.location.Point;
81
import eu.etaxonomy.cdm.model.media.ImageFile;
82
import eu.etaxonomy.cdm.model.media.Media;
83
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
84
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
85
import eu.etaxonomy.cdm.model.media.Rights;
86
import eu.etaxonomy.cdm.model.name.NameRelationship;
87
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
88
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
89
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
90
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
91
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
92
import eu.etaxonomy.cdm.model.occurrence.Specimen;
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.campanula.detailViews.fieldObservation.FieldObservationDetailsElement;
100
import eu.etaxonomy.taxeditor.ui.campanula.detailViews.fieldObservation.FieldObservationDetailsElementController;
101
import eu.etaxonomy.taxeditor.ui.campanula.detailViews.fieldObservation.FieldObservationGeneralElement;
102
import eu.etaxonomy.taxeditor.ui.campanula.detailViews.fieldObservation.FieldObservationGeneralElementController;
103
import eu.etaxonomy.taxeditor.ui.campanula.detailViews.fieldObservation.GatheringEventDetailsElement;
104
import eu.etaxonomy.taxeditor.ui.campanula.detailViews.fieldObservation.GatheringEventDetailsElementController;
105
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
106
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
107
import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
108
import eu.etaxonomy.taxeditor.ui.openurl.OpenUrlSelectorElement;
109
import eu.etaxonomy.taxeditor.ui.password.EditPasswordElement;
110
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
111
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
112
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
113
import eu.etaxonomy.taxeditor.ui.section.EmptyElement;
114
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement;
115
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection;
116
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailElement;
117
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
118
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailElement;
119
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
120
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
121
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberSection;
122
import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
123
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailElement;
124
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailSection;
125
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailElement;
126
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailSection;
127
import eu.etaxonomy.taxeditor.ui.section.common.ReferenceEntityDetailElement;
128
import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
129
import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
130
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
131
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailElement;
132
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
133
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
134
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
135
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
136
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceElement;
137
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
138
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceElement;
139
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
140
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
141
import eu.etaxonomy.taxeditor.ui.section.description.ModifierElement;
142
import eu.etaxonomy.taxeditor.ui.section.description.ModifierSection;
143
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageDetailElement;
144
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
145
import eu.etaxonomy.taxeditor.ui.section.description.ScopeElement;
146
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
147
import eu.etaxonomy.taxeditor.ui.section.description.StateDataElement;
148
import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;
149
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueElement;
150
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueSection;
151
import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;
152
import eu.etaxonomy.taxeditor.ui.section.description.detail.CategoricalDataDetailElement;
153
import eu.etaxonomy.taxeditor.ui.section.description.detail.CommonNameDetailElement;
154
import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
155
import eu.etaxonomy.taxeditor.ui.section.description.detail.IndividualsAssociationDetailElement;
156
import eu.etaxonomy.taxeditor.ui.section.description.detail.QuantitativeDataDetailElement;
157
import eu.etaxonomy.taxeditor.ui.section.description.detail.TaxonInteractionDetailElement;
158
import eu.etaxonomy.taxeditor.ui.section.description.detail.TextDataDetailElement;
159
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement;
160
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
161
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityCollectionElement;
162
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailElement;
163
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
164
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailElement;
165
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
166
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailElement;
167
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
168
import eu.etaxonomy.taxeditor.ui.section.key.GeographicalScopeDetailSection;
169
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailElement;
170
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
171
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailElement;
172
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
173
import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
174
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
175
import eu.etaxonomy.taxeditor.ui.section.media.ImageFileElement;
176
import eu.etaxonomy.taxeditor.ui.section.media.MediaElement;
177
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationElement;
178
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartElement;
179
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartSection;
180
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationSection;
181
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
182
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
183
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailSection;
184
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailElement;
185
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailSection;
186
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailElement;
187
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailSection;
188
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailElement;
189
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
190
import eu.etaxonomy.taxeditor.ui.section.name.NameTypeDesignationElement;
191
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusElement;
192
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
193
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailElement;
194
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
195
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueElement;
196
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
197
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
198
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
199
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
200
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
201
import eu.etaxonomy.taxeditor.ui.section.occurrence.CurrentDeterminationDetailSection;
202
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailElement;
203
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
204
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitFacadeDetailElement;
205
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitFacadeDetailSection;
206
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement;
207
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
208
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement;
209
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection;
210
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationDetailElement;
211
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationDetailSection;
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.GeneralDetailElement;
215
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeneralDetailSection;
216
import eu.etaxonomy.taxeditor.ui.section.occurrence.NamedAreaDetailElement;
217
import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
218
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElement;
219
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailSection;
220
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
221
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
222
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement;
223
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
224
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationElement;
225
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
226
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseElement;
227
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
228
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditElement;
229
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
230
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionElement;
231
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
232
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
233
import eu.etaxonomy.taxeditor.ui.section.supplemental.IdentifiableSourceElement;
234
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerElement;
235
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
236
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsElement;
237
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
238
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
239
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement;
240
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
241
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement;
242
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
243
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailElement;
244
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
245
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailElement;
246
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailElement;
247
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
248
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailElement;
249
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
250
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailElement;
251
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
252
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailElement;
253
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
254
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement;
255
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailSection;
256
import eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailSection;
257
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailElement;
258
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
259
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
260
import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
261
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
262

    
263
/**
264
 * <p>
265
 * CdmFormFactory class.
266
 * </p>
267
 *
268
 * @author n.hoffmann
269
 * @created Feb 24, 2010
270
 * @version 1.0
271
 */
272
public class CdmFormFactory extends FormToolkit {
273

    
274
    private BoldFontHolder2 boldFontHolder2;
275
    private MouseListener selectionMouseHandler;
276
    private FocusListener selectionFocusHandler;
277

    
278
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
279

    
280
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
281

    
282
    private final int orientation = Window.getDefaultOrientation();
283
    private ISelectionProvider selectionProvider;
284

    
285
    /** Constant <code>EMPTY_SELECTION</code> */
286
    public static ISelection EMPTY_SELECTION = new ISelection() {
287
        @Override
288
        public boolean isEmpty() {
289
            return true;
290
        }
291
    };
292

    
293
    /**
294
     *
295
     * @author n.hoffmann
296
     * @date Jan 25, 2010
297
     *
298
     */
299
    private class SelectionMouseHandler extends MouseAdapter {
300
        @Override
301
        public void mouseDown(MouseEvent e) {
302
            notifySelectionListeners(e);
303
        }
304
    }
305

    
306
    /**
307
     *
308
     * @author n.hoffmann
309
     * @date Jan 25, 2010
310
     *
311
     */
312
    private class SelectionFocusHandler extends FocusAdapter {
313
        @Override
314
        public void focusGained(FocusEvent e) {
315
            notifySelectionListeners(e);
316
        }
317
    }
318

    
319
    private void notifySelectionListeners(TypedEvent e) {
320
        Event event = new Event();
321
        event.widget = e.widget;
322
        SelectionEvent selectionEvent = new SelectionEvent(event);
323

    
324
        for (SelectionListener listener : selectionListenerList) {
325
            listener.widgetSelected(selectionEvent);
326
        }
327
    }
328

    
329
    /**
330
     * <p>
331
     * Constructor for CdmFormFactory.
332
     * </p>
333
     *
334
     * @param display
335
     *            a {@link org.eclipse.swt.widgets.Display} object.
336
     * @param selectionProvider
337
     *            a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
338
     */
339
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
340
        super(display);
341
        this.selectionProvider = selectionProvider;
342
        init();
343
    }
344

    
345
    /**
346
     * <p>
347
     * Constructor for CdmFormFactory.
348
     * </p>
349
     *
350
     * @param display
351
     *            a {@link org.eclipse.swt.widgets.Display} object.
352
     */
353
    public CdmFormFactory(Display display) {
354
        super(display);
355
        init();
356
    }
357

    
358
    /**
359
	 *
360
	 */
361
    private void init() {
362
        boldFontHolder2 = new BoldFontHolder2();
363
        selectionMouseHandler = new SelectionMouseHandler();
364
        selectionFocusHandler = new SelectionFocusHandler();
365
    }
366

    
367
    /**
368
     * Creates an instance initialized with the correct selectionProvider
369
     *
370
     * Make sure to remove the instance when the entityComposite disposes via
371
     * destroySelectionArbitrator(..)
372
     *
373
     * @param entityElement
374
     *            a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
375
     *            object.
376
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
377
     *         object.
378
     */
379
    public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
380
        SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
381
        selectionArbitrator.addSelectionProvider(selectionProvider);
382
        selectionProvider.addSelectionChangedListener(selectionArbitrator);
383
        addSelectionListener(selectionArbitrator);
384
        return selectionArbitrator;
385
    }
386

    
387
    /**
388
     * <p>
389
     * destroySelectionArbitrator
390
     * </p>
391
     *
392
     * @param selectionArbitrator
393
     *            a
394
     *            {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
395
     *            object.
396
     */
397
    public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
398
        removeSelectionListener(selectionArbitrator);
399
        if (selectionProvider != null) {
400
            selectionProvider.removeSelectionChangedListener(selectionArbitrator);
401
        } else {
402
            AbstractUtility.error(this.getClass(),
403
                    "Tried to destroy a selection listener from this factories listeners but was null", null);
404
        }
405
    }
406

    
407
    /**
408
     * <p>
409
     * Adapts the {@link AbstractCdmFormElement}:<br>
410
     * - sets the {@link IPropertyChangeListener}s handled by this class
411
     * </p>
412
     *
413
     * @param formElement
414
     *            a
415
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
416
     *            object.
417
     */
418
    public void adapt(AbstractCdmFormElement formElement) {
419
        formElement.setPropertyChangeListeners(propertyChangeListeners);
420
    }
421

    
422
    /** {@inheritDoc} */
423
    @Override
424
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
425
        if (trackFocus) {
426
            control.addFocusListener(selectionFocusHandler);
427
        }
428
        super.adapt(control, trackFocus, trackKeyboard);
429
    }
430

    
431
    /** {@inheritDoc} */
432
    @Override
433
    public void adapt(Composite composite) {
434
        composite.addMouseListener(selectionMouseHandler);
435
        super.adapt(composite);
436
    }
437

    
438
    /**
439
     * <p>
440
     * destroyElement
441
     * </p>
442
     *
443
     * @param formElement
444
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
445
     *            object.
446
     */
447
    public void destroyElement(ICdmFormElement formElement) {
448
        // return if element was not initialized
449
        if (formElement == null) {
450
            return;
451
        }
452
        // destroy selection arbitrator, if any
453
        if (formElement instanceof ISelectableElement) {
454
            destroySelectionArbitrator(((ISelectableElement) formElement).getSelectionArbitrator());
455
        }
456
        // remove this element form its parents list of elements
457
        // ICdmFormElement parentElement = formElement.getParentElement();
458
        // if(parentElement != null){
459
        // parentElement.removeElement(formElement);
460
        // }
461
        // call destroy on child elements recursively
462
        for (ICdmFormElement childElement : formElement.getElements()) {
463
            destroyElement(childElement);
464
        }
465
        // dispose of the controls
466
        for (Control control : formElement.getControls()) {
467
            // we added the layoutComposite of the parental element as the
468
            // layout composite to this formElement
469
            // but we do not want to destroy it.
470
            if (control.equals(formElement.getLayoutComposite())) {
471
                continue;
472
            } else {
473
                control.dispose();
474
                control = null;
475
            }
476
        }
477
    }
478

    
479
    /**
480
     * <p>
481
     * createEmptyCell
482
     * </p>
483
     *
484
     * @param parent
485
     *            a {@link org.eclipse.swt.widgets.Composite} object.
486
     * @return a {@link org.eclipse.swt.widgets.Label} object.
487
     */
488
    public Label createEmptyCell(Composite parent) {
489
        return this.createLabel(parent, null);
490
    }
491

    
492
    /**
493
     * <p>
494
     * createMultilineTextWithLabel
495
     * </p>
496
     *
497
     * @param labelString
498
     *            a {@link java.lang.String} object.
499
     * @param textHeight
500
     *            a int.
501
     * @param style
502
     *            a int.
503
     * @param parentElement
504
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
505
     *            object.
506
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
507
     *         object.
508
     */
509
    public TextWithLabelElement createMultilineTextWithLabel(ICdmFormElement parentElement, String labelString,
510
            int textHeight, int style) {
511
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, style);
512
        adapt(element);
513
        parentElement.addElement(element);
514
        return element;
515
    }
516

    
517
    /**
518
     * <p>
519
     * createMultiLanguageTextElement
520
     * </p>
521
     *
522
     * @param parentElement
523
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
524
     *            object.
525
     * @param labelString
526
     *            a {@link java.lang.String} object.
527
     * @param multilanguageText
528
     *            a {@link java.util.Map} object.
529
     * @param textHeight
530
     *            a int.
531
     * @param style
532
     *            a int.
533
     * @return a
534
     *         {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
535
     *         object.
536
     */
537
    public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
538
            Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
539
        MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
540
                multilanguageText, textHeight, style);
541
        adapt(element);
542
        parentElement.addElement(element);
543
        return element;
544
    }
545

    
546
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
547
            KeyStatement keyStatement, int textHeight, int style) {
548
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
549
                textHeight, style);
550
        adapt(element);
551
        parentElement.addElement(element);
552
        return element;
553
    }
554

    
555
    /**
556
     * <p>
557
     * createTextWithLabelElement
558
     * </p>
559
     *
560
     * @param labelString
561
     *            a {@link java.lang.String} object.
562
     * @param initialText
563
     *            a {@link java.lang.String} object.
564
     * @param style
565
     *            a int.
566
     * @param parentElement
567
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
568
     *            object.
569
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
570
     *         object.
571
     */
572
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
573
            String initialText, int style) {
574
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
575
                style);
576
        adapt(element);
577
        parentElement.addElement(element);
578
        return element;
579
    }
580

    
581
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
582
            URI initialUri, int style) {
583
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
584
        adapt(element);
585
        parentElement.addElement(element);
586
        return element;
587
    }
588

    
589
    /**
590
     * @param element
591
     * @param string
592
     * @param uri
593
     * @param style
594
     * @return
595
     */
596
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
597
            IOpenUrlEnabled openUrlEnabled, int style) {
598
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
599
                style);
600
        adapt(element);
601
        parentElement.addElement(element);
602
        return element;
603
    }
604

    
605
    /**
606
     *
607
     * @param parentElement
608
     * @param labelString
609
     * @param conversationEnabled
610
     * @param user
611
     * @param style
612
     * @return
613
     */
614
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
615
            ConversationHolder conversation, User user, int style) {
616
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
617
        adapt(element);
618
        parentElement.addElement(element);
619
        return element;
620
    }
621

    
622
    /**
623
     * <p>
624
     * createIntegerTextWithLabelElement
625
     * </p>
626
     *
627
     * @param parentElement
628
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
629
     *            object.
630
     * @param labelString
631
     *            a {@link java.lang.String} object.
632
     * @param initialInteger
633
     *            a {@link java.lang.Integer} object.
634
     * @param style
635
     *            a int.
636
     * @return a
637
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
638
     *         object.
639
     */
640
    public NumberWithLabelElement createIntegerTextWithLabelElement(ICdmFormElement parentElement, String labelString,
641
            Integer initialInteger, int style) {
642
        NumberWithLabelElement element = new NumberWithLabelElement(this, parentElement, labelString, initialInteger,
643
                style);
644
        adapt(element);
645
        parentElement.addElement(element);
646
        return element;
647
    }
648

    
649
    /**
650
     * <p>
651
     * createFloatTextWithLabelElement
652
     * </p>
653
     *
654
     * @param parentElement
655
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
656
     *            object.
657
     * @param labelString
658
     *            a {@link java.lang.String} object.
659
     * @param initialFloat
660
     *            a float.
661
     * @param style
662
     *            a int.
663
     * @return a
664
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
665
     *         object.
666
     */
667
    public NumberWithLabelElement createFloatTextWithLabelElement(ICdmFormElement parentElement, String labelString,
668
            float initialFloat, int style) {
669
        NumberWithLabelElement element = new NumberWithLabelElement(this, parentElement, labelString, initialFloat,
670
                style);
671
        adapt(element);
672
        parentElement.addElement(element);
673
        return element;
674
    }
675

    
676
    /**
677
     * <p>
678
     * createLanguageStringWithLabelElement
679
     * </p>
680
     *
681
     * @param parentElement
682
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
683
     *            object.
684
     * @param labelString
685
     *            a {@link java.lang.String} object.
686
     * @param languageString
687
     *            a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
688
     * @param style
689
     *            a int.
690
     * @return a
691
     *         {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement}
692
     *         object.
693
     */
694
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
695
            String labelString, LanguageString languageString, int style) {
696
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
697
                languageString, style);
698
        adapt(element);
699
        parentElement.addElement(element);
700
        return element;
701
    }
702

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

    
732
    /**
733
     * <p>
734
     * createTextElement
735
     * </p>
736
     *
737
     * @param parentElement
738
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
739
     *            object.
740
     * @param initialText
741
     *            a {@link java.lang.String} object.
742
     * @param style
743
     *            a int.
744
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
745
     *         object.
746
     */
747
    public TextWithLabelElement createTextElement(ICdmFormElement parentElement, String initialText, int style) {
748
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, null, initialText, null, style);
749
        adapt(element);
750
        parentElement.addElement(element);
751
        return element;
752
    }
753

    
754
    /**
755
     * <p>
756
     * createKeyValueViewerElement
757
     * </p>
758
     *
759
     * @param parentElement
760
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
761
     *            object.
762
     * @param keyHeading
763
     *            a {@link java.lang.String} object.
764
     * @param valueHeading
765
     *            a {@link java.lang.String} object.
766
     * @param map
767
     *            a {@link java.util.Map} object.
768
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
769
     *         object.
770
     */
771
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
772
            String valueHeading, Map<Object, Object> map) {
773
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
774
        adapt(element);
775
        parentElement.addElement(element);
776
        return element;
777
    }
778

    
779
    /**
780
     * <p>
781
     * createTermComboElement
782
     * </p>
783
     *
784
     * @param termComboType
785
     *            a
786
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
787
     *            object.
788
     * @param parentElement
789
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
790
     *            object.
791
     * @param labelString
792
     *            a {@link java.lang.String} object.
793
     * @param selection
794
     *            a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
795
     *            object.
796
     * @param style
797
     *            a int.
798
     * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
799
     *         object.
800
     */
801

    
802
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
803
            ICdmFormElement parentElement, String labelString, T selection, int style) {
804
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString,
805
                selection, style);
806
        adapt(element);
807
        parentElement.addElement(element);
808
        return element;
809
    }
810

    
811
    /**
812
     * <p>
813
     * createEnumComboElement
814
     * </p>
815
     *
816
     * @param enumComboType
817
     *            a
818
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType}
819
     *            object.
820
     * @param parentElement
821
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
822
     *            object.
823
     * @param style
824
     *            a int.
825
     * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
826
     *         object.
827
     */
828
    public <T extends IDefinedTerm> EnumComboElement<T> createEnumComboElement(Class<T> enumComboType,
829
            ICdmFormElement parentElement, int style) {
830
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
831
        adapt(element);
832
        parentElement.addElement(element);
833
        return element;
834
    }
835

    
836
    /**
837
     * <p>
838
     * createBrowserElement
839
     * </p>
840
     *
841
     * @param imageUri
842
     *            a {@link java.net.URI} object.
843
     * @param style
844
     *            a int.
845
     * @param parentElement
846
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
847
     *            object.
848
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
849
     *         object.
850
     */
851
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
852
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
853
        adapt(element);
854
        parentElement.addElement(element);
855
        return element;
856
    }
857

    
858
    /**
859
     * <p>
860
     * createImageElement
861
     * </p>
862
     *
863
     * @param parentElement
864
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
865
     *            object.
866
     * @param imageUri
867
     *            a {@link java.net.URI} object.
868
     * @param style
869
     *            a int.
870
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
871
     */
872
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
873
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
874
        adapt(element);
875
        parentElement.addElement(element);
876
        return element;
877
    }
878

    
879
    /**
880
     * <p>
881
     * createTextActionElement
882
     * </p>
883
     *
884
     * @param labelString
885
     *            a {@link java.lang.String} object.
886
     * @param initialText
887
     *            a {@link java.lang.String} object.
888
     * @param style
889
     *            a int.
890
     * @param parentElement
891
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
892
     *            object.
893
     * @param buttonLabel
894
     *            a {@link java.lang.String} object.
895
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
896
     *         object.
897
     */
898
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
899
            String buttonLabel, String initialText, int style) {
900
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
901
                style);
902
        adapt(element);
903
        parentElement.addElement(element);
904
        return element;
905
    }
906

    
907
    /**
908
     * <p>
909
     * createCheckbox
910
     * </p>
911
     *
912
     * @param parentElement
913
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
914
     *            object.
915
     * @param label
916
     *            a {@link java.lang.String} object.
917
     * @param initialState
918
     *            a boolean.
919
     * @param style
920
     *            a int.
921
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
922
     *         object.
923
     */
924
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, boolean initialState, int style) {
925
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
926
        adapt(element);
927
        parentElement.addElement(element);
928
        return element;
929
    }
930

    
931
    /**
932
     * Creates a section as a part of the form.
933
     *
934
     * @return the section widget
935
     * @param section
936
     *            a
937
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
938
     *            object.
939
     */
940
    public Section adapt(AbstractFormSection section) {
941
        section.setMenu(section.getLayoutComposite().getMenu());
942
        adapt(section, true, true);
943

    
944
        // handle focus and property change events for cdm use
945
        section.addFocusListener(selectionFocusHandler);
946
        section.setPropertyChangeListeners(propertyChangeListeners);
947

    
948
        if (section.getToggle() != null) {
949
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
950
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
951
        }
952

    
953
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
954

    
955
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
956
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
957
            getColors().initializeSectionToolBarColors();
958
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
959
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
960
        }
961
        // call setTitleBarForeground regardless as it also sets the label color
962
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
963
        return section;
964
    }
965

    
966
    private class BoldFontHolder2 {
967
        private Font normalFont;
968

    
969
        private Font boldFont;
970

    
971
        public BoldFontHolder2() {
972
        }
973

    
974
        public Font getBoldFont(Font font) {
975
            createBoldFont(font);
976
            return boldFont;
977
        }
978

    
979
        private void createBoldFont(Font font) {
980
            if (normalFont == null || !normalFont.equals(font)) {
981
                normalFont = font;
982
                dispose();
983
            }
984
            if (boldFont == null) {
985
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
986
            }
987
        }
988

    
989
        public void dispose() {
990
            if (boldFont != null) {
991
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
992
                boldFont = null;
993
            }
994
        }
995
    }
996

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

    
1025
    /**
1026
     * <p>
1027
     * createTimePeriodElement
1028
     * </p>
1029
     *
1030
     * @param parentElement
1031
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1032
     *            object.
1033
     * @param labelString
1034
     *            a {@link java.lang.String} object.
1035
     * @param timePeriod
1036
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1037
     * @param style
1038
     *            a int.
1039
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1040
     *         object.
1041
     */
1042
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1043
            TimePeriod timePeriod, int style) {
1044
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1045
        adapt(element);
1046
        parentElement.addElement(element);
1047
        return element;
1048
    }
1049

    
1050
    /**
1051
     * <p>
1052
     * createPointElement
1053
     * </p>
1054
     *
1055
     * @param style
1056
     *            a int.
1057
     * @param parentElement
1058
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1059
     *            object.
1060
     * @param point
1061
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1062
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1063
     */
1064
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1065
        PointElement element = new PointElement(this, parentElement, point, style);
1066
        adapt(element);
1067
        parentElement.addElement(element);
1068
        return element;
1069
    }
1070

    
1071
    /**
1072
     * <p>
1073
     * createDateDetailSection
1074
     * </p>
1075
     *
1076
     * @param parentElement
1077
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1078
     *            object.
1079
     * @param style
1080
     *            a int.
1081
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1082
     *         object.
1083
     */
1084
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1085
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1086
        parentElement.addElement(section);
1087
        adapt(section);
1088
        return section;
1089
    }
1090

    
1091
    /**
1092
     * <p>
1093
     * createPartialElement
1094
     * </p>
1095
     *
1096
     * @param parentElement
1097
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1098
     *            object.
1099
     * @param labelString
1100
     *            a {@link java.lang.String} object.
1101
     * @param partial
1102
     *            a {@link org.joda.time.Partial} object.
1103
     * @param style
1104
     *            a int.
1105
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1106
     *         object.
1107
     */
1108
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1109
            int style) {
1110
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1111
        adapt(element);
1112
        parentElement.addElement(element);
1113
        return element;
1114
    }
1115

    
1116
    /**
1117
     * <p>
1118
     * addSelectionListener
1119
     * </p>
1120
     *
1121
     * @param listener
1122
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1123
     */
1124
    public void addSelectionListener(SelectionListener listener) {
1125
        selectionListenerList.add(listener);
1126
    }
1127

    
1128
    /**
1129
     * <p>
1130
     * removeSelectionListener
1131
     * </p>
1132
     *
1133
     * @param listener
1134
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1135
     */
1136
    public void removeSelectionListener(SelectionListener listener) {
1137
        if (listener == null) {
1138
            AbstractUtility.error(this.getClass(),
1139
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1140
        } else {
1141
            selectionListenerList.remove(listener);
1142
        }
1143
    }
1144

    
1145
    /**
1146
     * <p>
1147
     * addPropertyChangeListener
1148
     * </p>
1149
     *
1150
     * @param listener
1151
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1152
     *            object.
1153
     */
1154
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1155
        if (propertyChangeListeners.contains(listener)) {
1156
            return;
1157
        }
1158
        propertyChangeListeners.add(0, listener);
1159
    }
1160

    
1161
    /**
1162
     * <p>
1163
     * removePropertyChangeListener
1164
     * </p>
1165
     *
1166
     * @param listener
1167
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1168
     *            object.
1169
     */
1170
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1171
        propertyChangeListeners.remove(listener);
1172
    }
1173

    
1174
    /**
1175
     * @return the propertyChangeListeners
1176
     */
1177
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1178
        return propertyChangeListeners;
1179
    }
1180

    
1181
    /**
1182
     * <p>
1183
     * createHorizontalSeparator
1184
     * </p>
1185
     *
1186
     * @param parentElement
1187
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1188
     *            object.
1189
     * @param style
1190
     *            a int.
1191
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1192
     */
1193
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1194
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1195
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1196
        return separator;
1197
    }
1198

    
1199
    /**
1200
     * <p>
1201
     * createVersionElement
1202
     * </p>
1203
     *
1204
     * @param parentElement
1205
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1206
     *            object.
1207
     * @param entity
1208
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1209
     *            object.
1210
     * @param style
1211
     *            a int.
1212
     * @return a
1213
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1214
     *         object.
1215
     */
1216
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1217
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1218
        adapt(element);
1219
        parentElement.addElement(element);
1220
        return element;
1221
    }
1222

    
1223
    /**
1224
     * @param cdmBaseSection
1225
     * @param object
1226
     * @param style
1227
     * @return
1228
     */
1229
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1230
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1231
        adapt(element);
1232
        parentElement.addElement(element);
1233
        return element;
1234
    }
1235

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

    
1257
    /**
1258
     * @param parent
1259
     * @param i
1260
     * @return
1261
     */
1262
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1263
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1264
        parentElement.addElement(section);
1265
        adapt(section);
1266
        return section;
1267
    }
1268

    
1269
    /**
1270
     * <p>
1271
     * createEmptyElement
1272
     * </p>
1273
     *
1274
     * @param parentElement
1275
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1276
     *            object.
1277
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1278
     */
1279
    public EmptyElement createEmptyElement(ICdmFormElement parentElement) {
1280
        EmptyElement element = new EmptyElement(this, parentElement, null, SWT.NULL);
1281
        adapt(element);
1282
        parentElement.addElement(element);
1283
        return element;
1284
    }
1285

    
1286
    /**
1287
     * <p>
1288
     * createHeadlineSection
1289
     * </p>
1290
     *
1291
     * @param parentElement
1292
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1293
     *            object.
1294
     * @return a
1295
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1296
     *         object.
1297
     */
1298
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1299
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1300
        parentElement.addElement(section);
1301
        adapt(section);
1302
        return section;
1303
    }
1304

    
1305
    /**
1306
     * <p>
1307
     * createParsingMessageElement
1308
     * </p>
1309
     *
1310
     * @param parentElement
1311
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1312
     *            object.
1313
     * @param parserProblem
1314
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1315
     *            object.
1316
     * @param style
1317
     *            a int.
1318
     * @return a
1319
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1320
     *         object.
1321
     */
1322
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1323
            ParserProblem parserProblem, int style) {
1324
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1325
        adapt(element);
1326
        parentElement.addElement(element);
1327
        return element;
1328
    }
1329

    
1330
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1331
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1332

    
1333
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1334
                selectionProvider, style);
1335

    
1336
        parentElement.addElement(section);
1337
        adapt(section);
1338
        return section;
1339

    
1340
    }
1341

    
1342
    /**
1343
     * @param definedTermClass
1344
     * @param formElement
1345
     * @param style
1346
     * @return
1347
     */
1348
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass, AbstractCdmDetailSection parentElement, int style) {
1349
        AbstractCdmDetailElement element = null;
1350

    
1351
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1352
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1353
        } else {
1354
            element = new DefinedTermDetailElement(this, parentElement);
1355
        }
1356

    
1357
        adapt(element);
1358
        parentElement.addElement(element);
1359
        return element;
1360
    }
1361

    
1362

    
1363
    //--------DetailSections---------
1364
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1365
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1366
        addAndAdaptSection(parentElement, section);
1367
        return section;
1368
    }
1369

    
1370
    public ReferenceDetailSection createReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1371
        ReferenceDetailSection section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1372
        addAndAdaptSection(parentElement, section);
1373
        return section;
1374
    }
1375

    
1376
    public NomenclaturalReferenceDetailSection createNomenclaturalReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1377
        NomenclaturalReferenceDetailSection section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1378
        addAndAdaptSection(parentElement, section);
1379
        return section;
1380
    }
1381

    
1382
    public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1383
        TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1384
        addAndAdaptSection(parentElement, section);
1385
        return section;
1386
    }
1387

    
1388
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1389
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1390
        addAndAdaptSection(parentElement, section);
1391
        return section;
1392
    }
1393

    
1394
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1395
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1396
        addAndAdaptSection(parentElement, section);
1397
        return section;
1398
    }
1399

    
1400
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1401
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1402
        addAndAdaptSection(parentElement, section);
1403
        return section;
1404
    }
1405

    
1406
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1407
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1408
        addAndAdaptSection(parentElement, section);
1409
        return section;
1410
    }
1411

    
1412
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1413
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1414
        addAndAdaptSection(parentElement, section);
1415
        return section;
1416
    }
1417

    
1418
    public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1419
        DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1420
        addAndAdaptSection(parentElement, section);
1421
        return section;
1422
    }
1423

    
1424
    public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1425
        ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1426
        addAndAdaptSection(parentElement, section);
1427
        return section;
1428
    }
1429

    
1430
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1431
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, style);
1432
        addAndAdaptSection(parentElement, section);
1433
        return section;
1434
    }
1435

    
1436
    public MediaDetailsSection createMediaDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1437
        MediaDetailsSection section = new MediaDetailsSection(this, conversation, parentElement, selectionProvider, style);
1438
        addAndAdaptSection(parentElement, section);
1439
        return section;
1440
    }
1441

    
1442
    public DerivedUnitFacadeDetailSection createDerivedUnitFacadeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1443
        DerivedUnitFacadeDetailSection section = new DerivedUnitFacadeDetailSection(this, conversation, parentElement, selectionProvider, style);
1444
        addAndAdaptSection(parentElement, section);
1445
        return section;
1446
    }
1447

    
1448
    public FieldObservationDetailSection createFieldObservationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1449
        FieldObservationDetailSection section = new FieldObservationDetailSection(this, conversation, parentElement, selectionProvider, style);
1450
        addAndAdaptSection(parentElement, section);
1451
        return section;
1452
    }
1453

    
1454
    public GatheringEventDetailSection createGatheringEventDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1455
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1456
        addAndAdaptSection(parentElement, section);
1457
        return section;
1458
    }
1459

    
1460
    public DerivedUnitBaseDetailSection createDerivedUnitBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1461
        DerivedUnitBaseDetailSection section = new DerivedUnitBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1462
        addAndAdaptSection(parentElement, section);
1463
        return section;
1464
    }
1465

    
1466
    public NaturalLanguageSection createNaturalLanguageSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1467
        NaturalLanguageSection section = new NaturalLanguageSection(this, conversation, parentElement, selectionProvider, style);
1468
        addAndAdaptSection(parentElement, section);
1469
        return section;
1470
    }
1471

    
1472
    public FeatureDistributionDetailSection createFeatureDistributionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1473
        FeatureDistributionDetailSection section = new FeatureDistributionDetailSection(this, conversation, parentElement, selectionProvider, style);
1474
        addAndAdaptSection(parentElement, section);
1475
        return section;
1476
    }
1477

    
1478
    public ClassificationDetailSection createClassificationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1479
        ClassificationDetailSection section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style);
1480
        addAndAdaptSection(parentElement, section);
1481
        return section;
1482
    }
1483

    
1484
    public TaxonNodeDetailSection createTaxonNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1485
        TaxonNodeDetailSection section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1486
        addAndAdaptSection(parentElement, section);
1487
        return section;
1488
    }
1489

    
1490
    public PolytomousKeyDetailSection createPolytomousKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1491
        PolytomousKeyDetailSection section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
1492
        addAndAdaptSection(parentElement, section);
1493
        return section;
1494
    }
1495

    
1496
    public PolytomousKeyNodeDetailSection createPolytomousKeyNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1497
        PolytomousKeyNodeDetailSection section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1498
        addAndAdaptSection(parentElement, section);
1499
        return section;
1500
    }
1501

    
1502
    public InstitutionDetailSection createInstitutionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1503
        InstitutionDetailSection section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
1504
        addAndAdaptSection(parentElement, section);
1505
        return section;
1506
    }
1507

    
1508
    public GeneralDetailSection createGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1509
        GeneralDetailSection section = new GeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1510
        addAndAdaptSection(parentElement, section);
1511
        return section;
1512
    }
1513

    
1514
    public HybridDetailSection createHybridDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1515
        HybridDetailSection section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
1516
        addAndAdaptSection(parentElement, section);
1517
        return section;
1518
    }
1519

    
1520
    public UserDetailSection createUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1521
        UserDetailSection section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
1522
        addAndAdaptSection(parentElement, section);
1523
        return section;
1524
    }
1525

    
1526
    public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1527
        GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
1528
        addAndAdaptSection(parentElement, section);
1529
        return section;
1530
    }
1531

    
1532
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1533
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1534
        addAndAdaptSection(parentElement, section);
1535
        return section;
1536
    }
1537

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

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

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

    
1556

    
1557
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1558
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
1559
        addAndAdaptSection(parentElement, section);
1560
        return section;
1561
    }
1562

    
1563
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1564
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
1565
        addAndAdaptSection(parentElement, section);
1566
        return section;
1567
    }
1568

    
1569
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1570
        parentElement.addElement(section);
1571
        adapt(section);
1572
    }
1573

    
1574
    //--------DetailElements------------
1575

    
1576
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1577
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1578
        addAndAdaptElement(parentElement, element);
1579
        return element;
1580
    }
1581

    
1582
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1583
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1584
        addAndAdaptElement(parentElement, element);
1585
        return element;
1586
    }
1587

    
1588
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1589
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1590
        addAndAdaptElement(parentElement, element);
1591
        return element;
1592
    }
1593

    
1594
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1595
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1596
        addAndAdaptElement(parentElement, element);
1597
        return element;
1598
    }
1599

    
1600
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1601
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1602
        addAndAdaptElement(parentElement, element);
1603
        return element;
1604
    }
1605

    
1606
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1607
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1608
        addAndAdaptElement(parentElement, element);
1609
        return element;
1610
    }
1611

    
1612
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1613
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
1614
        addAndAdaptElement(parentElement, element);
1615
        return element;
1616
    }
1617

    
1618
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
1619
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
1620
        addAndAdaptElement(parentElement, element);
1621
        return element;
1622
    }
1623

    
1624
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
1625
        UserDetailElement element = new UserDetailElement(this, parentElement);
1626
        addAndAdaptElement(parentElement, element);
1627
        return element;
1628
    }
1629

    
1630
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
1631
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
1632
        addAndAdaptElement(parentElement, element);
1633
        return element;
1634
    }
1635

    
1636
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
1637
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
1638
        addAndAdaptElement(parentElement, element);
1639
        return element;
1640
    }
1641

    
1642
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
1643
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
1644
        addAndAdaptElement(parentElement, element);
1645
        return element;
1646
    }
1647

    
1648
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
1649
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
1650
        addAndAdaptElement(parentElement, element);
1651
        return element;
1652
    }
1653

    
1654
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
1655
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
1656
        addAndAdaptElement(parentElement, element);
1657
        return element;
1658
    }
1659

    
1660
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement){
1661
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement);
1662
        addAndAdaptElement(parentElement, element);
1663
        return element;
1664
    }
1665

    
1666
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
1667
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
1668
        addAndAdaptElement(parentElement, element);
1669
        return element;
1670
    }
1671

    
1672
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
1673
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
1674
        addAndAdaptElement(parentElement, element);
1675
        return element;
1676
    }
1677

    
1678
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
1679
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
1680
        addAndAdaptElement(parentElement, element);
1681
        return element;
1682
    }
1683

    
1684
    public DerivedUnitFacadeDetailElement createDerivedUnitFacadeDetailElement(ICdmFormElement parentElement){
1685
        DerivedUnitFacadeDetailElement element = new DerivedUnitFacadeDetailElement(this, parentElement);
1686
        addAndAdaptElement(parentElement, element);
1687
        return element;
1688
    }
1689

    
1690
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
1691
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
1692
        addAndAdaptElement(parentElement, element);
1693
        return element;
1694
    }
1695

    
1696
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
1697
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
1698
        addAndAdaptElement(parentElement, element);
1699
        return element;
1700
    }
1701

    
1702
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
1703
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
1704
        addAndAdaptElement(parentElement, element);
1705
        return element;
1706
    }
1707

    
1708
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
1709
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
1710
        addAndAdaptElement(parentElement, element);
1711
        return element;
1712
    }
1713

    
1714
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style){
1715
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style);
1716
        addAndAdaptElement(parentElement, element);
1717
        return element;
1718
    }
1719

    
1720
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
1721
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
1722
        addAndAdaptElement(parentElement, element);
1723
        return element;
1724
    }
1725

    
1726
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
1727
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
1728
        addAndAdaptElement(parentElement, element);
1729
        return element;
1730
    }
1731

    
1732
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
1733
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
1734
        addAndAdaptElement(parentElement, element);
1735
        return element;
1736
    }
1737

    
1738
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
1739
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
1740
        addAndAdaptElement(parentElement, element);
1741
        return element;
1742
    }
1743

    
1744
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
1745
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
1746
        addAndAdaptElement(parentElement, element);
1747
        return element;
1748
    }
1749

    
1750

    
1751
    public GeneralDetailElement createGeneralDetailElement(ICdmFormElement parentElement){
1752
        GeneralDetailElement element = new GeneralDetailElement(this, parentElement);
1753
        addAndAdaptElement(parentElement, element);
1754
        return element;
1755
    }
1756

    
1757
    public FieldObservationGeneralElementController createFieldObservationGeneralElement(ICdmFormElement parentElement){
1758
        FieldObservationGeneralElement fieldObservationGeneralElement = new FieldObservationGeneralElement(parentElement.getLayoutComposite(), SWT.NONE);
1759
        fieldObservationGeneralElement.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2,1));
1760
        FieldObservationGeneralElementController element = new FieldObservationGeneralElementController(fieldObservationGeneralElement, this, parentElement);
1761
        addAndAdaptElement(parentElement, element);
1762
        return element;
1763
    }
1764

    
1765
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
1766
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
1767
        addAndAdaptElement(parentElement, element);
1768
        return element;
1769
    }
1770

    
1771
    public GatheringEventDetailsElementController createGatheringEventDetailsElementController(ICdmFormElement parentElement) {
1772
        GatheringEventDetailsElement gatheringEventDetailsElement = new GatheringEventDetailsElement(parentElement.getLayoutComposite(), SWT.NONE);
1773
        gatheringEventDetailsElement.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2,1));
1774
        GatheringEventDetailsElementController element = new GatheringEventDetailsElementController(gatheringEventDetailsElement, this, parentElement);
1775
        adapt(element);
1776
        parentElement.addElement(element);
1777
        return element;
1778
    }
1779

    
1780
    public FieldObservationDetailElement createFieldObservationDetailElement(ICdmFormElement parentElement) {
1781
        FieldObservationDetailElement element = new FieldObservationDetailElement(this, parentElement);
1782
        addAndAdaptElement(parentElement, element);
1783
        return element;
1784
    }
1785

    
1786
    public FieldObservationDetailsElementController createFieldObservationDetailsElementController(ICdmFormElement parentElement) {
1787
        FieldObservationDetailsElement fieldObservationDetailsElement = new FieldObservationDetailsElement(parentElement.getLayoutComposite(), SWT.NONE);
1788
        fieldObservationDetailsElement.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2,1));
1789
        FieldObservationDetailsElementController element = new FieldObservationDetailsElementController(fieldObservationDetailsElement, this, parentElement);
1790
        addAndAdaptElement(parentElement, element);
1791
        return element;
1792
    }
1793

    
1794
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
1795
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
1796
        addAndAdaptElement(parentElement, element);
1797
        return element;
1798
    }
1799

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

    
1806
    /**
1807
     * @param parentElement
1808
     * @param element
1809
     */
1810
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
1811
        adapt(element);
1812
        parentElement.addElement(element);
1813
    }
1814

    
1815
    //--------EntityCollectionSection----------
1816
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1817
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style);
1818
        addAndAdaptSection(parentElement, section);
1819
        return section;
1820
    }
1821

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1924
    public TypeDesignationSection createTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1925
        TypeDesignationSection section = new TypeDesignationSection(this, conversation, parentElement, style);
1926
        addAndAdaptSection(parentElement, section);
1927
        return section;
1928
    }
1929

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

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

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

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

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

    
1960
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1961
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
1962
        addAndAdaptSection(parentElement, section);
1963
        return section;
1964
    }
1965

    
1966
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1967
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
1968
        addAndAdaptSection(parentElement, section);
1969
        return section;
1970
    }
1971

    
1972
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1973
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
1974
        addAndAdaptSection(parentElement, section);
1975
        return section;
1976
    }
1977

    
1978
    public GeographicalScopeDetailSection createGeographicalScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1979
        GeographicalScopeDetailSection section = new GeographicalScopeDetailSection(this, conversation, parentElement, style);
1980
        addAndAdaptSection(parentElement, section);
1981
        return section;
1982
    }
1983

    
1984
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1985
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
1986
        addAndAdaptSection(parentElement, section);
1987
        return section;
1988
    }
1989

    
1990
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1991
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
1992
        addAndAdaptSection(parentElement, section);
1993
        return section;
1994
    }
1995

    
1996
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1997
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
1998
        addAndAdaptSection(parentElement, section);
1999
        return section;
2000
    }
2001

    
2002
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2003
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2004
        addAndAdaptSection(parentElement, section);
2005
        return section;
2006
    }
2007

    
2008
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2009
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2010
        addAndAdaptSection(parentElement, section);
2011
        return section;
2012
    }
2013

    
2014
    /**
2015
     * <p>
2016
     * createEntityCollectionElement
2017
     * </p>
2018
     *
2019
     * @param removeListener
2020
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
2021
     * @param style
2022
     *            a int.
2023
     * @param parentElement
2024
     *            a
2025
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
2026
     *            object.
2027
     * @param versionableEntity
2028
     *            a {@link eu.etaxonomy.cdm.model.common.IVersionableEntity}
2029
     *            object.
2030
     * @param backgroundColor
2031
     *            a {@link org.eclipse.swt.graphics.Color} object.
2032
     * @return a
2033
     *         {@link eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement}
2034
     *         object.
2035
     */
2036
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2037
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2038
        AbstractEntityCollectionElement element = null;
2039

    
2040
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2041

    
2042
        if (entity instanceof Annotation) {
2043
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2044
        } else if (entity instanceof Person) {
2045
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
2046
        } else if (entity instanceof Credit) {
2047
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2048
        } else if (entity instanceof Extension) {
2049
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2050
        } else if (entity instanceof Marker) {
2051
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2052
        } else if (entity instanceof Media) {
2053
            element = new MediaElement(this, parentElement, (Media) entity, removeListener, style);
2054
        } else if (entity instanceof MediaRepresentation) {
2055
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2056
                    style);
2057
        } else if (entity instanceof ImageFile) {
2058
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2059
        } else if (entity instanceof MediaRepresentationPart) {
2060
            element = new MediaRepresentationPartElement(this, parentElement, (MediaRepresentationPart) entity,
2061
                    removeListener, style);
2062
        } else if (entity instanceof NomenclaturalStatus) {
2063
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2064
                    style);
2065
        } else if (entity instanceof Rights) {
2066
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2067
        } else if (entity instanceof DescriptionElementSource) {
2068
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2069
                    removeListener, style);
2070
        } else if (entity instanceof IdentifiableSource) {
2071
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2072
                    style);
2073
        } else if (entity instanceof Scope) {
2074
            element = new ScopeElement(this, parentElement, (Scope) entity, removeListener, style);
2075
        } else if (entity instanceof Modifier) {
2076
            element = new ModifierElement(this, parentElement, (Modifier) entity, removeListener, style);
2077
        } else if (entity instanceof Reference) {
2078
            element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2079
        } else if (entity instanceof NameTypeDesignation) {
2080
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2081
                    style);
2082
        } else if (entity instanceof NameRelationship) {
2083
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2084
                    style);
2085
        } else if (entity instanceof SpecimenTypeDesignation) {
2086
            element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2087
                    removeListener, style);
2088
        } else if (entity instanceof StateData) {
2089
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2090
        } else if (entity instanceof StatisticalMeasurementValue) {
2091
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2092
                    removeListener, style);
2093
        } else if (entity instanceof DerivedUnit) {
2094
            element = new DerivedUnitElement(this, parentElement, (DerivedUnit) entity, removeListener, style);
2095
        } else if (entity instanceof NamedArea) {
2096
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2097
        } else if (entity instanceof DeterminationEvent) {
2098
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2099
        } else if (entity instanceof Specimen) {
2100
            element = new SpecimenCollectionDetailElement(this, parentElement, (Specimen) entity, removeListener, style);
2101
        } else if (entity instanceof User) {
2102
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2103
        } else if (entity instanceof GrantedAuthority) {
2104
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity,
2105
                    removeListener, style);
2106
        } else if (entity instanceof Group) {
2107
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2108
        } else if (entity instanceof Taxon) {
2109
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2110
        } else if (entity instanceof DescriptionElementBase) {
2111
            // this is the special case for protologs, maybe we can do this
2112
            // differently when API improves
2113
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2114
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2115
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2116
            }
2117
        }
2118

    
2119
        if (element == null) {
2120
            AbstractUtility.errorDialog("No element for entity", this,
2121
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2122
                            + entity, null);
2123
        }
2124

    
2125
        else if (backgroundColor != null && !backgroundColor.isDisposed()) {
2126
            element.setPersistentBackground(backgroundColor);
2127
            adapt(element);
2128
            parentElement.addElement(element);
2129
        }
2130

    
2131
        return element;
2132
    }
2133

    
2134
    /**
2135
     * <p>
2136
     * Creates a selection element for the given type T.
2137
     * </p>
2138
     * <p>
2139
     * <strong>Selection elements not handled by this method:</strong>
2140
     * <ul>
2141
     * <li>{@link TaxonNodeSelectionElement} see
2142
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2143
     * </li>
2144
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2145
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2146
     * </li>
2147
     * </ul>
2148
     * </p>
2149
     *
2150
     * @param clazz
2151
     *            a {@link Class} object of the type that you want the selection
2152
     *            element to handle
2153
     * @param parentElement
2154
     *            a {@link ICdmFormElement} object.
2155
     * @param labelString
2156
     *            a {@link String} object.
2157
     * @param selectionType
2158
     * @param selection
2159
     *            a {@link ICdmBase} object.
2160
     * @param style
2161
     *            a int.
2162
     * @param conversation
2163
     *            a {@link ConversationHolder} object.
2164
     * @return a {@link EntitySelectionElement} object.
2165
     */
2166
    public <T extends ICdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2167
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2168
            int style) {
2169
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2170
                labelString, selection, mode, style);
2171
        adapt(element);
2172
        parentElement.addElement(element);
2173
        return element;
2174
    }
2175

    
2176
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2177
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2178
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2179
                labelString, selection, mode, style);
2180
        adapt(element);
2181
        parentElement.addElement(element);
2182
        return element;
2183
    }
2184

    
2185
    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2186
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2187
            int mode, int style) {
2188
        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2189
                conversation, parentElement, labelString, selection, mode, style);
2190
        adapt(element);
2191
        parentElement.addElement(element);
2192
        return element;
2193
    }
2194

    
2195
    /** {@inheritDoc} */
2196
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2197
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2198
        adapt(labelElement);
2199
        parentElement.addElement(labelElement);
2200
        return labelElement;
2201
    }
2202

    
2203
    /**
2204
     * <p>
2205
     * Getter for the field <code>selectionProvider</code>.
2206
     * </p>
2207
     *
2208
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2209
     */
2210
    public ISelectionProvider getSelectionProvider() {
2211
        return selectionProvider;
2212
    }
2213

    
2214
    /**
2215
     * <p>
2216
     * createDetailedDescriptionDetailElement
2217
     * </p>
2218
     *
2219
     * @param parentElement
2220
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2221
     *            object.
2222
     * @param entity
2223
     *            a
2224
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2225
     *            object.
2226
     * @param style
2227
     *            a int.
2228
     * @return a
2229
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2230
     *         object.
2231
     */
2232
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2233
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2234
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2235

    
2236
        if (entity instanceof CategoricalData) {
2237
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2238
                    (CategoricalData) entity, style);
2239
        } else if (entity instanceof CommonTaxonName) {
2240
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2241
                    style);
2242
        } else if (entity instanceof Distribution) {
2243
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2244
                    style);
2245
        } else if (entity instanceof IndividualsAssociation) {
2246
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2247
                    (IndividualsAssociation) entity, style);
2248
        } else if (entity instanceof QuantitativeData) {
2249
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2250
                    (QuantitativeData) entity, style);
2251
        } else if (entity instanceof TaxonInteraction) {
2252
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2253
                    (TaxonInteraction) entity, style);
2254
        } else if (entity instanceof TextData) {
2255
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2256
        } else {
2257
            throw new IllegalStateException("There is no interface for the given description element");
2258
        }
2259
        adapt(detailedDescriptionElement);
2260
        parentElement.addElement(detailedDescriptionElement);
2261
        return detailedDescriptionElement;
2262

    
2263
    }
2264

    
2265
    /**
2266
     * Creates a styled text as a part of the form.
2267
     *
2268
     * @param parent
2269
     *            the text parent
2270
     * @param value
2271
     *            the text initial value
2272
     * @param style
2273
     *            the text style
2274
     * @return the text widget
2275
     */
2276
    public StyledText createStyledText(Composite parent, String value, int style) {
2277
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2278
        if (value != null) {
2279
            text.setText(value);
2280
        }
2281
        text.setForeground(getColors().getForeground());
2282
        text.setBackground(getColors().getBackground());
2283
        // text.addFocusListener(visibilityHandler);
2284
        return text;
2285
    }
2286

    
2287
}
(6-6/35)