had to rename the packages to make them compliant with buckminster
[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.common.DescriptionElementSource;
17 import eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection;
18 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
19 import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
20 import eu.etaxonomy.taxeditor.ui.forms.IEntityElement;
21 import eu.etaxonomy.taxeditor.ui.forms.SelectionArbitrator;
22 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
23 import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractOriginalSourceElement;
24 import eu.etaxonomy.taxeditor.ui.selection.NameSelectionElement;
25
26 /**
27 * <p>DescriptionElementSourceElement class.</p>
28 *
29 * @author n.hoffmann
30 * @created Nov 16, 2009
31 * @version 1.0
32 * @param <T>
33 */
34 public class DescriptionElementSourceElement extends AbstractOriginalSourceElement<DescriptionElementSource> implements IEntityElement<DescriptionElementSource>{
35
36 private SelectionArbitrator selectionArbitrator;
37
38 private NameSelectionElement selection_name;
39
40
41 /**
42 * <p>Constructor for DescriptionElementSourceElement.</p>
43 *
44 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection} object.
45 * @param element a {@link eu.etaxonomy.cdm.model.common.DescriptionElementSource} object.
46 * @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
47 * @param style a int.
48 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
49 */
50 public DescriptionElementSourceElement(CdmFormFactory cdmFormFactory, AbstractFormSection formElement,
51 DescriptionElementSource element, SelectionListener removeListener, int style) {
52 super(cdmFormFactory, formElement, element, removeListener, style);
53 selectionArbitrator = formFactory.createSelectionArbitrator(this);
54 }
55
56 /* (non-Javadoc)
57 * @see eu.etaxonomy.taxeditor.forms.entitysections.OriginalSourceComposite#createControls(org.eclipse.swt.widgets.Composite, int)
58 */
59 /** {@inheritDoc} */
60 @Override
61 public void createControls(ICdmFormElement formElement, int style) {
62 super.createControls(formElement, style);
63 selection_name = (NameSelectionElement) formFactory.createSelectionElement(SelectionType.NAME, getConversationHolder(), formElement, "Name in Source", null, SWT.NULL);
64 }
65
66 /*
67 * (non-Javadoc)
68 * @see eu.etaxonomy.taxeditor.forms.section.cdmdetail.AbstractOriginalSourceElement#setElement(eu.etaxonomy.cdm.model.common.OriginalSourceBase)
69 */
70 /** {@inheritDoc} */
71 @Override
72 public void setEntity(DescriptionElementSource entity) {
73 super.setEntity(entity);
74 text_idInSource.setText(entity.getIdInSource());
75 text_idNamespace.setText(entity.getIdNamespace());
76
77 selection_reference.setEntity(entity.getCitation());
78 text_referenceDetail.setText(entity.getCitationMicroReference());
79 text_originaleNameString.setText(entity.getOriginalNameString());
80 selection_name.setEntity(entity.getNameUsedInSource());
81 }
82
83
84 /** {@inheritDoc} */
85 public void setSelected(boolean selected) {
86
87 }
88
89 /*
90 * (non-Javadoc)
91 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#handleEvent(java.lang.Object)
92 */
93 /** {@inheritDoc} */
94 @Override
95 public void handleEvent(Object eventSource) {
96 if(eventSource == text_idInSource){
97 getEntity().setIdInSource(text_idInSource.getText());
98 }
99 else if(eventSource == text_idNamespace){
100 getEntity().setIdNamespace(text_idNamespace.getText());
101 }
102 else if(eventSource == selection_reference){
103 getEntity().setCitation(selection_reference.getSelection());
104 }
105 else if(eventSource == text_referenceDetail){
106 getEntity().setCitationMicroReference(text_referenceDetail.getText());
107 }
108 else if(eventSource == text_originaleNameString){
109 getEntity().setOriginalNameString(text_originaleNameString.getText());
110 }
111 else if(eventSource == selection_name){
112 getEntity().setNameUsedInSource(selection_name.getSelection());
113 }
114 }
115
116 }