Project

General

Profile

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

    
307
/**
308
 * <p>
309
 * CdmFormFactory class.
310
 * </p>
311
 *
312
 * @author n.hoffmann
313
 * @created Feb 24, 2010
314
 * @version 1.0
315
 */
316
public class CdmFormFactory extends FormToolkit {
317

    
318
    private BoldFontHolder2 boldFontHolder2;
319
    private MouseListener selectionMouseHandler;
320
    private FocusListener selectionFocusHandler;
321

    
322
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
323

    
324
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
325

    
326
    private final int orientation = Window.getDefaultOrientation();
327
    private ISelectionProvider selectionProvider;
328

    
329
    /** Constant <code>EMPTY_SELECTION</code> */
330
    public static ISelection EMPTY_SELECTION = new ISelection() {
331
        @Override
332
        public boolean isEmpty() {
333
            return true;
334
        }
335
    };
336

    
337
    /**
338
     *
339
     * @author n.hoffmann
340
     * @date Jan 25, 2010
341
     *
342
     */
343
    private class SelectionMouseHandler extends MouseAdapter {
344
        @Override
345
        public void mouseDown(MouseEvent e) {
346
            notifySelectionListeners(e);
347
        }
348
    }
349

    
350
    /**
351
     *
352
     * @author n.hoffmann
353
     * @date Jan 25, 2010
354
     *
355
     */
356
    private class SelectionFocusHandler extends FocusAdapter {
357
        @Override
358
        public void focusGained(FocusEvent e) {
359
            notifySelectionListeners(e);
360
        }
361
    }
362

    
363
    private void notifySelectionListeners(TypedEvent e) {
364
        Event event = new Event();
365
        event.widget = e.widget;
366
        SelectionEvent selectionEvent = new SelectionEvent(event);
367

    
368
        for (SelectionListener listener : selectionListenerList) {
369
            listener.widgetSelected(selectionEvent);
370
        }
371
    }
372

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

    
389
    /**
390
     * <p>
391
     * Constructor for CdmFormFactory.
392
     * </p>
393
     *
394
     * @param display
395
     *            a {@link org.eclipse.swt.widgets.Display} object.
396
     */
397
    public CdmFormFactory(Display display) {
398
        super(display);
399
        init();
400
    }
401

    
402
    /**
403
	 *
404
	 */
405
    private void init() {
406
        boldFontHolder2 = new BoldFontHolder2();
407
        selectionMouseHandler = new SelectionMouseHandler();
408
        selectionFocusHandler = new SelectionFocusHandler();
409
    }
410

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

    
431
    /**
432
     * <p>
433
     * destroySelectionArbitrator
434
     * </p>
435
     *
436
     * @param selectionArbitrator
437
     *            a
438
     *            {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
439
     *            object.
440
     */
441
    public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
442
        removeSelectionListener(selectionArbitrator);
443
        if (selectionProvider != null) {
444
            selectionProvider.removeSelectionChangedListener(selectionArbitrator);
445
        } else {
446
            MessagingUtils.error(this.getClass(),
447
                    "Tried to destroy a selection listener from this factories listeners but was null", null);
448
        }
449
    }
450

    
451
    /**
452
     * <p>
453
     * Adapts the {@link AbstractCdmFormElement}:<br>
454
     * - sets the {@link IPropertyChangeListener}s handled by this class
455
     * </p>
456
     *
457
     * @param formElement
458
     *            a
459
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
460
     *            object.
461
     */
462
    public void adapt(ICdmFormElement formElement) {
463
        formElement.setPropertyChangeListeners(propertyChangeListeners);
464
    }
465

    
466
    /** {@inheritDoc} */
467
    @Override
468
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
469
        if (trackFocus) {
470
            control.addFocusListener(selectionFocusHandler);
471
        }
472
        super.adapt(control, trackFocus, trackKeyboard);
473
    }
474

    
475
    /** {@inheritDoc} */
476
    @Override
477
    public void adapt(Composite composite) {
478
        composite.addMouseListener(selectionMouseHandler);
479
        super.adapt(composite);
480
    }
481

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

    
523
    /**
524
     * <p>
525
     * createEmptyCell
526
     * </p>
527
     *
528
     * @param parent
529
     *            a {@link org.eclipse.swt.widgets.Composite} object.
530
     * @return a {@link org.eclipse.swt.widgets.Label} object.
531
     */
532
    public Label createEmptyCell(Composite parent) {
533
        return this.createLabel(parent, null);
534
    }
535

    
536
    /**
537
     * <p>
538
     * createMultiLanguageTextElement
539
     * </p>
540
     *
541
     * @param parentElement
542
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
543
     *            object.
544
     * @param labelString
545
     *            a {@link java.lang.String} object.
546
     * @param multilanguageText
547
     *            a {@link java.util.Map} object.
548
     * @param textHeight
549
     *            a int.
550
     * @param style
551
     *            a int.
552
     * @return a
553
     *         {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
554
     *         object.
555
     */
556
    public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
557
            Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
558
        MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
559
                multilanguageText, textHeight, style);
560
        adapt(element);
561
        parentElement.addElement(element);
562
        return element;
563
    }
564

    
565
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
566
            KeyStatement keyStatement, int textHeight, int style) {
567
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
568
                textHeight, style);
569
        adapt(element);
570
        parentElement.addElement(element);
571
        return element;
572
    }
573

    
574
    /**
575
     * Creates a text field with a label. The initial content will be the return value of the initalObject's {@link #toString()}
576
     * method.<br>
577
     * <b>Note</b>: if initialObject is <code>null</code> then an empty string is used.
578
     * @param parentElement the parent container
579
     * @param labelString the label name
580
     * @param initialObject the object from which the <code>toString()</code> method is called
581
     * @param style {@link SWT} style constant
582
     * @return the created textfield with label
583
     */
584
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
585
            Object initialObject, int style) {
586
        return createTextWithLabelElement(parentElement, labelString, initialObject==null?"":initialObject.toString(), style);
587
    }
588

    
589
    /**
590
     * <p>
591
     * createTextWithLabelElement
592
     * </p>
593
     *
594
     * @param parentElement
595
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
596
     *            object.
597
     * @param labelString
598
     *            a {@link java.lang.String} object.
599
     * @param initialText
600
     *            a {@link java.lang.String} object.
601
     * @param style
602
     *            a int.
603
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
604
     *         object.
605
     */
606
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
607
            String initialText, int style) {
608
        return createTextWithLabelElement(parentElement, labelString, initialText, null, style);
609
    }
610
    /**
611
     * <p>
612
     * createTextWithLabelElement
613
     * </p>
614
     *
615
     * @param parentElement
616
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
617
     *            object.
618
     * @param labelString
619
     *            a {@link java.lang.String} object.
620
     * @param initialText
621
     *            a {@link java.lang.String} object.
622
     * @param textLimit maximal number of characters allowed
623
     * @param style
624
     *            a int.
625
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
626
     *         object.
627
     */
628
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
629
            String initialText, Integer textLimit, int style) {
630
        if(initialText==null){
631
            initialText = "";
632
        }
633

    
634
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
635
                textLimit, style);
636
        adapt(element);
637
        parentElement.addElement(element);
638
        return element;
639
    }
640

    
641
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
642
            int textHeight, int style) {
643
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
644
        adapt(element);
645
        parentElement.addElement(element);
646
        return element;
647
    }
648

    
649
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
650
            URI initialUri, int style) {
651
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
652
        adapt(element);
653
        parentElement.addElement(element);
654
        return element;
655
    }
656

    
657
    /**
658
     * @param element
659
     * @param string
660
     * @param uri
661
     * @param style
662
     * @return
663
     */
664
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
665
            IOpenUrlEnabled openUrlEnabled, int style) {
666
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
667
                style);
668
        adapt(element);
669
        parentElement.addElement(element);
670
        return element;
671
    }
672

    
673
    /**
674
     *
675
     * @param parentElement
676
     * @param labelString
677
     * @param conversationEnabled
678
     * @param user
679
     * @param style
680
     * @return
681
     */
682
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
683
            ConversationHolder conversation, User user, int style) {
684
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
685
        adapt(element);
686
        parentElement.addElement(element);
687
        return element;
688
    }
689

    
690
    /**
691
     * <p>
692
     * createIntegerTextWithLabelElement
693
     * </p>
694
     *
695
     * @param parentElement
696
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
697
     *            object.
698
     * @param labelString
699
     *            a {@link java.lang.String} object.
700
     * @param initialInteger
701
     *            a {@link java.lang.Integer} object.
702
     * @param style
703
     *            a int.
704
     * @return a
705
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
706
     *         object.
707
     */
708
	public NumberWithLabelElement createNumberTextWithLabelElement(
709
			ICdmFormElement parentElement, String labelString,
710
			Number initialNumber, int style) {
711
		NumberWithLabelElement element = new NumberWithLabelElement(this,
712
				parentElement, labelString, initialNumber, style);
713
		adapt(element);
714
		parentElement.addElement(element);
715
		return element;
716
	}
717

    
718
    /**
719
     * <p>
720
     * createLanguageStringWithLabelElement
721
     * </p>
722
     *
723
     * @param parentElement
724
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
725
     *            object.
726
     * @param labelString
727
     *            a {@link java.lang.String} object.
728
     * @param languageString
729
     *            a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
730
     * @param style
731
     *            a int.
732
     * @return a
733
     *         {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement}
734
     *         object.
735
     */
736
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
737
            String labelString, LanguageString languageString, int style) {
738
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
739
                languageString, style);
740
        adapt(element);
741
        parentElement.addElement(element);
742
        return element;
743
    }
744

    
745
    /**
746
     * <p>
747
     * createLanguageStringWithLabelElement
748
     * </p>
749
     *
750
     * @param parentElement
751
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
752
     *            object.
753
     * @param labelString
754
     *            a {@link java.lang.String} object.
755
     * @param languageString
756
     *            a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
757
     * @param height
758
     *            a int.
759
     * @param style
760
     *            a int.
761
     * @return a
762
     *         {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement}
763
     *         object.
764
     */
765
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
766
            String labelString, LanguageString languageString, int height, int style) {
767
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
768
                languageString, height, style);
769
        adapt(element);
770
        parentElement.addElement(element);
771
        return element;
772
    }
773

    
774

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

    
800
    /**
801
     * <p>
802
     * createTermComboElement
803
     * </p>
804
     *
805
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
806
     * @param termComboType
807
     *            a
808
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
809
     *            object.
810
     * @param parentElement
811
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
812
     *            object.
813
     * @param labelString
814
     *            a {@link java.lang.String} object.
815
     * @param selection
816
     *            a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
817
     *            object.
818
     * @param style
819
     *            a int.
820
     * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
821
     *         object.
822
     */
823
    @Deprecated
824
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
825
            ICdmFormElement parentElement, String labelString, T selection, int style) {
826
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString,
827
                selection, style);
828
        adapt(element);
829
        parentElement.addElement(element);
830
        return element;
831
    }
832

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

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

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

    
891
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
892
	        TermVocabulary<?> termVocabulary,
893
	        ICdmFormElement parentElement,
894
	        String labelString,
895
	        T selection,
896
	        int style) {
897
	    TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, style);
898
	    adapt(element);
899
	    parentElement.addElement(element);
900
	    return element;
901
	}
902

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

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

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

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

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

    
1027
    /**
1028
     * Creates a section as a part of the form.
1029
     *
1030
     * @return the section widget
1031
     * @param section
1032
     *            a
1033
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1034
     *            object.
1035
     */
1036
    public Section adapt(AbstractFormSection section) {
1037
        section.setMenu(section.getLayoutComposite().getMenu());
1038
        adapt(section, true, true);
1039

    
1040
        // handle focus and property change events for cdm use
1041
        section.addFocusListener(selectionFocusHandler);
1042
        section.setPropertyChangeListeners(propertyChangeListeners);
1043

    
1044
        if (section.getToggle() != null) {
1045
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1046
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1047
        }
1048

    
1049
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1050

    
1051
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1052
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1053
            getColors().initializeSectionToolBarColors();
1054
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1055
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1056
        }
1057
        // call setTitleBarForeground regardless as it also sets the label color
1058
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1059
        return section;
1060
    }
1061

    
1062
    private class BoldFontHolder2 {
1063
        private Font normalFont;
1064

    
1065
        private Font boldFont;
1066

    
1067
        public BoldFontHolder2() {
1068
        }
1069

    
1070
        public Font getBoldFont(Font font) {
1071
            createBoldFont(font);
1072
            return boldFont;
1073
        }
1074

    
1075
        private void createBoldFont(Font font) {
1076
            if (normalFont == null || !normalFont.equals(font)) {
1077
                normalFont = font;
1078
                dispose();
1079
            }
1080
            if (boldFont == null) {
1081
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1082
            }
1083
        }
1084

    
1085
        public void dispose() {
1086
            if (boldFont != null) {
1087
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1088
                boldFont = null;
1089
            }
1090
        }
1091
    }
1092

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

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

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

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

    
1201

    
1202

    
1203
    /**
1204
     * @param conversationHolder
1205
     * @param parent
1206
     * @param detailsViewer
1207
     * @param i
1208
     * @return
1209
     */
1210
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1211
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1212
        parentElement.addElement(section);
1213
        adapt(section);
1214
        return section;
1215
    }
1216

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

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

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

    
1282
    /**
1283
     * <p>
1284
     * addSelectionListener
1285
     * </p>
1286
     *
1287
     * @param listener
1288
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1289
     */
1290
    public void addSelectionListener(SelectionListener listener) {
1291
        selectionListenerList.add(listener);
1292
    }
1293

    
1294
    /**
1295
     * <p>
1296
     * removeSelectionListener
1297
     * </p>
1298
     *
1299
     * @param listener
1300
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1301
     */
1302
    public void removeSelectionListener(SelectionListener listener) {
1303
        if (listener == null) {
1304
            MessagingUtils.error(this.getClass(),
1305
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1306
        } else {
1307
            selectionListenerList.remove(listener);
1308
        }
1309
    }
1310

    
1311
    /**
1312
     * <p>
1313
     * addPropertyChangeListener
1314
     * </p>
1315
     *
1316
     * @param listener
1317
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1318
     *            object.
1319
     */
1320
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1321
        if (propertyChangeListeners.contains(listener)) {
1322
            return;
1323
        }
1324
        propertyChangeListeners.add(0, listener);
1325
    }
1326

    
1327
    /**
1328
     * <p>
1329
     * removePropertyChangeListener
1330
     * </p>
1331
     *
1332
     * @param listener
1333
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1334
     *            object.
1335
     */
1336
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1337
        propertyChangeListeners.remove(listener);
1338
    }
1339

    
1340
    /**
1341
     * @return the propertyChangeListeners
1342
     */
1343
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1344
        return propertyChangeListeners;
1345
    }
1346

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

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

    
1389
    /**
1390
     * @param cdmBaseSection
1391
     * @param object
1392
     * @param style
1393
     * @return
1394
     */
1395
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1396
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1397
        adapt(element);
1398
        parentElement.addElement(element);
1399
        return element;
1400
    }
1401

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

    
1423
    /**
1424
     * @param parent
1425
     * @param i
1426
     * @return
1427
     */
1428
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1429
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1430
        parentElement.addElement(section);
1431
        adapt(section);
1432
        return section;
1433
    }
1434

    
1435
    /**
1436
     * <p>
1437
     * createEmptyElement
1438
     * </p>
1439
     *
1440
     * @param parentElement
1441
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1442
     *            object.
1443
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1444
     */
1445
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1446
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1447
        adapt(element);
1448
        parentElement.addElement(element);
1449
        return element;
1450
    }
1451

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

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

    
1496
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1497
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1498

    
1499
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1500
                selectionProvider, style);
1501

    
1502
        parentElement.addElement(section);
1503
        adapt(section);
1504
        return section;
1505

    
1506
    }
1507

    
1508
    /**
1509
     * @param definedTermClass
1510
     * @param formElement
1511
     * @param style
1512
     * @return
1513
     */
1514
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1515
            AbstractCdmDetailSection parentElement, int style) {
1516
        AbstractCdmDetailElement element = null;
1517

    
1518
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1519
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1520
        } else if (definedTermClass.equals(Feature.class)) {
1521
            element = new FeatureDetailElement(this, parentElement);
1522
        } else {
1523
            element = new DefinedTermDetailElement(this, parentElement);
1524
        }
1525

    
1526
        adapt(element);
1527
        parentElement.addElement(element);
1528
        return element;
1529
    }
1530

    
1531

    
1532
    //--------DetailSections---------
1533
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1534
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1535
        addAndAdaptSection(parentElement, section);
1536
        return section;
1537
    }
1538

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

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

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

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

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

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

    
1575
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1576
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1577
        addAndAdaptSection(parentElement, section);
1578
        return section;
1579
    }
1580

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1845
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1846
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
1847
        addAndAdaptSection(parentElement, section);
1848
        return section;
1849
    }
1850

    
1851
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1852
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
1853
        addAndAdaptSection(parentElement, section);
1854
        return section;
1855
    }
1856

    
1857
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1858
        parentElement.addElement(section);
1859
        adapt(section);
1860
    }
1861

    
1862
    //--------DetailElements------------
1863

    
1864
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1865
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1866
        addAndAdaptElement(parentElement, element);
1867
        return element;
1868
    }
1869

    
1870
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1871
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1872
        addAndAdaptElement(parentElement, element);
1873
        return element;
1874
    }
1875

    
1876
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1877
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1878
        addAndAdaptElement(parentElement, element);
1879
        return element;
1880
    }
1881

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1972
    public DerivedUnitFacadeDetailElement createDerivedUnitFacadeDetailElement(ICdmFormElement parentElement){
1973
        DerivedUnitFacadeDetailElement element = new DerivedUnitFacadeDetailElement(this, parentElement);
1974
        addAndAdaptElement(parentElement, element);
1975
        return element;
1976
    }
1977

    
1978
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
1979
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
1980
        addAndAdaptElement(parentElement, element);
1981
        return element;
1982
    }
1983

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

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

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

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

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

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

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

    
2026
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
2027
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
2028
        addAndAdaptElement(parentElement, element);
2029
        return element;
2030
    }
2031

    
2032
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2033
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2034
        addAndAdaptElement(parentElement, element);
2035
        return element;
2036
    }
2037

    
2038

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

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

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

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

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

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

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

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

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

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

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

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

    
2111
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2112
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2113
        addAndAdaptElement(parentElement, element);
2114
        return element;
2115
    }
2116

    
2117
    public SpecimenScanGeneralDetailElement createSpecimenScanGeneralDetailElement(ICdmFormElement parentElement){
2118
        SpecimenScanGeneralDetailElement element = new SpecimenScanGeneralDetailElement(this, parentElement);
2119
        addAndAdaptElement(parentElement, element);
2120
        return element;
2121
    }
2122

    
2123
    public LivingPlantPhotoGeneralDetailElement createLivingPlantPhotoGeneralDetailElement(ICdmFormElement parentElement){
2124
        LivingPlantPhotoGeneralDetailElement element = new LivingPlantPhotoGeneralDetailElement(this, parentElement);
2125
        addAndAdaptElement(parentElement, element);
2126
        return element;
2127
    }
2128

    
2129
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2130
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2131
        addAndAdaptElement(parentElement, element);
2132
        return element;
2133
    }
2134

    
2135
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2136
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2137
        addAndAdaptElement(parentElement, mediaDetailElement);
2138
        return mediaDetailElement;
2139
    }
2140

    
2141
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2142
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2143
        addAndAdaptElement(parentElement, element);
2144
        return element;
2145
    }
2146

    
2147
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2148
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2149
        addAndAdaptElement(parentElement, element);
2150
        return element;
2151
    }
2152

    
2153

    
2154
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2155
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2156
        addAndAdaptElement(parentElement, element);
2157
        return element;
2158
    }
2159

    
2160
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2161
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2162
        addAndAdaptElement(parentElement, element);
2163
        return element;
2164
    }
2165

    
2166
    public PreservedSpecimenDeterminationDetailElement createPreservedSpecimenDeterminationDetailElement(ICdmFormElement parentElement) {
2167
        PreservedSpecimenDeterminationDetailElement element = new PreservedSpecimenDeterminationDetailElement(this, parentElement);
2168
        addAndAdaptElement(parentElement, element);
2169
        return element;
2170
    }
2171

    
2172
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2173
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2174
        addAndAdaptElement(parentElement, element);
2175
        return element;
2176
    }
2177

    
2178
    /**
2179
     * @param parentElement
2180
     * @param element
2181
     */
2182
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2183
        adapt(element);
2184
        parentElement.addElement(element);
2185
    }
2186

    
2187
    //--------EntityCollectionSection----------
2188
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2189
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style);
2190
        addAndAdaptSection(parentElement, section);
2191
        return section;
2192
    }
2193

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2380
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2381
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2382
        addAndAdaptSection(parentElement, section);
2383
        return section;
2384
    }
2385

    
2386
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2387
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2388
        addAndAdaptSection(parentElement, section);
2389
        return section;
2390
    }
2391

    
2392
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2393
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2394
        addAndAdaptSection(parentElement, section);
2395
        return section;
2396
    }
2397

    
2398
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2399
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2400
        addAndAdaptSection(parentElement, section);
2401
        return section;
2402
    }
2403

    
2404
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2405
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2406
        addAndAdaptSection(parentElement, section);
2407
        return section;
2408
    }
2409

    
2410
    /**
2411
     * <p>
2412
     * createEntityCollectionElement
2413
     * </p>
2414
     *
2415
     * @param removeListener
2416
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
2417
     * @param style
2418
     *            a int.
2419
     * @param parentElement
2420
     *            a
2421
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
2422
     *            object.
2423
     * @param versionableEntity
2424
     *            a {@link eu.etaxonomy.cdm.model.common.IVersionableEntity}
2425
     *            object.
2426
     * @param backgroundColor
2427
     *            a {@link org.eclipse.swt.graphics.Color} object.
2428
     * @return a
2429
     *         {@link eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement}
2430
     *         object.
2431
     */
2432
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2433
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2434
        AbstractEntityCollectionElement element = null;
2435

    
2436
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2437

    
2438
        if (entity instanceof Annotation) {
2439
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2440
        } else if (entity instanceof Person) {
2441
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
2442
        } else if (entity instanceof Credit) {
2443
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2444
        } else if (entity instanceof Extension) {
2445
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2446
        } else if (entity instanceof Marker) {
2447
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2448
        } else if (entity instanceof Media) {
2449
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2450
        } else if (entity instanceof MediaRepresentation) {
2451
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2452
                    style);
2453
        } else if (entity instanceof ImageFile) {
2454
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2455
        } else if (entity instanceof MediaRepresentationPart) {
2456
            element = new MediaRepresentationPartElement(this, parentElement, (MediaRepresentationPart) entity,
2457
                    removeListener, style);
2458
        } else if (entity instanceof NomenclaturalStatus) {
2459
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2460
                    style);
2461
        } else if (entity instanceof Rights) {
2462
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2463
        } else if (entity instanceof DescriptionElementSource) {
2464
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2465
                    removeListener, style);
2466
        } else if (entity instanceof IdentifiableSource) {
2467
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2468
                    style);
2469
		} else if (entity instanceof DefinedTerm) {
2470
			switch(((DefinedTerm)entity).getTermType()) {
2471
				case Scope:
2472
					element = new ScopeElement(this,
2473
							parentElement,
2474
							(DefinedTerm) entity,
2475
							removeListener,
2476
							style);
2477
					break;
2478
				case Modifier:
2479
					element = new ModifierElement(this,
2480
							parentElement,
2481
							(DefinedTerm) entity,
2482
							removeListener,
2483
							style);
2484
					break;
2485
				default:
2486
					//FIXME : Actually we should through an exception here
2487
					element = null;
2488
					break;
2489

    
2490
			}
2491
        } else if (entity instanceof Reference) {
2492
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2493
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2494
            }
2495
            else{
2496
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2497
            }
2498
        } else if (entity instanceof NameTypeDesignation) {
2499
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2500
                    style);
2501
        } else if (entity instanceof NameRelationship) {
2502
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2503
                    style);
2504
        } else if (entity instanceof SynonymRelationship) {
2505
            element = new SynonymRelationshipDetailElement(this, parentElement, (SynonymRelationship) entity, removeListener,
2506
                    style);
2507
        } else if (entity instanceof SpecimenTypeDesignation) {
2508
            element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2509
                    removeListener, style);
2510
        } else if (entity instanceof StateData) {
2511
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2512
        } else if (entity instanceof StatisticalMeasurementValue) {
2513
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2514
                    removeListener, style);
2515
        } else if (entity instanceof DerivedUnit) {
2516
        	switch(((DerivedUnit)entity).getRecordBasis()) {
2517
				case LivingSpecimen:
2518
				case PreservedSpecimen:
2519
				case OtherSpecimen:
2520
					element = new SpecimenCollectionDetailElement(this,
2521
								parentElement,
2522
								(DerivedUnit) entity,
2523
								removeListener,
2524
								style);
2525
					break;
2526
				default:
2527
					element = new DerivedUnitElement(this,
2528
								parentElement,
2529
								(DerivedUnit) entity,
2530
								removeListener,
2531
								style);
2532
			}
2533

    
2534
        } else if (entity instanceof NamedArea) {
2535
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2536
        } else if (entity instanceof DeterminationEvent) {
2537
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2538
        } else if (entity instanceof User) {
2539
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2540
        } else if (entity instanceof GrantedAuthority) {
2541
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity,
2542
                    removeListener, style);
2543
        } else if (entity instanceof Group) {
2544
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2545
        } else if (entity instanceof Taxon) {
2546
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2547
        } else if (entity instanceof DescriptionElementBase) {
2548
            // this is the special case for protologs, maybe we can do this
2549
            // differently when API improves
2550
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2551
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2552
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2553
            }
2554
        }
2555

    
2556
        if (element == null) {
2557
            MessagingUtils.messageDialog("No element for entity", this,
2558
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2559
                            + entity, null);
2560
        }
2561

    
2562
        else{
2563
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2564
                element.setPersistentBackground(backgroundColor);
2565
            }
2566
            adapt(element);
2567
            parentElement.addElement(element);
2568
        }
2569

    
2570
        return element;
2571
    }
2572

    
2573
    /**
2574
     * <p>
2575
     * Creates a selection element for the given type T.
2576
     * </p>
2577
     * <p>
2578
     * <strong>Selection elements not handled by this method:</strong>
2579
     * <ul>
2580
     * <li>{@link TaxonNodeSelectionElement} see
2581
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2582
     * </li>
2583
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2584
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2585
     * </li>
2586
     * </ul>
2587
     * </p>
2588
     *
2589
     * @param clazz
2590
     *            a {@link Class} object of the type that you want the selection
2591
     *            element to handle
2592
     * @param parentElement
2593
     *            a {@link ICdmFormElement} object.
2594
     * @param labelString
2595
     *            a {@link String} object.
2596
     * @param selectionType
2597
     * @param selection
2598
     *            a {@link ICdmBase} object.
2599
     * @param style
2600
     *            a int.
2601
     * @param conversation
2602
     *            a {@link ConversationHolder} object.
2603
     * @return a {@link EntitySelectionElement} object.
2604
     */
2605
    public <T extends ICdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2606
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2607
            int style) {
2608
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2609
                labelString, selection, mode, style);
2610
        adapt(element);
2611
        parentElement.addElement(element);
2612
        return element;
2613
    }
2614

    
2615
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2616
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2617
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2618
                labelString, selection, mode, style);
2619
        adapt(element);
2620
        parentElement.addElement(element);
2621
        return element;
2622
    }
2623

    
2624
    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2625
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2626
            int mode, int style) {
2627
        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2628
                conversation, parentElement, labelString, selection, mode, style);
2629
        adapt(element);
2630
        parentElement.addElement(element);
2631
        return element;
2632
    }
2633

    
2634
    /** {@inheritDoc} */
2635
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2636
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2637
        adapt(labelElement);
2638
        parentElement.addElement(labelElement);
2639
        return labelElement;
2640
    }
2641

    
2642
    /**
2643
     * <p>
2644
     * Getter for the field <code>selectionProvider</code>.
2645
     * </p>
2646
     *
2647
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2648
     */
2649
    public ISelectionProvider getSelectionProvider() {
2650
        return selectionProvider;
2651
    }
2652

    
2653
    /**
2654
     * <p>
2655
     * createDetailedDescriptionDetailElement
2656
     * </p>
2657
     *
2658
     * @param parentElement
2659
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2660
     *            object.
2661
     * @param entity
2662
     *            a
2663
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2664
     *            object.
2665
     * @param style
2666
     *            a int.
2667
     * @return a
2668
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2669
     *         object.
2670
     */
2671
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2672
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2673
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2674

    
2675
        if (entity instanceof CategoricalData) {
2676
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2677
                    (CategoricalData) entity, style);
2678
        } else if (entity instanceof CommonTaxonName) {
2679
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2680
                    style);
2681
        } else if (entity instanceof Distribution) {
2682
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2683
                    style);
2684
        } else if (entity instanceof IndividualsAssociation) {
2685
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2686
                    (IndividualsAssociation) entity, style);
2687
        } else if (entity instanceof QuantitativeData) {
2688
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2689
                    (QuantitativeData) entity, style);
2690
        } else if (entity instanceof TaxonInteraction) {
2691
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2692
                    (TaxonInteraction) entity, style);
2693
        } else if (entity instanceof TextData) {
2694
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2695
        } else {
2696
            throw new IllegalStateException("There is no interface for the given description element");
2697
        }
2698
        adapt(detailedDescriptionElement);
2699
        parentElement.addElement(detailedDescriptionElement);
2700
        return detailedDescriptionElement;
2701

    
2702
    }
2703

    
2704
    /**
2705
     * Creates a styled text as a part of the form.
2706
     *
2707
     * @param parent
2708
     *            the text parent
2709
     * @param value
2710
     *            the text initial value
2711
     * @param style
2712
     *            the text style
2713
     * @return the text widget
2714
     */
2715
    public StyledText createStyledText(Composite parent, String value, int style) {
2716
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2717
        if (value != null) {
2718
            text.setText(value);
2719
        }
2720
        text.setForeground(getColors().getForeground());
2721
        text.setBackground(getColors().getBackground());
2722
        // text.addFocusListener(visibilityHandler);
2723
        return text;
2724
    }
2725

    
2726
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2727
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2728
        addAndAdaptSection(parentElement, section);
2729
        return section;
2730
    }
2731

    
2732
    /**
2733
     * @param parentElement
2734
     * @return
2735
     */
2736
    public OriginalLabelDataController createOriginalLabelDataController(AbstractCdmDetailSection<DerivedUnitFacade> parentElement) {
2737
        OriginalLabelDataElement originalLabelDataElement = new OriginalLabelDataElement(parentElement.getLayoutComposite(), SWT.NONE);
2738
        originalLabelDataElement.initController(this, parentElement);
2739
        return originalLabelDataElement.getController();
2740
    }
2741

    
2742
}
(6-6/39)