Project

General

Profile

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

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

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

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

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

    
311
    private BoldFontHolder2 boldFontHolder2;
312
    private MouseListener selectionMouseHandler;
313
    private FocusListener selectionFocusHandler;
314

    
315
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
316

    
317
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
318

    
319
    private final int orientation = Window.getDefaultOrientation();
320
    private ISelectionProvider selectionProvider;
321

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

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

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

    
356
    private void notifySelectionListeners(TypedEvent e) {
357
        Event event = new Event();
358
        event.widget = e.widget;
359
        SelectionEvent selectionEvent = new SelectionEvent(event);
360

    
361
        for (SelectionListener listener : selectionListenerList) {
362
            listener.widgetSelected(selectionEvent);
363
        }
364
    }
365

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

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

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

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

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

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

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

    
468
    /** {@inheritDoc} */
469
    @Override
470
    public void adapt(Composite composite) {
471
        composite.addMouseListener(selectionMouseHandler);
472
        super.adapt(composite);
473
    }
474

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

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

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

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

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

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

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

    
652
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null, textLimit, style);
653
        adapt(element);
654
        parentElement.addElement(element);
655
        return element;
656
    }
657

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

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

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

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

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

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

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

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

    
830
    /**
831
     * <p>
832
     * createTermComboElement
833
     * </p>
834
     *
835
     * @param termComboType
836
     *            a
837
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
838
     *            object.
839
     * @param parentElement
840
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
841
     *            object.
842
     * @param labelString
843
     *            a {@link java.lang.String} object.
844
     * @param selection
845
     *            a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
846
     *            object.
847
     * @param style
848
     *            a int.
849
     * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
850
     *         object.
851
     */
852

    
853
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
854
            ICdmFormElement parentElement, String labelString, T selection, int style) {
855
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString,
856
                selection, style);
857
        adapt(element);
858
        parentElement.addElement(element);
859
        return element;
860
    }
861

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

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

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

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

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

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

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

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

    
1034
        // handle focus and property change events for cdm use
1035
        section.addFocusListener(selectionFocusHandler);
1036
        section.setPropertyChangeListeners(propertyChangeListeners);
1037

    
1038
        if (section.getToggle() != null) {
1039
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1040
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1041
        }
1042

    
1043
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1044

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

    
1056
    private class BoldFontHolder2 {
1057
        private Font normalFont;
1058

    
1059
        private Font boldFont;
1060

    
1061
        public BoldFontHolder2() {
1062
        }
1063

    
1064
        public Font getBoldFont(Font font) {
1065
            createBoldFont(font);
1066
            return boldFont;
1067
        }
1068

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

    
1079
        public void dispose() {
1080
            if (boldFont != null) {
1081
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1082
                boldFont = null;
1083
            }
1084
        }
1085
    }
1086

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

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

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

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

    
1195

    
1196

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

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

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

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

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

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

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

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

    
1334
    /**
1335
     * @return the propertyChangeListeners
1336
     */
1337
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1338
        return propertyChangeListeners;
1339
    }
1340

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

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

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

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

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

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

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

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

    
1490
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1491
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1492

    
1493
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1494
                selectionProvider, style);
1495

    
1496
        parentElement.addElement(section);
1497
        adapt(section);
1498
        return section;
1499

    
1500
    }
1501

    
1502
    /**
1503
     * @param definedTermClass
1504
     * @param formElement
1505
     * @param style
1506
     * @return
1507
     */
1508
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1509
            AbstractCdmDetailSection parentElement, int style) {
1510
        AbstractCdmDetailElement element = null;
1511

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

    
1520
        adapt(element);
1521
        parentElement.addElement(element);
1522
        return element;
1523
    }
1524

    
1525

    
1526
    //--------DetailSections---------
1527
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1528
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1529
        addAndAdaptSection(parentElement, section);
1530
        return section;
1531
    }
1532

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

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

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

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

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

    
1563
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1564
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1565
        addAndAdaptSection(parentElement, section);
1566
        return section;
1567
    }
1568

    
1569
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1570
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1571
        addAndAdaptSection(parentElement, section);
1572
        return section;
1573
    }
1574

    
1575
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1576
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1577
        addAndAdaptSection(parentElement, section);
1578
        return section;
1579
    }
1580

    
1581
    public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1582
        DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1583
        addAndAdaptSection(parentElement, section);
1584
        return section;
1585
    }
1586

    
1587
    public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1588
        ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1589
        addAndAdaptSection(parentElement, section);
1590
        return section;
1591
    }
1592

    
1593
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1594
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, style);
1595
        addAndAdaptSection(parentElement, section);
1596
        return section;
1597
    }
1598

    
1599
    public MediaDetailsSection createMediaDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1600
        MediaDetailsSection section = new MediaDetailsSection(this, conversation, parentElement, selectionProvider, style);
1601
        addAndAdaptSection(parentElement, section);
1602
        return section;
1603
    }
1604

    
1605
    public DerivedUnitFacadeDetailSection createDerivedUnitFacadeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1606
        DerivedUnitFacadeDetailSection section = new DerivedUnitFacadeDetailSection(this, conversation, parentElement, selectionProvider, style);
1607
        addAndAdaptSection(parentElement, section);
1608
        return section;
1609
    }
1610

    
1611
    public FieldUnitDetailSection createFieldUnitDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1612
        FieldUnitDetailSection section = new FieldUnitDetailSection(this, conversation, parentElement, selectionProvider, style);
1613
        addAndAdaptSection(parentElement, section);
1614
        return section;
1615
    }
1616

    
1617
    public GatheringEventDetailSection createGatheringEventDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1618
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1619
        addAndAdaptSection(parentElement, section);
1620
        return section;
1621
    }
1622

    
1623
    public DerivedUnitBaseDetailSection createDerivedUnitBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1624
        DerivedUnitBaseDetailSection section = new DerivedUnitBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1625
        addAndAdaptSection(parentElement, section);
1626
        return section;
1627
    }
1628

    
1629
    public NaturalLanguageSection createNaturalLanguageSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1630
        NaturalLanguageSection section = new NaturalLanguageSection(this, conversation, parentElement, selectionProvider, style);
1631
        addAndAdaptSection(parentElement, section);
1632
        return section;
1633
    }
1634

    
1635
    public FeatureDistributionDetailSection createFeatureDistributionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1636
        FeatureDistributionDetailSection section = new FeatureDistributionDetailSection(this, conversation, parentElement, selectionProvider, style);
1637
        addAndAdaptSection(parentElement, section);
1638
        return section;
1639
    }
1640

    
1641
    public ClassificationDetailSection createClassificationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1642
        ClassificationDetailSection section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style);
1643
        addAndAdaptSection(parentElement, section);
1644
        return section;
1645
    }
1646

    
1647
    public TaxonNodeDetailSection createTaxonNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1648
        TaxonNodeDetailSection section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1649
        addAndAdaptSection(parentElement, section);
1650
        return section;
1651
    }
1652

    
1653
    public PolytomousKeyDetailSection createPolytomousKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1654
        PolytomousKeyDetailSection section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
1655
        addAndAdaptSection(parentElement, section);
1656
        return section;
1657
    }
1658

    
1659
    public PolytomousKeyNodeDetailSection createPolytomousKeyNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1660
        PolytomousKeyNodeDetailSection section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1661
        addAndAdaptSection(parentElement, section);
1662
        return section;
1663
    }
1664

    
1665
    public InstitutionDetailSection createInstitutionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1666
        InstitutionDetailSection section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
1667
        addAndAdaptSection(parentElement, section);
1668
        return section;
1669
    }
1670

    
1671
    public FieldUnitGeneralDetailSection createFieldUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1672
        FieldUnitGeneralDetailSection section = new FieldUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1673
        addAndAdaptSection(parentElement, section);
1674
        return section;
1675
    }
1676

    
1677
    public DerivedUnitGeneralDetailSection createDerivedUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1678
        DerivedUnitGeneralDetailSection section = new DerivedUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1679
        addAndAdaptSection(parentElement, section);
1680
        return section;
1681
    }
1682

    
1683
    public PreservedSpecimenGeneralDetailSection createPreservedSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1684
        PreservedSpecimenGeneralDetailSection section = new PreservedSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1685
        addAndAdaptSection(parentElement, section);
1686
        return section;
1687
    }
1688

    
1689
    public TissueSampleGeneralDetailSection createTissueSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1690
        TissueSampleGeneralDetailSection section = new TissueSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1691
        addAndAdaptSection(parentElement, section);
1692
        return section;
1693
    }
1694

    
1695
    public DnaSampleGeneralDetailSection createDnaSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1696
        DnaSampleGeneralDetailSection section = new DnaSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1697
        addAndAdaptSection(parentElement, section);
1698
        return section;
1699
    }
1700

    
1701
    public DnaQualityDetailSection createDnaQualityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1702
        DnaQualityDetailSection section = new DnaQualityDetailSection(this, conversation, parentElement, selectionProvider, style);
1703
        addAndAdaptSection(parentElement, section);
1704
        return section;
1705
    }
1706

    
1707
    public SequenceGeneralDetailSection createSequenceGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1708
        SequenceGeneralDetailSection section = new SequenceGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1709
        addAndAdaptSection(parentElement, section);
1710
        return section;
1711
    }
1712

    
1713
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1714
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
1715
        addAndAdaptSection(parentElement, section);
1716
        return section;
1717
    }
1718

    
1719
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1720
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
1721
        addAndAdaptSection(parentElement, section);
1722
        return section;
1723
    }
1724

    
1725
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1726
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1727
        addAndAdaptSection(parentElement, section);
1728
        return section;
1729
    }
1730

    
1731
    public SingleReadGeneralDetailSection createSingleReadGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1732
        SingleReadGeneralDetailSection section = new SingleReadGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1733
        addAndAdaptSection(parentElement, section);
1734
        return section;
1735
    }
1736

    
1737
    public AmplificationGeneralDetailSection createAmplificationGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1738
        AmplificationGeneralDetailSection section = new AmplificationGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1739
        addAndAdaptSection(parentElement, section);
1740
        return section;
1741
    }
1742

    
1743
    public AmplificationPrimerDetailSection createAmplificationPrimerDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1744
        AmplificationPrimerDetailSection section = new AmplificationPrimerDetailSection(this, conversation, parentElement, selectionProvider, style);
1745
        addAndAdaptSection(parentElement, section);
1746
        return section;
1747
    }
1748

    
1749
    public AmplificationCloningDetailSection createAmplificationCloningDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1750
        AmplificationCloningDetailSection section = new AmplificationCloningDetailSection(this, conversation, parentElement, selectionProvider, style);
1751
        addAndAdaptSection(parentElement, section);
1752
        return section;
1753
    }
1754

    
1755
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1756
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1757
        addAndAdaptSection(parentElement, section);
1758
        return section;
1759
    }
1760

    
1761
    public SpecimenScanGeneralDetailSection createSpecimenScanGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1762
        SpecimenScanGeneralDetailSection section = new SpecimenScanGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1763
        addAndAdaptSection(parentElement, section);
1764
        return section;
1765
    }
1766

    
1767
    public LivingPlantPhotoGeneralDetailSection createLivingPlantPhotoGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1768
        LivingPlantPhotoGeneralDetailSection section = new LivingPlantPhotoGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1769
        addAndAdaptSection(parentElement, section);
1770
        return section;
1771
    }
1772

    
1773
    public MediaSpecimenGeneralDetailSection createMediaSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1774
        MediaSpecimenGeneralDetailSection section = new MediaSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1775
        addAndAdaptSection(parentElement, section);
1776
        return section;
1777
    }
1778

    
1779
    public HybridDetailSection createHybridDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1780
        HybridDetailSection section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
1781
        addAndAdaptSection(parentElement, section);
1782
        return section;
1783
    }
1784

    
1785
    public UserDetailSection createUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1786
        UserDetailSection section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
1787
        addAndAdaptSection(parentElement, section);
1788
        return section;
1789
    }
1790

    
1791
    public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1792
        GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
1793
        addAndAdaptSection(parentElement, section);
1794
        return section;
1795
    }
1796

    
1797
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1798
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1799
        addAndAdaptSection(parentElement, section);
1800
        return section;
1801
    }
1802

    
1803
    public PreservedSpecimenDeterminationDetailSection createPreservedSpecimenDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1804
        PreservedSpecimenDeterminationDetailSection section = new PreservedSpecimenDeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1805
        addAndAdaptSection(parentElement, section);
1806
        return section;
1807
    }
1808

    
1809
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1810
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1811
        addAndAdaptSection(parentElement, section);
1812
        return section;
1813
    }
1814

    
1815
    public ReferencedEntityDetailSection createReferencedEntityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1816
        ReferencedEntityDetailSection section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
1817
        addAndAdaptSection(parentElement, section);
1818
        return section;
1819
    }
1820

    
1821
    public TermVocabularyDetailSection createTermVocabularyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1822
        TermVocabularyDetailSection section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
1823
        addAndAdaptSection(parentElement, section);
1824
        return section;
1825
    }
1826

    
1827
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1828
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1829
        addAndAdaptSection(parentElement, section);
1830
        return section;
1831
    }
1832

    
1833
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1834
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
1835
        addAndAdaptSection(parentElement, section);
1836
        return section;
1837
    }
1838

    
1839
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1840
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
1841
        addAndAdaptSection(parentElement, section);
1842
        return section;
1843
    }
1844

    
1845
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1846
        parentElement.addElement(section);
1847
        adapt(section);
1848
    }
1849

    
1850
    //--------DetailElements------------
1851

    
1852
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1853
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1854
        addAndAdaptElement(parentElement, element);
1855
        return element;
1856
    }
1857

    
1858
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1859
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1860
        addAndAdaptElement(parentElement, element);
1861
        return element;
1862
    }
1863

    
1864
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1865
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1866
        addAndAdaptElement(parentElement, element);
1867
        return element;
1868
    }
1869

    
1870
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1871
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1872
        addAndAdaptElement(parentElement, element);
1873
        return element;
1874
    }
1875

    
1876
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1877
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1878
        addAndAdaptElement(parentElement, element);
1879
        return element;
1880
    }
1881

    
1882
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1883
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1884
        addAndAdaptElement(parentElement, element);
1885
        return element;
1886
    }
1887

    
1888
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1889
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
1890
        addAndAdaptElement(parentElement, element);
1891
        return element;
1892
    }
1893

    
1894
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
1895
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
1896
        addAndAdaptElement(parentElement, element);
1897
        return element;
1898
    }
1899

    
1900
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
1901
        UserDetailElement element = new UserDetailElement(this, parentElement);
1902
        addAndAdaptElement(parentElement, element);
1903
        return element;
1904
    }
1905

    
1906
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
1907
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
1908
        addAndAdaptElement(parentElement, element);
1909
        return element;
1910
    }
1911

    
1912
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
1913
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
1914
        addAndAdaptElement(parentElement, element);
1915
        return element;
1916
    }
1917

    
1918
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
1919
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
1920
        addAndAdaptElement(parentElement, element);
1921
        return element;
1922
    }
1923

    
1924
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
1925
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
1926
        addAndAdaptElement(parentElement, element);
1927
        return element;
1928
    }
1929

    
1930
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
1931
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
1932
        addAndAdaptElement(parentElement, element);
1933
        return element;
1934
    }
1935

    
1936
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement){
1937
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement);
1938
        addAndAdaptElement(parentElement, element);
1939
        return element;
1940
    }
1941

    
1942
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
1943
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
1944
        addAndAdaptElement(parentElement, element);
1945
        return element;
1946
    }
1947

    
1948
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
1949
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
1950
        addAndAdaptElement(parentElement, element);
1951
        return element;
1952
    }
1953

    
1954
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
1955
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
1956
        addAndAdaptElement(parentElement, element);
1957
        return element;
1958
    }
1959

    
1960
    public DerivedUnitFacadeDetailElement createDerivedUnitFacadeDetailElement(ICdmFormElement parentElement){
1961
        DerivedUnitFacadeDetailElement element = new DerivedUnitFacadeDetailElement(this, parentElement);
1962
        addAndAdaptElement(parentElement, element);
1963
        return element;
1964
    }
1965

    
1966
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
1967
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
1968
        addAndAdaptElement(parentElement, element);
1969
        return element;
1970
    }
1971

    
1972
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
1973
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
1974
        addAndAdaptElement(parentElement, element);
1975
        return element;
1976
    }
1977

    
1978
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
1979
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
1980
        addAndAdaptElement(parentElement, element);
1981
        return element;
1982
    }
1983

    
1984
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
1985
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
1986
        addAndAdaptElement(parentElement, element);
1987
        return element;
1988
    }
1989

    
1990
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style){
1991
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style);
1992
        addAndAdaptElement(parentElement, element);
1993
        return element;
1994
    }
1995

    
1996
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
1997
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
1998
        addAndAdaptElement(parentElement, element);
1999
        return element;
2000
    }
2001

    
2002
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2003
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2004
        addAndAdaptElement(parentElement, element);
2005
        return element;
2006
    }
2007

    
2008
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2009
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2010
        addAndAdaptElement(parentElement, element);
2011
        return element;
2012
    }
2013

    
2014
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
2015
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
2016
        addAndAdaptElement(parentElement, element);
2017
        return element;
2018
    }
2019

    
2020
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2021
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2022
        addAndAdaptElement(parentElement, element);
2023
        return element;
2024
    }
2025

    
2026

    
2027
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2028
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2029
        addAndAdaptElement(parentElement, element);
2030
        return element;
2031
    }
2032

    
2033
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2034
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2035
        addAndAdaptElement(parentElement, element);
2036
        return element;
2037
    }
2038

    
2039
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2040
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2041
        addAndAdaptElement(parentElement, element);
2042
        return element;
2043
    }
2044

    
2045
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2046
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2047
        addAndAdaptElement(parentElement, element);
2048
        return element;
2049
    }
2050

    
2051
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2052
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2053
        addAndAdaptElement(parentElement, element);
2054
        return element;
2055
    }
2056

    
2057
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2058
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2059
        addAndAdaptElement(parentElement, element);
2060
        return element;
2061
    }
2062

    
2063
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2064
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2065
        addAndAdaptElement(parentElement, element);
2066
        return element;
2067
    }
2068

    
2069
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2070
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2071
        addAndAdaptElement(parentElement, element);
2072
        return element;
2073
    }
2074

    
2075
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2076
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2077
        addAndAdaptElement(parentElement, element);
2078
        return element;
2079
    }
2080

    
2081
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2082
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2083
        addAndAdaptElement(parentElement, element);
2084
        return element;
2085
    }
2086

    
2087
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2088
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2089
        addAndAdaptElement(parentElement, element);
2090
        return element;
2091
    }
2092

    
2093
    public SpecimenScanGeneralDetailElement createSpecimenScanGeneralDetailElement(ICdmFormElement parentElement){
2094
        SpecimenScanGeneralDetailElement element = new SpecimenScanGeneralDetailElement(this, parentElement);
2095
        addAndAdaptElement(parentElement, element);
2096
        return element;
2097
    }
2098

    
2099
    public LivingPlantPhotoGeneralDetailElement createLivingPlantPhotoGeneralDetailElement(ICdmFormElement parentElement){
2100
        LivingPlantPhotoGeneralDetailElement element = new LivingPlantPhotoGeneralDetailElement(this, parentElement);
2101
        addAndAdaptElement(parentElement, element);
2102
        return element;
2103
    }
2104

    
2105
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2106
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2107
        addAndAdaptElement(parentElement, element);
2108
        return element;
2109
    }
2110

    
2111

    
2112
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2113
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2114
        addAndAdaptElement(parentElement, element);
2115
        return element;
2116
    }
2117

    
2118
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2119
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2120
        addAndAdaptElement(parentElement, element);
2121
        return element;
2122
    }
2123

    
2124

    
2125
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2126
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2127
        addAndAdaptElement(parentElement, element);
2128
        return element;
2129
    }
2130

    
2131
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2132
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2133
        addAndAdaptElement(parentElement, element);
2134
        return element;
2135
    }
2136

    
2137
    public PreservedSpecimenDeterminationDetailElement createPreservedSpecimenDeterminationDetailElement(ICdmFormElement parentElement) {
2138
        PreservedSpecimenDeterminationDetailElement element = new PreservedSpecimenDeterminationDetailElement(this, parentElement);
2139
        addAndAdaptElement(parentElement, element);
2140
        return element;
2141
    }
2142

    
2143
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2144
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2145
        addAndAdaptElement(parentElement, element);
2146
        return element;
2147
    }
2148

    
2149
    /**
2150
     * @param parentElement
2151
     * @param element
2152
     */
2153
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2154
        adapt(element);
2155
        parentElement.addElement(element);
2156
    }
2157

    
2158
    //--------EntityCollectionSection----------
2159
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2160
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style);
2161
        addAndAdaptSection(parentElement, section);
2162
        return section;
2163
    }
2164

    
2165
    public AnnotationSection createAnnotationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2166
        AnnotationSection section = new AnnotationSection(this, conversation, parentElement, style);
2167
        addAndAdaptSection(parentElement, section);
2168
        return section;
2169
    }
2170

    
2171
    public CreditSection createCreditSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2172
        CreditSection section = new CreditSection(this, conversation, parentElement, style);
2173
        addAndAdaptSection(parentElement, section);
2174
        return section;
2175
    }
2176

    
2177
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2178
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2179
        addAndAdaptSection(parentElement, section);
2180
        return section;
2181
    }
2182

    
2183
    public ExtensionSection createExtensionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2184
        ExtensionSection section = new ExtensionSection(this, conversation, parentElement, style);
2185
        addAndAdaptSection(parentElement, section);
2186
        return section;
2187
    }
2188

    
2189
    public MarkerSection createMarkerSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2190
        MarkerSection section = new MarkerSection(this, conversation, parentElement, style);
2191
        addAndAdaptSection(parentElement, section);
2192
        return section;
2193
    }
2194

    
2195
    public MediaSection createMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2196
        MediaSection section = new MediaSection(this, conversation, parentElement, style);
2197
        addAndAdaptSection(parentElement, section);
2198
        return section;
2199
    }
2200

    
2201
    public DescriptionElementMediaSection createDescriptionElementMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2202
        DescriptionElementMediaSection section = new DescriptionElementMediaSection(this, conversation, parentElement, style);
2203
        addAndAdaptSection(parentElement, section);
2204
        return section;
2205
    }
2206

    
2207
    public MediaRepresentationSection createMediaRepresentationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2208
        MediaRepresentationSection section = new MediaRepresentationSection(this, conversation, parentElement, style);
2209
        addAndAdaptSection(parentElement, section);
2210
        return section;
2211
    }
2212

    
2213
    public MediaRepresentationPartSection createMediaRepresentationPartSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2214
        MediaRepresentationPartSection section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
2215
        addAndAdaptSection(parentElement, section);
2216
        return section;
2217
    }
2218

    
2219
    public ModifierSection createModifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2220
        ModifierSection section = new ModifierSection(this, conversation, parentElement, style);
2221
        addAndAdaptSection(parentElement, section);
2222
        return section;
2223
    }
2224

    
2225
    public NomenclaturalStatusSection createNomenclaturalStatusSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2226
        NomenclaturalStatusSection section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
2227
        addAndAdaptSection(parentElement, section);
2228
        return section;
2229
    }
2230

    
2231
    public NameRelationshipDetailSection createNameRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2232
        NameRelationshipDetailSection section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
2233
        addAndAdaptSection(parentElement, section);
2234
        return section;
2235
    }
2236

    
2237
    public SynonymRelationshipDetailSection createSynonymRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2238
        SynonymRelationshipDetailSection section = new SynonymRelationshipDetailSection(this, conversation, parentElement, style);
2239
        addAndAdaptSection(parentElement, section);
2240
        return section;
2241
    }
2242

    
2243
    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2244
        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2245
        addAndAdaptSection(parentElement, section);
2246
        return section;
2247
    }
2248

    
2249
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2250
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2251
        addAndAdaptSection(parentElement, section);
2252
        return section;
2253
    }
2254

    
2255
    public SourceSection createSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2256
        SourceSection section = new SourceSection(this, conversation, parentElement, style);
2257
        addAndAdaptSection(parentElement, section);
2258
        return section;
2259
    }
2260

    
2261
    public ScopeSection createScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2262
        ScopeSection section = new ScopeSection(this, conversation, parentElement, style);
2263
        addAndAdaptSection(parentElement, section);
2264
        return section;
2265
    }
2266

    
2267
    public DescriptionSourceSection createDescriptionSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2268
        DescriptionSourceSection section = new DescriptionSourceSection(this, conversation, parentElement, style);
2269
        addAndAdaptSection(parentElement, section);
2270
        return section;
2271
    }
2272

    
2273
    public TypeDesignationSection createTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2274
        TypeDesignationSection section = new TypeDesignationSection(this, conversation, parentElement, style);
2275
        addAndAdaptSection(parentElement, section);
2276
        return section;
2277
    }
2278

    
2279
    public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2280
        StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
2281
        addAndAdaptSection(parentElement, section);
2282
        return section;
2283
    }
2284

    
2285
    public StatisticalMeasurementValueSection createStatisticalMeasurementValueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2286
        StatisticalMeasurementValueSection section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
2287
        addAndAdaptSection(parentElement, section);
2288
        return section;
2289
    }
2290

    
2291
    public DescribedSpecimenSection createDescribedSpecimenSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2292
        DescribedSpecimenSection section = new DescribedSpecimenSection(this, conversation, parentElement, style);
2293
        addAndAdaptSection(parentElement, section);
2294
        return section;
2295
    }
2296

    
2297
    public CollectingAreasDetailSection createCollectingAreasDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2298
        CollectingAreasDetailSection section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
2299
        addAndAdaptSection(parentElement, section);
2300
        return section;
2301
    }
2302

    
2303
    public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2304
        CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
2305
        addAndAdaptSection(parentElement, section);
2306
        return section;
2307
    }
2308

    
2309
    public PreservedSpecimenCurrentDeterminationDetailSection createPreservedSpecimenCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2310
        PreservedSpecimenCurrentDeterminationDetailSection section = new PreservedSpecimenCurrentDeterminationDetailSection(this, conversation, parentElement, style);
2311
        addAndAdaptSection(parentElement, section);
2312
        return section;
2313
    }
2314

    
2315
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2316
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
2317
        addAndAdaptSection(parentElement, section);
2318
        return section;
2319
    }
2320

    
2321
    public PreservedSpecimenDeterminationHistoryDetailSection createPreservedSpecimenDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2322
        PreservedSpecimenDeterminationHistoryDetailSection section = new PreservedSpecimenDeterminationHistoryDetailSection(this, conversation, parentElement, style);
2323
        addAndAdaptSection(parentElement, section);
2324
        return section;
2325
    }
2326

    
2327
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2328
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
2329
        addAndAdaptSection(parentElement, section);
2330
        return section;
2331
    }
2332

    
2333
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2334
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2335
        addAndAdaptSection(parentElement, section);
2336
        return section;
2337
    }
2338

    
2339
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2340
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2341
        addAndAdaptSection(parentElement, section);
2342
        return section;
2343
    }
2344

    
2345
    public GeographicalScopeDetailSection createGeographicalScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2346
        GeographicalScopeDetailSection section = new GeographicalScopeDetailSection(this, conversation, parentElement, style);
2347
        addAndAdaptSection(parentElement, section);
2348
        return section;
2349
    }
2350

    
2351
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2352
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2353
        addAndAdaptSection(parentElement, section);
2354
        return section;
2355
    }
2356

    
2357
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2358
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2359
        addAndAdaptSection(parentElement, section);
2360
        return section;
2361
    }
2362

    
2363
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2364
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2365
        addAndAdaptSection(parentElement, section);
2366
        return section;
2367
    }
2368

    
2369
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2370
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2371
        addAndAdaptSection(parentElement, section);
2372
        return section;
2373
    }
2374

    
2375
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2376
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2377
        addAndAdaptSection(parentElement, section);
2378
        return section;
2379
    }
2380

    
2381
    /**
2382
     * <p>
2383
     * createEntityCollectionElement
2384
     * </p>
2385
     *
2386
     * @param removeListener
2387
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
2388
     * @param style
2389
     *            a int.
2390
     * @param parentElement
2391
     *            a
2392
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
2393
     *            object.
2394
     * @param versionableEntity
2395
     *            a {@link eu.etaxonomy.cdm.model.common.IVersionableEntity}
2396
     *            object.
2397
     * @param backgroundColor
2398
     *            a {@link org.eclipse.swt.graphics.Color} object.
2399
     * @return a
2400
     *         {@link eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement}
2401
     *         object.
2402
     */
2403
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2404
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2405
        AbstractEntityCollectionElement element = null;
2406

    
2407
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2408

    
2409
        if (entity instanceof Annotation) {
2410
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2411
        } else if (entity instanceof Person) {
2412
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
2413
        } else if (entity instanceof Credit) {
2414
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2415
        } else if (entity instanceof Extension) {
2416
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2417
        } else if (entity instanceof Marker) {
2418
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2419
        } else if (entity instanceof Media) {
2420
            element = new MediaElement(this, parentElement, (Media) entity, removeListener, style);
2421
        } else if (entity instanceof MediaRepresentation) {
2422
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2423
                    style);
2424
        } else if (entity instanceof ImageFile) {
2425
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2426
        } else if (entity instanceof MediaRepresentationPart) {
2427
            element = new MediaRepresentationPartElement(this, parentElement, (MediaRepresentationPart) entity,
2428
                    removeListener, style);
2429
        } else if (entity instanceof NomenclaturalStatus) {
2430
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2431
                    style);
2432
        } else if (entity instanceof Rights) {
2433
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2434
        } else if (entity instanceof DescriptionElementSource) {
2435
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2436
                    removeListener, style);
2437
        } else if (entity instanceof IdentifiableSource) {
2438
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2439
                    style);
2440
		} else if (entity instanceof DefinedTerm) {
2441
			switch(((DefinedTerm)entity).getTermType()) {
2442
				case Scope:
2443
					element = new ScopeElement(this,
2444
							parentElement,
2445
							(DefinedTerm) entity,
2446
							removeListener,
2447
							style);
2448
					break;
2449
				case Modifier:
2450
					element = new ModifierElement(this,
2451
							parentElement,
2452
							(DefinedTerm) entity,
2453
							removeListener,
2454
							style);
2455
					break;
2456
				default:
2457
					//FIXME : Actually we should through an exception here
2458
					element = null;
2459
					break;
2460

    
2461
			}
2462
        } else if (entity instanceof Reference) {
2463
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2464
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2465
            }
2466
            else{
2467
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2468
            }
2469
        } else if (entity instanceof NameTypeDesignation) {
2470
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2471
                    style);
2472
        } else if (entity instanceof NameRelationship) {
2473
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2474
                    style);
2475
        } else if (entity instanceof SynonymRelationship) {
2476
            element = new SynonymRelationshipDetailElement(this, parentElement, (SynonymRelationship) entity, removeListener,
2477
                    style);
2478
        } else if (entity instanceof SpecimenTypeDesignation) {
2479
            element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2480
                    removeListener, style);
2481
        } else if (entity instanceof StateData) {
2482
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2483
        } else if (entity instanceof StatisticalMeasurementValue) {
2484
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2485
                    removeListener, style);
2486
        } else if (entity instanceof DerivedUnit) {
2487
        	switch(((DerivedUnit)entity).getRecordBasis()) {
2488
				case LivingSpecimen:
2489
				case PreservedSpecimen:
2490
				case OtherSpecimen:
2491
					element = new SpecimenCollectionDetailElement(this,
2492
								parentElement,
2493
								(DerivedUnit) entity,
2494
								removeListener,
2495
								style);
2496
					break;
2497
				default:
2498
					element = new DerivedUnitElement(this,
2499
								parentElement,
2500
								(DerivedUnit) entity,
2501
								removeListener,
2502
								style);
2503
			}
2504

    
2505
        } else if (entity instanceof NamedArea) {
2506
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2507
        } else if (entity instanceof DeterminationEvent) {
2508
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2509
        } else if (entity instanceof User) {
2510
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2511
        } else if (entity instanceof GrantedAuthority) {
2512
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity,
2513
                    removeListener, style);
2514
        } else if (entity instanceof Group) {
2515
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2516
        } else if (entity instanceof Taxon) {
2517
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2518
        } else if (entity instanceof DescriptionElementBase) {
2519
            // this is the special case for protologs, maybe we can do this
2520
            // differently when API improves
2521
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2522
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2523
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2524
            }
2525
        }
2526

    
2527
        if (element == null) {
2528
            AbstractUtility.errorDialog("No element for entity", this,
2529
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2530
                            + entity, null);
2531
        }
2532

    
2533
        else if (backgroundColor != null && !backgroundColor.isDisposed()) {
2534
            element.setPersistentBackground(backgroundColor);
2535
            adapt(element);
2536
            parentElement.addElement(element);
2537
        }
2538

    
2539
        return element;
2540
    }
2541

    
2542
    /**
2543
     * <p>
2544
     * Creates a selection element for the given type T.
2545
     * </p>
2546
     * <p>
2547
     * <strong>Selection elements not handled by this method:</strong>
2548
     * <ul>
2549
     * <li>{@link TaxonNodeSelectionElement} see
2550
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2551
     * </li>
2552
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2553
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2554
     * </li>
2555
     * </ul>
2556
     * </p>
2557
     *
2558
     * @param clazz
2559
     *            a {@link Class} object of the type that you want the selection
2560
     *            element to handle
2561
     * @param parentElement
2562
     *            a {@link ICdmFormElement} object.
2563
     * @param labelString
2564
     *            a {@link String} object.
2565
     * @param selectionType
2566
     * @param selection
2567
     *            a {@link ICdmBase} object.
2568
     * @param style
2569
     *            a int.
2570
     * @param conversation
2571
     *            a {@link ConversationHolder} object.
2572
     * @return a {@link EntitySelectionElement} object.
2573
     */
2574
    public <T extends ICdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2575
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2576
            int style) {
2577
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2578
                labelString, selection, mode, style);
2579
        adapt(element);
2580
        parentElement.addElement(element);
2581
        return element;
2582
    }
2583

    
2584
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2585
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2586
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2587
                labelString, selection, mode, style);
2588
        adapt(element);
2589
        parentElement.addElement(element);
2590
        return element;
2591
    }
2592

    
2593
    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2594
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2595
            int mode, int style) {
2596
        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2597
                conversation, parentElement, labelString, selection, mode, style);
2598
        adapt(element);
2599
        parentElement.addElement(element);
2600
        return element;
2601
    }
2602

    
2603
    /** {@inheritDoc} */
2604
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2605
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2606
        adapt(labelElement);
2607
        parentElement.addElement(labelElement);
2608
        return labelElement;
2609
    }
2610

    
2611
    /**
2612
     * <p>
2613
     * Getter for the field <code>selectionProvider</code>.
2614
     * </p>
2615
     *
2616
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2617
     */
2618
    public ISelectionProvider getSelectionProvider() {
2619
        return selectionProvider;
2620
    }
2621

    
2622
    /**
2623
     * <p>
2624
     * createDetailedDescriptionDetailElement
2625
     * </p>
2626
     *
2627
     * @param parentElement
2628
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2629
     *            object.
2630
     * @param entity
2631
     *            a
2632
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2633
     *            object.
2634
     * @param style
2635
     *            a int.
2636
     * @return a
2637
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2638
     *         object.
2639
     */
2640
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2641
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2642
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2643

    
2644
        if (entity instanceof CategoricalData) {
2645
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2646
                    (CategoricalData) entity, style);
2647
        } else if (entity instanceof CommonTaxonName) {
2648
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2649
                    style);
2650
        } else if (entity instanceof Distribution) {
2651
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2652
                    style);
2653
        } else if (entity instanceof IndividualsAssociation) {
2654
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2655
                    (IndividualsAssociation) entity, style);
2656
        } else if (entity instanceof QuantitativeData) {
2657
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2658
                    (QuantitativeData) entity, style);
2659
        } else if (entity instanceof TaxonInteraction) {
2660
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2661
                    (TaxonInteraction) entity, style);
2662
        } else if (entity instanceof TextData) {
2663
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2664
        } else {
2665
            throw new IllegalStateException("There is no interface for the given description element");
2666
        }
2667
        adapt(detailedDescriptionElement);
2668
        parentElement.addElement(detailedDescriptionElement);
2669
        return detailedDescriptionElement;
2670

    
2671
    }
2672

    
2673
    /**
2674
     * Creates a styled text as a part of the form.
2675
     *
2676
     * @param parent
2677
     *            the text parent
2678
     * @param value
2679
     *            the text initial value
2680
     * @param style
2681
     *            the text style
2682
     * @return the text widget
2683
     */
2684
    public StyledText createStyledText(Composite parent, String value, int style) {
2685
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2686
        if (value != null) {
2687
            text.setText(value);
2688
        }
2689
        text.setForeground(getColors().getForeground());
2690
        text.setBackground(getColors().getBackground());
2691
        // text.addFocusListener(visibilityHandler);
2692
        return text;
2693
    }
2694

    
2695
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2696
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2697
        addAndAdaptSection(parentElement, section);
2698
        return section;
2699
    }
2700

    
2701
}
(6-6/39)