merge-update from trunk
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / DescriptionElementSourceElement.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.description;
12
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.events.SelectionListener;
15
16 import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
17 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
18 import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
19 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
20 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21 import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
22 import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractOriginalSourceElement;
23 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
24
25 /**
26 * <p>
27 * DescriptionElementSourceElement class.
28 * </p>
29 *
30 * @author n.hoffmann
31 * @created Nov 16, 2009
32 * @version 1.0
33 * @param <T>
34 */
35 public class DescriptionElementSourceElement extends
36 AbstractOriginalSourceElement<DescriptionElementSource> implements
37 IEntityElement<DescriptionElementSource> {
38
39 private EntitySelectionElement<TaxonNameBase> selection_name;
40
41 /**
42 * <p>
43 * Constructor for DescriptionElementSourceElement.
44 * </p>
45 *
46 * @param formElement
47 * a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
48 * object.
49 * @param element
50 * a
51 * {@link eu.etaxonomy.cdm.model.common.DescriptionElementSource}
52 * object.
53 * @param removeListener
54 * a {@link org.eclipse.swt.events.SelectionListener} object.
55 * @param style
56 * a int.
57 * @param cdmFormFactory
58 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
59 * object.
60 */
61 public DescriptionElementSourceElement(CdmFormFactory cdmFormFactory,
62 AbstractFormSection formElement, DescriptionElementSource element,
63 SelectionListener removeListener, int style) {
64 super(cdmFormFactory, formElement, element, removeListener, style);
65 formFactory.createSelectionArbitrator(this);
66 }
67
68 /*
69 * (non-Javadoc)
70 *
71 * @see eu.etaxonomy.taxeditor.forms.entitysections.OriginalSourceComposite#
72 * createControls(org.eclipse.swt.widgets.Composite, int)
73 */
74 /** {@inheritDoc} */
75 @Override
76 public void createControls(ICdmFormElement formElement, int style) {
77 super.createControls(formElement, style);
78 selection_name = formFactory
79 .createSelectionElement(TaxonNameBase.class,
80 getConversationHolder(), formElement, "Name in Source",
81 null, EntitySelectionElement.ALL, SWT.NULL);
82 }
83
84 /*
85 * (non-Javadoc)
86 *
87 * @see
88 * eu.etaxonomy.taxeditor.forms.section.cdmdetail.AbstractOriginalSourceElement
89 * #setElement(eu.etaxonomy.cdm.model.common.OriginalSourceBase)
90 */
91 /** {@inheritDoc} */
92 @Override
93 public void setEntity(DescriptionElementSource entity) {
94 super.setEntity(entity);
95 text_idInSource.setText(entity.getIdInSource());
96 text_idNamespace.setText(entity.getIdNamespace());
97
98 selection_reference.setEntity(entity.getCitation());
99 text_referenceDetail.setText(entity.getCitationMicroReference());
100 text_originaleNameString.setText(entity.getOriginalNameString());
101 selection_name.setEntity(entity.getNameUsedInSource());
102 combo_origsourcetype.setSelection(entity.getType());
103 }
104
105 /** {@inheritDoc} */
106 @Override
107 public void setSelected(boolean selected) {
108
109 }
110
111 /*
112 * (non-Javadoc)
113 *
114 * @see
115 * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#handleEvent
116 * (java.lang.Object)
117 */
118 /** {@inheritDoc} */
119 @Override
120 public void handleEvent(Object eventSource) {
121 if (eventSource == text_idInSource) {
122 getEntity().setIdInSource(text_idInSource.getText());
123 } else if (eventSource == text_idNamespace) {
124 getEntity().setIdNamespace(text_idNamespace.getText());
125 } else if (eventSource == selection_reference) {
126 getEntity().setCitation(selection_reference.getSelection());
127 } else if (eventSource == text_referenceDetail) {
128 getEntity().setCitationMicroReference(
129 text_referenceDetail.getText());
130 } else if (eventSource == text_originaleNameString) {
131 getEntity().setOriginalNameString(
132 text_originaleNameString.getText());
133 } else if (eventSource == selection_name) {
134 getEntity().setNameUsedInSource(selection_name.getSelection());
135 }
136 }
137
138 }