Project

General

Profile

Download (102 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 *
3
 */
4
package eu.etaxonomy.taxeditor.ui.element;
5

    
6
import java.net.URI;
7
import java.util.ArrayList;
8
import java.util.HashSet;
9
import java.util.List;
10
import java.util.Map;
11
import java.util.Set;
12

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
967
    private class BoldFontHolder2 {
968
        private Font normalFont;
969

    
970
        private Font boldFont;
971

    
972
        public BoldFontHolder2() {
973
        }
974

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1341
    }
1342

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

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

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

    
1363

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1557

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

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

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

    
1575
    //--------DetailElements------------
1576

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1751

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2132
        return element;
2133
    }
2134

    
2135
    public void createNamedAreaFieldController(AbstractFormSection parentElement, NamedArea namedArea, SelectionListener removeListener){
2136
//        Object entity = HibernateProxyHelper.deproxy(versionableEntity); TODO deproxy necessary??
2137
        NamedAreaFieldController element = new NamedAreaFieldController(this, parentElement, namedArea, removeListener, SWT.NONE);
2138
        adapt(element);
2139
        parentElement.addElement(element);
2140
    }
2141

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

    
2184
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2185
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2186
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2187
                labelString, selection, mode, style);
2188
        adapt(element);
2189
        parentElement.addElement(element);
2190
        return element;
2191
    }
2192

    
2193
    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2194
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2195
            int mode, int style) {
2196
        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2197
                conversation, parentElement, labelString, selection, mode, style);
2198
        adapt(element);
2199
        parentElement.addElement(element);
2200
        return element;
2201
    }
2202

    
2203
    /** {@inheritDoc} */
2204
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2205
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2206
        adapt(labelElement);
2207
        parentElement.addElement(labelElement);
2208
        return labelElement;
2209
    }
2210

    
2211
    /**
2212
     * <p>
2213
     * Getter for the field <code>selectionProvider</code>.
2214
     * </p>
2215
     *
2216
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2217
     */
2218
    public ISelectionProvider getSelectionProvider() {
2219
        return selectionProvider;
2220
    }
2221

    
2222
    /**
2223
     * <p>
2224
     * createDetailedDescriptionDetailElement
2225
     * </p>
2226
     *
2227
     * @param parentElement
2228
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2229
     *            object.
2230
     * @param entity
2231
     *            a
2232
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2233
     *            object.
2234
     * @param style
2235
     *            a int.
2236
     * @return a
2237
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2238
     *         object.
2239
     */
2240
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2241
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2242
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2243

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

    
2271
    }
2272

    
2273
    /**
2274
     * Creates a styled text as a part of the form.
2275
     *
2276
     * @param parent
2277
     *            the text parent
2278
     * @param value
2279
     *            the text initial value
2280
     * @param style
2281
     *            the text style
2282
     * @return the text widget
2283
     */
2284
    public StyledText createStyledText(Composite parent, String value, int style) {
2285
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2286
        if (value != null) {
2287
            text.setText(value);
2288
        }
2289
        text.setForeground(getColors().getForeground());
2290
        text.setBackground(getColors().getBackground());
2291
        // text.addFocusListener(visibilityHandler);
2292
        return text;
2293
    }
2294

    
2295
}
(6-6/35)