Project

General

Profile

Download (144 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 *
3
 */
4
package eu.etaxonomy.taxeditor.ui.element;
5

    
6
import java.net.URI;
7
import java.util.ArrayList;
8
import java.util.Comparator;
9
import java.util.HashSet;
10
import java.util.List;
11
import java.util.Map;
12
import java.util.Set;
13

    
14
import javax.inject.Inject;
15

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

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

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

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

    
363
    @Inject
364
    private IEclipseContext context;
365

    
366
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
367

    
368
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
369

    
370
    private final int orientation = Window.getDefaultOrientation();
371
    private ISelectionProvider selectionProvider;
372

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

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

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

    
407
    private void notifySelectionListeners(TypedEvent e) {
408
        Event event = new Event();
409
        event.widget = e.widget;
410
        SelectionEvent selectionEvent = new SelectionEvent(event);
411

    
412
        for (SelectionListener listener : selectionListenerList) {
413
            listener.widgetSelected(selectionEvent);
414
        }
415
    }
416

    
417
    public CdmFormFactory(Display display) {
418
        this(display, null);
419
    }
420

    
421
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
422
        super(display);
423
        this.selectionProvider = selectionProvider;
424
        init();
425
    }
426

    
427
    private void init() {
428
        boldFontHolder2 = new BoldFontHolder2();
429
        selectionMouseHandler = new SelectionMouseHandler();
430
        selectionFocusHandler = new SelectionFocusHandler();
431
    }
432

    
433
    public IEclipseContext getContext() {
434
        return context;
435
    }
436

    
437
    /**
438
     * Creates an instance initialized with the correct selectionProvider
439
     *
440
     * Make sure to remove the instance when the entityComposite disposes via
441
     * destroySelectionArbitrator(..)
442
     *
443
     * @param entityElement
444
     *            a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
445
     *            object.
446
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
447
     *         object.
448
     */
449
    public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
450
        SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
451
        selectionArbitrator.addSelectionProvider(selectionProvider);
452
        selectionProvider.addSelectionChangedListener(selectionArbitrator);
453
        addSelectionListener(selectionArbitrator);
454
        return selectionArbitrator;
455
    }
456

    
457
    /**
458
     * <p>
459
     * destroySelectionArbitrator
460
     * </p>
461
     *
462
     * @param selectionArbitrator
463
     *            a
464
     *            {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
465
     *            object.
466
     */
467
    public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
468
        removeSelectionListener(selectionArbitrator);
469
        if (selectionProvider != null) {
470
            selectionProvider.removeSelectionChangedListener(selectionArbitrator);
471
        } else {
472
            MessagingUtils.error(this.getClass(),
473
                    "Tried to destroy a selection listener from this factories listeners but was null", null);
474
        }
475
    }
476

    
477
    /**
478
     * <p>
479
     * Adapts the {@link AbstractCdmFormElement}:<br>
480
     * - sets the {@link IPropertyChangeListener}s handled by this class
481
     * </p>
482
     *
483
     * @param formElement
484
     *            a
485
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
486
     *            object.
487
     */
488
    public void adapt(ICdmFormElement formElement) {
489
        formElement.setPropertyChangeListeners(propertyChangeListeners);
490
    }
491

    
492
    /** {@inheritDoc} */
493
    @Override
494
    public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
495
        if (trackFocus) {
496
            control.addFocusListener(selectionFocusHandler);
497
        }
498
        super.adapt(control, trackFocus, trackKeyboard);
499
    }
500

    
501
    /** {@inheritDoc} */
502
    @Override
503
    public void adapt(Composite composite) {
504
        composite.addMouseListener(selectionMouseHandler);
505

    
506
        super.adapt(composite);
507
    }
508

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

    
552
    /**
553
     * <p>
554
     * createEmptyCell
555
     * </p>
556
     *
557
     * @param parent
558
     *            a {@link org.eclipse.swt.widgets.Composite} object.
559
     * @return a {@link org.eclipse.swt.widgets.Label} object.
560
     */
561
    public Label createEmptyCell(Composite parent) {
562
        return this.createLabel(parent, null);
563
    }
564

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

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

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

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

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

    
698
    public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
699
            KeyStatement keyStatement, int textHeight, int style) {
700
        KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
701
                textHeight, style);
702
        adapt(element);
703
        parentElement.addElement(element);
704
        return element;
705
    }
706

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

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

    
767
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
768
                textLimit, style);
769
        adapt(element);
770
        parentElement.addElement(element);
771
        return element;
772
    }
773

    
774
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
775
            int textHeight, int style) {
776
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
777
        adapt(element);
778
        parentElement.addElement(element);
779
        return element;
780
    }
781

    
782
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
783
            LSID initialLsid, int style) {
784
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
785
        adapt(element);
786
        parentElement.addElement(element);
787
        return element;
788
    }
789

    
790
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
791
            URI initialUri, int style) {
792
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
793
        adapt(element);
794
        parentElement.addElement(element);
795
        return element;
796
    }
797

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

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

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

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

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

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

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

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

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

    
948

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

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

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

    
1000
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1001
	        Class<T> enumComboType, ICdmFormElement parentElement,
1002
	        int style) {
1003
	    return createEnumComboElement(enumComboType, parentElement, null, style);
1004
	}
1005

    
1006
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1007
			Class<T> enumComboType, ICdmFormElement parentElement, Comparator<T> comparator,
1008
			int style) {
1009
        EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, comparator, style);
1010
        adapt(element);
1011
        parentElement.addElement(element);
1012
        return element;
1013
    }
1014

    
1015
	public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
1016
	        TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
1017
	    VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
1018
	    adapt(element);
1019
	    parentElement.addElement(element);
1020
	    return element;
1021
	}
1022

    
1023
    /**
1024
     * <p>
1025
     * createBrowserElement
1026
     * </p>
1027
     *
1028
     * @param imageUri
1029
     *            a {@link java.net.URI} object.
1030
     * @param style
1031
     *            a int.
1032
     * @param parentElement
1033
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1034
     *            object.
1035
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
1036
     *         object.
1037
     */
1038
    public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
1039
        BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
1040
        adapt(element);
1041
        parentElement.addElement(element);
1042
        return element;
1043
    }
1044

    
1045
    /**
1046
     * <p>
1047
     * createImageElement
1048
     * </p>
1049
     *
1050
     * @param parentElement
1051
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1052
     *            object.
1053
     * @param imageUri
1054
     *            a {@link java.net.URI} object.
1055
     * @param style
1056
     *            a int.
1057
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
1058
     */
1059
    public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
1060
        ImageElement element = new ImageElement(this, parentElement, imageUri, style);
1061
        adapt(element);
1062
        parentElement.addElement(element);
1063
        return element;
1064
    }
1065

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

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

    
1121
    /**
1122
     * Creates a section as a part of the form.
1123
     *
1124
     * @return the section widget
1125
     * @param section
1126
     *            a
1127
     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1128
     *            object.
1129
     */
1130
    public Section adapt(AbstractFormSection section) {
1131
        section.setMenu(section.getLayoutComposite().getMenu());
1132
        adapt(section, true, true);
1133

    
1134
        // handle focus and property change events for cdm use
1135
        section.addFocusListener(selectionFocusHandler);
1136
        section.setPropertyChangeListeners(propertyChangeListeners);
1137

    
1138
        if (section.getToggle() != null) {
1139
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1140
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1141
        }
1142

    
1143
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1144

    
1145
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1146
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1147
            getColors().initializeSectionToolBarColors();
1148
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1149
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1150
        }
1151
        // call setTitleBarForeground regardless as it also sets the label color
1152
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1153
        return section;
1154
    }
1155

    
1156
    private class BoldFontHolder2 {
1157
        private Font normalFont;
1158

    
1159
        private Font boldFont;
1160

    
1161
        public BoldFontHolder2() {
1162
        }
1163

    
1164
        public Font getBoldFont(Font font) {
1165
            createBoldFont(font);
1166
            return boldFont;
1167
        }
1168

    
1169
        private void createBoldFont(Font font) {
1170
            if (normalFont == null || !normalFont.equals(font)) {
1171
                normalFont = font;
1172
                dispose();
1173
            }
1174
            if (boldFont == null) {
1175
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1176
            }
1177
        }
1178

    
1179
        public void dispose() {
1180
            if (boldFont != null) {
1181
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1182
                boldFont = null;
1183
            }
1184
        }
1185
    }
1186

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

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

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

    
1274
    /**
1275
     * <p>
1276
     * createPointElement
1277
     * </p>
1278
     *
1279
     * @param style
1280
     *            a int.
1281
     * @param parentElement
1282
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1283
     *            object.
1284
     * @param point
1285
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1286
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1287
     */
1288
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1289
        PointElement element = new PointElement(this, parentElement, point, style);
1290
        adapt(element);
1291
        parentElement.addElement(element);
1292
        return element;
1293
    }
1294

    
1295

    
1296

    
1297
    /**
1298
     * @param conversationHolder
1299
     * @param parent
1300
     * @param detailsViewer
1301
     * @param i
1302
     * @return
1303
     */
1304
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1305
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1306
        parentElement.addElement(section);
1307
        adapt(section);
1308
        return section;
1309
    }
1310

    
1311
    /**
1312
     * <p>
1313
     * createDateDetailSection
1314
     * </p>
1315
     *
1316
     * @param parentElement
1317
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1318
     *            object.
1319
     * @param style
1320
     *            a int.
1321
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1322
     *         object.
1323
     */
1324
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1325
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1326
        parentElement.addElement(section);
1327
        adapt(section);
1328
        return section;
1329
    }
1330

    
1331
	/**
1332
	 * <p>
1333
	 * createDateDetailSection
1334
	 * </p>
1335
	 *
1336
	 * @param parentElement
1337
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1338
	 *            object.
1339
	 * @param style
1340
	 *            a int.
1341
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1342
	 *         object.
1343
	 */
1344
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1345
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1346
		parentElement.addElement(section);
1347
		adapt(section);
1348
		return section;
1349
	}
1350

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

    
1376
    /**
1377
     * <p>
1378
     * addSelectionListener
1379
     * </p>
1380
     *
1381
     * @param listener
1382
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1383
     */
1384
    public void addSelectionListener(SelectionListener listener) {
1385
        selectionListenerList.add(listener);
1386
    }
1387

    
1388
    /**
1389
     * <p>
1390
     * removeSelectionListener
1391
     * </p>
1392
     *
1393
     * @param listener
1394
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1395
     */
1396
    public void removeSelectionListener(SelectionListener listener) {
1397
        if (listener == null) {
1398
            MessagingUtils.error(this.getClass(),
1399
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1400
        } else {
1401
            selectionListenerList.remove(listener);
1402
        }
1403
    }
1404

    
1405
    /**
1406
     * <p>
1407
     * addPropertyChangeListener
1408
     * </p>
1409
     *
1410
     * @param listener
1411
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1412
     *            object.
1413
     */
1414
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1415
        if (propertyChangeListeners.contains(listener)) {
1416
            return;
1417
        }
1418
        propertyChangeListeners.add(0, listener);
1419
    }
1420

    
1421
    /**
1422
     * <p>
1423
     * removePropertyChangeListener
1424
     * </p>
1425
     *
1426
     * @param listener
1427
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1428
     *            object.
1429
     */
1430
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1431
        propertyChangeListeners.remove(listener);
1432
    }
1433

    
1434
    /**
1435
     * @return the propertyChangeListeners
1436
     */
1437
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1438
        return propertyChangeListeners;
1439
    }
1440

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

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

    
1483
    /**
1484
     * @param cdmBaseSection
1485
     * @param object
1486
     * @param style
1487
     * @return
1488
     */
1489
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1490
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1491
        adapt(element);
1492
        parentElement.addElement(element);
1493
        return element;
1494
    }
1495

    
1496
    /**
1497
     * <p>
1498
     * createVersionSection
1499
     * </p>
1500
     *
1501
     * @param parentElement
1502
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1503
     *            object.
1504
     * @param style
1505
     *            a int.
1506
     * @return a
1507
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1508
     *         object.
1509
     */
1510
    public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1511
        VersionSection section = new VersionSection(this, parentElement, style);
1512
        parentElement.addElement(section);
1513
        adapt(section);
1514
        return section;
1515
    }
1516

    
1517
    /**
1518
     * @param parent
1519
     * @param i
1520
     * @return
1521
     */
1522
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1523
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1524
        parentElement.addElement(section);
1525
        adapt(section);
1526
        return section;
1527
    }
1528

    
1529
    /**
1530
     * <p>
1531
     * createEmptyElement
1532
     * </p>
1533
     *
1534
     * @param parentElement
1535
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1536
     *            object.
1537
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1538
     */
1539
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1540
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1541
        adapt(element);
1542
        parentElement.addElement(element);
1543
        return element;
1544
    }
1545

    
1546
    /**
1547
     * <p>
1548
     * createHeadlineSection
1549
     * </p>
1550
     *
1551
     * @param parentElement
1552
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1553
     *            object.
1554
     * @return a
1555
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1556
     *         object.
1557
     */
1558
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1559
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1560
        parentElement.addElement(section);
1561
        adapt(section);
1562
        return section;
1563
    }
1564

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

    
1590
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1591
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1592

    
1593
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1594
                selectionProvider, style);
1595

    
1596
        parentElement.addElement(section);
1597
        adapt(section);
1598
        return section;
1599

    
1600
    }
1601

    
1602
    /**
1603
     * @param definedTermClass
1604
     * @param formElement
1605
     * @param style
1606
     * @return
1607
     */
1608
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1609
            AbstractCdmDetailSection parentElement, int style) {
1610
        AbstractCdmDetailElement element = null;
1611

    
1612
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1613
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1614
        } else if (definedTermClass.equals(Feature.class)) {
1615
            element = new FeatureDetailElement(this, parentElement);
1616
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1617
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1618
        } else {
1619
            element = new DefinedTermDetailElement(this, parentElement);
1620
        }
1621

    
1622

    
1623
        adapt(element);
1624
        parentElement.addElement(element);
1625
        return element;
1626
    }
1627

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

    
1634
    public CharacterDetailElement createCharacterDetailElement(ICdmFormElement parentElement, int style){
1635
        CharacterDetailElement element = new CharacterDetailElement(this, parentElement);
1636
        addAndAdaptElement(parentElement, element);
1637
        return element;
1638
    }
1639

    
1640

    
1641
    //--------DetailSections---------
1642
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1643
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1644
        addAndAdaptSection(parentElement, section);
1645
        return section;
1646
    }
1647

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

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

    
1660
    public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1661
        TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1662
        addAndAdaptSection(parentElement, section);
1663
        return section;
1664
    }
1665

    
1666
    public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1667
        AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1668
        addAndAdaptSection(parentElement, section);
1669
        return section;
1670
    }
1671

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

    
1678
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1679
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1680
        addAndAdaptSection(parentElement, section);
1681
        return section;
1682
    }
1683

    
1684
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1685
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1686
        addAndAdaptSection(parentElement, section);
1687
        return section;
1688
    }
1689

    
1690
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1691
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1692
        addAndAdaptSection(parentElement, section);
1693
        return section;
1694
    }
1695

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

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

    
1708

    
1709

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1836
    public DnaSamplePreparationPreservationSection createDnaSamplePreparationPreservationSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1837
        DnaSamplePreparationPreservationSection section = new DnaSamplePreparationPreservationSection(this, conversation, parentElement, selectionProvider, style);
1838
        addAndAdaptSection(parentElement, section);
1839
        return section;
1840
    }
1841

    
1842
    public DnaQualityDetailSection createDnaQualityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1843
        DnaQualityDetailSection section = new DnaQualityDetailSection(this, conversation, parentElement, selectionProvider, style);
1844
        addAndAdaptSection(parentElement, section);
1845
        return section;
1846
    }
1847

    
1848
    public SequenceGeneralDetailSection createSequenceGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1849
        SequenceGeneralDetailSection section = new SequenceGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1850
        addAndAdaptSection(parentElement, section);
1851
        return section;
1852
    }
1853

    
1854
    public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1855
        SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
1856
        addAndAdaptSection(parentElement, section);
1857
        return section;
1858
    }
1859

    
1860
    public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1861
        SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
1862
        addAndAdaptSection(parentElement, section);
1863
        return section;
1864
    }
1865

    
1866
    public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1867
        SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1868
        addAndAdaptSection(parentElement, section);
1869
        return section;
1870
    }
1871

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1974
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1975
        parentElement.addElement(section);
1976
        adapt(section);
1977
    }
1978

    
1979
    //--------DetailElements------------
1980

    
1981
    public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1982
        UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1983
        addAndAdaptElement(parentElement, element);
1984
        return element;
1985
    }
1986

    
1987
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1988
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1989
        addAndAdaptElement(parentElement, element);
1990
        return element;
1991
    }
1992

    
1993
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1994
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1995
        addAndAdaptElement(parentElement, element);
1996
        return element;
1997
    }
1998

    
1999
    public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
2000
        TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
2001
        addAndAdaptElement(parentElement, element);
2002
        return element;
2003
    }
2004

    
2005
    public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
2006
        ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
2007
        addAndAdaptElement(parentElement, element);
2008
        return element;
2009
    }
2010

    
2011
    public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
2012
        TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
2013
        addAndAdaptElement(parentElement, element);
2014
        return element;
2015
    }
2016

    
2017
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
2018
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2019
        addAndAdaptElement(parentElement, element);
2020
        return element;
2021
    }
2022

    
2023
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2024
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2025
        addAndAdaptElement(parentElement, element);
2026
        return element;
2027
    }
2028

    
2029
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2030
        UserDetailElement element = new UserDetailElement(this, parentElement);
2031
        addAndAdaptElement(parentElement, element);
2032
        return element;
2033
    }
2034

    
2035
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2036
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2037
        addAndAdaptElement(parentElement, element);
2038
        return element;
2039
    }
2040

    
2041
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2042
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2043
        addAndAdaptElement(parentElement, element);
2044
        return element;
2045
    }
2046

    
2047
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2048
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2049
        addAndAdaptElement(parentElement, element);
2050
        return element;
2051
    }
2052

    
2053
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2054
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2055
        addAndAdaptElement(parentElement, element);
2056
        return element;
2057
    }
2058

    
2059
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2060
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2061
        addAndAdaptElement(parentElement, element);
2062
        return element;
2063
    }
2064

    
2065
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2066
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2067
        adapt(element);
2068
        parentElement.addElement(element);
2069

    
2070
        return element;
2071
    }
2072

    
2073
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2074
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2075
        addAndAdaptElement(parentElement, element);
2076
        return element;
2077
    }
2078

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

    
2085
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2086
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2087
        addAndAdaptElement(parentElement, element);
2088
        return element;
2089
    }
2090

    
2091
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2092
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2093
        addAndAdaptElement(parentElement, element);
2094
        return element;
2095
    }
2096

    
2097
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2098
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2099
        addAndAdaptElement(parentElement, element);
2100
        return element;
2101
    }
2102

    
2103
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2104
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2105
        addAndAdaptElement(parentElement, element);
2106
        return element;
2107
    }
2108

    
2109
    public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
2110
        DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
2111
        addAndAdaptElement(parentElement, element);
2112
        return element;
2113
    }
2114

    
2115
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2116
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2117
        addAndAdaptElement(parentElement, element);
2118
        return element;
2119
    }
2120

    
2121
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2122
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2123
        addAndAdaptElement(parentElement, element);
2124
        return element;
2125
    }
2126

    
2127
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2128
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2129
        addAndAdaptElement(parentElement, element);
2130
        return element;
2131
    }
2132

    
2133
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2134
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2135
        addAndAdaptElement(parentElement, element);
2136
        return element;
2137
    }
2138

    
2139
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2140
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2141
        addAndAdaptElement(parentElement, element);
2142
        return element;
2143
    }
2144

    
2145
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2146
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2147
        addAndAdaptElement(parentElement, element);
2148
        return element;
2149
    }
2150

    
2151
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2152
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2153
        addAndAdaptElement(parentElement, element);
2154
        return element;
2155
    }
2156

    
2157
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2158
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2159
        addAndAdaptElement(parentElement, element);
2160
        return element;
2161
    }
2162

    
2163

    
2164
    public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2165
        FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2166
        addAndAdaptElement(parentElement, element);
2167
        return element;
2168
    }
2169

    
2170
    public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2171
        DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2172
        addAndAdaptElement(parentElement, element);
2173
        return element;
2174
    }
2175

    
2176
    public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2177
        TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2178
        addAndAdaptElement(parentElement, element);
2179
        return element;
2180
    }
2181

    
2182
    public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2183
        PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2184
        addAndAdaptElement(parentElement, element);
2185
        return element;
2186
    }
2187

    
2188
    public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2189
        TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2190
        addAndAdaptElement(parentElement, element);
2191
        return element;
2192
    }
2193

    
2194
    public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2195
        DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2196
        addAndAdaptElement(parentElement, element);
2197
        return element;
2198
    }
2199

    
2200
    public DnaSamplePreparationPreservationDetailElement createDnaSamplePreparationPreservationDetailElement(ICdmFormElement parentElement){
2201
        DnaSamplePreparationPreservationDetailElement element = new DnaSamplePreparationPreservationDetailElement(this, parentElement);
2202
        addAndAdaptElement(parentElement, element);
2203
        return element;
2204
    }
2205

    
2206
    public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2207
        DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2208
        addAndAdaptElement(parentElement, element);
2209
        return element;
2210
    }
2211

    
2212
    public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2213
        SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2214
        addAndAdaptElement(parentElement, element);
2215
        return element;
2216
    }
2217

    
2218
    public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2219
        SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2220
        addAndAdaptElement(parentElement, element);
2221
        return element;
2222
    }
2223

    
2224
    public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2225
        PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2226
        addAndAdaptElement(parentElement, element);
2227
        return element;
2228
    }
2229

    
2230
    public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2231
        AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2232
        addAndAdaptElement(parentElement, element);
2233
        return element;
2234
    }
2235

    
2236
    public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2237
        AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2238
        addAndAdaptElement(parentElement, element);
2239
        return element;
2240
    }
2241

    
2242
    public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2243
        AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2244
        addAndAdaptElement(parentElement, element);
2245
        return element;
2246
    }
2247

    
2248
    public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2249
        AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2250
        addAndAdaptElement(parentElement, element);
2251
        return element;
2252
    }
2253

    
2254
    public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2255
        MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2256
        addAndAdaptElement(parentElement, element);
2257
        return element;
2258
    }
2259

    
2260
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2261
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2262
        addAndAdaptElement(parentElement, mediaDetailElement);
2263
        return mediaDetailElement;
2264
    }
2265

    
2266
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2267
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2268
        addAndAdaptElement(parentElement, element);
2269
        return element;
2270
    }
2271

    
2272
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2273
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2274
        addAndAdaptElement(parentElement, element);
2275
        return element;
2276
    }
2277

    
2278
    public SpecimenHierarchyDetailElement createSpecimenHierarchyDetailElement(ICdmFormElement parentElement) {
2279
        SpecimenHierarchyDetailElement element = new SpecimenHierarchyDetailElement(this, parentElement);
2280
        addAndAdaptElement(parentElement, element);
2281
        return element;
2282
    }
2283

    
2284
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2285
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2286
        addAndAdaptElement(parentElement, element);
2287
        return element;
2288
    }
2289

    
2290
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2291
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2292
        addAndAdaptElement(parentElement, element);
2293
        return element;
2294
    }
2295

    
2296
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2297
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2298
        addAndAdaptElement(parentElement, element);
2299
        return element;
2300
    }
2301

    
2302
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2303
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2304
        addAndAdaptElement(parentElement, element);
2305
        return element;
2306
    }
2307

    
2308
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2309
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2310
        addAndAdaptElement(parentElement, element);
2311
        return element;
2312
    }
2313

    
2314
    /**
2315
     * @param parentElement
2316
     * @param element
2317
     */
2318
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2319
        adapt(element);
2320
        parentElement.addElement(element);
2321
    }
2322

    
2323
    //--------EntityCollectionSection----------
2324
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2325
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2326
        addAndAdaptSection(parentElement, section);
2327
        return section;
2328
    }
2329

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2570
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2571
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2572
        addAndAdaptSection(parentElement, section);
2573
        return section;
2574
    }
2575

    
2576
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2577
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2578
        addAndAdaptSection(parentElement, section);
2579
        return section;
2580
    }
2581

    
2582
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2583
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2584
        addAndAdaptSection(parentElement, section);
2585
        return section;
2586
    }
2587

    
2588

    
2589
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2590
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2591
        AbstractEntityCollectionElement element = null;
2592

    
2593
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2594

    
2595
        if (entity instanceof Annotation) {
2596
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2597
        }else if (entity instanceof Person ) {
2598
            boolean isNomenclatural = false;
2599
            if (parentElement instanceof TeamMemberSection){
2600
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2601
            }
2602
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2603
        } else if (entity instanceof Credit) {
2604
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2605
        } else if (entity instanceof Extension) {
2606
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2607
        } else if (entity instanceof Marker) {
2608
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2609
        } else if (entity instanceof TaxonNodeAgentRelation) {
2610
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2611
        }else if (entity instanceof Media) {
2612
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2613
        } else if (entity instanceof MediaRepresentation) {
2614
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2615
                    style);
2616
        } else if (entity instanceof ImageFile) {
2617
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2618
        } else if (entity instanceof MediaRepresentationPart) {
2619
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2620
                    removeListener, style);
2621
        } else if (entity instanceof NomenclaturalStatus) {
2622
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2623
                    style);
2624
        } else if (entity instanceof Rights) {
2625
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2626
        } else if (entity instanceof DescriptionElementSource) {
2627
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2628
                    removeListener, style);
2629
        } else if (entity instanceof TaxonNodeAgentRelation) {
2630
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2631
                    removeListener,backgroundColor, style);
2632
        }
2633
        else if (entity instanceof IdentifiableSource) {
2634
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2635
                    style);
2636
        } else if (entity instanceof DefinedTerm) {
2637
            switch(((DefinedTerm)entity).getTermType()) {
2638
            case Scope:
2639
                element = new ScopeElement(this,
2640
                        parentElement,
2641
                        (DefinedTerm) entity,
2642
                        removeListener,
2643
                        style);
2644
                break;
2645
            case Modifier:
2646
                element = new ModifierElement(this,
2647
                        parentElement,
2648
                        (DefinedTerm) entity,
2649
                        removeListener,
2650
                        style);
2651
                break;
2652
            default:
2653
                break;
2654

    
2655
            }
2656
        } else if (entity instanceof Reference) {
2657
            if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2658
                element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2659
            }
2660
            else{
2661
                element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2662
            }
2663
        } else if (entity instanceof NameTypeDesignation) {
2664
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2665
                    style);
2666
        } else if (entity instanceof NameRelationship) {
2667
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2668
                    style);
2669
        } else if (entity instanceof SpecimenTypeDesignation) {
2670
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
2671
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2672
                        removeListener, style);
2673
            }
2674
            else{
2675
                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2676
                        removeListener, style);
2677
            }
2678
        } else if (entity instanceof StateData) {
2679
            element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2680
        } else if (entity instanceof StatisticalMeasurementValue) {
2681
            element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2682
                    removeListener, style);
2683
        } else if (entity instanceof DerivedUnit) {
2684
            switch(((DerivedUnit)entity).getRecordBasis()) {
2685
            case LivingSpecimen:
2686
            case PreservedSpecimen:
2687
            case OtherSpecimen:
2688
                element = new SpecimenCollectionDetailElement(this,
2689
                        parentElement,
2690
                        (DerivedUnit) entity,
2691
                        removeListener,
2692
                        style);
2693
                break;
2694
            default:
2695
                element = new DerivedUnitElement(this,
2696
                        parentElement,
2697
                        (DerivedUnit) entity,
2698
                        removeListener,
2699
                        style);
2700
            }
2701

    
2702
        } else if (entity instanceof NamedArea) {
2703
            element = new CollectingAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2704
        } else if (entity instanceof DeterminationEvent) {
2705
            element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2706
        } else if (entity instanceof User) {
2707
            element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2708
        } else if (entity instanceof GrantedAuthority) {
2709
            element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, ((Group)parentElement.getEntity()),
2710
                    removeListener, style);
2711
        } else if (entity instanceof Group) {
2712
            element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2713
        } else if (entity instanceof Taxon) {
2714
            element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2715
        } else if (entity instanceof DescriptionElementBase) {
2716
            // this is the special case for protologs, maybe we can do this
2717
            // differently when API improves
2718
            DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2719
            if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2720
                element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2721
            }
2722
        } else if (entity instanceof Identifier) {
2723
            if(parentElement instanceof AbstractSampleDesignationDetailSection){
2724
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2725
            }
2726
            else{
2727
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
2728
            }
2729
        } else if (entity instanceof TermVocabulary) {
2730
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
2731
            switch (termVocabulary.getTermType()) {
2732
            case State:
2733
                element = new StateVocabularyCollectionElement(this, parentElement, (TermVocabulary<State>) entity, removeListener, backgroundColor, style);
2734
                break;
2735
            case Modifier:
2736
                element = new RecommendedModifierVocabulariesElement(this, parentElement, (TermVocabulary<DefinedTerm>) entity, removeListener, backgroundColor, style);
2737
                break;
2738
            default:
2739
                break;
2740
            }
2741
        } else if (entity instanceof MeasurementUnit) {
2742
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2743
        } else if (entity instanceof StatisticalMeasure) {
2744
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2745
        }
2746

    
2747
        //check for parent section when entity is null
2748
        //this happens when AbstractUnboundEntityCollectionSection is used
2749
        if(entity==null){
2750
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
2751
                element = new ScopeElement(this,
2752
                        parentElement,
2753
                        (DefinedTerm) entity,
2754
                        removeListener,
2755
                        style);
2756
            }
2757
            else if(parentElement instanceof ModifierSection){
2758
                element = new ModifierElement(this,
2759
                        parentElement,
2760
                        (DefinedTerm) entity,
2761
                        removeListener,
2762
                        style);
2763
            }
2764
        }
2765

    
2766

    
2767
        if (element == null) {
2768
            MessagingUtils.messageDialog("No element for entity", this,
2769
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2770
                            + entity, null);
2771
        }
2772

    
2773
        else{
2774
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2775
                element.setPersistentBackground(backgroundColor);
2776
            }
2777
            adapt(element);
2778
            parentElement.addElement(element);
2779
        }
2780

    
2781
        return element;
2782
    }
2783

    
2784
    /**
2785
     * <p>
2786
     * Creates a selection element for the given type T.
2787
     * </p>
2788
     * <p>
2789
     * <strong>Selection elements not handled by this method:</strong>
2790
     * <ul>
2791
     * <li>{@link TaxonNodeSelectionElement} see
2792
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2793
     * </li>
2794
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2795
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2796
     * </li>
2797
     * </ul>
2798
     * </p>
2799
     *
2800
     * @param clazz
2801
     *            a {@link Class} object of the type that you want the selection
2802
     *            element to handle
2803
     * @param parentElement
2804
     *            a {@link ICdmFormElement} object.
2805
     * @param labelString
2806
     *            a {@link String} object.
2807
     * @param selectionType
2808
     * @param selection
2809
     *            a {@link ICdmBase} object.
2810
     * @param style
2811
     *            a int.
2812
     * @param conversation
2813
     *            a {@link ConversationHolder} object.
2814
     * @return a {@link EntitySelectionElement} object.
2815
     */
2816
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2817
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2818
            int style, boolean filterElement) {
2819
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
2820
                parentElement, clazz,
2821
                labelString, selection, mode, style, filterElement);
2822
        adapt(element);
2823
        parentElement.addElement(element);
2824
        return element;
2825
    }
2826

    
2827
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2828
//            ConversationHolder conversation,
2829
            ICdmFormElement parentElement, String labelString, T selection, int mode,
2830
            int style) {
2831
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
2832
                parentElement, clazz,
2833
                labelString, selection, mode, style);
2834
        adapt(element);
2835
        parentElement.addElement(element);
2836
        return element;
2837
    }
2838

    
2839
    /**
2840
     * <p>
2841
     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
2842
     * </p>
2843
     * <p>
2844
     * <strong>Selection elements not handled by this method:</strong>
2845
     * <ul>
2846
     * <li>{@link TaxonNodeSelectionElement} see
2847
     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2848
     * </li>
2849
     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2850
     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2851
     * </li>
2852
     * </ul>
2853
     * </p>
2854
     *
2855
     * @param clazz
2856
     *            a {@link Class} object of the type that you want the selection
2857
     *            element to handle
2858
     * @param parentElement
2859
     *            a {@link ICdmFormElement} object.
2860
     * @param labelString
2861
     *            a {@link String} object.
2862
     * @param selectionType
2863
     * @param selection
2864
     *            a {@link ICdmBase} object.
2865
     * @param style
2866
     *            a int.
2867
     * @param conversation
2868
     *            a {@link ConversationHolder} object.
2869
     * @return a {@link EntitySelectionElement} object.
2870
     */
2871
    public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
2872
            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
2873
            T selection, int mode, int style) {
2874
        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, //conversation,
2875
                parentElement, clazz,
2876
                labelString, selection, mode, style);
2877
        adapt(element);
2878
        parentElement.addElement(element);
2879
        return element;
2880
    }
2881

    
2882
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2883
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2884
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
2885
                parentElement,
2886
                labelString, selection, mode, style);
2887
        adapt(element);
2888
        parentElement.addElement(element);
2889
        return element;
2890
    }
2891

    
2892
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2893
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2894
//            int mode, int style) {
2895
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2896
//                conversation, parentElement, labelString, selection, mode, style);
2897
//        adapt(element);
2898
//        parentElement.addElement(element);
2899
//        return element;
2900
//    }
2901

    
2902
    /** {@inheritDoc} */
2903
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2904
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2905
        adapt(labelElement);
2906
        parentElement.addElement(labelElement);
2907
        return labelElement;
2908
    }
2909

    
2910
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2911
//        Label label = new Label(formElement.getLayoutComposite(), style);
2912
//        label.setText(labelText+" (yyyy-MM-dd)");
2913
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
2914
//        dateElement.initInternalController();
2915
//
2916
//        return dateElement;
2917
//    }
2918

    
2919
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
2920
    	 Label label = new Label(formElement.getLayoutComposite(), style);
2921
         label.setText(labelText);
2922
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2923
         DateElement dateElement = new DateElement(this, formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
2924
         dateElement.initController(this, formElement);
2925
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2926
         return dateElement;
2927
    }
2928

    
2929
    /**
2930
     * <p>
2931
     * Getter for the field <code>selectionProvider</code>.
2932
     * </p>
2933
     *
2934
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2935
     */
2936
    public ISelectionProvider getSelectionProvider() {
2937
        return selectionProvider;
2938
    }
2939

    
2940
    /**
2941
     * <p>
2942
     * createDetailedDescriptionDetailElement
2943
     * </p>
2944
     *
2945
     * @param parentElement
2946
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2947
     *            object.
2948
     * @param entity
2949
     *            a
2950
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2951
     *            object.
2952
     * @param style
2953
     *            a int.
2954
     * @return a
2955
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2956
     *         object.
2957
     */
2958
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2959
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
2960
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2961

    
2962
        if (entity instanceof CategoricalData) {
2963
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2964
                    (CategoricalData) entity, style);
2965
        } else if (entity instanceof CommonTaxonName) {
2966
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2967
                    style);
2968
        } else if (entity instanceof Distribution && !enabled) {
2969
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2970
                    style);
2971
            detailedDescriptionElement.setEnabled(enabled);
2972
        } else if (entity instanceof Distribution) {
2973
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2974
                    style);
2975
        }else if (entity instanceof IndividualsAssociation) {
2976
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2977
                    (IndividualsAssociation) entity, style);
2978
        } else if (entity instanceof QuantitativeData) {
2979
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2980
                    (QuantitativeData) entity, style);
2981
        } else if (entity instanceof TaxonInteraction) {
2982
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2983
                    (TaxonInteraction) entity, style);
2984
        } else if (entity instanceof TextData) {
2985
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2986
        } else {
2987
            throw new IllegalStateException("There is no interface for the given description element");
2988
        }
2989
        adapt(detailedDescriptionElement);
2990
        parentElement.addElement(detailedDescriptionElement);
2991
        return detailedDescriptionElement;
2992

    
2993
    }
2994

    
2995
    /**
2996
     * Creates a styled text as a part of the form.
2997
     *
2998
     * @param parent
2999
     *            the text parent
3000
     * @param value
3001
     *            the text initial value
3002
     * @param style
3003
     *            the text style
3004
     * @return the text widget
3005
     */
3006
    public StyledText createStyledText(Composite parent, String value, int style) {
3007
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3008
        if (value != null) {
3009
            text.setText(value);
3010
        }
3011
        text.setForeground(getColors().getForeground());
3012
        text.setBackground(getColors().getBackground());
3013
        // text.addFocusListener(visibilityHandler);
3014
        return text;
3015
    }
3016

    
3017
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3018
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3019
        addAndAdaptSection(parentElement, section);
3020
        return section;
3021
    }
3022

    
3023
    /**
3024
     * @param formElement
3025
     * @param conversationHolder
3026
     * @param style
3027
     * @return
3028
     */
3029
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3030
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3031
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3032
        addAndAdaptSection(formElement, section);
3033
        return section;
3034
    }
3035

    
3036

    
3037
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3038
			ICdmFormElement parentElement, int style) {
3039
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3040
		addAndAdaptElement(parentElement, section);
3041
        return section;
3042
	}
3043

    
3044
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3045
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3046
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3047
	        addAndAdaptSection(formElement, section);
3048
	        return section;
3049
	}
3050

    
3051

    
3052

    
3053
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3054
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3055
//				 initialText, textHeight, style);
3056
//	        adapt(element);
3057
//	        parentElement.addElement(element);
3058
//	        return element;
3059
//	}
3060

    
3061

    
3062

    
3063

    
3064

    
3065

    
3066

    
3067
}
(7-7/45)