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