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