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