Project

General

Profile

Download (4.02 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.classification;
11

    
12
import org.eclipse.swt.SWT;
13

    
14
import eu.etaxonomy.cdm.model.common.LanguageString;
15
import eu.etaxonomy.cdm.model.reference.Reference;
16
import eu.etaxonomy.cdm.model.taxon.Classification;
17
import eu.etaxonomy.taxeditor.store.CdmStore;
18
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
21
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
22
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
23
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
24
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopeDetailSection;
25
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
26

    
27
/**
28
 * <p>
29
 * ClassificationDetailElement class.
30
 * </p>
31
 *
32
 * @author n.hoffmann
33
 * @created Sep 27, 2010
34
 * @version 1.0
35
 */
36
public class ClassificationDetailElement extends
37
		AbstractCdmDetailElement<Classification> {
38

    
39
	private TextWithLabelElement text_treeLabel;
40

    
41
	private EntitySelectionElement<Reference> selection_reference;
42

    
43
	private TextWithLabelElement text_microReference;
44

    
45
	private TimePeriodElement element_date;
46

    
47
    private GeoScopeDetailSection section_collectingAreas;
48

    
49

    
50

    
51

    
52
	/**
53
	 * <p>
54
	 * Constructor for ClassificationDetailElement.
55
	 * </p>
56
	 *
57
	 * @param formFactory
58
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
59
	 *            object.
60
	 * @param formElement
61
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
62
	 *            object.
63
	 */
64
	public ClassificationDetailElement(CdmFormFactory formFactory,
65
			ICdmFormElement formElement) {
66
		super(formFactory, formElement);
67
	}
68

    
69
	/*
70
	 * (non-Javadoc)
71
	 *
72
	 * @see
73
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
74
	 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement,
75
	 * eu.etaxonomy.cdm.model.common.IAnnotatableEntity, int)
76
	 */
77
	/** {@inheritDoc} */
78
	@Override
79
	protected void createControls(ICdmFormElement formElement,
80
	        Classification entity, int style) {
81
	    text_treeLabel = formFactory.createTextWithLabelElement(formElement, "Label", entity != null ? entity.getName().getText() : null, SWT.NULL);
82
	    selection_reference = formFactory.createSelectionElement(Reference.class, //getConversationHolder(),
83
	            formElement, "Reference",
84
	            entity != null ? entity.getReference() : null, EntitySelectionElement.ALL, SWT.NULL);
85
	    text_microReference = formFactory.createTextWithLabelElement(formElement, "Reference Detail",
86
	            entity != null ? entity.getMicroReference() : null, SWT.NULL);
87
	       element_date = formFactory.createTimePeriodElement(formElement, "Date",
88
                   entity.getTimeperiod(), style);
89
	       section_collectingAreas = formFactory.createGeoScopeDetailSection(getConversationHolder(), formElement, SWT.NULL);
90
           section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
91
           section_collectingAreas.setEntity(entity);
92

    
93
	}
94

    
95
	/*
96
	 * (non-Javadoc)
97
	 *
98
	 * @see
99
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
100
	 * .lang.Object)
101
	 */
102
	/** {@inheritDoc} */
103
	@Override
104
	public void handleEvent(Object eventSource) {
105
		if (eventSource == text_treeLabel) {
106
			LanguageString languageString = LanguageString.NewInstance(
107
					text_treeLabel.getText(), CdmStore.getDefaultLanguage());
108
			getEntity().setName(languageString);
109
		} else if (eventSource == selection_reference) {
110
			getEntity().setReference(selection_reference.getEntity());
111
		} else if (eventSource == text_microReference) {
112
			getEntity().setMicroReference(text_microReference.getText());
113
		}else if (eventSource == element_date) {
114
            getEntity().setTimeperiod(element_date.getTimePeriod());
115
		}
116
	}
117
}
(2-2/12)