Project

General

Profile

Download (4 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.preference.EditorPreferencePredicate;
19
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
20
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
21
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
22
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
23
import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
24
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
25
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractOriginalSourceElement;
26
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
27

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

    
38
	private EntitySelectionElement<TaxonName> selection_name;
39

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

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

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

    
60
	/** {@inheritDoc} */
61
	@Override
62
	public void setEntity(DescriptionElementSource entity) {
63
		super.setEntity(entity);
64
		if (PreferencesUtil.getBooleanValue(EditorPreferencePredicate.ShowIdInSource.getKey())){
65
		    text_idInSource.setText(entity.getIdInSource());
66
		}
67
		if (PreferencesUtil.getBooleanValue(EditorPreferencePredicate.ShowNamespaceInSource.getKey())){
68
		    text_idNamespace.setText(entity.getIdNamespace());
69
		}
70

    
71
		selection_reference.setEntity(entity.getCitation());
72
		text_referenceDetail.setText(entity.getCitationMicroReference());
73
		text_originaleNameString.setText(entity.getOriginalNameString());
74
		selection_name.setEntity(entity.getNameUsedInSource());
75
		combo_origsourcetype.setSelection(entity.getType());
76
	}
77

    
78
	/** {@inheritDoc} */
79
	@Override
80
	public void setSelected(boolean selected) {
81

    
82
	}
83

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

    
106
	}
107

    
108
}
(9-9/26)