Project

General

Profile

Download (6.55 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2017 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.editor.workingSet;
10

    
11
import java.util.List;
12

    
13
import org.eclipse.jface.viewers.ITreeSelection;
14
import org.eclipse.jface.viewers.StructuredSelection;
15
import org.eclipse.jface.viewers.TreeViewer;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.events.SelectionAdapter;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.layout.FillLayout;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.layout.GridLayout;
22
import org.eclipse.swt.widgets.Button;
23
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.Label;
25
import org.eclipse.swt.widgets.Text;
26
import org.eclipse.swt.widgets.Tree;
27

    
28
import eu.etaxonomy.cdm.api.service.IClassificationService;
29
import eu.etaxonomy.cdm.model.common.TermType;
30
import eu.etaxonomy.cdm.model.description.FeatureTree;
31
import eu.etaxonomy.cdm.model.location.NamedArea;
32
import eu.etaxonomy.cdm.model.name.Rank;
33
import eu.etaxonomy.cdm.model.taxon.Classification;
34
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
35
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditorComposite;
36
import eu.etaxonomy.taxeditor.store.CdmStore;
37
import eu.etaxonomy.taxeditor.ui.combo.TermUuidComboViewer;
38
import eu.etaxonomy.taxeditor.ui.dialog.selection.NamedAreaSelectionDialog;
39
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeContentProvider;
40
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeLabelProvider;
41

    
42
/**
43
 * @author pplitzner
44
 * @since Nov 21, 2017
45
 *
46
 */
47
public class WorkingSetComposite extends Composite {
48
    private Text txtWorkingSetLabel;
49
    private TermUuidComboViewer comboRankMin;
50
    private TermUuidComboViewer comboRankMax;
51
    private FeatureTreeEditorComposite featureTreeEditorComposite;
52
    private TreeViewer taxonNodeTree;
53
    private NamedArea area;
54
    private Label lblAreaLabel;
55

    
56
    public WorkingSetComposite(Composite parent, int style) {
57
        super(parent, style);
58
        setLayout(new GridLayout(4, false));
59

    
60
        Label lblNewLabel = new Label(this, SWT.NONE);
61
        lblNewLabel.setText("Working set label");
62

    
63
        txtWorkingSetLabel = new Text(this, SWT.BORDER);
64
        txtWorkingSetLabel.setEditable(false);
65
        txtWorkingSetLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
66

    
67
        Label lblNewLabel_1 = new Label(this, SWT.NONE);
68
        lblNewLabel_1.setText("Taxon filter");
69

    
70
        featureTreeEditorComposite = new FeatureTreeEditorComposite(this, SWT.NONE);
71
        featureTreeEditorComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4));
72
        featureTreeEditorComposite.init(null, null, null, null);
73

    
74
        Label lblNewLabel_2 = new Label(this, SWT.NONE);
75
        lblNewLabel_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
76
        lblNewLabel_2.setText("Rank min");
77

    
78
        comboRankMin = new TermUuidComboViewer(this, SWT.NONE);
79
        comboRankMin.setInput(TermType.Rank);
80
        comboRankMin.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
81

    
82
        Composite composite = new Composite(this, SWT.NONE);
83
        composite.setLayout(new FillLayout(SWT.HORIZONTAL));
84
        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
85

    
86
        taxonNodeTree = new TreeViewer(new Tree(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
87

    
88
        taxonNodeTree.setContentProvider(new TaxonTreeNodeContentProvider());
89
        taxonNodeTree.setLabelProvider(new TaxonTreeNodeLabelProvider());
90
        List<Classification> list = CdmStore.getService(IClassificationService.class).list(Classification.class, null, null, null, null);
91
        taxonNodeTree.setInput(list);
92

    
93
        Label lblNewLabel_3 = new Label(this, SWT.NONE);
94
        lblNewLabel_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
95
        lblNewLabel_3.setText("Rank max");
96

    
97
        comboRankMax = new TermUuidComboViewer(this, SWT.NONE);
98
        comboRankMax.setInput(TermType.Rank);
99
        comboRankMax.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
100

    
101
        Label lblNewLabel_4 = new Label(this, SWT.NONE);
102
        lblNewLabel_4.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
103
        lblNewLabel_4.setText("Area");
104

    
105
        Composite composite_1 = new Composite(this, SWT.NONE);
106
        composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
107
        composite_1.setLayout(new GridLayout(2, false));
108

    
109
        lblAreaLabel = new Label(composite_1, SWT.NONE);
110
        lblAreaLabel.setText("New Label");
111

    
112

    
113
        Button btnNewButton = new Button(composite_1, SWT.NONE);
114
        btnNewButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
115
        btnNewButton.setText("Choose");
116
        btnNewButton.addSelectionListener(new SelectionAdapter() {
117
            @Override
118
            public void widgetSelected(SelectionEvent e) {
119
                NamedArea area = NamedAreaSelectionDialog.select(parent.getShell(), null, null);
120
                setArea(area);
121
            }
122

    
123
        });
124

    
125
    }
126

    
127
    @Override
128
    protected void checkSubclass() {
129
        // Disable the check that prevents subclassing of SWT components
130
    }
131
    public Text getTxt_label() {
132
        return txtWorkingSetLabel;
133
    }
134

    
135
    public TermUuidComboViewer getRankMin() {
136
        return comboRankMin;
137
    }
138
    public TermUuidComboViewer getRankMax() {
139
        return comboRankMax;
140
    }
141

    
142
    public void setRankMin(Rank min) {
143
        comboRankMin.setTerm(min);
144
    }
145
    public void setRankMax(Rank max) {
146
        comboRankMax.setTerm(max);
147
    }
148

    
149
    public FeatureTree getCharacters(){
150
        return featureTreeEditorComposite.getFeatureTree();
151
    }
152
    public void setCharacters(FeatureTree characters) {
153
        featureTreeEditorComposite.setSelectedTree(characters, null);
154
    }
155

    
156
    public TaxonNode getTaxonNode(){
157
        ITreeSelection selection = (ITreeSelection) taxonNodeTree.getSelection();
158
        if(selection!=null && selection.getFirstElement() instanceof TaxonNode){
159
            return (TaxonNode) selection.getFirstElement();
160
        }
161
        return null;
162
    }
163
    public void setTaxonNode(TaxonNode taxonNode){
164
        taxonNodeTree.setSelection(new StructuredSelection(taxonNode), true);
165
    }
166

    
167
    public NamedArea getArea(){
168
        return area;
169
    }
170
    public void setArea(NamedArea area) {
171
        this.area = area;
172
        lblAreaLabel.setText(area.getLabel());
173
    }
174
}
(1-1/2)