Project

General

Profile

Download (2.8 KB) Statistics
| Branch: | Tag: | Revision:
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.term.TermTree;
14
import eu.etaxonomy.taxeditor.model.ColorResources;
15
import eu.etaxonomy.taxeditor.preference.Resources;
16
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
17
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
18
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
19
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
20
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
21

    
22
/**
23
 * @author pplitzner
24
 * @since Dec 21, 2017
25
 */
26
public class TermTreeDetailElementForNode extends AbstractCdmDetailElement<TermTree> {
27

    
28
    private CheckboxElement allowDuplicates;
29
    private CheckboxElement orderRelevant;
30
    private CheckboxElement isFlat;
31

    
32
    private TextWithLabelElement titleCacheText;
33

    
34
	public TermTreeDetailElementForNode(CdmFormFactory formFactory,
35
			ICdmFormElement formElement) {
36
		super(formFactory, formElement);
37
	}
38

    
39

    
40
	@Override
41
	protected void createControls(ICdmFormElement formElement, TermTree entity, int style) {
42
	    Label lblTermType = new Label(formElement.getLayoutComposite(), style);
43
	    lblTermType.setText("Term Type");
44
	    Label lblStructureText = new Label(formElement.getLayoutComposite(), style);
45
	    lblStructureText.setText(entity.getTermType().getLabel());
46
	    lblStructureText.setForeground(ColorResources.getColor(Resources.BLACK));
47

    
48
	    titleCacheText = formFactory.createTextWithLabelElement(
49
                formElement, "Title Cache", entity.getTitleCache(), style);
50

    
51
	    allowDuplicates = formFactory.createCheckbox(formElement, "Allow duplicates", entity.isAllowDuplicates(), style);
52
	    orderRelevant = formFactory.createCheckbox(formElement, "Order relevant", entity.isOrderRelevant(), style);
53
	    isFlat = formFactory.createCheckbox(formElement, "Is flat", entity.isFlat(), style);
54
    }
55

    
56
	@Override
57
	protected void updateControlStates() {
58
	    super.updateControlStates();
59
//	    toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
60
	}
61

    
62
	@Override
63
	public void handleEvent(Object eventSource) {
64
	    if (eventSource == titleCacheText) {
65
	            getEntity().setTitleCache(titleCacheText.getText());;
66
        }
67
	    else
68
	    if (eventSource == allowDuplicates) {
69
	        getEntity().setAllowDuplicates(allowDuplicates.getSelection());
70
	    }
71
	    else if (eventSource == orderRelevant) {
72
	        getEntity().setOrderRelevant(orderRelevant.getSelection());
73
	    }
74
	    else if (eventSource == isFlat) {
75
	        getEntity().setFlat(isFlat.getSelection());
76
	    }
77
	}
78

    
79
}
(25-25/25)