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