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