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