1
|
/**
|
2
|
* Copyright (C) 2009 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.feature;
|
10
|
|
11
|
import org.eclipse.swt.widgets.Label;
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.common.Language;
|
14
|
import eu.etaxonomy.cdm.model.term.Representation;
|
15
|
import eu.etaxonomy.cdm.model.term.TermTree;
|
16
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
17
|
import eu.etaxonomy.taxeditor.model.ColorResources;
|
18
|
import eu.etaxonomy.taxeditor.preference.Resources;
|
19
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
20
|
import eu.etaxonomy.taxeditor.termtree.e4.ICharacterEditor;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.RepresentationElement;
|
25
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
26
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
27
|
|
28
|
/**
|
29
|
* @author pplitzner
|
30
|
* @since Dec 21, 2017
|
31
|
*/
|
32
|
public class TermTreeDetailElementForNode extends AbstractCdmDetailElement<TermTree> {
|
33
|
|
34
|
private CheckboxElement allowDuplicates;
|
35
|
private CheckboxElement orderRelevant;
|
36
|
private CheckboxElement isFlat;
|
37
|
|
38
|
// private TextWithLabelElement titleCacheText;
|
39
|
protected RepresentationElement element_Representation;
|
40
|
|
41
|
public TermTreeDetailElementForNode(CdmFormFactory formFactory,
|
42
|
ICdmFormElement formElement) {
|
43
|
super(formFactory, formElement);
|
44
|
}
|
45
|
|
46
|
|
47
|
@Override
|
48
|
protected void createControls(ICdmFormElement formElement, TermTree entity, int style) {
|
49
|
|
50
|
Label lblTermType = new Label(formElement.getLayoutComposite(), style);
|
51
|
lblTermType.setText("Term Type");
|
52
|
Label lblStructureText = new Label(formElement.getLayoutComposite(), style);
|
53
|
lblStructureText.setText(entity.getTermType().getLabel());
|
54
|
lblStructureText.setForeground(ColorResources.getColor(Resources.BLACK));
|
55
|
|
56
|
// titleCacheText = formFactory.createTextWithLabelElement(
|
57
|
// formElement, "Title Cache", entity.getTitleCache(), style);
|
58
|
element_Representation = formFactory.createTranslatableRepresentationElement(formElement, entity.getPreferredRepresentation(CdmStore.getDefaultLanguage()),entity, 100, style, true);
|
59
|
|
60
|
allowDuplicates = formFactory.createCheckbox(formElement, "Allow duplicates", entity.isAllowDuplicates(), style);
|
61
|
orderRelevant = formFactory.createCheckbox(formElement, "Order relevant", entity.isOrderRelevant(), style);
|
62
|
isFlat = formFactory.createCheckbox(formElement, "Is flat", entity.isFlat(), style);
|
63
|
if (AbstractUtility.getActivePart() instanceof ICharacterEditor){
|
64
|
element_Representation.setEnabled(false);
|
65
|
allowDuplicates.setEnabled(false);
|
66
|
orderRelevant.setEnabled(false);
|
67
|
isFlat.setEnabled(false);
|
68
|
}
|
69
|
|
70
|
}
|
71
|
|
72
|
@Override
|
73
|
protected void updateControlStates() {
|
74
|
super.updateControlStates();
|
75
|
// toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
|
76
|
}
|
77
|
|
78
|
@Override
|
79
|
public void handleEvent(Object eventSource) {
|
80
|
if (eventSource == element_Representation) {
|
81
|
Representation selectedRepresentation = element_Representation.getSelectedRepresentation();
|
82
|
if(selectedRepresentation!=null){
|
83
|
Language representationLanguage = selectedRepresentation.getLanguage();
|
84
|
if(representationLanguage==null){
|
85
|
representationLanguage = Language.getDefaultLanguage();
|
86
|
}
|
87
|
getEntity().setLabel(selectedRepresentation.getLabel(), representationLanguage);
|
88
|
getEntity().getRepresentation(representationLanguage).setAbbreviatedLabel(selectedRepresentation.getAbbreviatedLabel());
|
89
|
getEntity().getRepresentation(representationLanguage).setText(selectedRepresentation.getDescription());
|
90
|
}
|
91
|
getEntity().setTitleCache(null);
|
92
|
}
|
93
|
else
|
94
|
if (eventSource == allowDuplicates) {
|
95
|
getEntity().setAllowDuplicates(allowDuplicates.getSelection());
|
96
|
}
|
97
|
else if (eventSource == orderRelevant) {
|
98
|
getEntity().setOrderRelevant(orderRelevant.getSelection());
|
99
|
}
|
100
|
else if (eventSource == isFlat) {
|
101
|
getEntity().setFlat(isFlat.getSelection());
|
102
|
}
|
103
|
}
|
104
|
|
105
|
}
|