merge-update from trunk
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / SpecimenCollectionDetailElement.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.taxeditor.ui.section.occurrence;
12
13 import org.eclipse.swt.events.SelectionListener;
14
15 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
16 import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
17 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
18 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
20 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
21
22 /**
23 * <p>
24 * SpecimenCollectionDetailElement class.
25 * </p>
26 *
27 * @author n.hoffmann
28 * @created Oct 14, 2010
29 * @version 1.0
30 */
31 public class SpecimenCollectionDetailElement extends
32 AbstractEntityCollectionElement<DerivedUnit> {
33
34 private EntitySelectionElement<DerivedUnit> selection_derivedUnit;
35
36 /**
37 * <p>
38 * Constructor for SpecimenCollectionDetailElement.
39 * </p>
40 *
41 * @param formFactory
42 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
43 * object.
44 * @param section
45 * a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
46 * object.
47 * @param entity
48 * a {@link eu.etaxonomy.cdm.model.occurrence.Specimen} object.
49 * @param removeListener
50 * a {@link org.eclipse.swt.events.SelectionListener} object.
51 * @param style
52 * a int.
53 */
54 public SpecimenCollectionDetailElement(CdmFormFactory formFactory,
55 AbstractFormSection section, DerivedUnit entity,
56 SelectionListener removeListener, int style) {
57 super(formFactory, section, entity, removeListener, null, style);
58 }
59
60 /*
61 * (non-Javadoc)
62 *
63 * @see
64 * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#setEntity
65 * (java.lang.Object)
66 */
67 /** {@inheritDoc} */
68 @Override
69 public void setEntity(DerivedUnit entity) {
70 this.entity = entity;
71 selection_derivedUnit.setEntity(entity);
72 }
73
74 /*
75 * (non-Javadoc)
76 *
77 * @see
78 * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#createControls
79 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
80 */
81 /** {@inheritDoc} */
82 @Override
83 public void createControls(ICdmFormElement element, int style) {
84 selection_derivedUnit = formFactory
85 .createSelectionElement(DerivedUnit.class,
86 getConversationHolder(), element, "Derived Unit", null,
87 EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
88 }
89
90 /*
91 * (non-Javadoc)
92 *
93 * @see
94 * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#handleEvent
95 * (java.lang.Object)
96 */
97 /** {@inheritDoc} */
98 @Override
99 public void handleEvent(Object eventSource) {
100 if (eventSource == selection_derivedUnit) {
101 this.setEntity((DerivedUnit) selection_derivedUnit.getSelection());
102 }
103 }
104
105 }