Project

General

Profile

Download (144 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 org.eclipse.jface.layout.GridDataFactory;
15
import org.eclipse.jface.util.IPropertyChangeListener;
16
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.jface.viewers.ISelectionProvider;
18
import org.eclipse.jface.window.Window;
19
import org.eclipse.nebula.widgets.richtext.RichTextEditor;
20
import org.eclipse.nebula.widgets.richtext.RichTextEditorConfiguration;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.custom.StyledText;
23
import org.eclipse.swt.events.FocusAdapter;
24
import org.eclipse.swt.events.FocusEvent;
25
import org.eclipse.swt.events.FocusListener;
26
import org.eclipse.swt.events.MouseAdapter;
27
import org.eclipse.swt.events.MouseEvent;
28
import org.eclipse.swt.events.MouseListener;
29
import org.eclipse.swt.events.SelectionEvent;
30
import org.eclipse.swt.events.SelectionListener;
31
import org.eclipse.swt.events.TypedEvent;
32
import org.eclipse.swt.graphics.Color;
33
import org.eclipse.swt.graphics.Font;
34
import org.eclipse.swt.widgets.Composite;
35
import org.eclipse.swt.widgets.Control;
36
import org.eclipse.swt.widgets.Display;
37
import org.eclipse.swt.widgets.Event;
38
import org.eclipse.swt.widgets.Label;
39
import org.eclipse.swt.widgets.Text;
40
import org.eclipse.ui.forms.IFormColors;
41
import org.eclipse.ui.forms.widgets.ExpandableComposite;
42
import org.eclipse.ui.forms.widgets.FormToolkit;
43
import org.eclipse.ui.forms.widgets.Section;
44
import org.eclipse.ui.forms.widgets.TableWrapData;
45

    
46
import org.eclipse.ui.internal.forms.widgets.FormFonts;
47
import org.joda.time.DateTime;
48
import org.joda.time.Partial;
49
import org.springframework.security.core.GrantedAuthority;
50

    
51
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
52
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
53
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
54
import eu.etaxonomy.cdm.model.agent.Person;
55
import eu.etaxonomy.cdm.model.agent.Team;
56
import eu.etaxonomy.cdm.model.common.Annotation;
57
import eu.etaxonomy.cdm.model.common.CdmBase;
58
import eu.etaxonomy.cdm.model.common.Credit;
59
import eu.etaxonomy.cdm.model.common.DefinedTerm;
60
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
61
import eu.etaxonomy.cdm.model.common.Extension;
62
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
63
import eu.etaxonomy.cdm.model.common.Group;
64
import eu.etaxonomy.cdm.model.common.ICdmBase;
65
import eu.etaxonomy.cdm.model.common.IEnumTerm;
66
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
67
import eu.etaxonomy.cdm.model.common.Identifier;
68
import eu.etaxonomy.cdm.model.common.IntextReference;
69
import eu.etaxonomy.cdm.model.common.LSID;
70
import eu.etaxonomy.cdm.model.common.Language;
71
import eu.etaxonomy.cdm.model.common.LanguageString;
72
import eu.etaxonomy.cdm.model.common.Marker;
73
import eu.etaxonomy.cdm.model.common.Representation;
74
import eu.etaxonomy.cdm.model.common.TermBase;
75
import eu.etaxonomy.cdm.model.common.TermType;
76
import eu.etaxonomy.cdm.model.common.TermVocabulary;
77
import eu.etaxonomy.cdm.model.common.TimePeriod;
78
import eu.etaxonomy.cdm.model.common.User;
79
import eu.etaxonomy.cdm.model.common.VersionableEntity;
80
import eu.etaxonomy.cdm.model.description.CategoricalData;
81
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
82
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
83
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
84
import eu.etaxonomy.cdm.model.description.Distribution;
85
import eu.etaxonomy.cdm.model.description.Feature;
86
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
87
import eu.etaxonomy.cdm.model.description.KeyStatement;
88
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
89
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
90
import eu.etaxonomy.cdm.model.description.QuantitativeData;
91
import eu.etaxonomy.cdm.model.description.State;
92
import eu.etaxonomy.cdm.model.description.StateData;
93
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
94
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
95
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
96
import eu.etaxonomy.cdm.model.description.TextData;
97
import eu.etaxonomy.cdm.model.location.NamedArea;
98
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
99
import eu.etaxonomy.cdm.model.location.Point;
100
import eu.etaxonomy.cdm.model.media.ImageFile;
101
import eu.etaxonomy.cdm.model.media.Media;
102
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
103
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
104
import eu.etaxonomy.cdm.model.media.Rights;
105
import eu.etaxonomy.cdm.model.molecular.DnaSample;
106
import eu.etaxonomy.cdm.model.name.NameRelationship;
107
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
108
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
109
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
110
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
111
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
112
import eu.etaxonomy.cdm.model.reference.Reference;
113
import eu.etaxonomy.cdm.model.taxon.Taxon;
114
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
115
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
116
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
117
import eu.etaxonomy.taxeditor.model.MessagingUtils;
118
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
119
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
120
import eu.etaxonomy.taxeditor.ui.combo.VocabularyComboElement;
121
import eu.etaxonomy.taxeditor.ui.dialog.CloneClassificationDetailElement;
122
import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection.UnitType;
123
import eu.etaxonomy.taxeditor.ui.mvc.element.DateElement;
124

    
125
import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
126
import eu.etaxonomy.taxeditor.ui.openurl.OpenUrlSelectorElement;
127
import eu.etaxonomy.taxeditor.ui.password.EditPasswordElement;
128
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
129
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
130
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
131
import eu.etaxonomy.taxeditor.ui.section.EmptyElement;
132
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement;
133
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection;
134
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailElement;
135
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
136
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailElement;
137
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
138
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
139
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberSection;
140
import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
141
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailElement;
142
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailSection;
143
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeAgentRelationCollectionElement;
144
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeAgentRelationCollectionSection;
145
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailElement;
146
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailSection;
147
import eu.etaxonomy.taxeditor.ui.section.common.ReferenceEntityDetailElement;
148
import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
149
import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
150
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
151
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailElement;
152
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
153
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
154
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
155
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
156
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceElement;
157
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
158
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceElement;
159
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
160
import eu.etaxonomy.taxeditor.ui.section.description.IntextReferenceDetailElement;
161
import eu.etaxonomy.taxeditor.ui.section.description.IntextReferenceSection;
162
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
163
import eu.etaxonomy.taxeditor.ui.section.description.ModifierElement;
164
import eu.etaxonomy.taxeditor.ui.section.description.ModifierSection;
165
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageDetailElement;
166
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
167
import eu.etaxonomy.taxeditor.ui.section.description.ScopeElement;
168
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
169
import eu.etaxonomy.taxeditor.ui.section.description.StateDataElement;
170
import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;
171
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueElement;
172
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueSection;
173
import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;
174
import eu.etaxonomy.taxeditor.ui.section.description.detail.CategoricalDataDetailElement;
175
import eu.etaxonomy.taxeditor.ui.section.description.detail.CommonNameDetailElement;
176
import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
177
import eu.etaxonomy.taxeditor.ui.section.description.detail.IndividualsAssociationDetailElement;
178
import eu.etaxonomy.taxeditor.ui.section.description.detail.QuantitativeDataDetailElement;
179
import eu.etaxonomy.taxeditor.ui.section.description.detail.TaxonInteractionDetailElement;
180
import eu.etaxonomy.taxeditor.ui.section.description.detail.TextDataDetailElement;
181
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement;
182
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
183
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityCollectionElement;
184
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailElement;
185
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
186
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailElement;
187
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
188
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailElement;
189
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
190
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailElement;
191
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
192
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailElement;
193
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
194
import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
195
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
196
import eu.etaxonomy.taxeditor.ui.section.media.ImageFileElement;
197
import eu.etaxonomy.taxeditor.ui.section.media.MediaDetailElement;
198
import eu.etaxonomy.taxeditor.ui.section.media.MediaMetaElement;
199
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationElement;
200
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartElement;
201
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartSection;
202
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationSection;
203
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
204
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
205
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailSection;
206
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailElement;
207
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailSection;
208
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailElement;
209
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailSection;
210
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailElement;
211
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
212
import eu.etaxonomy.taxeditor.ui.section.name.NameTypeDesignationElement;
213
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusElement;
214
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
215
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailElement;
216
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
217
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueElement;
218
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
219
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
220
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
221
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
222
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
223
import eu.etaxonomy.taxeditor.ui.section.occurrence.CurrentDeterminationDetailSection;
224
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailElement;
225
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
226
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailElement;
227
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
228
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement;
229
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
230
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement;
231
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection;
232
import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
233
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailElement;
234
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailSection;
235
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailElement;
236
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSection;
237
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailElement;
238
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
239
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopeDetailSection;
240
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopePolyKeyDetailSection;
241
import eu.etaxonomy.taxeditor.ui.section.occurrence.NamedAreaDetailElement;
242
import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
243
import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
244
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElement;
245
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailSection;
246
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenHierarchyDetailElement;
247
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenHierarchyDetailSection;
248
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationElement;
249
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationSection;
250
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailElement;
251
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
252
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenCurrentDeterminationDetailSection;
253
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailElement;
254
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailSection;
255
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailElement;
256
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailSection;
257
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenSourceCollectionDetailSection;
258
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractSampleDesignationDetailSection;
259
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailElement;
260
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailSection;
261
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoCollectionDetailSection;
262
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoDetailElement;
263
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailElement;
264
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailSection;
265
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailElement;
266
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailSection;
267
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.CurrentSampleDesignationDetailSection;
268
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailElement;
269
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
270
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailElement;
271
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
272
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationDetailElement;
273
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationSection;
274
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.PrimerGeneralDetailElement;
275
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailElement;
276
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailSection;
277
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationHistoryDetailSection;
278
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationTextDetailElement;
279
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceContigFileCollectionDetailSection;
280
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailElement;
281
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
282
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailElement;
283
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
284
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailElement;
285
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
286
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadPherogramCollectionDetailSection;
287
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailElement;
288
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
289
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailElement;
290
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
291
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
292
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
293
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement;
294
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
295
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationElement;
296
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
297
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseElement;
298
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
299
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditElement;
300
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
301
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionElement;
302
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
303
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
304
import eu.etaxonomy.taxeditor.ui.section.supplemental.IdentifiableSourceElement;
305
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerElement;
306
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
307
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsElement;
308
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
309
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
310
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement;
311
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
312
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.DerivedUnitFacadeIdentifierSection;
313
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierElement;
314
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierSection;
315
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement;
316
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
317
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailElement;
318
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
319
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailElement;
320
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailElement;
321
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
322
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailElement;
323
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
324
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailElement;
325
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
326
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailElement;
327
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
328
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement;
329
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailSection;
330
import eu.etaxonomy.taxeditor.ui.section.vocabulary.FeatureDetailElement;
331
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionElement;
332
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionSection;
333
import eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailSection;
334
import eu.etaxonomy.taxeditor.ui.section.vocabulary.PresenceAbsenceTermDetailElement;
335
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesCollectionSection;
336
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesElement;
337
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionElement;
338
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionSection;
339
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionElement;
340
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionSection;
341
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailElement;
342
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
343
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
344
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementWithAbbreviatedTitle;
345
import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
346
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
347

    
348
/**
349
 * <p>
350
 * CdmFormFactory class.
351
 * </p>
352
 *
353
 * @author n.hoffmann
354
 * @created Feb 24, 2010
355
 * @version 1.0
356
 */
357
public class CdmFormFactory extends FormToolkit {
358

    
359
    private BoldFontHolder2 boldFontHolder2;
360
    private MouseListener selectionMouseHandler;
361
    private FocusListener selectionFocusHandler;
362

    
363
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
364

    
365
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
366

    
367
    private final int orientation = Window.getDefaultOrientation();
368
    private ISelectionProvider selectionProvider;
369

    
370
    /** Constant <code>EMPTY_SELECTION</code> */
371
    public static ISelection EMPTY_SELECTION = new ISelection() {
372
        @Override
373
        public boolean isEmpty() {
374
            return true;
375
        }
376
    };
377

    
378
    /**
379
     *
380
     * @author n.hoffmann
381
     * @date Jan 25, 2010
382
     *
383
     */
384
    private class SelectionMouseHandler extends MouseAdapter {
385
        @Override
386
        public void mouseDown(MouseEvent e) {
387
            notifySelectionListeners(e);
388
        }
389
    }
390

    
391
    /**
392
     *
393
     * @author n.hoffmann
394
     * @date Jan 25, 2010
395
     *
396
     */
397
    private class SelectionFocusHandler extends FocusAdapter {
398
        @Override
399
        public void focusGained(FocusEvent e) {
400
            notifySelectionListeners(e);
401
        }
402
    }
403

    
404
    private void notifySelectionListeners(TypedEvent e) {
405
        Event event = new Event();
406
        event.widget = e.widget;
407
        SelectionEvent selectionEvent = new SelectionEvent(event);
408

    
409
        for (SelectionListener listener : selectionListenerList) {
410
            listener.widgetSelected(selectionEvent);
411
        }
412
    }
413

    
414
    /**
415
     * <p>
416
     * Constructor for CdmFormFactory.
417
     * </p>
418
     *
419
     * @param display
420
     *            a {@link org.eclipse.swt.widgets.Display} object.
421
     * @param selectionProvider
422
     *            a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
423
     */
424
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
425
        super(display);
426
        this.selectionProvider = selectionProvider;
427
        init();
428
    }
429

    
430
    /**
431
     * <p>
432
     * Constructor for CdmFormFactory.
433
     * </p>
434
     *
435
     * @param display
436
     *            a {@link org.eclipse.swt.widgets.Display} object.
437
     */
438
    public CdmFormFactory(Display display) {
439
        super(display);
440
        init();
441
    }
442

    
443
    /**
444
	 *
445
	 */
446
    private void init() {
447
        boldFontHolder2 = new BoldFontHolder2();
448
        selectionMouseHandler = new SelectionMouseHandler();
449
        selectionFocusHandler = new SelectionFocusHandler();
450
    }
451

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
780
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
781
                textLimit, style);
782
        adapt(element);
783
        parentElement.addElement(element);
784
        return element;
785
    }
786
    
787
    /**
788
	 * Creates a text as a part of the form.
789
	 *
790
	 * @param parent
791
	 *            the text parent
792
	 * @param value
793
	 *            the text initial value
794
	 * @param style
795
	 *            the text style
796
	 * @return the text widget
797
	 */
798
	public RichTextEditor createRichTextEditor(Composite parent, String value, int style) {
799
		RichTextEditorConfiguration config = new RichTextEditorConfiguration();
800
		config.setOption("allowedContent", Boolean.TRUE);
801
		RichTextEditor text = new RichTextEditor(parent, config, super.getBorderStyle() | style | orientation);
802
		
803
		if (value != null)
804
			text.setText(value);
805
		text.setForeground(getColors().getForeground());
806
		text.setBackground(getColors().getBackground());
807
		
808
		return text;
809
	}
810

    
811
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
812
            int textHeight, int style) {
813
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
814
        adapt(element);
815
        parentElement.addElement(element);
816
        return element;
817
    }
818

    
819
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
820
            LSID initialLsid, int style) {
821
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
822
        adapt(element);
823
        parentElement.addElement(element);
824
        return element;
825
    }
826

    
827
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
828
            URI initialUri, int style) {
829
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
830
        adapt(element);
831
        parentElement.addElement(element);
832
        return element;
833
    }
834

    
835
    /**
836
     * @param element
837
     * @param string
838
     * @param uri
839
     * @param style
840
     * @return
841
     */
842
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
843
            IOpenUrlEnabled openUrlEnabled, int style) {
844
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
845
                style);
846
        adapt(element);
847
        parentElement.addElement(element);
848
        return element;
849
    }
850

    
851
    /**
852
     *
853
     * @param parentElement
854
     * @param labelString
855
     * @param conversationEnabled
856
     * @param user
857
     * @param style
858
     * @return
859
     */
860
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
861
            ConversationHolder conversation, User user, int style) {
862
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
863
        adapt(element);
864
        parentElement.addElement(element);
865
        return element;
866
    }
867

    
868
    /**
869
     * <p>
870
     * createIntegerTextWithLabelElement
871
     * </p>
872
     *
873
     * @param parentElement
874
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
875
     *            object.
876
     * @param labelString
877
     *            a {@link java.lang.String} object.
878
     * @param initialInteger
879
     *            a {@link java.lang.Integer} object.
880
     * @param style
881
     *            a int.
882
     * @return a
883
     *         {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
884
     *         object.
885
     */
886
	public NumberWithLabelElement createNumberTextWithLabelElement(
887
			ICdmFormElement parentElement, String labelString,
888
			Number initialNumber, int style) {
889
		NumberWithLabelElement element = new NumberWithLabelElement(this,
890
				parentElement, labelString, initialNumber, style);
891
		adapt(element);
892
		parentElement.addElement(element);
893
		return element;
894
	}
895

    
896
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
897
            String labelString, LanguageString languageString, int style) {
898
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
899
    }
900

    
901
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
902
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
903
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
904
                languageString, height, isMultiLine, style);
905
        adapt(element);
906
        parentElement.addElement(element);
907
        return element;
908
    }
909
    public LanguageRichTextWithLabel createLanguageRichTextWithLabelElement(ICdmFormElement parentElement,
910
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
911
        LanguageRichTextWithLabel element = new LanguageRichTextWithLabel(this, parentElement, labelString,
912
                languageString, height, isMultiLine, style);
913
        adapt(element);
914
        parentElement.addElement(element);
915
        return element;
916
    }
917

    
918

    
919
    /**
920
     * <p>
921
     * createKeyValueViewerElement
922
     * </p>
923
     *
924
     * @param parentElement
925
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
926
     *            object.
927
     * @param keyHeading
928
     *            a {@link java.lang.String} object.
929
     * @param valueHeading
930
     *            a {@link java.lang.String} object.
931
     * @param map
932
     *            a {@link java.util.Map} object.
933
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
934
     *         object.
935
     */
936
    public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
937
            String valueHeading, Map<Object, Object> map) {
938
        KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
939
        adapt(element);
940
        parentElement.addElement(element);
941
        return element;
942
    }
943
    /**
944
     * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
945
     */
946
    @Deprecated
947
    public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
948
            ICdmFormElement parentElement, String labelString, T selection, int style) {
949
        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString, selection, true, style);
950
        adapt(element);
951
        parentElement.addElement(element);
952
        return element;
953
    }
954

    
955
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
956
            TermType termType,
957
            ICdmFormElement parentElement,
958
            String labelString,
959
            T selection,
960
            int style) {
961
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false);
962
    }
963

    
964
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
965
			TermType termType,
966
			ICdmFormElement parentElement,
967
			String labelString,
968
			T selection,
969
			boolean addEmptyElement,
970
			int style) {
971
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, false);
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, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel);
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, parentElement, labelString, selection, true, style, false);
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, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel);
1003
	}
1004

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1188
    private class BoldFontHolder2 {
1189
        private Font normalFont;
1190

    
1191
        private Font boldFont;
1192

    
1193
        public BoldFontHolder2() {
1194
        }
1195

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

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

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

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

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

    
1272
	/**
1273
	 * <p>
1274
	 * createGatheringEventUnitElement
1275
	 * </p>
1276
	 *
1277
	 * @param parentElement
1278
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1279
	 *            object.
1280
	 * @param labelString
1281
	 *            a {@link java.lang.String} object.
1282
	 * @param timePeriod
1283
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1284
	 * @param style
1285
	 *            a int.
1286
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1287
	 *         object.
1288
	 */
1289
	public GatheringEventUnitElement createGatheringEventUnitElement(
1290
			ICdmFormElement parentElement,
1291
			String labelString,
1292
			DerivedUnitFacade gatheringEvent,
1293
			MinMaxTextSection.UnitType unitType,
1294
			int style) {
1295
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1296
				parentElement,
1297
				labelString,
1298
				gatheringEvent,
1299
				unitType,
1300
				style);
1301
		adapt(element);
1302
		parentElement.addElement(element);
1303
		return element;
1304
	}
1305

    
1306
    /**
1307
     * <p>
1308
     * createPointElement
1309
     * </p>
1310
     *
1311
     * @param style
1312
     *            a int.
1313
     * @param parentElement
1314
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1315
     *            object.
1316
     * @param point
1317
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1318
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1319
     */
1320
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1321
        PointElement element = new PointElement(this, parentElement, point, style);
1322
        adapt(element);
1323
        parentElement.addElement(element);
1324
        return element;
1325
    }
1326

    
1327

    
1328

    
1329
    /**
1330
     * @param conversationHolder
1331
     * @param parent
1332
     * @param detailsViewer
1333
     * @param i
1334
     * @return
1335
     */
1336
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1337
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1338
        parentElement.addElement(section);
1339
        adapt(section);
1340
        return section;
1341
    }
1342

    
1343
    /**
1344
     * <p>
1345
     * createDateDetailSection
1346
     * </p>
1347
     *
1348
     * @param parentElement
1349
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1350
     *            object.
1351
     * @param style
1352
     *            a int.
1353
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1354
     *         object.
1355
     */
1356
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1357
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1358
        parentElement.addElement(section);
1359
        adapt(section);
1360
        return section;
1361
    }
1362

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

    
1383
    /**
1384
     * <p>
1385
     * createPartialElement
1386
     * </p>
1387
     *
1388
     * @param parentElement
1389
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1390
     *            object.
1391
     * @param labelString
1392
     *            a {@link java.lang.String} object.
1393
     * @param partial
1394
     *            a {@link org.joda.time.Partial} object.
1395
     * @param style
1396
     *            a int.
1397
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1398
     *         object.
1399
     */
1400
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1401
            int style) {
1402
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1403
        adapt(element);
1404
        parentElement.addElement(element);
1405
        return element;
1406
    }
1407

    
1408
    /**
1409
     * <p>
1410
     * addSelectionListener
1411
     * </p>
1412
     *
1413
     * @param listener
1414
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1415
     */
1416
    public void addSelectionListener(SelectionListener listener) {
1417
        selectionListenerList.add(listener);
1418
    }
1419

    
1420
    /**
1421
     * <p>
1422
     * removeSelectionListener
1423
     * </p>
1424
     *
1425
     * @param listener
1426
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1427
     */
1428
    public void removeSelectionListener(SelectionListener listener) {
1429
        if (listener == null) {
1430
            MessagingUtils.error(this.getClass(),
1431
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1432
        } else {
1433
            selectionListenerList.remove(listener);
1434
        }
1435
    }
1436

    
1437
    /**
1438
     * <p>
1439
     * addPropertyChangeListener
1440
     * </p>
1441
     *
1442
     * @param listener
1443
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1444
     *            object.
1445
     */
1446
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1447
        if (propertyChangeListeners.contains(listener)) {
1448
            return;
1449
        }
1450
        propertyChangeListeners.add(0, listener);
1451
    }
1452

    
1453
    /**
1454
     * <p>
1455
     * removePropertyChangeListener
1456
     * </p>
1457
     *
1458
     * @param listener
1459
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1460
     *            object.
1461
     */
1462
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1463
        propertyChangeListeners.remove(listener);
1464
    }
1465

    
1466
    /**
1467
     * @return the propertyChangeListeners
1468
     */
1469
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1470
        return propertyChangeListeners;
1471
    }
1472

    
1473
    /**
1474
     * <p>
1475
     * createHorizontalSeparator
1476
     * </p>
1477
     *
1478
     * @param parentElement
1479
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1480
     *            object.
1481
     * @param style
1482
     *            a int.
1483
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1484
     */
1485
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1486
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1487
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1488
        return separator;
1489
    }
1490

    
1491
    /**
1492
     * <p>
1493
     * createVersionElement
1494
     * </p>
1495
     *
1496
     * @param parentElement
1497
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1498
     *            object.
1499
     * @param entity
1500
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1501
     *            object.
1502
     * @param style
1503
     *            a int.
1504
     * @return a
1505
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1506
     *         object.
1507
     */
1508
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1509
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1510
        adapt(element);
1511
        parentElement.addElement(element);
1512
        return element;
1513
    }
1514

    
1515
    /**
1516
     * @param cdmBaseSection
1517
     * @param object
1518
     * @param style
1519
     * @return
1520
     */
1521
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1522
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1523
        adapt(element);
1524
        parentElement.addElement(element);
1525
        return element;
1526
    }
1527

    
1528
    /**
1529
     * <p>
1530
     * createVersionSection
1531
     * </p>
1532
     *
1533
     * @param parentElement
1534
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1535
     *            object.
1536
     * @param style
1537
     *            a int.
1538
     * @return a
1539
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1540
     *         object.
1541
     */
1542
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1543
        VersionSection section = new VersionSection(this, parentElement, style);
1544
        parentElement.addElement(section);
1545
        adapt(section);
1546
        return section;
1547
    }
1548

    
1549
    /**
1550
     * @param parent
1551
     * @param i
1552
     * @return
1553
     */
1554
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1555
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1556
        parentElement.addElement(section);
1557
        adapt(section);
1558
        return section;
1559
    }
1560

    
1561
    /**
1562
     * <p>
1563
     * createEmptyElement
1564
     * </p>
1565
     *
1566
     * @param parentElement
1567
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1568
     *            object.
1569
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1570
     */
1571
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1572
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1573
        adapt(element);
1574
        parentElement.addElement(element);
1575
        return element;
1576
    }
1577

    
1578
    /**
1579
     * <p>
1580
     * createHeadlineSection
1581
     * </p>
1582
     *
1583
     * @param parentElement
1584
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1585
     *            object.
1586
     * @return a
1587
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1588
     *         object.
1589
     */
1590
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1591
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1592
        parentElement.addElement(section);
1593
        adapt(section);
1594
        return section;
1595
    }
1596

    
1597
    /**
1598
     * <p>
1599
     * createParsingMessageElement
1600
     * </p>
1601
     *
1602
     * @param parentElement
1603
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1604
     *            object.
1605
     * @param parserProblem
1606
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1607
     *            object.
1608
     * @param style
1609
     *            a int.
1610
     * @return a
1611
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1612
     *         object.
1613
     */
1614
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1615
            ParserProblem parserProblem, int style) {
1616
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1617
        adapt(element);
1618
        parentElement.addElement(element);
1619
        return element;
1620
    }
1621

    
1622
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1623
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1624

    
1625
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1626
                selectionProvider, style);
1627

    
1628
        parentElement.addElement(section);
1629
        adapt(section);
1630
        return section;
1631

    
1632
    }
1633

    
1634
    /**
1635
     * @param definedTermClass
1636
     * @param formElement
1637
     * @param style
1638
     * @return
1639
     */
1640
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1641
            AbstractCdmDetailSection parentElement, int style) {
1642
        AbstractCdmDetailElement element = null;
1643

    
1644
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1645
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1646
        } else if (definedTermClass.equals(Feature.class)) {
1647
            element = new FeatureDetailElement(this, parentElement);
1648
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1649
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1650
        } else {
1651
            element = new DefinedTermDetailElement(this, parentElement);
1652
        }
1653

    
1654

    
1655
        adapt(element);
1656
        parentElement.addElement(element);
1657
        return element;
1658
    }
1659

    
1660

    
1661
    //--------DetailSections---------
1662
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1663
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1664
        addAndAdaptSection(parentElement, section);
1665
        return section;
1666
    }
1667

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

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

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

    
1686
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1687
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1688
        addAndAdaptSection(parentElement, section);
1689
        return section;
1690
    }
1691

    
1692
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1693
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1694
        addAndAdaptSection(parentElement, section);
1695
        return section;
1696
    }
1697

    
1698
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1699
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1700
        addAndAdaptSection(parentElement, section);
1701
        return section;
1702
    }
1703

    
1704
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1705
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1706
        addAndAdaptSection(parentElement, section);
1707
        return section;
1708
    }
1709

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

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

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

    
1728

    
1729

    
1730
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, boolean nameChoosable, int style){
1731
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, nameChoosable, style);
1732
        addAndAdaptSection(parentElement, section);
1733
        return section;
1734
    }
1735

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1874
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1875
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
1876
        addAndAdaptSection(parentElement, section);
1877
        return section;
1878
    }
1879

    
1880
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1881
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
1882
        addAndAdaptSection(parentElement, section);
1883
        return section;
1884
    }
1885

    
1886
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1887
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1888
        addAndAdaptSection(parentElement, section);
1889
        return section;
1890
    }
1891

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

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

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

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

    
1916
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1917
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1918
        addAndAdaptSection(parentElement, section);
1919
        return section;
1920
    }
1921

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

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

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

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

    
1946
    public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1947
        DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1948
        addAndAdaptSection(parentElement, section);
1949
        return section;
1950
    }
1951

    
1952
    public SampleDesignationDetailSection createSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1953
        SampleDesignationDetailSection section = new SampleDesignationDetailSection(this, conversation, parentElement, selectionProvider, style);
1954
        addAndAdaptSection(parentElement, section);
1955
        return section;
1956
    }
1957

    
1958
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1959
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1960
        addAndAdaptSection(parentElement, section);
1961
        return section;
1962
    }
1963

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

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

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

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

    
1988
    public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1989
        UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
1990
        addAndAdaptSection(parentElement, section);
1991
        return section;
1992
    }
1993

    
1994
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1995
        parentElement.addElement(section);
1996
        adapt(section);
1997
    }
1998

    
1999
    //--------DetailElements------------
2000

    
2001
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
2002
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
2003
        addAndAdaptElement(parentElement, element);
2004
        return element;
2005
    }
2006

    
2007
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
2008
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
2009
        addAndAdaptElement(parentElement, element);
2010
        return element;
2011
    }
2012

    
2013
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
2014
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
2015
        addAndAdaptElement(parentElement, element);
2016
        return element;
2017
    }
2018

    
2019
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
2020
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
2021
        addAndAdaptElement(parentElement, element);
2022
        return element;
2023
    }
2024

    
2025
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
2026
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
2027
        addAndAdaptElement(parentElement, element);
2028
        return element;
2029
    }
2030

    
2031
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
2032
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
2033
        addAndAdaptElement(parentElement, element);
2034
        return element;
2035
    }
2036

    
2037
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
2038
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2039
        addAndAdaptElement(parentElement, element);
2040
        return element;
2041
    }
2042

    
2043
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2044
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2045
        addAndAdaptElement(parentElement, element);
2046
        return element;
2047
    }
2048

    
2049
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2050
        UserDetailElement element = new UserDetailElement(this, parentElement);
2051
        addAndAdaptElement(parentElement, element);
2052
        return element;
2053
    }
2054

    
2055
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2056
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2057
        addAndAdaptElement(parentElement, element);
2058
        return element;
2059
    }
2060

    
2061
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2062
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2063
        addAndAdaptElement(parentElement, element);
2064
        return element;
2065
    }
2066

    
2067
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2068
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2069
        addAndAdaptElement(parentElement, element);
2070
        return element;
2071
    }
2072

    
2073
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2074
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2075
        addAndAdaptElement(parentElement, element);
2076
        return element;
2077
    }
2078

    
2079
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2080
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2081
        addAndAdaptElement(parentElement, element);
2082
        return element;
2083
    }
2084

    
2085
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2086
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2087
        adapt(element);
2088
        parentElement.addElement(element);
2089

    
2090
        return element;
2091
    }
2092

    
2093
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2094
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2095
        addAndAdaptElement(parentElement, element);
2096
        return element;
2097
    }
2098

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

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

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

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

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

    
2129
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2130
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2131
        addAndAdaptElement(parentElement, element);
2132
        return element;
2133
    }
2134

    
2135
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2136
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2137
        addAndAdaptElement(parentElement, element);
2138
        return element;
2139
    }
2140

    
2141
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2142
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2143
        addAndAdaptElement(parentElement, element);
2144
        return element;
2145
    }
2146

    
2147
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2148
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2149
        addAndAdaptElement(parentElement, element);
2150
        return element;
2151
    }
2152

    
2153
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2154
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2155
        addAndAdaptElement(parentElement, element);
2156
        return element;
2157
    }
2158

    
2159
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2160
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2161
        addAndAdaptElement(parentElement, element);
2162
        return element;
2163
    }
2164

    
2165
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2166
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2167
        addAndAdaptElement(parentElement, element);
2168
        return element;
2169
    }
2170

    
2171
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2172
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2173
        addAndAdaptElement(parentElement, element);
2174
        return element;
2175
    }
2176

    
2177
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2178
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2179
        addAndAdaptElement(parentElement, element);
2180
        return element;
2181
    }
2182

    
2183
//    public IntextReferenceDetailElement createIntextReferenceDetailElement(ICdmFormElement parentElement, LanguageStringWithLabelElement referencedElement, int style) {
2184
//    	IntextReferenceDetailElement element = new IntextReferenceDetailElement(this, parentElement, referencedElement, null, element, null, style);
2185
//         addAndAdaptElement(parentElement, element);
2186
//         return element;
2187
//	}
2188

    
2189

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

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

    
2202
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2203
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2204
        addAndAdaptElement(parentElement, element);
2205
        return element;
2206
    }
2207

    
2208
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2209
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2210
        addAndAdaptElement(parentElement, element);
2211
        return element;
2212
    }
2213

    
2214
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2215
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2216
        addAndAdaptElement(parentElement, element);
2217
        return element;
2218
    }
2219

    
2220
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2221
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2222
        addAndAdaptElement(parentElement, element);
2223
        return element;
2224
    }
2225

    
2226
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2227
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2228
        addAndAdaptElement(parentElement, element);
2229
        return element;
2230
    }
2231

    
2232
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2233
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2234
        addAndAdaptElement(parentElement, element);
2235
        return element;
2236
    }
2237

    
2238
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2239
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2240
        addAndAdaptElement(parentElement, element);
2241
        return element;
2242
    }
2243

    
2244
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2245
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2246
        addAndAdaptElement(parentElement, element);
2247
        return element;
2248
    }
2249

    
2250
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2251
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2252
        addAndAdaptElement(parentElement, element);
2253
        return element;
2254
    }
2255

    
2256
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2257
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2258
        addAndAdaptElement(parentElement, element);
2259
        return element;
2260
    }
2261

    
2262
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2263
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2264
        addAndAdaptElement(parentElement, element);
2265
        return element;
2266
    }
2267

    
2268
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2269
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2270
        addAndAdaptElement(parentElement, element);
2271
        return element;
2272
    }
2273

    
2274
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2275
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2276
        addAndAdaptElement(parentElement, element);
2277
        return element;
2278
    }
2279

    
2280
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2281
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2282
        addAndAdaptElement(parentElement, element);
2283
        return element;
2284
    }
2285

    
2286
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2287
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2288
        addAndAdaptElement(parentElement, mediaDetailElement);
2289
        return mediaDetailElement;
2290
    }
2291

    
2292
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2293
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2294
        addAndAdaptElement(parentElement, element);
2295
        return element;
2296
    }
2297

    
2298
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2299
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2300
        addAndAdaptElement(parentElement, element);
2301
        return element;
2302
    }
2303

    
2304
    public SpecimenHierarchyDetailElement createSpecimenHierarchyDetailElement(ICdmFormElement parentElement) {
2305
        SpecimenHierarchyDetailElement element = new SpecimenHierarchyDetailElement(this, parentElement);
2306
        addAndAdaptElement(parentElement, element);
2307
        return element;
2308
    }
2309

    
2310
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2311
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2312
        addAndAdaptElement(parentElement, element);
2313
        return element;
2314
    }
2315

    
2316
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2317
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2318
        addAndAdaptElement(parentElement, element);
2319
        return element;
2320
    }
2321

    
2322
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2323
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2324
        addAndAdaptElement(parentElement, element);
2325
        return element;
2326
    }
2327

    
2328
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2329
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2330
        addAndAdaptElement(parentElement, element);
2331
        return element;
2332
    }
2333

    
2334
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2335
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2336
        addAndAdaptElement(parentElement, element);
2337
        return element;
2338
    }
2339

    
2340
    /**
2341
     * @param parentElement
2342
     * @param element
2343
     */
2344
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2345
        adapt(element);
2346
        parentElement.addElement(element);
2347
    }
2348

    
2349
    //--------EntityCollectionSection----------
2350
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2351
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2352
        addAndAdaptSection(parentElement, section);
2353
        return section;
2354
    }
2355

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

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

    
2368
    public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2369
        DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2370
        addAndAdaptSection(parentElement, section);
2371
        return section;
2372
    }
2373
    
2374
    public IntextReferenceSection createIntextReferenceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2375
        IntextReferenceSection section = new IntextReferenceSection(this, conversation, parentElement, style);
2376
        addAndAdaptSection(parentElement, section);
2377
        return section;
2378
    }
2379

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

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

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

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

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

    
2410
    public MediaRepresentationPartSection createMediaRepresentationPartSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2411
        MediaRepresentationPartSection section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
2412
        addAndAdaptSection(parentElement, section);
2413
        return section;
2414
    }
2415

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2500
    public MeasurementUnitCollectionSection createMeasurementUnitCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2501
        MeasurementUnitCollectionSection section = new MeasurementUnitCollectionSection(this, conversation, parentElement, style);
2502
        addAndAdaptSection(parentElement, section);
2503
        return section;
2504
    }
2505

    
2506
    public StatisticalMeasureCollectionSection createStatisticalMeasureCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2507
        StatisticalMeasureCollectionSection section = new StatisticalMeasureCollectionSection(this, conversation, parentElement, style);
2508
        addAndAdaptSection(parentElement, section);
2509
        return section;
2510
    }
2511

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2620

    
2621
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2622
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2623
        AbstractEntityCollectionElement element = null;
2624

    
2625
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2626

    
2627
        if (entity instanceof Annotation) {
2628
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2629
        }else if (entity instanceof Person ) {
2630
            boolean isNomenclatural = false;
2631
            if (parentElement instanceof TeamMemberSection){
2632
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2633
            }
2634
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2635
        } else if (entity instanceof Credit) {
2636
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2637
        } else if (entity instanceof Extension) {
2638
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2639
        } else if (entity instanceof Marker) {
2640
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2641
        } else if (entity instanceof TaxonNodeAgentRelation) {
2642
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2643
        }else if (entity instanceof Media) {
2644
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2645
        } else if (entity instanceof MediaRepresentation) {
2646
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2647
                    style);
2648
        } else if (entity instanceof ImageFile) {
2649
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2650
        } else if (entity instanceof MediaRepresentationPart) {
2651
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2652
                    removeListener, style);
2653
        } else if (entity instanceof NomenclaturalStatus) {
2654
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2655
                    style);
2656
        } else if (entity instanceof Rights) {
2657
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2658
        } else if (entity instanceof DescriptionElementSource) {
2659
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2660
                    removeListener, style);
2661
        }else if (entity instanceof IntextReference) {
2662
        	if (parentElement instanceof IntextReferenceSection){
2663
        		ILanguageStringProvider langElement = ((IntextReferenceSection)parentElement).getlangStringElement();
2664
        		element = new IntextReferenceDetailElement(this, parentElement, langElement, (IntextReference) entity,removeListener, null,style);
2665
        	}
2666
           
2667
        } else if (entity instanceof TaxonNodeAgentRelation) {
2668
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2669
                    removeListener,backgroundColor, style);
2670
        }
2671
        else if (entity instanceof IdentifiableSource) {
2672
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2673
                    style);
2674
        } else if (entity instanceof DefinedTerm) {
2675
            switch(((DefinedTerm)entity).getTermType()) {
2676
            case Scope:
2677
                element = new ScopeElement(this,
2678
                        parentElement,
2679
                        (DefinedTerm) entity,
2680
                        removeListener,
2681
                        style);
2682
                break;
2683
            case Modifier:
2684
                element = new ModifierElement(this,
2685
                        parentElement,
2686
                        (DefinedTerm) entity,
2687
                        removeListener,
2688
                        style);
2689
                break;
2690
            default:
2691
                break;
2692

    
2693
            }
2694
        } else if (entity instanceof Reference) {
2695
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2696
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2697
            }
2698
            else{
2699
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2700
            }
2701
        } else if (entity instanceof NameTypeDesignation) {
2702
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2703
                    style);
2704
        } else if (entity instanceof NameRelationship) {
2705
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2706
                    style);
2707
        } else if (entity instanceof SpecimenTypeDesignation) {
2708
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
2709
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2710
                        removeListener, style);
2711
            }
2712
            else{
2713
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2714
                        removeListener, style);
2715
            }
2716
        } else if (entity instanceof StateData) {
2717
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2718
        } else if (entity instanceof StatisticalMeasurementValue) {
2719
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2720
                    removeListener, style);
2721
        } else if (entity instanceof DerivedUnit) {
2722
            switch(((DerivedUnit)entity).getRecordBasis()) {
2723
            case LivingSpecimen:
2724
            case PreservedSpecimen:
2725
            case OtherSpecimen:
2726
                element = new SpecimenCollectionDetailElement(this,
2727
                        parentElement,
2728
                        (DerivedUnit) entity,
2729
                        removeListener,
2730
                        style);
2731
                break;
2732
            default:
2733
                element = new DerivedUnitElement(this,
2734
                        parentElement,
2735
                        (DerivedUnit) entity,
2736
                        removeListener,
2737
                        style);
2738
            }
2739

    
2740
        } else if (entity instanceof NamedArea) {
2741
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2742
        } else if (entity instanceof DeterminationEvent) {
2743
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2744
        } else if (entity instanceof User) {
2745
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2746
        } else if (entity instanceof GrantedAuthority) {
2747
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
2748
                    removeListener, style);
2749
        } else if (entity instanceof Group) {
2750
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2751
        } else if (entity instanceof Taxon) {
2752
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2753
        } else if (entity instanceof DescriptionElementBase) {
2754
            // this is the special case for protologs, maybe we can do this
2755
            // differently when API improves
2756
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2757
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2758
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2759
            }
2760
        } else if (entity instanceof Identifier) {
2761
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2762
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2763
            }
2764
            else{
2765
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
2766
            }
2767
        } else if (entity instanceof TermVocabulary) {
2768
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
2769
            switch (termVocabulary.getTermType()) {
2770
            case State:
2771
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
2772
                break;
2773
            case Modifier:
2774
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
2775
                break;
2776
            default:
2777
                break;
2778
            }
2779
        } else if (entity instanceof MeasurementUnit) {
2780
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2781
        } else if (entity instanceof StatisticalMeasure) {
2782
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2783
        }
2784

    
2785
        //check for parent section when entity is null
2786
        //this happens when AbstractUnboundEntityCollectionSection is used
2787
        if(entity==null){
2788
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
2789
                element = new ScopeElement(this,
2790
                        parentElement,
2791
                        (DefinedTerm) entity,
2792
                        removeListener,
2793
                        style);
2794
            }
2795
            else if(parentElement instanceof ModifierSection){
2796
                element = new ModifierElement(this,
2797
                        parentElement,
2798
                        (DefinedTerm) entity,
2799
                        removeListener,
2800
                        style);
2801
            }
2802
        }
2803

    
2804

    
2805
        if (element == null) {
2806
            MessagingUtils.messageDialog("No element for entity", this,
2807
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2808
                            + entity, null);
2809
        }
2810

    
2811
        else{
2812
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2813
                element.setPersistentBackground(backgroundColor);
2814
            }
2815
            adapt(element);
2816
            parentElement.addElement(element);
2817
        }
2818

    
2819
        return element;
2820
    }
2821

    
2822
    /**
2823
     * <p>
2824
     * Creates a selection element for the given type T.
2825
     * </p>
2826
     * <p>
2827
     * <strong>Selection elements not handled by this method:</strong>
2828
     * <ul>
2829
     * <li>{@link TaxonNodeSelectionElement} see
2830
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2831
     * </li>
2832
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2833
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2834
     * </li>
2835
     * </ul>
2836
     * </p>
2837
     *
2838
     * @param clazz
2839
     *            a {@link Class} object of the type that you want the selection
2840
     *            element to handle
2841
     * @param parentElement
2842
     *            a {@link ICdmFormElement} object.
2843
     * @param labelString
2844
     *            a {@link String} object.
2845
     * @param selectionType
2846
     * @param selection
2847
     *            a {@link ICdmBase} object.
2848
     * @param style
2849
     *            a int.
2850
     * @param conversation
2851
     *            a {@link ConversationHolder} object.
2852
     * @return a {@link EntitySelectionElement} object.
2853
     */
2854
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2855
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2856
            int style, boolean filterElement) {
2857
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2858
                labelString, selection, mode, style, filterElement);
2859
        adapt(element);
2860
        parentElement.addElement(element);
2861
        return element;
2862
    }
2863

    
2864
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2865
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2866
            int style) {
2867
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2868
                labelString, selection, mode, style);
2869
        adapt(element);
2870
        parentElement.addElement(element);
2871
        return element;
2872
    }
2873

    
2874
    /**
2875
     * <p>
2876
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
2877
     * </p>
2878
     * <p>
2879
     * <strong>Selection elements not handled by this method:</strong>
2880
     * <ul>
2881
     * <li>{@link TaxonNodeSelectionElement} see
2882
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2883
     * </li>
2884
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2885
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2886
     * </li>
2887
     * </ul>
2888
     * </p>
2889
     *
2890
     * @param clazz
2891
     *            a {@link Class} object of the type that you want the selection
2892
     *            element to handle
2893
     * @param parentElement
2894
     *            a {@link ICdmFormElement} object.
2895
     * @param labelString
2896
     *            a {@link String} object.
2897
     * @param selectionType
2898
     * @param selection
2899
     *            a {@link ICdmBase} object.
2900
     * @param style
2901
     *            a int.
2902
     * @param conversation
2903
     *            a {@link ConversationHolder} object.
2904
     * @return a {@link EntitySelectionElement} object.
2905
     */
2906
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
2907
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
2908
            T selection, int mode, int style) {
2909
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, conversation, parentElement, clazz,
2910
                labelString, selection, mode, style);
2911
        adapt(element);
2912
        parentElement.addElement(element);
2913
        return element;
2914
    }
2915

    
2916
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2917
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2918
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2919
                labelString, selection, mode, style);
2920
        adapt(element);
2921
        parentElement.addElement(element);
2922
        return element;
2923
    }
2924

    
2925
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2926
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2927
//            int mode, int style) {
2928
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2929
//                conversation, parentElement, labelString, selection, mode, style);
2930
//        adapt(element);
2931
//        parentElement.addElement(element);
2932
//        return element;
2933
//    }
2934

    
2935
    /** {@inheritDoc} */
2936
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2937
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2938
        adapt(labelElement);
2939
        parentElement.addElement(labelElement);
2940
        return labelElement;
2941
    }
2942

    
2943
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2944
//        Label label = new Label(formElement.getLayoutComposite(), style);
2945
//        label.setText(labelText+" (yyyy-MM-dd)");
2946
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
2947
//        dateElement.initInternalController();
2948
//        
2949
//        return dateElement;
2950
//    }
2951
    
2952
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
2953
    	 Label label = new Label(formElement.getLayoutComposite(), style);
2954
         label.setText(labelText);
2955
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2956
         DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
2957
         dateElement.initController(this, formElement);
2958
         return dateElement;
2959
    }
2960

    
2961
    /**
2962
     * <p>
2963
     * Getter for the field <code>selectionProvider</code>.
2964
     * </p>
2965
     *
2966
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2967
     */
2968
    public ISelectionProvider getSelectionProvider() {
2969
        return selectionProvider;
2970
    }
2971

    
2972
    /**
2973
     * <p>
2974
     * createDetailedDescriptionDetailElement
2975
     * </p>
2976
     *
2977
     * @param parentElement
2978
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2979
     *            object.
2980
     * @param entity
2981
     *            a
2982
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2983
     *            object.
2984
     * @param style
2985
     *            a int.
2986
     * @return a
2987
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2988
     *         object.
2989
     */
2990
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2991
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2992
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2993

    
2994
        if (entity instanceof CategoricalData) {
2995
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2996
                    (CategoricalData) entity, style);
2997
        } else if (entity instanceof CommonTaxonName) {
2998
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2999
                    style);
3000
        } else if (entity instanceof Distribution) {
3001
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3002
                    style);
3003
        } else if (entity instanceof IndividualsAssociation) {
3004
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
3005
                    (IndividualsAssociation) entity, style);
3006
        } else if (entity instanceof QuantitativeData) {
3007
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
3008
                    (QuantitativeData) entity, style);
3009
        } else if (entity instanceof TaxonInteraction) {
3010
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
3011
                    (TaxonInteraction) entity, style);
3012
        } else if (entity instanceof TextData) {
3013
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
3014
        } else {
3015
            throw new IllegalStateException("There is no interface for the given description element");
3016
        }
3017
        adapt(detailedDescriptionElement);
3018
        parentElement.addElement(detailedDescriptionElement);
3019
        return detailedDescriptionElement;
3020

    
3021
    }
3022

    
3023
    /**
3024
     * Creates a styled text as a part of the form.
3025
     *
3026
     * @param parent
3027
     *            the text parent
3028
     * @param value
3029
     *            the text initial value
3030
     * @param style
3031
     *            the text style
3032
     * @return the text widget
3033
     */
3034
    public StyledText createStyledText(Composite parent, String value, int style) {
3035
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3036
        if (value != null) {
3037
            text.setText(value);
3038
        }
3039
        text.setForeground(getColors().getForeground());
3040
        text.setBackground(getColors().getBackground());
3041
        // text.addFocusListener(visibilityHandler);
3042
        return text;
3043
    }
3044

    
3045
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3046
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3047
        addAndAdaptSection(parentElement, section);
3048
        return section;
3049
    }
3050

    
3051
    /**
3052
     * @param formElement
3053
     * @param conversationHolder
3054
     * @param style
3055
     * @return
3056
     */
3057
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3058
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3059
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3060
        addAndAdaptSection(formElement, section);
3061
        return section;
3062
    }
3063

    
3064
	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, LanguageString initialText, int textHeight, int style) {
3065
		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3066
				 initialText, textHeight, 0, true, style);
3067
		
3068
	        adapt(element);
3069
	        parentElement.addElement(element);
3070
	        return element;
3071
	}
3072

    
3073
	
3074

    
3075

    
3076

    
3077

    
3078

    
3079
}
(7-7/47)