Project

General

Profile

Download (3.52 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.name;
11

    
12
import org.eclipse.swt.events.SelectionListener;
13

    
14
import eu.etaxonomy.cdm.api.service.IVocabularyService;
15
import eu.etaxonomy.cdm.model.common.TermVocabulary;
16
import eu.etaxonomy.cdm.model.common.VocabularyEnum;
17
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
18
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
19
import eu.etaxonomy.taxeditor.store.CdmStore;
20
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
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.ISelectableElement;
26
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
27
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
28
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractReferencedEntityElement;
29

    
30
/**
31
 * @author n.hoffmann
32
 * @created Nov 5, 2009
33
 * @version 1.0
34
 */
35
public class NomenclaturalStatusElement extends AbstractReferencedEntityElement<NomenclaturalStatus> implements IEntityElement<NomenclaturalStatus>, ISelectableElement{
36

    
37
	private TermComboElement<NomenclaturalStatusType> nomenclaturalStatusTypeCombo;
38

    
39
	private TextWithLabelElement ruleConsideredText;
40

    
41
	private final SelectionArbitrator selectionArbitrator;
42

    
43
	public NomenclaturalStatusElement(CdmFormFactory cdmFormFactory, AbstractFormSection formElement,
44
			NomenclaturalStatus element, SelectionListener removeListener, int style) {
45
		super(cdmFormFactory, formElement, element, removeListener, style);
46
		selectionArbitrator = cdmFormFactory.createSelectionArbitrator(this);
47
	}
48

    
49
	/** {@inheritDoc} */
50
	@Override
51
	public void createControls(ICdmFormElement element, int style) {
52
	    TermVocabulary vocabulary = CdmStore.getService(IVocabularyService.class).find(VocabularyEnum.NomenclaturalStatusType.getUuid());
53
		nomenclaturalStatusTypeCombo = formFactory.createDefinedTermComboElement(vocabulary, this, "Nomenclatural Status Type", null,false, style, true);
54
		ruleConsideredText = formFactory.createTextWithLabelElement(this, "Rule Considered", "", style);
55

    
56
		super.createControls(element, style);
57
	}
58

    
59
	/** {@inheritDoc} */
60
	@Override
61
	public void setEntity(NomenclaturalStatus entity) {
62
		super.setEntity(entity);
63
		nomenclaturalStatusTypeCombo.setSelection(entity.getType());
64
		ruleConsideredText.setText(entity.getRuleConsidered());
65
	}
66

    
67
	/**
68
	 * <p>Getter for the field <code>selectionArbitrator</code>.</p>
69
	 *
70
	 * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} object.
71
	 */
72
	@Override
73
    public SelectionArbitrator getSelectionArbitrator() {
74
		return selectionArbitrator;
75
	}
76

    
77
	/** {@inheritDoc} */
78
	@Override
79
	public void handleEvent(Object eventSource) {
80
		if(eventSource == nomenclaturalStatusTypeCombo){
81
			getEntity().setType(nomenclaturalStatusTypeCombo.getSelection());
82
		}
83
		else if(eventSource == ruleConsideredText){
84
			getEntity().setRuleConsidered(ruleConsideredText.getText());
85
		}
86
		else if(eventSource == selection_reference){
87
			getEntity().setCitation(selection_reference.getSelection());
88
		}
89
		else if(eventSource == text_referenceDetail){
90
			getEntity().setCitationMicroReference(text_referenceDetail.getText());
91
		}
92
	}
93
}
(13-13/21)