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