refactoring of package names for consistency
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / classification / ClassificationDetailElement.java
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.apache.log4j.Logger;
14 import org.eclipse.swt.SWT;
15
16 import eu.etaxonomy.cdm.model.common.LanguageString;
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.CdmPropertyChangeEvent;
21 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
23 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.SelectionType;
24 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
25 import eu.etaxonomy.taxeditor.ui.selection.ReferenceSelectionElement;
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 static final Logger logger = Logger
40 .getLogger(ClassificationDetailElement.class);
41
42 private TextWithLabelElement text_treeLabel;
43
44 private ReferenceSelectionElement selection_reference;
45
46 private TextWithLabelElement text_microReference;
47
48 /**
49 * <p>
50 * Constructor for ClassificationDetailElement.
51 * </p>
52 *
53 * @param formFactory
54 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
55 * object.
56 * @param formElement
57 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
58 * object.
59 */
60 public ClassificationDetailElement(CdmFormFactory formFactory,
61 ICdmFormElement formElement) {
62 super(formFactory, formElement);
63 }
64
65 /*
66 * (non-Javadoc)
67 *
68 * @see
69 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
70 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement,
71 * eu.etaxonomy.cdm.model.common.IAnnotatableEntity, int)
72 */
73 /** {@inheritDoc} */
74 @Override
75 protected void createControls(ICdmFormElement formElement,
76 Classification entity, int style) {
77 text_treeLabel = formFactory.createTextWithLabelElement(formElement,
78 "Label", entity != null ? entity.getTitleCache() : null,
79 SWT.NULL);
80 selection_reference = (ReferenceSelectionElement) formFactory
81 .createSelectionElement(SelectionType.REFERENCE,
82 getConversationHolder(), formElement, "Reference",
83 entity != null ? entity.getReference() : null,
84 ReferenceSelectionElement.DEFAULT, SWT.NULL);
85 text_microReference = formFactory.createTextWithLabelElement(
86 formElement, "Reference Detail",
87 entity != null ? entity.getMicroReference() : null, SWT.NULL);
88 }
89
90 /*
91 * (non-Javadoc)
92 *
93 * @see
94 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
95 * .lang.Object)
96 */
97 /** {@inheritDoc} */
98 @Override
99 public void handleEvent(Object eventSource) {
100 if (eventSource == text_treeLabel) {
101 LanguageString languageString = LanguageString.NewInstance(
102 text_treeLabel.getText(), CdmStore.getDefaultLanguage());
103 getEntity().setName(languageString);
104 } else if (eventSource == selection_reference) {
105 getEntity().setReference(selection_reference.getEntity());
106 } else if (eventSource == text_microReference) {
107 getEntity().setMicroReference(text_microReference.getText());
108 }
109 }
110 }