Project

General

Profile

Download (4.35 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.cdm.model.reference.Reference;
19
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
20
import eu.etaxonomy.taxeditor.store.StoreUtil;
21
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
22
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
23
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
24
import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
25
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
26
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
27
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractOriginalSourceElement;
28
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
29

    
30
/**
31
 *
32
 * @author n.hoffmann
33
 * @created Nov 16, 2009
34
 * @version 1.0
35
 */
36
public class DescriptionElementSourceElement extends
37
		AbstractOriginalSourceElement<DescriptionElementSource> implements
38
		IEntityElement<DescriptionElementSource>{//, IEnableableFormElement {
39
    private EntitySelectionElement<Reference> selection_descriptionElementSource;
40
	private EntitySelectionElement<TaxonName> selection_name;
41
	boolean isEnabled = true;
42

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

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

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

    
63

    
64
	/** {@inheritDoc} */
65
	@Override
66
	public void setEntity(DescriptionElementSource entity) {
67
		super.setEntity(entity);
68
		if (text_idInSource != null){
69
			if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
70
			    text_idInSource.setText(entity.getIdInSource());
71
			}
72
			if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){
73
			    text_idNamespace.setText(entity.getIdNamespace());
74
			}
75
	
76
			selection_reference.setEntity(entity.getCitation());
77
			text_referenceDetail.setText(entity.getCitationMicroReference());
78
			text_originaleNameString.setText(entity.getOriginalNameString());
79
			selection_name.setEntity(entity.getNameUsedInSource());
80
			combo_origsourcetype.setSelection(entity.getType());
81
		}
82
	}
83

    
84
	/** {@inheritDoc} */
85
	@Override
86
	public void setSelected(boolean selected) {
87

    
88
	}
89

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

    
112
	}
113

    
114
}
(9-9/26)