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