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.layout.GridData;
|
18
|
import org.eclipse.swt.layout.GridLayout;
|
19
|
import org.eclipse.swt.widgets.Button;
|
20
|
import org.eclipse.swt.widgets.Composite;
|
21
|
import org.eclipse.swt.widgets.Label;
|
22
|
import org.eclipse.swt.widgets.Text;
|
23
|
import org.eclipse.swt.widgets.Tree;
|
24
|
|
25
|
import eu.etaxonomy.cdm.api.service.IClassificationService;
|
26
|
import eu.etaxonomy.cdm.model.common.TermType;
|
27
|
import eu.etaxonomy.cdm.model.description.FeatureTree;
|
28
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
29
|
import eu.etaxonomy.cdm.model.name.Rank;
|
30
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
31
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
32
|
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditorComposite;
|
33
|
import eu.etaxonomy.taxeditor.model.ImageResources;
|
34
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
35
|
import eu.etaxonomy.taxeditor.ui.combo.TermUuidComboViewer;
|
36
|
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeContentProvider;
|
37
|
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeLabelProvider;
|
38
|
|
39
|
/**
|
40
|
* @author pplitzner
|
41
|
* @since Nov 21, 2017
|
42
|
*
|
43
|
*/
|
44
|
public class WorkingSetComposite extends Composite {
|
45
|
private Text txtWorkingSet;
|
46
|
private TermUuidComboViewer comboRankMin;
|
47
|
private TermUuidComboViewer comboRankMax;
|
48
|
private FeatureTreeEditorComposite featureTreeEditorComposite;
|
49
|
private TreeViewer taxonNodeTree;
|
50
|
private NamedArea area;
|
51
|
private Button btnOpenWorkingSet;
|
52
|
private Label lblWorkingSet;
|
53
|
private Text textAreaText;
|
54
|
|
55
|
public WorkingSetComposite(Composite parent, int style) {
|
56
|
super(parent, style);
|
57
|
|
58
|
List<Classification> list = CdmStore.getService(IClassificationService.class).list(Classification.class, null, null, null, null);
|
59
|
|
60
|
setLayout(new GridLayout(3, false));
|
61
|
|
62
|
Composite composite = new Composite(this, SWT.BORDER);
|
63
|
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));
|
64
|
composite.setLayout(new GridLayout(4, false));
|
65
|
|
66
|
lblWorkingSet = new Label(composite, SWT.NONE);
|
67
|
lblWorkingSet.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
|
68
|
lblWorkingSet.setText("-no working set loaded-");
|
69
|
|
70
|
btnOpenWorkingSet = new Button(composite, SWT.NONE);
|
71
|
btnOpenWorkingSet.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
72
|
btnOpenWorkingSet.setText("Open...");
|
73
|
btnOpenWorkingSet.setImage(ImageResources.getImage(ImageResources.BROWSE_ICON));
|
74
|
|
75
|
Label lblNewLabel = new Label(this, SWT.NONE);
|
76
|
lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
77
|
lblNewLabel.setText("Label");
|
78
|
|
79
|
txtWorkingSet = new Text(this, SWT.BORDER);
|
80
|
txtWorkingSet.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
81
|
|
82
|
Label lblNewLabel_1 = new Label(this, SWT.NONE);
|
83
|
lblNewLabel_1.setText("Taxon filter");
|
84
|
|
85
|
Label lblNewLabel_2 = new Label(this, SWT.NONE);
|
86
|
lblNewLabel_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
87
|
lblNewLabel_2.setText("Rank min");
|
88
|
|
89
|
comboRankMin = new TermUuidComboViewer(this, SWT.NONE);
|
90
|
comboRankMin.setInput(TermType.Rank);
|
91
|
comboRankMin.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
|
92
|
Tree tree = new Tree(this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
|
93
|
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4));
|
94
|
taxonNodeTree = new TreeViewer(tree);
|
95
|
|
96
|
taxonNodeTree.setContentProvider(new TaxonTreeNodeContentProvider());
|
97
|
taxonNodeTree.setLabelProvider(new TaxonTreeNodeLabelProvider());
|
98
|
taxonNodeTree.setInput(list);
|
99
|
|
100
|
Label lblNewLabel_3 = new Label(this, SWT.NONE);
|
101
|
lblNewLabel_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
102
|
lblNewLabel_3.setText("Rank max");
|
103
|
|
104
|
comboRankMax = new TermUuidComboViewer(this, SWT.NONE);
|
105
|
comboRankMax.setInput(TermType.Rank);
|
106
|
comboRankMax.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
|
107
|
|
108
|
Label lblNewLabel_4 = new Label(this, SWT.NONE);
|
109
|
lblNewLabel_4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
110
|
lblNewLabel_4.setText("Area");
|
111
|
|
112
|
textAreaText = new Text(this, SWT.BORDER);
|
113
|
textAreaText.setEditable(false);
|
114
|
textAreaText.setText("Choose...");
|
115
|
textAreaText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
116
|
|
117
|
featureTreeEditorComposite = new FeatureTreeEditorComposite(this, SWT.NONE);
|
118
|
featureTreeEditorComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
|
119
|
featureTreeEditorComposite.init(null, null, null, null);
|
120
|
|
121
|
|
122
|
|
123
|
}
|
124
|
|
125
|
@Override
|
126
|
protected void checkSubclass() {
|
127
|
// Disable the check that prevents subclassing of SWT components
|
128
|
}
|
129
|
public Text getTxt_label() {
|
130
|
return txtWorkingSet;
|
131
|
}
|
132
|
|
133
|
public TermUuidComboViewer getRankMin() {
|
134
|
return comboRankMin;
|
135
|
}
|
136
|
public TermUuidComboViewer getRankMax() {
|
137
|
return comboRankMax;
|
138
|
}
|
139
|
|
140
|
public void setRankMin(Rank min) {
|
141
|
comboRankMin.setTerm(min);
|
142
|
}
|
143
|
public void setRankMax(Rank max) {
|
144
|
comboRankMax.setTerm(max);
|
145
|
}
|
146
|
|
147
|
public FeatureTree getCharacters(){
|
148
|
return featureTreeEditorComposite.getFeatureTree();
|
149
|
}
|
150
|
public void setCharacters(FeatureTree characters) {
|
151
|
featureTreeEditorComposite.setSelectedTree(characters, null);
|
152
|
}
|
153
|
|
154
|
public TaxonNode getTaxonNode(){
|
155
|
ITreeSelection selection = (ITreeSelection) taxonNodeTree.getSelection();
|
156
|
if(selection!=null && selection.getFirstElement() instanceof TaxonNode){
|
157
|
return (TaxonNode) selection.getFirstElement();
|
158
|
}
|
159
|
return null;
|
160
|
}
|
161
|
public void setTaxonNode(TaxonNode taxonNode){
|
162
|
taxonNodeTree.setSelection(new StructuredSelection(taxonNode), true);
|
163
|
}
|
164
|
|
165
|
public NamedArea getArea(){
|
166
|
return area;
|
167
|
}
|
168
|
public void setArea(NamedArea area) {
|
169
|
this.area = area;
|
170
|
textAreaText.setText(area.getLabel());
|
171
|
}
|
172
|
public Label getLblWorkingSet() {
|
173
|
return lblWorkingSet;
|
174
|
}
|
175
|
public Text getTextAreaText() {
|
176
|
return textAreaText;
|
177
|
}
|
178
|
public Button getBtnOpenWorkingSet() {
|
179
|
return btnOpenWorkingSet;
|
180
|
}
|
181
|
}
|