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