Project

General

Profile

Download (153 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.events.ExpansionAdapter;
42
import org.eclipse.ui.forms.events.ExpansionEvent;
43
import org.eclipse.ui.forms.widgets.ExpandableComposite;
44
import org.eclipse.ui.forms.widgets.FormToolkit;
45
import org.eclipse.ui.forms.widgets.Section;
46
import org.eclipse.ui.forms.widgets.TableWrapData;
47
import org.eclipse.ui.internal.forms.widgets.FormFonts;
48
import org.joda.time.DateTime;
49
import org.joda.time.Partial;
50
import org.springframework.security.core.GrantedAuthority;
51

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

    
376
/**
377
 * <p>
378
 * CdmFormFactory class.
379
 * </p>
380
 *
381
 * @author n.hoffmann
382
 * @created Feb 24, 2010
383
 */
384
public class CdmFormFactory extends FormToolkit {
385

    
386
    private BoldFontHolder2 boldFontHolder2;
387
    private MouseListener selectionMouseHandler;
388
    private FocusListener selectionFocusHandler;
389

    
390
    @Inject
391
    private IEclipseContext context;
392

    
393
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
394

    
395
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
396

    
397
    private final int orientation = Window.getDefaultOrientation();
398
    private ISelectionProvider selectionProvider;
399

    
400
    /** Constant <code>EMPTY_SELECTION</code> */
401
    public static ISelection EMPTY_SELECTION = new ISelection() {
402
        @Override
403
        public boolean isEmpty() {
404
            return true;
405
        }
406
    };
407

    
408
    /**
409
     *
410
     * @author n.hoffmann
411
     * @date Jan 25, 2010
412
     *
413
     */
414
    private class SelectionMouseHandler extends MouseAdapter {
415
        @Override
416
        public void mouseDown(MouseEvent e) {
417
            notifySelectionListeners(e);
418
        }
419
    }
420

    
421
    /**
422
     *
423
     * @author n.hoffmann
424
     * @date Jan 25, 2010
425
     *
426
     */
427
    private class SelectionFocusHandler extends FocusAdapter {
428
        @Override
429
        public void focusGained(FocusEvent e) {
430
            notifySelectionListeners(e);
431
        }
432
    }
433

    
434
    private void notifySelectionListeners(TypedEvent e) {
435
        Event event = new Event();
436
        event.widget = e.widget;
437
        SelectionEvent selectionEvent = new SelectionEvent(event);
438

    
439
        for (SelectionListener listener : selectionListenerList) {
440
            listener.widgetSelected(selectionEvent);
441
        }
442
    }
443

    
444
    public CdmFormFactory(Display display) {
445
        this(display, null);
446
    }
447

    
448
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
449
        super(display);
450
        this.selectionProvider = selectionProvider;
451
        init();
452
    }
453

    
454
    private void init() {
455
        boldFontHolder2 = new BoldFontHolder2();
456
        selectionMouseHandler = new SelectionMouseHandler();
457
        selectionFocusHandler = new SelectionFocusHandler();
458
    }
459

    
460
    public IEclipseContext getContext() {
461
        return context;
462
    }
463

    
464
    /**
465
     * Creates an instance initialized with the correct selectionProvider
466
     *
467
     * Make sure to remove the instance when the entityComposite disposes via
468
     * destroySelectionArbitrator(..)
469
     *
470
     * @param entityElement
471
     *            a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
472
     *            object.
473
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
474
     *         object.
475
     */
476
    public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
477
        SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
478
        selectionArbitrator.addSelectionProvider(selectionProvider);
479
        selectionProvider.addSelectionChangedListener(selectionArbitrator);
480
        addSelectionListener(selectionArbitrator);
481
        return selectionArbitrator;
482
    }
483

    
484
    /**
485
     * <p>
486
     * destroySelectionArbitrator
487
     * </p>
488
     *
489
     * @param selectionArbitrator
490
     *            a
491
     *            {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
492
     *            object.
493
     */
494
    public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
495
        if(selectionArbitrator==null){
496
            return;
497
        }
498
        removeSelectionListener(selectionArbitrator);
499
        if (selectionProvider != null) {
500
            selectionProvider.removeSelectionChangedListener(selectionArbitrator);
501
        } else {
502
            MessagingUtils.error(this.getClass(),
503
                    "Tried to destroy a selection listener from this factories listeners but was null", null);
504
        }
505
    }
506

    
507
    /**
508
     * <p>
509
     * Adapts the {@link AbstractCdmFormElement}:<br>
510
     * - sets the {@link IPropertyChangeListener}s handled by this class
511
     * </p>
512
     *
513
     * @param formElement
514
     *            a
515
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
516
     *            object.
517
     */
518
    public void adapt(ICdmFormElement formElement) {
519
        formElement.setPropertyChangeListeners(propertyChangeListeners);
520
    }
521

    
522
    /** {@inheritDoc} */
523
    @Override
524
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
525
        if (trackFocus) {
526
            control.addFocusListener(selectionFocusHandler);
527
        }
528
        super.adapt(control, trackFocus, trackKeyboard);
529
    }
530

    
531
    /** {@inheritDoc} */
532
    @Override
533
    public void adapt(Composite composite) {
534
        composite.addMouseListener(selectionMouseHandler);
535

    
536
        super.adapt(composite);
537
    }
538

    
539
    /**
540
     * <p>
541
     * destroyElement
542
     * </p>
543
     *
544
     * @param formElement
545
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
546
     *            object.
547
     */
548
    public void destroyElement(ICdmFormElement formElement) {
549
        // return if element was not initialized
550
        if (formElement == null) {
551
            return;
552
        }
553
        // destroy selection arbitrator, if any
554
        if (formElement instanceof ISelectableElement) {
555
            destroySelectionArbitrator(((ISelectableElement) formElement).getSelectionArbitrator());
556
        }
557
        // remove this element form its parents list of elements
558
        // ICdmFormElement parentElement = formElement.getParentElement();
559
        // if(parentElement != null){
560
        // parentElement.removeElement(formElement);
561
        // }
562
        // call destroy on child elements recursively
563
        for (ICdmFormElement childElement : formElement.getElements()) {
564
            destroyElement(childElement);
565
        }
566
        // dispose of the controls
567
        for (Control control : formElement.getControls()) {
568
            // we added the layoutComposite of the parental element as the
569
            // layout composite to this formElement
570
            // but we do not want to destroy it.
571
            if (control.equals(formElement.getLayoutComposite())) {
572
                continue;
573
            } else {
574
                if (control != null && !control.isDisposed()){
575
                    control.dispose();
576
                }
577
                control = null;
578
            }
579
        }
580
    }
581

    
582
    /**
583
     * <p>
584
     * createEmptyCell
585
     * </p>
586
     *
587
     * @param parent
588
     *            a {@link org.eclipse.swt.widgets.Composite} object.
589
     * @return a {@link org.eclipse.swt.widgets.Label} object.
590
     */
591
    public Label createEmptyCell(Composite parent) {
592
        return this.createLabel(parent, null);
593
    }
594

    
595
    /**
596
     * <p>
597
     * createMultiLanguageTextElement
598
     * </p>
599
     *
600
     * @param parentElement
601
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
602
     *            object.
603
     * @param labelString
604
     *            a {@link java.lang.String} object.
605
     * @param multilanguageText
606
     *            a {@link java.util.Map} object.
607
     * @param textHeight
608
     *            a int.
609
     * @param style
610
     *            a int.
611
     * @return a
612
     *         {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
613
     *         object.
614
     */
615
    public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
616
            Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
617
        MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
618
                multilanguageText, textHeight, style);
619
        adapt(element);
620
        parentElement.addElement(element);
621
        return element;
622
    }
623

    
624
    /**
625
     * <p>
626
     * createMultiLanguageTextElement
627
     * </p>
628
     *
629
     * @param parentElement
630
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
631
     *            object.
632
     *
633
     * @param Representation
634
     *            a {@link eu.etaxonomy.cdm.model.term.Representation} object.
635
     * @param textHeight
636
     *            a int.
637
     * @param style
638
     *            a int.
639
     * @return a
640
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
641
     *         object.
642
     */
643
    public RepresentationElement createRepresentationElement(ICdmFormElement parentElement, Representation representation, TermBase term,int textHeight, int style, boolean fillDetails) {
644
        RepresentationElement element = new RepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
645
        adapt(element);
646
        parentElement.addElement(element);
647
        return element;
648
    }
649

    
650
    /**
651
     * <p>
652
     * createMultiLanguageTextElement
653
     * </p>
654
     *
655
     * @param parentElement
656
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
657
     *            object.
658
     *
659
     * @param Representation
660
     *            a {@link eu.etaxonomy.cdm.model.term.Representation} object.
661
     * @param textHeight
662
     *            a int.
663
     * @param style
664
     *            a int.
665
     * @return a
666
     *         {@link eu.etaxonomy.taxeditor.ui.element.RepresentationElement}
667
     *         object.
668
     */
669
    public TranslatableRepresentationElement createTranslatableRepresentationElement(ICdmFormElement parentElement, Representation representation, TermBase term,int textHeight, int style, boolean fillDetails) {
670
        TranslatableRepresentationElement element = new TranslatableRepresentationElement(this, parentElement, representation, term, textHeight, style, fillDetails);
671
        adapt(element);
672
        parentElement.addElement(element);
673
        return element;
674
    }
675

    
676
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
677
            KeyStatement keyStatement, int textHeight, int style) {
678
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
679
                textHeight, style);
680
        adapt(element);
681
        parentElement.addElement(element);
682
        return element;
683
    }
684

    
685
    /**
686
     * Creates a text field with a label. The initial content will be the return value of the initalObject's {@link #toString()}
687
     * method.<br>
688
     * <b>Note</b>: if initialObject is <code>null</code> then an empty string is used.
689
     * @param parentElement the parent container
690
     * @param labelString the label name
691
     * @param initialObject the object from which the <code>toString()</code> method is called
692
     * @param style {@link SWT} style constant
693
     * @return the created textfield with label
694
     */
695
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
696
            Object initialObject, int style) {
697
        return createTextWithLabelElement(parentElement, labelString, initialObject==null?"":initialObject.toString(), style);
698
    }
699

    
700
    /**
701
     * <p>
702
     * createTextWithLabelElement
703
     * </p>
704
     *
705
     * @param parentElement
706
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
707
     *            object.
708
     * @param labelString
709
     *            a {@link java.lang.String} object.
710
     * @param initialText
711
     *            a {@link java.lang.String} object.
712
     * @param style
713
     *            a int.
714
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
715
     *         object.
716
     */
717
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
718
            String initialText, int style) {
719
        return createTextWithLabelElement(parentElement, labelString, initialText, null, style);
720
    }
721
    /**
722
     * <p>
723
     * createTextWithLabelElement
724
     * </p>
725
     *
726
     * @param parentElement
727
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
728
     *            object.
729
     * @param labelString
730
     *            a {@link java.lang.String} object.
731
     * @param initialText
732
     *            a {@link java.lang.String} object.
733
     * @param textLimit maximal number of characters allowed
734
     * @param style
735
     *            a int.
736
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
737
     *         object.
738
     */
739
    public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
740
            String initialText, Integer textLimit, int style) {
741
        if(initialText==null){
742
            initialText = "";
743
        }
744

    
745
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
746
                textLimit, style);
747
        adapt(element);
748
        parentElement.addElement(element);
749
        return element;
750
    }
751

    
752
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
753
            int textHeight, int style) {
754
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
755
        adapt(element);
756
        parentElement.addElement(element);
757
        return element;
758
    }
759

    
760
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
761
            LSID initialLsid, int style) {
762
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
763
        adapt(element);
764
        parentElement.addElement(element);
765
        return element;
766
    }
767

    
768
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
769
            URI initialUri, int style) {
770
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
771
        adapt(element);
772
        parentElement.addElement(element);
773
        return element;
774
    }
775
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
776
            URI initialUri,Integer textHeight, int style) {
777
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, textHeight, style);
778
        adapt(element);
779
        parentElement.addElement(element);
780
        return element;
781
    }
782

    
783

    
784
    public DoiWithLabelElement createDoiWithLabelElement(ICdmFormElement parentElement, String labelString,
785
            DOI initialDoi, int style) {
786
        DoiWithLabelElement element = new DoiWithLabelElement(this, parentElement, labelString, initialDoi, null, style);
787
        adapt(element);
788
        parentElement.addElement(element);
789
        return element;
790
    }
791
    public DoiWithLabelElement createDoiWithLabelElement(ICdmFormElement parentElement, String labelString,
792
            DOI initialDoi,Integer textHeight, int style) {
793
        DoiWithLabelElement element = new DoiWithLabelElement(this, parentElement, labelString, initialDoi, textHeight, style);
794
        adapt(element);
795
        parentElement.addElement(element);
796
        return element;
797
    }
798

    
799
    /**
800
     * @param element
801
     * @param string
802
     * @param uri
803
     * @param style
804
     * @return
805
     */
806
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
807
            IOpenUrlEnabled openUrlEnabled, int style) {
808
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
809
                style);
810
        adapt(element);
811
        parentElement.addElement(element);
812
        return element;
813
    }
814

    
815
    /**
816
     *
817
     * @param parentElement
818
     * @param labelString
819
     * @param conversationEnabled
820
     * @param user
821
     * @param style
822
     * @return
823
     */
824
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
825
            ConversationHolder conversation, User user, int style) {
826
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
827
        adapt(element);
828
        parentElement.addElement(element);
829
        return element;
830
    }
831

    
832
    /**
833
     * <p>
834
     * createIntegerTextWithLabelElement
835
     * </p>
836
     *
837
     * @param parentElement
838
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
839
     *            object.
840
     * @param labelString
841
     *            a {@link java.lang.String} object.
842
     * @param initialInteger
843
     *            a {@link java.lang.Integer} object.
844
     * @param style
845
     *            a int.
846
     * @return a
847
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
848
     *         object.
849
     */
850
	public NumberWithLabelElement createNumberTextWithLabelElement(
851
			ICdmFormElement parentElement, String labelString,
852
			Number initialNumber, int style) {
853
		NumberWithLabelElement element = new NumberWithLabelElement(this,
854
				parentElement, labelString, initialNumber, style);
855
		adapt(element);
856
		parentElement.addElement(element);
857
		return element;
858
	}
859

    
860
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
861
            String labelString, LanguageString languageString, int style) {
862
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
863
    }
864

    
865
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
866
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
867
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
868
                languageString, height, isMultiLine, style);
869
        adapt(element);
870
        parentElement.addElement(element);
871
        return element;
872
    }
873

    
874
    /**
875
     * <p>
876
     * createKeyValueViewerElement
877
     * </p>
878
     *
879
     * @param parentElement
880
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
881
     *            object.
882
     * @param keyHeading
883
     *            a {@link java.lang.String} object.
884
     * @param valueHeading
885
     *            a {@link java.lang.String} object.
886
     * @param map
887
     *            a {@link java.util.Map} object.
888
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
889
     *         object.
890
     */
891
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
892
            String valueHeading, Map<Object, Object> map) {
893
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
894
        adapt(element);
895
        parentElement.addElement(element);
896
        return element;
897
    }
898
    /**
899
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
900
     */
901
    @Deprecated
902
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
903
            ICdmFormElement parentElement, String labelString, T selection, int style) {
904
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString, selection, true, style);
905
        adapt(element);
906
        parentElement.addElement(element);
907
        return element;
908
    }
909

    
910
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
911
            TermType termType,
912
            ICdmFormElement parentElement,
913
            String labelString,
914
            T selection,
915
            int style,
916
            Comparator<T> comparator) {
917
        return this.createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, true, style, false, comparator);
918
    }
919

    
920
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
921
			TermType termType,
922
			ICdmFormElement parentElement,
923
			String labelString,
924
			T selection,
925
			boolean addEmptyElement,
926
			int style) {
927
        return this.createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, addEmptyElement, style, false, null);
928
	}
929

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

    
939
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
940
            List<T> terms,
941
            ICdmFormElement parentElement,
942
            String labelString,
943
            T selection,
944
            int style) {
945
        return  this.createDefinedTermComboElement(null, null, terms, parentElement, labelString, selection, true, style, false, null);
946
    }
947
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
948
			TermType termType,
949
			ICdmFormElement parentElement,
950
			String labelString,
951
			T selection,
952
			boolean addEmptyElement,
953
			int style,
954
			boolean useAbbrevLabel) {
955
		return createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
956
	}
957

    
958

    
959
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
960
            TermVocabulary<?> termVocabulary,
961
            ICdmFormElement parentElement,
962
            String labelString,
963
            T selection,
964
            int style) {
965
        return this.createDefinedTermComboElement(null, termVocabulary, null, parentElement, labelString, selection, true, style, false, null);
966
    }
967

    
968
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
969
	        TermVocabulary<?> termVocabulary,
970
	        ICdmFormElement parentElement,
971
	        String labelString,
972
	        T selection,
973
	        boolean addEmptyElement,
974
	        int style,
975
	        boolean useAbbrevLabel) {
976
	    return createDefinedTermComboElement(null, termVocabulary, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
977
	}
978

    
979
	private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
980
	        TermType termType,
981
	        TermVocabulary<?> termVocabulary,
982
	        List<T> terms,
983
	        ICdmFormElement parentElement,
984
	        String labelString,
985
	        T selection,
986
	        boolean addEmptyElement,
987
	        int style,
988
	        boolean useAbbrevLabel,
989
	        Comparator<T> comparator) {
990
	    if(termType!=null){
991
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
992
	        adapt(element);
993
	        parentElement.addElement(element);
994
	        return element;
995
	    }
996
	    else if(termVocabulary!=null){
997
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
998
	        if (comparator!= null){
999
	        	element.setTermComparator(comparator);
1000
	        }
1001
	        adapt(element);
1002
	        parentElement.addElement(element);
1003
	        return element;
1004
	    }else if (terms != null){
1005

    
1006
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, terms, labelString, selection, addEmptyElement, style, useAbbrevLabel);
1007
            if (comparator!= null){
1008
                element.setTermComparator(comparator);
1009
            }
1010
            adapt(element);
1011
            parentElement.addElement(element);
1012
            return element;
1013
	    }
1014
	    else {
1015
	        //this should never happen
1016
	        return null;
1017
	    }
1018
	}
1019

    
1020
	public NameRelationshipTypeCombo createNameRelationshipTypeCombo(ICdmFormElement parentElement,
1021
            String labelString,
1022
            int style,
1023
            boolean useAbbrevLabel,
1024
            Comparator<NameRelationshipType> comparator) {
1025

    
1026
        NameRelationshipTypeCombo<InverseTermWrapper> element = new NameRelationshipTypeCombo(this, parentElement, labelString, true, style, useAbbrevLabel, comparator);
1027
        adapt(element);
1028
        parentElement.addElement(element);
1029
        return element;
1030
    }
1031

    
1032
	public MisappliedRelationshipComboElement createMisappliedRelationshipComboElement(
1033
	        ICdmFormElement parentElement,
1034
            String labelString,
1035
            TaxonRelationshipType selection,
1036
            int style) {
1037
	    MisappliedRelationshipComboElement combo = new MisappliedRelationshipComboElement(this, parentElement, labelString, selection, false, style, false);
1038
	    adapt(combo);
1039
        parentElement.addElement(combo);
1040
        return combo;
1041
    }
1042

    
1043
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1044
	        Class<T> enumComboType, ICdmFormElement parentElement,
1045
	        int style) {
1046
	    return createEnumComboElement(enumComboType, parentElement, null, style);
1047
	}
1048

    
1049
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1050
			Class<T> enumComboType, ICdmFormElement parentElement, Comparator<T> comparator,
1051
			int style) {
1052
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, comparator, style);
1053
        adapt(element);
1054
        parentElement.addElement(element);
1055
        return element;
1056
    }
1057

    
1058
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
1059
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
1060
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1061
	    adapt(element);
1062
	    parentElement.addElement(element);
1063
	    return element;
1064
	}
1065

    
1066
    /**
1067
     * <p>
1068
     * createBrowserElement
1069
     * </p>
1070
     *
1071
     * @param imageUri
1072
     *            a {@link java.net.URI} object.
1073
     * @param style
1074
     *            a int.
1075
     * @param parentElement
1076
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1077
     *            object.
1078
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
1079
     *         object.
1080
     */
1081
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
1082
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
1083
        adapt(element);
1084
        parentElement.addElement(element);
1085
        return element;
1086
    }
1087

    
1088
    /**
1089
     * <p>
1090
     * createImageElement
1091
     * </p>
1092
     *
1093
     * @param parentElement
1094
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1095
     *            object.
1096
     * @param imageUri
1097
     *            a {@link java.net.URI} object.
1098
     * @param style
1099
     *            a int.
1100
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1101
     */
1102
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1103
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1104
        adapt(element);
1105
        parentElement.addElement(element);
1106
        return element;
1107
    }
1108

    
1109
    /**
1110
     * <p>
1111
     * createTextActionElement
1112
     * </p>
1113
     *
1114
     * @param labelString
1115
     *            a {@link java.lang.String} object.
1116
     * @param initialText
1117
     *            a {@link java.lang.String} object.
1118
     * @param style
1119
     *            a int.
1120
     * @param parentElement
1121
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1122
     *            object.
1123
     * @param buttonLabel
1124
     *            a {@link java.lang.String} object.
1125
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
1126
     *         object.
1127
     */
1128
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
1129
            String buttonLabel, String initialText, int style) {
1130
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
1131
                style);
1132
        adapt(element);
1133
        parentElement.addElement(element);
1134
        return element;
1135
    }
1136

    
1137
    /**
1138
     * <p>
1139
     * createCheckbox
1140
     * </p>
1141
     *
1142
     * @param parentElement
1143
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1144
     *            object.
1145
     * @param label
1146
     *            a {@link java.lang.String} object.
1147
     * @param initialState
1148
     *            a boolean.
1149
     * @param style
1150
     *            a int.
1151
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1152
     *         object.
1153
     */
1154
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1155
        if(initialState==null){
1156
            initialState = Boolean.FALSE;
1157
        }
1158
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1159
        adapt(element);
1160
        parentElement.addElement(element);
1161
        return element;
1162
    }
1163

    
1164
    /**
1165
     * Creates a section as a part of the form.
1166
     *
1167
     * @return the section widget
1168
     * @param section
1169
     *            a
1170
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1171
     *            object.
1172
     */
1173
    public Section adapt(AbstractFormSection section) {
1174
        section.setMenu(section.getLayoutComposite().getMenu());
1175
        adapt(section, true, true);
1176

    
1177
        // handle focus and property change events for cdm use
1178
        section.addFocusListener(selectionFocusHandler);
1179
        section.setPropertyChangeListeners(propertyChangeListeners);
1180

    
1181
        section.addExpansionListener(new ExpansionAdapter(){
1182
            @Override
1183
            public void expansionStateChanged(ExpansionEvent e) {
1184
                super.expansionStateChanged(e);
1185
                if(section.getEntity()!=null){
1186
                    PreferencesUtil.setStringValue(StoreUtil.getPrefKey(section.getClass(), section.getEntity().getClass().getCanonicalName()), e.getState()?CdmSectionPart.EXPANDED:CdmSectionPart.COLLAPSED);
1187
                }
1188
            }
1189
        });
1190

    
1191
        if (section.getToggle() != null) {
1192
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1193
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1194
        }
1195

    
1196
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1197

    
1198
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1199
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1200
            getColors().initializeSectionToolBarColors();
1201
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1202
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1203
        }
1204
        // call setTitleBarForeground regardless as it also sets the label color
1205
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1206
        return section;
1207
    }
1208

    
1209
    private class BoldFontHolder2 {
1210
        private Font normalFont;
1211

    
1212
        private Font boldFont;
1213

    
1214
        public BoldFontHolder2() {
1215
        }
1216

    
1217
        public Font getBoldFont(Font font) {
1218
            createBoldFont(font);
1219
            return boldFont;
1220
        }
1221

    
1222
        private void createBoldFont(Font font) {
1223
            if (normalFont == null || !normalFont.equals(font)) {
1224
                normalFont = font;
1225
                dispose();
1226
            }
1227
            if (boldFont == null) {
1228
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1229
            }
1230
        }
1231

    
1232
        public void dispose() {
1233
            if (boldFont != null) {
1234
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1235
                boldFont = null;
1236
            }
1237
        }
1238
    }
1239

    
1240
    /**
1241
     * <p>
1242
     * createToggleableTextField
1243
     * </p>
1244
     *
1245
     * @param parentElement
1246
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1247
     *            object.
1248
     * @param labelString
1249
     *            a {@link java.lang.String} object.
1250
     * @param initialText
1251
     *            a {@link java.lang.String} object.
1252
     * @param initialState
1253
     *            a boolean.
1254
     * @param style
1255
     *            a int.
1256
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1257
     *         object.
1258
     */
1259
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1260
            String initialText, boolean initialState, int style) {
1261
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1262
                initialState, style | orientation);
1263

    
1264
        adapt(element);
1265
        parentElement.addElement(element);
1266
        return element;
1267
    }
1268

    
1269
    /**
1270
     * <p>
1271
     * createTimePeriodElement
1272
     * </p>
1273
     *
1274
     * @param parentElement
1275
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1276
     *            object.
1277
     * @param labelString
1278
     *            a {@link java.lang.String} object.
1279
     * @param timePeriod
1280
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1281
     * @param style
1282
     *            a int.
1283
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1284
     *         object.
1285
     */
1286
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1287
            TimePeriod timePeriod, int style) {
1288
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1289
        adapt(element);
1290
        parentElement.addElement(element);
1291
        return element;
1292
    }
1293

    
1294
    /**
1295
     * <p>
1296
     * createVerbatimTimePeriodElement
1297
     * </p>
1298
     *
1299
     * @param parentElement
1300
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1301
     *            object.
1302
     * @param labelString
1303
     *            a {@link java.lang.String} object.
1304
     * @param timePeriod
1305
     *            a {@link eu.etaxonomy.cdm.model.common.VerbatimTimePeriod} object.
1306
     * @param style
1307
     *            a int.
1308
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.VerbatimTimePeriodElement}
1309
     *         object.
1310
     */
1311
    public VerbatimTimePeriodElement createVerbatimTimePeriodElement(ICdmFormElement parentElement, String labelString,
1312
            VerbatimTimePeriod timePeriod, int style) {
1313
        VerbatimTimePeriodElement element = new VerbatimTimePeriodElement(this, parentElement, labelString, timePeriod, style);
1314
        adapt(element);
1315
        parentElement.addElement(element);
1316
        return element;
1317
    }
1318

    
1319

    
1320

    
1321
	/**
1322
	 * <p>
1323
	 * createGatheringEventUnitElement
1324
	 * </p>
1325
	 *
1326
	 * @param parentElement
1327
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1328
	 *            object.
1329
	 * @param labelString
1330
	 *            a {@link java.lang.String} object.
1331
	 * @param timePeriod
1332
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1333
	 * @param style
1334
	 *            a int.
1335
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1336
	 *         object.
1337
	 */
1338
	public GatheringEventUnitElement createGatheringEventUnitElement(
1339
			ICdmFormElement parentElement,
1340
			String labelString,
1341
			DerivedUnitFacade gatheringEvent,
1342
			MinMaxTextSection.UnitType unitType,
1343
			int style) {
1344
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1345
				parentElement,
1346
				labelString,
1347
				gatheringEvent,
1348
				unitType,
1349
				style);
1350
		adapt(element);
1351
		parentElement.addElement(element);
1352
		return element;
1353
	}
1354

    
1355
    /**
1356
     * <p>
1357
     * createPointElement
1358
     * </p>
1359
     *
1360
     * @param style
1361
     *            a int.
1362
     * @param parentElement
1363
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1364
     *            object.
1365
     * @param point
1366
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1367
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1368
     */
1369
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1370
        PointElement element = new PointElement(this, parentElement, point, style);
1371
        adapt(element);
1372
        parentElement.addElement(element);
1373
        return element;
1374
    }
1375

    
1376
    /**
1377
     * Creates an empty section with the given message.<br>
1378
     * If message is <code>null</code> a default message will be displayed.
1379
     */
1380
    public EmptySection createEmptySection(String message, CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1381
        EmptySection section = new EmptySection(message, formFactory, parentElement, style);
1382
        parentElement.addElement(section);
1383
        adapt(section);
1384
        return section;
1385
    }
1386

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

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

    
1428
	/**
1429
	 * <p>
1430
	 * createDateDetailSection
1431
	 * </p>
1432
	 *
1433
	 * @param parentElement
1434
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1435
	 *            object.
1436
	 * @param style
1437
	 *            a int.
1438
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1439
	 *         object.
1440
	 */
1441
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1442
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1443
		parentElement.addElement(section);
1444
		adapt(section);
1445
		return section;
1446
	}
1447

    
1448
    /**
1449
     * <p>
1450
     * createPartialElement
1451
     * </p>
1452
     *
1453
     * @param parentElement
1454
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1455
     *            object.
1456
     * @param labelString
1457
     *            a {@link java.lang.String} object.
1458
     * @param partial
1459
     *            a {@link org.joda.time.Partial} object.
1460
     * @param style
1461
     *            a int.
1462
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1463
     *         object.
1464
     */
1465
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1466
            int style) {
1467
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1468
        adapt(element);
1469
        parentElement.addElement(element);
1470
        return element;
1471
    }
1472

    
1473
    /**
1474
     * <p>
1475
     * addSelectionListener
1476
     * </p>
1477
     *
1478
     * @param listener
1479
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1480
     */
1481
    public void addSelectionListener(SelectionListener listener) {
1482
        selectionListenerList.add(listener);
1483
    }
1484

    
1485
    /**
1486
     * <p>
1487
     * removeSelectionListener
1488
     * </p>
1489
     *
1490
     * @param listener
1491
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1492
     */
1493
    public void removeSelectionListener(SelectionListener listener) {
1494
        if (listener == null) {
1495
            MessagingUtils.error(this.getClass(),
1496
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1497
        } else {
1498
            selectionListenerList.remove(listener);
1499
        }
1500
    }
1501

    
1502
    /**
1503
     * <p>
1504
     * addPropertyChangeListener
1505
     * </p>
1506
     *
1507
     * @param listener
1508
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1509
     *            object.
1510
     */
1511
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1512
        if (propertyChangeListeners.contains(listener)) {
1513
            return;
1514
        }
1515
        propertyChangeListeners.add(0, listener);
1516
    }
1517

    
1518
    /**
1519
     * <p>
1520
     * removePropertyChangeListener
1521
     * </p>
1522
     *
1523
     * @param listener
1524
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1525
     *            object.
1526
     */
1527
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1528
        propertyChangeListeners.remove(listener);
1529
    }
1530

    
1531
    /**
1532
     * @return the propertyChangeListeners
1533
     */
1534
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1535
        return propertyChangeListeners;
1536
    }
1537

    
1538
    /**
1539
     * <p>
1540
     * createHorizontalSeparator
1541
     * </p>
1542
     *
1543
     * @param parentElement
1544
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1545
     *            object.
1546
     * @param style
1547
     *            a int.
1548
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1549
     */
1550
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1551
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1552
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1553
        return separator;
1554
    }
1555

    
1556
    /**
1557
     * <p>
1558
     * createVersionElement
1559
     * </p>
1560
     *
1561
     * @param parentElement
1562
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1563
     *            object.
1564
     * @param entity
1565
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1566
     *            object.
1567
     * @param style
1568
     *            a int.
1569
     * @return a
1570
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1571
     *         object.
1572
     */
1573
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1574
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1575
        adapt(element);
1576
        parentElement.addElement(element);
1577
        return element;
1578
    }
1579

    
1580
    /**
1581
     * @param cdmBaseSection
1582
     * @param object
1583
     * @param style
1584
     * @return
1585
     */
1586
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1587
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1588
        adapt(element);
1589
        parentElement.addElement(element);
1590
        return element;
1591
    }
1592

    
1593
    /**
1594
     * <p>
1595
     * createVersionSection
1596
     * </p>
1597
     *
1598
     * @param parentElement
1599
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1600
     *            object.
1601
     * @param style
1602
     *            a int.
1603
     * @return a
1604
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1605
     *         object.
1606
     */
1607
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1608
        VersionSection section = new VersionSection(this, parentElement, style);
1609
        parentElement.addElement(section);
1610
        adapt(section);
1611
        return section;
1612
    }
1613

    
1614
    /**
1615
     * @param parent
1616
     * @param i
1617
     * @return
1618
     */
1619
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1620
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1621
        parentElement.addElement(section);
1622
        adapt(section);
1623
        return section;
1624
    }
1625

    
1626
    /**
1627
     * <p>
1628
     * createEmptyElement
1629
     * </p>
1630
     *
1631
     * @param parentElement
1632
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1633
     *            object.
1634
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1635
     */
1636
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1637
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1638
        adapt(element);
1639
        parentElement.addElement(element);
1640
        return element;
1641
    }
1642

    
1643
    /**
1644
     * <p>
1645
     * createHeadlineSection
1646
     * </p>
1647
     *
1648
     * @param parentElement
1649
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1650
     *            object.
1651
     * @return a
1652
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1653
     *         object.
1654
     */
1655
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1656
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1657
        parentElement.addElement(section);
1658
        adapt(section);
1659
        return section;
1660
    }
1661

    
1662
    /**
1663
     * <p>
1664
     * createParsingMessageElement
1665
     * </p>
1666
     *
1667
     * @param parentElement
1668
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1669
     *            object.
1670
     * @param parserProblem
1671
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1672
     *            object.
1673
     * @param style
1674
     *            a int.
1675
     * @return a
1676
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1677
     *         object.
1678
     */
1679
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1680
            ParserProblem parserProblem, int style) {
1681
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1682
        adapt(element);
1683
        parentElement.addElement(element);
1684
        return element;
1685
    }
1686

    
1687
    public DefinedTermDetailSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1688
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1689

    
1690
        DefinedTermDetailSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1691
                selectionProvider, style);
1692

    
1693
        parentElement.addElement(section);
1694
        adapt(section);
1695
        return section;
1696

    
1697
    }
1698

    
1699
    public TermMediaSection createTermMediaSection(ConversationHolder conversation,
1700
            ICdmFormElement parentElement, int style) {
1701
        TermMediaSection section = new TermMediaSection(this, conversation, parentElement, style);
1702
        parentElement.addElement(section);
1703
        adapt(section);
1704
        return section;
1705

    
1706
    }
1707

    
1708
    /**
1709
     * @param definedTermClass
1710
     * @param formElement
1711
     * @param style
1712
     * @return
1713
     */
1714
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1715
            AbstractCdmDetailSection parentElement, int style) {
1716
        AbstractCdmDetailElement element = null;
1717

    
1718
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1719
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1720
        } else if (definedTermClass.equals(Feature.class)) {
1721
            element = new FeatureDetailElement(this, parentElement);
1722
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1723
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1724
        } else {
1725
            element = new DefinedTermDetailElement(this, parentElement);
1726
        }
1727

    
1728

    
1729
        adapt(element);
1730
        parentElement.addElement(element);
1731
        return element;
1732
    }
1733

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

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

    
1746
    public CharacterNodeDetailElement createCharacterNodeDetailElement(ICdmFormElement parentElement, int style){
1747
        CharacterNodeDetailElement element = new CharacterNodeDetailElement(this, parentElement);
1748
        addAndAdaptElement(parentElement, element);
1749
        return element;
1750
    }
1751

    
1752
    public CharacterDetailElement createCharacterDetailElement(ICdmFormElement parentElement, int style){
1753
        CharacterDetailElement element = new CharacterDetailElement(this, parentElement);
1754
        addAndAdaptElement(parentElement, element);
1755
        return element;
1756
    }
1757

    
1758
    public FeatureTreeDetailElement createFeatureTreeDetailElement(ICdmFormElement parentElement, int style){
1759
        FeatureTreeDetailElement element = new FeatureTreeDetailElement(this, parentElement);
1760
        addAndAdaptElement(parentElement, element);
1761
        return element;
1762
    }
1763

    
1764
    public FeatureNodeDetailElement createFeatureNodeDetailElement(ICdmFormElement parentElement, int style){
1765
        FeatureNodeDetailElement element = new FeatureNodeDetailElement(this, parentElement);
1766
        addAndAdaptElement(parentElement, element);
1767
        return element;
1768
    }
1769

    
1770

    
1771
    //--------DetailSections---------
1772
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1773
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1774
        addAndAdaptSection(parentElement, section);
1775
        return section;
1776
    }
1777

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

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

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

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

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

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

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

    
1820
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1821
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1822
        addAndAdaptSection(parentElement, section);
1823
        return section;
1824
    }
1825

    
1826
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1827
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1828
        addAndAdaptSection(parentElement, section);
1829
        return section;
1830
    }
1831

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

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

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

    
1850

    
1851

    
1852
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, boolean nameChoosable, int style){
1853
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, nameChoosable, style);
1854
        addAndAdaptSection(parentElement, section);
1855
        return section;
1856
    }
1857

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1948
    public DerivedUnitGeneralDetailSection createDerivedUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1949
        DerivedUnitGeneralDetailSection section = new DerivedUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1950
        addAndAdaptSection(parentElement, section);
1951
        return section;
1952
    }
1953

    
1954
    public PreservedSpecimenGeneralDetailSection createPreservedSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1955
        PreservedSpecimenGeneralDetailSection section = new PreservedSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1956
        addAndAdaptSection(parentElement, section);
1957
        return section;
1958
    }
1959

    
1960
    public TissueSampleGeneralDetailSection createTissueSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1961
        TissueSampleGeneralDetailSection section = new TissueSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1962
        addAndAdaptSection(parentElement, section);
1963
        return section;
1964
    }
1965

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

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

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

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

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

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

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

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

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

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

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

    
2032
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2033
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
2034
        addAndAdaptSection(parentElement, section);
2035
        return section;
2036
    }
2037

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

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

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

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

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

    
2068
    public SampleDesignationDetailSection createSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2069
        SampleDesignationDetailSection section = new SampleDesignationDetailSection(this, conversation, parentElement, selectionProvider, style);
2070
        addAndAdaptSection(parentElement, section);
2071
        return section;
2072
    }
2073

    
2074
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2075
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style, true);
2076
        addAndAdaptSection(parentElement, section);
2077
        return section;
2078
    }
2079

    
2080
    public ReferencedEntityDetailSection createReferencedEntityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2081
        ReferencedEntityDetailSection section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
2082
        addAndAdaptSection(parentElement, section);
2083
        return section;
2084
    }
2085

    
2086
    public TermVocabularyDetailSection createTermVocabularyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2087
        TermVocabularyDetailSection section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
2088
        addAndAdaptSection(parentElement, section);
2089
        return section;
2090
    }
2091

    
2092
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2093
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
2094
        addAndAdaptSection(parentElement, section);
2095
        return section;
2096
    }
2097

    
2098
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2099
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
2100
        addAndAdaptSection(parentElement, section);
2101
        return section;
2102
    }
2103

    
2104
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2105
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
2106
        addAndAdaptSection(parentElement, section);
2107
        return section;
2108
    }
2109

    
2110
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
2111
        parentElement.addElement(section);
2112
        adapt(section);
2113
    }
2114

    
2115
    //--------DetailElements------------
2116

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

    
2123
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
2124
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
2125
        addAndAdaptElement(parentElement, element);
2126
        return element;
2127
    }
2128

    
2129
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
2130
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
2131
        addAndAdaptElement(parentElement, element);
2132
        return element;
2133
    }
2134

    
2135
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
2136
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
2137
        addAndAdaptElement(parentElement, element);
2138
        return element;
2139
    }
2140

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

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

    
2153
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
2154
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2155
        addAndAdaptElement(parentElement, element);
2156
        return element;
2157
    }
2158

    
2159
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2160
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2161
        addAndAdaptElement(parentElement, element);
2162
        return element;
2163
    }
2164

    
2165
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2166
        UserDetailElement element = new UserDetailElement(this, parentElement);
2167
        addAndAdaptElement(parentElement, element);
2168
        return element;
2169
    }
2170

    
2171
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2172
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2173
        addAndAdaptElement(parentElement, element);
2174
        return element;
2175
    }
2176

    
2177
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2178
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2179
        addAndAdaptElement(parentElement, element);
2180
        return element;
2181
    }
2182

    
2183
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2184
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2185
        addAndAdaptElement(parentElement, element);
2186
        return element;
2187
    }
2188

    
2189
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2190
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2191
        addAndAdaptElement(parentElement, element);
2192
        return element;
2193
    }
2194

    
2195
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2196
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2197
        addAndAdaptElement(parentElement, element);
2198
        return element;
2199
    }
2200

    
2201
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2202
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2203
        adapt(element);
2204
        parentElement.addElement(element);
2205

    
2206
        return element;
2207
    }
2208

    
2209
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2210
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2211
        addAndAdaptElement(parentElement, element);
2212
        return element;
2213
    }
2214

    
2215
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
2216
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
2217
        addAndAdaptElement(parentElement, element);
2218
        return element;
2219
    }
2220

    
2221
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2222
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2223
        addAndAdaptElement(parentElement, element);
2224
        return element;
2225
    }
2226

    
2227
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2228
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2229
        addAndAdaptElement(parentElement, element);
2230
        return element;
2231
    }
2232

    
2233
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2234
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2235
        addAndAdaptElement(parentElement, element);
2236
        return element;
2237
    }
2238

    
2239
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2240
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2241
        addAndAdaptElement(parentElement, element);
2242
        return element;
2243
    }
2244

    
2245
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2246
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2247
        addAndAdaptElement(parentElement, element);
2248
        return element;
2249
    }
2250

    
2251
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2252
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2253
        addAndAdaptElement(parentElement, element);
2254
        return element;
2255
    }
2256

    
2257
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2258
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2259
        addAndAdaptElement(parentElement, element);
2260
        return element;
2261
    }
2262

    
2263
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2264
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2265
        addAndAdaptElement(parentElement, element);
2266
        return element;
2267
    }
2268

    
2269
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2270
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2271
        addAndAdaptElement(parentElement, element);
2272
        return element;
2273
    }
2274

    
2275
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2276
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2277
        addAndAdaptElement(parentElement, element);
2278
        return element;
2279
    }
2280

    
2281
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2282
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2283
        addAndAdaptElement(parentElement, element);
2284
        return element;
2285
    }
2286

    
2287
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2288
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2289
        addAndAdaptElement(parentElement, element);
2290
        return element;
2291
    }
2292

    
2293
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2294
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2295
        addAndAdaptElement(parentElement, element);
2296
        return element;
2297
    }
2298

    
2299

    
2300
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2301
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2302
        addAndAdaptElement(parentElement, element);
2303
        return element;
2304
    }
2305

    
2306
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2307
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2308
        addAndAdaptElement(parentElement, element);
2309
        return element;
2310
    }
2311

    
2312
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2313
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2314
        addAndAdaptElement(parentElement, element);
2315
        return element;
2316
    }
2317

    
2318
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2319
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2320
        addAndAdaptElement(parentElement, element);
2321
        return element;
2322
    }
2323

    
2324
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2325
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2326
        addAndAdaptElement(parentElement, element);
2327
        return element;
2328
    }
2329

    
2330
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2331
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2332
        addAndAdaptElement(parentElement, element);
2333
        return element;
2334
    }
2335

    
2336
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2337
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2338
        addAndAdaptElement(parentElement, element);
2339
        return element;
2340
    }
2341

    
2342
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2343
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2344
        addAndAdaptElement(parentElement, element);
2345
        return element;
2346
    }
2347

    
2348
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2349
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2350
        addAndAdaptElement(parentElement, element);
2351
        return element;
2352
    }
2353

    
2354
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2355
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2356
        addAndAdaptElement(parentElement, element);
2357
        return element;
2358
    }
2359

    
2360
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2361
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2362
        addAndAdaptElement(parentElement, element);
2363
        return element;
2364
    }
2365

    
2366
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2367
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2368
        addAndAdaptElement(parentElement, element);
2369
        return element;
2370
    }
2371

    
2372
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2373
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2374
        addAndAdaptElement(parentElement, element);
2375
        return element;
2376
    }
2377

    
2378
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2379
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2380
        addAndAdaptElement(parentElement, element);
2381
        return element;
2382
    }
2383

    
2384
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2385
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2386
        addAndAdaptElement(parentElement, element);
2387
        return element;
2388
    }
2389

    
2390
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2391
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2392
        addAndAdaptElement(parentElement, element);
2393
        return element;
2394
    }
2395

    
2396
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2397
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2398
        addAndAdaptElement(parentElement, mediaDetailElement);
2399
        return mediaDetailElement;
2400
    }
2401

    
2402
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2403
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2404
        addAndAdaptElement(parentElement, element);
2405
        return element;
2406
    }
2407

    
2408
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2409
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2410
        addAndAdaptElement(parentElement, element);
2411
        return element;
2412
    }
2413

    
2414
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2415
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2416
        addAndAdaptElement(parentElement, element);
2417
        return element;
2418
    }
2419

    
2420
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2421
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2422
        addAndAdaptElement(parentElement, element);
2423
        return element;
2424
    }
2425

    
2426
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2427
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2428
        addAndAdaptElement(parentElement, element);
2429
        return element;
2430
    }
2431

    
2432
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2433
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2434
        addAndAdaptElement(parentElement, element);
2435
        return element;
2436
    }
2437

    
2438
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2439
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2440
        addAndAdaptElement(parentElement, element);
2441
        return element;
2442
    }
2443

    
2444
    /**
2445
     * @param parentElement
2446
     * @param element
2447
     */
2448
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2449
        adapt(element);
2450
        parentElement.addElement(element);
2451
    }
2452

    
2453
    //--------EntityCollectionSection----------
2454
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2455
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2456
        addAndAdaptSection(parentElement, section);
2457
        return section;
2458
    }
2459

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

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

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

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

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

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

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

    
2502
    public MediaSection createMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2503
        MediaSection section = new MediaSection(this, conversation, parentElement, style);
2504
        addAndAdaptSection(parentElement, section);
2505
        return section;
2506
    }
2507

    
2508
    public DescriptionElementMediaSection createDescriptionElementMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2509
        DescriptionElementMediaSection section = new DescriptionElementMediaSection(this, conversation, parentElement, style);
2510
        addAndAdaptSection(parentElement, section);
2511
        return section;
2512
    }
2513

    
2514
    public MediaRepresentationSection createMediaRepresentationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2515
        MediaRepresentationSection section = new MediaRepresentationSection(this, conversation, parentElement, style);
2516
        addAndAdaptSection(parentElement, section);
2517
        return section;
2518
    }
2519

    
2520
    public MediaRepresentationPartSection createMediaRepresentationPartSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2521
        MediaRepresentationPartSection section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
2522
        addAndAdaptSection(parentElement, section);
2523
        return section;
2524
    }
2525

    
2526
    public ModifierSection createModifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2527
        ModifierSection section = new ModifierSection(this, conversation, parentElement, style);
2528
        addAndAdaptSection(parentElement, section);
2529
        return section;
2530
    }
2531

    
2532
    public NomenclaturalStatusSection createNomenclaturalStatusSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2533
        NomenclaturalStatusSection section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
2534
        addAndAdaptSection(parentElement, section);
2535
        return section;
2536
    }
2537

    
2538
    public NameRelationshipDetailSection createNameRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2539
        NameRelationshipDetailSection section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
2540
        addAndAdaptSection(parentElement, section);
2541
        return section;
2542
    }
2543

    
2544
    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2545
        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2546
        addAndAdaptSection(parentElement, section);
2547
        return section;
2548
    }
2549
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2550
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, style);
2551
        addAndAdaptSection(parentElement, section);
2552
        return section;
2553
    }
2554

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2693
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2694
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2695
        addAndAdaptSection(parentElement, section);
2696
        return section;
2697
    }
2698

    
2699
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2700
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2701
        addAndAdaptSection(parentElement, section);
2702
        return section;
2703
    }
2704

    
2705
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2706
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2707
        addAndAdaptSection(parentElement, section);
2708
        return section;
2709
    }
2710

    
2711
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2712
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2713
        addAndAdaptSection(parentElement, section);
2714
        return section;
2715
    }
2716

    
2717
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2718
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2719
        addAndAdaptSection(parentElement, section);
2720
        return section;
2721
    }
2722

    
2723
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2724
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2725
        addAndAdaptSection(parentElement, section);
2726
        return section;
2727
    }
2728

    
2729
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2730
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2731
        addAndAdaptSection(parentElement, section);
2732
        return section;
2733
    }
2734

    
2735

    
2736
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2737
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2738
        AbstractEntityCollectionElement<?> element = null;
2739

    
2740
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2741

    
2742
        if (entity instanceof Annotation) {
2743
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2744
        }else if (entity instanceof Person ) {
2745
            boolean isNomenclatural = false;
2746
            if (parentElement instanceof TeamMemberSection){
2747
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2748
            }
2749
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2750
        } else if (entity instanceof Credit) {
2751
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2752
        } else if (entity instanceof Extension) {
2753
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2754
        } else if (entity instanceof ExternalLink) {
2755
            element = new ExternalLinksElement(this, parentElement, (ExternalLink) entity, removeListener, style);
2756
        } else if (entity instanceof Marker) {
2757
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2758
        } else if (entity instanceof TaxonNodeAgentRelation) {
2759
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2760
        }else if (entity instanceof Media) {
2761
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2762
        } else if (entity instanceof MediaRepresentation) {
2763
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2764
                    style);
2765
        } else if (entity instanceof ImageFile) {
2766
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2767
        } else if (entity instanceof MediaRepresentationPart) {
2768
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2769
                    removeListener, style);
2770
        } else if (entity instanceof NomenclaturalStatus) {
2771
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2772
                    style);
2773
        } else if (entity instanceof Rights) {
2774
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2775
        } else if (entity instanceof DescriptionElementSource && parentElement.getEntity() instanceof CommonTaxonName) {
2776
            element = new CommonNameSourceElement(this, parentElement, (DescriptionElementSource) entity,
2777
                    removeListener, style);
2778
        } else if (entity instanceof DescriptionElementSource) {
2779
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2780
                    removeListener, style, false);
2781
        } else if (entity instanceof TaxonNodeAgentRelation) {
2782
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2783
                    removeListener,backgroundColor, style);
2784
        }
2785
        else if (entity instanceof IdentifiableSource) {
2786
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2787
                    style);
2788
        } else if (entity instanceof DefinedTerm) {
2789
            switch(((DefinedTerm)entity).getTermType()) {
2790
            case Scope:
2791
                element = new ScopeElement(this,
2792
                        parentElement,
2793
                        (DefinedTerm) entity,
2794
                        removeListener,
2795
                        style);
2796
                break;
2797
            case Modifier:
2798
                element = new ModifierElement(this,
2799
                        parentElement,
2800
                        (DefinedTerm) entity,
2801
                        removeListener,
2802
                        style);
2803
                break;
2804
            default:
2805
                break;
2806

    
2807
            }
2808
        } else if (entity instanceof Reference) {
2809
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2810
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2811
            }
2812
            else{
2813
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2814
            }
2815
        } else if (entity instanceof NameTypeDesignation) {
2816
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2817
                    style);
2818
        } else if (entity instanceof TextualTypeDesignation) {
2819
            element = new TextTypeDesignationElement(this, parentElement, (TextualTypeDesignation) entity, removeListener,
2820
                    style);
2821
        } else if (entity instanceof NameRelationship) {
2822
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2823
                    style);
2824
        } else if (entity instanceof SpecimenTypeDesignation) {
2825
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
2826
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2827
                        removeListener, style);
2828
            }
2829
            else{
2830
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2831
                        removeListener, style);
2832
            }
2833
        } else if (entity instanceof StateData) {
2834
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2835
        } else if (entity instanceof StatisticalMeasurementValue) {
2836
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2837
                    removeListener, style);
2838
        } else if (entity instanceof DerivedUnit) {
2839
            switch(((DerivedUnit)entity).getRecordBasis()) {
2840
            case LivingSpecimen:
2841
            case PreservedSpecimen:
2842
            case OtherSpecimen:
2843
                element = new SpecimenCollectionDetailElement(this,
2844
                        parentElement,
2845
                        (DerivedUnit) entity,
2846
                        removeListener,
2847
                        style);
2848
                break;
2849
            default:
2850
                element = new DerivedUnitElement(this,
2851
                        parentElement,
2852
                        (DerivedUnit) entity,
2853
                        removeListener,
2854
                        style);
2855
            }
2856

    
2857
        } else if (entity instanceof NamedArea) {
2858
            element = new CollectingAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2859
        } else if (entity instanceof DeterminationEvent) {
2860
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2861
        } else if (entity instanceof User) {
2862
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2863
        } else if (entity instanceof GrantedAuthority) {
2864
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
2865
                    removeListener, style);
2866
        } else if (entity instanceof Group) {
2867
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2868
        } else if (entity instanceof Taxon) {
2869
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2870
        } else if (entity instanceof DescriptionElementBase) {
2871
            // this is the special case for protologs, maybe we can do this
2872
            // differently when API improves
2873
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2874
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2875
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2876
            }
2877
        } else if (entity instanceof Identifier) {
2878
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2879
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2880
            }
2881
            else{
2882
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
2883
            }
2884
        } else if (entity instanceof TermVocabulary) {
2885
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
2886
            switch (termVocabulary.getTermType()) {
2887
            case State:
2888
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
2889
                break;
2890
            case Modifier:
2891
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
2892
                break;
2893
            default:
2894
                break;
2895
            }
2896
        } else if (entity instanceof MeasurementUnit) {
2897
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2898
        } else if (entity instanceof StatisticalMeasure) {
2899
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2900
        } else if (entity instanceof FeatureState && parentElement instanceof InapplicableIfEntityCollectionSection) {
2901
            element = new InapplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
2902
        } else if (entity instanceof FeatureState && parentElement instanceof OnlyApplicableIfEntityCollectionSection) {
2903
            element = new OnlyApplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
2904
        }
2905

    
2906
        //check for parent section when entity is null
2907
        //this happens when AbstractUnboundEntityCollectionSection is used
2908
        if(element==null){
2909
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
2910
                element = new ScopeElement(this,
2911
                        parentElement,
2912
                        (DefinedTerm) entity,
2913
                        removeListener,
2914
                        style);
2915
            }
2916
            else if(parentElement instanceof ModifierSection){
2917
                element = new ModifierElement(this,
2918
                        parentElement,
2919
                        (DefinedTerm) entity,
2920
                        removeListener,
2921
                        style);
2922
            }
2923
        }
2924

    
2925

    
2926
        if (element == null) {
2927
            MessagingUtils.messageDialog(
2928
                    String.format("Error when creating section %s",
2929
                            parentElement.getClass().getSimpleName()),
2930
                    this,
2931
                    String.format("Could not generate collection element for entity of class %s."
2932
                            + " Looks like the case is not yet handled. Check implementation.\n"
2933
                            + "Entity: %s", entity.getClass(), entity.toString()), null);
2934
        }
2935

    
2936
        else{
2937
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2938
                element.setPersistentBackground(backgroundColor);
2939
            }
2940
            adapt(element);
2941
            parentElement.addElement(element);
2942
        }
2943

    
2944
        return element;
2945
    }
2946

    
2947
    /**
2948
     * <p>
2949
     * Creates a selection element for the given type T.
2950
     * </p>
2951
     * <p>
2952
     * <strong>Selection elements not handled by this method:</strong>
2953
     * <ul>
2954
     * <li>{@link TaxonNodeSelectionElement} see
2955
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2956
     * </li>
2957
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2958
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2959
     * </li>
2960
     * </ul>
2961
     * </p>
2962
     *
2963
     * @param clazz
2964
     *            a {@link Class} object of the type that you want the selection
2965
     *            element to handle
2966
     * @param parentElement
2967
     *            a {@link ICdmFormElement} object.
2968
     * @param labelString
2969
     *            a {@link String} object.
2970
     * @param selectionType
2971
     * @param selection
2972
     *            a {@link ICdmBase} object.
2973
     * @param style
2974
     *            a int.
2975
     * @param conversation
2976
     *            a {@link ConversationHolder} object.
2977
     * @return a {@link EntitySelectionElement} object.
2978
     */
2979
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2980
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2981
            int style, boolean filterElement) {
2982
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
2983
                parentElement, clazz,
2984
                labelString, selection, mode, style, filterElement);
2985
        adapt(element);
2986
        parentElement.addElement(element);
2987
        return element;
2988
    }
2989

    
2990
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2991
//            ConversationHolder conversation,
2992
            ICdmFormElement parentElement, String labelString, T selection, int mode,
2993
            int style) {
2994
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this,
2995
                parentElement, clazz,
2996
                labelString, selection, mode, style);
2997
        adapt(element);
2998
        parentElement.addElement(element);
2999
        return element;
3000
    }
3001

    
3002
    public CommonNameReferenceSelectionElement createCommonNameReferenceSelectionElement(ICdmFormElement parentElement, String labelString, Reference selection, int mode,
3003
          int style) {
3004
        CommonNameReferenceSelectionElement element = new CommonNameReferenceSelectionElement(this,
3005
              parentElement, labelString, selection, mode, style);
3006
      adapt(element);
3007
      parentElement.addElement(element);
3008
      return element;
3009
  }
3010

    
3011
    /**
3012
     * <p>
3013
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
3014
     * </p>
3015
     * <p>
3016
     * <strong>Selection elements not handled by this method:</strong>
3017
     * <ul>
3018
     * <li>{@link TaxonNodeSelectionElement} see
3019
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
3020
     * </li>
3021
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
3022
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
3023
     * </li>
3024
     * </ul>
3025
     * </p>
3026
     *
3027
     * @param clazz
3028
     *            a {@link Class} object of the type that you want the selection
3029
     *            element to handle
3030
     * @param parentElement
3031
     *            a {@link ICdmFormElement} object.
3032
     * @param labelString
3033
     *            a {@link String} object.
3034
     * @param selectionType
3035
     * @param selection
3036
     *            a {@link ICdmBase} object.
3037
     * @param style
3038
     *            a int.
3039
     * @param conversation
3040
     *            a {@link ConversationHolder} object.
3041
     * @return a {@link EntitySelectionElement} object.
3042
     */
3043
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
3044
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
3045
            T selection, int mode, int style) {
3046
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, //conversation,
3047
                parentElement, clazz,
3048
                labelString, selection, mode, style);
3049
        adapt(element);
3050
        parentElement.addElement(element);
3051
        return element;
3052
    }
3053

    
3054
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3055
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
3056
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
3057
                parentElement,
3058
                labelString, selection, mode, style);
3059
        adapt(element);
3060
        parentElement.addElement(element);
3061
        return element;
3062
    }
3063

    
3064

    
3065

    
3066
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
3067
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
3068
//            int mode, int style) {
3069
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
3070
//                conversation, parentElement, labelString, selection, mode, style);
3071
//        adapt(element);
3072
//        parentElement.addElement(element);
3073
//        return element;
3074
//    }
3075

    
3076
    /** {@inheritDoc} */
3077
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
3078
        LabelElement labelElement = new LabelElement(this, parentElement, text);
3079
        adapt(labelElement);
3080
        parentElement.addElement(labelElement);
3081
        return labelElement;
3082
    }
3083

    
3084

    
3085

    
3086
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
3087
//        Label label = new Label(formElement.getLayoutComposite(), style);
3088
//        label.setText(labelText+" (yyyy-MM-dd)");
3089
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
3090
//        dateElement.initInternalController();
3091
//
3092
//        return dateElement;
3093
//    }
3094

    
3095
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
3096
    	 Label label = new Label(formElement.getLayoutComposite(), style);
3097
         label.setText(labelText);
3098
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3099
         DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
3100
         dateElement.initController(this, formElement);
3101
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3102
         return dateElement;
3103
    }
3104

    
3105
    /**
3106
     * <p>
3107
     * Getter for the field <code>selectionProvider</code>.
3108
     * </p>
3109
     *
3110
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
3111
     */
3112
    public ISelectionProvider getSelectionProvider() {
3113
        return selectionProvider;
3114
    }
3115

    
3116
    /**
3117
     * <p>
3118
     * createDetailedDescriptionDetailElement
3119
     * </p>
3120
     *
3121
     * @param parentElement
3122
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3123
     *            object.
3124
     * @param entity
3125
     *            a
3126
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
3127
     *            object.
3128
     * @param style
3129
     *            a int.
3130
     * @return a
3131
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
3132
     *         object.
3133
     */
3134
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
3135
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
3136
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
3137

    
3138
        if (entity instanceof CategoricalData) {
3139
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
3140
                    (CategoricalData) entity, style);
3141
        } else if (entity instanceof CommonTaxonName) {
3142
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
3143
                    style);
3144
        } else if (entity instanceof Distribution && !enabled) {
3145
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3146
                    enabled, style);
3147
        } else if (entity instanceof Distribution) {
3148
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3149
                    true, style);
3150
        }else if (entity instanceof IndividualsAssociation) {
3151
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
3152
                    (IndividualsAssociation) entity, style);
3153
        } else if (entity instanceof QuantitativeData) {
3154
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
3155
                    (QuantitativeData) entity, style);
3156
        } else if (entity instanceof TaxonInteraction) {
3157
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
3158
                    (TaxonInteraction) entity, style);
3159
        } else if (entity instanceof TextData) {
3160
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
3161
        } else {
3162
            throw new IllegalStateException("There is no interface for the given description element");
3163
        }
3164
        adapt(detailedDescriptionElement);
3165
        parentElement.addElement(detailedDescriptionElement);
3166
        return detailedDescriptionElement;
3167

    
3168
    }
3169

    
3170
    /**
3171
     * Creates a styled text as a part of the form.
3172
     *
3173
     * @param parent
3174
     *            the text parent
3175
     * @param value
3176
     *            the text initial value
3177
     * @param style
3178
     *            the text style
3179
     * @return the text widget
3180
     */
3181
    public StyledText createStyledText(Composite parent, String value, int style) {
3182
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3183
        if (value != null) {
3184
            text.setText(value);
3185
        }
3186
        text.setForeground(getColors().getForeground());
3187
        text.setBackground(getColors().getBackground());
3188
        // text.addFocusListener(visibilityHandler);
3189
        return text;
3190
    }
3191

    
3192
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3193
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3194
        addAndAdaptSection(parentElement, section);
3195
        return section;
3196
    }
3197

    
3198
    /**
3199
     * @param formElement
3200
     * @param conversationHolder
3201
     * @param style
3202
     * @return
3203
     */
3204
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3205
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3206
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3207
        addAndAdaptSection(formElement, section);
3208
        return section;
3209
    }
3210

    
3211

    
3212
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3213
			ICdmFormElement parentElement, int style) {
3214
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3215
		addAndAdaptElement(parentElement, section);
3216
        return section;
3217
	}
3218

    
3219
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3220
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3221
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3222
	        addAndAdaptSection(formElement, section);
3223
	        return section;
3224
	}
3225

    
3226

    
3227

    
3228

    
3229

    
3230
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3231
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3232
//				 initialText, textHeight, style);
3233
//	        adapt(element);
3234
//	        parentElement.addElement(element);
3235
//	        return element;
3236
//	}
3237

    
3238

    
3239

    
3240

    
3241

    
3242

    
3243

    
3244
}
(7-7/48)