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