Project

General

Profile

Download (4.59 KB) Statistics
| Branch: | Tag: | Revision:
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.ICdmFormElement;
19
import eu.etaxonomy.taxeditor.ui.forms.IEntityElement;
20
import eu.etaxonomy.taxeditor.ui.forms.SelectionArbitrator;
21
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractOriginalSourceElement;
22
import eu.etaxonomy.taxeditor.ui.selection.NameSelectionElement;
23
import eu.etaxonomy.taxeditor.singlesource.ui.forms.CdmFormFactoryFacade;
24
import eu.etaxonomy.taxeditor.singlesource.ui.forms.TextWithLabelElementFacade;
25
import eu.etaxonomy.taxeditor.singlesource.ui.forms.CdmFormFactoryFacade.SelectionType;
26
/**
27
 * <p>
28
 * DescriptionElementSourceElement class.
29
 * </p>
30
 * 
31
 * @author n.hoffmann
32
 * @created Nov 16, 2009
33
 * @version 1.0
34
 * @param <T>
35
 */
36
public class DescriptionElementSourceElement extends
37
		AbstractOriginalSourceElement<DescriptionElementSource> implements
38
		IEntityElement<DescriptionElementSource> {
39

    
40
	private final SelectionArbitrator selectionArbitrator;
41

    
42
	private NameSelectionElement selection_name;
43

    
44
	/**
45
	 * <p>
46
	 * Constructor for DescriptionElementSourceElement.
47
	 * </p>
48
	 * 
49
	 * @param formElement
50
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection}
51
	 *            object.
52
	 * @param element
53
	 *            a
54
	 *            {@link eu.etaxonomy.cdm.model.common.DescriptionElementSource}
55
	 *            object.
56
	 * @param removeListener
57
	 *            a {@link org.eclipse.swt.events.SelectionListener} object.
58
	 * @param style
59
	 *            a int.
60
	 * @param cdmFormFactory
61
	 *            a {@link eu.etaxonomy.taxeditor.singlesource.ui.forms.CdmFormFactoryFacade}
62
	 *            object.
63
	 */
64
	public DescriptionElementSourceElement(CdmFormFactoryFacade cdmFormFactory,
65
			AbstractFormSection formElement, DescriptionElementSource element,
66
			SelectionListener removeListener, int style) {
67
		super(cdmFormFactory, formElement, element, removeListener, style);
68
		selectionArbitrator = formFactory.createSelectionArbitrator(this);
69
	}
70

    
71
	/*
72
	 * (non-Javadoc)
73
	 * 
74
	 * @see eu.etaxonomy.taxeditor.forms.entitysections.OriginalSourceComposite#
75
	 * createControls(org.eclipse.swt.widgets.Composite, int)
76
	 */
77
	/** {@inheritDoc} */
78
	@Override
79
	public void createControls(ICdmFormElement formElement, int style) {
80
		super.createControls(formElement, style);
81
		selection_name = (NameSelectionElement) formFactory
82
				.createSelectionElement(SelectionType.NAME,
83
						getConversationHolder(), formElement, "Name in Source",
84
						null, NameSelectionElement.DEFAULT, SWT.NULL);
85
	}
86

    
87
	/*
88
	 * (non-Javadoc)
89
	 * 
90
	 * @see
91
	 * eu.etaxonomy.taxeditor.forms.section.cdmdetail.AbstractOriginalSourceElement
92
	 * #setElement(eu.etaxonomy.cdm.model.common.OriginalSourceBase)
93
	 */
94
	/** {@inheritDoc} */
95
	@Override
96
	public void setEntity(DescriptionElementSource entity) {
97
		super.setEntity(entity);
98
		text_idInSource.setText(entity.getIdInSource());
99
		text_idNamespace.setText(entity.getIdNamespace());
100

    
101
		selection_reference.setEntity(entity.getCitation());
102
		text_referenceDetail.setText(entity.getCitationMicroReference());
103
		text_originaleNameString.setText(entity.getOriginalNameString());
104
		selection_name.setEntity(entity.getNameUsedInSource());
105
	}
106

    
107
	/** {@inheritDoc} */
108
	@Override
109
	public void setSelected(boolean selected) {
110

    
111
	}
112

    
113
	/*
114
	 * (non-Javadoc)
115
	 * 
116
	 * @see
117
	 * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#handleEvent
118
	 * (java.lang.Object)
119
	 */
120
	/** {@inheritDoc} */
121
	@Override
122
	public void handleEvent(Object eventSource) {
123
		if (eventSource == text_idInSource) {
124
			getEntity().setIdInSource(text_idInSource.getText());
125
		} else if (eventSource == text_idNamespace) {
126
			getEntity().setIdNamespace(text_idNamespace.getText());
127
		} else if (eventSource == selection_reference) {
128
			getEntity().setCitation(selection_reference.getSelection());
129
		} else if (eventSource == text_referenceDetail) {
130
			getEntity().setCitationMicroReference(
131
					text_referenceDetail.getText());
132
		} else if (eventSource == text_originaleNameString) {
133
			getEntity().setOriginalNameString(
134
					text_originaleNameString.getText());
135
		} else if (eventSource == selection_name) {
136
			getEntity().setNameUsedInSource(selection_name.getSelection());
137
		}
138
	}
139

    
140
}
(8-8/24)