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