Project

General

Profile

Download (4.01 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2007 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10

    
11
package eu.etaxonomy.taxeditor.ui.section.classification;
12

    
13
import org.eclipse.swt.SWT;
14

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

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

    
40
	private TextWithLabelElement text_treeLabel;
41

    
42
	private EntitySelectionElement<Reference> selection_reference;
43

    
44
	private TextWithLabelElement text_microReference;
45

    
46
	private TimePeriodElement element_date;
47

    
48
    private GeoScopeDetailSection section_collectingAreas;
49

    
50

    
51

    
52

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

    
70
	/*
71
	 * (non-Javadoc)
72
	 *
73
	 * @see
74
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
75
	 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement,
76
	 * eu.etaxonomy.cdm.model.common.IAnnotatableEntity, int)
77
	 */
78
	/** {@inheritDoc} */
79
	@Override
80
	protected void createControls(ICdmFormElement formElement,
81
	        Classification entity, int style) {
82
	    text_treeLabel = formFactory.createTextWithLabelElement(formElement, "Label", entity != null ? entity.getName().getText() : null, SWT.NULL);
83
	    selection_reference = formFactory.createSelectionElement(Reference.class, getConversationHolder(), 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)