Project

General

Profile

Download (3.12 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.persistence.dto.TermTreeDto;
14
import eu.etaxonomy.taxeditor.event.EventUtility;
15
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
16
import eu.etaxonomy.taxeditor.model.ColorResources;
17
import eu.etaxonomy.taxeditor.preference.Resources;
18
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
20
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
21
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
22
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
23

    
24
/**
25
 *
26
 * @author pplitzner
27
 * @since Dec 21, 2017
28
 *
29
 */
30
public class TermTreeDetailElement extends AbstractCdmDetailElement<TermTreeDto> {
31

    
32
    private CheckboxElement allowDuplicates;
33
    private CheckboxElement orderRelevant;
34
    private CheckboxElement isFlat;
35

    
36
    private TextWithLabelElement titleCacheText;
37

    
38
	public TermTreeDetailElement(CdmFormFactory formFactory,
39
			ICdmFormElement formElement) {
40
		super(formFactory, formElement);
41
	}
42

    
43

    
44
	@Override
45
	protected void createControls(ICdmFormElement formElement, TermTreeDto entity, int style) {
46
	    Label lblTermType = new Label(formElement.getLayoutComposite(), style);
47
	    lblTermType.setText("Term Type");
48
	    Label lblStructureText = new Label(formElement.getLayoutComposite(), style);
49
	    lblStructureText.setText(entity.getTermType().getLabel());
50
	    lblStructureText.setForeground(ColorResources.getColor(Resources.BLACK));
51

    
52
	    titleCacheText = formFactory.createTextWithLabelElement(
53
                formElement, "Title Cache", entity.getTitleCache(), style);
54

    
55
	    allowDuplicates = formFactory.createCheckbox(formElement, "Allow duplicates", entity.isAllowDuplicate(), style);
56
	    if (entity.isContainsDuplicates() && entity.isAllowDuplicate()){
57
	        allowDuplicates.setEnabled(false);
58
	    }
59
	    orderRelevant = formFactory.createCheckbox(formElement, "Order relevant", entity.isOrderRelevant(), style);
60

    
61
	    isFlat = formFactory.createCheckbox(formElement, "Is flat", entity.isFlat(), style);
62
	    if (entity.containsSubtrees()){
63
	        isFlat.setEnabled(false);
64
	    }
65

    
66

    
67
	}
68

    
69
	@Override
70
	protected void updateControlStates() {
71
	    super.updateControlStates();
72
	}
73

    
74
	@Override
75
	public void handleEvent(Object eventSource) {
76
	    if (eventSource == titleCacheText) {
77
	            getEntity().setTitleCache(titleCacheText.getText());
78
        }
79
	    else
80
	    if (eventSource == allowDuplicates) {
81
	        getEntity().setAllowDuplicate(allowDuplicates.getSelection());
82
	    }
83
	    else if (eventSource == orderRelevant) {
84
	        getEntity().setOrderRelevant(orderRelevant.getSelection());
85
	    }
86
	    else if (eventSource == isFlat) {
87
	        getEntity().setFlat(isFlat.getSelection());
88
	    }
89
	    EventUtility.postEvent(WorkbenchEventConstants.ADD_SAVE_CANDIDATE, getEntity());
90

    
91
	}
92
}
(22-22/25)