Project

General

Profile

Download (4.12 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

    
15
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
16
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
17
import eu.etaxonomy.cdm.model.name.TaxonName;
18
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
19
import eu.etaxonomy.taxeditor.store.StoreUtil;
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.common.ExternalLinksSection;
26
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractOriginalSourceElement;
27
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
28

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

    
39
	private EntitySelectionElement<TaxonName> selection_name;
40

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

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

    
57
		externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
58
        externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
59
	}
60

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

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

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

    
83
	}
84

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

    
107
	}
108

    
109
}
(9-9/26)