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.description;
|
11
|
|
12
|
import java.util.Arrays;
|
13
|
|
14
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
15
|
|
16
|
import eu.etaxonomy.cdm.model.description.DescriptionBase;
|
17
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
|
20
|
|
21
|
/**
|
22
|
* <p>DescriptionDetailElement class.</p>
|
23
|
*
|
24
|
* @author n.hoffmann
|
25
|
* @created Mar 5, 2010
|
26
|
* @version 1.0
|
27
|
*/
|
28
|
public class DescriptionDetailElement extends AbstractIdentifiableEntityDetailElement<DescriptionBase> {
|
29
|
|
30
|
// private EntitySelectionElement<FeatureTree> selection_featureTree;
|
31
|
|
32
|
public DescriptionDetailElement(CdmFormFactory cdmFormFactory,
|
33
|
ICdmFormElement formElement, int style) {
|
34
|
super(cdmFormFactory, formElement);
|
35
|
}
|
36
|
|
37
|
@Override
|
38
|
protected void createControls(ICdmFormElement formElement, DescriptionBase entity, int style) {
|
39
|
toggleable_cache = formFactory.createToggleableTextField(this, "Label", entity.getTitleCache(), entity.isProtectedTitleCache(), style);
|
40
|
// TODO I initially thought that we can handle the entity's descriptive system with a feature tree
|
41
|
// Since descriptiveSystem is a Set of Features that are present or allowed for the current description,
|
42
|
// it is similar to a FeatureTree (you can get this information from a feature tree) but not the same.
|
43
|
// Please correct this once it is clear what descriptive system will be used for in CDM
|
44
|
// selection_featureTree = formFactory.createSelectionElement(FeatureTree.class, getConversationHolder(), formElement, "Feature Tree", null, EntitySelectionElement.ALL, style);
|
45
|
}
|
46
|
|
47
|
@Override
|
48
|
protected void updateContent() {
|
49
|
super.updateContent();
|
50
|
toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
|
51
|
setIrrelevant(toggleable_cache.getState(),
|
52
|
Arrays.asList(new Object[] { toggleable_cache}));
|
53
|
}
|
54
|
|
55
|
@Override
|
56
|
protected void handleTitleCacheRelevantChange(PropertyChangeEvent event) {
|
57
|
if(!getEntity().isProtectedTitleCache()){
|
58
|
String title = getEntity().generateTitle();
|
59
|
getEntity().setTitleCache(title, false);
|
60
|
}
|
61
|
super.updateToggleableCacheField();
|
62
|
}
|
63
|
|
64
|
@Override
|
65
|
public void handleEvent(Object eventSource) {
|
66
|
if (eventSource == toggleable_cache) {
|
67
|
getEntity().setTitleCache(toggleable_cache.getText(), toggleable_cache.getState());
|
68
|
setIrrelevant(toggleable_cache.getState(), Arrays.asList(new Object[] { toggleable_cache }));
|
69
|
}
|
70
|
}
|
71
|
}
|