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