Project

General

Profile

Download (141 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.swt.SWT;
21
import org.eclipse.swt.custom.StyledText;
22
import org.eclipse.swt.events.FocusAdapter;
23
import org.eclipse.swt.events.FocusEvent;
24
import org.eclipse.swt.events.FocusListener;
25
import org.eclipse.swt.events.MouseAdapter;
26
import org.eclipse.swt.events.MouseEvent;
27
import org.eclipse.swt.events.MouseListener;
28
import org.eclipse.swt.events.SelectionEvent;
29
import org.eclipse.swt.events.SelectionListener;
30
import org.eclipse.swt.events.TypedEvent;
31
import org.eclipse.swt.graphics.Color;
32
import org.eclipse.swt.graphics.Font;
33
import org.eclipse.swt.widgets.Composite;
34
import org.eclipse.swt.widgets.Control;
35
import org.eclipse.swt.widgets.Display;
36
import org.eclipse.swt.widgets.Event;
37
import org.eclipse.swt.widgets.Label;
38
import org.eclipse.swt.widgets.Text;
39
import org.eclipse.ui.forms.IFormColors;
40
import org.eclipse.ui.forms.widgets.ExpandableComposite;
41
import org.eclipse.ui.forms.widgets.FormToolkit;
42
import org.eclipse.ui.forms.widgets.Section;
43
import org.eclipse.ui.internal.forms.widgets.FormFonts;
44
import org.joda.time.DateTime;
45
import org.joda.time.Partial;
46
import org.springframework.security.core.GrantedAuthority;
47

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

    
342
/**
343
 * <p>
344
 * CdmFormFactory class.
345
 * </p>
346
 *
347
 * @author n.hoffmann
348
 * @created Feb 24, 2010
349
 * @version 1.0
350
 */
351
public class CdmFormFactory extends FormToolkit {
352

    
353
    private BoldFontHolder2 boldFontHolder2;
354
    private MouseListener selectionMouseHandler;
355
    private FocusListener selectionFocusHandler;
356

    
357
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
358

    
359
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
360

    
361
    private final int orientation = Window.getDefaultOrientation();
362
    private ISelectionProvider selectionProvider;
363

    
364
    /** Constant <code>EMPTY_SELECTION</code> */
365
    public static ISelection EMPTY_SELECTION = new ISelection() {
366
        @Override
367
        public boolean isEmpty() {
368
            return true;
369
        }
370
    };
371

    
372
    /**
373
     *
374
     * @author n.hoffmann
375
     * @date Jan 25, 2010
376
     *
377
     */
378
    private class SelectionMouseHandler extends MouseAdapter {
379
        @Override
380
        public void mouseDown(MouseEvent e) {
381
            notifySelectionListeners(e);
382
        }
383
    }
384

    
385
    /**
386
     *
387
     * @author n.hoffmann
388
     * @date Jan 25, 2010
389
     *
390
     */
391
    private class SelectionFocusHandler extends FocusAdapter {
392
        @Override
393
        public void focusGained(FocusEvent e) {
394
            notifySelectionListeners(e);
395
        }
396
    }
397

    
398
    private void notifySelectionListeners(TypedEvent e) {
399
        Event event = new Event();
400
        event.widget = e.widget;
401
        SelectionEvent selectionEvent = new SelectionEvent(event);
402

    
403
        for (SelectionListener listener : selectionListenerList) {
404
            listener.widgetSelected(selectionEvent);
405
        }
406
    }
407

    
408
    /**
409
     * <p>
410
     * Constructor for CdmFormFactory.
411
     * </p>
412
     *
413
     * @param display
414
     *            a {@link org.eclipse.swt.widgets.Display} object.
415
     * @param selectionProvider
416
     *            a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
417
     */
418
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
419
        super(display);
420
        this.selectionProvider = selectionProvider;
421
        init();
422
    }
423

    
424
    /**
425
     * <p>
426
     * Constructor for CdmFormFactory.
427
     * </p>
428
     *
429
     * @param display
430
     *            a {@link org.eclipse.swt.widgets.Display} object.
431
     */
432
    public CdmFormFactory(Display display) {
433
        super(display);
434
        init();
435
    }
436

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

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

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

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

    
501
    /** {@inheritDoc} */
502
    @Override
503
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
504
        if (trackFocus) {
505
            control.addFocusListener(selectionFocusHandler);
506
        }
507
        super.adapt(control, trackFocus, trackKeyboard);
508
    }
509

    
510
    /** {@inheritDoc} */
511
    @Override
512
    public void adapt(Composite composite) {
513
        composite.addMouseListener(selectionMouseHandler);
514
       
515
        super.adapt(composite);
516
    }
517

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

    
559
    /**
560
     * <p>
561
     * createEmptyCell
562
     * </p>
563
     *
564
     * @param parent
565
     *            a {@link org.eclipse.swt.widgets.Composite} object.
566
     * @return a {@link org.eclipse.swt.widgets.Label} object.
567
     */
568
    public Label createEmptyCell(Composite parent) {
569
        return this.createLabel(parent, null);
570
    }
571

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

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

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

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

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

    
705
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
706
            KeyStatement keyStatement, int textHeight, int style) {
707
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
708
                textHeight, style);
709
        adapt(element);
710
        parentElement.addElement(element);
711
        return element;
712
    }
713

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

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

    
774
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
775
                textLimit, style);
776
        adapt(element);
777
        parentElement.addElement(element);
778
        return element;
779
    }
780

    
781
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
782
            int textHeight, int style) {
783
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
784
        adapt(element);
785
        parentElement.addElement(element);
786
        return element;
787
    }
788

    
789
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
790
            LSID initialLsid, int style) {
791
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
792
        adapt(element);
793
        parentElement.addElement(element);
794
        return element;
795
    }
796

    
797
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
798
            URI initialUri, int style) {
799
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
800
        adapt(element);
801
        parentElement.addElement(element);
802
        return element;
803
    }
804

    
805
    /**
806
     * @param element
807
     * @param string
808
     * @param uri
809
     * @param style
810
     * @return
811
     */
812
    public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
813
            IOpenUrlEnabled openUrlEnabled, int style) {
814
        OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
815
                style);
816
        adapt(element);
817
        parentElement.addElement(element);
818
        return element;
819
    }
820

    
821
    /**
822
     *
823
     * @param parentElement
824
     * @param labelString
825
     * @param conversationEnabled
826
     * @param user
827
     * @param style
828
     * @return
829
     */
830
    public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
831
            ConversationHolder conversation, User user, int style) {
832
        EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
833
        adapt(element);
834
        parentElement.addElement(element);
835
        return element;
836
    }
837

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

    
866
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
867
            String labelString, LanguageString languageString, int style) {
868
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
869
    }
870

    
871
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
872
            String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
873
        LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
874
                languageString, height, isMultiLine, style);
875
        adapt(element);
876
        parentElement.addElement(element);
877
        return element;
878
    }
879

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

    
916
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
917
            TermType termType,
918
            ICdmFormElement parentElement,
919
            String labelString,
920
            T selection,
921
            int style) {
922
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false);
923
    }
924

    
925
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
926
			TermType termType,
927
			ICdmFormElement parentElement,
928
			String labelString,
929
			T selection,
930
			boolean addEmptyElement,
931
			int style) {
932
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, false);
933
	}
934
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
935
			TermType termType,
936
			ICdmFormElement parentElement,
937
			String labelString,
938
			T selection,
939
			boolean addEmptyElement,
940
			int style,
941
			boolean useAbbrevLabel) {
942
		return createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel);
943
	}
944

    
945

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

    
955
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
956
	        TermVocabulary<?> termVocabulary,
957
	        ICdmFormElement parentElement,
958
	        String labelString,
959
	        T selection,
960
	        boolean addEmptyElement,
961
	        int style,
962
	        boolean useAbbrevLabel) {
963
	    return createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel);
964
	}
965

    
966
	private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
967
	        TermType termType,
968
	        TermVocabulary<?> termVocabulary,
969
	        ICdmFormElement parentElement,
970
	        String labelString,
971
	        T selection,
972
	        boolean addEmptyElement,
973
	        int style,
974
	        boolean useAbbrevLabel) {
975
	    if(termType!=null){
976
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel);
977
	        adapt(element);
978
	        parentElement.addElement(element);
979
	        return element;
980
	    }
981
	    else if(termVocabulary!=null){
982
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style, useAbbrevLabel);
983
	        adapt(element);
984
	        parentElement.addElement(element);
985
	        return element;
986
	    }
987
	    else{
988
	        //this should never happen
989
	        return null;
990
	    }
991
	}
992

    
993
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
994
	        Class<T> enumComboType, ICdmFormElement parentElement,
995
	        int style) {
996
	    return createEnumComboElement(enumComboType, parentElement, null, style);
997
	}
998

    
999
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1000
			Class<T> enumComboType, ICdmFormElement parentElement, Comparator<T> comparator,
1001
			int style) {
1002
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, comparator, style);
1003
        adapt(element);
1004
        parentElement.addElement(element);
1005
        return element;
1006
    }
1007

    
1008
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
1009
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
1010
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1011
	    adapt(element);
1012
	    parentElement.addElement(element);
1013
	    return element;
1014
	}
1015

    
1016
    /**
1017
     * <p>
1018
     * createBrowserElement
1019
     * </p>
1020
     *
1021
     * @param imageUri
1022
     *            a {@link java.net.URI} object.
1023
     * @param style
1024
     *            a int.
1025
     * @param parentElement
1026
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1027
     *            object.
1028
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
1029
     *         object.
1030
     */
1031
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
1032
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
1033
        adapt(element);
1034
        parentElement.addElement(element);
1035
        return element;
1036
    }
1037

    
1038
    /**
1039
     * <p>
1040
     * createImageElement
1041
     * </p>
1042
     *
1043
     * @param parentElement
1044
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1045
     *            object.
1046
     * @param imageUri
1047
     *            a {@link java.net.URI} object.
1048
     * @param style
1049
     *            a int.
1050
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1051
     */
1052
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1053
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1054
        adapt(element);
1055
        parentElement.addElement(element);
1056
        return element;
1057
    }
1058

    
1059
    /**
1060
     * <p>
1061
     * createTextActionElement
1062
     * </p>
1063
     *
1064
     * @param labelString
1065
     *            a {@link java.lang.String} object.
1066
     * @param initialText
1067
     *            a {@link java.lang.String} object.
1068
     * @param style
1069
     *            a int.
1070
     * @param parentElement
1071
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1072
     *            object.
1073
     * @param buttonLabel
1074
     *            a {@link java.lang.String} object.
1075
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
1076
     *         object.
1077
     */
1078
    public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
1079
            String buttonLabel, String initialText, int style) {
1080
        TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
1081
                style);
1082
        adapt(element);
1083
        parentElement.addElement(element);
1084
        return element;
1085
    }
1086

    
1087
    /**
1088
     * <p>
1089
     * createCheckbox
1090
     * </p>
1091
     *
1092
     * @param parentElement
1093
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1094
     *            object.
1095
     * @param label
1096
     *            a {@link java.lang.String} object.
1097
     * @param initialState
1098
     *            a boolean.
1099
     * @param style
1100
     *            a int.
1101
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
1102
     *         object.
1103
     */
1104
    public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
1105
        if(initialState==null){
1106
            initialState = Boolean.FALSE;
1107
        }
1108
        CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1109
        adapt(element);
1110
        parentElement.addElement(element);
1111
        return element;
1112
    }
1113

    
1114
    /**
1115
     * Creates a section as a part of the form.
1116
     *
1117
     * @return the section widget
1118
     * @param section
1119
     *            a
1120
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1121
     *            object.
1122
     */
1123
    public Section adapt(AbstractFormSection section) {
1124
        section.setMenu(section.getLayoutComposite().getMenu());
1125
        adapt(section, true, true);
1126

    
1127
        // handle focus and property change events for cdm use
1128
        section.addFocusListener(selectionFocusHandler);
1129
        section.setPropertyChangeListeners(propertyChangeListeners);
1130

    
1131
        if (section.getToggle() != null) {
1132
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1133
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1134
        }
1135

    
1136
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1137

    
1138
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1139
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1140
            getColors().initializeSectionToolBarColors();
1141
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1142
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1143
        }
1144
        // call setTitleBarForeground regardless as it also sets the label color
1145
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1146
        return section;
1147
    }
1148

    
1149
    private class BoldFontHolder2 {
1150
        private Font normalFont;
1151

    
1152
        private Font boldFont;
1153

    
1154
        public BoldFontHolder2() {
1155
        }
1156

    
1157
        public Font getBoldFont(Font font) {
1158
            createBoldFont(font);
1159
            return boldFont;
1160
        }
1161

    
1162
        private void createBoldFont(Font font) {
1163
            if (normalFont == null || !normalFont.equals(font)) {
1164
                normalFont = font;
1165
                dispose();
1166
            }
1167
            if (boldFont == null) {
1168
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1169
            }
1170
        }
1171

    
1172
        public void dispose() {
1173
            if (boldFont != null) {
1174
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1175
                boldFont = null;
1176
            }
1177
        }
1178
    }
1179

    
1180
    /**
1181
     * <p>
1182
     * createToggleableTextField
1183
     * </p>
1184
     *
1185
     * @param parentElement
1186
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1187
     *            object.
1188
     * @param labelString
1189
     *            a {@link java.lang.String} object.
1190
     * @param initialText
1191
     *            a {@link java.lang.String} object.
1192
     * @param initialState
1193
     *            a boolean.
1194
     * @param style
1195
     *            a int.
1196
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1197
     *         object.
1198
     */
1199
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1200
            String initialText, boolean initialState, int style) {
1201
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1202
                initialState, style | orientation);
1203
        adapt(element);
1204
        parentElement.addElement(element);
1205
        return element;
1206
    }
1207

    
1208
    /**
1209
     * <p>
1210
     * createTimePeriodElement
1211
     * </p>
1212
     *
1213
     * @param parentElement
1214
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1215
     *            object.
1216
     * @param labelString
1217
     *            a {@link java.lang.String} object.
1218
     * @param timePeriod
1219
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1220
     * @param style
1221
     *            a int.
1222
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1223
     *         object.
1224
     */
1225
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1226
            TimePeriod timePeriod, int style) {
1227
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1228
        adapt(element);
1229
        parentElement.addElement(element);
1230
        return element;
1231
    }
1232

    
1233
	/**
1234
	 * <p>
1235
	 * createGatheringEventUnitElement
1236
	 * </p>
1237
	 *
1238
	 * @param parentElement
1239
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1240
	 *            object.
1241
	 * @param labelString
1242
	 *            a {@link java.lang.String} object.
1243
	 * @param timePeriod
1244
	 *            a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1245
	 * @param style
1246
	 *            a int.
1247
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1248
	 *         object.
1249
	 */
1250
	public GatheringEventUnitElement createGatheringEventUnitElement(
1251
			ICdmFormElement parentElement,
1252
			String labelString,
1253
			DerivedUnitFacade gatheringEvent,
1254
			MinMaxTextSection.UnitType unitType,
1255
			int style) {
1256
		GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1257
				parentElement,
1258
				labelString,
1259
				gatheringEvent,
1260
				unitType,
1261
				style);
1262
		adapt(element);
1263
		parentElement.addElement(element);
1264
		return element;
1265
	}
1266

    
1267
    /**
1268
     * <p>
1269
     * createPointElement
1270
     * </p>
1271
     *
1272
     * @param style
1273
     *            a int.
1274
     * @param parentElement
1275
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1276
     *            object.
1277
     * @param point
1278
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1279
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1280
     */
1281
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1282
        PointElement element = new PointElement(this, parentElement, point, style);
1283
        adapt(element);
1284
        parentElement.addElement(element);
1285
        return element;
1286
    }
1287

    
1288

    
1289

    
1290
    /**
1291
     * @param conversationHolder
1292
     * @param parent
1293
     * @param detailsViewer
1294
     * @param i
1295
     * @return
1296
     */
1297
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1298
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1299
        parentElement.addElement(section);
1300
        adapt(section);
1301
        return section;
1302
    }
1303

    
1304
    /**
1305
     * <p>
1306
     * createDateDetailSection
1307
     * </p>
1308
     *
1309
     * @param parentElement
1310
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1311
     *            object.
1312
     * @param style
1313
     *            a int.
1314
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1315
     *         object.
1316
     */
1317
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1318
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1319
        parentElement.addElement(section);
1320
        adapt(section);
1321
        return section;
1322
    }
1323

    
1324
	/**
1325
	 * <p>
1326
	 * createDateDetailSection
1327
	 * </p>
1328
	 *
1329
	 * @param parentElement
1330
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1331
	 *            object.
1332
	 * @param style
1333
	 *            a int.
1334
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1335
	 *         object.
1336
	 */
1337
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1338
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1339
		parentElement.addElement(section);
1340
		adapt(section);
1341
		return section;
1342
	}
1343

    
1344
    /**
1345
     * <p>
1346
     * createPartialElement
1347
     * </p>
1348
     *
1349
     * @param parentElement
1350
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1351
     *            object.
1352
     * @param labelString
1353
     *            a {@link java.lang.String} object.
1354
     * @param partial
1355
     *            a {@link org.joda.time.Partial} object.
1356
     * @param style
1357
     *            a int.
1358
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1359
     *         object.
1360
     */
1361
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1362
            int style) {
1363
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1364
        adapt(element);
1365
        parentElement.addElement(element);
1366
        return element;
1367
    }
1368

    
1369
    /**
1370
     * <p>
1371
     * addSelectionListener
1372
     * </p>
1373
     *
1374
     * @param listener
1375
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1376
     */
1377
    public void addSelectionListener(SelectionListener listener) {
1378
        selectionListenerList.add(listener);
1379
    }
1380

    
1381
    /**
1382
     * <p>
1383
     * removeSelectionListener
1384
     * </p>
1385
     *
1386
     * @param listener
1387
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1388
     */
1389
    public void removeSelectionListener(SelectionListener listener) {
1390
        if (listener == null) {
1391
            MessagingUtils.error(this.getClass(),
1392
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1393
        } else {
1394
            selectionListenerList.remove(listener);
1395
        }
1396
    }
1397

    
1398
    /**
1399
     * <p>
1400
     * addPropertyChangeListener
1401
     * </p>
1402
     *
1403
     * @param listener
1404
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1405
     *            object.
1406
     */
1407
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1408
        if (propertyChangeListeners.contains(listener)) {
1409
            return;
1410
        }
1411
        propertyChangeListeners.add(0, listener);
1412
    }
1413

    
1414
    /**
1415
     * <p>
1416
     * removePropertyChangeListener
1417
     * </p>
1418
     *
1419
     * @param listener
1420
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1421
     *            object.
1422
     */
1423
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1424
        propertyChangeListeners.remove(listener);
1425
    }
1426

    
1427
    /**
1428
     * @return the propertyChangeListeners
1429
     */
1430
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1431
        return propertyChangeListeners;
1432
    }
1433

    
1434
    /**
1435
     * <p>
1436
     * createHorizontalSeparator
1437
     * </p>
1438
     *
1439
     * @param parentElement
1440
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1441
     *            object.
1442
     * @param style
1443
     *            a int.
1444
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1445
     */
1446
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1447
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1448
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1449
        return separator;
1450
    }
1451

    
1452
    /**
1453
     * <p>
1454
     * createVersionElement
1455
     * </p>
1456
     *
1457
     * @param parentElement
1458
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1459
     *            object.
1460
     * @param entity
1461
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1462
     *            object.
1463
     * @param style
1464
     *            a int.
1465
     * @return a
1466
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1467
     *         object.
1468
     */
1469
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1470
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1471
        adapt(element);
1472
        parentElement.addElement(element);
1473
        return element;
1474
    }
1475

    
1476
    /**
1477
     * @param cdmBaseSection
1478
     * @param object
1479
     * @param style
1480
     * @return
1481
     */
1482
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1483
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1484
        adapt(element);
1485
        parentElement.addElement(element);
1486
        return element;
1487
    }
1488

    
1489
    /**
1490
     * <p>
1491
     * createVersionSection
1492
     * </p>
1493
     *
1494
     * @param parentElement
1495
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1496
     *            object.
1497
     * @param style
1498
     *            a int.
1499
     * @return a
1500
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1501
     *         object.
1502
     */
1503
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1504
        VersionSection section = new VersionSection(this, parentElement, style);
1505
        parentElement.addElement(section);
1506
        adapt(section);
1507
        return section;
1508
    }
1509

    
1510
    /**
1511
     * @param parent
1512
     * @param i
1513
     * @return
1514
     */
1515
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1516
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1517
        parentElement.addElement(section);
1518
        adapt(section);
1519
        return section;
1520
    }
1521

    
1522
    /**
1523
     * <p>
1524
     * createEmptyElement
1525
     * </p>
1526
     *
1527
     * @param parentElement
1528
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1529
     *            object.
1530
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1531
     */
1532
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1533
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1534
        adapt(element);
1535
        parentElement.addElement(element);
1536
        return element;
1537
    }
1538

    
1539
    /**
1540
     * <p>
1541
     * createHeadlineSection
1542
     * </p>
1543
     *
1544
     * @param parentElement
1545
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1546
     *            object.
1547
     * @return a
1548
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1549
     *         object.
1550
     */
1551
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1552
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1553
        parentElement.addElement(section);
1554
        adapt(section);
1555
        return section;
1556
    }
1557

    
1558
    /**
1559
     * <p>
1560
     * createParsingMessageElement
1561
     * </p>
1562
     *
1563
     * @param parentElement
1564
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1565
     *            object.
1566
     * @param parserProblem
1567
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1568
     *            object.
1569
     * @param style
1570
     *            a int.
1571
     * @return a
1572
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1573
     *         object.
1574
     */
1575
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1576
            ParserProblem parserProblem, int style) {
1577
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1578
        adapt(element);
1579
        parentElement.addElement(element);
1580
        return element;
1581
    }
1582

    
1583
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1584
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1585

    
1586
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1587
                selectionProvider, style);
1588

    
1589
        parentElement.addElement(section);
1590
        adapt(section);
1591
        return section;
1592

    
1593
    }
1594

    
1595
    /**
1596
     * @param definedTermClass
1597
     * @param formElement
1598
     * @param style
1599
     * @return
1600
     */
1601
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1602
            AbstractCdmDetailSection parentElement, int style) {
1603
        AbstractCdmDetailElement element = null;
1604

    
1605
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1606
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1607
        } else if (definedTermClass.equals(Feature.class)) {
1608
            element = new FeatureDetailElement(this, parentElement);
1609
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1610
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1611
        } else {
1612
            element = new DefinedTermDetailElement(this, parentElement);
1613
        }
1614

    
1615

    
1616
        adapt(element);
1617
        parentElement.addElement(element);
1618
        return element;
1619
    }
1620

    
1621

    
1622
    //--------DetailSections---------
1623
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1624
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1625
        addAndAdaptSection(parentElement, section);
1626
        return section;
1627
    }
1628

    
1629
    public ReferenceDetailSection createReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1630
        ReferenceDetailSection section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1631
        addAndAdaptSection(parentElement, section);
1632
        return section;
1633
    }
1634

    
1635
    public NomenclaturalReferenceDetailSection createNomenclaturalReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1636
        NomenclaturalReferenceDetailSection section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1637
        addAndAdaptSection(parentElement, section);
1638
        return section;
1639
    }
1640

    
1641
    public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1642
        TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1643
        addAndAdaptSection(parentElement, section);
1644
        return section;
1645
    }
1646

    
1647
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1648
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1649
        addAndAdaptSection(parentElement, section);
1650
        return section;
1651
    }
1652

    
1653
    public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1654
        TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1655
        addAndAdaptSection(parentElement, section);
1656
        return section;
1657
    }
1658

    
1659
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1660
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1661
        addAndAdaptSection(parentElement, section);
1662
        return section;
1663
    }
1664

    
1665
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1666
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1667
        addAndAdaptSection(parentElement, section);
1668
        return section;
1669
    }
1670

    
1671
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1672
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1673
        addAndAdaptSection(parentElement, section);
1674
        return section;
1675
    }
1676

    
1677
    public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1678
        DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1679
        addAndAdaptSection(parentElement, section);
1680
        return section;
1681
    }
1682

    
1683
    public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1684
        ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1685
        addAndAdaptSection(parentElement, section);
1686
        return section;
1687
    }
1688

    
1689

    
1690

    
1691
    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, boolean nameChoosable, int style){
1692
        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, nameChoosable, style);
1693
        addAndAdaptSection(parentElement, section);
1694
        return section;
1695
    }
1696

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1835
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1836
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
1837
        addAndAdaptSection(parentElement, section);
1838
        return section;
1839
    }
1840

    
1841
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1842
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
1843
        addAndAdaptSection(parentElement, section);
1844
        return section;
1845
    }
1846

    
1847
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1848
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1849
        addAndAdaptSection(parentElement, section);
1850
        return section;
1851
    }
1852

    
1853
    public SingleReadGeneralDetailSection createSingleReadGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1854
        SingleReadGeneralDetailSection section = new SingleReadGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1855
        addAndAdaptSection(parentElement, section);
1856
        return section;
1857
    }
1858

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

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

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

    
1877
    public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1878
        AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1879
        addAndAdaptSection(parentElement, section);
1880
        return section;
1881
    }
1882

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

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

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

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

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

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

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

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

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

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

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

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

    
1955
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1956
        parentElement.addElement(section);
1957
        adapt(section);
1958
    }
1959

    
1960
    //--------DetailElements------------
1961

    
1962
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1963
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1964
        addAndAdaptElement(parentElement, element);
1965
        return element;
1966
    }
1967

    
1968
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1969
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1970
        addAndAdaptElement(parentElement, element);
1971
        return element;
1972
    }
1973

    
1974
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1975
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1976
        addAndAdaptElement(parentElement, element);
1977
        return element;
1978
    }
1979

    
1980
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1981
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1982
        addAndAdaptElement(parentElement, element);
1983
        return element;
1984
    }
1985

    
1986
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1987
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1988
        addAndAdaptElement(parentElement, element);
1989
        return element;
1990
    }
1991

    
1992
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1993
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1994
        addAndAdaptElement(parentElement, element);
1995
        return element;
1996
    }
1997

    
1998
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1999
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2000
        addAndAdaptElement(parentElement, element);
2001
        return element;
2002
    }
2003

    
2004
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2005
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2006
        addAndAdaptElement(parentElement, element);
2007
        return element;
2008
    }
2009

    
2010
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2011
        UserDetailElement element = new UserDetailElement(this, parentElement);
2012
        addAndAdaptElement(parentElement, element);
2013
        return element;
2014
    }
2015

    
2016
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2017
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2018
        addAndAdaptElement(parentElement, element);
2019
        return element;
2020
    }
2021

    
2022
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2023
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2024
        addAndAdaptElement(parentElement, element);
2025
        return element;
2026
    }
2027

    
2028
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2029
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2030
        addAndAdaptElement(parentElement, element);
2031
        return element;
2032
    }
2033

    
2034
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2035
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2036
        addAndAdaptElement(parentElement, element);
2037
        return element;
2038
    }
2039

    
2040
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2041
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2042
        addAndAdaptElement(parentElement, element);
2043
        return element;
2044
    }
2045

    
2046
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2047
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2048
        adapt(element);
2049
        parentElement.addElement(element);
2050

    
2051
        return element;
2052
    }
2053

    
2054
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2055
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2056
        addAndAdaptElement(parentElement, element);
2057
        return element;
2058
    }
2059

    
2060
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
2061
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
2062
        addAndAdaptElement(parentElement, element);
2063
        return element;
2064
    }
2065

    
2066
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2067
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2068
        addAndAdaptElement(parentElement, element);
2069
        return element;
2070
    }
2071

    
2072
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2073
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2074
        addAndAdaptElement(parentElement, element);
2075
        return element;
2076
    }
2077

    
2078
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2079
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2080
        addAndAdaptElement(parentElement, element);
2081
        return element;
2082
    }
2083

    
2084
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2085
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2086
        addAndAdaptElement(parentElement, element);
2087
        return element;
2088
    }
2089

    
2090
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2091
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2092
        addAndAdaptElement(parentElement, element);
2093
        return element;
2094
    }
2095

    
2096
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2097
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2098
        addAndAdaptElement(parentElement, element);
2099
        return element;
2100
    }
2101

    
2102
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2103
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2104
        addAndAdaptElement(parentElement, element);
2105
        return element;
2106
    }
2107

    
2108
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2109
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2110
        addAndAdaptElement(parentElement, element);
2111
        return element;
2112
    }
2113

    
2114
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2115
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2116
        addAndAdaptElement(parentElement, element);
2117
        return element;
2118
    }
2119

    
2120
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2121
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2122
        addAndAdaptElement(parentElement, element);
2123
        return element;
2124
    }
2125

    
2126
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2127
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2128
        addAndAdaptElement(parentElement, element);
2129
        return element;
2130
    }
2131

    
2132
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2133
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2134
        addAndAdaptElement(parentElement, element);
2135
        return element;
2136
    }
2137

    
2138
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2139
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2140
        addAndAdaptElement(parentElement, element);
2141
        return element;
2142
    }
2143

    
2144

    
2145
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2146
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2147
        addAndAdaptElement(parentElement, element);
2148
        return element;
2149
    }
2150

    
2151
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2152
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2153
        addAndAdaptElement(parentElement, element);
2154
        return element;
2155
    }
2156

    
2157
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2158
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2159
        addAndAdaptElement(parentElement, element);
2160
        return element;
2161
    }
2162

    
2163
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2164
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2165
        addAndAdaptElement(parentElement, element);
2166
        return element;
2167
    }
2168

    
2169
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2170
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2171
        addAndAdaptElement(parentElement, element);
2172
        return element;
2173
    }
2174

    
2175
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2176
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2177
        addAndAdaptElement(parentElement, element);
2178
        return element;
2179
    }
2180

    
2181
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2182
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2183
        addAndAdaptElement(parentElement, element);
2184
        return element;
2185
    }
2186

    
2187
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2188
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2189
        addAndAdaptElement(parentElement, element);
2190
        return element;
2191
    }
2192

    
2193
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2194
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2195
        addAndAdaptElement(parentElement, element);
2196
        return element;
2197
    }
2198

    
2199
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2200
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2201
        addAndAdaptElement(parentElement, element);
2202
        return element;
2203
    }
2204

    
2205
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2206
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2207
        addAndAdaptElement(parentElement, element);
2208
        return element;
2209
    }
2210

    
2211
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2212
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2213
        addAndAdaptElement(parentElement, element);
2214
        return element;
2215
    }
2216

    
2217
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2218
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2219
        addAndAdaptElement(parentElement, element);
2220
        return element;
2221
    }
2222

    
2223
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2224
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2225
        addAndAdaptElement(parentElement, element);
2226
        return element;
2227
    }
2228

    
2229
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2230
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2231
        addAndAdaptElement(parentElement, element);
2232
        return element;
2233
    }
2234

    
2235
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2236
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2237
        addAndAdaptElement(parentElement, element);
2238
        return element;
2239
    }
2240

    
2241
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2242
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2243
        addAndAdaptElement(parentElement, mediaDetailElement);
2244
        return mediaDetailElement;
2245
    }
2246

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

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

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

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

    
2271
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2272
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2273
        addAndAdaptElement(parentElement, element);
2274
        return element;
2275
    }
2276

    
2277
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2278
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2279
        addAndAdaptElement(parentElement, element);
2280
        return element;
2281
    }
2282

    
2283
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2284
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2285
        addAndAdaptElement(parentElement, element);
2286
        return element;
2287
    }
2288

    
2289
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2290
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2291
        addAndAdaptElement(parentElement, element);
2292
        return element;
2293
    }
2294

    
2295
    /**
2296
     * @param parentElement
2297
     * @param element
2298
     */
2299
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2300
        adapt(element);
2301
        parentElement.addElement(element);
2302
    }
2303

    
2304
    //--------EntityCollectionSection----------
2305
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2306
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2307
        addAndAdaptSection(parentElement, section);
2308
        return section;
2309
    }
2310

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

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

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

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

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

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

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

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

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

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

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

    
2377
    public NameRelationshipDetailSection createNameRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2378
        NameRelationshipDetailSection section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
2379
        addAndAdaptSection(parentElement, section);
2380
        return section;
2381
    }
2382

    
2383
    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2384
        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2385
        addAndAdaptSection(parentElement, section);
2386
        return section;
2387
    }
2388

    
2389
    public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2390
        RightsSection section = new RightsSection(this, conversation, parentElement, style);
2391
        addAndAdaptSection(parentElement, section);
2392
        return section;
2393
    }
2394

    
2395
    public SourceSection createSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2396
        SourceSection section = new SourceSection(this, conversation, parentElement, style);
2397
        addAndAdaptSection(parentElement, section);
2398
        return section;
2399
    }
2400

    
2401
    public ScopeSection createScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2402
        ScopeSection section = new ScopeSection(this, conversation, parentElement, style);
2403
        addAndAdaptSection(parentElement, section);
2404
        return section;
2405
    }
2406

    
2407
    public DescriptionSourceSection createDescriptionSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2408
        DescriptionSourceSection section = new DescriptionSourceSection(this, conversation, parentElement, style);
2409
        addAndAdaptSection(parentElement, section);
2410
        return section;
2411
    }
2412

    
2413
    public TypeDesignationSection createTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2414
        TypeDesignationSection section = new TypeDesignationSection(this, conversation, parentElement, style);
2415
        addAndAdaptSection(parentElement, section);
2416
        return section;
2417
    }
2418

    
2419
    public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2420
        StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
2421
        addAndAdaptSection(parentElement, section);
2422
        return section;
2423
    }
2424

    
2425
    public StatisticalMeasurementValueSection createStatisticalMeasurementValueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2426
        StatisticalMeasurementValueSection section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
2427
        addAndAdaptSection(parentElement, section);
2428
        return section;
2429
    }
2430

    
2431
    public DescribedSpecimenSection createDescribedSpecimenSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2432
        DescribedSpecimenSection section = new DescribedSpecimenSection(this, conversation, parentElement, style);
2433
        addAndAdaptSection(parentElement, section);
2434
        return section;
2435
    }
2436

    
2437
    public StateVocabularyCollectionSection createStateVocabulariesSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2438
        StateVocabularyCollectionSection section = new StateVocabularyCollectionSection(this, conversation, parentElement, style);
2439
        addAndAdaptSection(parentElement, section);
2440
        return section;
2441
    }
2442

    
2443
    public RecommendedModifierVocabulariesCollectionSection createRecommendedModifierVocabulariesCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2444
        RecommendedModifierVocabulariesCollectionSection section = new RecommendedModifierVocabulariesCollectionSection(this, conversation, parentElement, style);
2445
        addAndAdaptSection(parentElement, section);
2446
        return section;
2447
    }
2448

    
2449
    public MeasurementUnitCollectionSection createMeasurementUnitCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2450
        MeasurementUnitCollectionSection section = new MeasurementUnitCollectionSection(this, conversation, parentElement, style);
2451
        addAndAdaptSection(parentElement, section);
2452
        return section;
2453
    }
2454

    
2455
    public StatisticalMeasureCollectionSection createStatisticalMeasureCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2456
        StatisticalMeasureCollectionSection section = new StatisticalMeasureCollectionSection(this, conversation, parentElement, style);
2457
        addAndAdaptSection(parentElement, section);
2458
        return section;
2459
    }
2460

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2569

    
2570
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2571
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2572
        AbstractEntityCollectionElement element = null;
2573

    
2574
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2575

    
2576
        if (entity instanceof Annotation) {
2577
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2578
        }else if (entity instanceof Person ) {
2579
            boolean isNomenclatural = false;
2580
            if (parentElement instanceof TeamMemberSection){
2581
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2582
            }
2583
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2584
        } else if (entity instanceof Credit) {
2585
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2586
        } else if (entity instanceof Extension) {
2587
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2588
        } else if (entity instanceof Marker) {
2589
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2590
        } else if (entity instanceof TaxonNodeAgentRelation) {
2591
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2592
        }else if (entity instanceof Media) {
2593
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2594
        } else if (entity instanceof MediaRepresentation) {
2595
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2596
                    style);
2597
        } else if (entity instanceof ImageFile) {
2598
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2599
        } else if (entity instanceof MediaRepresentationPart) {
2600
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2601
                    removeListener, style);
2602
        } else if (entity instanceof NomenclaturalStatus) {
2603
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2604
                    style);
2605
        } else if (entity instanceof Rights) {
2606
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2607
        } else if (entity instanceof DescriptionElementSource) {
2608
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2609
                    removeListener, style);
2610
        } else if (entity instanceof TaxonNodeAgentRelation) {
2611
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2612
                    removeListener,backgroundColor, style);
2613
        }
2614
        else if (entity instanceof IdentifiableSource) {
2615
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2616
                    style);
2617
        } else if (entity instanceof DefinedTerm) {
2618
            switch(((DefinedTerm)entity).getTermType()) {
2619
            case Scope:
2620
                element = new ScopeElement(this,
2621
                        parentElement,
2622
                        (DefinedTerm) entity,
2623
                        removeListener,
2624
                        style);
2625
                break;
2626
            case Modifier:
2627
                element = new ModifierElement(this,
2628
                        parentElement,
2629
                        (DefinedTerm) entity,
2630
                        removeListener,
2631
                        style);
2632
                break;
2633
            default:
2634
                break;
2635

    
2636
            }
2637
        } else if (entity instanceof Reference) {
2638
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2639
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2640
            }
2641
            else{
2642
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2643
            }
2644
        } else if (entity instanceof NameTypeDesignation) {
2645
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2646
                    style);
2647
        } else if (entity instanceof NameRelationship) {
2648
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2649
                    style);
2650
        } else if (entity instanceof SpecimenTypeDesignation) {
2651
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
2652
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2653
                        removeListener, style);
2654
            }
2655
            else{
2656
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2657
                        removeListener, style);
2658
            }
2659
        } else if (entity instanceof StateData) {
2660
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2661
        } else if (entity instanceof StatisticalMeasurementValue) {
2662
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2663
                    removeListener, style);
2664
        } else if (entity instanceof DerivedUnit) {
2665
            switch(((DerivedUnit)entity).getRecordBasis()) {
2666
            case LivingSpecimen:
2667
            case PreservedSpecimen:
2668
            case OtherSpecimen:
2669
                element = new SpecimenCollectionDetailElement(this,
2670
                        parentElement,
2671
                        (DerivedUnit) entity,
2672
                        removeListener,
2673
                        style);
2674
                break;
2675
            default:
2676
                element = new DerivedUnitElement(this,
2677
                        parentElement,
2678
                        (DerivedUnit) entity,
2679
                        removeListener,
2680
                        style);
2681
            }
2682

    
2683
        } else if (entity instanceof NamedArea) {
2684
            element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2685
        } else if (entity instanceof DeterminationEvent) {
2686
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2687
        } else if (entity instanceof User) {
2688
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2689
        } else if (entity instanceof GrantedAuthority) {
2690
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
2691
                    removeListener, style);
2692
        } else if (entity instanceof Group) {
2693
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2694
        } else if (entity instanceof Taxon) {
2695
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2696
        } else if (entity instanceof DescriptionElementBase) {
2697
            // this is the special case for protologs, maybe we can do this
2698
            // differently when API improves
2699
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2700
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2701
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2702
            }
2703
        } else if (entity instanceof Identifier) {
2704
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2705
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2706
            }
2707
            else{
2708
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
2709
            }
2710
        } else if (entity instanceof TermVocabulary) {
2711
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
2712
            switch (termVocabulary.getTermType()) {
2713
            case State:
2714
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
2715
                break;
2716
            case Modifier:
2717
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
2718
                break;
2719
            default:
2720
                break;
2721
            }
2722
        } else if (entity instanceof MeasurementUnit) {
2723
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2724
        } else if (entity instanceof StatisticalMeasure) {
2725
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2726
        }
2727

    
2728
        //check for parent section when entity is null
2729
        //this happens when AbstractUnboundEntityCollectionSection is used
2730
        if(entity==null){
2731
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
2732
                element = new ScopeElement(this,
2733
                        parentElement,
2734
                        (DefinedTerm) entity,
2735
                        removeListener,
2736
                        style);
2737
            }
2738
            else if(parentElement instanceof ModifierSection){
2739
                element = new ModifierElement(this,
2740
                        parentElement,
2741
                        (DefinedTerm) entity,
2742
                        removeListener,
2743
                        style);
2744
            }
2745
        }
2746

    
2747

    
2748
        if (element == null) {
2749
            MessagingUtils.messageDialog("No element for entity", this,
2750
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2751
                            + entity, null);
2752
        }
2753

    
2754
        else{
2755
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2756
                element.setPersistentBackground(backgroundColor);
2757
            }
2758
            adapt(element);
2759
            parentElement.addElement(element);
2760
        }
2761

    
2762
        return element;
2763
    }
2764

    
2765
    /**
2766
     * <p>
2767
     * Creates a selection element for the given type T.
2768
     * </p>
2769
     * <p>
2770
     * <strong>Selection elements not handled by this method:</strong>
2771
     * <ul>
2772
     * <li>{@link TaxonNodeSelectionElement} see
2773
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2774
     * </li>
2775
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2776
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2777
     * </li>
2778
     * </ul>
2779
     * </p>
2780
     *
2781
     * @param clazz
2782
     *            a {@link Class} object of the type that you want the selection
2783
     *            element to handle
2784
     * @param parentElement
2785
     *            a {@link ICdmFormElement} object.
2786
     * @param labelString
2787
     *            a {@link String} object.
2788
     * @param selectionType
2789
     * @param selection
2790
     *            a {@link ICdmBase} object.
2791
     * @param style
2792
     *            a int.
2793
     * @param conversation
2794
     *            a {@link ConversationHolder} object.
2795
     * @return a {@link EntitySelectionElement} object.
2796
     */
2797
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2798
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2799
            int style, boolean filterElement) {
2800
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2801
                labelString, selection, mode, style, filterElement);
2802
        adapt(element);
2803
        parentElement.addElement(element);
2804
        return element;
2805
    }
2806

    
2807
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2808
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2809
            int style) {
2810
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2811
                labelString, selection, mode, style);
2812
        adapt(element);
2813
        parentElement.addElement(element);
2814
        return element;
2815
    }
2816

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

    
2859
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2860
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2861
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2862
                labelString, selection, mode, style);
2863
        adapt(element);
2864
        parentElement.addElement(element);
2865
        return element;
2866
    }
2867

    
2868
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2869
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2870
//            int mode, int style) {
2871
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2872
//                conversation, parentElement, labelString, selection, mode, style);
2873
//        adapt(element);
2874
//        parentElement.addElement(element);
2875
//        return element;
2876
//    }
2877

    
2878
    /** {@inheritDoc} */
2879
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2880
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2881
        adapt(labelElement);
2882
        parentElement.addElement(labelElement);
2883
        return labelElement;
2884
    }
2885

    
2886
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2887
//        Label label = new Label(formElement.getLayoutComposite(), style);
2888
//        label.setText(labelText+" (yyyy-MM-dd)");
2889
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
2890
//        dateElement.initInternalController();
2891
//        
2892
//        return dateElement;
2893
//    }
2894
    
2895
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2896
    	 Label label = new Label(formElement.getLayoutComposite(), style);
2897
         label.setText(labelText+" (yyyy-MM-dd)");
2898
         DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, style);
2899
         dateElement.initController(this, formElement);
2900
         return dateElement;
2901
    }
2902

    
2903
    /**
2904
     * <p>
2905
     * Getter for the field <code>selectionProvider</code>.
2906
     * </p>
2907
     *
2908
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2909
     */
2910
    public ISelectionProvider getSelectionProvider() {
2911
        return selectionProvider;
2912
    }
2913

    
2914
    /**
2915
     * <p>
2916
     * createDetailedDescriptionDetailElement
2917
     * </p>
2918
     *
2919
     * @param parentElement
2920
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2921
     *            object.
2922
     * @param entity
2923
     *            a
2924
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2925
     *            object.
2926
     * @param style
2927
     *            a int.
2928
     * @return a
2929
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2930
     *         object.
2931
     */
2932
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2933
            ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2934
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2935

    
2936
        if (entity instanceof CategoricalData) {
2937
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2938
                    (CategoricalData) entity, style);
2939
        } else if (entity instanceof CommonTaxonName) {
2940
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2941
                    style);
2942
        } else if (entity instanceof Distribution) {
2943
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2944
                    style);
2945
        } else if (entity instanceof IndividualsAssociation) {
2946
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2947
                    (IndividualsAssociation) entity, style);
2948
        } else if (entity instanceof QuantitativeData) {
2949
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2950
                    (QuantitativeData) entity, style);
2951
        } else if (entity instanceof TaxonInteraction) {
2952
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2953
                    (TaxonInteraction) entity, style);
2954
        } else if (entity instanceof TextData) {
2955
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2956
        } else {
2957
            throw new IllegalStateException("There is no interface for the given description element");
2958
        }
2959
        adapt(detailedDescriptionElement);
2960
        parentElement.addElement(detailedDescriptionElement);
2961
        return detailedDescriptionElement;
2962

    
2963
    }
2964

    
2965
    /**
2966
     * Creates a styled text as a part of the form.
2967
     *
2968
     * @param parent
2969
     *            the text parent
2970
     * @param value
2971
     *            the text initial value
2972
     * @param style
2973
     *            the text style
2974
     * @return the text widget
2975
     */
2976
    public StyledText createStyledText(Composite parent, String value, int style) {
2977
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2978
        if (value != null) {
2979
            text.setText(value);
2980
        }
2981
        text.setForeground(getColors().getForeground());
2982
        text.setBackground(getColors().getBackground());
2983
        // text.addFocusListener(visibilityHandler);
2984
        return text;
2985
    }
2986

    
2987
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2988
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2989
        addAndAdaptSection(parentElement, section);
2990
        return section;
2991
    }
2992

    
2993
    /**
2994
     * @param formElement
2995
     * @param conversationHolder
2996
     * @param style
2997
     * @return
2998
     */
2999
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3000
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3001
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3002
        addAndAdaptSection(formElement, section);
3003
        return section;
3004
    }
3005

    
3006
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3007
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3008
//				 initialText, textHeight, style);
3009
//	        adapt(element);
3010
//	        parentElement.addElement(element);
3011
//	        return element;
3012
//	}
3013

    
3014
	
3015

    
3016

    
3017

    
3018

    
3019

    
3020
}
(7-7/45)