Project

General

Profile

Download (3.69 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9

    
10
package eu.etaxonomy.taxeditor.ui.section.description;
11

    
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.events.SelectionListener;
14
import org.eclipse.ui.forms.widgets.ExpandableComposite;
15

    
16
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
17
import eu.etaxonomy.cdm.model.name.TaxonName;
18
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
19
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
21
import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
22
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
23
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractOriginalSourceElement;
24
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
25

    
26
/**
27
 *
28
 * @author n.hoffmann
29
 * @created Nov 16, 2009
30
 * @version 1.0
31
 */
32
public class DescriptionElementSourceElement extends
33
		AbstractOriginalSourceElement<DescriptionElementSource> implements
34
		IEntityElement<DescriptionElementSource> {
35

    
36
	private EntitySelectionElement<TaxonName> selection_name;
37

    
38
	public DescriptionElementSourceElement(CdmFormFactory cdmFormFactory,
39
			AbstractFormSection<?> formElement, DescriptionElementSource element,
40
			SelectionListener removeListener, int style, boolean isCommonNameReference) {
41
		super(cdmFormFactory, formElement, element, removeListener, style, isCommonNameReference);
42
		formFactory.createSelectionArbitrator(this);
43
	}
44

    
45
	/** {@inheritDoc} */
46
	@Override
47
	public void createControls(ICdmFormElement formElement, int style) {
48
		super.createControls(formElement, style);
49
		selection_name = formFactory
50
				.createSelectionElement(TaxonName.class,//getConversationHolder(),
51
				        formElement, "Name in Source",
52
						null, EntitySelectionElement.ALL, SWT.NULL);
53

    
54
		externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
55
        externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
56
	}
57

    
58
	/** {@inheritDoc} */
59
	@Override
60
	public void setEntity(DescriptionElementSource entity) {
61
		super.setEntity(entity);
62
		text_idInSource.setText(entity.getIdInSource());
63
		text_idNamespace.setText(entity.getIdNamespace());
64

    
65
		selection_reference.setEntity(entity.getCitation());
66
		text_referenceDetail.setText(entity.getCitationMicroReference());
67
		text_originaleNameString.setText(entity.getOriginalNameString());
68
		selection_name.setEntity(entity.getNameUsedInSource());
69
		combo_origsourcetype.setSelection(entity.getType());
70
	}
71

    
72
	/** {@inheritDoc} */
73
	@Override
74
	public void setSelectedForColorChange(boolean selected) {
75

    
76
	}
77

    
78
	/** {@inheritDoc} */
79
	@Override
80
	public void handleEvent(Object eventSource) {
81
		if (eventSource == text_idInSource) {
82
			getEntity().setIdInSource(text_idInSource.getText());
83
		} else if (eventSource == text_idNamespace) {
84
			getEntity().setIdNamespace(text_idNamespace.getText());
85
		} else if (eventSource == selection_reference) {
86
		    getEntity().setCitation(selection_reference.getSelection());
87
		} else if (eventSource == text_referenceDetail) {
88
			getEntity().setCitationMicroReference(
89
					text_referenceDetail.getText());
90
		} else if (eventSource == text_originaleNameString) {
91
			getEntity().setOriginalNameString(
92
					text_originaleNameString.getText());
93
		} else if (eventSource == selection_name) {
94
			getEntity().setNameUsedInSource(selection_name.getSelection());
95
		}
96
		else if(eventSource == combo_origsourcetype){
97
		    getEntity().setType(combo_origsourcetype.getSelection());
98
		}
99

    
100
	}
101

    
102
}
(9-9/26)