Project

General

Profile

Download (7.12 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.model.ImageResources;
37
import eu.etaxonomy.taxeditor.store.CdmStore;
38
import eu.etaxonomy.taxeditor.ui.combo.TermUuidComboViewer;
39
import eu.etaxonomy.taxeditor.ui.dialog.selection.NamedAreaSelectionDialog;
40
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeContentProvider;
41
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeLabelProvider;
42

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

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

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

    
65
        Composite composite_2 = new Composite(this, SWT.NONE);
66
        composite_2.setLayout(new GridLayout(2, false));
67
        composite_2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
68

    
69
                txtWorkingSetLabel = new Text(composite_2, SWT.BORDER);
70
                txtWorkingSetLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
71
                txtWorkingSetLabel.setEditable(false);
72

    
73
                btnOpenWorkingSet = new Button(composite_2, SWT.NONE);
74
                btnOpenWorkingSet.setImage(ImageResources.getImage(ImageResources.BROWSE_ICON));
75

    
76
        Label lblNewLabel_1 = new Label(this, SWT.NONE);
77
        lblNewLabel_1.setText("Taxon filter");
78

    
79
        featureTreeEditorComposite = new FeatureTreeEditorComposite(this, SWT.NONE);
80
        featureTreeEditorComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4));
81
        featureTreeEditorComposite.init(null, null, null, null);
82

    
83
        Label lblNewLabel_2 = new Label(this, SWT.NONE);
84
        lblNewLabel_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
85
        lblNewLabel_2.setText("Rank min");
86

    
87
        comboRankMin = new TermUuidComboViewer(this, SWT.NONE);
88
        comboRankMin.setInput(TermType.Rank);
89
        comboRankMin.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
90

    
91
        Composite composite = new Composite(this, SWT.NONE);
92
        composite.setLayout(new FillLayout(SWT.HORIZONTAL));
93
        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
94

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

    
97
        taxonNodeTree.setContentProvider(new TaxonTreeNodeContentProvider());
98
        taxonNodeTree.setLabelProvider(new TaxonTreeNodeLabelProvider());
99
        List<Classification> list = CdmStore.getService(IClassificationService.class).list(Classification.class, null, null, null, null);
100
        taxonNodeTree.setInput(list);
101

    
102
        Label lblNewLabel_3 = new Label(this, SWT.NONE);
103
        lblNewLabel_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
104
        lblNewLabel_3.setText("Rank max");
105

    
106
        comboRankMax = new TermUuidComboViewer(this, SWT.NONE);
107
        comboRankMax.setInput(TermType.Rank);
108
        comboRankMax.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
109

    
110
        Label lblNewLabel_4 = new Label(this, SWT.NONE);
111
        lblNewLabel_4.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
112
        lblNewLabel_4.setText("Area");
113

    
114
        Composite composite_1 = new Composite(this, SWT.NONE);
115
        composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
116
        composite_1.setLayout(new GridLayout(2, false));
117

    
118
        lblAreaLabel = new Label(composite_1, SWT.NONE);
119
        lblAreaLabel.setText("New Label");
120

    
121

    
122
        Button btnNewButton = new Button(composite_1, SWT.NONE);
123
        btnNewButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
124
        btnNewButton.setText("Choose");
125
        btnNewButton.addSelectionListener(new SelectionAdapter() {
126
            @Override
127
            public void widgetSelected(SelectionEvent e) {
128
                NamedArea area = NamedAreaSelectionDialog.select(parent.getShell(), null, null);
129
                setArea(area);
130
            }
131

    
132
        });
133

    
134
    }
135

    
136
    @Override
137
    protected void checkSubclass() {
138
        // Disable the check that prevents subclassing of SWT components
139
    }
140
    public Text getTxt_label() {
141
        return txtWorkingSetLabel;
142
    }
143

    
144
    public TermUuidComboViewer getRankMin() {
145
        return comboRankMin;
146
    }
147
    public TermUuidComboViewer getRankMax() {
148
        return comboRankMax;
149
    }
150

    
151
    public void setRankMin(Rank min) {
152
        comboRankMin.setTerm(min);
153
    }
154
    public void setRankMax(Rank max) {
155
        comboRankMax.setTerm(max);
156
    }
157

    
158
    public FeatureTree getCharacters(){
159
        return featureTreeEditorComposite.getFeatureTree();
160
    }
161
    public void setCharacters(FeatureTree characters) {
162
        featureTreeEditorComposite.setSelectedTree(characters, null);
163
    }
164

    
165
    public TaxonNode getTaxonNode(){
166
        ITreeSelection selection = (ITreeSelection) taxonNodeTree.getSelection();
167
        if(selection!=null && selection.getFirstElement() instanceof TaxonNode){
168
            return (TaxonNode) selection.getFirstElement();
169
        }
170
        return null;
171
    }
172
    public void setTaxonNode(TaxonNode taxonNode){
173
        taxonNodeTree.setSelection(new StructuredSelection(taxonNode), true);
174
    }
175

    
176
    public NamedArea getArea(){
177
        return area;
178
    }
179
    public void setArea(NamedArea area) {
180
        this.area = area;
181
        lblAreaLabel.setText(area.getLabel());
182
    }
183
    public Button getBtnOpenWorkingSet() {
184
        return btnOpenWorkingSet;
185
    }
186
}
(1-1/2)