0ec1e7d2b8a032ea9264b094baac5a0e4b8fcef0
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / element / CdmFormFactory.java
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.HashSet;
9 import java.util.List;
10 import java.util.Map;
11 import java.util.Set;
12
13 import org.eclipse.jface.util.IPropertyChangeListener;
14 import org.eclipse.jface.viewers.ISelection;
15 import org.eclipse.jface.viewers.ISelectionProvider;
16 import org.eclipse.jface.window.Window;
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.custom.StyledText;
19 import org.eclipse.swt.events.FocusAdapter;
20 import org.eclipse.swt.events.FocusEvent;
21 import org.eclipse.swt.events.FocusListener;
22 import org.eclipse.swt.events.MouseAdapter;
23 import org.eclipse.swt.events.MouseEvent;
24 import org.eclipse.swt.events.MouseListener;
25 import org.eclipse.swt.events.SelectionEvent;
26 import org.eclipse.swt.events.SelectionListener;
27 import org.eclipse.swt.events.TypedEvent;
28 import org.eclipse.swt.graphics.Color;
29 import org.eclipse.swt.graphics.Font;
30 import org.eclipse.swt.widgets.Composite;
31 import org.eclipse.swt.widgets.Control;
32 import org.eclipse.swt.widgets.Display;
33 import org.eclipse.swt.widgets.Event;
34 import org.eclipse.swt.widgets.Label;
35 import org.eclipse.ui.forms.IFormColors;
36 import org.eclipse.ui.forms.widgets.ExpandableComposite;
37 import org.eclipse.ui.forms.widgets.FormToolkit;
38 import org.eclipse.ui.forms.widgets.Section;
39 import org.eclipse.ui.internal.forms.widgets.FormFonts;
40 import org.joda.time.DateTime;
41 import org.joda.time.Partial;
42 import org.springframework.security.core.GrantedAuthority;
43
44 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
45 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
46 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
47 import eu.etaxonomy.cdm.model.agent.Person;
48 import eu.etaxonomy.cdm.model.agent.Team;
49 import eu.etaxonomy.cdm.model.common.Annotation;
50 import eu.etaxonomy.cdm.model.common.CdmBase;
51 import eu.etaxonomy.cdm.model.common.Credit;
52 import eu.etaxonomy.cdm.model.common.DefinedTerm;
53 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
54 import eu.etaxonomy.cdm.model.common.Extension;
55 import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
56 import eu.etaxonomy.cdm.model.common.Group;
57 import eu.etaxonomy.cdm.model.common.ICdmBase;
58 import eu.etaxonomy.cdm.model.common.IEnumTerm;
59 import eu.etaxonomy.cdm.model.common.IdentifiableSource;
60 import eu.etaxonomy.cdm.model.common.Identifier;
61 import eu.etaxonomy.cdm.model.common.Language;
62 import eu.etaxonomy.cdm.model.common.LanguageString;
63 import eu.etaxonomy.cdm.model.common.Marker;
64 import eu.etaxonomy.cdm.model.common.TermType;
65 import eu.etaxonomy.cdm.model.common.TermVocabulary;
66 import eu.etaxonomy.cdm.model.common.TimePeriod;
67 import eu.etaxonomy.cdm.model.common.User;
68 import eu.etaxonomy.cdm.model.common.VersionableEntity;
69 import eu.etaxonomy.cdm.model.description.CategoricalData;
70 import eu.etaxonomy.cdm.model.description.CommonTaxonName;
71 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
72 import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
73 import eu.etaxonomy.cdm.model.description.Distribution;
74 import eu.etaxonomy.cdm.model.description.Feature;
75 import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
76 import eu.etaxonomy.cdm.model.description.KeyStatement;
77 import eu.etaxonomy.cdm.model.description.QuantitativeData;
78 import eu.etaxonomy.cdm.model.description.StateData;
79 import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
80 import eu.etaxonomy.cdm.model.description.TaxonInteraction;
81 import eu.etaxonomy.cdm.model.description.TextData;
82 import eu.etaxonomy.cdm.model.location.NamedArea;
83 import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
84 import eu.etaxonomy.cdm.model.location.Point;
85 import eu.etaxonomy.cdm.model.media.ImageFile;
86 import eu.etaxonomy.cdm.model.media.Media;
87 import eu.etaxonomy.cdm.model.media.MediaRepresentation;
88 import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
89 import eu.etaxonomy.cdm.model.media.Rights;
90 import eu.etaxonomy.cdm.model.molecular.DnaSample;
91 import eu.etaxonomy.cdm.model.name.NameRelationship;
92 import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
93 import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
94 import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
95 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
96 import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
97 import eu.etaxonomy.cdm.model.reference.Reference;
98 import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
99 import eu.etaxonomy.cdm.model.taxon.Taxon;
100 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
101 import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
102 import eu.etaxonomy.taxeditor.model.MessagingUtils;
103 import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
104 import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
105 import eu.etaxonomy.taxeditor.ui.combo.VocabularyComboElement;
106 import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection.UnitType;
107 import eu.etaxonomy.taxeditor.ui.mvc.element.DateElement;
108 import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
109 import eu.etaxonomy.taxeditor.ui.openurl.OpenUrlSelectorElement;
110 import eu.etaxonomy.taxeditor.ui.password.EditPasswordElement;
111 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
112 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
113 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
114 import eu.etaxonomy.taxeditor.ui.section.EmptyElement;
115 import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement;
116 import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection;
117 import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailElement;
118 import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
119 import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailElement;
120 import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
121 import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
122 import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberSection;
123 import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
124 import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailElement;
125 import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailSection;
126 import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailElement;
127 import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailSection;
128 import eu.etaxonomy.taxeditor.ui.section.common.ReferenceEntityDetailElement;
129 import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
130 import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
131 import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
132 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailElement;
133 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
134 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
135 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
136 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
137 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceElement;
138 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
139 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceElement;
140 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
141 import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
142 import eu.etaxonomy.taxeditor.ui.section.description.ModifierElement;
143 import eu.etaxonomy.taxeditor.ui.section.description.ModifierSection;
144 import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageDetailElement;
145 import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
146 import eu.etaxonomy.taxeditor.ui.section.description.ScopeElement;
147 import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
148 import eu.etaxonomy.taxeditor.ui.section.description.StateDataElement;
149 import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;
150 import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueElement;
151 import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueSection;
152 import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;
153 import eu.etaxonomy.taxeditor.ui.section.description.detail.CategoricalDataDetailElement;
154 import eu.etaxonomy.taxeditor.ui.section.description.detail.CommonNameDetailElement;
155 import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
156 import eu.etaxonomy.taxeditor.ui.section.description.detail.IndividualsAssociationDetailElement;
157 import eu.etaxonomy.taxeditor.ui.section.description.detail.QuantitativeDataDetailElement;
158 import eu.etaxonomy.taxeditor.ui.section.description.detail.TaxonInteractionDetailElement;
159 import eu.etaxonomy.taxeditor.ui.section.description.detail.TextDataDetailElement;
160 import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement;
161 import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
162 import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityCollectionElement;
163 import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailElement;
164 import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
165 import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailElement;
166 import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
167 import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailElement;
168 import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
169 import eu.etaxonomy.taxeditor.ui.section.identifier.IdentifierDetailElement;
170 import eu.etaxonomy.taxeditor.ui.section.identifier.IdentifierDetailSection;
171 import eu.etaxonomy.taxeditor.ui.section.key.GeographicalScopeDetailSection;
172 import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailElement;
173 import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
174 import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailElement;
175 import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
176 import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
177 import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
178 import eu.etaxonomy.taxeditor.ui.section.media.ImageFileElement;
179 import eu.etaxonomy.taxeditor.ui.section.media.MediaDetailElement;
180 import eu.etaxonomy.taxeditor.ui.section.media.MediaMetaElement;
181 import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationElement;
182 import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartElement;
183 import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartSection;
184 import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationSection;
185 import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
186 import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
187 import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailSection;
188 import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailElement;
189 import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailSection;
190 import eu.etaxonomy.taxeditor.ui.section.name.NameDetailElement;
191 import eu.etaxonomy.taxeditor.ui.section.name.NameDetailSection;
192 import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailElement;
193 import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
194 import eu.etaxonomy.taxeditor.ui.section.name.NameTypeDesignationElement;
195 import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusElement;
196 import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
197 import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailElement;
198 import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
199 import eu.etaxonomy.taxeditor.ui.section.name.ProtologueElement;
200 import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
201 import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
202 import eu.etaxonomy.taxeditor.ui.section.name.SynonymRelationshipDetailElement;
203 import eu.etaxonomy.taxeditor.ui.section.name.SynonymRelationshipDetailSection;
204 import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
205 import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
206 import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
207 import eu.etaxonomy.taxeditor.ui.section.occurrence.CurrentDeterminationDetailSection;
208 import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailElement;
209 import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
210 import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailElement;
211 import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
212 import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement;
213 import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
214 import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement;
215 import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection;
216 import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
217 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailElement;
218 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailSection;
219 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailElement;
220 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSection;
221 import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailElement;
222 import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
223 import eu.etaxonomy.taxeditor.ui.section.occurrence.NamedAreaDetailElement;
224 import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
225 import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
226 import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElement;
227 import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailSection;
228 import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenHierarchyDetailElement;
229 import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenHierarchyDetailSection;
230 import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailElement;
231 import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
232 import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenCurrentDeterminationDetailSection;
233 import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailElement;
234 import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDetailSection;
235 import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDeterminationDetailElement;
236 import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDeterminationDetailSection;
237 import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDeterminationHistoryDetailSection;
238 import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailElement;
239 import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailSection;
240 import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenSourceCollectionDetailSection;
241 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractSampleDesignationDetailSection;
242 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailElement;
243 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailSection;
244 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoCollectionDetailSection;
245 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoDetailElement;
246 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailElement;
247 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailSection;
248 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailElement;
249 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailSection;
250 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.CurrentSampleDesignationDetailSection;
251 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailElement;
252 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
253 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailElement;
254 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
255 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.PrimerGeneralDetailElement;
256 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailElement;
257 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailSection;
258 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationHistoryDetailSection;
259 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationTextDetailElement;
260 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceContigFileCollectionDetailSection;
261 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailElement;
262 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
263 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailElement;
264 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
265 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailElement;
266 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
267 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadPherogramCollectionDetailSection;
268 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailElement;
269 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
270 import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailElement;
271 import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
272 import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
273 import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
274 import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement;
275 import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
276 import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationElement;
277 import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
278 import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseElement;
279 import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
280 import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditElement;
281 import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
282 import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionElement;
283 import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
284 import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
285 import eu.etaxonomy.taxeditor.ui.section.supplemental.IdentifiableSourceElement;
286 import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerElement;
287 import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
288 import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsElement;
289 import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
290 import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
291 import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement;
292 import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
293 import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement;
294 import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
295 import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailElement;
296 import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
297 import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailElement;
298 import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailElement;
299 import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
300 import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailElement;
301 import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
302 import eu.etaxonomy.taxeditor.ui.section.user.UserDetailElement;
303 import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
304 import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailElement;
305 import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
306 import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement;
307 import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailSection;
308 import eu.etaxonomy.taxeditor.ui.section.vocabulary.FeatureDetailElement;
309 import eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailSection;
310 import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailElement;
311 import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
312 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
313 import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
314 import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
315
316 /**
317 * <p>
318 * CdmFormFactory class.
319 * </p>
320 *
321 * @author n.hoffmann
322 * @created Feb 24, 2010
323 * @version 1.0
324 */
325 public class CdmFormFactory extends FormToolkit {
326
327 private BoldFontHolder2 boldFontHolder2;
328 private MouseListener selectionMouseHandler;
329 private FocusListener selectionFocusHandler;
330
331 private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>();
332
333 private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
334
335 private final int orientation = Window.getDefaultOrientation();
336 private ISelectionProvider selectionProvider;
337
338 /** Constant <code>EMPTY_SELECTION</code> */
339 public static ISelection EMPTY_SELECTION = new ISelection() {
340 @Override
341 public boolean isEmpty() {
342 return true;
343 }
344 };
345
346 /**
347 *
348 * @author n.hoffmann
349 * @date Jan 25, 2010
350 *
351 */
352 private class SelectionMouseHandler extends MouseAdapter {
353 @Override
354 public void mouseDown(MouseEvent e) {
355 notifySelectionListeners(e);
356 }
357 }
358
359 /**
360 *
361 * @author n.hoffmann
362 * @date Jan 25, 2010
363 *
364 */
365 private class SelectionFocusHandler extends FocusAdapter {
366 @Override
367 public void focusGained(FocusEvent e) {
368 notifySelectionListeners(e);
369 }
370 }
371
372 private void notifySelectionListeners(TypedEvent e) {
373 Event event = new Event();
374 event.widget = e.widget;
375 SelectionEvent selectionEvent = new SelectionEvent(event);
376
377 for (SelectionListener listener : selectionListenerList) {
378 listener.widgetSelected(selectionEvent);
379 }
380 }
381
382 /**
383 * <p>
384 * Constructor for CdmFormFactory.
385 * </p>
386 *
387 * @param display
388 * a {@link org.eclipse.swt.widgets.Display} object.
389 * @param selectionProvider
390 * a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
391 */
392 public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
393 super(display);
394 this.selectionProvider = selectionProvider;
395 init();
396 }
397
398 /**
399 * <p>
400 * Constructor for CdmFormFactory.
401 * </p>
402 *
403 * @param display
404 * a {@link org.eclipse.swt.widgets.Display} object.
405 */
406 public CdmFormFactory(Display display) {
407 super(display);
408 init();
409 }
410
411 /**
412 *
413 */
414 private void init() {
415 boldFontHolder2 = new BoldFontHolder2();
416 selectionMouseHandler = new SelectionMouseHandler();
417 selectionFocusHandler = new SelectionFocusHandler();
418 }
419
420 /**
421 * Creates an instance initialized with the correct selectionProvider
422 *
423 * Make sure to remove the instance when the entityComposite disposes via
424 * destroySelectionArbitrator(..)
425 *
426 * @param entityElement
427 * a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
428 * object.
429 * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
430 * object.
431 */
432 public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
433 SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
434 selectionArbitrator.addSelectionProvider(selectionProvider);
435 selectionProvider.addSelectionChangedListener(selectionArbitrator);
436 addSelectionListener(selectionArbitrator);
437 return selectionArbitrator;
438 }
439
440 /**
441 * <p>
442 * destroySelectionArbitrator
443 * </p>
444 *
445 * @param selectionArbitrator
446 * a
447 * {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
448 * object.
449 */
450 public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
451 removeSelectionListener(selectionArbitrator);
452 if (selectionProvider != null) {
453 selectionProvider.removeSelectionChangedListener(selectionArbitrator);
454 } else {
455 MessagingUtils.error(this.getClass(),
456 "Tried to destroy a selection listener from this factories listeners but was null", null);
457 }
458 }
459
460 /**
461 * <p>
462 * Adapts the {@link AbstractCdmFormElement}:<br>
463 * - sets the {@link IPropertyChangeListener}s handled by this class
464 * </p>
465 *
466 * @param formElement
467 * a
468 * {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
469 * object.
470 */
471 public void adapt(ICdmFormElement formElement) {
472 formElement.setPropertyChangeListeners(propertyChangeListeners);
473 }
474
475 /** {@inheritDoc} */
476 @Override
477 public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
478 if (trackFocus) {
479 control.addFocusListener(selectionFocusHandler);
480 }
481 super.adapt(control, trackFocus, trackKeyboard);
482 }
483
484 /** {@inheritDoc} */
485 @Override
486 public void adapt(Composite composite) {
487 composite.addMouseListener(selectionMouseHandler);
488 super.adapt(composite);
489 }
490
491 /**
492 * <p>
493 * destroyElement
494 * </p>
495 *
496 * @param formElement
497 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
498 * object.
499 */
500 public void destroyElement(ICdmFormElement formElement) {
501 // return if element was not initialized
502 if (formElement == null) {
503 return;
504 }
505 // destroy selection arbitrator, if any
506 if (formElement instanceof ISelectableElement) {
507 destroySelectionArbitrator(((ISelectableElement) formElement).getSelectionArbitrator());
508 }
509 // remove this element form its parents list of elements
510 // ICdmFormElement parentElement = formElement.getParentElement();
511 // if(parentElement != null){
512 // parentElement.removeElement(formElement);
513 // }
514 // call destroy on child elements recursively
515 for (ICdmFormElement childElement : formElement.getElements()) {
516 destroyElement(childElement);
517 }
518 // dispose of the controls
519 for (Control control : formElement.getControls()) {
520 // we added the layoutComposite of the parental element as the
521 // layout composite to this formElement
522 // but we do not want to destroy it.
523 if (control.equals(formElement.getLayoutComposite())) {
524 continue;
525 } else {
526 control.dispose();
527 control = null;
528 }
529 }
530 }
531
532 /**
533 * <p>
534 * createEmptyCell
535 * </p>
536 *
537 * @param parent
538 * a {@link org.eclipse.swt.widgets.Composite} object.
539 * @return a {@link org.eclipse.swt.widgets.Label} object.
540 */
541 public Label createEmptyCell(Composite parent) {
542 return this.createLabel(parent, null);
543 }
544
545 /**
546 * <p>
547 * createMultiLanguageTextElement
548 * </p>
549 *
550 * @param parentElement
551 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
552 * object.
553 * @param labelString
554 * a {@link java.lang.String} object.
555 * @param multilanguageText
556 * a {@link java.util.Map} object.
557 * @param textHeight
558 * a int.
559 * @param style
560 * a int.
561 * @return a
562 * {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
563 * object.
564 */
565 public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
566 Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
567 MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
568 multilanguageText, textHeight, style);
569 adapt(element);
570 parentElement.addElement(element);
571 return element;
572 }
573
574 public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
575 KeyStatement keyStatement, int textHeight, int style) {
576 KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
577 textHeight, style);
578 adapt(element);
579 parentElement.addElement(element);
580 return element;
581 }
582
583 /**
584 * Creates a text field with a label. The initial content will be the return value of the initalObject's {@link #toString()}
585 * method.<br>
586 * <b>Note</b>: if initialObject is <code>null</code> then an empty string is used.
587 * @param parentElement the parent container
588 * @param labelString the label name
589 * @param initialObject the object from which the <code>toString()</code> method is called
590 * @param style {@link SWT} style constant
591 * @return the created textfield with label
592 */
593 public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
594 Object initialObject, int style) {
595 return createTextWithLabelElement(parentElement, labelString, initialObject==null?"":initialObject.toString(), style);
596 }
597
598 /**
599 * <p>
600 * createTextWithLabelElement
601 * </p>
602 *
603 * @param parentElement
604 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
605 * object.
606 * @param labelString
607 * a {@link java.lang.String} object.
608 * @param initialText
609 * a {@link java.lang.String} object.
610 * @param style
611 * a int.
612 * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
613 * object.
614 */
615 public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
616 String initialText, int style) {
617 return createTextWithLabelElement(parentElement, labelString, initialText, null, style);
618 }
619 /**
620 * <p>
621 * createTextWithLabelElement
622 * </p>
623 *
624 * @param parentElement
625 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
626 * object.
627 * @param labelString
628 * a {@link java.lang.String} object.
629 * @param initialText
630 * a {@link java.lang.String} object.
631 * @param textLimit maximal number of characters allowed
632 * @param style
633 * a int.
634 * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
635 * object.
636 */
637 public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
638 String initialText, Integer textLimit, int style) {
639 if(initialText==null){
640 initialText = "";
641 }
642
643 TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
644 textLimit, style);
645 adapt(element);
646 parentElement.addElement(element);
647 return element;
648 }
649
650 public TextWithLabelElement createMultiLineTextWithLabel(ICdmFormElement parentElement, String labelString,
651 int textHeight, int style) {
652 TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, true, style);
653 adapt(element);
654 parentElement.addElement(element);
655 return element;
656 }
657
658 public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
659 URI initialUri, int style) {
660 UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
661 adapt(element);
662 parentElement.addElement(element);
663 return element;
664 }
665
666 /**
667 * @param element
668 * @param string
669 * @param uri
670 * @param style
671 * @return
672 */
673 public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
674 IOpenUrlEnabled openUrlEnabled, int style) {
675 OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
676 style);
677 adapt(element);
678 parentElement.addElement(element);
679 return element;
680 }
681
682 /**
683 *
684 * @param parentElement
685 * @param labelString
686 * @param conversationEnabled
687 * @param user
688 * @param style
689 * @return
690 */
691 public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
692 ConversationHolder conversation, User user, int style) {
693 EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
694 adapt(element);
695 parentElement.addElement(element);
696 return element;
697 }
698
699 /**
700 * <p>
701 * createIntegerTextWithLabelElement
702 * </p>
703 *
704 * @param parentElement
705 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
706 * object.
707 * @param labelString
708 * a {@link java.lang.String} object.
709 * @param initialInteger
710 * a {@link java.lang.Integer} object.
711 * @param style
712 * a int.
713 * @return a
714 * {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
715 * object.
716 */
717 public NumberWithLabelElement createNumberTextWithLabelElement(
718 ICdmFormElement parentElement, String labelString,
719 Number initialNumber, int style) {
720 NumberWithLabelElement element = new NumberWithLabelElement(this,
721 parentElement, labelString, initialNumber, style);
722 adapt(element);
723 parentElement.addElement(element);
724 return element;
725 }
726
727 public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
728 String labelString, LanguageString languageString, int style) {
729 return createLanguageStringWithLabelElement(parentElement, labelString, languageString, null, false, style);
730 }
731
732 public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
733 String labelString, LanguageString languageString, Integer height, boolean isMultiLine, int style) {
734 LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
735 languageString, height, isMultiLine, style);
736 adapt(element);
737 parentElement.addElement(element);
738 return element;
739 }
740
741 /**
742 * <p>
743 * createKeyValueViewerElement
744 * </p>
745 *
746 * @param parentElement
747 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
748 * object.
749 * @param keyHeading
750 * a {@link java.lang.String} object.
751 * @param valueHeading
752 * a {@link java.lang.String} object.
753 * @param map
754 * a {@link java.util.Map} object.
755 * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
756 * object.
757 */
758 public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
759 String valueHeading, Map<Object, Object> map) {
760 KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
761 adapt(element);
762 parentElement.addElement(element);
763 return element;
764 }
765
766 /**
767 * <p>
768 * createTermComboElement
769 * </p>
770 *
771 * @deprecated Use {@link #createDefinedTermComboElement(TermType, ICdmFormElement, String, DefinedTermBase, int)} instead
772 * @param termComboType
773 * a
774 * {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
775 * object.
776 * @param parentElement
777 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
778 * object.
779 * @param labelString
780 * a {@link java.lang.String} object.
781 * @param selection
782 * a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
783 * object.
784 * @param style
785 * a int.
786 * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
787 * object.
788 */
789 @Deprecated
790 public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
791 ICdmFormElement parentElement, String labelString, T selection, int style) {
792 TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString,
793 selection, style);
794 adapt(element);
795 parentElement.addElement(element);
796 return element;
797 }
798
799 /**
800 * <p>
801 * createTermComboElement
802 * </p>
803 *
804 * @param termComboType
805 * a
806 * {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
807 * object.
808 * @param parentElement
809 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
810 * object.
811 * @param labelString
812 * a {@link java.lang.String} object.
813 * @param selection
814 * a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
815 * object.
816 * @param style
817 * a int.
818 * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
819 * object.
820 */
821
822 public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
823 TermType termType,
824 ICdmFormElement parentElement,
825 String labelString,
826 T selection,
827 int style) {
828 TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termType, labelString, selection, style);
829 adapt(element);
830 parentElement.addElement(element);
831 return element;
832 }
833
834 /**
835 * <p>
836 * createTermComboElement
837 * </p>
838 *
839 * @param termComboType
840 * a
841 * {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
842 * object.
843 * @param parentElement
844 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
845 * object.
846 * @param labelString
847 * a {@link java.lang.String} object.
848 * @param selection
849 * a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
850 * object.
851 * @param style
852 * a int.
853 * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
854 * object.
855 */
856
857 public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
858 TermVocabulary<?> termVocabulary,
859 ICdmFormElement parentElement,
860 String labelString,
861 T selection,
862 int style) {
863 TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termVocabulary, labelString, selection, style);
864 adapt(element);
865 parentElement.addElement(element);
866 return element;
867 }
868
869 /**
870 * <p>
871 * createEnumComboElement
872 * </p>
873 *
874 * @param enumComboType
875 * a
876 * {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType}
877 * object.
878 * @param parentElement
879 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
880 * object.
881 * @param style
882 * a int.
883 * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
884 * object.
885 */
886 public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
887 Class<T> enumComboType, ICdmFormElement parentElement,
888 int style) {
889 EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
890 adapt(element);
891 parentElement.addElement(element);
892 return element;
893 }
894
895 public <TERM extends DefinedTermBase<TERM>, VOC extends TermVocabulary<TERM>> VocabularyComboElement<TERM, VOC> createVocabularyComboElement(
896 TermType termType, String label, VOC selection, ICdmFormElement parentElement, int style) {
897 VocabularyComboElement<TERM, VOC> element = new VocabularyComboElement<TERM, VOC>(this, parentElement, termType, label, selection, style);
898 adapt(element);
899 parentElement.addElement(element);
900 return element;
901 }
902
903 /**
904 * <p>
905 * createBrowserElement
906 * </p>
907 *
908 * @param imageUri
909 * a {@link java.net.URI} object.
910 * @param style
911 * a int.
912 * @param parentElement
913 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
914 * object.
915 * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
916 * object.
917 */
918 public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
919 BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
920 adapt(element);
921 parentElement.addElement(element);
922 return element;
923 }
924
925 /**
926 * <p>
927 * createImageElement
928 * </p>
929 *
930 * @param parentElement
931 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
932 * object.
933 * @param imageUri
934 * a {@link java.net.URI} object.
935 * @param style
936 * a int.
937 * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
938 */
939 public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
940 ImageElement element = new ImageElement(this, parentElement, imageUri, style);
941 adapt(element);
942 parentElement.addElement(element);
943 return element;
944 }
945
946 /**
947 * <p>
948 * createTextActionElement
949 * </p>
950 *
951 * @param labelString
952 * a {@link java.lang.String} object.
953 * @param initialText
954 * a {@link java.lang.String} object.
955 * @param style
956 * a int.
957 * @param parentElement
958 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
959 * object.
960 * @param buttonLabel
961 * a {@link java.lang.String} object.
962 * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
963 * object.
964 */
965 public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
966 String buttonLabel, String initialText, int style) {
967 TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
968 style);
969 adapt(element);
970 parentElement.addElement(element);
971 return element;
972 }
973
974 /**
975 * <p>
976 * createCheckbox
977 * </p>
978 *
979 * @param parentElement
980 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
981 * object.
982 * @param label
983 * a {@link java.lang.String} object.
984 * @param initialState
985 * a boolean.
986 * @param style
987 * a int.
988 * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
989 * object.
990 */
991 public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, Boolean initialState, int style) {
992 if(initialState==null){
993 initialState = Boolean.FALSE;
994 }
995 CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
996 adapt(element);
997 parentElement.addElement(element);
998 return element;
999 }
1000
1001 /**
1002 * Creates a section as a part of the form.
1003 *
1004 * @return the section widget
1005 * @param section
1006 * a
1007 * {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
1008 * object.
1009 */
1010 public Section adapt(AbstractFormSection section) {
1011 section.setMenu(section.getLayoutComposite().getMenu());
1012 adapt(section, true, true);
1013
1014 // handle focus and property change events for cdm use
1015 section.addFocusListener(selectionFocusHandler);
1016 section.setPropertyChangeListeners(propertyChangeListeners);
1017
1018 if (section.getToggle() != null) {
1019 section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1020 section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
1021 }
1022
1023 section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1024
1025 if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
1026 || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
1027 getColors().initializeSectionToolBarColors();
1028 section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1029 section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
1030 }
1031 // call setTitleBarForeground regardless as it also sets the label color
1032 section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
1033 return section;
1034 }
1035
1036 private class BoldFontHolder2 {
1037 private Font normalFont;
1038
1039 private Font boldFont;
1040
1041 public BoldFontHolder2() {
1042 }
1043
1044 public Font getBoldFont(Font font) {
1045 createBoldFont(font);
1046 return boldFont;
1047 }
1048
1049 private void createBoldFont(Font font) {
1050 if (normalFont == null || !normalFont.equals(font)) {
1051 normalFont = font;
1052 dispose();
1053 }
1054 if (boldFont == null) {
1055 boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
1056 }
1057 }
1058
1059 public void dispose() {
1060 if (boldFont != null) {
1061 FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1062 boldFont = null;
1063 }
1064 }
1065 }
1066
1067 /**
1068 * <p>
1069 * createToggleableTextField
1070 * </p>
1071 *
1072 * @param parentElement
1073 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1074 * object.
1075 * @param labelString
1076 * a {@link java.lang.String} object.
1077 * @param initialText
1078 * a {@link java.lang.String} object.
1079 * @param initialState
1080 * a boolean.
1081 * @param style
1082 * a int.
1083 * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
1084 * object.
1085 */
1086 public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
1087 String initialText, boolean initialState, int style) {
1088 ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
1089 initialState, style | orientation);
1090 adapt(element);
1091 parentElement.addElement(element);
1092 return element;
1093 }
1094
1095 /**
1096 * <p>
1097 * createTimePeriodElement
1098 * </p>
1099 *
1100 * @param parentElement
1101 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1102 * object.
1103 * @param labelString
1104 * a {@link java.lang.String} object.
1105 * @param timePeriod
1106 * a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1107 * @param style
1108 * a int.
1109 * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
1110 * object.
1111 */
1112 public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
1113 TimePeriod timePeriod, int style) {
1114 TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1115 adapt(element);
1116 parentElement.addElement(element);
1117 return element;
1118 }
1119
1120 /**
1121 * <p>
1122 * createGatheringEventUnitElement
1123 * </p>
1124 *
1125 * @param parentElement
1126 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1127 * object.
1128 * @param labelString
1129 * a {@link java.lang.String} object.
1130 * @param timePeriod
1131 * a {@link eu.etaxonomy.cdm.model.common.GatheringEvent} object.
1132 * @param style
1133 * a int.
1134 * @return a {@link eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement}
1135 * object.
1136 */
1137 public GatheringEventUnitElement createGatheringEventUnitElement(
1138 ICdmFormElement parentElement,
1139 String labelString,
1140 DerivedUnitFacade gatheringEvent,
1141 MinMaxTextSection.UnitType unitType,
1142 int style) {
1143 GatheringEventUnitElement element = new GatheringEventUnitElement(this,
1144 parentElement,
1145 labelString,
1146 gatheringEvent,
1147 unitType,
1148 style);
1149 adapt(element);
1150 parentElement.addElement(element);
1151 return element;
1152 }
1153
1154 /**
1155 * <p>
1156 * createPointElement
1157 * </p>
1158 *
1159 * @param style
1160 * a int.
1161 * @param parentElement
1162 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1163 * object.
1164 * @param point
1165 * a {@link eu.etaxonomy.cdm.model.location.Point} object.
1166 * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
1167 */
1168 public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
1169 PointElement element = new PointElement(this, parentElement, point, style);
1170 adapt(element);
1171 parentElement.addElement(element);
1172 return element;
1173 }
1174
1175
1176
1177 /**
1178 * @param conversationHolder
1179 * @param parent
1180 * @param detailsViewer
1181 * @param i
1182 * @return
1183 */
1184 public EmptySection createEmptySection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
1185 EmptySection section = new EmptySection(formFactory, parentElement, style);
1186 parentElement.addElement(section);
1187 adapt(section);
1188 return section;
1189 }
1190
1191 /**
1192 * <p>
1193 * createDateDetailSection
1194 * </p>
1195 *
1196 * @param parentElement
1197 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1198 * object.
1199 * @param style
1200 * a int.
1201 * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
1202 * object.
1203 */
1204 public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
1205 DateDetailSection section = new DateDetailSection(this, parentElement, style);
1206 parentElement.addElement(section);
1207 adapt(section);
1208 return section;
1209 }
1210
1211 /**
1212 * <p>
1213 * createDateDetailSection
1214 * </p>
1215 *
1216 * @param parentElement
1217 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1218 * object.
1219 * @param style
1220 * a int.
1221 * @return a {@link eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection}
1222 * object.
1223 */
1224 public MinMaxTextSection createMinMaxTextSection(ICdmFormElement parentElement, UnitType unitType, int style) {
1225 MinMaxTextSection section = new MinMaxTextSection(this, parentElement, unitType, style);
1226 parentElement.addElement(section);
1227 adapt(section);
1228 return section;
1229 }
1230
1231 /**
1232 * <p>
1233 * createPartialElement
1234 * </p>
1235 *
1236 * @param parentElement
1237 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1238 * object.
1239 * @param labelString
1240 * a {@link java.lang.String} object.
1241 * @param partial
1242 * a {@link org.joda.time.Partial} object.
1243 * @param style
1244 * a int.
1245 * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
1246 * object.
1247 */
1248 public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
1249 int style) {
1250 PartialElement element = new PartialElement(this, parentElement, labelString, style);
1251 adapt(element);
1252 parentElement.addElement(element);
1253 return element;
1254 }
1255
1256 /**
1257 * <p>
1258 * addSelectionListener
1259 * </p>
1260 *
1261 * @param listener
1262 * a {@link org.eclipse.swt.events.SelectionListener} object.
1263 */
1264 public void addSelectionListener(SelectionListener listener) {
1265 selectionListenerList.add(listener);
1266 }
1267
1268 /**
1269 * <p>
1270 * removeSelectionListener
1271 * </p>
1272 *
1273 * @param listener
1274 * a {@link org.eclipse.swt.events.SelectionListener} object.
1275 */
1276 public void removeSelectionListener(SelectionListener listener) {
1277 if (listener == null) {
1278 MessagingUtils.error(this.getClass(),
1279 "Tried to remove a selection listener from this factories listeners but was null", null);
1280 } else {
1281 selectionListenerList.remove(listener);
1282 }
1283 }
1284
1285 /**
1286 * <p>
1287 * addPropertyChangeListener
1288 * </p>
1289 *
1290 * @param listener
1291 * a {@link org.eclipse.jface.util.IPropertyChangeListener}
1292 * object.
1293 */
1294 public void addPropertyChangeListener(IPropertyChangeListener listener) {
1295 if (propertyChangeListeners.contains(listener)) {
1296 return;
1297 }
1298 propertyChangeListeners.add(0, listener);
1299 }
1300
1301 /**
1302 * <p>
1303 * removePropertyChangeListener
1304 * </p>
1305 *
1306 * @param listener
1307 * a {@link org.eclipse.jface.util.IPropertyChangeListener}
1308 * object.
1309 */
1310 public void removePropertyChangeListener(IPropertyChangeListener listener) {
1311 propertyChangeListeners.remove(listener);
1312 }
1313
1314 /**
1315 * @return the propertyChangeListeners
1316 */
1317 public List<IPropertyChangeListener> getPropertyChangeListeners() {
1318 return propertyChangeListeners;
1319 }
1320
1321 /**
1322 * <p>
1323 * createHorizontalSeparator
1324 * </p>
1325 *
1326 * @param parentElement
1327 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1328 * object.
1329 * @param style
1330 * a int.
1331 * @return a {@link org.eclipse.swt.widgets.Label} object.
1332 */
1333 public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1334 Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1335 separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
1336 return separator;
1337 }
1338
1339 /**
1340 * <p>
1341 * createVersionElement
1342 * </p>
1343 *
1344 * @param parentElement
1345 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1346 * object.
1347 * @param entity
1348 * a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1349 * object.
1350 * @param style
1351 * a int.
1352 * @return a
1353 * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1354 * object.
1355 */
1356 public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
1357 VersionElement element = new VersionElement(this, parentElement, entity, style);
1358 adapt(element);
1359 parentElement.addElement(element);
1360 return element;
1361 }
1362
1363 /**
1364 * @param cdmBaseSection
1365 * @param object
1366 * @param style
1367 * @return
1368 */
1369 public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
1370 CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
1371 adapt(element);
1372 parentElement.addElement(element);
1373 return element;
1374 }
1375
1376 /**
1377 * <p>
1378 * createVersionSection
1379 * </p>
1380 *
1381 * @param parentElement
1382 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1383 * object.
1384 * @param style
1385 * a int.
1386 * @return a
1387 * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1388 * object.
1389 */
1390 public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1391 VersionSection section = new VersionSection(this, parentElement, style);
1392 parentElement.addElement(section);
1393 adapt(section);
1394 return section;
1395 }
1396
1397 /**
1398 * @param parent
1399 * @param i
1400 * @return
1401 */
1402 public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
1403 CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
1404 parentElement.addElement(section);
1405 adapt(section);
1406 return section;
1407 }
1408
1409 /**
1410 * <p>
1411 * createEmptyElement
1412 * </p>
1413 *
1414 * @param parentElement
1415 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1416 * object.
1417 * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1418 */
1419 public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1420 EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1421 adapt(element);
1422 parentElement.addElement(element);
1423 return element;
1424 }
1425
1426 /**
1427 * <p>
1428 * createHeadlineSection
1429 * </p>
1430 *
1431 * @param parentElement
1432 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1433 * object.
1434 * @return a
1435 * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1436 * object.
1437 */
1438 public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1439 HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1440 parentElement.addElement(section);
1441 adapt(section);
1442 return section;
1443 }
1444
1445 /**
1446 * <p>
1447 * createParsingMessageElement
1448 * </p>
1449 *
1450 * @param parentElement
1451 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
1452 * object.
1453 * @param parserProblem
1454 * a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1455 * object.
1456 * @param style
1457 * a int.
1458 * @return a
1459 * {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1460 * object.
1461 */
1462 public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
1463 ParserProblem parserProblem, int style) {
1464 ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1465 adapt(element);
1466 parentElement.addElement(element);
1467 return element;
1468 }
1469
1470 public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
1471 ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
1472
1473 AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
1474 selectionProvider, style);
1475
1476 parentElement.addElement(section);
1477 adapt(section);
1478 return section;
1479
1480 }
1481
1482 /**
1483 * @param definedTermClass
1484 * @param formElement
1485 * @param style
1486 * @return
1487 */
1488 public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
1489 AbstractCdmDetailSection parentElement, int style) {
1490 AbstractCdmDetailElement element = null;
1491
1492 if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1493 element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1494 } else if (definedTermClass.equals(Feature.class)) {
1495 element = new FeatureDetailElement(this, parentElement);
1496 } else {
1497 element = new DefinedTermDetailElement(this, parentElement);
1498 }
1499
1500 adapt(element);
1501 parentElement.addElement(element);
1502 return element;
1503 }
1504
1505
1506 //--------DetailSections---------
1507 public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1508 NameDetailSection section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1509 addAndAdaptSection(parentElement, section);
1510 return section;
1511 }
1512
1513 public ReferenceDetailSection createReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1514 ReferenceDetailSection section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1515 addAndAdaptSection(parentElement, section);
1516 return section;
1517 }
1518
1519 public NomenclaturalReferenceDetailSection createNomenclaturalReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1520 NomenclaturalReferenceDetailSection section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1521 addAndAdaptSection(parentElement, section);
1522 return section;
1523 }
1524
1525 public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1526 TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1527 addAndAdaptSection(parentElement, section);
1528 return section;
1529 }
1530
1531 public AuthorshipDetailSection createAuthorshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1532 AuthorshipDetailSection section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1533 addAndAdaptSection(parentElement, section);
1534 return section;
1535 }
1536
1537 public TeamOrPersonBaseDetailSection createTeamOrPersonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1538 TeamOrPersonBaseDetailSection section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1539 addAndAdaptSection(parentElement, section);
1540 return section;
1541 }
1542
1543 public TeamDetailSection createTeamDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1544 TeamDetailSection section = new TeamDetailSection(this, conversation, parentElement, null, style);
1545 addAndAdaptSection(parentElement, section);
1546 return section;
1547 }
1548
1549 public PersonDetailSection createPersonDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1550 PersonDetailSection section = new PersonDetailSection(this, conversation, parentElement, null, style);
1551 addAndAdaptSection(parentElement, section);
1552 return section;
1553 }
1554
1555 public DescriptionDetailSection createDescriptionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1556 DescriptionDetailSection section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1557 addAndAdaptSection(parentElement, section);
1558 return section;
1559 }
1560
1561 public DescriptionElementDetailSection createDescriptionElementDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1562 DescriptionElementDetailSection section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1563 addAndAdaptSection(parentElement, section);
1564 return section;
1565 }
1566
1567 public ParsingMessagesSection createParsingMessagesSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1568 ParsingMessagesSection section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1569 addAndAdaptSection(parentElement, section);
1570 return section;
1571 }
1572
1573 public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1574 NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, style);
1575 addAndAdaptSection(parentElement, section);
1576 return section;
1577 }
1578
1579 public MediaDetailsSection createMediaDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1580 MediaDetailsSection section = new MediaDetailsSection(this, conversation, parentElement, selectionProvider, style);
1581 addAndAdaptSection(parentElement, section);
1582 return section;
1583 }
1584
1585 public FieldUnitDetailSection createFieldUnitDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1586 FieldUnitDetailSection section = new FieldUnitDetailSection(this, conversation, parentElement, selectionProvider, style);
1587 addAndAdaptSection(parentElement, section);
1588 return section;
1589 }
1590
1591 public GatheringEventDetailSection createGatheringEventDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1592 GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1593 addAndAdaptSection(parentElement, section);
1594 return section;
1595 }
1596
1597 public SpecimenHierarchyDetailSection createSpecimenHierarchyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1598 SpecimenHierarchyDetailSection section = new SpecimenHierarchyDetailSection(this, conversation, parentElement, selectionProvider, style);
1599 addAndAdaptSection(parentElement, section);
1600 return section;
1601 }
1602
1603 public DerivedUnitBaseDetailSection createDerivedUnitBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1604 DerivedUnitBaseDetailSection section = new DerivedUnitBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1605 addAndAdaptSection(parentElement, section);
1606 return section;
1607 }
1608
1609 public TaxonAssociationDetailSection createTaxonAssociationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1610 TaxonAssociationDetailSection section = new TaxonAssociationDetailSection(this, conversation, parentElement, selectionProvider, style);
1611 addAndAdaptSection(parentElement, section);
1612 return section;
1613 }
1614
1615 public OriginalLabelDataSection createOriginalLabelDataSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1616 OriginalLabelDataSection section = new OriginalLabelDataSection(this, conversation, parentElement, selectionProvider, style);
1617 addAndAdaptSection(parentElement, section);
1618 return section;
1619 }
1620
1621 public NaturalLanguageSection createNaturalLanguageSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1622 NaturalLanguageSection section = new NaturalLanguageSection(this, conversation, parentElement, selectionProvider, style);
1623 addAndAdaptSection(parentElement, section);
1624 return section;
1625 }
1626
1627 public FeatureDistributionDetailSection createFeatureDistributionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1628 FeatureDistributionDetailSection section = new FeatureDistributionDetailSection(this, conversation, parentElement, selectionProvider, style);
1629 addAndAdaptSection(parentElement, section);
1630 return section;
1631 }
1632
1633 public ClassificationDetailSection createClassificationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1634 ClassificationDetailSection section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style);
1635 addAndAdaptSection(parentElement, section);
1636 return section;
1637 }
1638
1639 public TaxonNodeDetailSection createTaxonNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1640 TaxonNodeDetailSection section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1641 addAndAdaptSection(parentElement, section);
1642 return section;
1643 }
1644
1645 public PolytomousKeyDetailSection createPolytomousKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1646 PolytomousKeyDetailSection section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
1647 addAndAdaptSection(parentElement, section);
1648 return section;
1649 }
1650
1651 public PolytomousKeyNodeDetailSection createPolytomousKeyNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1652 PolytomousKeyNodeDetailSection section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1653 addAndAdaptSection(parentElement, section);
1654 return section;
1655 }
1656
1657 public InstitutionDetailSection createInstitutionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1658 InstitutionDetailSection section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
1659 addAndAdaptSection(parentElement, section);
1660 return section;
1661 }
1662
1663 public FieldUnitGeneralDetailSection createFieldUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1664 FieldUnitGeneralDetailSection section = new FieldUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1665 addAndAdaptSection(parentElement, section);
1666 return section;
1667 }
1668
1669 public DerivedUnitGeneralDetailSection createDerivedUnitGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1670 DerivedUnitGeneralDetailSection section = new DerivedUnitGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1671 addAndAdaptSection(parentElement, section);
1672 return section;
1673 }
1674
1675 public PreservedSpecimenGeneralDetailSection createPreservedSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1676 PreservedSpecimenGeneralDetailSection section = new PreservedSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1677 addAndAdaptSection(parentElement, section);
1678 return section;
1679 }
1680
1681 public TissueSampleGeneralDetailSection createTissueSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1682 TissueSampleGeneralDetailSection section = new TissueSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1683 addAndAdaptSection(parentElement, section);
1684 return section;
1685 }
1686
1687 public DnaSampleGeneralDetailSection createDnaSampleGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1688 DnaSampleGeneralDetailSection section = new DnaSampleGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1689 addAndAdaptSection(parentElement, section);
1690 return section;
1691 }
1692
1693 public DnaQualityDetailSection createDnaQualityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1694 DnaQualityDetailSection section = new DnaQualityDetailSection(this, conversation, parentElement, selectionProvider, style);
1695 addAndAdaptSection(parentElement, section);
1696 return section;
1697 }
1698
1699 public SequenceGeneralDetailSection createSequenceGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1700 SequenceGeneralDetailSection section = new SequenceGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1701 addAndAdaptSection(parentElement, section);
1702 return section;
1703 }
1704
1705 public SequenceContigFileCollectionDetailSection createSequenceContigFileCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1706 SequenceContigFileCollectionDetailSection section = new SequenceContigFileCollectionDetailSection(this, conversation, parentElement, style);
1707 addAndAdaptSection(parentElement, section);
1708 return section;
1709 }
1710
1711 public SingleReadPherogramCollectionDetailSection createSingleReadPherogramCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1712 SingleReadPherogramCollectionDetailSection section = new SingleReadPherogramCollectionDetailSection(this, conversation, parentElement, style);
1713 addAndAdaptSection(parentElement, section);
1714 return section;
1715 }
1716
1717 public SequenceReferenceCollectionDetailSection createSequenceReferenceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1718 SequenceReferenceCollectionDetailSection section = new SequenceReferenceCollectionDetailSection(this, conversation, parentElement, style);
1719 addAndAdaptSection(parentElement, section);
1720 return section;
1721 }
1722
1723 public SingleReadGeneralDetailSection createSingleReadGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1724 SingleReadGeneralDetailSection section = new SingleReadGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1725 addAndAdaptSection(parentElement, section);
1726 return section;
1727 }
1728
1729 public AmplificationGeneralDetailSection createAmplificationGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1730 AmplificationGeneralDetailSection section = new AmplificationGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1731 addAndAdaptSection(parentElement, section);
1732 return section;
1733 }
1734
1735 public AmplificationPrimerDetailSection createAmplificationPrimerDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1736 AmplificationPrimerDetailSection section = new AmplificationPrimerDetailSection(this, conversation, parentElement, selectionProvider, style);
1737 addAndAdaptSection(parentElement, section);
1738 return section;
1739 }
1740
1741 public AmplificationCloningDetailSection createAmplificationCloningDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1742 AmplificationCloningDetailSection section = new AmplificationCloningDetailSection(this, conversation, parentElement, selectionProvider, style);
1743 addAndAdaptSection(parentElement, section);
1744 return section;
1745 }
1746
1747 public AmplificationGelPhotoCollectionDetailSection createAmplificationGelPhotoCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
1748 AmplificationGelPhotoCollectionDetailSection section = new AmplificationGelPhotoCollectionDetailSection(this, conversation, parentElement, style);
1749 addAndAdaptSection(parentElement, section);
1750 return section;
1751 }
1752
1753 public MediaSpecimenGeneralDetailSection createMediaSpecimenGeneralDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1754 MediaSpecimenGeneralDetailSection section = new MediaSpecimenGeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1755 addAndAdaptSection(parentElement, section);
1756 return section;
1757 }
1758
1759 public HybridDetailSection createHybridDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1760 HybridDetailSection section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
1761 addAndAdaptSection(parentElement, section);
1762 return section;
1763 }
1764
1765 public UserDetailSection createUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1766 UserDetailSection section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
1767 addAndAdaptSection(parentElement, section);
1768 return section;
1769 }
1770
1771 public GroupDetailSection createGroupDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1772 GroupDetailSection section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
1773 addAndAdaptSection(parentElement, section);
1774 return section;
1775 }
1776
1777 public DeterminationDetailSection createDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1778 DeterminationDetailSection section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1779 addAndAdaptSection(parentElement, section);
1780 return section;
1781 }
1782
1783 public SampleDesignationDetailSection createSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1784 SampleDesignationDetailSection section = new SampleDesignationDetailSection(this, conversation, parentElement, selectionProvider, style);
1785 addAndAdaptSection(parentElement, section);
1786 return section;
1787 }
1788
1789 public PreservedSpecimenDeterminationDetailSection createPreservedSpecimenDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1790 PreservedSpecimenDeterminationDetailSection section = new PreservedSpecimenDeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
1791 addAndAdaptSection(parentElement, section);
1792 return section;
1793 }
1794
1795 public TaxonRelationshipDetailSection createTaxonRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1796 TaxonRelationshipDetailSection section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1797 addAndAdaptSection(parentElement, section);
1798 return section;
1799 }
1800
1801 public ReferencedEntityDetailSection createReferencedEntityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1802 ReferencedEntityDetailSection section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
1803 addAndAdaptSection(parentElement, section);
1804 return section;
1805 }
1806
1807 public TermVocabularyDetailSection createTermVocabularyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1808 TermVocabularyDetailSection section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
1809 addAndAdaptSection(parentElement, section);
1810 return section;
1811 }
1812
1813 public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1814 GatheringEventDetailSection section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1815 addAndAdaptSection(parentElement, section);
1816 return section;
1817 }
1818
1819 public NamedAreaDetailSection createNamedAreaDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1820 NamedAreaDetailSection section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
1821 addAndAdaptSection(parentElement, section);
1822 return section;
1823 }
1824
1825 public UseRecordDetailSection createUseRecordDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1826 UseRecordDetailSection section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
1827 addAndAdaptSection(parentElement, section);
1828 return section;
1829 }
1830
1831 private void addAndAdaptSection(ICdmFormElement parentElement, AbstractFormSection<?> section) {
1832 parentElement.addElement(section);
1833 adapt(section);
1834 }
1835
1836 //--------DetailElements------------
1837
1838 public UseRecordDetailElement createUseRecordDetailElement(ICdmFormElement parentElement){
1839 UseRecordDetailElement element = new UseRecordDetailElement(this, parentElement);
1840 addAndAdaptElement(parentElement, element);
1841 return element;
1842 }
1843
1844 public DefinedTermDetailElement<NamedAreaLevel> createNamedAreaLevelElement(ICdmFormElement parentElement){
1845 DefinedTermDetailElement<NamedAreaLevel> element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1846 addAndAdaptElement(parentElement, element);
1847 return element;
1848 }
1849
1850 public eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement createNamedAreaDetailElement(ICdmFormElement parentElement){
1851 eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1852 addAndAdaptElement(parentElement, element);
1853 return element;
1854 }
1855
1856 public TermVocabularyDetailElement createTermVocabularyDetailElement(ICdmFormElement parentElement){
1857 TermVocabularyDetailElement element = new TermVocabularyDetailElement(this, parentElement);
1858 addAndAdaptElement(parentElement, element);
1859 return element;
1860 }
1861
1862 public ReferenceEntityDetailElement createReferenceEntityDetailElement(ICdmFormElement parentElement){
1863 ReferenceEntityDetailElement element = new ReferenceEntityDetailElement(this, parentElement);
1864 addAndAdaptElement(parentElement, element);
1865 return element;
1866 }
1867
1868 public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){
1869 TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement);
1870 addAndAdaptElement(parentElement, element);
1871 return element;
1872 }
1873
1874 public GrantedAuthorityDetailElement createGrantedAuthorityDetailElement(ICdmFormElement parentElement){
1875 GrantedAuthorityDetailElement element = new GrantedAuthorityDetailElement(this, parentElement);
1876 addAndAdaptElement(parentElement, element);
1877 return element;
1878 }
1879
1880 public GroupDetailElement createGroupDetailElement(ICdmFormElement parentElement){
1881 GroupDetailElement element = new GroupDetailElement(this, parentElement);
1882 addAndAdaptElement(parentElement, element);
1883 return element;
1884 }
1885
1886 public UserDetailElement createUserDetailElement(ICdmFormElement parentElement){
1887 UserDetailElement element = new UserDetailElement(this, parentElement);
1888 addAndAdaptElement(parentElement, element);
1889 return element;
1890 }
1891
1892 public HybridDetailElement createHybridDetailElement(ICdmFormElement parentElement){
1893 HybridDetailElement element = new HybridDetailElement(this, parentElement);
1894 addAndAdaptElement(parentElement, element);
1895 return element;
1896 }
1897
1898 public InstitutionDetailElement createInstitutionDetailElement(ICdmFormElement parentElement){
1899 InstitutionDetailElement element = new InstitutionDetailElement(this, parentElement);
1900 addAndAdaptElement(parentElement, element);
1901 return element;
1902 }
1903
1904 public PolytomousKeyNodeDetailElement createPolytomousKeyNodeDetailElement(ICdmFormElement parentElement){
1905 PolytomousKeyNodeDetailElement element = new PolytomousKeyNodeDetailElement(this, parentElement);
1906 addAndAdaptElement(parentElement, element);
1907 return element;
1908 }
1909
1910 public PolytomousKeyDetailElement createPolytomousKeyDetailElement(ICdmFormElement parentElement){
1911 PolytomousKeyDetailElement element = new PolytomousKeyDetailElement(this, parentElement);
1912 addAndAdaptElement(parentElement, element);
1913 return element;
1914 }
1915
1916 public CollectionDetailElement createCollectionDetailElement(ICdmFormElement parentElement){
1917 CollectionDetailElement element = new CollectionDetailElement(this, parentElement);
1918 addAndAdaptElement(parentElement, element);
1919 return element;
1920 }
1921
1922 public TaxonNodeDetailElement createTaxonNodeDetailElement(ICdmFormElement parentElement){
1923 TaxonNodeDetailElement element = new TaxonNodeDetailElement(this, parentElement);
1924 addAndAdaptElement(parentElement, element);
1925 return element;
1926 }
1927
1928 public ClassificationDetailElement createClassificationDetailElement(ICdmFormElement parentElement){
1929 ClassificationDetailElement element = new ClassificationDetailElement(this, parentElement);
1930 addAndAdaptElement(parentElement, element);
1931 return element;
1932 }
1933
1934 public FeatureDistributionDetailElement createFeatureDistributionDetailElement(ICdmFormElement parentElement){
1935 FeatureDistributionDetailElement element = new FeatureDistributionDetailElement(this, parentElement);
1936 addAndAdaptElement(parentElement, element);
1937 return element;
1938 }
1939
1940 public NaturalLanguageDetailElement createNaturalLanguageDetailElement(ICdmFormElement parentElement){
1941 NaturalLanguageDetailElement element = new NaturalLanguageDetailElement(this, parentElement);
1942 addAndAdaptElement(parentElement, element);
1943 return element;
1944 }
1945
1946 public NonViralNameDetailElement createNonViralNameDetailElement(ICdmFormElement parentElement){
1947 NonViralNameDetailElement element = new NonViralNameDetailElement(this, parentElement);
1948 addAndAdaptElement(parentElement, element);
1949 return element;
1950 }
1951
1952 public DescriptionElementDetailElement createDescriptionElementDetailElement(ICdmFormElement parentElement, int style){
1953 DescriptionElementDetailElement element = new DescriptionElementDetailElement(this, parentElement, style);
1954 addAndAdaptElement(parentElement, element);
1955 return element;
1956 }
1957
1958 public DescriptionDetailElement createDescriptionDetailElement(ICdmFormElement parentElement, int style){
1959 DescriptionDetailElement element = new DescriptionDetailElement(this, parentElement, style);
1960 addAndAdaptElement(parentElement, element);
1961 return element;
1962 }
1963
1964 public PersonDetailElement createPersonDetailElement(ICdmFormElement parentElement, int style){
1965 PersonDetailElement element = new PersonDetailElement(this, parentElement, style);
1966 addAndAdaptElement(parentElement, element);
1967 return element;
1968 }
1969
1970 public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style){
1971 TeamDetailElement element = new TeamDetailElement(this, parentElement, style);
1972 addAndAdaptElement(parentElement, element);
1973 return element;
1974 }
1975
1976 public AuthorshipDetailElement createAuthorshipDetailElement(ICdmFormElement parentElement, int style){
1977 AuthorshipDetailElement element = new AuthorshipDetailElement(this, parentElement, style);
1978 addAndAdaptElement(parentElement, element);
1979 return element;
1980 }
1981
1982 public TaxonBaseDetailElement createTaxonBaseDetailElement(ICdmFormElement parentElement, int style){
1983 TaxonBaseDetailElement element = new TaxonBaseDetailElement(this, parentElement, style);
1984 addAndAdaptElement(parentElement, element);
1985 return element;
1986 }
1987
1988 public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
1989 NameDetailElement element = new NameDetailElement(this, parentElement, style);
1990 addAndAdaptElement(parentElement, element);
1991 return element;
1992 }
1993
1994 public ReferenceDetailElement createReferenceDetailElement(ICdmFormElement parentElement, int style){
1995 ReferenceDetailElement element = new ReferenceDetailElement(this, parentElement, style);
1996 addAndAdaptElement(parentElement, element);
1997 return element;
1998 }
1999
2000 public NomenclaturalReferenceDetailElement createNomenclaturalReferenceDetailElement(ICdmFormElement parentElement, int style){
2001 NomenclaturalReferenceDetailElement element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
2002 addAndAdaptElement(parentElement, element);
2003 return element;
2004 }
2005
2006
2007 public FieldUnitGeneralDetailElement createFieldUnitGeneralDetailElement(ICdmFormElement parentElement){
2008 FieldUnitGeneralDetailElement element = new FieldUnitGeneralDetailElement(this, parentElement);
2009 addAndAdaptElement(parentElement, element);
2010 return element;
2011 }
2012
2013 public DerivedUnitGeneralDetailElement createDerivedUnitGeneralDetailElement(ICdmFormElement parentElement){
2014 DerivedUnitGeneralDetailElement element = new DerivedUnitGeneralDetailElement(this, parentElement);
2015 addAndAdaptElement(parentElement, element);
2016 return element;
2017 }
2018
2019 public TaxonAssociationDetailElement createTaxonAssociationDetailElement(ICdmFormElement parentElement){
2020 TaxonAssociationDetailElement element = new TaxonAssociationDetailElement(this, parentElement);
2021 addAndAdaptElement(parentElement, element);
2022 return element;
2023 }
2024
2025 public PreservedSpecimenGeneralDetailElement createPreservedSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2026 PreservedSpecimenGeneralDetailElement element = new PreservedSpecimenGeneralDetailElement(this, parentElement);
2027 addAndAdaptElement(parentElement, element);
2028 return element;
2029 }
2030
2031 public TissueSampleGeneralDetailElement createTissueSampleGeneralDetailElement(ICdmFormElement parentElement){
2032 TissueSampleGeneralDetailElement element = new TissueSampleGeneralDetailElement(this, parentElement);
2033 addAndAdaptElement(parentElement, element);
2034 return element;
2035 }
2036
2037 public DnaSampleGeneralDetailElement createDnaSampleGeneralDetailElement(ICdmFormElement parentElement){
2038 DnaSampleGeneralDetailElement element = new DnaSampleGeneralDetailElement(this, parentElement);
2039 addAndAdaptElement(parentElement, element);
2040 return element;
2041 }
2042
2043 public DnaQualityDetailElement createDnaQualityDetailElement(ICdmFormElement parentElement){
2044 DnaQualityDetailElement element = new DnaQualityDetailElement(this, parentElement);
2045 addAndAdaptElement(parentElement, element);
2046 return element;
2047 }
2048
2049 public SequenceGeneralDetailElement createSequenceGeneralDetailElement(ICdmFormElement parentElement){
2050 SequenceGeneralDetailElement element = new SequenceGeneralDetailElement(this, parentElement);
2051 addAndAdaptElement(parentElement, element);
2052 return element;
2053 }
2054
2055 public SingleReadGeneralDetailElement createSingleReadGeneralDetailElement(ICdmFormElement parentElement){
2056 SingleReadGeneralDetailElement element = new SingleReadGeneralDetailElement(this, parentElement);
2057 addAndAdaptElement(parentElement, element);
2058 return element;
2059 }
2060
2061 public PrimerGeneralDetailElement createPrimerGeneralDetailElement(ICdmFormElement parentElement){
2062 PrimerGeneralDetailElement element = new PrimerGeneralDetailElement(this, parentElement);
2063 addAndAdaptElement(parentElement, element);
2064 return element;
2065 }
2066
2067 public AmplificationGeneralDetailElement createAmplificationGeneralDetailElement(ICdmFormElement parentElement){
2068 AmplificationGeneralDetailElement element = new AmplificationGeneralDetailElement(this, parentElement);
2069 addAndAdaptElement(parentElement, element);
2070 return element;
2071 }
2072
2073 public AmplificationPrimerDetailElement createAmplificationPrimerDetailElement(ICdmFormElement parentElement){
2074 AmplificationPrimerDetailElement element = new AmplificationPrimerDetailElement(this, parentElement);
2075 addAndAdaptElement(parentElement, element);
2076 return element;
2077 }
2078
2079 public AmplificationCloningDetailElement createAmplificationCloningDetailElement(ICdmFormElement parentElement){
2080 AmplificationCloningDetailElement element = new AmplificationCloningDetailElement(this, parentElement);
2081 addAndAdaptElement(parentElement, element);
2082 return element;
2083 }
2084
2085 public AmplificationGelPhotoDetailElement createAmplificationGelPhotoDetailElement(ICdmFormElement parentElement){
2086 AmplificationGelPhotoDetailElement element = new AmplificationGelPhotoDetailElement(this, parentElement);
2087 addAndAdaptElement(parentElement, element);
2088 return element;
2089 }
2090
2091 public MediaSpecimenGeneralDetailElement createMediaSpecimenGeneralDetailElement(ICdmFormElement parentElement){
2092 MediaSpecimenGeneralDetailElement element = new MediaSpecimenGeneralDetailElement(this, parentElement);
2093 addAndAdaptElement(parentElement, element);
2094 return element;
2095 }
2096
2097 public MediaDetailElement createMediaDetailElement(ICdmFormElement parentElement){
2098 MediaDetailElement mediaDetailElement = new MediaDetailElement(this, parentElement);
2099 addAndAdaptElement(parentElement, mediaDetailElement);
2100 return mediaDetailElement;
2101 }
2102
2103 public GatheringEventDetailElement createGatheringEventDetailElement(ICdmFormElement parentElement) {
2104 GatheringEventDetailElement element = new GatheringEventDetailElement(this, parentElement);
2105 addAndAdaptElement(parentElement, element);
2106 return element;
2107 }
2108
2109 public FieldUnitDetailElement createFieldUnitDetailElement(ICdmFormElement parentElement) {
2110 FieldUnitDetailElement element = new FieldUnitDetailElement(this, parentElement);
2111 addAndAdaptElement(parentElement, element);
2112 return element;
2113 }
2114
2115 public SpecimenHierarchyDetailElement createSpecimenHierarchyDetailElement(ICdmFormElement parentElement) {
2116 SpecimenHierarchyDetailElement element = new SpecimenHierarchyDetailElement(this, parentElement);
2117 addAndAdaptElement(parentElement, element);
2118 return element;
2119 }
2120
2121 public DerivedUnitBaseDetailElement createDerivedUnitBaseDetailElement(ICdmFormElement parentElement) {
2122 DerivedUnitBaseDetailElement element = new DerivedUnitBaseDetailElement(this, parentElement);
2123 addAndAdaptElement(parentElement, element);
2124 return element;
2125 }
2126
2127 public OriginalLabelDataElement createOriginalLabelDataElement(ICdmFormElement parentElement) {
2128 OriginalLabelDataElement element = new OriginalLabelDataElement(this, parentElement);
2129 addAndAdaptElement(parentElement, element);
2130 return element;
2131 }
2132
2133 public PreservedSpecimenDetailElement createPreservedSpecimenDetailElement(ICdmFormElement parentElement) {
2134 PreservedSpecimenDetailElement element = new PreservedSpecimenDetailElement(this, parentElement);
2135 addAndAdaptElement(parentElement, element);
2136 return element;
2137 }
2138
2139 public PreservedSpecimenDeterminationDetailElement createPreservedSpecimenDeterminationDetailElement(ICdmFormElement parentElement) {
2140 PreservedSpecimenDeterminationDetailElement element = new PreservedSpecimenDeterminationDetailElement(this, parentElement);
2141 addAndAdaptElement(parentElement, element);
2142 return element;
2143 }
2144
2145 public DeterminationDetailElement createDeterminationDetailElement(ICdmFormElement parentElement) {
2146 DeterminationDetailElement element = new DeterminationDetailElement(this, parentElement);
2147 addAndAdaptElement(parentElement, element);
2148 return element;
2149 }
2150
2151 public SampleDesignationDetailElement createSampleDesignationDetailElement(ICdmFormElement parentElement) {
2152 SampleDesignationDetailElement element = new SampleDesignationDetailElement(this, parentElement);
2153 addAndAdaptElement(parentElement, element);
2154 return element;
2155 }
2156
2157 /**
2158 * @param parentElement
2159 * @param element
2160 */
2161 private void addAndAdaptElement(ICdmFormElement parentElement, AbstractCdmDetailElement<?> element) {
2162 adapt(element);
2163 parentElement.addElement(element);
2164 }
2165
2166 //--------EntityCollectionSection----------
2167 public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2168 TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style);
2169 addAndAdaptSection(parentElement, section);
2170 return section;
2171 }
2172
2173 public AnnotationSection createAnnotationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2174 AnnotationSection section = new AnnotationSection(this, conversation, parentElement, style);
2175 addAndAdaptSection(parentElement, section);
2176 return section;
2177 }
2178
2179 public CreditSection createCreditSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2180 CreditSection section = new CreditSection(this, conversation, parentElement, style);
2181 addAndAdaptSection(parentElement, section);
2182 return section;
2183 }
2184
2185 public DescriptionElementSourceSection createDescriptionElementSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2186 DescriptionElementSourceSection section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
2187 addAndAdaptSection(parentElement, section);
2188 return section;
2189 }
2190
2191 public ExtensionSection createExtensionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2192 ExtensionSection section = new ExtensionSection(this, conversation, parentElement, style);
2193 addAndAdaptSection(parentElement, section);
2194 return section;
2195 }
2196
2197 public MarkerSection createMarkerSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2198 MarkerSection section = new MarkerSection(this, conversation, parentElement, style);
2199 addAndAdaptSection(parentElement, section);
2200 return section;
2201 }
2202
2203 public MediaSection createMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2204 MediaSection section = new MediaSection(this, conversation, parentElement, style);
2205 addAndAdaptSection(parentElement, section);
2206 return section;
2207 }
2208
2209 public DescriptionElementMediaSection createDescriptionElementMediaSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2210 DescriptionElementMediaSection section = new DescriptionElementMediaSection(this, conversation, parentElement, style);
2211 addAndAdaptSection(parentElement, section);
2212 return section;
2213 }
2214
2215 public MediaRepresentationSection createMediaRepresentationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2216 MediaRepresentationSection section = new MediaRepresentationSection(this, conversation, parentElement, style);
2217 addAndAdaptSection(parentElement, section);
2218 return section;
2219 }
2220
2221 public MediaRepresentationPartSection createMediaRepresentationPartSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2222 MediaRepresentationPartSection section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
2223 addAndAdaptSection(parentElement, section);
2224 return section;
2225 }
2226
2227 public ModifierSection createModifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2228 ModifierSection section = new ModifierSection(this, conversation, parentElement, style);
2229 addAndAdaptSection(parentElement, section);
2230 return section;
2231 }
2232
2233 public NomenclaturalStatusSection createNomenclaturalStatusSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2234 NomenclaturalStatusSection section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
2235 addAndAdaptSection(parentElement, section);
2236 return section;
2237 }
2238
2239 public NameRelationshipDetailSection createNameRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2240 NameRelationshipDetailSection section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
2241 addAndAdaptSection(parentElement, section);
2242 return section;
2243 }
2244
2245 public SynonymRelationshipDetailSection createSynonymRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2246 SynonymRelationshipDetailSection section = new SynonymRelationshipDetailSection(this, conversation, parentElement, style);
2247 addAndAdaptSection(parentElement, section);
2248 return section;
2249 }
2250
2251 public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2252 ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2253 addAndAdaptSection(parentElement, section);
2254 return section;
2255 }
2256
2257 public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2258 RightsSection section = new RightsSection(this, conversation, parentElement, style);
2259 addAndAdaptSection(parentElement, section);
2260 return section;
2261 }
2262
2263 public SourceSection createSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2264 SourceSection section = new SourceSection(this, conversation, parentElement, style);
2265 addAndAdaptSection(parentElement, section);
2266 return section;
2267 }
2268
2269 public ScopeSection createScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2270 ScopeSection section = new ScopeSection(this, conversation, parentElement, style);
2271 addAndAdaptSection(parentElement, section);
2272 return section;
2273 }
2274
2275 public DescriptionSourceSection createDescriptionSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2276 DescriptionSourceSection section = new DescriptionSourceSection(this, conversation, parentElement, style);
2277 addAndAdaptSection(parentElement, section);
2278 return section;
2279 }
2280
2281 public TypeDesignationSection createTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2282 TypeDesignationSection section = new TypeDesignationSection(this, conversation, parentElement, style);
2283 addAndAdaptSection(parentElement, section);
2284 return section;
2285 }
2286
2287 public StateDataSection createStateDataSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2288 StateDataSection section = new StateDataSection(this, conversation, parentElement, style);
2289 addAndAdaptSection(parentElement, section);
2290 return section;
2291 }
2292
2293 public StatisticalMeasurementValueSection createStatisticalMeasurementValueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2294 StatisticalMeasurementValueSection section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
2295 addAndAdaptSection(parentElement, section);
2296 return section;
2297 }
2298
2299 public DescribedSpecimenSection createDescribedSpecimenSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2300 DescribedSpecimenSection section = new DescribedSpecimenSection(this, conversation, parentElement, style);
2301 addAndAdaptSection(parentElement, section);
2302 return section;
2303 }
2304
2305 public CollectingAreasDetailSection createCollectingAreasDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2306 CollectingAreasDetailSection section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
2307 addAndAdaptSection(parentElement, section);
2308 return section;
2309 }
2310
2311 public IdentifierDetailSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2312 IdentifierDetailSection section = new IdentifierDetailSection(this, conversation, parentElement, style);
2313 addAndAdaptSection(parentElement, section);
2314 return section;
2315 }
2316
2317 public CurrentSampleDesignationDetailSection createCurrentSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2318 CurrentSampleDesignationDetailSection section = new CurrentSampleDesignationDetailSection(this, conversation, parentElement, style);
2319 addAndAdaptSection(parentElement, section);
2320 return section;
2321 }
2322
2323 public CurrentDeterminationDetailSection createCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2324 CurrentDeterminationDetailSection section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
2325 addAndAdaptSection(parentElement, section);
2326 return section;
2327 }
2328
2329 public PreservedSpecimenCurrentDeterminationDetailSection createPreservedSpecimenCurrentDeterminationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2330 PreservedSpecimenCurrentDeterminationDetailSection section = new PreservedSpecimenCurrentDeterminationDetailSection(this, conversation, parentElement, style);
2331 addAndAdaptSection(parentElement, section);
2332 return section;
2333 }
2334
2335 public SampleDesignationHistoryDetailSection createSampleDesignationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2336 SampleDesignationHistoryDetailSection section = new SampleDesignationHistoryDetailSection(this, conversation, parentElement, style);
2337 addAndAdaptSection(parentElement, section);
2338 return section;
2339 }
2340
2341 public DeterminationHistoryDetailSection createDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2342 DeterminationHistoryDetailSection section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
2343 addAndAdaptSection(parentElement, section);
2344 return section;
2345 }
2346
2347 public PreservedSpecimenDeterminationHistoryDetailSection createPreservedSpecimenDeterminationHistoryDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2348 PreservedSpecimenDeterminationHistoryDetailSection section = new PreservedSpecimenDeterminationHistoryDetailSection(this, conversation, parentElement, style);
2349 addAndAdaptSection(parentElement, section);
2350 return section;
2351 }
2352
2353 public SpecimenCollectionDetailSection createSpecimenCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2354 SpecimenCollectionDetailSection section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
2355 addAndAdaptSection(parentElement, section);
2356 return section;
2357 }
2358
2359 public PreservedSpecimenSourceCollectionDetailSection createPreservedSpecimenSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2360 PreservedSpecimenSourceCollectionDetailSection section = new PreservedSpecimenSourceCollectionDetailSection(this, conversation, parentElement, style);
2361 addAndAdaptSection(parentElement, section);
2362 return section;
2363 }
2364
2365 public SourceCollectionDetailSection createSourceCollectionDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2366 SourceCollectionDetailSection section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
2367 addAndAdaptSection(parentElement, section);
2368 return section;
2369 }
2370
2371 public GeographicalScopeDetailSection createGeographicalScopeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2372 GeographicalScopeDetailSection section = new GeographicalScopeDetailSection(this, conversation, parentElement, style);
2373 addAndAdaptSection(parentElement, section);
2374 return section;
2375 }
2376
2377 public ScopeRestrictionSection createScopeRestrictionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2378 ScopeRestrictionSection section = new ScopeRestrictionSection(this, conversation, parentElement, style);
2379 addAndAdaptSection(parentElement, section);
2380 return section;
2381 }
2382
2383 public MemberDetailSection createMemberDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2384 MemberDetailSection section = new MemberDetailSection(this, conversation, parentElement, style);
2385 addAndAdaptSection(parentElement, section);
2386 return section;
2387 }
2388
2389 public GrantedAuthorityDetailSection createGrantedAuthorityDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2390 GrantedAuthorityDetailSection section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
2391 addAndAdaptSection(parentElement, section);
2392 return section;
2393 }
2394
2395 public GroupsByUserDetailSection createGroupsByUserDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2396 GroupsByUserDetailSection section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
2397 addAndAdaptSection(parentElement, section);
2398 return section;
2399 }
2400
2401 public TaxonomicScopeSection createTaxonomicScopeSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2402 TaxonomicScopeSection section = new TaxonomicScopeSection(this, conversation, parentElement, style);
2403 addAndAdaptSection(parentElement, section);
2404 return section;
2405 }
2406
2407 public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
2408 Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
2409 AbstractEntityCollectionElement element = null;
2410
2411 Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2412
2413 if (entity instanceof Annotation) {
2414 element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2415 } else if (entity instanceof Person) {
2416 element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
2417 } else if (entity instanceof Credit) {
2418 element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2419 } else if (entity instanceof Extension) {
2420 element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
2421 } else if (entity instanceof Marker) {
2422 element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
2423 } else if (entity instanceof Media) {
2424 element = new MediaMetaElement(this, parentElement, (Media) entity, removeListener, true, style);
2425 } else if (entity instanceof MediaRepresentation) {
2426 element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
2427 style);
2428 } else if (entity instanceof ImageFile) {
2429 element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2430 } else if (entity instanceof MediaRepresentationPart) {
2431 element = new MediaRepresentationPartElement(this, parentElement, (MediaRepresentationPart) entity,
2432 removeListener, style);
2433 } else if (entity instanceof NomenclaturalStatus) {
2434 element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
2435 style);
2436 } else if (entity instanceof Rights) {
2437 element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
2438 } else if (entity instanceof DescriptionElementSource) {
2439 element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
2440 removeListener, style);
2441 } else if (entity instanceof IdentifiableSource) {
2442 element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
2443 style);
2444 } else if (entity instanceof DefinedTerm) {
2445 switch(((DefinedTerm)entity).getTermType()) {
2446 case Scope:
2447 element = new ScopeElement(this,
2448 parentElement,
2449 (DefinedTerm) entity,
2450 removeListener,
2451 style);
2452 break;
2453 case Modifier:
2454 element = new ModifierElement(this,
2455 parentElement,
2456 (DefinedTerm) entity,
2457 removeListener,
2458 style);
2459 break;
2460 default:
2461 //FIXME : Actually we should through an exception here
2462 element = null;
2463 break;
2464
2465 }
2466 } else if (entity instanceof Reference) {
2467 if(parentElement instanceof SequenceReferenceCollectionDetailSection){
2468 element = new SequenceReferenceCollectionDetailElement(this, parentElement, (Reference) entity, removeListener, style);
2469 }
2470 else{
2471 element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
2472 }
2473 } else if (entity instanceof NameTypeDesignation) {
2474 element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2475 style);
2476 } else if (entity instanceof NameRelationship) {
2477 element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2478 style);
2479 } else if (entity instanceof SynonymRelationship) {
2480 element = new SynonymRelationshipDetailElement(this, parentElement, (SynonymRelationship) entity, removeListener,
2481 style);
2482 } else if (entity instanceof SpecimenTypeDesignation) {
2483 element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
2484 removeListener, style);
2485 } else if (entity instanceof StateData) {
2486 element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
2487 } else if (entity instanceof StatisticalMeasurementValue) {
2488 element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
2489 removeListener, style);
2490 } else if (entity instanceof DerivedUnit) {
2491 switch(((DerivedUnit)entity).getRecordBasis()) {
2492 case LivingSpecimen:
2493 case PreservedSpecimen:
2494 case OtherSpecimen:
2495 element = new SpecimenCollectionDetailElement(this,
2496 parentElement,
2497 (DerivedUnit) entity,
2498 removeListener,
2499 style);
2500 break;
2501 default:
2502 element = new DerivedUnitElement(this,
2503 parentElement,
2504 (DerivedUnit) entity,
2505 removeListener,
2506 style);
2507 }
2508
2509 } else if (entity instanceof NamedArea) {
2510 element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
2511 } else if (entity instanceof DeterminationEvent) {
2512 element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
2513 } else if (entity instanceof User) {
2514 element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
2515 } else if (entity instanceof GrantedAuthority) {
2516 element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity,
2517 removeListener, style);
2518 } else if (entity instanceof Group) {
2519 element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
2520 } else if (entity instanceof Taxon) {
2521 element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
2522 } else if (entity instanceof DescriptionElementBase) {
2523 // this is the special case for protologs, maybe we can do this
2524 // differently when API improves
2525 DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2526 if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2527 element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
2528 }
2529 } else if (entity instanceof Identifier) {
2530 if(parentElement instanceof AbstractSampleDesignationDetailSection){
2531 element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2532 }
2533 else{
2534 element = new IdentifierDetailElement(this, parentElement, (Identifier) entity, removeListener, style);
2535 }
2536 }
2537
2538 if (element == null) {
2539 MessagingUtils.messageDialog("No element for entity", this,
2540 "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
2541 + entity, null);
2542 }
2543
2544 else{
2545 if (backgroundColor != null && !backgroundColor.isDisposed()) {
2546 element.setPersistentBackground(backgroundColor);
2547 }
2548 adapt(element);
2549 parentElement.addElement(element);
2550 }
2551
2552 return element;
2553 }
2554
2555 /**
2556 * <p>
2557 * Creates a selection element for the given type T.
2558 * </p>
2559 * <p>
2560 * <strong>Selection elements not handled by this method:</strong>
2561 * <ul>
2562 * <li>{@link TaxonNodeSelectionElement} see
2563 * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
2564 * </li>
2565 * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
2566 * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
2567 * </li>
2568 * </ul>
2569 * </p>
2570 *
2571 * @param clazz
2572 * a {@link Class} object of the type that you want the selection
2573 * element to handle
2574 * @param parentElement
2575 * a {@link ICdmFormElement} object.
2576 * @param labelString
2577 * a {@link String} object.
2578 * @param selectionType
2579 * @param selection
2580 * a {@link ICdmBase} object.
2581 * @param style
2582 * a int.
2583 * @param conversation
2584 * a {@link ConversationHolder} object.
2585 * @return a {@link EntitySelectionElement} object.
2586 */
2587 public <T extends ICdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
2588 ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
2589 int style) {
2590 EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
2591 labelString, selection, mode, style);
2592 adapt(element);
2593 parentElement.addElement(element);
2594 return element;
2595 }
2596
2597 public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
2598 ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
2599 TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
2600 labelString, selection, mode, style);
2601 adapt(element);
2602 parentElement.addElement(element);
2603 return element;
2604 }
2605
2606 public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2607 ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2608 int mode, int style) {
2609 NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2610 conversation, parentElement, labelString, selection, mode, style);
2611 adapt(element);
2612 parentElement.addElement(element);
2613 return element;
2614 }
2615
2616 /** {@inheritDoc} */
2617 public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2618 LabelElement labelElement = new LabelElement(this, parentElement, text);
2619 adapt(labelElement);
2620 parentElement.addElement(labelElement);
2621 return labelElement;
2622 }
2623
2624 public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style){
2625 Label label = new Label(formElement.getLayoutComposite(), style);
2626 label.setText(labelText+" (yyyy-MM-dd)");
2627 DateElement dateElement = new DateElement(formElement.getLayoutComposite(), dateTime, style);
2628 dateElement.initController(this, formElement);
2629 return dateElement;
2630 }
2631
2632 /**
2633 * <p>
2634 * Getter for the field <code>selectionProvider</code>.
2635 * </p>
2636 *
2637 * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2638 */
2639 public ISelectionProvider getSelectionProvider() {
2640 return selectionProvider;
2641 }
2642
2643 /**
2644 * <p>
2645 * createDetailedDescriptionDetailElement
2646 * </p>
2647 *
2648 * @param parentElement
2649 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
2650 * object.
2651 * @param entity
2652 * a
2653 * {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2654 * object.
2655 * @param style
2656 * a int.
2657 * @return a
2658 * {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2659 * object.
2660 */
2661 public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2662 ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
2663 AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2664
2665 if (entity instanceof CategoricalData) {
2666 detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
2667 (CategoricalData) entity, style);
2668 } else if (entity instanceof CommonTaxonName) {
2669 detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
2670 style);
2671 } else if (entity instanceof Distribution) {
2672 detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
2673 style);
2674 } else if (entity instanceof IndividualsAssociation) {
2675 detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
2676 (IndividualsAssociation) entity, style);
2677 } else if (entity instanceof QuantitativeData) {
2678 detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
2679 (QuantitativeData) entity, style);
2680 } else if (entity instanceof TaxonInteraction) {
2681 detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
2682 (TaxonInteraction) entity, style);
2683 } else if (entity instanceof TextData) {
2684 detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
2685 } else {
2686 throw new IllegalStateException("There is no interface for the given description element");
2687 }
2688 adapt(detailedDescriptionElement);
2689 parentElement.addElement(detailedDescriptionElement);
2690 return detailedDescriptionElement;
2691
2692 }
2693
2694 /**
2695 * Creates a styled text as a part of the form.
2696 *
2697 * @param parent
2698 * the text parent
2699 * @param value
2700 * the text initial value
2701 * @param style
2702 * the text style
2703 * @return the text widget
2704 */
2705 public StyledText createStyledText(Composite parent, String value, int style) {
2706 StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2707 if (value != null) {
2708 text.setText(value);
2709 }
2710 text.setForeground(getColors().getForeground());
2711 text.setBackground(getColors().getBackground());
2712 // text.addFocusListener(visibilityHandler);
2713 return text;
2714 }
2715
2716 public PreservedSpecimenDetailSection createPreservedSpecimenDetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
2717 PreservedSpecimenDetailSection section = new PreservedSpecimenDetailSection(this, conversation, parentElement, selectionProvider, style);
2718 addAndAdaptSection(parentElement, section);
2719 return section;
2720 }
2721
2722 }