2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
;
11 import java
.util
.ArrayList
;
12 import java
.util
.List
;
13 import java
.util
.stream
.Collectors
;
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
;
25 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
26 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
27 import eu
.etaxonomy
.cdm
.model
.term
.TermTree
;
28 import eu
.etaxonomy
.cdm
.model
.term
.TermType
;
29 import eu
.etaxonomy
.cdm
.persistence
.dto
.TermDto
;
30 import eu
.etaxonomy
.cdm
.remote
.l10n
.TermRepresentation_L10n
;
31 import eu
.etaxonomy
.taxeditor
.editor
.l10n
.Messages
;
32 import eu
.etaxonomy
.taxeditor
.featuretree
.e4
.FeatureTreeEditorComposite
;
33 import eu
.etaxonomy
.taxeditor
.model
.ImageResources
;
34 import eu
.etaxonomy
.taxeditor
.ui
.combo
.term
.TermUuidComboViewer
;
35 import eu
.etaxonomy
.taxeditor
.util
.TaxonTreeNodeContentProvider
;
36 import eu
.etaxonomy
.taxeditor
.util
.TaxonTreeNodeLabelProvider
;
43 public class DescriptiveDataSetComposite
extends Composite
{
44 private Text txtDescriptiveDataSet
;
45 private TermUuidComboViewer comboRankMin
;
46 private TermUuidComboViewer comboRankMax
;
47 private FeatureTreeEditorComposite
<Feature
> featureTreeEditorComposite
;
48 private TreeViewer taxonNodeTree
;
49 private List
<TermDto
> areas
= new ArrayList
<>();
50 private Text textAreaText
;
51 private Button btnChooseArea
;
52 private Button btnRemoveRankMin
;
53 private Button btnRemoveRankMax
;
55 public DescriptiveDataSetComposite(Composite parent
, int style
) {
58 setLayout(new GridLayout(3, false));
60 Label lblNewLabel
= new Label(this, SWT
.NONE
);
61 lblNewLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
62 lblNewLabel
.setText(Messages
.DescriptiveDataSetComposite_LABEL
);
64 txtDescriptiveDataSet
= new Text(this, SWT
.BORDER
);
65 txtDescriptiveDataSet
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1));
67 Label lblNewLabel_1
= new Label(this, SWT
.NONE
);
68 lblNewLabel_1
.setText(Messages
.DescriptiveDataSetComposite_TAXON_FILTER
);
70 Label lblNewLabel_2
= new Label(this, SWT
.NONE
);
71 lblNewLabel_2
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
72 lblNewLabel_2
.setText(Messages
.DescriptiveDataSetComposite_RANK_MIN
);
74 Composite composite_1
= new Composite(this, SWT
.NONE
);
75 composite_1
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1));
76 GridLayout gl_composite_1
= new GridLayout(2, false);
77 gl_composite_1
.horizontalSpacing
= 0;
78 gl_composite_1
.verticalSpacing
= 0;
79 gl_composite_1
.marginWidth
= 0;
80 gl_composite_1
.marginHeight
= 0;
81 composite_1
.setLayout(gl_composite_1
);
83 comboRankMin
= new TermUuidComboViewer(composite_1
, SWT
.NONE
);
84 comboRankMin
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1));
85 comboRankMin
.setInput(TermType
.Rank
);
87 btnRemoveRankMin
= new Button(composite_1
, SWT
.NONE
);
88 btnRemoveRankMin
.setImage(ImageResources
.getImage(ImageResources
.TRASH_ICON
));
90 Tree tree
= new Tree(this, SWT
.H_SCROLL
| SWT
.V_SCROLL
| SWT
.FULL_SELECTION
);
91 tree
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true, 1, 4));
92 taxonNodeTree
= new TreeViewer(tree
);
94 taxonNodeTree
.setContentProvider(new TaxonTreeNodeContentProvider());
95 taxonNodeTree
.setLabelProvider(new TaxonTreeNodeLabelProvider());
97 Label lblNewLabel_3
= new Label(this, SWT
.NONE
);
98 lblNewLabel_3
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
99 lblNewLabel_3
.setText(Messages
.DescriptiveDataSetComposite_RANK_MAX
);
101 Composite composite_2
= new Composite(this, SWT
.NONE
);
102 composite_2
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1));
103 GridLayout gl_composite_2
= new GridLayout(2, false);
104 gl_composite_2
.horizontalSpacing
= 0;
105 gl_composite_2
.verticalSpacing
= 0;
106 gl_composite_2
.marginWidth
= 0;
107 gl_composite_2
.marginHeight
= 0;
108 composite_2
.setLayout(gl_composite_2
);
110 comboRankMax
= new TermUuidComboViewer(composite_2
, SWT
.NONE
);
111 comboRankMax
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1));
112 comboRankMax
.setInput(TermType
.Rank
);
114 btnRemoveRankMax
= new Button(composite_2
, SWT
.NONE
);
115 btnRemoveRankMax
.setImage(ImageResources
.getImage(ImageResources
.TRASH_ICON
));
117 Label lblNewLabel_4
= new Label(this, SWT
.NONE
);
118 lblNewLabel_4
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
119 lblNewLabel_4
.setText(Messages
.DescriptiveDataSetComposite_AREA
);
121 Composite composite
= new Composite(this, SWT
.NONE
);
122 composite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, false, 1, 1));
123 GridLayout gl_composite
= new GridLayout(2, false);
124 gl_composite
.horizontalSpacing
= 0;
125 gl_composite
.verticalSpacing
= 0;
126 gl_composite
.marginHeight
= 0;
127 gl_composite
.marginWidth
= 0;
128 composite
.setLayout(gl_composite
);
130 textAreaText
= new Text(composite
, SWT
.BORDER
);
131 textAreaText
.setEditable(false);
132 textAreaText
.setText(Messages
.DescriptiveDataSetComposite_CHOOSE
);
133 textAreaText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1));
135 btnChooseArea
= new Button(composite
, SWT
.NONE
);
136 btnChooseArea
.setImage(ImageResources
.getImage(ImageResources
.BROWSE_ICON
));
138 featureTreeEditorComposite
= new FeatureTreeEditorComposite
<>(this, SWT
.NONE
);
139 featureTreeEditorComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true, 2, 1));
143 protected void checkSubclass() {
144 // Disable the check that prevents subclassing of SWT components
146 public Text
getTxt_label() {
147 return txtDescriptiveDataSet
;
150 public TermUuidComboViewer
getRankMin() {
153 public TermUuidComboViewer
getRankMax() {
157 public void setRankMin(Rank min
) {
158 comboRankMin
.setElement(min
);
160 public void setRankMax(Rank max
) {
161 comboRankMax
.setElement(max
);
164 public FeatureTreeEditorComposite
<Feature
> getFeatureTreeEditorComposite() {
165 return featureTreeEditorComposite
;
168 public TermTree
<Feature
> getCharacters(){
169 return featureTreeEditorComposite
.getFeatureTree();
171 public void setCharacters(TermTree
<Feature
> characters
) {
172 featureTreeEditorComposite
.setSelectedTree(characters
);
175 public TreeViewer
getTaxonNodeTree() {
176 return taxonNodeTree
;
178 public List
<TermDto
> getAreas() {
181 public void setAreas(List
<TermDto
> areas
) {
183 textAreaText
.setText(areas
.stream().map(area
->{
184 area
.localize(new TermRepresentation_L10n());
185 return area
.getRepresentation_L10n();
186 }).collect(Collectors
.joining(", ")));
188 public Button
getBtnChooseArea() {
189 return btnChooseArea
;
191 public Button
getBtnRemoveRankMin() {
192 return btnRemoveRankMin
;
194 public Button
getBtnRemoveRankMax() {
195 return btnRemoveRankMax
;