Project

General

Profile

Download (4.36 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
//        AbstractEntityCollectionElement<Reference> {
38

    
39
		AbstractOriginalSourceElement<DescriptionElementSource> implements
40
		IEntityElement<DescriptionElementSource>{//, IEnableableFormElement {
41
    private EntitySelectionElement<Reference> selection_descriptionElementSource;
42
	private EntitySelectionElement<TaxonName> selection_name;
43
	boolean isEnabled = true;
44

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

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

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

    
65

    
66
	/** {@inheritDoc} */
67
	@Override
68
	public void setEntity(DescriptionElementSource entity) {
69
		super.setEntity(entity);
70
		if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
71
		    text_idInSource.setText(entity.getIdInSource());
72
		}
73
		if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){
74
		    text_idNamespace.setText(entity.getIdNamespace());
75
		}
76

    
77
		selection_reference.setEntity(entity.getCitation());
78
		text_referenceDetail.setText(entity.getCitationMicroReference());
79
		text_originaleNameString.setText(entity.getOriginalNameString());
80
		selection_name.setEntity(entity.getNameUsedInSource());
81
		combo_origsourcetype.setSelection(entity.getType());
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)