merge-update from trunk
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / vocabulary / NamedAreaDetailElement.java
1 // $Id$
2 /**
3 * Copyright (C) 2009 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 package eu.etaxonomy.taxeditor.ui.section.vocabulary;
11
12 import java.net.URISyntaxException;
13
14 import eu.etaxonomy.cdm.model.common.Language;
15 import eu.etaxonomy.cdm.model.location.NamedArea;
16 import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
17 import eu.etaxonomy.cdm.model.location.NamedAreaType;
18 import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
19 import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
20 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21 import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
22
23 /**
24 * @author l.morris
25 * @date 20 Dec 2011
26 *
27 */
28 public class NamedAreaDetailElement extends DefinedTermDetailElement<NamedArea> {
29
30 // level
31 // type
32 private TermComboElement<NamedAreaType> combo_namedAreaType;
33 private TermComboElement<NamedAreaLevel> combo_namedAreaLevel;
34 // validPeriod
35 private TimePeriodElement timePeriod_validPeriod;
36
37 /**
38 * @param formFactory
39 * @param formElement
40 */
41 public NamedAreaDetailElement(CdmFormFactory formFactory,
42 ICdmFormElement formElement) {
43 super(formFactory, formElement);
44 }
45
46 public void createControls(ICdmFormElement formElement, NamedArea entity, int style) {
47 super.createControls(formElement, entity, style);
48
49 timePeriod_validPeriod = formFactory.createTimePeriodElement(formElement, "Valid Period", getEntity().getValidPeriod(), style);
50 combo_namedAreaType = formFactory.createTermComboElement(NamedAreaType.class, formElement, "Named Area Type", getEntity().getType(), style);
51 combo_namedAreaLevel = formFactory.createTermComboElement(NamedAreaLevel.class, formElement, "Named Area Level", getEntity().getLevel(), style);
52
53 }
54
55 /* (non-Javadoc)
56 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement#handleEvent(java.lang.Object)
57 */
58 @Override
59 public void handleEvent(Object eventSource) {
60
61 if (eventSource == text_label) {
62 getEntity().setLabel(text_label.getText());
63 getEntity().setTitleCache(null);
64 } else if (eventSource == text_description) {
65
66 getEntity().getRepresentation(Language.DEFAULT()).setText(text_description.getText());
67
68 } else if (eventSource == uri_uri) {
69
70 try {
71 getEntity().setUri(uri_uri.getUri());
72 } catch (URISyntaxException e) {
73
74 e.printStackTrace();
75 }
76 } else if (eventSource == text_abbreviatedLabel) {
77 getEntity().getRepresentation(Language.DEFAULT()).setAbbreviatedLabel(text_abbreviatedLabel.getText());
78 } else if (eventSource == timePeriod_validPeriod) {
79 getEntity().setValidPeriod(timePeriod_validPeriod.getTimePeriod());
80 } else if (eventSource == combo_namedAreaType) {
81 getEntity().setType(combo_namedAreaType.getSelection());
82 } else if (eventSource == combo_namedAreaLevel) {
83 getEntity().setLevel(combo_namedAreaLevel.getSelection());
84 }
85
86
87 }
88
89
90 }