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