Project

General

Profile

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

    
94
	}
95

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