merged campanula branch to trunk. Main features are: BioCase Query via Imports, Deriv...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / DescriptionDetailElement.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.description;
12
13 import org.eclipse.swt.SWT;
14
15 import eu.etaxonomy.cdm.model.description.DescriptionBase;
16 import eu.etaxonomy.cdm.model.description.FeatureTree;
17 import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
18 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
20 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
21 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
22
23 /**
24 * <p>DescriptionDetailElement class.</p>
25 *
26 * @author n.hoffmann
27 * @created Mar 5, 2010
28 * @version 1.0
29 */
30 public class DescriptionDetailElement extends AbstractCdmDetailElement<DescriptionBase> {
31
32 private TextWithLabelElement detailDescription;
33 private EntitySelectionElement<FeatureTree> selection_featureTree;
34
35 /**
36 * <p>Constructor for DescriptionDetailElement.</p>
37 *
38 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
39 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
40 * @param style a int.
41 */
42 public DescriptionDetailElement(CdmFormFactory cdmFormFactory,
43 ICdmFormElement formElement, int style) {
44 super(cdmFormFactory, formElement);
45 }
46
47 /** {@inheritDoc} */
48 @Override
49 protected void createControls(ICdmFormElement formElement, DescriptionBase entity, int style) {
50 detailDescription = formFactory.createMultilineTextWithLabel(this, "Label", 50, SWT.WRAP);
51 detailDescription.setText(entity.getTitleCache());
52
53 // TODO I initially thought that we can handle the entity's descriptive system with a feature tree
54 // Since descriptiveSystem is a Set of Features that are present or allowed for the current description,
55 // it is similar to a FeatureTree (you can get this information from a feature tree) but not the same.
56 // Please correct this once it is clear what descriptive system will be used for in CDM
57 // selection_featureTree = formFactory.createSelectionElement(FeatureTree.class, getConversationHolder(), formElement, "Feature Tree", null, EntitySelectionElement.ALL, style);
58 }
59
60 /** {@inheritDoc} */
61 @Override
62 public void handleEvent(Object eventSource) {
63 if(eventSource == detailDescription){
64 getEntity().setTitleCache(detailDescription.getText(), true);
65 }
66 else if(eventSource == selection_featureTree){
67 FeatureTree featureTree = selection_featureTree.getSelection();
68 //descriptive system is not available anymore since v3.3
69 // getEntity().setDescriptiveSystem(featureTree.getDistinctFeatures());
70 }
71 }
72 }