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
|
package eu.etaxonomy.taxeditor.ui.section.description;
|
10
|
|
11
|
import java.util.stream.Collectors;
|
12
|
|
13
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.description.DescriptionBase;
|
16
|
import eu.etaxonomy.cdm.model.description.DescriptionType;
|
17
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
20
|
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
|
21
|
|
22
|
/**
|
23
|
* <p>DescriptionDetailElement class.</p>
|
24
|
*
|
25
|
* @author n.hoffmann
|
26
|
* @created Mar 5, 2010
|
27
|
*/
|
28
|
public class DescriptionDetailElement
|
29
|
extends AbstractIdentifiableEntityDetailElement<DescriptionBase<?>> {
|
30
|
|
31
|
// private EntitySelectionElement<FeatureTree> selection_featureTree;
|
32
|
private TextWithLabelElement txtDescriptionTypes;
|
33
|
|
34
|
public DescriptionDetailElement(CdmFormFactory cdmFormFactory,
|
35
|
ICdmFormElement formElement, int style) {
|
36
|
super(cdmFormFactory, formElement);
|
37
|
}
|
38
|
|
39
|
@Override
|
40
|
protected void createControls(ICdmFormElement formElement, DescriptionBase entity, int style) {
|
41
|
toggleable_cache = formFactory.createToggleableTextField(this, "Label",
|
42
|
entity.getTitleCache(), entity.isProtectedTitleCache(), style);
|
43
|
// TODO I initially thought that we can handle the entity's descriptive system with a feature tree
|
44
|
// Since descriptiveSystem is a Set of Features that are present or allowed for the current description,
|
45
|
// it is similar to a FeatureTree (you can get this information from a feature tree) but not the same.
|
46
|
// Please correct this once it is clear what descriptive system will be used for in CDM
|
47
|
// selection_featureTree = formFactory.createSelectionElement(FeatureTree.class, getConversationHolder(), formElement, "Feature Tree", null, EntitySelectionElement.ALL, style);
|
48
|
|
49
|
Object typesString = entity.getTypes().stream().filter(type->type instanceof DescriptionType)
|
50
|
.map(type->((DescriptionType)type).getLabel())
|
51
|
.collect(Collectors.joining(","));
|
52
|
txtDescriptionTypes = formFactory.createTextWithLabelElement(formElement, "Types", typesString, style);
|
53
|
txtDescriptionTypes.setEnabled(false);
|
54
|
|
55
|
}
|
56
|
|
57
|
@Override
|
58
|
protected void updateControlStates(){
|
59
|
|
60
|
if (getEntity().isComputed()){
|
61
|
enabled = false;
|
62
|
}else{
|
63
|
enabled = true;
|
64
|
}
|
65
|
setEnabled(enabled);
|
66
|
}
|
67
|
|
68
|
@Override
|
69
|
protected void updateContent() {
|
70
|
super.updateContent();
|
71
|
toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
|
72
|
updateCacheRelevance();
|
73
|
}
|
74
|
|
75
|
@Override
|
76
|
protected void handleTitleCacheRelevantChange(PropertyChangeEvent event) {
|
77
|
if(!getEntity().isProtectedTitleCache()){
|
78
|
String title = getEntity().generateTitle();
|
79
|
getEntity().setTitleCache(title, false);
|
80
|
}
|
81
|
super.updateToggleableCacheField();
|
82
|
}
|
83
|
|
84
|
@Override
|
85
|
public void handleEvent(Object eventSource) {
|
86
|
if (eventSource == toggleable_cache) {
|
87
|
getEntity().setTitleCache(toggleable_cache.getText(), toggleable_cache.getState());
|
88
|
updateCacheRelevance();
|
89
|
}
|
90
|
}
|
91
|
}
|