Project

General

Profile

Download (4.01 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(), formElement, "Reference",
83
	            entity != null ? entity.getReference() : null, EntitySelectionElement.ALL, SWT.NULL);
84
	    text_microReference = formFactory.createTextWithLabelElement(formElement, "Reference Detail",
85
	            entity != null ? entity.getMicroReference() : null, SWT.NULL);
86
	       element_date = formFactory.createTimePeriodElement(formElement, "Date",
87
                   entity.getTimeperiod(), style);
88
	       section_collectingAreas = formFactory.createGeoScopeDetailSection(getConversationHolder(), formElement, SWT.NULL);
89
           section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
90
           section_collectingAreas.setEntity(entity);
91

    
92
	}
93

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