Project

General

Profile

Download (100 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.combo.EnumComboElement;
99
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
100
import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
101
import eu.etaxonomy.taxeditor.ui.openurl.OpenUrlSelectorElement;
102
import eu.etaxonomy.taxeditor.ui.password.EditPasswordElement;
103
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
104
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
105
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
106
import eu.etaxonomy.taxeditor.ui.section.EmptyElement;
107
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement;
108
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection;
109
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailElement;
110
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
111
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailElement;
112
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
113
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
114
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberSection;
115
import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
116
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailElement;
117
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailSection;
118
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailElement;
119
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailSection;
120
import eu.etaxonomy.taxeditor.ui.section.common.ReferenceEntityDetailElement;
121
import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
122
import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
123
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
124
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailElement;
125
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
126
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
127
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
128
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
129
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceElement;
130
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
131
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceElement;
132
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
133
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
134
import eu.etaxonomy.taxeditor.ui.section.description.ModifierElement;
135
import eu.etaxonomy.taxeditor.ui.section.description.ModifierSection;
136
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageDetailElement;
137
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
138
import eu.etaxonomy.taxeditor.ui.section.description.ScopeElement;
139
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
140
import eu.etaxonomy.taxeditor.ui.section.description.StateDataElement;
141
import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;
142
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueElement;
143
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueSection;
144
import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;
145
import eu.etaxonomy.taxeditor.ui.section.description.detail.CategoricalDataDetailElement;
146
import eu.etaxonomy.taxeditor.ui.section.description.detail.CommonNameDetailElement;
147
import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
148
import eu.etaxonomy.taxeditor.ui.section.description.detail.IndividualsAssociationDetailElement;
149
import eu.etaxonomy.taxeditor.ui.section.description.detail.QuantitativeDataDetailElement;
150
import eu.etaxonomy.taxeditor.ui.section.description.detail.TaxonInteractionDetailElement;
151
import eu.etaxonomy.taxeditor.ui.section.description.detail.TextDataDetailElement;
152
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement;
153
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
154
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityCollectionElement;
155
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailElement;
156
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
157
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailElement;
158
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
159
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailElement;
160
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
161
import eu.etaxonomy.taxeditor.ui.section.key.GeographicalScopeDetailSection;
162
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailElement;
163
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
164
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailElement;
165
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
166
import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
167
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
168
import eu.etaxonomy.taxeditor.ui.section.media.ImageFileElement;
169
import eu.etaxonomy.taxeditor.ui.section.media.MediaElement;
170
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationElement;
171
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartElement;
172
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartSection;
173
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationSection;
174
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
175
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
176
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailSection;
177
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailElement;
178
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailSection;
179
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailElement;
180
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailSection;
181
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailElement;
182
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
183
import eu.etaxonomy.taxeditor.ui.section.name.NameTypeDesignationElement;
184
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusElement;
185
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
186
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailElement;
187
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
188
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueElement;
189
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
190
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
191
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
192
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
193
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
194
import eu.etaxonomy.taxeditor.ui.section.occurrence.CurrentDeterminationDetailSection;
195
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailElement;
196
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
197
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitFacadeDetailElement;
198
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitFacadeDetailSection;
199
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement;
200
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
201
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement;
202
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection;
203
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationDetailElement;
204
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationDetailSection;
205
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailElement;
206
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
207
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeneralDetailElement;
208
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeneralDetailSection;
209
import eu.etaxonomy.taxeditor.ui.section.occurrence.NamedAreaDetailElement;
210
import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
211
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElement;
212
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailSection;
213
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
214
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
215
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement;
216
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
217
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationElement;
218
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
219
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseElement;
220
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
221
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditElement;
222
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
223
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionElement;
224
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
225
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
226
import eu.etaxonomy.taxeditor.ui.section.supplemental.IdentifiableSourceElement;
227
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerElement;
228
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
229
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsElement;
230
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
231
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
232
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement;
233
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
234
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement;
235
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
236
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailElement;
237
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
238
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailElement;
239
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailElement;
240
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
241
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailElement;
242
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
243
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailElement;
244
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
245
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailElement;
246
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
247
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement;
248
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailSection;
249
import eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailSection;
250
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailElement;
251
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
252
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
253
import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
254
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
255

    
256
/**
257
 * <p>
258
 * CdmFormFactory class.
259
 * </p>
260
 *
261
 * @author n.hoffmann
262
 * @created Feb 24, 2010
263
 * @version 1.0
264
 */
265
public class CdmFormFactory extends FormToolkit {
266

    
267
    private BoldFontHolder2 boldFontHolder2;
268
    private MouseListener selectionMouseHandler;
269
    private FocusListener selectionFocusHandler;
270

    
271
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
272

    
273
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
274

    
275
    private final int orientation = Window.getDefaultOrientation();
276
    private ISelectionProvider selectionProvider;
277

    
278
    /** Constant <code>EMPTY_SELECTION</code> */
279
    public static ISelection EMPTY_SELECTION = new ISelection() {
280
        @Override
281
        public boolean isEmpty() {
282
            return true;
283
        }
284
    };
285

    
286
    /**
287
     *
288
     * @author n.hoffmann
289
     * @date Jan 25, 2010
290
     *
291
     */
292
    private class SelectionMouseHandler extends MouseAdapter {
293
        @Override
294
        public void mouseDown(MouseEvent e) {
295
            notifySelectionListeners(e);
296
        }
297
    }
298

    
299
    /**
300
     *
301
     * @author n.hoffmann
302
     * @date Jan 25, 2010
303
     *
304
     */
305
    private class SelectionFocusHandler extends FocusAdapter {
306
        @Override
307
        public void focusGained(FocusEvent e) {
308
            notifySelectionListeners(e);
309
        }
310
    }
311

    
312
    private void notifySelectionListeners(TypedEvent e) {
313
        Event event = new Event();
314
        event.widget = e.widget;
315
        SelectionEvent selectionEvent = new SelectionEvent(event);
316

    
317
        for (SelectionListener listener : selectionListenerList) {
318
            listener.widgetSelected(selectionEvent);
319
        }
320
    }
321

    
322
    /**
323
     * <p>
324
     * Constructor for CdmFormFactory.
325
     * </p>
326
     *
327
     * @param display
328
     *            a {@link org.eclipse.swt.widgets.Display} object.
329
     * @param selectionProvider
330
     *            a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
331
     */
332
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
333
        super(display);
334
        this.selectionProvider = selectionProvider;
335
        init();
336
    }
337

    
338
    /**
339
     * <p>
340
     * Constructor for CdmFormFactory.
341
     * </p>
342
     *
343
     * @param display
344
     *            a {@link org.eclipse.swt.widgets.Display} object.
345
     */
346
    public CdmFormFactory(Display display) {
347
        super(display);
348
        init();
349
    }
350

    
351
    /**
352
	 *
353
	 */
354
    private void init() {
355
        boldFontHolder2 = new BoldFontHolder2();
356
        selectionMouseHandler = new SelectionMouseHandler();
357
        selectionFocusHandler = new SelectionFocusHandler();
358
    }
359

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

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

    
400
    /** {@inheritDoc} */
401
    @Override
402
    public void adapt(Composite composite) {
403
        composite.addMouseListener(selectionMouseHandler);
404
        super.adapt(composite);
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
    /**
432
     * <p>
433
     * destroyElement
434
     * </p>
435
     *
436
     * @param formElement
437
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
438
     *            object.
439
     */
440
    public void destroyElement(ICdmFormElement formElement) {
441
        // return if element was not initialized
442
        if (formElement == null) {
443
            return;
444
        }
445
        // destroy selection arbitrator, if any
446
        if (formElement instanceof ISelectableElement) {
447
            destroySelectionArbitrator(((ISelectableElement) formElement).getSelectionArbitrator());
448
        }
449
        // remove this element form its parents list of elements
450
        // ICdmFormElement parentElement = formElement.getParentElement();
451
        // if(parentElement != null){
452
        // parentElement.removeElement(formElement);
453
        // }
454
        // call destroy on child elements recursively
455
        for (ICdmFormElement childElement : formElement.getElements()) {
456
            destroyElement(childElement);
457
        }
458
        // dispose of the controls
459
        for (Control control : formElement.getControls()) {
460
            // we added the layoutComposite of the parental element as the
461
            // layout composite to this formElement
462
            // but we do not want to destroy it.
463
            if (control.equals(formElement.getLayoutComposite())) {
464
                continue;
465
            } else {
466
                control.dispose();
467
                control = null;
468
            }
469
        }
470
    }
471

    
472
    /**
473
     * <p>
474
     * createEmptyCell
475
     * </p>
476
     *
477
     * @param parent
478
     *            a {@link org.eclipse.swt.widgets.Composite} object.
479
     * @return a {@link org.eclipse.swt.widgets.Label} object.
480
     */
481
    public Label createEmptyCell(Composite parent) {
482
        return this.createLabel(parent, null);
483
    }
484

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

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

    
539
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
540
            KeyStatement keyStatement, int textHeight, int style) {
541
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
542
                textHeight, style);
543
        adapt(element);
544
        parentElement.addElement(element);
545
        return element;
546
    }
547

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

    
574
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
575
            URI initialUri, int style) {
576
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
577
        adapt(element);
578
        parentElement.addElement(element);
579
        return element;
580
    }
581

    
582
    /**
583
     * @param element
584
     * @param string
585
     * @param uri
586
     * @param style
587
     * @return
588
     */
589
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
590
            IOpenUrlEnabled openUrlEnabled, int style) {
591
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
592
                style);
593
        adapt(element);
594
        parentElement.addElement(element);
595
        return element;
596
    }
597

    
598
    /**
599
     *
600
     * @param parentElement
601
     * @param labelString
602
     * @param conversationEnabled
603
     * @param user
604
     * @param style
605
     * @return
606
     */
607
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
608
            ConversationHolder conversation, User user, int style) {
609
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
610
        adapt(element);
611
        parentElement.addElement(element);
612
        return element;
613
    }
614

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

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

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

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

    
725
    /**
726
     * <p>
727
     * createTextElement
728
     * </p>
729
     *
730
     * @param parentElement
731
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
732
     *            object.
733
     * @param initialText
734
     *            a {@link java.lang.String} object.
735
     * @param style
736
     *            a int.
737
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
738
     *         object.
739
     */
740
    public TextWithLabelElement createTextElement(ICdmFormElement parentElement, String initialText, int style) {
741
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, null, initialText, null, style);
742
        adapt(element);
743
        parentElement.addElement(element);
744
        return element;
745
    }
746

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

    
772
    /**
773
     * <p>
774
     * createTermComboElement
775
     * </p>
776
     *
777
     * @param termComboType
778
     *            a
779
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
780
     *            object.
781
     * @param parentElement
782
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
783
     *            object.
784
     * @param labelString
785
     *            a {@link java.lang.String} object.
786
     * @param selection
787
     *            a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
788
     *            object.
789
     * @param style
790
     *            a int.
791
     * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
792
     *         object.
793
     */
794

    
795
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
796
            ICdmFormElement parentElement, String labelString, T selection, int style) {
797
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString,
798
                selection, style);
799
        adapt(element);
800
        parentElement.addElement(element);
801
        return element;
802
    }
803

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

    
829
    /**
830
     * <p>
831
     * createBrowserElement
832
     * </p>
833
     *
834
     * @param imageUri
835
     *            a {@link java.net.URI} object.
836
     * @param style
837
     *            a int.
838
     * @param parentElement
839
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
840
     *            object.
841
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
842
     *         object.
843
     */
844
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
845
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
846
        adapt(element);
847
        parentElement.addElement(element);
848
        return element;
849
    }
850

    
851
    /**
852
     * <p>
853
     * createImageElement
854
     * </p>
855
     *
856
     * @param parentElement
857
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
858
     *            object.
859
     * @param imageUri
860
     *            a {@link java.net.URI} object.
861
     * @param style
862
     *            a int.
863
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
864
     */
865
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
866
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
867
        adapt(element);
868
        parentElement.addElement(element);
869
        return element;
870
    }
871

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

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

    
924
    /**
925
     * Creates a section as a part of the form.
926
     *
927
     * @return the section widget
928
     * @param section
929
     *            a
930
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
931
     *            object.
932
     */
933
    public Section adapt(AbstractFormSection section) {
934
        section.setMenu(section.getLayoutComposite().getMenu());
935
        adapt(section, true, true);
936

    
937
        // handle focus and property change events for cdm use
938
        section.addFocusListener(selectionFocusHandler);
939
        section.setPropertyChangeListeners(propertyChangeListeners);
940

    
941
        if (section.getToggle() != null) {
942
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
943
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
944
        }
945

    
946
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
947

    
948
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
949
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
950
            getColors().initializeSectionToolBarColors();
951
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
952
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
953
        }
954
        // call setTitleBarForeground regardless as it also sets the label color
955
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
956
        return section;
957
    }
958

    
959
    private class BoldFontHolder2 {
960
        private Font normalFont;
961

    
962
        private Font boldFont;
963

    
964
        public BoldFontHolder2() {
965
        }
966

    
967
        public Font getBoldFont(Font font) {
968
            createBoldFont(font);
969
            return boldFont;
970
        }
971

    
972
        private void createBoldFont(Font font) {
973
            if (normalFont == null || !normalFont.equals(font)) {
974
                normalFont = font;
975
                dispose();
976
            }
977
            if (boldFont == null) {
978
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
979
            }
980
        }
981

    
982
        public void dispose() {
983
            if (boldFont != null) {
984
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
985
                boldFont = null;
986
            }
987
        }
988
    }
989

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

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

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

    
1064
    /**
1065
     * <p>
1066
     * createDateDetailSection
1067
     * </p>
1068
     *
1069
     * @param parentElement
1070
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1071
     *            object.
1072
     * @param style
1073
     *            a int.
1074
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1075
     *         object.
1076
     */
1077
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1078
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1079
        parentElement.addElement(section);
1080
        adapt(section);
1081
        return section;
1082
    }
1083

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

    
1109
    /**
1110
     * <p>
1111
     * addSelectionListener
1112
     * </p>
1113
     *
1114
     * @param listener
1115
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1116
     */
1117
    public void addSelectionListener(SelectionListener listener) {
1118
        selectionListenerList.add(listener);
1119
    }
1120

    
1121
    /**
1122
     * <p>
1123
     * removeSelectionListener
1124
     * </p>
1125
     *
1126
     * @param listener
1127
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1128
     */
1129
    public void removeSelectionListener(SelectionListener listener) {
1130
        if (listener == null) {
1131
            AbstractUtility.error(this.getClass(),
1132
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1133
        } else {
1134
            selectionListenerList.remove(listener);
1135
        }
1136
    }
1137

    
1138
    /**
1139
     * <p>
1140
     * addPropertyChangeListener
1141
     * </p>
1142
     *
1143
     * @param listener
1144
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1145
     *            object.
1146
     */
1147
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1148
        if (propertyChangeListeners.contains(listener)) {
1149
            return;
1150
        }
1151
        propertyChangeListeners.add(0, listener);
1152
    }
1153

    
1154
    /**
1155
     * <p>
1156
     * removePropertyChangeListener
1157
     * </p>
1158
     *
1159
     * @param listener
1160
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1161
     *            object.
1162
     */
1163
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1164
        propertyChangeListeners.remove(listener);
1165
    }
1166

    
1167
    /**
1168
     * <p>
1169
     * createHorizontalSeparator
1170
     * </p>
1171
     *
1172
     * @param parentElement
1173
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1174
     *            object.
1175
     * @param style
1176
     *            a int.
1177
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1178
     */
1179
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1180
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1181
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1182
        return separator;
1183
    }
1184

    
1185
    /**
1186
     * <p>
1187
     * createVersionElement
1188
     * </p>
1189
     *
1190
     * @param parentElement
1191
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1192
     *            object.
1193
     * @param entity
1194
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1195
     *            object.
1196
     * @param style
1197
     *            a int.
1198
     * @return a
1199
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1200
     *         object.
1201
     */
1202
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1203
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1204
        adapt(element);
1205
        parentElement.addElement(element);
1206
        return element;
1207
    }
1208

    
1209
    /**
1210
     * @param cdmBaseSection
1211
     * @param object
1212
     * @param style
1213
     * @return
1214
     */
1215
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1216
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1217
        adapt(element);
1218
        parentElement.addElement(element);
1219
        return element;
1220
    }
1221

    
1222
    /**
1223
     * <p>
1224
     * createVersionSection
1225
     * </p>
1226
     *
1227
     * @param parentElement
1228
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1229
     *            object.
1230
     * @param style
1231
     *            a int.
1232
     * @return a
1233
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1234
     *         object.
1235
     */
1236
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1237
        VersionSection section = new VersionSection(this, parentElement, style);
1238
        parentElement.addElement(section);
1239
        adapt(section);
1240
        return section;
1241
    }
1242

    
1243
    /**
1244
     * @param parent
1245
     * @param i
1246
     * @return
1247
     */
1248
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1249
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1250
        parentElement.addElement(section);
1251
        adapt(section);
1252
        return section;
1253
    }
1254

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

    
1272
    /**
1273
     * <p>
1274
     * createHeadlineSection
1275
     * </p>
1276
     *
1277
     * @param parentElement
1278
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1279
     *            object.
1280
     * @return a
1281
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1282
     *         object.
1283
     */
1284
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1285
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1286
        parentElement.addElement(section);
1287
        adapt(section);
1288
        return section;
1289
    }
1290

    
1291
    /**
1292
     * <p>
1293
     * createParsingMessageElement
1294
     * </p>
1295
     *
1296
     * @param parentElement
1297
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1298
     *            object.
1299
     * @param parserProblem
1300
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1301
     *            object.
1302
     * @param style
1303
     *            a int.
1304
     * @return a
1305
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1306
     *         object.
1307
     */
1308
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1309
            ParserProblem parserProblem, int style) {
1310
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1311
        adapt(element);
1312
        parentElement.addElement(element);
1313
        return element;
1314
    }
1315

    
1316
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1317
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1318

    
1319
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1320
                selectionProvider, style);
1321

    
1322
        parentElement.addElement(section);
1323
        adapt(section);
1324
        return section;
1325

    
1326
    }
1327

    
1328
    /**
1329
     * @param definedTermClass
1330
     * @param formElement
1331
     * @param style
1332
     * @return
1333
     */
1334
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass, AbstractCdmDetailSection parentElement, int style) {
1335
        AbstractCdmDetailElement element = null;
1336

    
1337
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1338
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1339
        } else {
1340
            element = new DefinedTermDetailElement(this, parentElement);
1341
        }
1342

    
1343
        adapt(element);
1344
        parentElement.addElement(element);
1345
        return element;
1346
    }
1347

    
1348

    
1349
    //--------DetailSections---------
1350
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1351
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1352
        addAndAdaptSection(parentElement, section);
1353
        return section;
1354
    }
1355

    
1356
    public ReferenceDetailSection createReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1357
        ReferenceDetailSection section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1358
        addAndAdaptSection(parentElement, section);
1359
        return section;
1360
    }
1361

    
1362
    public NomenclaturalReferenceDetailSection createNomenclaturalReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1363
        NomenclaturalReferenceDetailSection section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1364
        addAndAdaptSection(parentElement, section);
1365
        return section;
1366
    }
1367

    
1368
    public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1369
        TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1370
        addAndAdaptSection(parentElement, section);
1371
        return section;
1372
    }
1373

    
1374
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1375
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1376
        addAndAdaptSection(parentElement, section);
1377
        return section;
1378
    }
1379

    
1380
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1381
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1382
        addAndAdaptSection(parentElement, section);
1383
        return section;
1384
    }
1385

    
1386
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1387
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1388
        addAndAdaptSection(parentElement, section);
1389
        return section;
1390
    }
1391

    
1392
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1393
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1394
        addAndAdaptSection(parentElement, section);
1395
        return section;
1396
    }
1397

    
1398
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1399
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1400
        addAndAdaptSection(parentElement, section);
1401
        return section;
1402
    }
1403

    
1404
    public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1405
        DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1406
        addAndAdaptSection(parentElement, section);
1407
        return section;
1408
    }
1409

    
1410
    public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1411
        ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1412
        addAndAdaptSection(parentElement, section);
1413
        return section;
1414
    }
1415

    
1416
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1417
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, style);
1418
        addAndAdaptSection(parentElement, section);
1419
        return section;
1420
    }
1421

    
1422
    public MediaDetailsSection createMediaDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1423
        MediaDetailsSection section = new MediaDetailsSection(this, conversation, parentElement, selectionProvider, style);
1424
        addAndAdaptSection(parentElement, section);
1425
        return section;
1426
    }
1427

    
1428
    public DerivedUnitFacadeDetailSection createDerivedUnitFacadeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1429
        DerivedUnitFacadeDetailSection section = new DerivedUnitFacadeDetailSection(this, conversation, parentElement, selectionProvider, style);
1430
        addAndAdaptSection(parentElement, section);
1431
        return section;
1432
    }
1433

    
1434
    public FieldObservationDetailSection createFieldObservationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1435
        FieldObservationDetailSection section = new FieldObservationDetailSection(this, conversation, parentElement, selectionProvider, style);
1436
        addAndAdaptSection(parentElement, section);
1437
        return section;
1438
    }
1439

    
1440
    public GatheringEventDetailSection createGatheringEventDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1441
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1442
        addAndAdaptSection(parentElement, section);
1443
        return section;
1444
    }
1445

    
1446
    public DerivedUnitBaseDetailSection createDerivedUnitBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1447
        DerivedUnitBaseDetailSection section = new DerivedUnitBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1448
        addAndAdaptSection(parentElement, section);
1449
        return section;
1450
    }
1451

    
1452
    public NaturalLanguageSection createNaturalLanguageSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1453
        NaturalLanguageSection section = new NaturalLanguageSection(this, conversation, parentElement, selectionProvider, style);
1454
        addAndAdaptSection(parentElement, section);
1455
        return section;
1456
    }
1457

    
1458
    public FeatureDistributionDetailSection createFeatureDistributionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1459
        FeatureDistributionDetailSection section = new FeatureDistributionDetailSection(this, conversation, parentElement, selectionProvider, style);
1460
        addAndAdaptSection(parentElement, section);
1461
        return section;
1462
    }
1463

    
1464
    public ClassificationDetailSection createClassificationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1465
        ClassificationDetailSection section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style);
1466
        addAndAdaptSection(parentElement, section);
1467
        return section;
1468
    }
1469

    
1470
    public TaxonNodeDetailSection createTaxonNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1471
        TaxonNodeDetailSection section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1472
        addAndAdaptSection(parentElement, section);
1473
        return section;
1474
    }
1475

    
1476
    public PolytomousKeyDetailSection createPolytomousKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1477
        PolytomousKeyDetailSection section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
1478
        addAndAdaptSection(parentElement, section);
1479
        return section;
1480
    }
1481

    
1482
    public PolytomousKeyNodeDetailSection createPolytomousKeyNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1483
        PolytomousKeyNodeDetailSection section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1484
        addAndAdaptSection(parentElement, section);
1485
        return section;
1486
    }
1487

    
1488
    public InstitutionDetailSection createInstitutionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1489
        InstitutionDetailSection section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
1490
        addAndAdaptSection(parentElement, section);
1491
        return section;
1492
    }
1493

    
1494
    public GeneralDetailSection createGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1495
        GeneralDetailSection section = new GeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1496
        addAndAdaptSection(parentElement, section);
1497
        return section;
1498
    }
1499

    
1500
    public HybridDetailSection createHybridDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1501
        HybridDetailSection section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
1502
        addAndAdaptSection(parentElement, section);
1503
        return section;
1504
    }
1505

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

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

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

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

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

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

    
1542

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

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

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

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

    
1567
    public FieldObservationDetailSection createFODetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1568
        FieldObservationDetailSection section = new FieldObservationDetailSection(this, conversation, parentElement, selectionProvider, style);
1569
        addAndAdaptSection(parentElement, section);
1570
        return section;
1571
    }
1572

    
1573
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1574
        parentElement.addElement(section);
1575
        adapt(section);
1576
    }
1577

    
1578
    //--------DetailElements------------
1579

    
1580
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1581
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1582
        addAndAdaptElement(parentElement, element);
1583
        return element;
1584
    }
1585

    
1586
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1587
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1588
        addAndAdaptElement(parentElement, element);
1589
        return element;
1590
    }
1591

    
1592
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1593
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1594
        addAndAdaptElement(parentElement, element);
1595
        return element;
1596
    }
1597

    
1598
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1599
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1600
        addAndAdaptElement(parentElement, element);
1601
        return element;
1602
    }
1603

    
1604
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1605
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1606
        addAndAdaptElement(parentElement, element);
1607
        return element;
1608
    }
1609

    
1610
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1611
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1612
        addAndAdaptElement(parentElement, element);
1613
        return element;
1614
    }
1615

    
1616
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1617
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
1618
        addAndAdaptElement(parentElement, element);
1619
        return element;
1620
    }
1621

    
1622
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
1623
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
1624
        addAndAdaptElement(parentElement, element);
1625
        return element;
1626
    }
1627

    
1628
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
1629
        UserDetailElement element = new UserDetailElement(this, parentElement);
1630
        addAndAdaptElement(parentElement, element);
1631
        return element;
1632
    }
1633

    
1634
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
1635
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
1636
        addAndAdaptElement(parentElement, element);
1637
        return element;
1638
    }
1639

    
1640
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
1641
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
1642
        addAndAdaptElement(parentElement, element);
1643
        return element;
1644
    }
1645

    
1646
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
1647
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
1648
        addAndAdaptElement(parentElement, element);
1649
        return element;
1650
    }
1651

    
1652
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
1653
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
1654
        addAndAdaptElement(parentElement, element);
1655
        return element;
1656
    }
1657

    
1658
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
1659
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
1660
        addAndAdaptElement(parentElement, element);
1661
        return element;
1662
    }
1663

    
1664
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement){
1665
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement);
1666
        addAndAdaptElement(parentElement, element);
1667
        return element;
1668
    }
1669

    
1670
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
1671
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
1672
        addAndAdaptElement(parentElement, element);
1673
        return element;
1674
    }
1675

    
1676
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
1677
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
1678
        addAndAdaptElement(parentElement, element);
1679
        return element;
1680
    }
1681

    
1682
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
1683
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
1684
        addAndAdaptElement(parentElement, element);
1685
        return element;
1686
    }
1687

    
1688
    public DerivedUnitFacadeDetailElement createDerivedUnitFacadeDetailElement(ICdmFormElement parentElement){
1689
        DerivedUnitFacadeDetailElement element = new DerivedUnitFacadeDetailElement(this, parentElement);
1690
        addAndAdaptElement(parentElement, element);
1691
        return element;
1692
    }
1693

    
1694
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
1695
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
1696
        addAndAdaptElement(parentElement, element);
1697
        return element;
1698
    }
1699

    
1700
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
1701
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
1702
        addAndAdaptElement(parentElement, element);
1703
        return element;
1704
    }
1705

    
1706
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
1707
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
1708
        addAndAdaptElement(parentElement, element);
1709
        return element;
1710
    }
1711

    
1712
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
1713
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
1714
        addAndAdaptElement(parentElement, element);
1715
        return element;
1716
    }
1717

    
1718
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style){
1719
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style);
1720
        addAndAdaptElement(parentElement, element);
1721
        return element;
1722
    }
1723

    
1724
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
1725
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
1726
        addAndAdaptElement(parentElement, element);
1727
        return element;
1728
    }
1729

    
1730
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
1731
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
1732
        addAndAdaptElement(parentElement, element);
1733
        return element;
1734
    }
1735

    
1736
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
1737
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
1738
        addAndAdaptElement(parentElement, element);
1739
        return element;
1740
    }
1741

    
1742
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
1743
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
1744
        addAndAdaptElement(parentElement, element);
1745
        return element;
1746
    }
1747

    
1748
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
1749
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
1750
        addAndAdaptElement(parentElement, element);
1751
        return element;
1752
    }
1753

    
1754

    
1755
    public GeneralDetailElement createGeneralDetailElement(ICdmFormElement parentElement){
1756
        GeneralDetailElement element = new GeneralDetailElement(this, parentElement);
1757
        addAndAdaptElement(parentElement, element);
1758
        return element;
1759
    }
1760

    
1761
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
1762
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
1763
        addAndAdaptElement(parentElement, element);
1764
        return element;
1765
    }
1766

    
1767
    public FieldObservationDetailElement createFieldObservationDetailElement(ICdmFormElement parentElement) {
1768
        FieldObservationDetailElement element = new FieldObservationDetailElement(this, parentElement);
1769
        addAndAdaptElement(parentElement, element);
1770
        return element;
1771
    }
1772

    
1773
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
1774
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
1775
        addAndAdaptElement(parentElement, element);
1776
        return element;
1777
    }
1778

    
1779
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
1780
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
1781
        addAndAdaptElement(parentElement, element);
1782
        return element;
1783
    }
1784

    
1785
    /**
1786
     * @param parentElement
1787
     * @param element
1788
     */
1789
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
1790
        adapt(element);
1791
        parentElement.addElement(element);
1792
    }
1793

    
1794
    //--------EntityCollectionSection----------
1795
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1796
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style);
1797
        addAndAdaptSection(parentElement, section);
1798
        return section;
1799
    }
1800

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

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

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

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

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

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

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

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

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

    
1855
    public ModifierSection createModifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1856
        ModifierSection section = new ModifierSection(this, conversation, parentElement, style);
1857
        addAndAdaptSection(parentElement, section);
1858
        return section;
1859
    }
1860

    
1861
    public NomenclaturalStatusSection createNomenclaturalStatusSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1862
        NomenclaturalStatusSection section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
1863
        addAndAdaptSection(parentElement, section);
1864
        return section;
1865
    }
1866

    
1867
    public NameRelationshipDetailSection createNameRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1868
        NameRelationshipDetailSection section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
1869
        addAndAdaptSection(parentElement, section);
1870
        return section;
1871
    }
1872

    
1873
    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1874
        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
1875
        addAndAdaptSection(parentElement, section);
1876
        return section;
1877
    }
1878

    
1879
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1880
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
1881
        addAndAdaptSection(parentElement, section);
1882
        return section;
1883
    }
1884

    
1885
    public SourceSection createSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1886
        SourceSection section = new SourceSection(this, conversation, parentElement, style);
1887
        addAndAdaptSection(parentElement, section);
1888
        return section;
1889
    }
1890

    
1891
    public ScopeSection createScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1892
        ScopeSection section = new ScopeSection(this, conversation, parentElement, style);
1893
        addAndAdaptSection(parentElement, section);
1894
        return section;
1895
    }
1896

    
1897
    public DescriptionSourceSection createDescriptionSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1898
        DescriptionSourceSection section = new DescriptionSourceSection(this, conversation, parentElement, style);
1899
        addAndAdaptSection(parentElement, section);
1900
        return section;
1901
    }
1902

    
1903
    public TypeDesignationSection createTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1904
        TypeDesignationSection section = new TypeDesignationSection(this, conversation, parentElement, style);
1905
        addAndAdaptSection(parentElement, section);
1906
        return section;
1907
    }
1908

    
1909
    public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1910
        StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
1911
        addAndAdaptSection(parentElement, section);
1912
        return section;
1913
    }
1914

    
1915
    public StatisticalMeasurementValueSection createStatisticalMeasurementValueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1916
        StatisticalMeasurementValueSection section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
1917
        addAndAdaptSection(parentElement, section);
1918
        return section;
1919
    }
1920

    
1921
    public DescribedSpecimenSection createDescribedSpecimenSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1922
        DescribedSpecimenSection section = new DescribedSpecimenSection(this, conversation, parentElement, style);
1923
        addAndAdaptSection(parentElement, section);
1924
        return section;
1925
    }
1926

    
1927
    public CollectingAreasDetailSection createCollectingAreasDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1928
        CollectingAreasDetailSection section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
1929
        addAndAdaptSection(parentElement, section);
1930
        return section;
1931
    }
1932

    
1933
    public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1934
        CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
1935
        addAndAdaptSection(parentElement, section);
1936
        return section;
1937
    }
1938

    
1939
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1940
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
1941
        addAndAdaptSection(parentElement, section);
1942
        return section;
1943
    }
1944

    
1945
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1946
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
1947
        addAndAdaptSection(parentElement, section);
1948
        return section;
1949
    }
1950

    
1951
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1952
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
1953
        addAndAdaptSection(parentElement, section);
1954
        return section;
1955
    }
1956

    
1957
    public GeographicalScopeDetailSection createGeographicalScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1958
        GeographicalScopeDetailSection section = new GeographicalScopeDetailSection(this, conversation, parentElement, style);
1959
        addAndAdaptSection(parentElement, section);
1960
        return section;
1961
    }
1962

    
1963
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1964
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
1965
        addAndAdaptSection(parentElement, section);
1966
        return section;
1967
    }
1968

    
1969
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1970
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
1971
        addAndAdaptSection(parentElement, section);
1972
        return section;
1973
    }
1974

    
1975
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1976
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
1977
        addAndAdaptSection(parentElement, section);
1978
        return section;
1979
    }
1980

    
1981
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1982
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
1983
        addAndAdaptSection(parentElement, section);
1984
        return section;
1985
    }
1986

    
1987
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1988
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
1989
        addAndAdaptSection(parentElement, section);
1990
        return section;
1991
    }
1992

    
1993
    /**
1994
     * <p>
1995
     * createEntityCollectionElement
1996
     * </p>
1997
     *
1998
     * @param removeListener
1999
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
2000
     * @param style
2001
     *            a int.
2002
     * @param parentElement
2003
     *            a
2004
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
2005
     *            object.
2006
     * @param versionableEntity
2007
     *            a {@link eu.etaxonomy.cdm.model.common.IVersionableEntity}
2008
     *            object.
2009
     * @param backgroundColor
2010
     *            a {@link org.eclipse.swt.graphics.Color} object.
2011
     * @return a
2012
     *         {@link eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement}
2013
     *         object.
2014
     */
2015
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2016
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2017
        AbstractEntityCollectionElement element = null;
2018

    
2019
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2020

    
2021
        if (entity instanceof Annotation) {
2022
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2023
        } else if (entity instanceof Person) {
2024
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
2025
        } else if (entity instanceof Credit) {
2026
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2027
        } else if (entity instanceof Extension) {
2028
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2029
        } else if (entity instanceof Marker) {
2030
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2031
        } else if (entity instanceof Media) {
2032
            element = new MediaElement(this, parentElement, (Media) entity, removeListener, style);
2033
        } else if (entity instanceof MediaRepresentation) {
2034
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2035
                    style);
2036
        } else if (entity instanceof ImageFile) {
2037
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2038
        } else if (entity instanceof MediaRepresentationPart) {
2039
            element = new MediaRepresentationPartElement(this, parentElement, (MediaRepresentationPart) entity,
2040
                    removeListener, style);
2041
        } else if (entity instanceof NomenclaturalStatus) {
2042
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2043
                    style);
2044
        } else if (entity instanceof Rights) {
2045
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2046
        } else if (entity instanceof DescriptionElementSource) {
2047
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2048
                    removeListener, style);
2049
        } else if (entity instanceof IdentifiableSource) {
2050
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2051
                    style);
2052
        } else if (entity instanceof Scope) {
2053
            element = new ScopeElement(this, parentElement, (Scope) entity, removeListener, style);
2054
        } else if (entity instanceof Modifier) {
2055
            element = new ModifierElement(this, parentElement, (Modifier) entity, removeListener, style);
2056
        } else if (entity instanceof Reference) {
2057
            element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2058
        } else if (entity instanceof NameTypeDesignation) {
2059
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2060
                    style);
2061
        } else if (entity instanceof NameRelationship) {
2062
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2063
                    style);
2064
        } else if (entity instanceof SpecimenTypeDesignation) {
2065
            element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2066
                    removeListener, style);
2067
        } else if (entity instanceof StateData) {
2068
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2069
        } else if (entity instanceof StatisticalMeasurementValue) {
2070
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2071
                    removeListener, style);
2072
        } else if (entity instanceof DerivedUnit) {
2073
            element = new DerivedUnitElement(this, parentElement, (DerivedUnit) entity, removeListener, style);
2074
        } else if (entity instanceof NamedArea) {
2075
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2076
        } else if (entity instanceof DeterminationEvent) {
2077
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity,
2078
                    removeListener, style);
2079
        } else if (entity instanceof Specimen) {
2080
            element = new SpecimenCollectionDetailElement(this, parentElement, (Specimen) entity, removeListener, style);
2081
        } else if (entity instanceof User) {
2082
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2083
        } else if (entity instanceof GrantedAuthority) {
2084
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity,
2085
                    removeListener, style);
2086
        } else if (entity instanceof Group) {
2087
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2088
        } else if (entity instanceof Taxon) {
2089
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2090
        } else if (entity instanceof DescriptionElementBase) {
2091
            // this is the special case for protologs, maybe we can do this
2092
            // differently when API improves
2093
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2094
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2095
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2096
            }
2097
        }
2098

    
2099
        if (element == null) {
2100
            AbstractUtility.errorDialog("No element for entity", this,
2101
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2102
                            + entity, null);
2103
        }
2104

    
2105
        else if (backgroundColor != null && !backgroundColor.isDisposed()) {
2106
            element.setPersistentBackground(backgroundColor);
2107
        }
2108

    
2109
        adapt(element);
2110
        parentElement.addElement(element);
2111
        return element;
2112
    }
2113

    
2114
    /**
2115
     * <p>
2116
     * Creates a selection element for the given type T.
2117
     * </p>
2118
     * <p>
2119
     * <strong>Selection elements not handled by this method:</strong>
2120
     * <ul>
2121
     * <li>{@link TaxonNodeSelectionElement} see
2122
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2123
     * </li>
2124
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2125
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2126
     * </li>
2127
     * </ul>
2128
     * </p>
2129
     *
2130
     * @param clazz
2131
     *            a {@link Class} object of the type that you want the selection
2132
     *            element to handle
2133
     * @param parentElement
2134
     *            a {@link ICdmFormElement} object.
2135
     * @param labelString
2136
     *            a {@link String} object.
2137
     * @param selectionType
2138
     * @param selection
2139
     *            a {@link ICdmBase} object.
2140
     * @param style
2141
     *            a int.
2142
     * @param conversation
2143
     *            a {@link ConversationHolder} object.
2144
     * @return a {@link EntitySelectionElement} object.
2145
     */
2146
    public <T extends ICdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2147
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2148
            int style) {
2149
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2150
                labelString, selection, mode, style);
2151
        adapt(element);
2152
        parentElement.addElement(element);
2153
        return element;
2154
    }
2155

    
2156
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2157
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2158
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2159
                labelString, selection, mode, style);
2160
        adapt(element);
2161
        parentElement.addElement(element);
2162
        return element;
2163
    }
2164

    
2165
    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2166
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2167
            int mode, int style) {
2168
        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2169
                conversation, parentElement, labelString, selection, mode, style);
2170
        adapt(element);
2171
        parentElement.addElement(element);
2172
        return element;
2173
    }
2174

    
2175
    /** {@inheritDoc} */
2176
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2177
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2178
        adapt(labelElement);
2179
        parentElement.addElement(labelElement);
2180
        return labelElement;
2181
    }
2182

    
2183
    /**
2184
     * <p>
2185
     * Getter for the field <code>selectionProvider</code>.
2186
     * </p>
2187
     *
2188
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2189
     */
2190
    public ISelectionProvider getSelectionProvider() {
2191
        return selectionProvider;
2192
    }
2193

    
2194
    /**
2195
     * <p>
2196
     * createDetailedDescriptionDetailElement
2197
     * </p>
2198
     *
2199
     * @param parentElement
2200
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2201
     *            object.
2202
     * @param entity
2203
     *            a
2204
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2205
     *            object.
2206
     * @param style
2207
     *            a int.
2208
     * @return a
2209
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2210
     *         object.
2211
     */
2212
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2213
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2214
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2215

    
2216
        if (entity instanceof CategoricalData) {
2217
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2218
                    (CategoricalData) entity, style);
2219
        } else if (entity instanceof CommonTaxonName) {
2220
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2221
                    style);
2222
        } else if (entity instanceof Distribution) {
2223
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2224
                    style);
2225
        } else if (entity instanceof IndividualsAssociation) {
2226
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2227
                    (IndividualsAssociation) entity, style);
2228
        } else if (entity instanceof QuantitativeData) {
2229
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2230
                    (QuantitativeData) entity, style);
2231
        } else if (entity instanceof TaxonInteraction) {
2232
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2233
                    (TaxonInteraction) entity, style);
2234
        } else if (entity instanceof TextData) {
2235
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2236
        } else {
2237
            throw new IllegalStateException("There is no interface for the given description element");
2238
        }
2239
        adapt(detailedDescriptionElement);
2240
        parentElement.addElement(detailedDescriptionElement);
2241
        return detailedDescriptionElement;
2242

    
2243
    }
2244

    
2245
    /**
2246
     * Creates a styled text as a part of the form.
2247
     *
2248
     * @param parent
2249
     *            the text parent
2250
     * @param value
2251
     *            the text initial value
2252
     * @param style
2253
     *            the text style
2254
     * @return the text widget
2255
     */
2256
    public StyledText createStyledText(Composite parent, String value, int style) {
2257
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2258
        if (value != null) {
2259
            text.setText(value);
2260
        }
2261
        text.setForeground(getColors().getForeground());
2262
        text.setBackground(getColors().getBackground());
2263
        // text.addFocusListener(visibilityHandler);
2264
        return text;
2265
    }
2266

    
2267
}
(6-6/37)