Project

General

Profile

Download (6.55 KB) Statistics
| Branch: | Tag: | Revision:
1 643bfc6c Patrick Plitzner
/**
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 ed3be14e Patrick Plitzner
package eu.etaxonomy.taxeditor.editor.workingSet;
10 643bfc6c Patrick Plitzner
11 d8baa72e Patrick Plitzner
import java.util.List;
12
13 b13380e4 Patrick Plitzner
import org.eclipse.jface.viewers.ITreeSelection;
14 f953c7b6 Patrick Plitzner
import org.eclipse.jface.viewers.StructuredSelection;
15 643bfc6c Patrick Plitzner
import org.eclipse.jface.viewers.TreeViewer;
16
import org.eclipse.swt.SWT;
17 f953c7b6 Patrick Plitzner
import org.eclipse.swt.events.SelectionAdapter;
18 d8baa72e Patrick Plitzner
import org.eclipse.swt.events.SelectionEvent;
19 643bfc6c Patrick Plitzner
import org.eclipse.swt.layout.FillLayout;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.layout.GridLayout;
22 d8baa72e Patrick Plitzner
import org.eclipse.swt.widgets.Button;
23 643bfc6c Patrick Plitzner
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 d8baa72e Patrick Plitzner
import eu.etaxonomy.cdm.api.service.IClassificationService;
29 49aad4b2 Patrick Plitzner
import eu.etaxonomy.cdm.model.common.TermType;
30 b13380e4 Patrick Plitzner
import eu.etaxonomy.cdm.model.description.FeatureTree;
31 d8baa72e Patrick Plitzner
import eu.etaxonomy.cdm.model.location.NamedArea;
32 f953c7b6 Patrick Plitzner
import eu.etaxonomy.cdm.model.name.Rank;
33 d8baa72e Patrick Plitzner
import eu.etaxonomy.cdm.model.taxon.Classification;
34 b13380e4 Patrick Plitzner
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
35
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditorComposite;
36 d8baa72e Patrick Plitzner
import eu.etaxonomy.taxeditor.store.CdmStore;
37 49aad4b2 Patrick Plitzner
import eu.etaxonomy.taxeditor.ui.combo.TermUuidComboViewer;
38 d8baa72e Patrick Plitzner
import eu.etaxonomy.taxeditor.ui.dialog.selection.NamedAreaSelectionDialog;
39
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeContentProvider;
40
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeLabelProvider;
41 49aad4b2 Patrick Plitzner
42 643bfc6c Patrick Plitzner
/**
43
 * @author pplitzner
44
 * @since Nov 21, 2017
45
 *
46
 */
47
public class WorkingSetComposite extends Composite {
48 b13380e4 Patrick Plitzner
    private Text txtWorkingSetLabel;
49
    private TermUuidComboViewer comboRankMin;
50
    private TermUuidComboViewer comboRankMax;
51
    private FeatureTreeEditorComposite featureTreeEditorComposite;
52
    private TreeViewer taxonNodeTree;
53
    private NamedArea area;
54 f953c7b6 Patrick Plitzner
    private Label lblAreaLabel;
55 643bfc6c Patrick Plitzner
56
    public WorkingSetComposite(Composite parent, int style) {
57
        super(parent, style);
58 b13380e4 Patrick Plitzner
        setLayout(new GridLayout(4, false));
59 643bfc6c Patrick Plitzner
60
        Label lblNewLabel = new Label(this, SWT.NONE);
61
        lblNewLabel.setText("Working set label");
62
63 b13380e4 Patrick Plitzner
        txtWorkingSetLabel = new Text(this, SWT.BORDER);
64
        txtWorkingSetLabel.setEditable(false);
65
        txtWorkingSetLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
66 643bfc6c Patrick Plitzner
67
        Label lblNewLabel_1 = new Label(this, SWT.NONE);
68
        lblNewLabel_1.setText("Taxon filter");
69
70 b13380e4 Patrick Plitzner
        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 643bfc6c Patrick Plitzner
        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 b13380e4 Patrick Plitzner
        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 643bfc6c Patrick Plitzner
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 b13380e4 Patrick Plitzner
        taxonNodeTree = new TreeViewer(new Tree(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
87 d8baa72e Patrick Plitzner
88 b13380e4 Patrick Plitzner
        taxonNodeTree.setContentProvider(new TaxonTreeNodeContentProvider());
89
        taxonNodeTree.setLabelProvider(new TaxonTreeNodeLabelProvider());
90 d8baa72e Patrick Plitzner
        List<Classification> list = CdmStore.getService(IClassificationService.class).list(Classification.class, null, null, null, null);
91 b13380e4 Patrick Plitzner
        taxonNodeTree.setInput(list);
92 643bfc6c Patrick Plitzner
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 b13380e4 Patrick Plitzner
        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 643bfc6c Patrick Plitzner
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 d8baa72e Patrick Plitzner
        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 f953c7b6 Patrick Plitzner
        lblAreaLabel = new Label(composite_1, SWT.NONE);
110
        lblAreaLabel.setText("New Label");
111 d8baa72e Patrick Plitzner
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 f953c7b6 Patrick Plitzner
        btnNewButton.addSelectionListener(new SelectionAdapter() {
117 d8baa72e Patrick Plitzner
            @Override
118
            public void widgetSelected(SelectionEvent e) {
119 f953c7b6 Patrick Plitzner
                NamedArea area = NamedAreaSelectionDialog.select(parent.getShell(), null, null);
120
                setArea(area);
121 d8baa72e Patrick Plitzner
            }
122
123
        });
124
125 643bfc6c Patrick Plitzner
    }
126
127
    @Override
128
    protected void checkSubclass() {
129
        // Disable the check that prevents subclassing of SWT components
130
    }
131
    public Text getTxt_label() {
132 b13380e4 Patrick Plitzner
        return txtWorkingSetLabel;
133
    }
134 f953c7b6 Patrick Plitzner
135
    public TermUuidComboViewer getRankMin() {
136 b13380e4 Patrick Plitzner
        return comboRankMin;
137
    }
138 f953c7b6 Patrick Plitzner
    public TermUuidComboViewer getRankMax() {
139 b13380e4 Patrick Plitzner
        return comboRankMax;
140
    }
141 f953c7b6 Patrick Plitzner
142
    public void setRankMin(Rank min) {
143
        comboRankMin.setTerm(min);
144
    }
145
    public void setRankMax(Rank max) {
146
        comboRankMax.setTerm(max);
147
    }
148
149 b13380e4 Patrick Plitzner
    public FeatureTree getCharacters(){
150
        return featureTreeEditorComposite.getFeatureTree();
151
    }
152 f953c7b6 Patrick Plitzner
    public void setCharacters(FeatureTree characters) {
153
        featureTreeEditorComposite.setSelectedTree(characters, null);
154
    }
155
156 b13380e4 Patrick Plitzner
    public TaxonNode getTaxonNode(){
157
        ITreeSelection selection = (ITreeSelection) taxonNodeTree.getSelection();
158 f63d0c56 Patrick Plitzner
        if(selection!=null && selection.getFirstElement() instanceof TaxonNode){
159 b13380e4 Patrick Plitzner
            return (TaxonNode) selection.getFirstElement();
160
        }
161
        return null;
162
    }
163 f953c7b6 Patrick Plitzner
    public void setTaxonNode(TaxonNode taxonNode){
164
        taxonNodeTree.setSelection(new StructuredSelection(taxonNode), true);
165
    }
166
167 b13380e4 Patrick Plitzner
    public NamedArea getArea(){
168
        return area;
169 643bfc6c Patrick Plitzner
    }
170 f953c7b6 Patrick Plitzner
    public void setArea(NamedArea area) {
171
        this.area = area;
172
        lblAreaLabel.setText(area.getLabel());
173
    }
174 643bfc6c Patrick Plitzner
}