Revision 5eece89f
Added by Patrick Plitzner almost 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/HorizontalToolbar.java | ||
---|---|---|
36 | 36 |
|
37 | 37 |
private final Button detailButton = new Button("Detail"); |
38 | 38 |
|
39 |
private final Button distributionSettingsButton = new Button("Distribution Settings"); |
|
40 |
|
|
39 | 41 |
private final Button settingsButton = new Button("Settings"); |
40 | 42 |
|
41 | 43 |
private final Button logoutButton= new Button("Logout"); |
... | ... | |
70 | 72 |
editButton.setIcon(new ThemeResource("icons/32/document-edit.png")); |
71 | 73 |
detailButton.setIcon(new ThemeResource("icons/32/document-txt.png")); |
72 | 74 |
settingsButton.setIcon(new ThemeResource("icons/32/settings_1.png")); |
75 |
distributionSettingsButton.setIcon(new ThemeResource("icons/32/settings_1.png")); |
|
73 | 76 |
logoutButton.setIcon(new ThemeResource("icons/32/cancel.png")); |
74 | 77 |
|
75 | 78 |
// SecurityContext context = (SecurityContext)VaadinService.getCurrentRequest().getWrappedSession().getAttribute("context"); |
... | ... | |
80 | 83 |
HorizontalLayout rightLayout = new HorizontalLayout(); |
81 | 84 |
Image image = new Image(null, new ThemeResource("icons/32/vseparator1.png")); |
82 | 85 |
rightLayout.addComponent(settingsButton); |
86 |
rightLayout.addComponent(distributionSettingsButton); |
|
83 | 87 |
rightLayout.addComponent(logoutButton); |
84 | 88 |
rightLayout.addComponent(image); |
85 | 89 |
rightLayout.addComponent(loginName); |
... | ... | |
109 | 113 |
public Button getSettingsButton(){ |
110 | 114 |
return settingsButton; |
111 | 115 |
} |
116 |
|
|
117 |
public Button getDistributionSettingsButton() { |
|
118 |
return distributionSettingsButton; |
|
119 |
} |
|
112 | 120 |
|
113 | 121 |
public Button getEditButton() { |
114 | 122 |
return editButton; |
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionSettingsConfigWindow.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2015 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.cdm.vaadin.view.dbstatus; |
|
11 |
|
|
12 |
import java.util.Set; |
|
13 |
|
|
14 |
import com.vaadin.data.Container; |
|
15 |
import com.vaadin.data.Property; |
|
16 |
import com.vaadin.data.Property.ValueChangeEvent; |
|
17 |
import com.vaadin.data.Property.ValueChangeListener; |
|
18 |
import com.vaadin.server.VaadinSession; |
|
19 |
import com.vaadin.ui.AbstractLayout; |
|
20 |
import com.vaadin.ui.Alignment; |
|
21 |
import com.vaadin.ui.Button; |
|
22 |
import com.vaadin.ui.Button.ClickEvent; |
|
23 |
import com.vaadin.ui.Button.ClickListener; |
|
24 |
import com.vaadin.ui.ComboBox; |
|
25 |
import com.vaadin.ui.CustomComponent; |
|
26 |
import com.vaadin.ui.HorizontalLayout; |
|
27 |
import com.vaadin.ui.Label; |
|
28 |
import com.vaadin.ui.ListSelect; |
|
29 |
import com.vaadin.ui.Notification; |
|
30 |
import com.vaadin.ui.Tree; |
|
31 |
import com.vaadin.ui.VerticalLayout; |
|
32 |
import com.vaadin.ui.Window; |
|
33 |
|
|
34 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|
35 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
36 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
37 |
import eu.etaxonomy.cdm.vaadin.container.NamedAreaContainer; |
|
38 |
import eu.etaxonomy.cdm.vaadin.container.TaxonNodeContainer; |
|
39 |
import eu.etaxonomy.cdm.vaadin.presenter.dbstatus.settings.SettingsPresenter; |
|
40 |
import eu.etaxonomy.cdm.vaadin.util.DistributionEditorUtil; |
|
41 |
|
|
42 |
/** |
|
43 |
* |
|
44 |
* @author pplitzner |
|
45 |
* |
|
46 |
*/ |
|
47 |
public class DistributionSettingsConfigWindow extends CustomComponent implements ValueChangeListener, ClickListener{ |
|
48 |
|
|
49 |
private static final long serialVersionUID = 1439411115014088780L; |
|
50 |
private ComboBox classificationBox; |
|
51 |
private ComboBox distAreaBox; |
|
52 |
private ListSelect namedAreaList; |
|
53 |
private Tree taxonTree; |
|
54 |
private Label labelNoClassification; |
|
55 |
private Button okButton; |
|
56 |
private Button cancelButton; |
|
57 |
private final SettingsPresenter presenter; |
|
58 |
private Window window; |
|
59 |
private HorizontalLayout mainLayout; |
|
60 |
|
|
61 |
/** |
|
62 |
* The constructor should first build the main layout, set the |
|
63 |
* composition root and then do any custom initialization. |
|
64 |
* |
|
65 |
* The constructor will not be automatically regenerated by the |
|
66 |
* visual editor. |
|
67 |
* @param distributionTableView |
|
68 |
*/ |
|
69 |
public DistributionSettingsConfigWindow(DistributionTableView distributionTableView) { |
|
70 |
buildMainLayout(); |
|
71 |
presenter = new SettingsPresenter(); |
|
72 |
init(); |
|
73 |
} |
|
74 |
|
|
75 |
private void init() { |
|
76 |
Container distributionContainer = presenter.getDistributionContainer(); |
|
77 |
TermVocabulary<NamedArea> chosenArea = presenter.getChosenArea(); |
|
78 |
|
|
79 |
classificationBox.setItemCaptionPropertyId(TaxonNodeContainer.LABEL); |
|
80 |
classificationBox.setContainerDataSource(new TaxonNodeContainer(null)); |
|
81 |
classificationBox.setImmediate(true); |
|
82 |
TaxonNode chosenTaxonNode = presenter.getChosenTaxonNode(); |
|
83 |
classificationBox.addValueChangeListener(this); |
|
84 |
if(chosenTaxonNode!=null){ |
|
85 |
classificationBox.setValue(chosenTaxonNode.getClassification().getRootNode()); |
|
86 |
taxonTree.setContainerDataSource(new TaxonNodeContainer((TaxonNode) classificationBox.getValue())); |
|
87 |
taxonTree.setValue(chosenTaxonNode); |
|
88 |
} |
|
89 |
taxonTree.setItemCaptionPropertyId(TaxonNodeContainer.LABEL); |
|
90 |
distAreaBox.setContainerDataSource(distributionContainer); |
|
91 |
distAreaBox.setValue(chosenArea); |
|
92 |
distAreaBox.addValueChangeListener(this); |
|
93 |
|
|
94 |
if(chosenArea!=null){ |
|
95 |
NamedAreaContainer container = new NamedAreaContainer(chosenArea); |
|
96 |
namedAreaList.setContainerDataSource(container); |
|
97 |
} |
|
98 |
Object selectedAreas = VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREAS); |
|
99 |
namedAreaList.setValue(selectedAreas); |
|
100 |
|
|
101 |
okButton.addClickListener(this); |
|
102 |
cancelButton.addClickListener(this); |
|
103 |
} |
|
104 |
|
|
105 |
public Window createWindow(){ |
|
106 |
window = new Window(); |
|
107 |
window.setModal(true); |
|
108 |
window.setWidth("60%"); |
|
109 |
window.setHeight("80%"); |
|
110 |
window.setCaption("Settings"); |
|
111 |
window.setContent(mainLayout); |
|
112 |
return window; |
|
113 |
} |
|
114 |
|
|
115 |
private AbstractLayout buildMainLayout() { |
|
116 |
|
|
117 |
mainLayout = new HorizontalLayout(); |
|
118 |
mainLayout.setImmediate(false); |
|
119 |
mainLayout.setSizeFull(); |
|
120 |
mainLayout.setMargin(true); |
|
121 |
mainLayout.setSpacing(true); |
|
122 |
|
|
123 |
VerticalLayout leftContainer = new VerticalLayout(); |
|
124 |
leftContainer.setImmediate(false); |
|
125 |
leftContainer.setSizeFull(); |
|
126 |
leftContainer.setSpacing(true); |
|
127 |
|
|
128 |
VerticalLayout rightContainer = new VerticalLayout(); |
|
129 |
rightContainer.setImmediate(false); |
|
130 |
rightContainer.setSizeFull(); |
|
131 |
rightContainer.setSpacing(true); |
|
132 |
|
|
133 |
//classification and term |
|
134 |
classificationBox = new ComboBox("Classification"); |
|
135 |
classificationBox.setImmediate(true); |
|
136 |
classificationBox.setWidth("100%"); |
|
137 |
|
|
138 |
//distribution area box |
|
139 |
distAreaBox = new ComboBox("Distribution Area:"); |
|
140 |
distAreaBox.setImmediate(true); |
|
141 |
distAreaBox.setWidth("100%"); |
|
142 |
|
|
143 |
// named areas |
|
144 |
namedAreaList = new ListSelect(); |
|
145 |
namedAreaList.setCaption("Areas"); |
|
146 |
namedAreaList.setWidth("100%"); |
|
147 |
namedAreaList.setMultiSelect(true); |
|
148 |
|
|
149 |
//taxonomy |
|
150 |
taxonTree = new Tree("Taxonomy"); |
|
151 |
taxonTree.setImmediate(false); |
|
152 |
|
|
153 |
//no classification selected label |
|
154 |
labelNoClassification = new Label(" - Please select a classification - "); |
|
155 |
|
|
156 |
leftContainer.addComponent(classificationBox); |
|
157 |
leftContainer.addComponent(distAreaBox); |
|
158 |
leftContainer.addComponent(namedAreaList); |
|
159 |
leftContainer.setSizeFull(); |
|
160 |
|
|
161 |
rightContainer.addComponent(taxonTree); |
|
162 |
rightContainer.setExpandRatio(taxonTree, 1); |
|
163 |
rightContainer.addComponent(labelNoClassification); |
|
164 |
rightContainer.setComponentAlignment(labelNoClassification, Alignment.BOTTOM_RIGHT); |
|
165 |
|
|
166 |
mainLayout.addComponent(leftContainer); |
|
167 |
mainLayout.addComponent(rightContainer); |
|
168 |
|
|
169 |
//button toolbar |
|
170 |
HorizontalLayout buttonToolBar = new HorizontalLayout(); |
|
171 |
// cancelButton |
|
172 |
cancelButton = new Button(); |
|
173 |
cancelButton.setCaption("Cancel"); |
|
174 |
cancelButton.setImmediate(true); |
|
175 |
buttonToolBar.addComponent(cancelButton); |
|
176 |
|
|
177 |
// okButton |
|
178 |
okButton = new Button(); |
|
179 |
okButton.setCaption("OK"); |
|
180 |
okButton.setImmediate(true); |
|
181 |
buttonToolBar.addComponent(okButton); |
|
182 |
|
|
183 |
mainLayout.addComponent(rightContainer); |
|
184 |
mainLayout.addComponent(buttonToolBar); |
|
185 |
mainLayout.setComponentAlignment(buttonToolBar, Alignment.BOTTOM_RIGHT); |
|
186 |
|
|
187 |
return mainLayout; |
|
188 |
} |
|
189 |
|
|
190 |
@Override |
|
191 |
public void valueChange(ValueChangeEvent event) { |
|
192 |
Property property = event.getProperty(); |
|
193 |
if(property==classificationBox){ |
|
194 |
TaxonNode parentNode = (TaxonNode) event.getProperty().getValue(); |
|
195 |
if(parentNode!=null){ |
|
196 |
taxonTree.setContainerDataSource(new TaxonNodeContainer(parentNode)); |
|
197 |
} |
|
198 |
else{ |
|
199 |
taxonTree.setContainerDataSource(null); |
|
200 |
} |
|
201 |
labelNoClassification.setVisible(parentNode==null); |
|
202 |
} |
|
203 |
|
|
204 |
else if(property==distAreaBox){ |
|
205 |
TermVocabulary<NamedArea> vocabulary = (TermVocabulary<NamedArea>) event.getProperty().getValue(); |
|
206 |
NamedAreaContainer container = new NamedAreaContainer(vocabulary); |
|
207 |
namedAreaList.setContainerDataSource(container); |
|
208 |
} |
|
209 |
} |
|
210 |
|
|
211 |
@Override |
|
212 |
public void buttonClick(ClickEvent event) { |
|
213 |
Object source = event.getSource(); |
|
214 |
if(source==okButton){ |
|
215 |
TaxonNode taxonNode; |
|
216 |
TermVocabulary<NamedArea> term = null; |
|
217 |
taxonNode = (TaxonNode) taxonTree.getValue(); |
|
218 |
if(taxonNode==null){ |
|
219 |
taxonNode = (TaxonNode) classificationBox.getValue(); |
|
220 |
} |
|
221 |
term = (TermVocabulary<NamedArea>) distAreaBox.getValue(); |
|
222 |
Set<NamedArea> selectedAreas = (Set<NamedArea>) namedAreaList.getValue(); |
|
223 |
if(taxonNode==null){ |
|
224 |
Notification.show("Please choose a classification and/or taxon", Notification.Type.HUMANIZED_MESSAGE); |
|
225 |
return; |
|
226 |
} |
|
227 |
if(term==null){ |
|
228 |
Notification.show("Please choose a distribution area", Notification.Type.HUMANIZED_MESSAGE); |
|
229 |
return; |
|
230 |
} |
|
231 |
DistributionEditorUtil.openDistributionView(taxonNode, term, selectedAreas); |
|
232 |
window.close(); |
|
233 |
} |
|
234 |
else if(source==cancelButton){ |
|
235 |
window.close(); |
|
236 |
} |
|
237 |
} |
|
238 |
|
|
239 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionTableView.java | ||
---|---|---|
189 | 189 |
} |
190 | 190 |
}); |
191 | 191 |
|
192 |
Button settingsButton = toolbar.getSettingsButton();
|
|
193 |
settingsButton.addClickListener(new ClickListener() {
|
|
192 |
Button distributionSettingsButton = toolbar.getDistributionSettingsButton();
|
|
193 |
distributionSettingsButton.addClickListener(new ClickListener() {
|
|
194 | 194 |
|
195 |
private static final long serialVersionUID = 3834048719431837966L;
|
|
195 |
private static final long serialVersionUID = -8695281619014251132L;
|
|
196 | 196 |
|
197 | 197 |
@Override |
198 | 198 |
public void buttonClick(ClickEvent event) { |
199 |
openSettings(); |
|
199 |
openDistributionSettings();
|
|
200 | 200 |
} |
201 | 201 |
}); |
202 | 202 |
|
203 |
Button settingsButton = toolbar.getSettingsButton(); |
|
204 |
settingsButton.addClickListener(new ClickListener() { |
|
205 |
|
|
206 |
private static final long serialVersionUID = -147703680580181544L; |
|
207 |
|
|
208 |
@Override |
|
209 |
public void buttonClick(ClickEvent event) { |
|
210 |
openSettings(); |
|
211 |
} |
|
212 |
}); |
|
213 |
|
|
203 | 214 |
Button saveButton = toolbar.getSaveButton(); |
204 | 215 |
saveButton.setClickShortcut(KeyCode.S, ModifierKey.CTRL); |
205 | 216 |
saveButton.setDescription("Shortcut: CTRL+S"); |
... | ... | |
221 | 232 |
} |
222 | 233 |
|
223 | 234 |
public void openSettings() { |
224 |
SettingsConfigWindow cw = new SettingsConfigWindow(); |
|
235 |
SettingsConfigWindow cw = new SettingsConfigWindow(this); |
|
236 |
Window window = cw.createWindow(); |
|
237 |
getUI().addWindow(window); |
|
238 |
} |
|
239 |
|
|
240 |
public void openDistributionSettings() { |
|
241 |
DistributionSettingsConfigWindow cw = new DistributionSettingsConfigWindow(this); |
|
225 | 242 |
Window window = cw.createWindow(); |
226 | 243 |
getUI().addWindow(window); |
227 | 244 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/SettingsConfigWindow.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.cdm.vaadin.view.dbstatus; |
11 | 11 |
|
12 |
import java.util.Set; |
|
13 |
|
|
14 |
import com.vaadin.data.Container; |
|
15 | 12 |
import com.vaadin.data.Property; |
16 | 13 |
import com.vaadin.data.Property.ValueChangeEvent; |
17 | 14 |
import com.vaadin.data.Property.ValueChangeListener; |
... | ... | |
22 | 19 |
import com.vaadin.ui.Button.ClickEvent; |
23 | 20 |
import com.vaadin.ui.Button.ClickListener; |
24 | 21 |
import com.vaadin.ui.CheckBox; |
25 |
import com.vaadin.ui.ComboBox; |
|
26 | 22 |
import com.vaadin.ui.CustomComponent; |
27 | 23 |
import com.vaadin.ui.HorizontalLayout; |
28 |
import com.vaadin.ui.Label; |
|
29 |
import com.vaadin.ui.ListSelect; |
|
30 |
import com.vaadin.ui.Notification; |
|
31 |
import com.vaadin.ui.Tree; |
|
32 | 24 |
import com.vaadin.ui.TwinColSelect; |
33 | 25 |
import com.vaadin.ui.VerticalLayout; |
34 | 26 |
import com.vaadin.ui.Window; |
35 | 27 |
|
36 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|
37 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
38 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
39 |
import eu.etaxonomy.cdm.vaadin.container.NamedAreaContainer; |
|
40 |
import eu.etaxonomy.cdm.vaadin.container.TaxonNodeContainer; |
|
41 | 28 |
import eu.etaxonomy.cdm.vaadin.presenter.dbstatus.settings.SettingsPresenter; |
42 | 29 |
import eu.etaxonomy.cdm.vaadin.util.DistributionEditorUtil; |
43 | 30 |
|
... | ... | |
51 | 38 |
private static final long serialVersionUID = -8220442386869594032L; |
52 | 39 |
private VerticalLayout mainLayout; |
53 | 40 |
private TwinColSelect distStatusSelect; |
54 |
private ComboBox classificationBox; |
|
55 |
private ComboBox distAreaBox; |
|
56 |
private ListSelect namedAreaList; |
|
57 |
private Tree taxonTree; |
|
58 |
private Label labelNoClassification; |
|
59 | 41 |
private CheckBox boxToggleAbbreviatedLabels; |
60 | 42 |
private Button okButton; |
61 | 43 |
private Button cancelButton; |
62 | 44 |
private final SettingsPresenter presenter; |
63 | 45 |
private Window window; |
46 |
private DistributionTableView distributionTableView; |
|
64 | 47 |
|
65 | 48 |
/** |
66 | 49 |
* The constructor should first build the main layout, set the |
... | ... | |
68 | 51 |
* |
69 | 52 |
* The constructor will not be automatically regenerated by the |
70 | 53 |
* visual editor. |
54 |
* @param distributionTableView |
|
71 | 55 |
*/ |
72 |
public SettingsConfigWindow() { |
|
56 |
public SettingsConfigWindow(DistributionTableView distributionTableView) { |
|
57 |
this.distributionTableView = distributionTableView; |
|
73 | 58 |
buildMainLayout(); |
74 | 59 |
presenter = new SettingsPresenter(); |
75 | 60 |
init(); |
76 | 61 |
} |
77 | 62 |
|
78 | 63 |
private void init() { |
79 |
Container distributionContainer = presenter.getDistributionContainer(); |
|
80 |
TermVocabulary<NamedArea> chosenArea = presenter.getChosenArea(); |
|
81 |
|
|
82 |
classificationBox.setItemCaptionPropertyId(TaxonNodeContainer.LABEL); |
|
83 |
classificationBox.setContainerDataSource(new TaxonNodeContainer(null)); |
|
84 |
classificationBox.setImmediate(true); |
|
85 |
TaxonNode chosenTaxonNode = presenter.getChosenTaxonNode(); |
|
86 |
classificationBox.addValueChangeListener(this); |
|
87 |
if(chosenTaxonNode!=null){ |
|
88 |
classificationBox.setValue(chosenTaxonNode.getClassification().getRootNode()); |
|
89 |
taxonTree.setContainerDataSource(new TaxonNodeContainer((TaxonNode) classificationBox.getValue())); |
|
90 |
taxonTree.setValue(chosenTaxonNode); |
|
91 |
} |
|
92 |
taxonTree.setItemCaptionPropertyId(TaxonNodeContainer.LABEL); |
|
93 |
distAreaBox.setContainerDataSource(distributionContainer); |
|
94 |
distAreaBox.setValue(chosenArea); |
|
95 |
distAreaBox.addValueChangeListener(this); |
|
96 |
|
|
97 |
if(chosenArea!=null){ |
|
98 |
NamedAreaContainer container = new NamedAreaContainer(chosenArea); |
|
99 |
namedAreaList.setContainerDataSource(container); |
|
100 |
} |
|
101 |
Object selectedAreas = VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREAS); |
|
102 |
namedAreaList.setValue(selectedAreas); |
|
103 |
|
|
104 | 64 |
boxToggleAbbreviatedLabels.addValueChangeListener(this); |
105 | 65 |
distStatusSelect.setContainerDataSource(presenter.getDistributionStatusContainer()); |
106 | 66 |
|
... | ... | |
126 | 86 |
mainLayout.setMargin(true); |
127 | 87 |
mainLayout.setSpacing(true); |
128 | 88 |
|
129 |
HorizontalLayout topContainer = new HorizontalLayout(); |
|
130 |
topContainer.setImmediate(false); |
|
131 |
topContainer.setSizeFull(); |
|
132 |
topContainer.setSpacing(true); |
|
133 |
|
|
134 |
VerticalLayout verticalLayout = new VerticalLayout(); |
|
135 |
verticalLayout.setImmediate(false); |
|
136 |
|
|
137 |
//classification and term |
|
138 |
classificationBox = new ComboBox("Classification"); |
|
139 |
classificationBox.setImmediate(true); |
|
140 |
classificationBox.setWidth("100%"); |
|
141 |
|
|
142 |
//distribution area box |
|
143 |
distAreaBox = new ComboBox("Distribution Area:"); |
|
144 |
distAreaBox.setImmediate(true); |
|
145 |
distAreaBox.setWidth("100%"); |
|
146 |
|
|
147 |
// named areas |
|
148 |
namedAreaList = new ListSelect(); |
|
149 |
namedAreaList.setCaption("Areas"); |
|
150 |
namedAreaList.setWidth("100%"); |
|
151 |
namedAreaList.setMultiSelect(true); |
|
152 |
|
|
153 | 89 |
//distribution status |
154 | 90 |
distStatusSelect = new TwinColSelect("Distribution Status:"); |
155 | 91 |
distStatusSelect.setImmediate(false); |
... | ... | |
159 | 95 |
boxToggleAbbreviatedLabels = new CheckBox("Show abbreviated labels", DistributionEditorUtil.isAbbreviatedLabels()); |
160 | 96 |
boxToggleAbbreviatedLabels.setImmediate(true); |
161 | 97 |
|
162 |
//taxonomy |
|
163 |
taxonTree = new Tree("Taxonomy"); |
|
164 |
taxonTree.setImmediate(false); |
|
165 |
|
|
166 |
//no classification selected label |
|
167 |
labelNoClassification = new Label(" - Please select a classification - "); |
|
168 |
|
|
169 |
verticalLayout.addComponent(classificationBox); |
|
170 |
verticalLayout.addComponent(distAreaBox); |
|
171 |
verticalLayout.addComponent(namedAreaList); |
|
172 |
verticalLayout.addComponent(boxToggleAbbreviatedLabels); |
|
173 |
verticalLayout.addComponent(distStatusSelect); |
|
174 |
verticalLayout.setExpandRatio(distStatusSelect, 1); |
|
175 |
verticalLayout.setSizeFull(); |
|
176 |
|
|
177 |
topContainer.addComponent(verticalLayout); |
|
178 |
topContainer.addComponent(taxonTree); |
|
179 |
topContainer.setExpandRatio(taxonTree, 1); |
|
180 |
topContainer.addComponent(labelNoClassification); |
|
181 |
topContainer.setComponentAlignment(labelNoClassification, Alignment.BOTTOM_RIGHT); |
|
182 |
topContainer.setExpandRatio(verticalLayout, 1); |
|
98 |
mainLayout.addComponent(boxToggleAbbreviatedLabels); |
|
99 |
mainLayout.addComponent(distStatusSelect); |
|
100 |
mainLayout.setExpandRatio(distStatusSelect, 1); |
|
101 |
mainLayout.setSizeFull(); |
|
183 | 102 |
|
184 | 103 |
//button toolbar |
185 |
HorizontalLayout buttonToolBar = new HorizontalLayout();
|
|
104 |
HorizontalLayout buttonContainer = new HorizontalLayout();
|
|
186 | 105 |
// cancelButton |
187 | 106 |
cancelButton = new Button(); |
188 | 107 |
cancelButton.setCaption("Cancel"); |
189 | 108 |
cancelButton.setImmediate(true); |
190 |
buttonToolBar.addComponent(cancelButton);
|
|
109 |
buttonContainer.addComponent(cancelButton);
|
|
191 | 110 |
|
192 | 111 |
// okButton |
193 | 112 |
okButton = new Button(); |
194 | 113 |
okButton.setCaption("OK"); |
195 | 114 |
okButton.setImmediate(true); |
196 |
buttonToolBar.addComponent(okButton);
|
|
115 |
buttonContainer.addComponent(okButton);
|
|
197 | 116 |
|
198 |
mainLayout.addComponent(topContainer); |
|
199 |
mainLayout.addComponent(buttonToolBar); |
|
200 |
mainLayout.setComponentAlignment(buttonToolBar, Alignment.BOTTOM_RIGHT); |
|
117 |
mainLayout.addComponent(buttonContainer); |
|
118 |
mainLayout.setComponentAlignment(buttonContainer, Alignment.BOTTOM_RIGHT); |
|
201 | 119 |
|
202 | 120 |
return mainLayout; |
203 | 121 |
} |
... | ... | |
205 | 123 |
@Override |
206 | 124 |
public void valueChange(ValueChangeEvent event) { |
207 | 125 |
Property property = event.getProperty(); |
208 |
if(property==classificationBox){ |
|
209 |
TaxonNode parentNode = (TaxonNode) event.getProperty().getValue(); |
|
210 |
if(parentNode!=null){ |
|
211 |
taxonTree.setContainerDataSource(new TaxonNodeContainer(parentNode)); |
|
212 |
} |
|
213 |
else{ |
|
214 |
taxonTree.setContainerDataSource(null); |
|
215 |
} |
|
216 |
labelNoClassification.setVisible(parentNode==null); |
|
217 |
} |
|
218 |
|
|
219 |
else if(property==distAreaBox){ |
|
220 |
TermVocabulary<NamedArea> vocabulary = (TermVocabulary<NamedArea>) event.getProperty().getValue(); |
|
221 |
NamedAreaContainer container = new NamedAreaContainer(vocabulary); |
|
222 |
namedAreaList.setContainerDataSource(container); |
|
223 |
} |
|
224 |
else if(property==boxToggleAbbreviatedLabels){ |
|
126 |
if(property==boxToggleAbbreviatedLabels){ |
|
225 | 127 |
VaadinSession.getCurrent().setAttribute(DistributionEditorUtil.SATTR_ABBREVIATED_LABELS, event.getProperty().getValue()); |
226 | 128 |
} |
227 | 129 |
} |
... | ... | |
230 | 132 |
public void buttonClick(ClickEvent event) { |
231 | 133 |
Object source = event.getSource(); |
232 | 134 |
if(source==okButton){ |
233 |
TaxonNode taxonNode; |
|
234 |
TermVocabulary<NamedArea> term = null; |
|
235 |
taxonNode = (TaxonNode) taxonTree.getValue(); |
|
236 |
if(taxonNode==null){ |
|
237 |
taxonNode = (TaxonNode) classificationBox.getValue(); |
|
238 |
} |
|
239 |
term = (TermVocabulary<NamedArea>) distAreaBox.getValue(); |
|
240 |
Set<NamedArea> selectedAreas = (Set<NamedArea>) namedAreaList.getValue(); |
|
241 |
if(taxonNode==null){ |
|
242 |
Notification.show("Please choose a classification and/or taxon", Notification.Type.HUMANIZED_MESSAGE); |
|
243 |
return; |
|
244 |
} |
|
245 |
if(term==null){ |
|
246 |
Notification.show("Please choose a distribution area", Notification.Type.HUMANIZED_MESSAGE); |
|
247 |
return; |
|
248 |
} |
|
249 |
DistributionEditorUtil.openDistributionView(taxonNode, term, selectedAreas); |
|
135 |
distributionTableView.enter(null); |
|
250 | 136 |
window.close(); |
251 | 137 |
} |
252 | 138 |
else if(source==cancelButton){ |
Also available in: Unified diff
ref #5458 Split settings window into two