Project

General

Profile

Download (151 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.Comparator;
9
import java.util.HashSet;
10
import java.util.List;
11
import java.util.Map;
12
import java.util.Set;
13

    
14
import javax.inject.Inject;
15

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

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

    
361
/**
362
 * <p>
363
 * CdmFormFactory class.
364
 * </p>
365
 *
366
 * @author n.hoffmann
367
 * @created Feb 24, 2010
368
 */
369
public class CdmFormFactory extends FormToolkit {
370

    
371
    private BoldFontHolder2 boldFontHolder2;
372
    private MouseListener selectionMouseHandler;
373
    private FocusListener selectionFocusHandler;
374

    
375
    @Inject
376
    private IEclipseContext context;
377

    
378
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
379

    
380
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
381

    
382
    private final int orientation = Window.getDefaultOrientation();
383
    private ISelectionProvider selectionProvider;
384

    
385
    /** Constant <code>EMPTY_SELECTION</code> */
386
    public static ISelection EMPTY_SELECTION = new ISelection() {
387
        @Override
388
        public boolean isEmpty() {
389
            return true;
390
        }
391
    };
392

    
393
    /**
394
     *
395
     * @author n.hoffmann
396
     * @date Jan 25, 2010
397
     *
398
     */
399
    private class SelectionMouseHandler extends MouseAdapter {
400
        @Override
401
        public void mouseDown(MouseEvent e) {
402
            notifySelectionListeners(e);
403
        }
404
    }
405

    
406
    /**
407
     *
408
     * @author n.hoffmann
409
     * @date Jan 25, 2010
410
     *
411
     */
412
    private class SelectionFocusHandler extends FocusAdapter {
413
        @Override
414
        public void focusGained(FocusEvent e) {
415
            notifySelectionListeners(e);
416
        }
417
    }
418

    
419
    private void notifySelectionListeners(TypedEvent e) {
420
        Event event = new Event();
421
        event.widget = e.widget;
422
        SelectionEvent selectionEvent = new SelectionEvent(event);
423

    
424
        for (SelectionListener listener : selectionListenerList) {
425
            listener.widgetSelected(selectionEvent);
426
        }
427
    }
428

    
429
    public CdmFormFactory(Display display) {
430
        this(display, null);
431
    }
432

    
433
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
434
        super(display);
435
        this.selectionProvider = selectionProvider;
436
        init();
437
    }
438

    
439
    private void init() {
440
        boldFontHolder2 = new BoldFontHolder2();
441
        selectionMouseHandler = new SelectionMouseHandler();
442
        selectionFocusHandler = new SelectionFocusHandler();
443
    }
444

    
445
    public IEclipseContext getContext() {
446
        return context;
447
    }
448

    
449
    /**
450
     * Creates an instance initialized with the correct selectionProvider
451
     *
452
     * Make sure to remove the instance when the entityComposite disposes via
453
     * destroySelectionArbitrator(..)
454
     *
455
     * @param entityElement
456
     *            a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
457
     *            object.
458
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
459
     *         object.
460
     */
461
    public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
462
        SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
463
        selectionArbitrator.addSelectionProvider(selectionProvider);
464
        selectionProvider.addSelectionChangedListener(selectionArbitrator);
465
        addSelectionListener(selectionArbitrator);
466
        return selectionArbitrator;
467
    }
468

    
469
    /**
470
     * <p>
471
     * destroySelectionArbitrator
472
     * </p>
473
     *
474
     * @param selectionArbitrator
475
     *            a
476
     *            {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
477
     *            object.
478
     */
479
    public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
480
        if(selectionArbitrator==null){
481
            return;
482
        }
483
        removeSelectionListener(selectionArbitrator);
484
        if (selectionProvider != null) {
485
            selectionProvider.removeSelectionChangedListener(selectionArbitrator);
486
        } else {
487
            MessagingUtils.error(this.getClass(),
488
                    "Tried to destroy a selection listener from this factories listeners but was null", null);
489
        }
490
    }
491

    
492
    /**
493
     * <p>
494
     * Adapts the {@link AbstractCdmFormElement}:<br>
495
     * - sets the {@link IPropertyChangeListener}s handled by this class
496
     * </p>
497
     *
498
     * @param formElement
499
     *            a
500
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
501
     *            object.
502
     */
503
    public void adapt(ICdmFormElement formElement) {
504
        formElement.setPropertyChangeListeners(propertyChangeListeners);
505
    }
506

    
507
    /** {@inheritDoc} */
508
    @Override
509
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
510
        if (trackFocus) {
511
            control.addFocusListener(selectionFocusHandler);
512
        }
513
        super.adapt(control, trackFocus, trackKeyboard);
514
    }
515

    
516
    /** {@inheritDoc} */
517
    @Override
518
    public void adapt(Composite composite) {
519
        composite.addMouseListener(selectionMouseHandler);
520

    
521
        super.adapt(composite);
522
    }
523

    
524
    /**
525
     * <p>
526
     * destroyElement
527
     * </p>
528
     *
529
     * @param formElement
530
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
531
     *            object.
532
     */
533
    public void destroyElement(ICdmFormElement formElement) {
534
        // return if element was not initialized
535
        if (formElement == null) {
536
            return;
537
        }
538
        // destroy selection arbitrator, if any
539
        if (formElement instanceof ISelectableElement) {
540
            destroySelectionArbitrator(((ISelectableElement) formElement).getSelectionArbitrator());
541
        }
542
        // remove this element form its parents list of elements
543
        // ICdmFormElement parentElement = formElement.getParentElement();
544
        // if(parentElement != null){
545
        // parentElement.removeElement(formElement);
546
        // }
547
        // call destroy on child elements recursively
548
        for (ICdmFormElement childElement : formElement.getElements()) {
549
            destroyElement(childElement);
550
        }
551
        // dispose of the controls
552
        for (Control control : formElement.getControls()) {
553
            // we added the layoutComposite of the parental element as the
554
            // layout composite to this formElement
555
            // but we do not want to destroy it.
556
            if (control.equals(formElement.getLayoutComposite())) {
557
                continue;
558
            } else {
559
                if (control != null && !control.isDisposed()){
560
                    control.dispose();
561
                }
562
                control = null;
563
            }
564
        }
565
    }
566

    
567
    /**
568
     * <p>
569
     * createEmptyCell
570
     * </p>
571
     *
572
     * @param parent
573
     *            a {@link org.eclipse.swt.widgets.Composite} object.
574
     * @return a {@link org.eclipse.swt.widgets.Label} object.
575
     */
576
    public Label createEmptyCell(Composite parent) {
577
        return this.createLabel(parent, null);
578
    }
579

    
580
    /**
581
     * <p>
582
     * createMultiLanguageTextElement
583
     * </p>
584
     *
585
     * @param parentElement
586
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
587
     *            object.
588
     * @param labelString
589
     *            a {@link java.lang.String} object.
590
     * @param multilanguageText
591
     *            a {@link java.util.Map} object.
592
     * @param textHeight
593
     *            a int.
594
     * @param style
595
     *            a int.
596
     * @return a
597
     *         {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
598
     *         object.
599
     */
600
    public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
601
            Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
602
        MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
603
                multilanguageText, textHeight, style);
604
        adapt(element);
605
        parentElement.addElement(element);
606
        return element;
607
    }
608

    
609
    /**
610
     * <p>
611
     * createMultiLanguageTextElement
612
     * </p>
613
     *
614
     * @param parentElement
615
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
616
     *            object.
617
     *
618
     * @param Representation
619
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
620
     * @param textHeight
621
     *            a int.
622
     * @param style
623
     *            a int.
624
     * @return a
625
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
626
     *         object.
627
     */
628
    public RepresentationElement createRepresentationElement(ICdmFormElement parentElement, Representation representation, TermBase term,int textHeight, int style, boolean fillDetails) {
629
        RepresentationElement element = new RepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
630
        adapt(element);
631
        parentElement.addElement(element);
632
        return element;
633
    }
634

    
635
    /**
636
     * <p>
637
     * createMultiLanguageTextElement
638
     * </p>
639
     *
640
     * @param parentElement
641
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
642
     *            object.
643
     *
644
     * @param Representation
645
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
646
     * @param textHeight
647
     *            a int.
648
     * @param style
649
     *            a int.
650
     * @return a
651
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
652
     *         object.
653
     */
654
    public TranslatableRepresentationElement createTranslatableRepresentationElement(ICdmFormElement parentElement, Representation representation, TermBase term,int textHeight, int style, boolean fillDetails) {
655
        TranslatableRepresentationElement element = new TranslatableRepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
656
        adapt(element);
657
        parentElement.addElement(element);
658
        return element;
659
    }
660

    
661
    /**
662
     * <p>
663
     * createMultiLanguageTextElement
664
     * </p>
665
     *
666
     * @param parentElement
667
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
668
     *            object.
669
     *
670
     * @param term
671
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
672
     * @param textHeight
673
     *            a int.
674
     * @param style
675
     *            a int.
676
     * @return a
677
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
678
     *         object.
679
     */
680
    public RepresentationElement createRepresentationElement(ICdmFormElement parentElement, TermBase term, int textHeight, int style, boolean fillDetails) {
681
        RepresentationElement element = new RepresentationElement(this, parentElement, term, textHeight, style, fillDetails);
682
        adapt(element);
683
        parentElement.addElement(element);
684
        return element;
685
    }
686

    
687
    /**
688
     * <p>
689
     * createMultiLanguageTextElement
690
     * </p>
691
     *
692
     * @param parentElement
693
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
694
     *            object.
695
     *
696
     * @param term
697
     *            a {@link eu.etaxonomy.cdm.model.common.Representation} object.
698
     * @param textHeight
699
     *            a int.
700
     * @param style
701
     *            a int.
702
     * @return a
703
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
704
     *         object.
705
     */
706
    public TranslatableRepresentationElement createTranslatableRepresentationElement(ICdmFormElement parentElement, TermBase term, int textHeight, int style, boolean fillDetails) {
707
        TranslatableRepresentationElement element = new TranslatableRepresentationElement(this, parentElement, term, textHeight, style, fillDetails);
708
        adapt(element);
709
        parentElement.addElement(element);
710
        return element;
711
    }
712

    
713
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
714
            KeyStatement keyStatement, int textHeight, int style) {
715
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
716
                textHeight, style);
717
        adapt(element);
718
        parentElement.addElement(element);
719
        return element;
720
    }
721

    
722
    /**
723
     * Creates a text field with a label. The initial content will be the return value of the initalObject's {@link #toString()}
724
     * method.<br>
725
     * <b>Note</b>: if initialObject is <code>null</code> then an empty string is used.
726
     * @param parentElement the parent container
727
     * @param labelString the label name
728
     * @param initialObject the object from which the <code>toString()</code> method is called
729
     * @param style {@link SWT} style constant
730
     * @return the created textfield with label
731
     */
732
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
733
            Object initialObject, int style) {
734
        return createTextWithLabelElement(parentElement, labelString, initialObject==null?"":initialObject.toString(), style);
735
    }
736

    
737
    /**
738
     * <p>
739
     * createTextWithLabelElement
740
     * </p>
741
     *
742
     * @param parentElement
743
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
744
     *            object.
745
     * @param labelString
746
     *            a {@link java.lang.String} object.
747
     * @param initialText
748
     *            a {@link java.lang.String} object.
749
     * @param style
750
     *            a int.
751
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
752
     *         object.
753
     */
754
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
755
            String initialText, int style) {
756
        return createTextWithLabelElement(parentElement, labelString, initialText, null, style);
757
    }
758
    /**
759
     * <p>
760
     * createTextWithLabelElement
761
     * </p>
762
     *
763
     * @param parentElement
764
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
765
     *            object.
766
     * @param labelString
767
     *            a {@link java.lang.String} object.
768
     * @param initialText
769
     *            a {@link java.lang.String} object.
770
     * @param textLimit maximal number of characters allowed
771
     * @param style
772
     *            a int.
773
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
774
     *         object.
775
     */
776
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
777
            String initialText, Integer textLimit, int style) {
778
        if(initialText==null){
779
            initialText = "";
780
        }
781

    
782
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
783
                textLimit, style);
784
        adapt(element);
785
        parentElement.addElement(element);
786
        return element;
787
    }
788

    
789
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
790
            int textHeight, int style) {
791
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
792
        adapt(element);
793
        parentElement.addElement(element);
794
        return element;
795
    }
796

    
797
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
798
            LSID initialLsid, int style) {
799
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
800
        adapt(element);
801
        parentElement.addElement(element);
802
        return element;
803
    }
804

    
805
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
806
            URI initialUri, int style) {
807
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
808
        adapt(element);
809
        parentElement.addElement(element);
810
        return element;
811
    }
812
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
813
            URI initialUri,Integer textHeight, int style) {
814
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, textHeight, style);
815
        adapt(element);
816
        parentElement.addElement(element);
817
        return element;
818
    }
819

    
820

    
821
    /**
822
     * @param element
823
     * @param string
824
     * @param uri
825
     * @param style
826
     * @return
827
     */
828
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
829
            IOpenUrlEnabled openUrlEnabled, int style) {
830
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
831
                style);
832
        adapt(element);
833
        parentElement.addElement(element);
834
        return element;
835
    }
836

    
837
    /**
838
     *
839
     * @param parentElement
840
     * @param labelString
841
     * @param conversationEnabled
842
     * @param user
843
     * @param style
844
     * @return
845
     */
846
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
847
            ConversationHolder conversation, User user, int style) {
848
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
849
        adapt(element);
850
        parentElement.addElement(element);
851
        return element;
852
    }
853

    
854
    /**
855
     * <p>
856
     * createIntegerTextWithLabelElement
857
     * </p>
858
     *
859
     * @param parentElement
860
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
861
     *            object.
862
     * @param labelString
863
     *            a {@link java.lang.String} object.
864
     * @param initialInteger
865
     *            a {@link java.lang.Integer} object.
866
     * @param style
867
     *            a int.
868
     * @return a
869
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
870
     *         object.
871
     */
872
	public NumberWithLabelElement createNumberTextWithLabelElement(
873
			ICdmFormElement parentElement, String labelString,
874
			Number initialNumber, int style) {
875
		NumberWithLabelElement element = new NumberWithLabelElement(this,
876
				parentElement, labelString, initialNumber, style);
877
		adapt(element);
878
		parentElement.addElement(element);
879
		return element;
880
	}
881

    
882
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
883
            String labelString, LanguageString languageString, int style) {
884
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
885
    }
886

    
887
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
888
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
889
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
890
                languageString, height, isMultiLine, style);
891
        adapt(element);
892
        parentElement.addElement(element);
893
        return element;
894
    }
895

    
896
    /**
897
     * <p>
898
     * createKeyValueViewerElement
899
     * </p>
900
     *
901
     * @param parentElement
902
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
903
     *            object.
904
     * @param keyHeading
905
     *            a {@link java.lang.String} object.
906
     * @param valueHeading
907
     *            a {@link java.lang.String} object.
908
     * @param map
909
     *            a {@link java.util.Map} object.
910
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
911
     *         object.
912
     */
913
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
914
            String valueHeading, Map<Object, Object> map) {
915
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
916
        adapt(element);
917
        parentElement.addElement(element);
918
        return element;
919
    }
920
    /**
921
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
922
     */
923
    @Deprecated
924
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
925
            ICdmFormElement parentElement, String labelString, T selection, int style) {
926
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString, selection, true, style);
927
        adapt(element);
928
        parentElement.addElement(element);
929
        return element;
930
    }
931

    
932
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
933
            TermType termType,
934
            ICdmFormElement parentElement,
935
            String labelString,
936
            T selection,
937
            int style,
938
            Comparator<T> comparator) {
939
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false, comparator);
940
    }
941

    
942
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
943
			TermType termType,
944
			ICdmFormElement parentElement,
945
			String labelString,
946
			T selection,
947
			boolean addEmptyElement,
948
			int style) {
949
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, false, null);
950
	}
951

    
952
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
953
			TermType termType,
954
			ICdmFormElement parentElement,
955
			String labelString,
956
			T selection,
957
			int style) {
958
		return  this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false, null);
959
	}
960
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
961
			TermType termType,
962
			ICdmFormElement parentElement,
963
			String labelString,
964
			T selection,
965
			boolean addEmptyElement,
966
			int style,
967
			boolean useAbbrevLabel) {
968
		return createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
969
	}
970

    
971

    
972
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
973
            TermVocabulary<?> termVocabulary,
974
            ICdmFormElement parentElement,
975
            String labelString,
976
            T selection,
977
            int style) {
978
        return this.createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, true, style, false, null);
979
    }
980

    
981
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
982
	        TermVocabulary<?> termVocabulary,
983
	        ICdmFormElement parentElement,
984
	        String labelString,
985
	        T selection,
986
	        boolean addEmptyElement,
987
	        int style,
988
	        boolean useAbbrevLabel) {
989
	    return createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
990
	}
991

    
992
	private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
993
	        TermType termType,
994
	        TermVocabulary<?> termVocabulary,
995
	        ICdmFormElement parentElement,
996
	        String labelString,
997
	        T selection,
998
	        boolean addEmptyElement,
999
	        int style,
1000
	        boolean useAbbrevLabel,
1001
	        Comparator<T> comparator) {
1002
	    if(termType!=null){
1003
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1004
	        adapt(element);
1005
	        parentElement.addElement(element);
1006
	        return element;
1007
	    }
1008
	    else if(termVocabulary!=null){
1009
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1010
	        if (comparator!= null){
1011
	        	element.setTermComparator(comparator);
1012
	        }
1013
	        adapt(element);
1014
	        parentElement.addElement(element);
1015
	        return element;
1016
	    }
1017
	    else{
1018
	        //this should never happen
1019
	        return null;
1020
	    }
1021
	}
1022
	public MisappliedRelationshipComboElement createMisappliedRelationshipComboElement(
1023
	        ICdmFormElement parentElement,
1024
            String labelString,
1025
            TaxonRelationshipType selection,
1026
            int style) {
1027
	    MisappliedRelationshipComboElement combo = new MisappliedRelationshipComboElement(this, parentElement, labelString, selection, false, style, false);
1028
	    adapt(combo);
1029
        parentElement.addElement(combo);
1030
        return combo;
1031
    }
1032

    
1033
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1034
	        Class<T> enumComboType, ICdmFormElement parentElement,
1035
	        int style) {
1036
	    return createEnumComboElement(enumComboType, parentElement, null, style);
1037
	}
1038

    
1039
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1040
			Class<T> enumComboType, ICdmFormElement parentElement, Comparator<T> comparator,
1041
			int style) {
1042
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, comparator, style);
1043
        adapt(element);
1044
        parentElement.addElement(element);
1045
        return element;
1046
    }
1047

    
1048
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
1049
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
1050
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1051
	    adapt(element);
1052
	    parentElement.addElement(element);
1053
	    return element;
1054
	}
1055

    
1056
    /**
1057
     * <p>
1058
     * createBrowserElement
1059
     * </p>
1060
     *
1061
     * @param imageUri
1062
     *            a {@link java.net.URI} object.
1063
     * @param style
1064
     *            a int.
1065
     * @param parentElement
1066
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1067
     *            object.
1068
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
1069
     *         object.
1070
     */
1071
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
1072
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
1073
        adapt(element);
1074
        parentElement.addElement(element);
1075
        return element;
1076
    }
1077

    
1078
    /**
1079
     * <p>
1080
     * createImageElement
1081
     * </p>
1082
     *
1083
     * @param parentElement
1084
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1085
     *            object.
1086
     * @param imageUri
1087
     *            a {@link java.net.URI} object.
1088
     * @param style
1089
     *            a int.
1090
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1091
     */
1092
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1093
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1094
        adapt(element);
1095
        parentElement.addElement(element);
1096
        return element;
1097
    }
1098

    
1099
    /**
1100
     * <p>
1101
     * createTextActionElement
1102
     * </p>
1103
     *
1104
     * @param labelString
1105
     *            a {@link java.lang.String} object.
1106
     * @param initialText
1107
     *            a {@link java.lang.String} object.
1108
     * @param style
1109
     *            a int.
1110
     * @param parentElement
1111
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1112
     *            object.
1113
     * @param buttonLabel
1114
     *            a {@link java.lang.String} object.
1115
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
1116
     *         object.
1117
     */
1118
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
1119
            String buttonLabel, String initialText, int style) {
1120
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
1121
                style);
1122
        adapt(element);
1123
        parentElement.addElement(element);
1124
        return element;
1125
    }
1126

    
1127
    /**
1128
     * <p>
1129
     * createCheckbox
1130
     * </p>
1131
     *
1132
     * @param parentElement
1133
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1134
     *            object.
1135
     * @param label
1136
     *            a {@link java.lang.String} object.
1137
     * @param initialState
1138
     *            a boolean.
1139
     * @param style
1140
     *            a int.
1141
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1142
     *         object.
1143
     */
1144
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1145
        if(initialState==null){
1146
            initialState = Boolean.FALSE;
1147
        }
1148
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1149
        adapt(element);
1150
        parentElement.addElement(element);
1151
        return element;
1152
    }
1153

    
1154
    /**
1155
     * Creates a section as a part of the form.
1156
     *
1157
     * @return the section widget
1158
     * @param section
1159
     *            a
1160
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1161
     *            object.
1162
     */
1163
    public Section adapt(AbstractFormSection section) {
1164
        section.setMenu(section.getLayoutComposite().getMenu());
1165
        adapt(section, true, true);
1166

    
1167
        // handle focus and property change events for cdm use
1168
        section.addFocusListener(selectionFocusHandler);
1169
        section.setPropertyChangeListeners(propertyChangeListeners);
1170

    
1171
        if (section.getToggle() != null) {
1172
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1173
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1174
        }
1175

    
1176
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1177

    
1178
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1179
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1180
            getColors().initializeSectionToolBarColors();
1181
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1182
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1183
        }
1184
        // call setTitleBarForeground regardless as it also sets the label color
1185
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1186
        return section;
1187
    }
1188

    
1189
    private class BoldFontHolder2 {
1190
        private Font normalFont;
1191

    
1192
        private Font boldFont;
1193

    
1194
        public BoldFontHolder2() {
1195
        }
1196

    
1197
        public Font getBoldFont(Font font) {
1198
            createBoldFont(font);
1199
            return boldFont;
1200
        }
1201

    
1202
        private void createBoldFont(Font font) {
1203
            if (normalFont == null || !normalFont.equals(font)) {
1204
                normalFont = font;
1205
                dispose();
1206
            }
1207
            if (boldFont == null) {
1208
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1209
            }
1210
        }
1211

    
1212
        public void dispose() {
1213
            if (boldFont != null) {
1214
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1215
                boldFont = null;
1216
            }
1217
        }
1218
    }
1219

    
1220
    /**
1221
     * <p>
1222
     * createToggleableTextField
1223
     * </p>
1224
     *
1225
     * @param parentElement
1226
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1227
     *            object.
1228
     * @param labelString
1229
     *            a {@link java.lang.String} object.
1230
     * @param initialText
1231
     *            a {@link java.lang.String} object.
1232
     * @param initialState
1233
     *            a boolean.
1234
     * @param style
1235
     *            a int.
1236
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1237
     *         object.
1238
     */
1239
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1240
            String initialText, boolean initialState, int style) {
1241
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1242
                initialState, style | orientation);
1243

    
1244
        adapt(element);
1245
        parentElement.addElement(element);
1246
        return element;
1247
    }
1248

    
1249
    /**
1250
     * <p>
1251
     * createTimePeriodElement
1252
     * </p>
1253
     *
1254
     * @param parentElement
1255
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1256
     *            object.
1257
     * @param labelString
1258
     *            a {@link java.lang.String} object.
1259
     * @param timePeriod
1260
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1261
     * @param style
1262
     *            a int.
1263
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1264
     *         object.
1265
     */
1266
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1267
            TimePeriod timePeriod, int style) {
1268
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1269
        adapt(element);
1270
        parentElement.addElement(element);
1271
        return element;
1272
    }
1273

    
1274
    /**
1275
     * <p>
1276
     * createVerbatimTimePeriodElement
1277
     * </p>
1278
     *
1279
     * @param parentElement
1280
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1281
     *            object.
1282
     * @param labelString
1283
     *            a {@link java.lang.String} object.
1284
     * @param timePeriod
1285
     *            a {@link eu.etaxonomy.cdm.model.common.VerbatimTimePeriod} object.
1286
     * @param style
1287
     *            a int.
1288
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.VerbatimTimePeriodElement}
1289
     *         object.
1290
     */
1291
    public VerbatimTimePeriodElement createVerbatimTimePeriodElement(ICdmFormElement parentElement, String labelString,
1292
            VerbatimTimePeriod timePeriod, int style) {
1293
        VerbatimTimePeriodElement element = new VerbatimTimePeriodElement(this, parentElement, labelString, timePeriod, style);
1294
        adapt(element);
1295
        parentElement.addElement(element);
1296
        return element;
1297
    }
1298

    
1299
	/**
1300
	 * <p>
1301
	 * createGatheringEventUnitElement
1302
	 * </p>
1303
	 *
1304
	 * @param parentElement
1305
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1306
	 *            object.
1307
	 * @param labelString
1308
	 *            a {@link java.lang.String} object.
1309
	 * @param timePeriod
1310
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1311
	 * @param style
1312
	 *            a int.
1313
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1314
	 *         object.
1315
	 */
1316
	public GatheringEventUnitElement createGatheringEventUnitElement(
1317
			ICdmFormElement parentElement,
1318
			String labelString,
1319
			DerivedUnitFacade gatheringEvent,
1320
			MinMaxTextSection.UnitType unitType,
1321
			int style) {
1322
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1323
				parentElement,
1324
				labelString,
1325
				gatheringEvent,
1326
				unitType,
1327
				style);
1328
		adapt(element);
1329
		parentElement.addElement(element);
1330
		return element;
1331
	}
1332

    
1333
    /**
1334
     * <p>
1335
     * createPointElement
1336
     * </p>
1337
     *
1338
     * @param style
1339
     *            a int.
1340
     * @param parentElement
1341
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1342
     *            object.
1343
     * @param point
1344
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1345
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1346
     */
1347
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1348
        PointElement element = new PointElement(this, parentElement, point, style);
1349
        adapt(element);
1350
        parentElement.addElement(element);
1351
        return element;
1352
    }
1353

    
1354
    /**
1355
     * Creates an empty section with the given message.<br>
1356
     * If message is <code>null</code> a default message will be displayed.
1357
     */
1358
    public EmptySection createEmptySection(String message, CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1359
        EmptySection section = new EmptySection(message, formFactory, parentElement, style);
1360
        parentElement.addElement(section);
1361
        adapt(section);
1362
        return section;
1363
    }
1364

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

    
1385
    /**
1386
     * <p>
1387
     * createVerbatimDateDetailSection
1388
     * </p>
1389
     *
1390
     * @param parentElement
1391
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1392
     *            object.
1393
     * @param style
1394
     *            a int.
1395
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.VerbatimDateDetailSection}
1396
     *         object.
1397
     */
1398
    public DateDetailSection<VerbatimTimePeriod> createVerbatimDateDetailSection(ICdmFormElement parentElement, int style) {
1399
        DateDetailSection<VerbatimTimePeriod> section
1400
        	= new DateDetailSection<VerbatimTimePeriod>(this, parentElement, true, style);
1401
        parentElement.addElement(section);
1402
        adapt(section);
1403
        return section;
1404
    }
1405

    
1406
	/**
1407
	 * <p>
1408
	 * createDateDetailSection
1409
	 * </p>
1410
	 *
1411
	 * @param parentElement
1412
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1413
	 *            object.
1414
	 * @param style
1415
	 *            a int.
1416
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1417
	 *         object.
1418
	 */
1419
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1420
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1421
		parentElement.addElement(section);
1422
		adapt(section);
1423
		return section;
1424
	}
1425

    
1426
    /**
1427
     * <p>
1428
     * createPartialElement
1429
     * </p>
1430
     *
1431
     * @param parentElement
1432
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1433
     *            object.
1434
     * @param labelString
1435
     *            a {@link java.lang.String} object.
1436
     * @param partial
1437
     *            a {@link org.joda.time.Partial} object.
1438
     * @param style
1439
     *            a int.
1440
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1441
     *         object.
1442
     */
1443
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1444
            int style) {
1445
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1446
        adapt(element);
1447
        parentElement.addElement(element);
1448
        return element;
1449
    }
1450

    
1451
    /**
1452
     * <p>
1453
     * addSelectionListener
1454
     * </p>
1455
     *
1456
     * @param listener
1457
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1458
     */
1459
    public void addSelectionListener(SelectionListener listener) {
1460
        selectionListenerList.add(listener);
1461
    }
1462

    
1463
    /**
1464
     * <p>
1465
     * removeSelectionListener
1466
     * </p>
1467
     *
1468
     * @param listener
1469
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1470
     */
1471
    public void removeSelectionListener(SelectionListener listener) {
1472
        if (listener == null) {
1473
            MessagingUtils.error(this.getClass(),
1474
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1475
        } else {
1476
            selectionListenerList.remove(listener);
1477
        }
1478
    }
1479

    
1480
    /**
1481
     * <p>
1482
     * addPropertyChangeListener
1483
     * </p>
1484
     *
1485
     * @param listener
1486
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1487
     *            object.
1488
     */
1489
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1490
        if (propertyChangeListeners.contains(listener)) {
1491
            return;
1492
        }
1493
        propertyChangeListeners.add(0, listener);
1494
    }
1495

    
1496
    /**
1497
     * <p>
1498
     * removePropertyChangeListener
1499
     * </p>
1500
     *
1501
     * @param listener
1502
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1503
     *            object.
1504
     */
1505
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1506
        propertyChangeListeners.remove(listener);
1507
    }
1508

    
1509
    /**
1510
     * @return the propertyChangeListeners
1511
     */
1512
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1513
        return propertyChangeListeners;
1514
    }
1515

    
1516
    /**
1517
     * <p>
1518
     * createHorizontalSeparator
1519
     * </p>
1520
     *
1521
     * @param parentElement
1522
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1523
     *            object.
1524
     * @param style
1525
     *            a int.
1526
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1527
     */
1528
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1529
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1530
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1531
        return separator;
1532
    }
1533

    
1534
    /**
1535
     * <p>
1536
     * createVersionElement
1537
     * </p>
1538
     *
1539
     * @param parentElement
1540
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1541
     *            object.
1542
     * @param entity
1543
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1544
     *            object.
1545
     * @param style
1546
     *            a int.
1547
     * @return a
1548
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1549
     *         object.
1550
     */
1551
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1552
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1553
        adapt(element);
1554
        parentElement.addElement(element);
1555
        return element;
1556
    }
1557

    
1558
    /**
1559
     * @param cdmBaseSection
1560
     * @param object
1561
     * @param style
1562
     * @return
1563
     */
1564
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1565
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1566
        adapt(element);
1567
        parentElement.addElement(element);
1568
        return element;
1569
    }
1570

    
1571
    /**
1572
     * <p>
1573
     * createVersionSection
1574
     * </p>
1575
     *
1576
     * @param parentElement
1577
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1578
     *            object.
1579
     * @param style
1580
     *            a int.
1581
     * @return a
1582
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1583
     *         object.
1584
     */
1585
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1586
        VersionSection section = new VersionSection(this, parentElement, style);
1587
        parentElement.addElement(section);
1588
        adapt(section);
1589
        return section;
1590
    }
1591

    
1592
    /**
1593
     * @param parent
1594
     * @param i
1595
     * @return
1596
     */
1597
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1598
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1599
        parentElement.addElement(section);
1600
        adapt(section);
1601
        return section;
1602
    }
1603

    
1604
    /**
1605
     * <p>
1606
     * createEmptyElement
1607
     * </p>
1608
     *
1609
     * @param parentElement
1610
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1611
     *            object.
1612
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1613
     */
1614
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1615
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1616
        adapt(element);
1617
        parentElement.addElement(element);
1618
        return element;
1619
    }
1620

    
1621
    /**
1622
     * <p>
1623
     * createHeadlineSection
1624
     * </p>
1625
     *
1626
     * @param parentElement
1627
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1628
     *            object.
1629
     * @return a
1630
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1631
     *         object.
1632
     */
1633
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1634
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1635
        parentElement.addElement(section);
1636
        adapt(section);
1637
        return section;
1638
    }
1639

    
1640
    /**
1641
     * <p>
1642
     * createParsingMessageElement
1643
     * </p>
1644
     *
1645
     * @param parentElement
1646
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1647
     *            object.
1648
     * @param parserProblem
1649
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1650
     *            object.
1651
     * @param style
1652
     *            a int.
1653
     * @return a
1654
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1655
     *         object.
1656
     */
1657
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1658
            ParserProblem parserProblem, int style) {
1659
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1660
        adapt(element);
1661
        parentElement.addElement(element);
1662
        return element;
1663
    }
1664

    
1665
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1666
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1667

    
1668
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1669
                selectionProvider, style);
1670

    
1671
        parentElement.addElement(section);
1672
        adapt(section);
1673
        return section;
1674

    
1675
    }
1676

    
1677
    /**
1678
     * @param definedTermClass
1679
     * @param formElement
1680
     * @param style
1681
     * @return
1682
     */
1683
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1684
            AbstractCdmDetailSection parentElement, int style) {
1685
        AbstractCdmDetailElement element = null;
1686

    
1687
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1688
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1689
        } else if (definedTermClass.equals(Feature.class)) {
1690
            element = new FeatureDetailElement(this, parentElement);
1691
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1692
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1693
        } else {
1694
            element = new DefinedTermDetailElement(this, parentElement);
1695
        }
1696

    
1697

    
1698
        adapt(element);
1699
        parentElement.addElement(element);
1700
        return element;
1701
    }
1702

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

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

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

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

    
1727

    
1728
    //--------DetailSections---------
1729
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1730
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1731
        addAndAdaptSection(parentElement, section);
1732
        return section;
1733
    }
1734

    
1735
    public FeatureNodeDetailSection createFeatureNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1736
        FeatureNodeDetailSection section = new FeatureNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1737
        addAndAdaptSection(parentElement, section);
1738
        return section;
1739
    }
1740

    
1741
    public FeatureTreeDetailSection createFeatureTreeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1742
        FeatureTreeDetailSection section = new FeatureTreeDetailSection(this, conversation, parentElement, selectionProvider, style);
1743
        addAndAdaptSection(parentElement, section);
1744
        return section;
1745
    }
1746

    
1747
    public ReferenceDetailSection createReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1748
        ReferenceDetailSection section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1749
        addAndAdaptSection(parentElement, section);
1750
        return section;
1751
    }
1752

    
1753
    public NomenclaturalReferenceDetailSection createNomenclaturalReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1754
        NomenclaturalReferenceDetailSection section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1755
        addAndAdaptSection(parentElement, section);
1756
        return section;
1757
    }
1758

    
1759
    public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1760
        TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1761
        addAndAdaptSection(parentElement, section);
1762
        return section;
1763
    }
1764

    
1765
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1766
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1767
        addAndAdaptSection(parentElement, section);
1768
        return section;
1769
    }
1770

    
1771
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1772
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1773
        addAndAdaptSection(parentElement, section);
1774
        return section;
1775
    }
1776

    
1777
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1778
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1779
        addAndAdaptSection(parentElement, section);
1780
        return section;
1781
    }
1782

    
1783
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1784
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1785
        addAndAdaptSection(parentElement, section);
1786
        return section;
1787
    }
1788

    
1789
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1790
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1791
        addAndAdaptSection(parentElement, section);
1792
        return section;
1793
    }
1794

    
1795
    public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1796
        DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1797
        addAndAdaptSection(parentElement, section);
1798
        return section;
1799
    }
1800

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

    
1807

    
1808

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

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

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

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

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

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

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

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

    
1857
    public NaturalLanguageSection createNaturalLanguageSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1858
        NaturalLanguageSection section = new NaturalLanguageSection(this, conversation, parentElement, selectionProvider, style);
1859
        addAndAdaptSection(parentElement, section);
1860
        return section;
1861
    }
1862

    
1863
    public FeatureDistributionDetailSection createFeatureDistributionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1864
        FeatureDistributionDetailSection section = new FeatureDistributionDetailSection(this, conversation, parentElement, selectionProvider, style);
1865
        addAndAdaptSection(parentElement, section);
1866
        return section;
1867
    }
1868

    
1869
    public ClassificationDetailSection createClassificationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1870
        ClassificationDetailSection section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style);
1871
        addAndAdaptSection(parentElement, section);
1872
        return section;
1873
    }
1874

    
1875
    public TaxonNodeDetailSection createTaxonNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1876
        TaxonNodeDetailSection section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1877
        addAndAdaptSection(parentElement, section);
1878
        return section;
1879
    }
1880

    
1881
    public PolytomousKeyDetailSection createPolytomousKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1882
        PolytomousKeyDetailSection section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
1883
        addAndAdaptSection(parentElement, section);
1884
        return section;
1885
    }
1886

    
1887
    public PolytomousKeyNodeDetailSection createPolytomousKeyNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1888
        PolytomousKeyNodeDetailSection section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1889
        addAndAdaptSection(parentElement, section);
1890
        return section;
1891
    }
1892

    
1893
    public InstitutionDetailSection createInstitutionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1894
        InstitutionDetailSection section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
1895
        addAndAdaptSection(parentElement, section);
1896
        return section;
1897
    }
1898

    
1899
    public FieldUnitGeneralDetailSection createFieldUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1900
        FieldUnitGeneralDetailSection section = new FieldUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1901
        addAndAdaptSection(parentElement, section);
1902
        return section;
1903
    }
1904

    
1905
    public DerivedUnitGeneralDetailSection createDerivedUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1906
        DerivedUnitGeneralDetailSection section = new DerivedUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1907
        addAndAdaptSection(parentElement, section);
1908
        return section;
1909
    }
1910

    
1911
    public PreservedSpecimenGeneralDetailSection createPreservedSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1912
        PreservedSpecimenGeneralDetailSection section = new PreservedSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1913
        addAndAdaptSection(parentElement, section);
1914
        return section;
1915
    }
1916

    
1917
    public TissueSampleGeneralDetailSection createTissueSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1918
        TissueSampleGeneralDetailSection section = new TissueSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1919
        addAndAdaptSection(parentElement, section);
1920
        return section;
1921
    }
1922

    
1923
    public DnaSampleGeneralDetailSection createDnaSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1924
        DnaSampleGeneralDetailSection section = new DnaSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1925
        addAndAdaptSection(parentElement, section);
1926
        return section;
1927
    }
1928

    
1929
    public DnaSamplePreparationPreservationSection createDnaSamplePreparationPreservationSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1930
        DnaSamplePreparationPreservationSection section = new DnaSamplePreparationPreservationSection(this, conversation, parentElement, selectionProvider, style);
1931
        addAndAdaptSection(parentElement, section);
1932
        return section;
1933
    }
1934

    
1935
    public DnaQualityDetailSection createDnaQualityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1936
        DnaQualityDetailSection section = new DnaQualityDetailSection(this, conversation, parentElement, selectionProvider, style);
1937
        addAndAdaptSection(parentElement, section);
1938
        return section;
1939
    }
1940

    
1941
    public SequenceGeneralDetailSection createSequenceGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1942
        SequenceGeneralDetailSection section = new SequenceGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1943
        addAndAdaptSection(parentElement, section);
1944
        return section;
1945
    }
1946

    
1947
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1948
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
1949
        addAndAdaptSection(parentElement, section);
1950
        return section;
1951
    }
1952

    
1953
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1954
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
1955
        addAndAdaptSection(parentElement, section);
1956
        return section;
1957
    }
1958

    
1959
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1960
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1961
        addAndAdaptSection(parentElement, section);
1962
        return section;
1963
    }
1964

    
1965
    public SingleReadGeneralDetailSection createSingleReadGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1966
        SingleReadGeneralDetailSection section = new SingleReadGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1967
        addAndAdaptSection(parentElement, section);
1968
        return section;
1969
    }
1970

    
1971
    public AmplificationGeneralDetailSection createAmplificationGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1972
        AmplificationGeneralDetailSection section = new AmplificationGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1973
        addAndAdaptSection(parentElement, section);
1974
        return section;
1975
    }
1976

    
1977
    public AmplificationPrimerDetailSection createAmplificationPrimerDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1978
        AmplificationPrimerDetailSection section = new AmplificationPrimerDetailSection(this, conversation, parentElement, selectionProvider, style);
1979
        addAndAdaptSection(parentElement, section);
1980
        return section;
1981
    }
1982

    
1983
    public AmplificationCloningDetailSection createAmplificationCloningDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1984
        AmplificationCloningDetailSection section = new AmplificationCloningDetailSection(this, conversation, parentElement, selectionProvider, style);
1985
        addAndAdaptSection(parentElement, section);
1986
        return section;
1987
    }
1988

    
1989
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1990
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1991
        addAndAdaptSection(parentElement, section);
1992
        return section;
1993
    }
1994

    
1995
    public MediaSpecimenGeneralDetailSection createMediaSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1996
        MediaSpecimenGeneralDetailSection section = new MediaSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1997
        addAndAdaptSection(parentElement, section);
1998
        return section;
1999
    }
2000

    
2001
    public HybridDetailSection createHybridDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2002
        HybridDetailSection section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
2003
        addAndAdaptSection(parentElement, section);
2004
        return section;
2005
    }
2006

    
2007
    public UserDetailSection createUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2008
        UserDetailSection section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
2009
        addAndAdaptSection(parentElement, section);
2010
        return section;
2011
    }
2012

    
2013
    public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2014
        GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
2015
        addAndAdaptSection(parentElement, section);
2016
        return section;
2017
    }
2018

    
2019
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2020
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
2021
        addAndAdaptSection(parentElement, section);
2022
        return section;
2023
    }
2024

    
2025
    public SampleDesignationDetailSection createSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2026
        SampleDesignationDetailSection section = new SampleDesignationDetailSection(this, conversation, parentElement, selectionProvider, style);
2027
        addAndAdaptSection(parentElement, section);
2028
        return section;
2029
    }
2030

    
2031
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2032
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style, true);
2033
        addAndAdaptSection(parentElement, section);
2034
        return section;
2035
    }
2036

    
2037
    public ReferencedEntityDetailSection createReferencedEntityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2038
        ReferencedEntityDetailSection section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
2039
        addAndAdaptSection(parentElement, section);
2040
        return section;
2041
    }
2042

    
2043
    public TermVocabularyDetailSection createTermVocabularyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2044
        TermVocabularyDetailSection section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
2045
        addAndAdaptSection(parentElement, section);
2046
        return section;
2047
    }
2048

    
2049
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2050
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
2051
        addAndAdaptSection(parentElement, section);
2052
        return section;
2053
    }
2054

    
2055
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2056
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
2057
        addAndAdaptSection(parentElement, section);
2058
        return section;
2059
    }
2060

    
2061
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2062
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
2063
        addAndAdaptSection(parentElement, section);
2064
        return section;
2065
    }
2066

    
2067
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
2068
        parentElement.addElement(section);
2069
        adapt(section);
2070
    }
2071

    
2072
    //--------DetailElements------------
2073

    
2074
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
2075
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
2076
        addAndAdaptElement(parentElement, element);
2077
        return element;
2078
    }
2079

    
2080
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
2081
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
2082
        addAndAdaptElement(parentElement, element);
2083
        return element;
2084
    }
2085

    
2086
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
2087
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
2088
        addAndAdaptElement(parentElement, element);
2089
        return element;
2090
    }
2091

    
2092
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
2093
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
2094
        addAndAdaptElement(parentElement, element);
2095
        return element;
2096
    }
2097

    
2098
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
2099
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
2100
        addAndAdaptElement(parentElement, element);
2101
        return element;
2102
    }
2103

    
2104
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
2105
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
2106
        addAndAdaptElement(parentElement, element);
2107
        return element;
2108
    }
2109

    
2110
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
2111
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2112
        addAndAdaptElement(parentElement, element);
2113
        return element;
2114
    }
2115

    
2116
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2117
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2118
        addAndAdaptElement(parentElement, element);
2119
        return element;
2120
    }
2121

    
2122
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2123
        UserDetailElement element = new UserDetailElement(this, parentElement);
2124
        addAndAdaptElement(parentElement, element);
2125
        return element;
2126
    }
2127

    
2128
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2129
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2130
        addAndAdaptElement(parentElement, element);
2131
        return element;
2132
    }
2133

    
2134
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2135
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2136
        addAndAdaptElement(parentElement, element);
2137
        return element;
2138
    }
2139

    
2140
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2141
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2142
        addAndAdaptElement(parentElement, element);
2143
        return element;
2144
    }
2145

    
2146
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2147
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2148
        addAndAdaptElement(parentElement, element);
2149
        return element;
2150
    }
2151

    
2152
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2153
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2154
        addAndAdaptElement(parentElement, element);
2155
        return element;
2156
    }
2157

    
2158
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2159
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2160
        adapt(element);
2161
        parentElement.addElement(element);
2162

    
2163
        return element;
2164
    }
2165

    
2166
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2167
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2168
        addAndAdaptElement(parentElement, element);
2169
        return element;
2170
    }
2171

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

    
2178
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2179
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2180
        addAndAdaptElement(parentElement, element);
2181
        return element;
2182
    }
2183

    
2184
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2185
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2186
        addAndAdaptElement(parentElement, element);
2187
        return element;
2188
    }
2189

    
2190
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2191
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2192
        addAndAdaptElement(parentElement, element);
2193
        return element;
2194
    }
2195

    
2196
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2197
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2198
        addAndAdaptElement(parentElement, element);
2199
        return element;
2200
    }
2201

    
2202
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2203
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2204
        addAndAdaptElement(parentElement, element);
2205
        return element;
2206
    }
2207

    
2208
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2209
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2210
        addAndAdaptElement(parentElement, element);
2211
        return element;
2212
    }
2213

    
2214
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2215
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2216
        addAndAdaptElement(parentElement, element);
2217
        return element;
2218
    }
2219

    
2220
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2221
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2222
        addAndAdaptElement(parentElement, element);
2223
        return element;
2224
    }
2225

    
2226
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2227
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2228
        addAndAdaptElement(parentElement, element);
2229
        return element;
2230
    }
2231

    
2232
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2233
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2234
        addAndAdaptElement(parentElement, element);
2235
        return element;
2236
    }
2237

    
2238
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2239
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2240
        addAndAdaptElement(parentElement, element);
2241
        return element;
2242
    }
2243

    
2244
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2245
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2246
        addAndAdaptElement(parentElement, element);
2247
        return element;
2248
    }
2249

    
2250
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2251
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2252
        addAndAdaptElement(parentElement, element);
2253
        return element;
2254
    }
2255

    
2256

    
2257
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2258
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2259
        addAndAdaptElement(parentElement, element);
2260
        return element;
2261
    }
2262

    
2263
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2264
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2265
        addAndAdaptElement(parentElement, element);
2266
        return element;
2267
    }
2268

    
2269
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2270
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2271
        addAndAdaptElement(parentElement, element);
2272
        return element;
2273
    }
2274

    
2275
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2276
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2277
        addAndAdaptElement(parentElement, element);
2278
        return element;
2279
    }
2280

    
2281
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2282
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2283
        addAndAdaptElement(parentElement, element);
2284
        return element;
2285
    }
2286

    
2287
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2288
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2289
        addAndAdaptElement(parentElement, element);
2290
        return element;
2291
    }
2292

    
2293
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2294
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2295
        addAndAdaptElement(parentElement, element);
2296
        return element;
2297
    }
2298

    
2299
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2300
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2301
        addAndAdaptElement(parentElement, element);
2302
        return element;
2303
    }
2304

    
2305
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2306
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2307
        addAndAdaptElement(parentElement, element);
2308
        return element;
2309
    }
2310

    
2311
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2312
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2313
        addAndAdaptElement(parentElement, element);
2314
        return element;
2315
    }
2316

    
2317
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2318
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2319
        addAndAdaptElement(parentElement, element);
2320
        return element;
2321
    }
2322

    
2323
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2324
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2325
        addAndAdaptElement(parentElement, element);
2326
        return element;
2327
    }
2328

    
2329
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2330
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2331
        addAndAdaptElement(parentElement, element);
2332
        return element;
2333
    }
2334

    
2335
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2336
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2337
        addAndAdaptElement(parentElement, element);
2338
        return element;
2339
    }
2340

    
2341
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2342
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2343
        addAndAdaptElement(parentElement, element);
2344
        return element;
2345
    }
2346

    
2347
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2348
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2349
        addAndAdaptElement(parentElement, element);
2350
        return element;
2351
    }
2352

    
2353
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2354
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2355
        addAndAdaptElement(parentElement, mediaDetailElement);
2356
        return mediaDetailElement;
2357
    }
2358

    
2359
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2360
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2361
        addAndAdaptElement(parentElement, element);
2362
        return element;
2363
    }
2364

    
2365
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2366
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2367
        addAndAdaptElement(parentElement, element);
2368
        return element;
2369
    }
2370

    
2371
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2372
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2373
        addAndAdaptElement(parentElement, element);
2374
        return element;
2375
    }
2376

    
2377
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2378
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2379
        addAndAdaptElement(parentElement, element);
2380
        return element;
2381
    }
2382

    
2383
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2384
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2385
        addAndAdaptElement(parentElement, element);
2386
        return element;
2387
    }
2388

    
2389
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2390
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2391
        addAndAdaptElement(parentElement, element);
2392
        return element;
2393
    }
2394

    
2395
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2396
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2397
        addAndAdaptElement(parentElement, element);
2398
        return element;
2399
    }
2400

    
2401
    /**
2402
     * @param parentElement
2403
     * @param element
2404
     */
2405
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2406
        adapt(element);
2407
        parentElement.addElement(element);
2408
    }
2409

    
2410
    //--------EntityCollectionSection----------
2411
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2412
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2413
        addAndAdaptSection(parentElement, section);
2414
        return section;
2415
    }
2416

    
2417
    public InapplicableIfEntityCollectionSection createInapplicableIfEntityCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2418
        InapplicableIfEntityCollectionSection section = new InapplicableIfEntityCollectionSection(this, conversation, parentElement, style);
2419
        addAndAdaptSection(parentElement, section);
2420
        return section;
2421
    }
2422

    
2423
    public OnlyApplicableIfEntityCollectionSection createOnlyApplicableIfEntityCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2424
        OnlyApplicableIfEntityCollectionSection section = new OnlyApplicableIfEntityCollectionSection(this, conversation, parentElement, style);
2425
        addAndAdaptSection(parentElement, section);
2426
        return section;
2427
    }
2428

    
2429
    public AnnotationSection createAnnotationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2430
        AnnotationSection section = new AnnotationSection(this, conversation, parentElement, style);
2431
        addAndAdaptSection(parentElement, section);
2432
        return section;
2433
    }
2434

    
2435
    public CreditSection createCreditSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2436
        CreditSection section = new CreditSection(this, conversation, parentElement, style);
2437
        addAndAdaptSection(parentElement, section);
2438
        return section;
2439
    }
2440

    
2441
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2442
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2443
        addAndAdaptSection(parentElement, section);
2444
        return section;
2445
    }
2446

    
2447
    public ExtensionSection createExtensionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2448
        ExtensionSection section = new ExtensionSection(this, conversation, parentElement, style);
2449
        addAndAdaptSection(parentElement, section);
2450
        return section;
2451
    }
2452

    
2453
    public MarkerSection createMarkerSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2454
        MarkerSection section = new MarkerSection(this, conversation, parentElement, style);
2455
        addAndAdaptSection(parentElement, section);
2456
        return section;
2457
    }
2458

    
2459
    public MediaSection createMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2460
        MediaSection section = new MediaSection(this, conversation, parentElement, style);
2461
        addAndAdaptSection(parentElement, section);
2462
        return section;
2463
    }
2464

    
2465
    public DescriptionElementMediaSection createDescriptionElementMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2466
        DescriptionElementMediaSection section = new DescriptionElementMediaSection(this, conversation, parentElement, style);
2467
        addAndAdaptSection(parentElement, section);
2468
        return section;
2469
    }
2470

    
2471
    public MediaRepresentationSection createMediaRepresentationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2472
        MediaRepresentationSection section = new MediaRepresentationSection(this, conversation, parentElement, style);
2473
        addAndAdaptSection(parentElement, section);
2474
        return section;
2475
    }
2476

    
2477
    public MediaRepresentationPartSection createMediaRepresentationPartSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2478
        MediaRepresentationPartSection section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
2479
        addAndAdaptSection(parentElement, section);
2480
        return section;
2481
    }
2482

    
2483
    public ModifierSection createModifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2484
        ModifierSection section = new ModifierSection(this, conversation, parentElement, style);
2485
        addAndAdaptSection(parentElement, section);
2486
        return section;
2487
    }
2488

    
2489
    public NomenclaturalStatusSection createNomenclaturalStatusSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2490
        NomenclaturalStatusSection section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
2491
        addAndAdaptSection(parentElement, section);
2492
        return section;
2493
    }
2494

    
2495
    public NameRelationshipDetailSection createNameRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2496
        NameRelationshipDetailSection section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
2497
        addAndAdaptSection(parentElement, section);
2498
        return section;
2499
    }
2500

    
2501
    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2502
        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2503
        addAndAdaptSection(parentElement, section);
2504
        return section;
2505
    }
2506
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2507
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, style);
2508
        addAndAdaptSection(parentElement, section);
2509
        return section;
2510
    }
2511

    
2512
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2513
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2514
        addAndAdaptSection(parentElement, section);
2515
        return section;
2516
    }
2517

    
2518
    public SourceSection createSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2519
        SourceSection section = new SourceSection(this, conversation, parentElement, style);
2520
        addAndAdaptSection(parentElement, section);
2521
        return section;
2522
    }
2523

    
2524
    public ScopeSection createScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2525
        ScopeSection section = new ScopeSection(this, conversation, parentElement, style);
2526
        addAndAdaptSection(parentElement, section);
2527
        return section;
2528
    }
2529

    
2530
    public DescriptionSourceSection createDescriptionSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2531
        DescriptionSourceSection section = new DescriptionSourceSection(this, conversation, parentElement, style);
2532
        addAndAdaptSection(parentElement, section);
2533
        return section;
2534
    }
2535

    
2536
    public TypeDesignationSection createTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2537
        TypeDesignationSection section = new TypeDesignationSection(this, conversation, parentElement, style);
2538
        addAndAdaptSection(parentElement, section);
2539
        return section;
2540
    }
2541

    
2542
    public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2543
        StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
2544
        addAndAdaptSection(parentElement, section);
2545
        return section;
2546
    }
2547

    
2548
    public StatisticalMeasurementValueSection createStatisticalMeasurementValueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2549
        StatisticalMeasurementValueSection section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
2550
        addAndAdaptSection(parentElement, section);
2551
        return section;
2552
    }
2553

    
2554
    public DescribedSpecimenSection createDescribedSpecimenSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2555
        DescribedSpecimenSection section = new DescribedSpecimenSection(this, conversation, parentElement, style);
2556
        addAndAdaptSection(parentElement, section);
2557
        return section;
2558
    }
2559

    
2560
    public StateVocabularyCollectionSection createStateVocabulariesSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2561
        StateVocabularyCollectionSection section = new StateVocabularyCollectionSection(this, conversation, parentElement, style);
2562
        addAndAdaptSection(parentElement, section);
2563
        return section;
2564
    }
2565

    
2566
    public RecommendedModifierVocabulariesCollectionSection createRecommendedModifierVocabulariesCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2567
        RecommendedModifierVocabulariesCollectionSection section = new RecommendedModifierVocabulariesCollectionSection(this, conversation, parentElement, style);
2568
        addAndAdaptSection(parentElement, section);
2569
        return section;
2570
    }
2571

    
2572
    public MeasurementUnitCollectionSection createMeasurementUnitCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2573
        MeasurementUnitCollectionSection section = new MeasurementUnitCollectionSection(this, conversation, parentElement, style);
2574
        addAndAdaptSection(parentElement, section);
2575
        return section;
2576
    }
2577

    
2578
    public StatisticalMeasureCollectionSection createStatisticalMeasureCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2579
        StatisticalMeasureCollectionSection section = new StatisticalMeasureCollectionSection(this, conversation, parentElement, style);
2580
        addAndAdaptSection(parentElement, section);
2581
        return section;
2582
    }
2583

    
2584
    public CollectingAreasDetailSection createCollectingAreasDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2585
        CollectingAreasDetailSection section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
2586
        addAndAdaptSection(parentElement, section);
2587
        return section;
2588
    }
2589

    
2590
    public GeoScopeDetailSection createGeoScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2591
        GeoScopeDetailSection section = new GeoScopeDetailSection(this, conversation, parentElement, style);
2592
        addAndAdaptSection(parentElement, section);
2593
        return section;
2594
    }
2595

    
2596
    public GeoScopePolyKeyDetailSection createGeoScopePolyKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2597
        GeoScopePolyKeyDetailSection section = new GeoScopePolyKeyDetailSection(this, conversation, parentElement, style);
2598
        addAndAdaptSection(parentElement, section);
2599
        return section;
2600
    }
2601

    
2602
    public IdentifierSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2603
        IdentifierSection section = new IdentifierSection(this, conversation, parentElement, style);
2604
        addAndAdaptSection(parentElement, section);
2605
        return section;
2606
    }
2607

    
2608
    public DerivedUnitFacadeIdentifierSection createDerivedUnitFacadeIdentifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2609
    	DerivedUnitFacadeIdentifierSection section = new DerivedUnitFacadeIdentifierSection(this, conversation, parentElement, style);
2610
    	addAndAdaptSection(parentElement, section);
2611
    	return section;
2612
    }
2613

    
2614
    public CurrentSampleDesignationDetailSection createCurrentSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2615
        CurrentSampleDesignationDetailSection section = new CurrentSampleDesignationDetailSection(this, conversation, parentElement, style);
2616
        addAndAdaptSection(parentElement, section);
2617
        return section;
2618
    }
2619

    
2620
    public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2621
        CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
2622
        addAndAdaptSection(parentElement, section);
2623
        return section;
2624
    }
2625

    
2626
    public PreservedSpecimenCurrentDeterminationDetailSection createPreservedSpecimenCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2627
        PreservedSpecimenCurrentDeterminationDetailSection section = new PreservedSpecimenCurrentDeterminationDetailSection(this, conversation, parentElement, style);
2628
        addAndAdaptSection(parentElement, section);
2629
        return section;
2630
    }
2631

    
2632
    public SampleDesignationHistoryDetailSection createSampleDesignationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2633
        SampleDesignationHistoryDetailSection section = new SampleDesignationHistoryDetailSection(this, conversation, parentElement, style);
2634
        addAndAdaptSection(parentElement, section);
2635
        return section;
2636
    }
2637

    
2638
    public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2639
        DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
2640
        addAndAdaptSection(parentElement, section);
2641
        return section;
2642
    }
2643

    
2644
    public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2645
        SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
2646
        addAndAdaptSection(parentElement, section);
2647
        return section;
2648
    }
2649

    
2650
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2651
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2652
        addAndAdaptSection(parentElement, section);
2653
        return section;
2654
    }
2655

    
2656
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2657
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2658
        addAndAdaptSection(parentElement, section);
2659
        return section;
2660
    }
2661

    
2662
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2663
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2664
        addAndAdaptSection(parentElement, section);
2665
        return section;
2666
    }
2667

    
2668
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2669
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2670
        addAndAdaptSection(parentElement, section);
2671
        return section;
2672
    }
2673

    
2674
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2675
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2676
        addAndAdaptSection(parentElement, section);
2677
        return section;
2678
    }
2679

    
2680
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2681
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2682
        addAndAdaptSection(parentElement, section);
2683
        return section;
2684
    }
2685

    
2686
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2687
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2688
        addAndAdaptSection(parentElement, section);
2689
        return section;
2690
    }
2691

    
2692

    
2693
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2694
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2695
        AbstractEntityCollectionElement<?> element = null;
2696

    
2697
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2698

    
2699
        if (entity instanceof Annotation) {
2700
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2701
        }else if (entity instanceof Person ) {
2702
            boolean isNomenclatural = false;
2703
            if (parentElement instanceof TeamMemberSection){
2704
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2705
            }
2706
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2707
        } else if (entity instanceof Credit) {
2708
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2709
        } else if (entity instanceof Extension) {
2710
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2711
        } else if (entity instanceof ExternalLink) {
2712
            element = new ExternalLinksElement(this, parentElement, (ExternalLink) entity, removeListener, style);
2713
        } else if (entity instanceof Marker) {
2714
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2715
        } else if (entity instanceof TaxonNodeAgentRelation) {
2716
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2717
        }else if (entity instanceof Media) {
2718
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2719
        } else if (entity instanceof MediaRepresentation) {
2720
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2721
                    style);
2722
        } else if (entity instanceof ImageFile) {
2723
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2724
        } else if (entity instanceof MediaRepresentationPart) {
2725
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2726
                    removeListener, style);
2727
        } else if (entity instanceof NomenclaturalStatus) {
2728
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2729
                    style);
2730
        } else if (entity instanceof Rights) {
2731
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2732
        } else if (entity instanceof DescriptionElementSource && parentElement.getEntity() instanceof CommonTaxonName) {
2733
            element = new CommonNameSourceElement(this, parentElement, (DescriptionElementSource) entity,
2734
                    removeListener, style);
2735
        } else if (entity instanceof DescriptionElementSource) {
2736
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2737
                    removeListener, style, false);
2738
        } else if (entity instanceof TaxonNodeAgentRelation) {
2739
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2740
                    removeListener,backgroundColor, style);
2741
        }
2742
        else if (entity instanceof IdentifiableSource) {
2743
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2744
                    style);
2745
        } else if (entity instanceof DefinedTerm) {
2746
            switch(((DefinedTerm)entity).getTermType()) {
2747
            case Scope:
2748
                element = new ScopeElement(this,
2749
                        parentElement,
2750
                        (DefinedTerm) entity,
2751
                        removeListener,
2752
                        style);
2753
                break;
2754
            case Modifier:
2755
                element = new ModifierElement(this,
2756
                        parentElement,
2757
                        (DefinedTerm) entity,
2758
                        removeListener,
2759
                        style);
2760
                break;
2761
            default:
2762
                break;
2763

    
2764
            }
2765
        } else if (entity instanceof Reference) {
2766
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2767
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2768
            }
2769
            else{
2770
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2771
            }
2772
        } else if (entity instanceof NameTypeDesignation) {
2773
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2774
                    style);
2775
        } else if (entity instanceof NameRelationship) {
2776
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2777
                    style);
2778
        } else if (entity instanceof SpecimenTypeDesignation) {
2779
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
2780
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2781
                        removeListener, style);
2782
            }
2783
            else{
2784
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2785
                        removeListener, style);
2786
            }
2787
        } else if (entity instanceof StateData) {
2788
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2789
        } else if (entity instanceof StatisticalMeasurementValue) {
2790
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2791
                    removeListener, style);
2792
        } else if (entity instanceof DerivedUnit) {
2793
            switch(((DerivedUnit)entity).getRecordBasis()) {
2794
            case LivingSpecimen:
2795
            case PreservedSpecimen:
2796
            case OtherSpecimen:
2797
                element = new SpecimenCollectionDetailElement(this,
2798
                        parentElement,
2799
                        (DerivedUnit) entity,
2800
                        removeListener,
2801
                        style);
2802
                break;
2803
            default:
2804
                element = new DerivedUnitElement(this,
2805
                        parentElement,
2806
                        (DerivedUnit) entity,
2807
                        removeListener,
2808
                        style);
2809
            }
2810

    
2811
        } else if (entity instanceof NamedArea) {
2812
            element = new CollectingAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2813
        } else if (entity instanceof DeterminationEvent) {
2814
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2815
        } else if (entity instanceof User) {
2816
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2817
        } else if (entity instanceof GrantedAuthority) {
2818
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
2819
                    removeListener, style);
2820
        } else if (entity instanceof Group) {
2821
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2822
        } else if (entity instanceof Taxon) {
2823
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2824
        } else if (entity instanceof DescriptionElementBase) {
2825
            // this is the special case for protologs, maybe we can do this
2826
            // differently when API improves
2827
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2828
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2829
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2830
            }
2831
        } else if (entity instanceof Identifier) {
2832
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2833
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2834
            }
2835
            else{
2836
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
2837
            }
2838
        } else if (entity instanceof TermVocabulary) {
2839
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
2840
            switch (termVocabulary.getTermType()) {
2841
            case State:
2842
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
2843
                break;
2844
            case Modifier:
2845
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
2846
                break;
2847
            default:
2848
                break;
2849
            }
2850
        } else if (entity instanceof MeasurementUnit) {
2851
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2852
        } else if (entity instanceof StatisticalMeasure) {
2853
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2854
        } else if (entity instanceof State && parentElement instanceof InapplicableIfEntityCollectionSection) {
2855
            element = new InapplicableIfCollectionElement(this, parentElement, (State) entity, removeListener, backgroundColor, style);
2856
        } else if (entity instanceof State && parentElement instanceof OnlyApplicableIfEntityCollectionSection) {
2857
            element = new OnlyApplicableIfCollectionElement(this, parentElement, (State) entity, removeListener, backgroundColor, style);
2858
        }
2859

    
2860
        //check for parent section when entity is null
2861
        //this happens when AbstractUnboundEntityCollectionSection is used
2862
        if(element==null){
2863
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
2864
                element = new ScopeElement(this,
2865
                        parentElement,
2866
                        (DefinedTerm) entity,
2867
                        removeListener,
2868
                        style);
2869
            }
2870
            else if(parentElement instanceof ModifierSection){
2871
                element = new ModifierElement(this,
2872
                        parentElement,
2873
                        (DefinedTerm) entity,
2874
                        removeListener,
2875
                        style);
2876
            }
2877
        }
2878

    
2879

    
2880
        if (element == null) {
2881
            MessagingUtils.messageDialog(
2882
                    String.format("Error when creating section %s",
2883
                            parentElement.getClass().getSimpleName()),
2884
                    this,
2885
                    String.format("Could not generate collection element for entity of class %s."
2886
                            + " Looks like the case is not yet handled. Check implementation.\n"
2887
                            + "Entity: %s", entity.getClass(), entity.toString()), null);
2888
        }
2889

    
2890
        else{
2891
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2892
                element.setPersistentBackground(backgroundColor);
2893
            }
2894
            adapt(element);
2895
            parentElement.addElement(element);
2896
        }
2897

    
2898
        return element;
2899
    }
2900

    
2901
    /**
2902
     * <p>
2903
     * Creates a selection element for the given type T.
2904
     * </p>
2905
     * <p>
2906
     * <strong>Selection elements not handled by this method:</strong>
2907
     * <ul>
2908
     * <li>{@link TaxonNodeSelectionElement} see
2909
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2910
     * </li>
2911
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2912
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2913
     * </li>
2914
     * </ul>
2915
     * </p>
2916
     *
2917
     * @param clazz
2918
     *            a {@link Class} object of the type that you want the selection
2919
     *            element to handle
2920
     * @param parentElement
2921
     *            a {@link ICdmFormElement} object.
2922
     * @param labelString
2923
     *            a {@link String} object.
2924
     * @param selectionType
2925
     * @param selection
2926
     *            a {@link ICdmBase} object.
2927
     * @param style
2928
     *            a int.
2929
     * @param conversation
2930
     *            a {@link ConversationHolder} object.
2931
     * @return a {@link EntitySelectionElement} object.
2932
     */
2933
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2934
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2935
            int style, boolean filterElement) {
2936
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
2937
                parentElement, clazz,
2938
                labelString, selection, mode, style, filterElement);
2939
        adapt(element);
2940
        parentElement.addElement(element);
2941
        return element;
2942
    }
2943

    
2944
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2945
//            ConversationHolder conversation,
2946
            ICdmFormElement parentElement, String labelString, T selection, int mode,
2947
            int style) {
2948
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this,
2949
                parentElement, clazz,
2950
                labelString, selection, mode, style);
2951
        adapt(element);
2952
        parentElement.addElement(element);
2953
        return element;
2954
    }
2955

    
2956
    public CommonNameReferenceSelectionElement createCommonNameReferenceSelectionElement(ICdmFormElement parentElement, String labelString, Reference selection, int mode,
2957
          int style) {
2958
        CommonNameReferenceSelectionElement element = new CommonNameReferenceSelectionElement(this,
2959
              parentElement, labelString, selection, mode, style);
2960
      adapt(element);
2961
      parentElement.addElement(element);
2962
      return element;
2963
  }
2964

    
2965
    /**
2966
     * <p>
2967
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
2968
     * </p>
2969
     * <p>
2970
     * <strong>Selection elements not handled by this method:</strong>
2971
     * <ul>
2972
     * <li>{@link TaxonNodeSelectionElement} see
2973
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2974
     * </li>
2975
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2976
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2977
     * </li>
2978
     * </ul>
2979
     * </p>
2980
     *
2981
     * @param clazz
2982
     *            a {@link Class} object of the type that you want the selection
2983
     *            element to handle
2984
     * @param parentElement
2985
     *            a {@link ICdmFormElement} object.
2986
     * @param labelString
2987
     *            a {@link String} object.
2988
     * @param selectionType
2989
     * @param selection
2990
     *            a {@link ICdmBase} object.
2991
     * @param style
2992
     *            a int.
2993
     * @param conversation
2994
     *            a {@link ConversationHolder} object.
2995
     * @return a {@link EntitySelectionElement} object.
2996
     */
2997
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
2998
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
2999
            T selection, int mode, int style) {
3000
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, //conversation,
3001
                parentElement, clazz,
3002
                labelString, selection, mode, style);
3003
        adapt(element);
3004
        parentElement.addElement(element);
3005
        return element;
3006
    }
3007

    
3008
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3009
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
3010
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
3011
                parentElement,
3012
                labelString, selection, mode, style);
3013
        adapt(element);
3014
        parentElement.addElement(element);
3015
        return element;
3016
    }
3017

    
3018

    
3019

    
3020
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
3021
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
3022
//            int mode, int style) {
3023
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
3024
//                conversation, parentElement, labelString, selection, mode, style);
3025
//        adapt(element);
3026
//        parentElement.addElement(element);
3027
//        return element;
3028
//    }
3029

    
3030
    /** {@inheritDoc} */
3031
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
3032
        LabelElement labelElement = new LabelElement(this, parentElement, text);
3033
        adapt(labelElement);
3034
        parentElement.addElement(labelElement);
3035
        return labelElement;
3036
    }
3037

    
3038

    
3039

    
3040
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
3041
//        Label label = new Label(formElement.getLayoutComposite(), style);
3042
//        label.setText(labelText+" (yyyy-MM-dd)");
3043
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
3044
//        dateElement.initInternalController();
3045
//
3046
//        return dateElement;
3047
//    }
3048

    
3049
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
3050
    	 Label label = new Label(formElement.getLayoutComposite(), style);
3051
         label.setText(labelText);
3052
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3053
         DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
3054
         dateElement.initController(this, formElement);
3055
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3056
         return dateElement;
3057
    }
3058

    
3059
    /**
3060
     * <p>
3061
     * Getter for the field <code>selectionProvider</code>.
3062
     * </p>
3063
     *
3064
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
3065
     */
3066
    public ISelectionProvider getSelectionProvider() {
3067
        return selectionProvider;
3068
    }
3069

    
3070
    /**
3071
     * <p>
3072
     * createDetailedDescriptionDetailElement
3073
     * </p>
3074
     *
3075
     * @param parentElement
3076
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3077
     *            object.
3078
     * @param entity
3079
     *            a
3080
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
3081
     *            object.
3082
     * @param style
3083
     *            a int.
3084
     * @return a
3085
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
3086
     *         object.
3087
     */
3088
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
3089
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
3090
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
3091

    
3092
        if (entity instanceof CategoricalData) {
3093
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
3094
                    (CategoricalData) entity, style);
3095
        } else if (entity instanceof CommonTaxonName) {
3096
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
3097
                    style);
3098
        } else if (entity instanceof Distribution && !enabled) {
3099
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3100
                    enabled, style);
3101
        } else if (entity instanceof Distribution) {
3102
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3103
                    true, style);
3104
        }else if (entity instanceof IndividualsAssociation) {
3105
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
3106
                    (IndividualsAssociation) entity, style);
3107
        } else if (entity instanceof QuantitativeData) {
3108
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
3109
                    (QuantitativeData) entity, style);
3110
        } else if (entity instanceof TaxonInteraction) {
3111
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
3112
                    (TaxonInteraction) entity, style);
3113
        } else if (entity instanceof TextData) {
3114
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
3115
        } else {
3116
            throw new IllegalStateException("There is no interface for the given description element");
3117
        }
3118
        adapt(detailedDescriptionElement);
3119
        parentElement.addElement(detailedDescriptionElement);
3120
        return detailedDescriptionElement;
3121

    
3122
    }
3123

    
3124
    /**
3125
     * Creates a styled text as a part of the form.
3126
     *
3127
     * @param parent
3128
     *            the text parent
3129
     * @param value
3130
     *            the text initial value
3131
     * @param style
3132
     *            the text style
3133
     * @return the text widget
3134
     */
3135
    public StyledText createStyledText(Composite parent, String value, int style) {
3136
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3137
        if (value != null) {
3138
            text.setText(value);
3139
        }
3140
        text.setForeground(getColors().getForeground());
3141
        text.setBackground(getColors().getBackground());
3142
        // text.addFocusListener(visibilityHandler);
3143
        return text;
3144
    }
3145

    
3146
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3147
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3148
        addAndAdaptSection(parentElement, section);
3149
        return section;
3150
    }
3151

    
3152
    /**
3153
     * @param formElement
3154
     * @param conversationHolder
3155
     * @param style
3156
     * @return
3157
     */
3158
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3159
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3160
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3161
        addAndAdaptSection(formElement, section);
3162
        return section;
3163
    }
3164

    
3165

    
3166
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3167
			ICdmFormElement parentElement, int style) {
3168
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3169
		addAndAdaptElement(parentElement, section);
3170
        return section;
3171
	}
3172

    
3173
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3174
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3175
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3176
	        addAndAdaptSection(formElement, section);
3177
	        return section;
3178
	}
3179

    
3180

    
3181

    
3182

    
3183

    
3184
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3185
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3186
//				 initialText, textHeight, style);
3187
//	        adapt(element);
3188
//	        parentElement.addElement(element);
3189
//	        return element;
3190
//	}
3191

    
3192

    
3193

    
3194

    
3195

    
3196

    
3197

    
3198
}
(7-7/47)