Project

General

Profile

Download (124 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.DateTime;
41
import org.joda.time.Partial;
42
import org.springframework.security.core.GrantedAuthority;
43

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

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

    
321
    private BoldFontHolder2 boldFontHolder2;
322
    private MouseListener selectionMouseHandler;
323
    private FocusListener selectionFocusHandler;
324

    
325
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
326

    
327
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
328

    
329
    private final int orientation = Window.getDefaultOrientation();
330
    private ISelectionProvider selectionProvider;
331

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

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

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

    
366
    private void notifySelectionListeners(TypedEvent e) {
367
        Event event = new Event();
368
        event.widget = e.widget;
369
        SelectionEvent selectionEvent = new SelectionEvent(event);
370

    
371
        for (SelectionListener listener : selectionListenerList) {
372
            listener.widgetSelected(selectionEvent);
373
        }
374
    }
375

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

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

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

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

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

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

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

    
478
    /** {@inheritDoc} */
479
    @Override
480
    public void adapt(Composite composite) {
481
        composite.addMouseListener(selectionMouseHandler);
482
        super.adapt(composite);
483
    }
484

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

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

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

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

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

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

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

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

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

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

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

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

    
721
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
722
            String labelString, LanguageString languageString, int style) {
723
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
724
    }
725

    
726
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
727
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
728
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
729
                languageString, height, isMultiLine, style);
730
        adapt(element);
731
        parentElement.addElement(element);
732
        return element;
733
    }
734

    
735
    /**
736
     * <p>
737
     * createKeyValueViewerElement
738
     * </p>
739
     *
740
     * @param parentElement
741
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
742
     *            object.
743
     * @param keyHeading
744
     *            a {@link java.lang.String} object.
745
     * @param valueHeading
746
     *            a {@link java.lang.String} object.
747
     * @param map
748
     *            a {@link java.util.Map} object.
749
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
750
     *         object.
751
     */
752
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
753
            String valueHeading, Map<Object, Object> map) {
754
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
755
        adapt(element);
756
        parentElement.addElement(element);
757
        return element;
758
    }
759

    
760
    /**
761
     * <p>
762
     * createTermComboElement
763
     * </p>
764
     *
765
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
766
     * @param termComboType
767
     *            a
768
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
769
     *            object.
770
     * @param parentElement
771
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
772
     *            object.
773
     * @param labelString
774
     *            a {@link java.lang.String} object.
775
     * @param selection
776
     *            a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
777
     *            object.
778
     * @param style
779
     *            a int.
780
     * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
781
     *         object.
782
     */
783
    @Deprecated
784
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
785
            ICdmFormElement parentElement, String labelString, T selection, int style) {
786
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString,
787
                selection, style);
788
        adapt(element);
789
        parentElement.addElement(element);
790
        return element;
791
    }
792

    
793
	/**
794
	 * <p>
795
	 * createTermComboElement
796
	 * </p>
797
	 *
798
	 * @param termComboType
799
	 *            a
800
	 *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
801
	 *            object.
802
	 * @param parentElement
803
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
804
	 *            object.
805
	 * @param labelString
806
	 *            a {@link java.lang.String} object.
807
	 * @param selection
808
	 *            a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
809
	 *            object.
810
	 * @param style
811
	 *            a int.
812
	 * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
813
	 *         object.
814
	 */
815

    
816
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
817
			TermType termType,
818
			ICdmFormElement parentElement,
819
			String labelString,
820
			T selection,
821
			int style) {
822
		TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, style);
823
		adapt(element);
824
		parentElement.addElement(element);
825
		return element;
826
	}
827

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

    
851
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
852
	        TermVocabulary<?> termVocabulary,
853
	        ICdmFormElement parentElement,
854
	        String labelString,
855
	        T selection,
856
	        int style) {
857
	    TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, style);
858
	    adapt(element);
859
	    parentElement.addElement(element);
860
	    return element;
861
	}
862

    
863
    /**
864
     * <p>
865
     * createEnumComboElement
866
     * </p>
867
     *
868
     * @param enumComboType
869
     *            a
870
     *            {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType}
871
     *            object.
872
     * @param parentElement
873
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
874
     *            object.
875
     * @param style
876
     *            a int.
877
     * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
878
     *         object.
879
     */
880
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
881
			Class<T> enumComboType, ICdmFormElement parentElement,
882
			int style) {
883
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
884
        adapt(element);
885
        parentElement.addElement(element);
886
        return element;
887
    }
888

    
889
    /**
890
     * <p>
891
     * createBrowserElement
892
     * </p>
893
     *
894
     * @param imageUri
895
     *            a {@link java.net.URI} object.
896
     * @param style
897
     *            a int.
898
     * @param parentElement
899
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
900
     *            object.
901
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
902
     *         object.
903
     */
904
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
905
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
906
        adapt(element);
907
        parentElement.addElement(element);
908
        return element;
909
    }
910

    
911
    /**
912
     * <p>
913
     * createImageElement
914
     * </p>
915
     *
916
     * @param parentElement
917
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
918
     *            object.
919
     * @param imageUri
920
     *            a {@link java.net.URI} object.
921
     * @param style
922
     *            a int.
923
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
924
     */
925
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
926
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
927
        adapt(element);
928
        parentElement.addElement(element);
929
        return element;
930
    }
931

    
932
    /**
933
     * <p>
934
     * createTextActionElement
935
     * </p>
936
     *
937
     * @param labelString
938
     *            a {@link java.lang.String} object.
939
     * @param initialText
940
     *            a {@link java.lang.String} object.
941
     * @param style
942
     *            a int.
943
     * @param parentElement
944
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
945
     *            object.
946
     * @param buttonLabel
947
     *            a {@link java.lang.String} object.
948
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
949
     *         object.
950
     */
951
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
952
            String buttonLabel, String initialText, int style) {
953
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
954
                style);
955
        adapt(element);
956
        parentElement.addElement(element);
957
        return element;
958
    }
959

    
960
    /**
961
     * <p>
962
     * createCheckbox
963
     * </p>
964
     *
965
     * @param parentElement
966
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
967
     *            object.
968
     * @param label
969
     *            a {@link java.lang.String} object.
970
     * @param initialState
971
     *            a boolean.
972
     * @param style
973
     *            a int.
974
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
975
     *         object.
976
     */
977
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
978
        if(initialState==null){
979
            initialState = Boolean.FALSE;
980
        }
981
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
982
        adapt(element);
983
        parentElement.addElement(element);
984
        return element;
985
    }
986

    
987
    /**
988
     * Creates a section as a part of the form.
989
     *
990
     * @return the section widget
991
     * @param section
992
     *            a
993
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
994
     *            object.
995
     */
996
    public Section adapt(AbstractFormSection section) {
997
        section.setMenu(section.getLayoutComposite().getMenu());
998
        adapt(section, true, true);
999

    
1000
        // handle focus and property change events for cdm use
1001
        section.addFocusListener(selectionFocusHandler);
1002
        section.setPropertyChangeListeners(propertyChangeListeners);
1003

    
1004
        if (section.getToggle() != null) {
1005
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1006
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1007
        }
1008

    
1009
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1010

    
1011
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1012
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1013
            getColors().initializeSectionToolBarColors();
1014
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1015
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1016
        }
1017
        // call setTitleBarForeground regardless as it also sets the label color
1018
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1019
        return section;
1020
    }
1021

    
1022
    private class BoldFontHolder2 {
1023
        private Font normalFont;
1024

    
1025
        private Font boldFont;
1026

    
1027
        public BoldFontHolder2() {
1028
        }
1029

    
1030
        public Font getBoldFont(Font font) {
1031
            createBoldFont(font);
1032
            return boldFont;
1033
        }
1034

    
1035
        private void createBoldFont(Font font) {
1036
            if (normalFont == null || !normalFont.equals(font)) {
1037
                normalFont = font;
1038
                dispose();
1039
            }
1040
            if (boldFont == null) {
1041
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1042
            }
1043
        }
1044

    
1045
        public void dispose() {
1046
            if (boldFont != null) {
1047
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1048
                boldFont = null;
1049
            }
1050
        }
1051
    }
1052

    
1053
    /**
1054
     * <p>
1055
     * createToggleableTextField
1056
     * </p>
1057
     *
1058
     * @param parentElement
1059
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1060
     *            object.
1061
     * @param labelString
1062
     *            a {@link java.lang.String} object.
1063
     * @param initialText
1064
     *            a {@link java.lang.String} object.
1065
     * @param initialState
1066
     *            a boolean.
1067
     * @param style
1068
     *            a int.
1069
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1070
     *         object.
1071
     */
1072
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1073
            String initialText, boolean initialState, int style) {
1074
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1075
                initialState, style | orientation);
1076
        adapt(element);
1077
        parentElement.addElement(element);
1078
        return element;
1079
    }
1080

    
1081
    /**
1082
     * <p>
1083
     * createTimePeriodElement
1084
     * </p>
1085
     *
1086
     * @param parentElement
1087
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1088
     *            object.
1089
     * @param labelString
1090
     *            a {@link java.lang.String} object.
1091
     * @param timePeriod
1092
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1093
     * @param style
1094
     *            a int.
1095
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1096
     *         object.
1097
     */
1098
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1099
            TimePeriod timePeriod, int style) {
1100
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1101
        adapt(element);
1102
        parentElement.addElement(element);
1103
        return element;
1104
    }
1105

    
1106
	/**
1107
	 * <p>
1108
	 * createGatheringEventUnitElement
1109
	 * </p>
1110
	 *
1111
	 * @param parentElement
1112
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1113
	 *            object.
1114
	 * @param labelString
1115
	 *            a {@link java.lang.String} object.
1116
	 * @param timePeriod
1117
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1118
	 * @param style
1119
	 *            a int.
1120
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1121
	 *         object.
1122
	 */
1123
	public GatheringEventUnitElement createGatheringEventUnitElement(
1124
			ICdmFormElement parentElement,
1125
			String labelString,
1126
			DerivedUnitFacade gatheringEvent,
1127
			MinMaxTextSection.UnitType unitType,
1128
			int style) {
1129
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1130
				parentElement,
1131
				labelString,
1132
				gatheringEvent,
1133
				unitType,
1134
				style);
1135
		adapt(element);
1136
		parentElement.addElement(element);
1137
		return element;
1138
	}
1139

    
1140
    /**
1141
     * <p>
1142
     * createPointElement
1143
     * </p>
1144
     *
1145
     * @param style
1146
     *            a int.
1147
     * @param parentElement
1148
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1149
     *            object.
1150
     * @param point
1151
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1152
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1153
     */
1154
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1155
        PointElement element = new PointElement(this, parentElement, point, style);
1156
        adapt(element);
1157
        parentElement.addElement(element);
1158
        return element;
1159
    }
1160

    
1161

    
1162

    
1163
    /**
1164
     * @param conversationHolder
1165
     * @param parent
1166
     * @param detailsViewer
1167
     * @param i
1168
     * @return
1169
     */
1170
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1171
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1172
        parentElement.addElement(section);
1173
        adapt(section);
1174
        return section;
1175
    }
1176

    
1177
    /**
1178
     * <p>
1179
     * createDateDetailSection
1180
     * </p>
1181
     *
1182
     * @param parentElement
1183
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1184
     *            object.
1185
     * @param style
1186
     *            a int.
1187
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1188
     *         object.
1189
     */
1190
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1191
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1192
        parentElement.addElement(section);
1193
        adapt(section);
1194
        return section;
1195
    }
1196

    
1197
	/**
1198
	 * <p>
1199
	 * createDateDetailSection
1200
	 * </p>
1201
	 *
1202
	 * @param parentElement
1203
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1204
	 *            object.
1205
	 * @param style
1206
	 *            a int.
1207
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1208
	 *         object.
1209
	 */
1210
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1211
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1212
		parentElement.addElement(section);
1213
		adapt(section);
1214
		return section;
1215
	}
1216

    
1217
    /**
1218
     * <p>
1219
     * createPartialElement
1220
     * </p>
1221
     *
1222
     * @param parentElement
1223
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1224
     *            object.
1225
     * @param labelString
1226
     *            a {@link java.lang.String} object.
1227
     * @param partial
1228
     *            a {@link org.joda.time.Partial} object.
1229
     * @param style
1230
     *            a int.
1231
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1232
     *         object.
1233
     */
1234
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1235
            int style) {
1236
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1237
        adapt(element);
1238
        parentElement.addElement(element);
1239
        return element;
1240
    }
1241

    
1242
    /**
1243
     * <p>
1244
     * addSelectionListener
1245
     * </p>
1246
     *
1247
     * @param listener
1248
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1249
     */
1250
    public void addSelectionListener(SelectionListener listener) {
1251
        selectionListenerList.add(listener);
1252
    }
1253

    
1254
    /**
1255
     * <p>
1256
     * removeSelectionListener
1257
     * </p>
1258
     *
1259
     * @param listener
1260
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1261
     */
1262
    public void removeSelectionListener(SelectionListener listener) {
1263
        if (listener == null) {
1264
            MessagingUtils.error(this.getClass(),
1265
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1266
        } else {
1267
            selectionListenerList.remove(listener);
1268
        }
1269
    }
1270

    
1271
    /**
1272
     * <p>
1273
     * addPropertyChangeListener
1274
     * </p>
1275
     *
1276
     * @param listener
1277
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1278
     *            object.
1279
     */
1280
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1281
        if (propertyChangeListeners.contains(listener)) {
1282
            return;
1283
        }
1284
        propertyChangeListeners.add(0, listener);
1285
    }
1286

    
1287
    /**
1288
     * <p>
1289
     * removePropertyChangeListener
1290
     * </p>
1291
     *
1292
     * @param listener
1293
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1294
     *            object.
1295
     */
1296
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1297
        propertyChangeListeners.remove(listener);
1298
    }
1299

    
1300
    /**
1301
     * @return the propertyChangeListeners
1302
     */
1303
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1304
        return propertyChangeListeners;
1305
    }
1306

    
1307
    /**
1308
     * <p>
1309
     * createHorizontalSeparator
1310
     * </p>
1311
     *
1312
     * @param parentElement
1313
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1314
     *            object.
1315
     * @param style
1316
     *            a int.
1317
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1318
     */
1319
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1320
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1321
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1322
        return separator;
1323
    }
1324

    
1325
    /**
1326
     * <p>
1327
     * createVersionElement
1328
     * </p>
1329
     *
1330
     * @param parentElement
1331
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1332
     *            object.
1333
     * @param entity
1334
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1335
     *            object.
1336
     * @param style
1337
     *            a int.
1338
     * @return a
1339
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1340
     *         object.
1341
     */
1342
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1343
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1344
        adapt(element);
1345
        parentElement.addElement(element);
1346
        return element;
1347
    }
1348

    
1349
    /**
1350
     * @param cdmBaseSection
1351
     * @param object
1352
     * @param style
1353
     * @return
1354
     */
1355
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1356
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1357
        adapt(element);
1358
        parentElement.addElement(element);
1359
        return element;
1360
    }
1361

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

    
1383
    /**
1384
     * @param parent
1385
     * @param i
1386
     * @return
1387
     */
1388
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1389
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1390
        parentElement.addElement(section);
1391
        adapt(section);
1392
        return section;
1393
    }
1394

    
1395
    /**
1396
     * <p>
1397
     * createEmptyElement
1398
     * </p>
1399
     *
1400
     * @param parentElement
1401
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1402
     *            object.
1403
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1404
     */
1405
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1406
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1407
        adapt(element);
1408
        parentElement.addElement(element);
1409
        return element;
1410
    }
1411

    
1412
    /**
1413
     * <p>
1414
     * createHeadlineSection
1415
     * </p>
1416
     *
1417
     * @param parentElement
1418
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1419
     *            object.
1420
     * @return a
1421
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1422
     *         object.
1423
     */
1424
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1425
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1426
        parentElement.addElement(section);
1427
        adapt(section);
1428
        return section;
1429
    }
1430

    
1431
    /**
1432
     * <p>
1433
     * createParsingMessageElement
1434
     * </p>
1435
     *
1436
     * @param parentElement
1437
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1438
     *            object.
1439
     * @param parserProblem
1440
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1441
     *            object.
1442
     * @param style
1443
     *            a int.
1444
     * @return a
1445
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1446
     *         object.
1447
     */
1448
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1449
            ParserProblem parserProblem, int style) {
1450
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1451
        adapt(element);
1452
        parentElement.addElement(element);
1453
        return element;
1454
    }
1455

    
1456
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1457
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1458

    
1459
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1460
                selectionProvider, style);
1461

    
1462
        parentElement.addElement(section);
1463
        adapt(section);
1464
        return section;
1465

    
1466
    }
1467

    
1468
    /**
1469
     * @param definedTermClass
1470
     * @param formElement
1471
     * @param style
1472
     * @return
1473
     */
1474
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1475
            AbstractCdmDetailSection parentElement, int style) {
1476
        AbstractCdmDetailElement element = null;
1477

    
1478
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1479
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1480
        } else if (definedTermClass.equals(Feature.class)) {
1481
            element = new FeatureDetailElement(this, parentElement);
1482
        } else {
1483
            element = new DefinedTermDetailElement(this, parentElement);
1484
        }
1485

    
1486
        adapt(element);
1487
        parentElement.addElement(element);
1488
        return element;
1489
    }
1490

    
1491

    
1492
    //--------DetailSections---------
1493
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1494
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1495
        addAndAdaptSection(parentElement, section);
1496
        return section;
1497
    }
1498

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

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

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

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

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

    
1529
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1530
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1531
        addAndAdaptSection(parentElement, section);
1532
        return section;
1533
    }
1534

    
1535
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1536
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1537
        addAndAdaptSection(parentElement, section);
1538
        return section;
1539
    }
1540

    
1541
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1542
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1543
        addAndAdaptSection(parentElement, section);
1544
        return section;
1545
    }
1546

    
1547
    public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1548
        DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1549
        addAndAdaptSection(parentElement, section);
1550
        return section;
1551
    }
1552

    
1553
    public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1554
        ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1555
        addAndAdaptSection(parentElement, section);
1556
        return section;
1557
    }
1558

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

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

    
1571
    public DerivedUnitFacadeDetailSection createDerivedUnitFacadeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1572
        DerivedUnitFacadeDetailSection section = new DerivedUnitFacadeDetailSection(this, conversation, parentElement, selectionProvider, style);
1573
        addAndAdaptSection(parentElement, section);
1574
        return section;
1575
    }
1576

    
1577
    public FieldUnitDetailSection createFieldUnitDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1578
        FieldUnitDetailSection section = new FieldUnitDetailSection(this, conversation, parentElement, selectionProvider, style);
1579
        addAndAdaptSection(parentElement, section);
1580
        return section;
1581
    }
1582

    
1583
    public GatheringEventDetailSection createGatheringEventDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1584
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1585
        addAndAdaptSection(parentElement, section);
1586
        return section;
1587
    }
1588

    
1589
    public DerivedUnitBaseDetailSection createDerivedUnitBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1590
        DerivedUnitBaseDetailSection section = new DerivedUnitBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1591
        addAndAdaptSection(parentElement, section);
1592
        return section;
1593
    }
1594

    
1595
    public OriginalLabelDataSection createOriginalLabelDataSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1596
        OriginalLabelDataSection section = new OriginalLabelDataSection(this, conversation, parentElement, selectionProvider, style);
1597
        addAndAdaptSection(parentElement, section);
1598
        return section;
1599
    }
1600

    
1601
    public NaturalLanguageSection createNaturalLanguageSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1602
        NaturalLanguageSection section = new NaturalLanguageSection(this, conversation, parentElement, selectionProvider, style);
1603
        addAndAdaptSection(parentElement, section);
1604
        return section;
1605
    }
1606

    
1607
    public FeatureDistributionDetailSection createFeatureDistributionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1608
        FeatureDistributionDetailSection section = new FeatureDistributionDetailSection(this, conversation, parentElement, selectionProvider, style);
1609
        addAndAdaptSection(parentElement, section);
1610
        return section;
1611
    }
1612

    
1613
    public ClassificationDetailSection createClassificationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1614
        ClassificationDetailSection section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style);
1615
        addAndAdaptSection(parentElement, section);
1616
        return section;
1617
    }
1618

    
1619
    public TaxonNodeDetailSection createTaxonNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1620
        TaxonNodeDetailSection section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1621
        addAndAdaptSection(parentElement, section);
1622
        return section;
1623
    }
1624

    
1625
    public PolytomousKeyDetailSection createPolytomousKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1626
        PolytomousKeyDetailSection section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
1627
        addAndAdaptSection(parentElement, section);
1628
        return section;
1629
    }
1630

    
1631
    public PolytomousKeyNodeDetailSection createPolytomousKeyNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1632
        PolytomousKeyNodeDetailSection section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1633
        addAndAdaptSection(parentElement, section);
1634
        return section;
1635
    }
1636

    
1637
    public InstitutionDetailSection createInstitutionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1638
        InstitutionDetailSection section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
1639
        addAndAdaptSection(parentElement, section);
1640
        return section;
1641
    }
1642

    
1643
    public FieldUnitGeneralDetailSection createFieldUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1644
        FieldUnitGeneralDetailSection section = new FieldUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1645
        addAndAdaptSection(parentElement, section);
1646
        return section;
1647
    }
1648

    
1649
    public DerivedUnitGeneralDetailSection createDerivedUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1650
        DerivedUnitGeneralDetailSection section = new DerivedUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1651
        addAndAdaptSection(parentElement, section);
1652
        return section;
1653
    }
1654

    
1655
    public PreservedSpecimenGeneralDetailSection createPreservedSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1656
        PreservedSpecimenGeneralDetailSection section = new PreservedSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1657
        addAndAdaptSection(parentElement, section);
1658
        return section;
1659
    }
1660

    
1661
    public TissueSampleGeneralDetailSection createTissueSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1662
        TissueSampleGeneralDetailSection section = new TissueSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1663
        addAndAdaptSection(parentElement, section);
1664
        return section;
1665
    }
1666

    
1667
    public DnaSampleGeneralDetailSection createDnaSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1668
        DnaSampleGeneralDetailSection section = new DnaSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1669
        addAndAdaptSection(parentElement, section);
1670
        return section;
1671
    }
1672

    
1673
    public DnaQualityDetailSection createDnaQualityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1674
        DnaQualityDetailSection section = new DnaQualityDetailSection(this, conversation, parentElement, selectionProvider, style);
1675
        addAndAdaptSection(parentElement, section);
1676
        return section;
1677
    }
1678

    
1679
    public SequenceGeneralDetailSection createSequenceGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1680
        SequenceGeneralDetailSection section = new SequenceGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1681
        addAndAdaptSection(parentElement, section);
1682
        return section;
1683
    }
1684

    
1685
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1686
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
1687
        addAndAdaptSection(parentElement, section);
1688
        return section;
1689
    }
1690

    
1691
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1692
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
1693
        addAndAdaptSection(parentElement, section);
1694
        return section;
1695
    }
1696

    
1697
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1698
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1699
        addAndAdaptSection(parentElement, section);
1700
        return section;
1701
    }
1702

    
1703
    public SingleReadGeneralDetailSection createSingleReadGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1704
        SingleReadGeneralDetailSection section = new SingleReadGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1705
        addAndAdaptSection(parentElement, section);
1706
        return section;
1707
    }
1708

    
1709
    public AmplificationGeneralDetailSection createAmplificationGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1710
        AmplificationGeneralDetailSection section = new AmplificationGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1711
        addAndAdaptSection(parentElement, section);
1712
        return section;
1713
    }
1714

    
1715
    public AmplificationPrimerDetailSection createAmplificationPrimerDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1716
        AmplificationPrimerDetailSection section = new AmplificationPrimerDetailSection(this, conversation, parentElement, selectionProvider, style);
1717
        addAndAdaptSection(parentElement, section);
1718
        return section;
1719
    }
1720

    
1721
    public AmplificationCloningDetailSection createAmplificationCloningDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1722
        AmplificationCloningDetailSection section = new AmplificationCloningDetailSection(this, conversation, parentElement, selectionProvider, style);
1723
        addAndAdaptSection(parentElement, section);
1724
        return section;
1725
    }
1726

    
1727
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1728
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1729
        addAndAdaptSection(parentElement, section);
1730
        return section;
1731
    }
1732

    
1733
    public MediaSpecimenGeneralDetailSection createMediaSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1734
        MediaSpecimenGeneralDetailSection section = new MediaSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1735
        addAndAdaptSection(parentElement, section);
1736
        return section;
1737
    }
1738

    
1739
    public HybridDetailSection createHybridDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1740
        HybridDetailSection section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
1741
        addAndAdaptSection(parentElement, section);
1742
        return section;
1743
    }
1744

    
1745
    public UserDetailSection createUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1746
        UserDetailSection section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
1747
        addAndAdaptSection(parentElement, section);
1748
        return section;
1749
    }
1750

    
1751
    public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1752
        GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
1753
        addAndAdaptSection(parentElement, section);
1754
        return section;
1755
    }
1756

    
1757
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1758
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1759
        addAndAdaptSection(parentElement, section);
1760
        return section;
1761
    }
1762

    
1763
    public SampleDesignationDetailSection createSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1764
        SampleDesignationDetailSection section = new SampleDesignationDetailSection(this, conversation, parentElement, selectionProvider, style);
1765
        addAndAdaptSection(parentElement, section);
1766
        return section;
1767
    }
1768

    
1769
    public PreservedSpecimenDeterminationDetailSection createPreservedSpecimenDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1770
        PreservedSpecimenDeterminationDetailSection section = new PreservedSpecimenDeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1771
        addAndAdaptSection(parentElement, section);
1772
        return section;
1773
    }
1774

    
1775
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1776
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1777
        addAndAdaptSection(parentElement, section);
1778
        return section;
1779
    }
1780

    
1781
    public ReferencedEntityDetailSection createReferencedEntityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1782
        ReferencedEntityDetailSection section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
1783
        addAndAdaptSection(parentElement, section);
1784
        return section;
1785
    }
1786

    
1787
    public TermVocabularyDetailSection createTermVocabularyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1788
        TermVocabularyDetailSection section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
1789
        addAndAdaptSection(parentElement, section);
1790
        return section;
1791
    }
1792

    
1793
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1794
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1795
        addAndAdaptSection(parentElement, section);
1796
        return section;
1797
    }
1798

    
1799
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1800
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
1801
        addAndAdaptSection(parentElement, section);
1802
        return section;
1803
    }
1804

    
1805
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1806
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
1807
        addAndAdaptSection(parentElement, section);
1808
        return section;
1809
    }
1810

    
1811
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1812
        parentElement.addElement(section);
1813
        adapt(section);
1814
    }
1815

    
1816
    //--------DetailElements------------
1817

    
1818
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1819
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1820
        addAndAdaptElement(parentElement, element);
1821
        return element;
1822
    }
1823

    
1824
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1825
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1826
        addAndAdaptElement(parentElement, element);
1827
        return element;
1828
    }
1829

    
1830
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1831
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1832
        addAndAdaptElement(parentElement, element);
1833
        return element;
1834
    }
1835

    
1836
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1837
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1838
        addAndAdaptElement(parentElement, element);
1839
        return element;
1840
    }
1841

    
1842
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1843
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1844
        addAndAdaptElement(parentElement, element);
1845
        return element;
1846
    }
1847

    
1848
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1849
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1850
        addAndAdaptElement(parentElement, element);
1851
        return element;
1852
    }
1853

    
1854
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1855
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
1856
        addAndAdaptElement(parentElement, element);
1857
        return element;
1858
    }
1859

    
1860
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
1861
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
1862
        addAndAdaptElement(parentElement, element);
1863
        return element;
1864
    }
1865

    
1866
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
1867
        UserDetailElement element = new UserDetailElement(this, parentElement);
1868
        addAndAdaptElement(parentElement, element);
1869
        return element;
1870
    }
1871

    
1872
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
1873
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
1874
        addAndAdaptElement(parentElement, element);
1875
        return element;
1876
    }
1877

    
1878
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
1879
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
1880
        addAndAdaptElement(parentElement, element);
1881
        return element;
1882
    }
1883

    
1884
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
1885
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
1886
        addAndAdaptElement(parentElement, element);
1887
        return element;
1888
    }
1889

    
1890
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
1891
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
1892
        addAndAdaptElement(parentElement, element);
1893
        return element;
1894
    }
1895

    
1896
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
1897
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
1898
        addAndAdaptElement(parentElement, element);
1899
        return element;
1900
    }
1901

    
1902
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement){
1903
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement);
1904
        addAndAdaptElement(parentElement, element);
1905
        return element;
1906
    }
1907

    
1908
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
1909
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
1910
        addAndAdaptElement(parentElement, element);
1911
        return element;
1912
    }
1913

    
1914
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
1915
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
1916
        addAndAdaptElement(parentElement, element);
1917
        return element;
1918
    }
1919

    
1920
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
1921
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
1922
        addAndAdaptElement(parentElement, element);
1923
        return element;
1924
    }
1925

    
1926
    public DerivedUnitFacadeDetailElement createDerivedUnitFacadeDetailElement(ICdmFormElement parentElement){
1927
        DerivedUnitFacadeDetailElement element = new DerivedUnitFacadeDetailElement(this, parentElement);
1928
        addAndAdaptElement(parentElement, element);
1929
        return element;
1930
    }
1931

    
1932
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
1933
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
1934
        addAndAdaptElement(parentElement, element);
1935
        return element;
1936
    }
1937

    
1938
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
1939
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
1940
        addAndAdaptElement(parentElement, element);
1941
        return element;
1942
    }
1943

    
1944
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
1945
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
1946
        addAndAdaptElement(parentElement, element);
1947
        return element;
1948
    }
1949

    
1950
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
1951
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
1952
        addAndAdaptElement(parentElement, element);
1953
        return element;
1954
    }
1955

    
1956
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style){
1957
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style);
1958
        addAndAdaptElement(parentElement, element);
1959
        return element;
1960
    }
1961

    
1962
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
1963
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
1964
        addAndAdaptElement(parentElement, element);
1965
        return element;
1966
    }
1967

    
1968
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
1969
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
1970
        addAndAdaptElement(parentElement, element);
1971
        return element;
1972
    }
1973

    
1974
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
1975
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
1976
        addAndAdaptElement(parentElement, element);
1977
        return element;
1978
    }
1979

    
1980
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
1981
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
1982
        addAndAdaptElement(parentElement, element);
1983
        return element;
1984
    }
1985

    
1986
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
1987
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
1988
        addAndAdaptElement(parentElement, element);
1989
        return element;
1990
    }
1991

    
1992

    
1993
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
1994
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
1995
        addAndAdaptElement(parentElement, element);
1996
        return element;
1997
    }
1998

    
1999
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2000
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2001
        addAndAdaptElement(parentElement, element);
2002
        return element;
2003
    }
2004

    
2005
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2006
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2007
        addAndAdaptElement(parentElement, element);
2008
        return element;
2009
    }
2010

    
2011
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2012
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2013
        addAndAdaptElement(parentElement, element);
2014
        return element;
2015
    }
2016

    
2017
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2018
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2019
        addAndAdaptElement(parentElement, element);
2020
        return element;
2021
    }
2022

    
2023
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2024
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2025
        addAndAdaptElement(parentElement, element);
2026
        return element;
2027
    }
2028

    
2029
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2030
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2031
        addAndAdaptElement(parentElement, element);
2032
        return element;
2033
    }
2034

    
2035
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2036
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2037
        addAndAdaptElement(parentElement, element);
2038
        return element;
2039
    }
2040

    
2041
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2042
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2043
        addAndAdaptElement(parentElement, element);
2044
        return element;
2045
    }
2046

    
2047
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2048
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2049
        addAndAdaptElement(parentElement, element);
2050
        return element;
2051
    }
2052

    
2053
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2054
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2055
        addAndAdaptElement(parentElement, element);
2056
        return element;
2057
    }
2058

    
2059
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2060
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2061
        addAndAdaptElement(parentElement, element);
2062
        return element;
2063
    }
2064

    
2065
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2066
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2067
        addAndAdaptElement(parentElement, element);
2068
        return element;
2069
    }
2070

    
2071
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2072
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2073
        addAndAdaptElement(parentElement, element);
2074
        return element;
2075
    }
2076

    
2077
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2078
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2079
        addAndAdaptElement(parentElement, mediaDetailElement);
2080
        return mediaDetailElement;
2081
    }
2082

    
2083
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2084
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2085
        addAndAdaptElement(parentElement, element);
2086
        return element;
2087
    }
2088

    
2089
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2090
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2091
        addAndAdaptElement(parentElement, element);
2092
        return element;
2093
    }
2094

    
2095

    
2096
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2097
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2098
        addAndAdaptElement(parentElement, element);
2099
        return element;
2100
    }
2101

    
2102
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2103
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2104
        addAndAdaptElement(parentElement, element);
2105
        return element;
2106
    }
2107

    
2108
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2109
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2110
        addAndAdaptElement(parentElement, element);
2111
        return element;
2112
    }
2113

    
2114
    public PreservedSpecimenDeterminationDetailElement createPreservedSpecimenDeterminationDetailElement(ICdmFormElement parentElement) {
2115
        PreservedSpecimenDeterminationDetailElement element = new PreservedSpecimenDeterminationDetailElement(this, parentElement);
2116
        addAndAdaptElement(parentElement, element);
2117
        return element;
2118
    }
2119

    
2120
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2121
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2122
        addAndAdaptElement(parentElement, element);
2123
        return element;
2124
    }
2125

    
2126
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2127
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2128
        addAndAdaptElement(parentElement, element);
2129
        return element;
2130
    }
2131

    
2132
    /**
2133
     * @param parentElement
2134
     * @param element
2135
     */
2136
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2137
        adapt(element);
2138
        parentElement.addElement(element);
2139
    }
2140

    
2141
    //--------EntityCollectionSection----------
2142
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2143
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style);
2144
        addAndAdaptSection(parentElement, section);
2145
        return section;
2146
    }
2147

    
2148
    public AnnotationSection createAnnotationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2149
        AnnotationSection section = new AnnotationSection(this, conversation, parentElement, style);
2150
        addAndAdaptSection(parentElement, section);
2151
        return section;
2152
    }
2153

    
2154
    public CreditSection createCreditSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2155
        CreditSection section = new CreditSection(this, conversation, parentElement, style);
2156
        addAndAdaptSection(parentElement, section);
2157
        return section;
2158
    }
2159

    
2160
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2161
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2162
        addAndAdaptSection(parentElement, section);
2163
        return section;
2164
    }
2165

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2402
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2403

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

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

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

    
2524
        if (element == null) {
2525
            MessagingUtils.messageDialog("No element for entity", this,
2526
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2527
                            + entity, null);
2528
        }
2529

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

    
2538
        return element;
2539
    }
2540

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

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

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

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

    
2610
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2611
        Label label = new Label(formElement.getLayoutComposite(), style);
2612
        label.setText(labelText+" (yyyy-MM-dd)");
2613
        DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, style);
2614
        dateElement.initController(this, formElement);
2615
        return dateElement;
2616
    }
2617

    
2618
    /**
2619
     * <p>
2620
     * Getter for the field <code>selectionProvider</code>.
2621
     * </p>
2622
     *
2623
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2624
     */
2625
    public ISelectionProvider getSelectionProvider() {
2626
        return selectionProvider;
2627
    }
2628

    
2629
    /**
2630
     * <p>
2631
     * createDetailedDescriptionDetailElement
2632
     * </p>
2633
     *
2634
     * @param parentElement
2635
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2636
     *            object.
2637
     * @param entity
2638
     *            a
2639
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2640
     *            object.
2641
     * @param style
2642
     *            a int.
2643
     * @return a
2644
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2645
     *         object.
2646
     */
2647
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2648
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2649
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2650

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

    
2678
    }
2679

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

    
2702
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2703
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2704
        addAndAdaptSection(parentElement, section);
2705
        return section;
2706
    }
2707

    
2708
}
(6-6/40)