Project

General

Profile

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

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

    
388
    private BoldFontHolder2 boldFontHolder2;
389
    private MouseListener selectionMouseHandler;
390
    private FocusListener selectionFocusHandler;
391

    
392
    @Inject
393
    private IEclipseContext context;
394

    
395
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
396

    
397
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
398

    
399
    private final int orientation = Window.getDefaultOrientation();
400
    private ISelectionProvider selectionProvider;
401

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

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

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

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

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

    
446
    public CdmFormFactory(Display display) {
447
        this(display, null);
448
    }
449

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

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

    
462
    public IEclipseContext getContext() {
463
        return context;
464
    }
465

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

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

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

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

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

    
538
        super.adapt(composite);
539
    }
540

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

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

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

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

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

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

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

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

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

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

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

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

    
785

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

    
801
    public OrcidWithLabelElement createOrcidWithLabelElement(ICdmFormElement parentElement, String labelString,
802
            ORCID initialDoi, int style) {
803
        OrcidWithLabelElement element = new OrcidWithLabelElement(this, parentElement, labelString, initialDoi, null, style);
804
        adapt(element);
805
        parentElement.addElement(element);
806
        return element;
807
    }
808
    public OrcidWithLabelElement createDoiWithLabelElement(ICdmFormElement parentElement, String labelString,
809
            ORCID initialDoi,Integer textHeight, int style) {
810
        OrcidWithLabelElement element = new OrcidWithLabelElement(this, parentElement, labelString, initialDoi, textHeight, style);
811
        adapt(element);
812
        parentElement.addElement(element);
813
        return element;
814
    }
815

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

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

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

    
877
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
878
            String labelString, LanguageString languageString, int style) {
879
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
880
    }
881

    
882
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
883
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
884
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
885
                languageString, height, isMultiLine, style);
886
        adapt(element);
887
        parentElement.addElement(element);
888
        return element;
889
    }
890

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

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

    
937
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
938
			TermType termType,
939
			ICdmFormElement parentElement,
940
			String labelString,
941
			T selection,
942
			boolean addEmptyElement,
943
			int style) {
944
        return this.createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, addEmptyElement, style, false, null);
945
	}
946

    
947
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
948
			TermType termType,
949
			ICdmFormElement parentElement,
950
			String labelString,
951
			T selection,
952
			int style) {
953
		return  this.createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, true, style, false, null);
954
	}
955

    
956
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
957
            List<T> terms,
958
            ICdmFormElement parentElement,
959
            String labelString,
960
            T selection,
961
            int style) {
962
        return  this.createDefinedTermComboElement(null, null, terms, parentElement, labelString, selection, true, style, false, null);
963
    }
964
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
965
	        List<T> terms,
966
	        ICdmFormElement parentElement,
967
	        String labelString,
968
	        T selection,
969
	        boolean addEmptyElement,
970
	        int style) {
971
	    return  this.createDefinedTermComboElement(null, null, terms, parentElement, labelString, selection, addEmptyElement, style, false, null);
972
	}
973
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
974
			TermType termType,
975
			ICdmFormElement parentElement,
976
			String labelString,
977
			T selection,
978
			boolean addEmptyElement,
979
			int style,
980
			boolean useAbbrevLabel) {
981
		return createDefinedTermComboElement(termType, null, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
982
	}
983

    
984

    
985
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
986
            TermVocabulary<?> termVocabulary,
987
            ICdmFormElement parentElement,
988
            String labelString,
989
            T selection,
990
            int style) {
991
        return this.createDefinedTermComboElement(null, termVocabulary, null, parentElement, labelString, selection, true, style, false, null);
992
    }
993

    
994
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
995
	        TermVocabulary<?> termVocabulary,
996
	        ICdmFormElement parentElement,
997
	        String labelString,
998
	        T selection,
999
	        boolean addEmptyElement,
1000
	        int style,
1001
	        boolean useAbbrevLabel) {
1002
	    return createDefinedTermComboElement(null, termVocabulary, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
1003
	}
1004

    
1005
	private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1006
	        TermType termType,
1007
	        TermVocabulary<?> termVocabulary,
1008
	        List<T> terms,
1009
	        ICdmFormElement parentElement,
1010
	        String labelString,
1011
	        T selection,
1012
	        boolean addEmptyElement,
1013
	        int style,
1014
	        boolean useAbbrevLabel,
1015
	        Comparator<T> comparator) {
1016
	    if(termType!=null){
1017
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1018
	        adapt(element);
1019
	        parentElement.addElement(element);
1020
	        return element;
1021
	    }
1022
	    else if(termVocabulary!=null){
1023
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1024
	        if (comparator!= null){
1025
	        	element.setTermComparator(comparator);
1026
	        }
1027
	        adapt(element);
1028
	        parentElement.addElement(element);
1029
	        return element;
1030
	    }else if (terms != null){
1031

    
1032
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, terms, labelString, selection, addEmptyElement, style, useAbbrevLabel);
1033
            if (comparator!= null){
1034
                element.setTermComparator(comparator);
1035
            }
1036
            adapt(element);
1037
            parentElement.addElement(element);
1038
            return element;
1039
	    }
1040
	    else {
1041
	        //this should never happen
1042
	        return null;
1043
	    }
1044
	}
1045

    
1046
	public NameRelationshipTypeCombo createNameRelationshipTypeCombo(ICdmFormElement parentElement,
1047
            String labelString,
1048
            int style,
1049
            boolean useAbbrevLabel,
1050
            Comparator<NameRelationshipType> comparator) {
1051

    
1052
        NameRelationshipTypeCombo<InverseTermWrapper> element = new NameRelationshipTypeCombo(this, parentElement, labelString, true, style, useAbbrevLabel, comparator);
1053
        adapt(element);
1054
        parentElement.addElement(element);
1055
        return element;
1056
    }
1057

    
1058
	public MisappliedRelationshipComboElement createMisappliedRelationshipComboElement(
1059
	        ICdmFormElement parentElement,
1060
            String labelString,
1061
            TaxonRelationshipType selection,
1062
            int style) {
1063
	    MisappliedRelationshipComboElement combo = new MisappliedRelationshipComboElement(this, parentElement, labelString, selection, false, style, false);
1064
	    adapt(combo);
1065
        parentElement.addElement(combo);
1066
        return combo;
1067
    }
1068

    
1069
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1070
	        Class<T> enumComboType, ICdmFormElement parentElement,
1071
	        int style) {
1072
	    return createEnumComboElement(enumComboType, parentElement, null, style);
1073
	}
1074

    
1075
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1076
			Class<T> enumComboType, ICdmFormElement parentElement, Comparator<T> comparator,
1077
			int style) {
1078
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, comparator, style);
1079
        adapt(element);
1080
        parentElement.addElement(element);
1081
        return element;
1082
    }
1083

    
1084
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
1085
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
1086
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1087
	    adapt(element);
1088
	    parentElement.addElement(element);
1089
	    return element;
1090
	}
1091

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

    
1114
    /**
1115
     * <p>
1116
     * createImageElement
1117
     * </p>
1118
     *
1119
     * @param parentElement
1120
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1121
     *            object.
1122
     * @param imageUri
1123
     *            a {@link java.net.URI} object.
1124
     * @param style
1125
     *            a int.
1126
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1127
     */
1128
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1129
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1130
        adapt(element);
1131
        parentElement.addElement(element);
1132
        return element;
1133
    }
1134

    
1135
    /**
1136
     * <p>
1137
     * createTextActionElement
1138
     * </p>
1139
     *
1140
     * @param labelString
1141
     *            a {@link java.lang.String} object.
1142
     * @param initialText
1143
     *            a {@link java.lang.String} object.
1144
     * @param style
1145
     *            a int.
1146
     * @param parentElement
1147
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1148
     *            object.
1149
     * @param buttonLabel
1150
     *            a {@link java.lang.String} object.
1151
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
1152
     *         object.
1153
     */
1154
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
1155
            String buttonLabel, String initialText, int style) {
1156
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
1157
                style);
1158
        adapt(element);
1159
        parentElement.addElement(element);
1160
        return element;
1161
    }
1162

    
1163
    /**
1164
     * <p>
1165
     * createCheckbox
1166
     * </p>
1167
     *
1168
     * @param parentElement
1169
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1170
     *            object.
1171
     * @param label
1172
     *            a {@link java.lang.String} object.
1173
     * @param initialState
1174
     *            a boolean.
1175
     * @param style
1176
     *            a int.
1177
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1178
     *         object.
1179
     */
1180
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1181
        if(initialState==null){
1182
            initialState = Boolean.FALSE;
1183
        }
1184
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1185
        adapt(element);
1186
        parentElement.addElement(element);
1187
        return element;
1188
    }
1189

    
1190
    /**
1191
     * Creates a section as a part of the form.
1192
     *
1193
     * @return the section widget
1194
     * @param section
1195
     *            a
1196
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1197
     *            object.
1198
     */
1199
    public Section adapt(AbstractFormSection section) {
1200
        section.setMenu(section.getLayoutComposite().getMenu());
1201
        adapt(section, true, true);
1202

    
1203
        // handle focus and property change events for cdm use
1204
        section.addFocusListener(selectionFocusHandler);
1205
        section.setPropertyChangeListeners(propertyChangeListeners);
1206

    
1207
        section.addExpansionListener(new ExpansionAdapter(){
1208
            @Override
1209
            public void expansionStateChanged(ExpansionEvent e) {
1210
                super.expansionStateChanged(e);
1211
                if(section.getEntity()!=null){
1212
                    PreferencesUtil.setStringValue(StoreUtil.getPrefKey(section.getClass(), section.getEntity().getClass().getCanonicalName()), e.getState()?CdmSectionPart.EXPANDED:CdmSectionPart.COLLAPSED);
1213
                }
1214
            }
1215
        });
1216

    
1217
        if (section.getToggle() != null) {
1218
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1219
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1220
        }
1221

    
1222
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1223

    
1224
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1225
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1226
            getColors().initializeSectionToolBarColors();
1227
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1228
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1229
        }
1230
        // call setTitleBarForeground regardless as it also sets the label color
1231
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1232
        return section;
1233
    }
1234

    
1235
    private class BoldFontHolder2 {
1236
        private Font normalFont;
1237

    
1238
        private Font boldFont;
1239

    
1240
        public BoldFontHolder2() {
1241
        }
1242

    
1243
        public Font getBoldFont(Font font) {
1244
            createBoldFont(font);
1245
            return boldFont;
1246
        }
1247

    
1248
        private void createBoldFont(Font font) {
1249
            if (normalFont == null || !normalFont.equals(font)) {
1250
                normalFont = font;
1251
                dispose();
1252
            }
1253
            if (boldFont == null) {
1254
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1255
            }
1256
        }
1257

    
1258
        public void dispose() {
1259
            if (boldFont != null) {
1260
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1261
                boldFont = null;
1262
            }
1263
        }
1264
    }
1265

    
1266
    /**
1267
     * <p>
1268
     * createToggleableTextField
1269
     * </p>
1270
     *
1271
     * @param parentElement
1272
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1273
     *            object.
1274
     * @param labelString
1275
     *            a {@link java.lang.String} object.
1276
     * @param initialText
1277
     *            a {@link java.lang.String} object.
1278
     * @param initialState
1279
     *            a boolean.
1280
     * @param style
1281
     *            a int.
1282
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1283
     *         object.
1284
     */
1285
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1286
            String initialText, boolean initialState, int style) {
1287
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1288
                initialState, style | orientation);
1289

    
1290
        adapt(element);
1291
        parentElement.addElement(element);
1292
        return element;
1293
    }
1294

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

    
1320
    /**
1321
     * <p>
1322
     * createVerbatimTimePeriodElement
1323
     * </p>
1324
     *
1325
     * @param parentElement
1326
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1327
     *            object.
1328
     * @param labelString
1329
     *            a {@link java.lang.String} object.
1330
     * @param timePeriod
1331
     *            a {@link eu.etaxonomy.cdm.model.common.VerbatimTimePeriod} object.
1332
     * @param style
1333
     *            a int.
1334
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.VerbatimTimePeriodElement}
1335
     *         object.
1336
     */
1337
    public VerbatimTimePeriodElement createVerbatimTimePeriodElement(ICdmFormElement parentElement, String labelString,
1338
            VerbatimTimePeriod timePeriod, int style) {
1339
        VerbatimTimePeriodElement element = new VerbatimTimePeriodElement(this, parentElement, labelString, timePeriod, style);
1340
        adapt(element);
1341
        parentElement.addElement(element);
1342
        return element;
1343
    }
1344

    
1345

    
1346

    
1347
	/**
1348
	 * <p>
1349
	 * createGatheringEventUnitElement
1350
	 * </p>
1351
	 *
1352
	 * @param parentElement
1353
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1354
	 *            object.
1355
	 * @param labelString
1356
	 *            a {@link java.lang.String} object.
1357
	 * @param timePeriod
1358
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1359
	 * @param style
1360
	 *            a int.
1361
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1362
	 *         object.
1363
	 */
1364
	public GatheringEventUnitElement createGatheringEventUnitElement(
1365
			ICdmFormElement parentElement,
1366
			String labelString,
1367
			DerivedUnitFacade gatheringEvent,
1368
			MinMaxTextSection.UnitType unitType,
1369
			int style) {
1370
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1371
				parentElement,
1372
				labelString,
1373
				gatheringEvent,
1374
				unitType,
1375
				style);
1376
		adapt(element);
1377
		parentElement.addElement(element);
1378
		return element;
1379
	}
1380

    
1381
    /**
1382
     * <p>
1383
     * createPointElement
1384
     * </p>
1385
     *
1386
     * @param style
1387
     *            a int.
1388
     * @param parentElement
1389
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1390
     *            object.
1391
     * @param point
1392
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1393
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1394
     */
1395
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1396
        PointElement element = new PointElement(this, parentElement, point, style);
1397
        adapt(element);
1398
        parentElement.addElement(element);
1399
        return element;
1400
    }
1401

    
1402
    /**
1403
     * Creates an empty section with the given message.<br>
1404
     * If message is <code>null</code> a default message will be displayed.
1405
     */
1406
    public EmptySection createEmptySection(String message, CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1407
        EmptySection section = new EmptySection(message, formFactory, parentElement, style);
1408
        parentElement.addElement(section);
1409
        adapt(section);
1410
        return section;
1411
    }
1412

    
1413
    /**
1414
     * <p>
1415
     * createDateDetailSection
1416
     * </p>
1417
     *
1418
     * @param parentElement
1419
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1420
     *            object.
1421
     * @param style
1422
     *            a int.
1423
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1424
     *         object.
1425
     */
1426
    public DateDetailSection<TimePeriod> createDateDetailSection(ICdmFormElement parentElement, int style) {
1427
        DateDetailSection<TimePeriod> section = new DateDetailSection<TimePeriod>(this, parentElement, false, style);
1428
        parentElement.addElement(section);
1429
        adapt(section);
1430
        return section;
1431
    }
1432

    
1433
    /**
1434
     * <p>
1435
     * createVerbatimDateDetailSection
1436
     * </p>
1437
     *
1438
     * @param parentElement
1439
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1440
     *            object.
1441
     * @param style
1442
     *            a int.
1443
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.VerbatimDateDetailSection}
1444
     *         object.
1445
     */
1446
    public DateDetailSection<VerbatimTimePeriod> createVerbatimDateDetailSection(ICdmFormElement parentElement, int style) {
1447
        DateDetailSection<VerbatimTimePeriod> section
1448
        	= new DateDetailSection<VerbatimTimePeriod>(this, parentElement, true, style);
1449
        parentElement.addElement(section);
1450
        adapt(section);
1451
        return section;
1452
    }
1453

    
1454
	/**
1455
	 * <p>
1456
	 * createDateDetailSection
1457
	 * </p>
1458
	 *
1459
	 * @param parentElement
1460
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1461
	 *            object.
1462
	 * @param style
1463
	 *            a int.
1464
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1465
	 *         object.
1466
	 */
1467
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1468
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1469
		parentElement.addElement(section);
1470
		adapt(section);
1471
		return section;
1472
	}
1473

    
1474
    /**
1475
     * <p>
1476
     * createPartialElement
1477
     * </p>
1478
     *
1479
     * @param parentElement
1480
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1481
     *            object.
1482
     * @param labelString
1483
     *            a {@link java.lang.String} object.
1484
     * @param partial
1485
     *            a {@link org.joda.time.Partial} object.
1486
     * @param style
1487
     *            a int.
1488
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1489
     *         object.
1490
     */
1491
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1492
            int style) {
1493
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1494
        adapt(element);
1495
        parentElement.addElement(element);
1496
        return element;
1497
    }
1498

    
1499
    /**
1500
     * <p>
1501
     * addSelectionListener
1502
     * </p>
1503
     *
1504
     * @param listener
1505
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1506
     */
1507
    public void addSelectionListener(SelectionListener listener) {
1508
        selectionListenerList.add(listener);
1509
    }
1510

    
1511
    /**
1512
     * <p>
1513
     * removeSelectionListener
1514
     * </p>
1515
     *
1516
     * @param listener
1517
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1518
     */
1519
    public void removeSelectionListener(SelectionListener listener) {
1520
        if (listener == null) {
1521
            MessagingUtils.error(this.getClass(),
1522
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1523
        } else {
1524
            selectionListenerList.remove(listener);
1525
        }
1526
    }
1527

    
1528
    /**
1529
     * <p>
1530
     * addPropertyChangeListener
1531
     * </p>
1532
     *
1533
     * @param listener
1534
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1535
     *            object.
1536
     */
1537
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1538
        if (propertyChangeListeners.contains(listener)) {
1539
            return;
1540
        }
1541
        propertyChangeListeners.add(0, listener);
1542
    }
1543

    
1544
    /**
1545
     * <p>
1546
     * removePropertyChangeListener
1547
     * </p>
1548
     *
1549
     * @param listener
1550
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1551
     *            object.
1552
     */
1553
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1554
        propertyChangeListeners.remove(listener);
1555
    }
1556

    
1557
    /**
1558
     * @return the propertyChangeListeners
1559
     */
1560
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1561
        return propertyChangeListeners;
1562
    }
1563

    
1564
    /**
1565
     * <p>
1566
     * createHorizontalSeparator
1567
     * </p>
1568
     *
1569
     * @param parentElement
1570
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1571
     *            object.
1572
     * @param style
1573
     *            a int.
1574
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1575
     */
1576
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1577
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1578
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1579
        return separator;
1580
    }
1581

    
1582
    /**
1583
     * <p>
1584
     * createVersionElement
1585
     * </p>
1586
     *
1587
     * @param parentElement
1588
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1589
     *            object.
1590
     * @param entity
1591
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1592
     *            object.
1593
     * @param style
1594
     *            a int.
1595
     * @return a
1596
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1597
     *         object.
1598
     */
1599
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1600
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1601
        adapt(element);
1602
        parentElement.addElement(element);
1603
        return element;
1604
    }
1605

    
1606
    /**
1607
     * @param cdmBaseSection
1608
     * @param object
1609
     * @param style
1610
     * @return
1611
     */
1612
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1613
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1614
        adapt(element);
1615
        parentElement.addElement(element);
1616
        return element;
1617
    }
1618

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

    
1640
    /**
1641
     * @param parent
1642
     * @param i
1643
     * @return
1644
     */
1645
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1646
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1647
        parentElement.addElement(section);
1648
        adapt(section);
1649
        return section;
1650
    }
1651

    
1652
    /**
1653
     * <p>
1654
     * createEmptyElement
1655
     * </p>
1656
     *
1657
     * @param parentElement
1658
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1659
     *            object.
1660
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1661
     */
1662
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1663
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1664
        adapt(element);
1665
        parentElement.addElement(element);
1666
        return element;
1667
    }
1668

    
1669
    /**
1670
     * <p>
1671
     * createHeadlineSection
1672
     * </p>
1673
     *
1674
     * @param parentElement
1675
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1676
     *            object.
1677
     * @return a
1678
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1679
     *         object.
1680
     */
1681
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1682
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1683
        parentElement.addElement(section);
1684
        adapt(section);
1685
        return section;
1686
    }
1687

    
1688
    /**
1689
     * <p>
1690
     * createParsingMessageElement
1691
     * </p>
1692
     *
1693
     * @param parentElement
1694
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1695
     *            object.
1696
     * @param parserProblem
1697
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1698
     *            object.
1699
     * @param style
1700
     *            a int.
1701
     * @return a
1702
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1703
     *         object.
1704
     */
1705
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1706
            ParserProblem parserProblem, int style) {
1707
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1708
        adapt(element);
1709
        parentElement.addElement(element);
1710
        return element;
1711
    }
1712

    
1713
    public DefinedTermDetailSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1714
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1715

    
1716
        DefinedTermDetailSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1717
                selectionProvider, style);
1718

    
1719
        parentElement.addElement(section);
1720
        adapt(section);
1721
        return section;
1722

    
1723
    }
1724

    
1725
    public TermMediaSection createTermMediaSection(ConversationHolder conversation,
1726
            ICdmFormElement parentElement, int style) {
1727
        TermMediaSection section = new TermMediaSection(this, conversation, parentElement, style);
1728
        parentElement.addElement(section);
1729
        adapt(section);
1730
        return section;
1731

    
1732
    }
1733

    
1734
    /**
1735
     * @param definedTermClass
1736
     * @param formElement
1737
     * @param style
1738
     * @return
1739
     */
1740
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1741
            AbstractCdmDetailSection parentElement, int style) {
1742
        AbstractCdmDetailElement element = null;
1743

    
1744
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1745
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1746
        } else if (definedTermClass.equals(Feature.class)) {
1747
            element = new FeatureDetailElement(this, parentElement);
1748
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1749
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1750
        } else {
1751
            element = new DefinedTermDetailElement(this, parentElement);
1752
        }
1753

    
1754

    
1755
        adapt(element);
1756
        parentElement.addElement(element);
1757
        return element;
1758
    }
1759

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

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

    
1772
    public CharacterNodeDetailElement createCharacterNodeDetailElement(ICdmFormElement parentElement, int style){
1773
        CharacterNodeDetailElement element = new CharacterNodeDetailElement(this, parentElement);
1774
        addAndAdaptElement(parentElement, element);
1775
        return element;
1776
    }
1777

    
1778
    public CharacterDetailElement createCharacterDetailElement(ICdmFormElement parentElement, int style){
1779
        CharacterDetailElement element = new CharacterDetailElement(this, parentElement);
1780
        addAndAdaptElement(parentElement, element);
1781
        return element;
1782
    }
1783

    
1784
    public FeatureTreeDetailElement createFeatureTreeDetailElement(ICdmFormElement parentElement, int style){
1785
        FeatureTreeDetailElement element = new FeatureTreeDetailElement(this, parentElement);
1786
        addAndAdaptElement(parentElement, element);
1787
        return element;
1788
    }
1789

    
1790
    public FeatureNodeDetailElement createFeatureNodeDetailElement(ICdmFormElement parentElement, int style){
1791
        FeatureNodeDetailElement element = new FeatureNodeDetailElement(this, parentElement);
1792
        addAndAdaptElement(parentElement, element);
1793
        return element;
1794
    }
1795

    
1796

    
1797
    //--------DetailSections---------
1798
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1799
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1800
        addAndAdaptSection(parentElement, section);
1801
        return section;
1802
    }
1803

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

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

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

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

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

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

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

    
1846
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1847
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1848
        addAndAdaptSection(parentElement, section);
1849
        return section;
1850
    }
1851

    
1852
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1853
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1854
        addAndAdaptSection(parentElement, section);
1855
        return section;
1856
    }
1857

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

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

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

    
1876

    
1877

    
1878
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, boolean nameChoosable, int style){
1879
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, nameChoosable, style);
1880
        addAndAdaptSection(parentElement, section);
1881
        return section;
1882
    }
1883

    
1884
    public MediaDetailsSection createMediaDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1885
        MediaDetailsSection section = new MediaDetailsSection(this, conversation, parentElement, selectionProvider, style);
1886
        addAndAdaptSection(parentElement, section);
1887
        return section;
1888
    }
1889

    
1890
    public FieldUnitDetailSection createFieldUnitDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1891
        FieldUnitDetailSection section = new FieldUnitDetailSection(this, conversation, parentElement, selectionProvider, style);
1892
        addAndAdaptSection(parentElement, section);
1893
        return section;
1894
    }
1895

    
1896
    public GatheringEventDetailSection createGatheringEventDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1897
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1898
        addAndAdaptSection(parentElement, section);
1899
        return section;
1900
    }
1901

    
1902
    public DerivedUnitBaseDetailSection createDerivedUnitBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1903
        DerivedUnitBaseDetailSection section = new DerivedUnitBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1904
        addAndAdaptSection(parentElement, section);
1905
        return section;
1906
    }
1907

    
1908
    public DerivedUnitTypeDesignationSection createDerivedUnitTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1909
        DerivedUnitTypeDesignationSection section = new DerivedUnitTypeDesignationSection(this, conversation, parentElement, style);
1910
        addAndAdaptSection(parentElement, section);
1911
        return section;
1912
    }
1913

    
1914
    public TaxonAssociationDetailSection createTaxonAssociationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1915
        TaxonAssociationDetailSection section = new TaxonAssociationDetailSection(this, conversation, parentElement, selectionProvider, style);
1916
        addAndAdaptSection(parentElement, section);
1917
        return section;
1918
    }
1919

    
1920
    public OriginalLabelDataSection createOriginalLabelDataSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1921
        OriginalLabelDataSection section = new OriginalLabelDataSection(this, conversation, parentElement, selectionProvider, style);
1922
        addAndAdaptSection(parentElement, section);
1923
        return section;
1924
    }
1925

    
1926
    public NaturalLanguageSection createNaturalLanguageSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1927
        NaturalLanguageSection section = new NaturalLanguageSection(this, conversation, parentElement, selectionProvider, style);
1928
        addAndAdaptSection(parentElement, section);
1929
        return section;
1930
    }
1931

    
1932
    public FeatureDistributionDetailSection createFeatureDistributionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1933
        FeatureDistributionDetailSection section = new FeatureDistributionDetailSection(this, conversation, parentElement, selectionProvider, style);
1934
        addAndAdaptSection(parentElement, section);
1935
        return section;
1936
    }
1937

    
1938
    public ClassificationDetailSection createClassificationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1939
        ClassificationDetailSection section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style);
1940
        addAndAdaptSection(parentElement, section);
1941
        return section;
1942
    }
1943

    
1944
    public TaxonNodeDetailSection createTaxonNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1945
        TaxonNodeDetailSection section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1946
        addAndAdaptSection(parentElement, section);
1947
        return section;
1948
    }
1949

    
1950
    public PolytomousKeyDetailSection createPolytomousKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1951
        PolytomousKeyDetailSection section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
1952
        addAndAdaptSection(parentElement, section);
1953
        return section;
1954
    }
1955

    
1956
    public PolytomousKeyNodeDetailSection createPolytomousKeyNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1957
        PolytomousKeyNodeDetailSection section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1958
        addAndAdaptSection(parentElement, section);
1959
        return section;
1960
    }
1961

    
1962
    public InstitutionDetailSection createInstitutionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1963
        InstitutionDetailSection section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
1964
        addAndAdaptSection(parentElement, section);
1965
        return section;
1966
    }
1967

    
1968
    public FieldUnitGeneralDetailSection createFieldUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1969
        FieldUnitGeneralDetailSection section = new FieldUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1970
        addAndAdaptSection(parentElement, section);
1971
        return section;
1972
    }
1973

    
1974
    public DerivedUnitGeneralDetailSection createDerivedUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1975
        DerivedUnitGeneralDetailSection section = new DerivedUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1976
        addAndAdaptSection(parentElement, section);
1977
        return section;
1978
    }
1979

    
1980
    public PreservedSpecimenGeneralDetailSection createPreservedSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1981
        PreservedSpecimenGeneralDetailSection section = new PreservedSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1982
        addAndAdaptSection(parentElement, section);
1983
        return section;
1984
    }
1985

    
1986
    public TissueSampleGeneralDetailSection createTissueSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1987
        TissueSampleGeneralDetailSection section = new TissueSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1988
        addAndAdaptSection(parentElement, section);
1989
        return section;
1990
    }
1991

    
1992
    public DnaSampleGeneralDetailSection createDnaSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1993
        DnaSampleGeneralDetailSection section = new DnaSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1994
        addAndAdaptSection(parentElement, section);
1995
        return section;
1996
    }
1997

    
1998
    public DnaSamplePreparationPreservationSection createDnaSamplePreparationPreservationSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1999
        DnaSamplePreparationPreservationSection section = new DnaSamplePreparationPreservationSection(this, conversation, parentElement, selectionProvider, style);
2000
        addAndAdaptSection(parentElement, section);
2001
        return section;
2002
    }
2003

    
2004
    public DnaQualityDetailSection createDnaQualityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2005
        DnaQualityDetailSection section = new DnaQualityDetailSection(this, conversation, parentElement, selectionProvider, style);
2006
        addAndAdaptSection(parentElement, section);
2007
        return section;
2008
    }
2009

    
2010
    public SequenceGeneralDetailSection createSequenceGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2011
        SequenceGeneralDetailSection section = new SequenceGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2012
        addAndAdaptSection(parentElement, section);
2013
        return section;
2014
    }
2015

    
2016
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2017
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
2018
        addAndAdaptSection(parentElement, section);
2019
        return section;
2020
    }
2021

    
2022
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2023
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
2024
        addAndAdaptSection(parentElement, section);
2025
        return section;
2026
    }
2027

    
2028
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2029
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
2030
        addAndAdaptSection(parentElement, section);
2031
        return section;
2032
    }
2033

    
2034
    public SingleReadGeneralDetailSection createSingleReadGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2035
        SingleReadGeneralDetailSection section = new SingleReadGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2036
        addAndAdaptSection(parentElement, section);
2037
        return section;
2038
    }
2039

    
2040
    public AmplificationGeneralDetailSection createAmplificationGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2041
        AmplificationGeneralDetailSection section = new AmplificationGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2042
        addAndAdaptSection(parentElement, section);
2043
        return section;
2044
    }
2045

    
2046
    public AmplificationPrimerDetailSection createAmplificationPrimerDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2047
        AmplificationPrimerDetailSection section = new AmplificationPrimerDetailSection(this, conversation, parentElement, selectionProvider, style);
2048
        addAndAdaptSection(parentElement, section);
2049
        return section;
2050
    }
2051

    
2052
    public AmplificationCloningDetailSection createAmplificationCloningDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2053
        AmplificationCloningDetailSection section = new AmplificationCloningDetailSection(this, conversation, parentElement, selectionProvider, style);
2054
        addAndAdaptSection(parentElement, section);
2055
        return section;
2056
    }
2057

    
2058
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2059
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
2060
        addAndAdaptSection(parentElement, section);
2061
        return section;
2062
    }
2063

    
2064
    public MediaSpecimenGeneralDetailSection createMediaSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2065
        MediaSpecimenGeneralDetailSection section = new MediaSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
2066
        addAndAdaptSection(parentElement, section);
2067
        return section;
2068
    }
2069

    
2070
    public HybridDetailSection createHybridDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2071
        HybridDetailSection section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
2072
        addAndAdaptSection(parentElement, section);
2073
        return section;
2074
    }
2075

    
2076
    public UserDetailSection createUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2077
        UserDetailSection section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
2078
        addAndAdaptSection(parentElement, section);
2079
        return section;
2080
    }
2081

    
2082
    public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2083
        GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
2084
        addAndAdaptSection(parentElement, section);
2085
        return section;
2086
    }
2087

    
2088
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2089
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
2090
        addAndAdaptSection(parentElement, section);
2091
        return section;
2092
    }
2093

    
2094
    public SampleDesignationDetailSection createSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2095
        SampleDesignationDetailSection section = new SampleDesignationDetailSection(this, conversation, parentElement, selectionProvider, style);
2096
        addAndAdaptSection(parentElement, section);
2097
        return section;
2098
    }
2099

    
2100
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2101
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style, true);
2102
        addAndAdaptSection(parentElement, section);
2103
        return section;
2104
    }
2105

    
2106
    public ReferencedEntityDetailSection createReferencedEntityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2107
        ReferencedEntityDetailSection section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
2108
        addAndAdaptSection(parentElement, section);
2109
        return section;
2110
    }
2111

    
2112
    public TermVocabularyDetailSection createTermVocabularyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2113
        TermVocabularyDetailSection section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
2114
        addAndAdaptSection(parentElement, section);
2115
        return section;
2116
    }
2117

    
2118
    public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2119
        GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
2120
        addAndAdaptSection(parentElement, section);
2121
        return section;
2122
    }
2123

    
2124
    public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2125
        NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
2126
        addAndAdaptSection(parentElement, section);
2127
        return section;
2128
    }
2129

    
2130
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
2131
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
2132
        addAndAdaptSection(parentElement, section);
2133
        return section;
2134
    }
2135

    
2136
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
2137
        parentElement.addElement(section);
2138
        adapt(section);
2139
    }
2140

    
2141
    //--------DetailElements------------
2142

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

    
2149
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
2150
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
2151
        addAndAdaptElement(parentElement, element);
2152
        return element;
2153
    }
2154

    
2155
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
2156
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
2157
        addAndAdaptElement(parentElement, element);
2158
        return element;
2159
    }
2160

    
2161
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
2162
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
2163
        addAndAdaptElement(parentElement, element);
2164
        return element;
2165
    }
2166

    
2167
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
2168
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
2169
        addAndAdaptElement(parentElement, element);
2170
        return element;
2171
    }
2172

    
2173
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
2174
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
2175
        addAndAdaptElement(parentElement, element);
2176
        return element;
2177
    }
2178

    
2179
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
2180
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2181
        addAndAdaptElement(parentElement, element);
2182
        return element;
2183
    }
2184

    
2185
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2186
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2187
        addAndAdaptElement(parentElement, element);
2188
        return element;
2189
    }
2190

    
2191
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2192
        UserDetailElement element = new UserDetailElement(this, parentElement);
2193
        addAndAdaptElement(parentElement, element);
2194
        return element;
2195
    }
2196

    
2197
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2198
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2199
        addAndAdaptElement(parentElement, element);
2200
        return element;
2201
    }
2202

    
2203
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2204
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2205
        addAndAdaptElement(parentElement, element);
2206
        return element;
2207
    }
2208

    
2209
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2210
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2211
        addAndAdaptElement(parentElement, element);
2212
        return element;
2213
    }
2214

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

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

    
2227
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2228
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2229
        adapt(element);
2230
        parentElement.addElement(element);
2231

    
2232
        return element;
2233
    }
2234

    
2235
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2236
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2237
        addAndAdaptElement(parentElement, element);
2238
        return element;
2239
    }
2240

    
2241
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
2242
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
2243
        addAndAdaptElement(parentElement, element);
2244
        return element;
2245
    }
2246

    
2247
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2248
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2249
        addAndAdaptElement(parentElement, element);
2250
        return element;
2251
    }
2252

    
2253
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2254
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2255
        addAndAdaptElement(parentElement, element);
2256
        return element;
2257
    }
2258

    
2259
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2260
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2261
        addAndAdaptElement(parentElement, element);
2262
        return element;
2263
    }
2264

    
2265
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2266
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2267
        addAndAdaptElement(parentElement, element);
2268
        return element;
2269
    }
2270

    
2271
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2272
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2273
        addAndAdaptElement(parentElement, element);
2274
        return element;
2275
    }
2276

    
2277
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2278
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2279
        addAndAdaptElement(parentElement, element);
2280
        return element;
2281
    }
2282

    
2283
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2284
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2285
        addAndAdaptElement(parentElement, element);
2286
        return element;
2287
    }
2288

    
2289
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2290
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2291
        addAndAdaptElement(parentElement, element);
2292
        return element;
2293
    }
2294

    
2295
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2296
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2297
        addAndAdaptElement(parentElement, element);
2298
        return element;
2299
    }
2300

    
2301
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2302
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2303
        addAndAdaptElement(parentElement, element);
2304
        return element;
2305
    }
2306

    
2307
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2308
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2309
        addAndAdaptElement(parentElement, element);
2310
        return element;
2311
    }
2312

    
2313
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2314
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2315
        addAndAdaptElement(parentElement, element);
2316
        return element;
2317
    }
2318

    
2319
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2320
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2321
        addAndAdaptElement(parentElement, element);
2322
        return element;
2323
    }
2324

    
2325

    
2326
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2327
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2328
        addAndAdaptElement(parentElement, element);
2329
        return element;
2330
    }
2331

    
2332
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2333
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2334
        addAndAdaptElement(parentElement, element);
2335
        return element;
2336
    }
2337

    
2338
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2339
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2340
        addAndAdaptElement(parentElement, element);
2341
        return element;
2342
    }
2343

    
2344
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2345
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2346
        addAndAdaptElement(parentElement, element);
2347
        return element;
2348
    }
2349

    
2350
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2351
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2352
        addAndAdaptElement(parentElement, element);
2353
        return element;
2354
    }
2355

    
2356
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2357
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2358
        addAndAdaptElement(parentElement, element);
2359
        return element;
2360
    }
2361

    
2362
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2363
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2364
        addAndAdaptElement(parentElement, element);
2365
        return element;
2366
    }
2367

    
2368
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2369
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2370
        addAndAdaptElement(parentElement, element);
2371
        return element;
2372
    }
2373

    
2374
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2375
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2376
        addAndAdaptElement(parentElement, element);
2377
        return element;
2378
    }
2379

    
2380
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2381
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2382
        addAndAdaptElement(parentElement, element);
2383
        return element;
2384
    }
2385

    
2386
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2387
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2388
        addAndAdaptElement(parentElement, element);
2389
        return element;
2390
    }
2391

    
2392
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2393
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2394
        addAndAdaptElement(parentElement, element);
2395
        return element;
2396
    }
2397

    
2398
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2399
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2400
        addAndAdaptElement(parentElement, element);
2401
        return element;
2402
    }
2403

    
2404
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2405
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2406
        addAndAdaptElement(parentElement, element);
2407
        return element;
2408
    }
2409

    
2410
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2411
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2412
        addAndAdaptElement(parentElement, element);
2413
        return element;
2414
    }
2415

    
2416
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2417
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2418
        addAndAdaptElement(parentElement, element);
2419
        return element;
2420
    }
2421

    
2422
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2423
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2424
        addAndAdaptElement(parentElement, mediaDetailElement);
2425
        return mediaDetailElement;
2426
    }
2427

    
2428
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2429
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2430
        addAndAdaptElement(parentElement, element);
2431
        return element;
2432
    }
2433

    
2434
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2435
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2436
        addAndAdaptElement(parentElement, element);
2437
        return element;
2438
    }
2439

    
2440
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2441
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2442
        addAndAdaptElement(parentElement, element);
2443
        return element;
2444
    }
2445

    
2446
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2447
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2448
        addAndAdaptElement(parentElement, element);
2449
        return element;
2450
    }
2451

    
2452
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2453
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2454
        addAndAdaptElement(parentElement, element);
2455
        return element;
2456
    }
2457

    
2458
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2459
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2460
        addAndAdaptElement(parentElement, element);
2461
        return element;
2462
    }
2463

    
2464
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2465
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2466
        addAndAdaptElement(parentElement, element);
2467
        return element;
2468
    }
2469

    
2470
    /**
2471
     * @param parentElement
2472
     * @param element
2473
     */
2474
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2475
        adapt(element);
2476
        parentElement.addElement(element);
2477
    }
2478

    
2479
    //--------EntityCollectionSection----------
2480
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2481
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2482
        addAndAdaptSection(parentElement, section);
2483
        return section;
2484
    }
2485

    
2486
    public InapplicableIfEntityCollectionSection createInapplicableIfEntityCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2487
        InapplicableIfEntityCollectionSection section = new InapplicableIfEntityCollectionSection(this, conversation, parentElement, style);
2488
        addAndAdaptSection(parentElement, section);
2489
        return section;
2490
    }
2491

    
2492
    public OnlyApplicableIfEntityCollectionSection createOnlyApplicableIfEntityCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2493
        OnlyApplicableIfEntityCollectionSection section = new OnlyApplicableIfEntityCollectionSection(this, conversation, parentElement, style);
2494
        addAndAdaptSection(parentElement, section);
2495
        return section;
2496
    }
2497

    
2498
    public AnnotationSection createAnnotationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2499
        AnnotationSection section = new AnnotationSection(this, conversation, parentElement, style);
2500
        addAndAdaptSection(parentElement, section);
2501
        return section;
2502
    }
2503

    
2504
    public CreditSection createCreditSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2505
        CreditSection section = new CreditSection(this, conversation, parentElement, style);
2506
        addAndAdaptSection(parentElement, section);
2507
        return section;
2508
    }
2509
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2510
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2511
        addAndAdaptSection(parentElement, section);
2512
        return section;
2513
    }
2514
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, Reference defaultSource, int style){
2515
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, defaultSource, style);
2516
        addAndAdaptSection(parentElement, section);
2517
        return section;
2518
    }
2519

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

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

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

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

    
2544
    public MediaRepresentationSection createMediaRepresentationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2545
        MediaRepresentationSection section = new MediaRepresentationSection(this, conversation, parentElement, style);
2546
        addAndAdaptSection(parentElement, section);
2547
        return section;
2548
    }
2549

    
2550
    public MediaRepresentationPartSection createMediaRepresentationPartSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2551
        MediaRepresentationPartSection section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
2552
        addAndAdaptSection(parentElement, section);
2553
        return section;
2554
    }
2555

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

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

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

    
2574
    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2575
        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2576
        addAndAdaptSection(parentElement, section);
2577
        return section;
2578
    }
2579
    public ExternalLinksSection createExternalLinksSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2580
        ExternalLinksSection section = new ExternalLinksSection(this, conversation, parentElement, style);
2581
        addAndAdaptSection(parentElement, section);
2582
        return section;
2583
    }
2584

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2735
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2736
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2737
        addAndAdaptSection(parentElement, section);
2738
        return section;
2739
    }
2740

    
2741
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2742
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2743
        addAndAdaptSection(parentElement, section);
2744
        return section;
2745
    }
2746

    
2747
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2748
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2749
        addAndAdaptSection(parentElement, section);
2750
        return section;
2751
    }
2752

    
2753
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2754
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2755
        addAndAdaptSection(parentElement, section);
2756
        return section;
2757
    }
2758

    
2759
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2760
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2761
        addAndAdaptSection(parentElement, section);
2762
        return section;
2763
    }
2764

    
2765

    
2766
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2767
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2768
        AbstractEntityCollectionElement<?> element = null;
2769

    
2770
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2771

    
2772
        if (entity instanceof Annotation) {
2773
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2774
        }else if (entity instanceof Person ) {
2775
            boolean isNomenclatural = false;
2776
            if (parentElement instanceof TeamMemberSection){
2777
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2778
            }
2779
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2780
        } else if (entity instanceof Credit) {
2781
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2782
        } else if (entity instanceof Extension) {
2783
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2784
        } else if (entity instanceof ExternalLink) {
2785
            element = new ExternalLinksElement(this, parentElement, (ExternalLink) entity, removeListener, style);
2786
        } else if (entity instanceof Marker) {
2787
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2788
        } else if (entity instanceof TaxonNodeAgentRelation) {
2789
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2790
        }else if (entity instanceof Media) {
2791
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2792
        } else if (entity instanceof MediaRepresentation) {
2793
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2794
                    style);
2795
        } else if (entity instanceof ImageFile) {
2796
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2797
        } else if (entity instanceof MediaRepresentationPart) {
2798
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2799
                    removeListener, style);
2800
        } else if (entity instanceof NomenclaturalStatus) {
2801
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2802
                    style);
2803
        } else if (entity instanceof Rights) {
2804
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2805
        } else if (entity instanceof DescriptionElementSource && parentElement.getEntity() instanceof CommonTaxonName) {
2806
            element = new CommonNameSourceElement(this, parentElement, (DescriptionElementSource) entity,
2807
                    removeListener, style);
2808
        } else if (entity instanceof DescriptionElementSource  && parentElement.getEntity() instanceof Distribution) {
2809
            Composite parent = null;
2810
            if (parentElement instanceof DescriptionElementSourceSection){
2811
               parent = ((DescriptionElementSourceSection)parentElement).getParent();
2812
            }
2813
            if(parent != null){
2814
                Composite grandParent = parent.getParent();
2815
            }
2816
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2817
                    removeListener, style, false);
2818
        } else if (entity instanceof DescriptionElementSource) {
2819
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2820
                    removeListener, style, false);
2821
        }else if (entity instanceof TaxonNodeAgentRelation) {
2822
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2823
                    removeListener,backgroundColor, style);
2824
        }
2825
        else if (entity instanceof IdentifiableSource) {
2826
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2827
                    style);
2828
        } else if (entity instanceof DefinedTerm) {
2829
            switch(((DefinedTerm)entity).getTermType()) {
2830
            case Scope:
2831
                element = new ScopeElement(this,
2832
                        parentElement,
2833
                        (DefinedTerm) entity,
2834
                        removeListener,
2835
                        style);
2836
                break;
2837
            case Modifier:
2838
                element = new ModifierElement(this,
2839
                        parentElement,
2840
                        (DefinedTerm) entity,
2841
                        removeListener,
2842
                        style);
2843
                break;
2844
            default:
2845
                break;
2846

    
2847
            }
2848
        } else if (entity instanceof Reference) {
2849
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2850
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2851
            }
2852
            else{
2853
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2854
            }
2855
        } else if (entity instanceof NameTypeDesignation) {
2856
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2857
                    style);
2858
        } else if (entity instanceof TextualTypeDesignation) {
2859
            element = new TextTypeDesignationElement(this, parentElement, (TextualTypeDesignation) entity, removeListener,
2860
                    style);
2861
        } else if (entity instanceof NameRelationship) {
2862
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2863
                    style);
2864
        } else if (entity instanceof SpecimenTypeDesignation) {
2865
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
2866
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2867
                        removeListener, style);
2868
            }
2869
            else{
2870
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2871
                        removeListener, style);
2872
            }
2873
        } else if (entity instanceof StateData) {
2874
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2875
        } else if (entity instanceof StatisticalMeasurementValue) {
2876
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2877
                    removeListener, style);
2878
        } else if (entity instanceof DerivedUnit) {
2879
            switch(((DerivedUnit)entity).getRecordBasis()) {
2880
            case LivingSpecimen:
2881
            case PreservedSpecimen:
2882
            case OtherSpecimen:
2883
                element = new SpecimenCollectionDetailElement(this,
2884
                        parentElement,
2885
                        (DerivedUnit) entity,
2886
                        removeListener,
2887
                        style);
2888
                break;
2889
            default:
2890
                element = new DerivedUnitElement(this,
2891
                        parentElement,
2892
                        (DerivedUnit) entity,
2893
                        removeListener,
2894
                        style);
2895
            }
2896

    
2897
        } else if (entity instanceof NamedArea) {
2898
            element = new CollectingAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2899
        } else if (entity instanceof DeterminationEvent) {
2900
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2901
        } else if (entity instanceof User) {
2902
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2903
        } else if (entity instanceof GrantedAuthority) {
2904
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
2905
                    removeListener, style);
2906
        } else if (entity instanceof Group) {
2907
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2908
        } else if (entity instanceof Taxon) {
2909
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2910
        } else if (entity instanceof DescriptionElementBase) {
2911
            // this is the special case for protologs, maybe we can do this
2912
            // differently when API improves
2913
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2914
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2915
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2916
            }
2917
        } else if (entity instanceof Identifier) {
2918
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2919
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2920
            }
2921
            else{
2922
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
2923
            }
2924
        } else if (entity instanceof TermVocabulary) {
2925
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
2926
            switch (termVocabulary.getTermType()) {
2927
            case State:
2928
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
2929
                break;
2930
            case Modifier:
2931
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
2932
                break;
2933
            default:
2934
                break;
2935
            }
2936
        } else if (entity instanceof MeasurementUnit) {
2937
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2938
        } else if (entity instanceof StatisticalMeasure) {
2939
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2940
        } else if (entity instanceof FeatureState && parentElement instanceof InapplicableIfEntityCollectionSection) {
2941
            element = new InapplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
2942
        } else if (entity instanceof FeatureState && parentElement instanceof OnlyApplicableIfEntityCollectionSection) {
2943
            element = new OnlyApplicableIfCollectionElement(this, parentElement, (FeatureState) entity, removeListener, backgroundColor, style);
2944
        }
2945

    
2946
        //check for parent section when entity is null
2947
        //this happens when AbstractUnboundEntityCollectionSection is used
2948
        if(element==null){
2949
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
2950
                element = new ScopeElement(this,
2951
                        parentElement,
2952
                        (DefinedTerm) entity,
2953
                        removeListener,
2954
                        style);
2955
            }
2956
            else if(parentElement instanceof ModifierSection){
2957
                element = new ModifierElement(this,
2958
                        parentElement,
2959
                        (DefinedTerm) entity,
2960
                        removeListener,
2961
                        style);
2962
            }
2963
        }
2964

    
2965

    
2966
        if (element == null) {
2967
            MessagingUtils.messageDialog(
2968
                    String.format("Error when creating section %s",
2969
                            parentElement.getClass().getSimpleName()),
2970
                    this,
2971
                    String.format("Could not generate collection element for entity of class %s."
2972
                            + " Looks like the case is not yet handled. Check implementation.\n"
2973
                            + "Entity: %s", entity.getClass(), entity.toString()), null);
2974
        }
2975

    
2976
        else{
2977
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2978
                element.setPersistentBackground(backgroundColor);
2979
            }
2980
            adapt(element);
2981
            parentElement.addElement(element);
2982
        }
2983

    
2984
        return element;
2985
    }
2986

    
2987
    /**
2988
     * <p>
2989
     * Creates a selection element for the given type T.
2990
     * </p>
2991
     * <p>
2992
     * <strong>Selection elements not handled by this method:</strong>
2993
     * <ul>
2994
     * <li>{@link TaxonNodeSelectionElement} see
2995
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2996
     * </li>
2997
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2998
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2999
     * </li>
3000
     * </ul>
3001
     * </p>
3002
     *
3003
     * @param clazz
3004
     *            a {@link Class} object of the type that you want the selection
3005
     *            element to handle
3006
     * @param parentElement
3007
     *            a {@link ICdmFormElement} object.
3008
     * @param labelString
3009
     *            a {@link String} object.
3010
     * @param selectionType
3011
     * @param selection
3012
     *            a {@link ICdmBase} object.
3013
     * @param style
3014
     *            a int.
3015
     * @param conversation
3016
     *            a {@link ConversationHolder} object.
3017
     * @return a {@link EntitySelectionElement} object.
3018
     */
3019
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3020
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3021
            int style, Integer limit) {
3022
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this,
3023
                parentElement, clazz,
3024
                labelString, selection, mode, style, limit);
3025
        adapt(element);
3026
        parentElement.addElement(element);
3027
        return element;
3028
    }
3029

    
3030
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3031
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3032
            int style, boolean filterElement) {
3033
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
3034
                parentElement, clazz,
3035
                labelString, selection, mode, style, filterElement);
3036
        adapt(element);
3037
        parentElement.addElement(element);
3038
        return element;
3039
    }
3040

    
3041
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
3042
//            ConversationHolder conversation,
3043
            ICdmFormElement parentElement, String labelString, T selection, int mode,
3044
            int style) {
3045
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this,
3046
                parentElement, clazz,
3047
                labelString, selection, mode, style);
3048
        adapt(element);
3049
        parentElement.addElement(element);
3050
        return element;
3051
    }
3052

    
3053
    public CommonNameReferenceSelectionElement createCommonNameReferenceSelectionElement(ICdmFormElement parentElement, String labelString, Reference selection, int mode,
3054
          int style) {
3055
        CommonNameReferenceSelectionElement element = new CommonNameReferenceSelectionElement(this,
3056
              parentElement, labelString, selection, mode, style);
3057
      adapt(element);
3058
      parentElement.addElement(element);
3059
      return element;
3060
  }
3061

    
3062
    /**
3063
     * <p>
3064
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
3065
     * </p>
3066
     * <p>
3067
     * <strong>Selection elements not handled by this method:</strong>
3068
     * <ul>
3069
     * <li>{@link TaxonNodeSelectionElement} see
3070
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
3071
     * </li>
3072
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
3073
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
3074
     * </li>
3075
     * </ul>
3076
     * </p>
3077
     *
3078
     * @param clazz
3079
     *            a {@link Class} object of the type that you want the selection
3080
     *            element to handle
3081
     * @param parentElement
3082
     *            a {@link ICdmFormElement} object.
3083
     * @param labelString
3084
     *            a {@link String} object.
3085
     * @param selectionType
3086
     * @param selection
3087
     *            a {@link ICdmBase} object.
3088
     * @param style
3089
     *            a int.
3090
     * @param conversation
3091
     *            a {@link ConversationHolder} object.
3092
     * @return a {@link EntitySelectionElement} object.
3093
     */
3094
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
3095
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
3096
            T selection, int mode, int style) {
3097
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, //conversation,
3098
                parentElement, clazz,
3099
                labelString, selection, mode, style);
3100
        adapt(element);
3101
        parentElement.addElement(element);
3102
        return element;
3103
    }
3104

    
3105
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3106
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
3107
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this,
3108
                parentElement,
3109
                labelString, selection, mode, style, null);
3110
        adapt(element);
3111
        parentElement.addElement(element);
3112
        return element;
3113
    }
3114
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
3115
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style, Integer limit) {
3116
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
3117
                parentElement,
3118
                labelString, selection, mode, style, limit);
3119
        adapt(element);
3120
        parentElement.addElement(element);
3121
        return element;
3122
    }
3123

    
3124

    
3125
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
3126
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
3127
//            int mode, int style) {
3128
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
3129
//                conversation, parentElement, labelString, selection, mode, style);
3130
//        adapt(element);
3131
//        parentElement.addElement(element);
3132
//        return element;
3133
//    }
3134

    
3135
    /** {@inheritDoc} */
3136
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
3137
        LabelElement labelElement = new LabelElement(this, parentElement, text);
3138
        adapt(labelElement);
3139
        parentElement.addElement(labelElement);
3140
        return labelElement;
3141
    }
3142

    
3143

    
3144

    
3145
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
3146
//        Label label = new Label(formElement.getLayoutComposite(), style);
3147
//        label.setText(labelText+" (yyyy-MM-dd)");
3148
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
3149
//        dateElement.initInternalController();
3150
//
3151
//        return dateElement;
3152
//    }
3153

    
3154
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
3155
    	 Label label = new Label(formElement.getLayoutComposite(), style);
3156
         label.setText(labelText);
3157
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3158
         DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
3159
         dateElement.initController(this, formElement);
3160
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
3161
         return dateElement;
3162
    }
3163

    
3164
    /**
3165
     * <p>
3166
     * Getter for the field <code>selectionProvider</code>.
3167
     * </p>
3168
     *
3169
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
3170
     */
3171
    public ISelectionProvider getSelectionProvider() {
3172
        return selectionProvider;
3173
    }
3174

    
3175
    /**
3176
     * <p>
3177
     * createDetailedDescriptionDetailElement
3178
     * </p>
3179
     *
3180
     * @param parentElement
3181
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3182
     *            object.
3183
     * @param entity
3184
     *            a
3185
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
3186
     *            object.
3187
     * @param style
3188
     *            a int.
3189
     * @return a
3190
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
3191
     *         object.
3192
     */
3193
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
3194
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
3195
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
3196

    
3197
        if (entity instanceof CategoricalData) {
3198
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
3199
                    (CategoricalData) entity, style);
3200
        } else if (entity instanceof CommonTaxonName) {
3201
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
3202
                    style);
3203
        } else if (entity instanceof Distribution && !enabled) {
3204
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3205
                    enabled, style);
3206
        } else if (entity instanceof Distribution) {
3207
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3208
                    true, style);
3209
        }else if (entity instanceof IndividualsAssociation) {
3210
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
3211
                    (IndividualsAssociation) entity, style);
3212
        } else if (entity instanceof QuantitativeData) {
3213
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
3214
                    (QuantitativeData) entity, style);
3215
        } else if (entity instanceof TaxonInteraction) {
3216
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
3217
                    (TaxonInteraction) entity, style);
3218
        } else if (entity instanceof TextData) {
3219
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
3220
        } else {
3221
            throw new IllegalStateException("There is no interface for the given description element");
3222
        }
3223
        adapt(detailedDescriptionElement);
3224
        parentElement.addElement(detailedDescriptionElement);
3225
        return detailedDescriptionElement;
3226

    
3227
    }
3228

    
3229
    /**
3230
     * Creates a styled text as a part of the form.
3231
     *
3232
     * @param parent
3233
     *            the text parent
3234
     * @param value
3235
     *            the text initial value
3236
     * @param style
3237
     *            the text style
3238
     * @return the text widget
3239
     */
3240
    public StyledText createStyledText(Composite parent, String value, int style) {
3241
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3242
        if (value != null) {
3243
            text.setText(value);
3244
        }
3245
        text.setForeground(getColors().getForeground());
3246
        text.setBackground(getColors().getBackground());
3247
        // text.addFocusListener(visibilityHandler);
3248
        return text;
3249
    }
3250

    
3251
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3252
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3253
        addAndAdaptSection(parentElement, section);
3254
        return section;
3255
    }
3256

    
3257
    /**
3258
     * @param formElement
3259
     * @param conversationHolder
3260
     * @param style
3261
     * @return
3262
     */
3263
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3264
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3265
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3266
        addAndAdaptSection(formElement, section);
3267
        return section;
3268
    }
3269

    
3270

    
3271
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3272
			ICdmFormElement parentElement, int style) {
3273
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3274
		addAndAdaptElement(parentElement, section);
3275
        return section;
3276
	}
3277

    
3278
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3279
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3280
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3281
	        addAndAdaptSection(formElement, section);
3282
	        return section;
3283
	}
3284

    
3285

    
3286
    /**
3287
     * <p>
3288
     * createTextWithLabelElement
3289
     * </p>
3290
     *
3291
     * @param parentElement
3292
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3293
     *            object.
3294
     * @param labelString
3295
     *            a {@link java.lang.String} object.
3296
     * @param initialText
3297
     *            a {@link java.lang.String} object.
3298
     * @param textLimit maximal number of characters allowed
3299
     * @param style
3300
     *            a int.
3301
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
3302
     *         object.
3303
     */
3304
    public RuleConsideredElement createRuleConsideredElement(ICdmFormElement parentElement, String labelString, boolean isShowCodeEdition, int style) {
3305
        RuleConsideredElement element = new RuleConsideredElement(this, parentElement, labelString, isShowCodeEdition, style);
3306
        adapt(element);
3307
        parentElement.addElement(element);
3308
        return element;
3309
    }
3310

    
3311

    
3312
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3313
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3314
//				 initialText, textHeight, style);
3315
//	        adapt(element);
3316
//	        parentElement.addElement(element);
3317
//	        return element;
3318
//	}
3319

    
3320

    
3321

    
3322

    
3323

    
3324

    
3325

    
3326
}
(7-7/49)