Project

General

Profile

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

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

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

    
362
    private BoldFontHolder2 boldFontHolder2;
363
    private MouseListener selectionMouseHandler;
364
    private FocusListener selectionFocusHandler;
365

    
366
    @Inject
367
    private IEclipseContext context;
368

    
369
    private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
370

    
371
    private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
372

    
373
    private final int orientation = Window.getDefaultOrientation();
374
    private ISelectionProvider selectionProvider;
375

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

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

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

    
410
    private void notifySelectionListeners(TypedEvent e) {
411
        Event event = new Event();
412
        event.widget = e.widget;
413
        SelectionEvent selectionEvent = new SelectionEvent(event);
414

    
415
        for (SelectionListener listener : selectionListenerList) {
416
            listener.widgetSelected(selectionEvent);
417
        }
418
    }
419

    
420
    public CdmFormFactory(Display display) {
421
        this(display, null);
422
    }
423

    
424
    public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
425
        super(display);
426
        this.selectionProvider = selectionProvider;
427
        init();
428
    }
429

    
430
    private void init() {
431
        boldFontHolder2 = new BoldFontHolder2();
432
        selectionMouseHandler = new SelectionMouseHandler();
433
        selectionFocusHandler = new SelectionFocusHandler();
434
    }
435

    
436
    public IEclipseContext getContext() {
437
        return context;
438
    }
439

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

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

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

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

    
504
    /** {@inheritDoc} */
505
    @Override
506
    public void adapt(Composite composite) {
507
        composite.addMouseListener(selectionMouseHandler);
508

    
509
        super.adapt(composite);
510
    }
511

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

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

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

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

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

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

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

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

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

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

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

    
777
    /**
778
	 * Creates a text as a part of the form.
779
	 *
780
	 * @param parent
781
	 *            the text parent
782
	 * @param value
783
	 *            the text initial value
784
	 * @param style
785
	 *            the text style
786
	 * @return the text widget
787
	 */
788
	public RichTextEditor createRichTextEditor(Composite parent, String value, int style) {
789
		RichTextEditorConfiguration config = new RichTextEditorConfiguration();
790
//		config.setResizable(true);
791
		config.setToolbarCollapsible(true);
792
		config.setToolbarInitialExpanded(false);
793
		config.setOption("allowedContent", Boolean.TRUE);
794
	
795
		RichTextEditor text = new RichTextEditor(parent, config, super.getBorderStyle() | style | orientation);
796

    
797
		if (value != null) {
798
            text.setText(value);
799
        }
800
		text.setForeground(getColors().getForeground());
801
		text.setBackground(getColors().getBackground());
802

    
803
		return text;
804
	}
805

    
806
    public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
807
            int textHeight, int style) {
808
        TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
809
        adapt(element);
810
        parentElement.addElement(element);
811
        return element;
812
    }
813

    
814
    public LsidWithExceptionLabelElement createLsidWithExceptionLabelElement(ICdmFormElement parentElement, String labelString,
815
            LSID initialLsid, int style) {
816
        LsidWithExceptionLabelElement element = new LsidWithExceptionLabelElement(this, parentElement, labelString, initialLsid, null, style);
817
        adapt(element);
818
        parentElement.addElement(element);
819
        return element;
820
    }
821

    
822
    public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
823
            URI initialUri, int style) {
824
        UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
825
        adapt(element);
826
        parentElement.addElement(element);
827
        return element;
828
    }
829

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

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

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

    
891
    public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
892
            String labelString, LanguageString languageString, int style) {
893
        return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
894
    }
895

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

    
913

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

    
950
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
951
            TermType termType,
952
            ICdmFormElement parentElement,
953
            String labelString,
954
            T selection,
955
            int style,
956
            Comparator<T> comparator) {
957
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false, comparator);
958
    }
959

    
960
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
961
			TermType termType,
962
			ICdmFormElement parentElement,
963
			String labelString,
964
			T selection,
965
			boolean addEmptyElement,
966
			int style) {
967
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, false, null);
968
	}
969

    
970
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
971
			TermType termType,
972
			ICdmFormElement parentElement,
973
			String labelString,
974
			T selection,
975
			int style) {
976
		return  this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false, null);
977
	}
978
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
979
			TermType termType,
980
			ICdmFormElement parentElement,
981
			String labelString,
982
			T selection,
983
			boolean addEmptyElement,
984
			int style,
985
			boolean useAbbrevLabel) {
986
		return createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
987
	}
988

    
989

    
990
    public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
991
            TermVocabulary<?> termVocabulary,
992
            ICdmFormElement parentElement,
993
            String labelString,
994
            T selection,
995
            int style) {
996
        return this.createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, true, style, false, null);
997
    }
998

    
999
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1000
	        TermVocabulary<?> termVocabulary,
1001
	        ICdmFormElement parentElement,
1002
	        String labelString,
1003
	        T selection,
1004
	        boolean addEmptyElement,
1005
	        int style,
1006
	        boolean useAbbrevLabel) {
1007
	    return createDefinedTermComboElement(null, termVocabulary, parentElement, labelString, selection, addEmptyElement, style, useAbbrevLabel, null);
1008
	}
1009

    
1010
	private <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
1011
	        TermType termType,
1012
	        TermVocabulary<?> termVocabulary,
1013
	        ICdmFormElement parentElement,
1014
	        String labelString,
1015
	        T selection,
1016
	        boolean addEmptyElement,
1017
	        int style,
1018
	        boolean useAbbrevLabel,
1019
	        Comparator<T> comparator) {
1020
	    if(termType!=null){
1021
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1022
	        adapt(element);
1023
	        parentElement.addElement(element);
1024
	        return element;
1025
	    }
1026
	    else if(termVocabulary!=null){
1027
	        TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, addEmptyElement, style, useAbbrevLabel, comparator);
1028
	        if (comparator!= null){
1029
	        	element.setTermComparator(comparator);
1030
	        }
1031
	        adapt(element);
1032
	        parentElement.addElement(element);
1033
	        return element;
1034
	    }
1035
	    else{
1036
	        //this should never happen
1037
	        return null;
1038
	    }
1039
	}
1040

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

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

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

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

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

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

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

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

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

    
1179
        if (section.getToggle() != null) {
1180
            section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1181
            section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1182
        }
1183

    
1184
        section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1185

    
1186
        if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1187
                || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1188
            getColors().initializeSectionToolBarColors();
1189
            section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1190
            section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1191
        }
1192
        // call setTitleBarForeground regardless as it also sets the label color
1193
        section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1194
        return section;
1195
    }
1196

    
1197
    private class BoldFontHolder2 {
1198
        private Font normalFont;
1199

    
1200
        private Font boldFont;
1201

    
1202
        public BoldFontHolder2() {
1203
        }
1204

    
1205
        public Font getBoldFont(Font font) {
1206
            createBoldFont(font);
1207
            return boldFont;
1208
        }
1209

    
1210
        private void createBoldFont(Font font) {
1211
            if (normalFont == null || !normalFont.equals(font)) {
1212
                normalFont = font;
1213
                dispose();
1214
            }
1215
            if (boldFont == null) {
1216
                boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1217
            }
1218
        }
1219

    
1220
        public void dispose() {
1221
            if (boldFont != null) {
1222
                FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1223
                boldFont = null;
1224
            }
1225
        }
1226
    }
1227

    
1228
    /**
1229
     * <p>
1230
     * createToggleableTextField
1231
     * </p>
1232
     *
1233
     * @param parentElement
1234
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1235
     *            object.
1236
     * @param labelString
1237
     *            a {@link java.lang.String} object.
1238
     * @param initialText
1239
     *            a {@link java.lang.String} object.
1240
     * @param initialState
1241
     *            a boolean.
1242
     * @param style
1243
     *            a int.
1244
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1245
     *         object.
1246
     */
1247
    public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1248
            String initialText, boolean initialState, int style) {
1249
        ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1250
                initialState, style | orientation);
1251
        adapt(element);
1252
        parentElement.addElement(element);
1253
        return element;
1254
    }
1255

    
1256
    /**
1257
     * <p>
1258
     * createTimePeriodElement
1259
     * </p>
1260
     *
1261
     * @param parentElement
1262
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1263
     *            object.
1264
     * @param labelString
1265
     *            a {@link java.lang.String} object.
1266
     * @param timePeriod
1267
     *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1268
     * @param style
1269
     *            a int.
1270
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1271
     *         object.
1272
     */
1273
    public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1274
            TimePeriod timePeriod, int style) {
1275
        TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1276
        adapt(element);
1277
        parentElement.addElement(element);
1278
        return element;
1279
    }
1280

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

    
1315
    /**
1316
     * <p>
1317
     * createPointElement
1318
     * </p>
1319
     *
1320
     * @param style
1321
     *            a int.
1322
     * @param parentElement
1323
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1324
     *            object.
1325
     * @param point
1326
     *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1327
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1328
     */
1329
    public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1330
        PointElement element = new PointElement(this, parentElement, point, style);
1331
        adapt(element);
1332
        parentElement.addElement(element);
1333
        return element;
1334
    }
1335

    
1336

    
1337

    
1338
    /**
1339
     * @param conversationHolder
1340
     * @param parent
1341
     * @param detailsViewer
1342
     * @param i
1343
     * @return
1344
     */
1345
    public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1346
        EmptySection section = new EmptySection(formFactory, parentElement, style);
1347
        parentElement.addElement(section);
1348
        adapt(section);
1349
        return section;
1350
    }
1351

    
1352
    /**
1353
     * <p>
1354
     * createDateDetailSection
1355
     * </p>
1356
     *
1357
     * @param parentElement
1358
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1359
     *            object.
1360
     * @param style
1361
     *            a int.
1362
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1363
     *         object.
1364
     */
1365
    public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1366
        DateDetailSection section = new DateDetailSection(this, parentElement, style);
1367
        parentElement.addElement(section);
1368
        adapt(section);
1369
        return section;
1370
    }
1371

    
1372
	/**
1373
	 * <p>
1374
	 * createDateDetailSection
1375
	 * </p>
1376
	 *
1377
	 * @param parentElement
1378
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1379
	 *            object.
1380
	 * @param style
1381
	 *            a int.
1382
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1383
	 *         object.
1384
	 */
1385
	public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1386
		MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1387
		parentElement.addElement(section);
1388
		adapt(section);
1389
		return section;
1390
	}
1391

    
1392
    /**
1393
     * <p>
1394
     * createPartialElement
1395
     * </p>
1396
     *
1397
     * @param parentElement
1398
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1399
     *            object.
1400
     * @param labelString
1401
     *            a {@link java.lang.String} object.
1402
     * @param partial
1403
     *            a {@link org.joda.time.Partial} object.
1404
     * @param style
1405
     *            a int.
1406
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1407
     *         object.
1408
     */
1409
    public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1410
            int style) {
1411
        PartialElement element = new PartialElement(this, parentElement, labelString, style);
1412
        adapt(element);
1413
        parentElement.addElement(element);
1414
        return element;
1415
    }
1416

    
1417
    /**
1418
     * <p>
1419
     * addSelectionListener
1420
     * </p>
1421
     *
1422
     * @param listener
1423
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1424
     */
1425
    public void addSelectionListener(SelectionListener listener) {
1426
        selectionListenerList.add(listener);
1427
    }
1428

    
1429
    /**
1430
     * <p>
1431
     * removeSelectionListener
1432
     * </p>
1433
     *
1434
     * @param listener
1435
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
1436
     */
1437
    public void removeSelectionListener(SelectionListener listener) {
1438
        if (listener == null) {
1439
            MessagingUtils.error(this.getClass(),
1440
                    "Tried to remove a selection listener from this factories listeners but was null", null);
1441
        } else {
1442
            selectionListenerList.remove(listener);
1443
        }
1444
    }
1445

    
1446
    /**
1447
     * <p>
1448
     * addPropertyChangeListener
1449
     * </p>
1450
     *
1451
     * @param listener
1452
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1453
     *            object.
1454
     */
1455
    public void addPropertyChangeListener(IPropertyChangeListener listener) {
1456
        if (propertyChangeListeners.contains(listener)) {
1457
            return;
1458
        }
1459
        propertyChangeListeners.add(0, listener);
1460
    }
1461

    
1462
    /**
1463
     * <p>
1464
     * removePropertyChangeListener
1465
     * </p>
1466
     *
1467
     * @param listener
1468
     *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1469
     *            object.
1470
     */
1471
    public void removePropertyChangeListener(IPropertyChangeListener listener) {
1472
        propertyChangeListeners.remove(listener);
1473
    }
1474

    
1475
    /**
1476
     * @return the propertyChangeListeners
1477
     */
1478
    public List<IPropertyChangeListener> getPropertyChangeListeners() {
1479
        return propertyChangeListeners;
1480
    }
1481

    
1482
    /**
1483
     * <p>
1484
     * createHorizontalSeparator
1485
     * </p>
1486
     *
1487
     * @param parentElement
1488
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1489
     *            object.
1490
     * @param style
1491
     *            a int.
1492
     * @return a {@link org.eclipse.swt.widgets.Label} object.
1493
     */
1494
    public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1495
        Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1496
        separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1497
        return separator;
1498
    }
1499

    
1500
    /**
1501
     * <p>
1502
     * createVersionElement
1503
     * </p>
1504
     *
1505
     * @param parentElement
1506
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1507
     *            object.
1508
     * @param entity
1509
     *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1510
     *            object.
1511
     * @param style
1512
     *            a int.
1513
     * @return a
1514
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1515
     *         object.
1516
     */
1517
    public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1518
        VersionElement element = new VersionElement(this, parentElement, entity, style);
1519
        adapt(element);
1520
        parentElement.addElement(element);
1521
        return element;
1522
    }
1523

    
1524
    /**
1525
     * @param cdmBaseSection
1526
     * @param object
1527
     * @param style
1528
     * @return
1529
     */
1530
    public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1531
        CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1532
        adapt(element);
1533
        parentElement.addElement(element);
1534
        return element;
1535
    }
1536

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

    
1558
    /**
1559
     * @param parent
1560
     * @param i
1561
     * @return
1562
     */
1563
    public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1564
        CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1565
        parentElement.addElement(section);
1566
        adapt(section);
1567
        return section;
1568
    }
1569

    
1570
    /**
1571
     * <p>
1572
     * createEmptyElement
1573
     * </p>
1574
     *
1575
     * @param parentElement
1576
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1577
     *            object.
1578
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1579
     */
1580
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1581
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1582
        adapt(element);
1583
        parentElement.addElement(element);
1584
        return element;
1585
    }
1586

    
1587
    /**
1588
     * <p>
1589
     * createHeadlineSection
1590
     * </p>
1591
     *
1592
     * @param parentElement
1593
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1594
     *            object.
1595
     * @return a
1596
     *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1597
     *         object.
1598
     */
1599
    public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1600
        HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1601
        parentElement.addElement(section);
1602
        adapt(section);
1603
        return section;
1604
    }
1605

    
1606
    /**
1607
     * <p>
1608
     * createParsingMessageElement
1609
     * </p>
1610
     *
1611
     * @param parentElement
1612
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1613
     *            object.
1614
     * @param parserProblem
1615
     *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1616
     *            object.
1617
     * @param style
1618
     *            a int.
1619
     * @return a
1620
     *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1621
     *         object.
1622
     */
1623
    public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1624
            ParserProblem parserProblem, int style) {
1625
        ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1626
        adapt(element);
1627
        parentElement.addElement(element);
1628
        return element;
1629
    }
1630

    
1631
    public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1632
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1633

    
1634
        AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1635
                selectionProvider, style);
1636

    
1637
        parentElement.addElement(section);
1638
        adapt(section);
1639
        return section;
1640

    
1641
    }
1642

    
1643
    /**
1644
     * @param definedTermClass
1645
     * @param formElement
1646
     * @param style
1647
     * @return
1648
     */
1649
    public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1650
            AbstractCdmDetailSection parentElement, int style) {
1651
        AbstractCdmDetailElement element = null;
1652

    
1653
        if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1654
            element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1655
        } else if (definedTermClass.equals(Feature.class)) {
1656
            element = new FeatureDetailElement(this, parentElement);
1657
        } else if(definedTermClass.equals(PresenceAbsenceTerm.class)){
1658
            element = new PresenceAbsenceTermDetailElement(this, parentElement);
1659
        } else {
1660
            element = new DefinedTermDetailElement(this, parentElement);
1661
        }
1662

    
1663

    
1664
        adapt(element);
1665
        parentElement.addElement(element);
1666
        return element;
1667
    }
1668

    
1669

    
1670
    //--------DetailSections---------
1671
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1672
        NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1673
        addAndAdaptSection(parentElement, section);
1674
        return section;
1675
    }
1676

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

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

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

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

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

    
1707
    public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1708
        TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1709
        addAndAdaptSection(parentElement, section);
1710
        return section;
1711
    }
1712

    
1713
    public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1714
        PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1715
        addAndAdaptSection(parentElement, section);
1716
        return section;
1717
    }
1718

    
1719
    public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1720
        DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1721
        addAndAdaptSection(parentElement, section);
1722
        return section;
1723
    }
1724

    
1725
    public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1726
        DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1727
        addAndAdaptSection(parentElement, section);
1728
        return section;
1729
    }
1730

    
1731
    public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1732
        ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1733
        addAndAdaptSection(parentElement, section);
1734
        return section;
1735
    }
1736

    
1737

    
1738

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1967
    public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1968
        TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style, true);
1969
        addAndAdaptSection(parentElement, section);
1970
        return section;
1971
    }
1972

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

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

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

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

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

    
2003
    private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
2004
        parentElement.addElement(section);
2005
        adapt(section);
2006
    }
2007

    
2008
    //--------DetailElements------------
2009

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

    
2016
    public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
2017
        DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
2018
        addAndAdaptElement(parentElement, element);
2019
        return element;
2020
    }
2021

    
2022
    public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
2023
        eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
2024
        addAndAdaptElement(parentElement, element);
2025
        return element;
2026
    }
2027

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

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

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

    
2046
    public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
2047
        GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
2048
        addAndAdaptElement(parentElement, element);
2049
        return element;
2050
    }
2051

    
2052
    public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
2053
        GroupDetailElement element = new GroupDetailElement(this, parentElement);
2054
        addAndAdaptElement(parentElement, element);
2055
        return element;
2056
    }
2057

    
2058
    public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
2059
        UserDetailElement element = new UserDetailElement(this, parentElement);
2060
        addAndAdaptElement(parentElement, element);
2061
        return element;
2062
    }
2063

    
2064
    public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
2065
        HybridDetailElement element = new HybridDetailElement(this, parentElement);
2066
        addAndAdaptElement(parentElement, element);
2067
        return element;
2068
    }
2069

    
2070
    public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
2071
        InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
2072
        addAndAdaptElement(parentElement, element);
2073
        return element;
2074
    }
2075

    
2076
    public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
2077
        PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
2078
        addAndAdaptElement(parentElement, element);
2079
        return element;
2080
    }
2081

    
2082
    public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
2083
        PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
2084
        addAndAdaptElement(parentElement, element);
2085
        return element;
2086
    }
2087

    
2088
    public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
2089
        CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
2090
        addAndAdaptElement(parentElement, element);
2091
        return element;
2092
    }
2093

    
2094
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionElement(ICdmFormElement parentElement, ConversationHolder conversation, int style){
2095
        TaxonNodeAgentRelationCollectionSection element = new TaxonNodeAgentRelationCollectionSection(this, conversation, parentElement, style);
2096
        adapt(element);
2097
        parentElement.addElement(element);
2098

    
2099
        return element;
2100
    }
2101

    
2102
    public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement, boolean createNew){
2103
        TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement, createNew);
2104
        addAndAdaptElement(parentElement, element);
2105
        return element;
2106
    }
2107

    
2108
    public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
2109
        ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
2110
        addAndAdaptElement(parentElement, element);
2111
        return element;
2112
    }
2113

    
2114
    public CloneClassificationDetailElement createCloneClassificationDetailElement(ICdmFormElement parentElement){
2115
        CloneClassificationDetailElement element = new CloneClassificationDetailElement(this, parentElement);
2116
        addAndAdaptElement(parentElement, element);
2117
        return element;
2118
    }
2119

    
2120
    public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
2121
        FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
2122
        addAndAdaptElement(parentElement, element);
2123
        return element;
2124
    }
2125

    
2126
    public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
2127
        NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
2128
        addAndAdaptElement(parentElement, element);
2129
        return element;
2130
    }
2131

    
2132
    public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
2133
        NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
2134
        addAndAdaptElement(parentElement, element);
2135
        return element;
2136
    }
2137

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

    
2144
    public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
2145
        DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
2146
        addAndAdaptElement(parentElement, element);
2147
        return element;
2148
    }
2149

    
2150
    public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
2151
        PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
2152
        addAndAdaptElement(parentElement, element);
2153
        return element;
2154
    }
2155

    
2156
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
2157
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
2158
        addAndAdaptElement(parentElement, element);
2159
        return element;
2160
    }
2161

    
2162
    public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
2163
        AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
2164
        addAndAdaptElement(parentElement, element);
2165
        return element;
2166
    }
2167

    
2168
    public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
2169
        TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
2170
        addAndAdaptElement(parentElement, element);
2171
        return element;
2172
    }
2173

    
2174
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2175
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2176
        addAndAdaptElement(parentElement, element);
2177
        return element;
2178
    }
2179

    
2180
    public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style, boolean isWizard){
2181
        ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style, isWizard);
2182
        addAndAdaptElement(parentElement, element);
2183
        return element;
2184
    }
2185

    
2186
    public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2187
        NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2188
        addAndAdaptElement(parentElement, element);
2189
        return element;
2190
    }
2191

    
2192
//    public IntextReferenceDetailElement createIntextReferenceDetailElement(ICdmFormElement parentElement, LanguageStringWithLabelElement referencedElement, int style) {
2193
//    	IntextReferenceDetailElement element = new IntextReferenceDetailElement(this, parentElement, referencedElement, null, element, null, style);
2194
//         addAndAdaptElement(parentElement, element);
2195
//         return element;
2196
//	}
2197

    
2198

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2295
    public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2296
        MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2297
        addAndAdaptElement(parentElement, mediaDetailElement);
2298
        return mediaDetailElement;
2299
    }
2300

    
2301
    public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2302
        GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2303
        addAndAdaptElement(parentElement, element);
2304
        return element;
2305
    }
2306

    
2307
    public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2308
        FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2309
        addAndAdaptElement(parentElement, element);
2310
        return element;
2311
    }
2312

    
2313
    public SpecimenHierarchyDetailElement createSpecimenHierarchyDetailElement(ICdmFormElement parentElement) {
2314
        SpecimenHierarchyDetailElement element = new SpecimenHierarchyDetailElement(this, parentElement);
2315
        addAndAdaptElement(parentElement, element);
2316
        return element;
2317
    }
2318

    
2319
    public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2320
        DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2321
        addAndAdaptElement(parentElement, element);
2322
        return element;
2323
    }
2324

    
2325
    public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2326
        OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2327
        addAndAdaptElement(parentElement, element);
2328
        return element;
2329
    }
2330

    
2331
    public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2332
        PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2333
        addAndAdaptElement(parentElement, element);
2334
        return element;
2335
    }
2336

    
2337
    public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2338
        DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2339
        addAndAdaptElement(parentElement, element);
2340
        return element;
2341
    }
2342

    
2343
    public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2344
        SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2345
        addAndAdaptElement(parentElement, element);
2346
        return element;
2347
    }
2348

    
2349
    /**
2350
     * @param parentElement
2351
     * @param element
2352
     */
2353
    private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2354
        adapt(element);
2355
        parentElement.addElement(element);
2356
    }
2357

    
2358
    //--------EntityCollectionSection----------
2359
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2360
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2361
        addAndAdaptSection(parentElement, section);
2362
        return section;
2363
    }
2364

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2587
    public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2588
        PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2589
        addAndAdaptSection(parentElement, section);
2590
        return section;
2591
    }
2592

    
2593
    public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2594
        SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2595
        addAndAdaptSection(parentElement, section);
2596
        return section;
2597
    }
2598

    
2599
    public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2600
        ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2601
        addAndAdaptSection(parentElement, section);
2602
        return section;
2603
    }
2604

    
2605
    public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2606
        MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2607
        addAndAdaptSection(parentElement, section);
2608
        return section;
2609
    }
2610

    
2611
    public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2612
        GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2613
        addAndAdaptSection(parentElement, section);
2614
        return section;
2615
    }
2616

    
2617
    public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2618
        GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2619
        addAndAdaptSection(parentElement, section);
2620
        return section;
2621
    }
2622

    
2623
    public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2624
        TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2625
        addAndAdaptSection(parentElement, section);
2626
        return section;
2627
    }
2628

    
2629

    
2630
    public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2631
            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2632
        AbstractEntityCollectionElement element = null;
2633

    
2634
        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2635

    
2636
        if (entity instanceof Annotation) {
2637
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2638
        }else if (entity instanceof Person ) {
2639
            boolean isNomenclatural = false;
2640
            if (parentElement instanceof TeamMemberSection){
2641
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2642
            }
2643
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2644
        } else if (entity instanceof Credit) {
2645
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2646
        } else if (entity instanceof Extension) {
2647
            element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2648
        } else if (entity instanceof Marker) {
2649
            element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2650
        } else if (entity instanceof TaxonNodeAgentRelation) {
2651
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity, removeListener, backgroundColor, style);
2652
        }else if (entity instanceof Media) {
2653
            element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, style);
2654
        } else if (entity instanceof MediaRepresentation) {
2655
            element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2656
                    style);
2657
        } else if (entity instanceof ImageFile) {
2658
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2659
        } else if (entity instanceof MediaRepresentationPart) {
2660
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2661
                    removeListener, style);
2662
        } else if (entity instanceof NomenclaturalStatus) {
2663
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2664
                    style);
2665
        } else if (entity instanceof Rights) {
2666
            element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2667
        } else if (entity instanceof DescriptionElementSource) {
2668
            element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2669
                    removeListener, style);
2670
        }else if (entity instanceof IntextReference) {
2671
        	if (parentElement instanceof IntextReferenceSection){
2672
        		ILanguageStringProvider langElement = ((IntextReferenceSection)parentElement).getlangStringElement();
2673
        		element = new IntextReferenceDetailElement(this, parentElement, langElement, (IntextReference) entity,removeListener, null,style);
2674
        	}
2675

    
2676
        } else if (entity instanceof TaxonNodeAgentRelation) {
2677
            element = new TaxonNodeAgentRelationCollectionElement(this, parentElement, (TaxonNodeAgentRelation) entity,
2678
                    removeListener,backgroundColor, style);
2679
        }
2680
        else if (entity instanceof IdentifiableSource) {
2681
            element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2682
                    style);
2683
        } else if (entity instanceof DefinedTerm) {
2684
            switch(((DefinedTerm)entity).getTermType()) {
2685
            case Scope:
2686
                element = new ScopeElement(this,
2687
                        parentElement,
2688
                        (DefinedTerm) entity,
2689
                        removeListener,
2690
                        style);
2691
                break;
2692
            case Modifier:
2693
                element = new ModifierElement(this,
2694
                        parentElement,
2695
                        (DefinedTerm) entity,
2696
                        removeListener,
2697
                        style);
2698
                break;
2699
            default:
2700
                break;
2701

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

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

    
2794
        //check for parent section when entity is null
2795
        //this happens when AbstractUnboundEntityCollectionSection is used
2796
        if(entity==null){
2797
            if(parentElement instanceof ScopeSection || parentElement instanceof ScopeRestrictionSection){
2798
                element = new ScopeElement(this,
2799
                        parentElement,
2800
                        (DefinedTerm) entity,
2801
                        removeListener,
2802
                        style);
2803
            }
2804
            else if(parentElement instanceof ModifierSection){
2805
                element = new ModifierElement(this,
2806
                        parentElement,
2807
                        (DefinedTerm) entity,
2808
                        removeListener,
2809
                        style);
2810
            }
2811
        }
2812

    
2813

    
2814
        if (element == null) {
2815
            MessagingUtils.messageDialog("No element for entity", this,
2816
                    "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2817
                            + entity, null);
2818
        }
2819

    
2820
        else{
2821
            if (backgroundColor != null && !backgroundColor.isDisposed()) {
2822
                element.setPersistentBackground(backgroundColor);
2823
            }
2824
            adapt(element);
2825
            parentElement.addElement(element);
2826
        }
2827

    
2828
        return element;
2829
    }
2830

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

    
2874
    public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2875
//            ConversationHolder conversation,
2876
            ICdmFormElement parentElement, String labelString, T selection, int mode,
2877
            int style) {
2878
        EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
2879
                parentElement, clazz,
2880
                labelString, selection, mode, style);
2881
        adapt(element);
2882
        parentElement.addElement(element);
2883
        return element;
2884
    }
2885

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

    
2929
    public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2930
            ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2931
        TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
2932
                parentElement,
2933
                labelString, selection, mode, style);
2934
        adapt(element);
2935
        parentElement.addElement(element);
2936
        return element;
2937
    }
2938

    
2939
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2940
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2941
//            int mode, int style) {
2942
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2943
//                conversation, parentElement, labelString, selection, mode, style);
2944
//        adapt(element);
2945
//        parentElement.addElement(element);
2946
//        return element;
2947
//    }
2948

    
2949
    /** {@inheritDoc} */
2950
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2951
        LabelElement labelElement = new LabelElement(this, parentElement, text);
2952
        adapt(labelElement);
2953
        parentElement.addElement(labelElement);
2954
        return labelElement;
2955
    }
2956

    
2957
//    public DateElementFormElement createDateElementForm(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2958
//        Label label = new Label(formElement.getLayoutComposite(), style);
2959
//        label.setText(labelText+" (yyyy-MM-dd)");
2960
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
2961
//        dateElement.initInternalController();
2962
//
2963
//        return dateElement;
2964
//    }
2965

    
2966
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
2967
    	 Label label = new Label(formElement.getLayoutComposite(), style);
2968
         label.setText(labelText);
2969
         label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2970
         DateElement dateElement = new DateElement(this, formElement.getLayoutComposite(), dateTime, labelText, style, editableText);
2971
         dateElement.initController(this, formElement);
2972
         dateElement.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
2973
         return dateElement;
2974
    }
2975

    
2976
    /**
2977
     * <p>
2978
     * Getter for the field <code>selectionProvider</code>.
2979
     * </p>
2980
     *
2981
     * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2982
     */
2983
    public ISelectionProvider getSelectionProvider() {
2984
        return selectionProvider;
2985
    }
2986

    
2987
    /**
2988
     * <p>
2989
     * createDetailedDescriptionDetailElement
2990
     * </p>
2991
     *
2992
     * @param parentElement
2993
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2994
     *            object.
2995
     * @param entity
2996
     *            a
2997
     *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2998
     *            object.
2999
     * @param style
3000
     *            a int.
3001
     * @return a
3002
     *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
3003
     *         object.
3004
     */
3005
    public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
3006
            ICdmFormElement parentElement, DescriptionElementBase entity, int style, boolean enabled) {
3007
        AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
3008

    
3009
        if (entity instanceof CategoricalData) {
3010
            detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
3011
                    (CategoricalData) entity, style);
3012
        } else if (entity instanceof CommonTaxonName) {
3013
            detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
3014
                    style);
3015
        } else if (entity instanceof Distribution && !enabled) {
3016
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3017
                    style);
3018
            detailedDescriptionElement.setEnabled(enabled);
3019
        } else if (entity instanceof Distribution) {
3020
            detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
3021
                    style);
3022
        }else if (entity instanceof IndividualsAssociation) {
3023
            detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
3024
                    (IndividualsAssociation) entity, style);
3025
        } else if (entity instanceof QuantitativeData) {
3026
            detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
3027
                    (QuantitativeData) entity, style);
3028
        } else if (entity instanceof TaxonInteraction) {
3029
            detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
3030
                    (TaxonInteraction) entity, style);
3031
        } else if (entity instanceof TextData) {
3032
            detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
3033
        } else {
3034
            throw new IllegalStateException("There is no interface for the given description element");
3035
        }
3036
        adapt(detailedDescriptionElement);
3037
        parentElement.addElement(detailedDescriptionElement);
3038
        return detailedDescriptionElement;
3039

    
3040
    }
3041

    
3042
    /**
3043
     * Creates a styled text as a part of the form.
3044
     *
3045
     * @param parent
3046
     *            the text parent
3047
     * @param value
3048
     *            the text initial value
3049
     * @param style
3050
     *            the text style
3051
     * @return the text widget
3052
     */
3053
    public StyledText createStyledText(Composite parent, String value, int style) {
3054
        StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
3055
        if (value != null) {
3056
            text.setText(value);
3057
        }
3058
        text.setForeground(getColors().getForeground());
3059
        text.setBackground(getColors().getBackground());
3060
        // text.addFocusListener(visibilityHandler);
3061
        return text;
3062
    }
3063

    
3064
    public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
3065
        PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
3066
        addAndAdaptSection(parentElement, section);
3067
        return section;
3068
    }
3069

    
3070
    /**
3071
     * @param formElement
3072
     * @param conversationHolder
3073
     * @param style
3074
     * @return
3075
     */
3076
    public TaxonNodeAgentRelationCollectionSection createTaxonNodeAgentRelationCollectionSection(
3077
            ICdmFormElement formElement, ConversationHolder conversationHolder, int style) {
3078
        TaxonNodeAgentRelationCollectionSection section = new TaxonNodeAgentRelationCollectionSection(this, conversationHolder, formElement, style);
3079
        addAndAdaptSection(formElement, section);
3080
        return section;
3081
    }
3082

    
3083

    
3084
	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, LanguageString initialText, int textHeight, int style) {
3085
		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3086
				 initialText, textHeight, 0, true, style);
3087

    
3088
	        adapt(element);
3089
	        parentElement.addElement(element);
3090
	        return element;
3091
	}
3092

    
3093

    
3094
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3095
			ICdmFormElement parentElement, int style) {
3096
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
3097
		addAndAdaptElement(parentElement, section);
3098
        return section;
3099
	}
3100

    
3101
	public TaxonDetailSection createTaxonDetailSection(ConversationHolder conversationHolder,
3102
			ICdmFormElement formElement, ISelectionProvider selectionProvider, int style) {
3103
			TaxonDetailSection section = new TaxonDetailSection(this, conversationHolder, formElement, selectionProvider, style);
3104
	        addAndAdaptSection(formElement, section);
3105
	        return section;
3106
	}
3107

    
3108

    
3109

    
3110
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
3111
//		 RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
3112
//				 initialText, textHeight, style);
3113
//	        adapt(element);
3114
//	        parentElement.addElement(element);
3115
//	        return element;
3116
//	}
3117

    
3118

    
3119

    
3120

    
3121

    
3122

    
3123

    
3124

    
3125
}
(7-7/47)