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