1
|
package eu.etaxonomy.cdm.vaadin.view.dbstatus;
|
2
|
|
3
|
import java.sql.SQLException;
|
4
|
import java.util.List;
|
5
|
|
6
|
import com.vaadin.annotations.AutoGenerated;
|
7
|
import com.vaadin.data.Container;
|
8
|
import com.vaadin.data.util.IndexedContainer;
|
9
|
import com.vaadin.event.ShortcutAction.KeyCode;
|
10
|
import com.vaadin.navigator.View;
|
11
|
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
|
12
|
import com.vaadin.ui.Alignment;
|
13
|
import com.vaadin.ui.Button;
|
14
|
import com.vaadin.ui.Button.ClickEvent;
|
15
|
import com.vaadin.ui.Button.ClickListener;
|
16
|
import com.vaadin.ui.ComboBox;
|
17
|
import com.vaadin.ui.CustomComponent;
|
18
|
import com.vaadin.ui.Label;
|
19
|
import com.vaadin.ui.Panel;
|
20
|
import com.vaadin.ui.VerticalLayout;
|
21
|
|
22
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
23
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
24
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
25
|
import eu.etaxonomy.cdm.vaadin.container.TaxonNodeContainer;
|
26
|
|
27
|
public class DistributionSelectionView extends CustomComponent implements IDistributionSelectionComponent, View, ClickListener{
|
28
|
|
29
|
/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
|
30
|
|
31
|
@AutoGenerated
|
32
|
private VerticalLayout mainLayout;
|
33
|
@AutoGenerated
|
34
|
private Panel panel_1;
|
35
|
@AutoGenerated
|
36
|
private VerticalLayout verticalLayout_2;
|
37
|
@AutoGenerated
|
38
|
private Button button_proceed;
|
39
|
@AutoGenerated
|
40
|
private ComboBox distributionAreaBox;
|
41
|
@AutoGenerated
|
42
|
private ComboBox taxonNodeBox;
|
43
|
@AutoGenerated
|
44
|
private Label label_1;
|
45
|
/**
|
46
|
*
|
47
|
*/
|
48
|
private static final long serialVersionUID = 1L;
|
49
|
private DistributionSelectionComponentListener distListener;
|
50
|
/**
|
51
|
* The constructor should first build the main layout, set the
|
52
|
* composition root and then do any custom initialization.
|
53
|
*
|
54
|
* The constructor will not be automatically regenerated by the
|
55
|
* visual editor.
|
56
|
*/
|
57
|
public DistributionSelectionView(){
|
58
|
buildMainLayout();
|
59
|
setCompositionRoot(mainLayout);
|
60
|
setStyleName("login");
|
61
|
button_proceed.addClickListener(this);
|
62
|
button_proceed.setClickShortcut(KeyCode.ENTER, null);
|
63
|
}
|
64
|
|
65
|
|
66
|
@Override
|
67
|
public void addListener(DistributionSelectionComponentListener listener) {
|
68
|
distListener = listener;
|
69
|
}
|
70
|
|
71
|
@Override
|
72
|
public void buttonClick(ClickEvent event) {
|
73
|
if(taxonNodeBox != null && distributionAreaBox != null){
|
74
|
TaxonNode classification = (TaxonNode) taxonNodeBox.getValue();
|
75
|
TermVocabulary<DefinedTermBase> term = (TermVocabulary<DefinedTermBase>)distributionAreaBox.getValue();
|
76
|
try {
|
77
|
distListener.buttonClick(classification, term);
|
78
|
} catch (SQLException e) {
|
79
|
// TODO Auto-generated catch block
|
80
|
e.printStackTrace();
|
81
|
}
|
82
|
}
|
83
|
}
|
84
|
|
85
|
public void dataBinding(){
|
86
|
List<TermVocabulary<DefinedTermBase>> namedAreaList = distListener.getNamedAreaList();
|
87
|
Container c = new TaxonNodeContainer();
|
88
|
taxonNodeBox.setItemCaptionPropertyId(TaxonNodeContainer.LABEL);
|
89
|
taxonNodeBox.setContainerDataSource(c);
|
90
|
// classificationSelection.setContainerDataSource(c);
|
91
|
Container d = new IndexedContainer(namedAreaList);
|
92
|
distributionAreaBox.setContainerDataSource(d);
|
93
|
// distributionSelection.setContainerDataSource(d);
|
94
|
}
|
95
|
|
96
|
@Override
|
97
|
public void enter(ViewChangeEvent event) {
|
98
|
}
|
99
|
|
100
|
@AutoGenerated
|
101
|
private VerticalLayout buildMainLayout() {
|
102
|
// common part: create layout
|
103
|
mainLayout = new VerticalLayout();
|
104
|
mainLayout.setImmediate(false);
|
105
|
mainLayout.setWidth("100%");
|
106
|
mainLayout.setHeight("100%");
|
107
|
mainLayout.setMargin(false);
|
108
|
|
109
|
// top-level component properties
|
110
|
setWidth("100.0%");
|
111
|
setHeight("100.0%");
|
112
|
|
113
|
// panel_1
|
114
|
panel_1 = buildPanel_1();
|
115
|
mainLayout.addComponent(panel_1);
|
116
|
mainLayout.setComponentAlignment(panel_1, new Alignment(48));
|
117
|
|
118
|
return mainLayout;
|
119
|
}
|
120
|
|
121
|
|
122
|
@AutoGenerated
|
123
|
private Panel buildPanel_1() {
|
124
|
// common part: create layout
|
125
|
panel_1 = new Panel();
|
126
|
panel_1.setImmediate(false);
|
127
|
panel_1.setWidth("-1px");
|
128
|
panel_1.setHeight("-1px");
|
129
|
|
130
|
// verticalLayout_2
|
131
|
verticalLayout_2 = buildVerticalLayout_2();
|
132
|
panel_1.setContent(verticalLayout_2);
|
133
|
|
134
|
return panel_1;
|
135
|
}
|
136
|
|
137
|
|
138
|
@AutoGenerated
|
139
|
private VerticalLayout buildVerticalLayout_2() {
|
140
|
// common part: create layout
|
141
|
verticalLayout_2 = new VerticalLayout();
|
142
|
verticalLayout_2.setImmediate(false);
|
143
|
verticalLayout_2.setWidth("-1px");
|
144
|
verticalLayout_2.setHeight("-1px");
|
145
|
verticalLayout_2.setMargin(true);
|
146
|
verticalLayout_2.setSpacing(true);
|
147
|
|
148
|
// label_1
|
149
|
label_1 = new Label();
|
150
|
label_1.setImmediate(false);
|
151
|
label_1.setWidth("213px");
|
152
|
label_1.setHeight("-1px");
|
153
|
label_1.setValue("Please choose a Classification or taxon and a distribution area to proceed.");
|
154
|
verticalLayout_2.addComponent(label_1);
|
155
|
|
156
|
// classificationBox
|
157
|
taxonNodeBox = new ComboBox();
|
158
|
taxonNodeBox.setCaption("Classification/Taxon: ");
|
159
|
taxonNodeBox.setImmediate(false);
|
160
|
taxonNodeBox.setWidth("200px");
|
161
|
taxonNodeBox.setHeight("-1px");
|
162
|
verticalLayout_2.addComponent(taxonNodeBox);
|
163
|
|
164
|
// distributionAreaBox
|
165
|
distributionAreaBox = new ComboBox();
|
166
|
distributionAreaBox.setCaption("Distribution Area");
|
167
|
distributionAreaBox.setImmediate(false);
|
168
|
distributionAreaBox.setWidth("200px");
|
169
|
distributionAreaBox.setHeight("-1px");
|
170
|
verticalLayout_2.addComponent(distributionAreaBox);
|
171
|
|
172
|
// button_proceed
|
173
|
button_proceed = new Button();
|
174
|
button_proceed.setCaption("Proceed");
|
175
|
button_proceed.setImmediate(true);
|
176
|
button_proceed.setWidth("-1px");
|
177
|
button_proceed.setHeight("-1px");
|
178
|
verticalLayout_2.addComponent(button_proceed);
|
179
|
verticalLayout_2.setComponentAlignment(button_proceed, new Alignment(10));
|
180
|
|
181
|
return verticalLayout_2;
|
182
|
}
|
183
|
|
184
|
}
|