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