Project

General

Profile

Download (7.48 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.descriptiveDataSet;
10

    
11
import java.util.HashSet;
12
import java.util.Set;
13
import java.util.stream.Collectors;
14

    
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.model.common.TermType;
26
import eu.etaxonomy.cdm.model.description.FeatureTree;
27
import eu.etaxonomy.cdm.model.location.NamedArea;
28
import eu.etaxonomy.cdm.model.name.Rank;
29
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
30
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditorComposite;
31
import eu.etaxonomy.taxeditor.model.ImageResources;
32
import eu.etaxonomy.taxeditor.ui.combo.TermUuidComboViewer;
33
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeContentProvider;
34
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeLabelProvider;
35

    
36
/**
37
 * @author pplitzner
38
 * @since Nov 21, 2017
39
 *
40
 */
41
public class DescriptiveDataSetComposite extends Composite {
42
    private Text txtDescriptiveDataSet;
43
    private TermUuidComboViewer comboRankMin;
44
    private TermUuidComboViewer comboRankMax;
45
    private FeatureTreeEditorComposite featureTreeEditorComposite;
46
    private TreeViewer taxonNodeTree;
47
    private Set<NamedArea> areas = new HashSet<>();
48
    private Text textAreaText;
49
    private Button btnChooseArea;
50
    private Button btnRemoveRankMin;
51
    private Button btnRemoveRankMax;
52

    
53
    public DescriptiveDataSetComposite(Composite parent, int style) {
54
        super(parent, style);
55

    
56
        setLayout(new GridLayout(3, false));
57

    
58
        Label lblNewLabel = new Label(this, SWT.NONE);
59
        lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
60
        lblNewLabel.setText(Messages.DescriptiveDataSetComposite_LABEL);
61

    
62
        txtDescriptiveDataSet = new Text(this, SWT.BORDER);
63
        txtDescriptiveDataSet.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
64

    
65
        Label lblNewLabel_1 = new Label(this, SWT.NONE);
66
        lblNewLabel_1.setText(Messages.DescriptiveDataSetComposite_TAXON_FILTER);
67

    
68
        Label lblNewLabel_2 = new Label(this, SWT.NONE);
69
        lblNewLabel_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
70
        lblNewLabel_2.setText(Messages.DescriptiveDataSetComposite_RANK_MIN);
71

    
72
        Composite composite_1 = new Composite(this, SWT.NONE);
73
        composite_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
74
        GridLayout gl_composite_1 = new GridLayout(2, false);
75
        gl_composite_1.horizontalSpacing = 0;
76
        gl_composite_1.verticalSpacing = 0;
77
        gl_composite_1.marginWidth = 0;
78
        gl_composite_1.marginHeight = 0;
79
        composite_1.setLayout(gl_composite_1);
80

    
81
        comboRankMin = new TermUuidComboViewer(composite_1, SWT.NONE);
82
        comboRankMin.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
83
        comboRankMin.setInput(TermType.Rank);
84

    
85
        btnRemoveRankMin = new Button(composite_1, SWT.NONE);
86
        btnRemoveRankMin.setImage(ImageResources.getImage(ImageResources.TRASH_ICON));
87

    
88
        Tree tree = new Tree(this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
89
        tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4));
90
        taxonNodeTree = new TreeViewer(tree);
91

    
92
        taxonNodeTree.setContentProvider(new TaxonTreeNodeContentProvider());
93
        taxonNodeTree.setLabelProvider(new TaxonTreeNodeLabelProvider());
94

    
95
        Label lblNewLabel_3 = new Label(this, SWT.NONE);
96
        lblNewLabel_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
97
        lblNewLabel_3.setText(Messages.DescriptiveDataSetComposite_RANK_MAX);
98

    
99
        Composite composite_2 = new Composite(this, SWT.NONE);
100
        composite_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
101
        GridLayout gl_composite_2 = new GridLayout(2, false);
102
        gl_composite_2.horizontalSpacing = 0;
103
        gl_composite_2.verticalSpacing = 0;
104
        gl_composite_2.marginWidth = 0;
105
        gl_composite_2.marginHeight = 0;
106
        composite_2.setLayout(gl_composite_2);
107

    
108
        comboRankMax = new TermUuidComboViewer(composite_2, SWT.NONE);
109
        comboRankMax.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
110
        comboRankMax.setInput(TermType.Rank);
111

    
112
        btnRemoveRankMax = new Button(composite_2, SWT.NONE);
113
        btnRemoveRankMax.setImage(ImageResources.getImage(ImageResources.TRASH_ICON));
114

    
115
        Label lblNewLabel_4 = new Label(this, SWT.NONE);
116
        lblNewLabel_4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
117
        lblNewLabel_4.setText(Messages.DescriptiveDataSetComposite_AREA);
118

    
119
        Composite composite = new Composite(this, SWT.NONE);
120
        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
121
        GridLayout gl_composite = new GridLayout(2, false);
122
        gl_composite.horizontalSpacing = 0;
123
        gl_composite.verticalSpacing = 0;
124
        gl_composite.marginHeight = 0;
125
        gl_composite.marginWidth = 0;
126
        composite.setLayout(gl_composite);
127

    
128
        textAreaText = new Text(composite, SWT.BORDER);
129
        textAreaText.setEditable(false);
130
        textAreaText.setText(Messages.DescriptiveDataSetComposite_CHOOSE);
131
        textAreaText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
132

    
133
        btnChooseArea = new Button(composite, SWT.NONE);
134
        btnChooseArea.setImage(ImageResources.getImage(ImageResources.BROWSE_ICON));
135

    
136
        featureTreeEditorComposite = new FeatureTreeEditorComposite(this, SWT.NONE);
137
        featureTreeEditorComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
138
    }
139

    
140
    @Override
141
    protected void checkSubclass() {
142
        // Disable the check that prevents subclassing of SWT components
143
    }
144
    public Text getTxt_label() {
145
        return txtDescriptiveDataSet;
146
    }
147

    
148
    public TermUuidComboViewer getRankMin() {
149
        return comboRankMin;
150
    }
151
    public TermUuidComboViewer getRankMax() {
152
        return comboRankMax;
153
    }
154

    
155
    public void setRankMin(Rank min) {
156
        comboRankMin.setElement(min);
157
    }
158
    public void setRankMax(Rank max) {
159
        comboRankMax.setElement(max);
160
    }
161

    
162
    public FeatureTreeEditorComposite getFeatureTreeEditorComposite() {
163
        return featureTreeEditorComposite;
164
    }
165

    
166
    public FeatureTree getCharacters(){
167
        return featureTreeEditorComposite.getFeatureTree();
168
    }
169
    public void setCharacters(FeatureTree characters) {
170
        featureTreeEditorComposite.setSelectedTree(characters);
171
    }
172

    
173
    public TreeViewer getTaxonNodeTree() {
174
        return taxonNodeTree;
175
    }
176
    public Set<NamedArea> getAreas() {
177
        return areas;
178
    }
179
    public void setAreas(Set<NamedArea> areas) {
180
        this.areas = areas;
181
        textAreaText.setText(areas.stream().map(area->area.getLabel()).collect(Collectors.joining(", ")));
182
    }
183
    public Button getBtnChooseArea() {
184
        return btnChooseArea;
185
    }
186
    public Button getBtnRemoveRankMin() {
187
        return btnRemoveRankMin;
188
    }
189
    public Button getBtnRemoveRankMax() {
190
        return btnRemoveRankMax;
191
    }
192
}
(2-2/5)