1
|
/**
|
2
|
* Copyright (C) 2015 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.cdm.vaadin.view.dbstatus;
|
10
|
|
11
|
import com.vaadin.data.Property;
|
12
|
import com.vaadin.data.Property.ValueChangeEvent;
|
13
|
import com.vaadin.data.Property.ValueChangeListener;
|
14
|
import com.vaadin.server.VaadinSession;
|
15
|
import com.vaadin.ui.AbstractLayout;
|
16
|
import com.vaadin.ui.Alignment;
|
17
|
import com.vaadin.ui.Button.ClickEvent;
|
18
|
import com.vaadin.ui.Button.ClickListener;
|
19
|
import com.vaadin.ui.CheckBox;
|
20
|
import com.vaadin.ui.HorizontalLayout;
|
21
|
import com.vaadin.ui.TwinColSelect;
|
22
|
import com.vaadin.ui.VerticalLayout;
|
23
|
|
24
|
import eu.etaxonomy.cdm.vaadin.util.DistributionEditorUtil;
|
25
|
|
26
|
/**
|
27
|
* @author alex
|
28
|
* @date 22.04.2015
|
29
|
*
|
30
|
*/
|
31
|
public class SettingsConfigWindow extends AbstractSettingsDialogWindow implements ValueChangeListener, ClickListener{
|
32
|
|
33
|
private static final long serialVersionUID = -8220442386869594032L;
|
34
|
private TwinColSelect distStatusSelect;
|
35
|
private CheckBox boxToggleAbbreviatedLabels;
|
36
|
private DistributionTableView distributionTableView;
|
37
|
|
38
|
/**
|
39
|
* The constructor should first build the main layout, set the
|
40
|
* composition root and then do any custom initialization.
|
41
|
*
|
42
|
* The constructor will not be automatically regenerated by the
|
43
|
* visual editor.
|
44
|
* @param distributionTableView
|
45
|
*/
|
46
|
public SettingsConfigWindow(DistributionTableView distributionTableView) {
|
47
|
super();
|
48
|
this.distributionTableView = distributionTableView;
|
49
|
}
|
50
|
|
51
|
protected void init() {
|
52
|
boxToggleAbbreviatedLabels.addValueChangeListener(this);
|
53
|
distStatusSelect.setContainerDataSource(presenter.getDistributionStatusContainer());
|
54
|
|
55
|
okButton.addClickListener(this);
|
56
|
cancelButton.addClickListener(this);
|
57
|
updateButtons();
|
58
|
}
|
59
|
|
60
|
protected AbstractLayout buildMainLayout() {
|
61
|
|
62
|
mainLayout = new VerticalLayout();
|
63
|
mainLayout.setImmediate(false);
|
64
|
mainLayout.setSizeFull();
|
65
|
mainLayout.setMargin(true);
|
66
|
mainLayout.setSpacing(true);
|
67
|
|
68
|
//distribution status
|
69
|
distStatusSelect = new TwinColSelect("Distribution Status:");
|
70
|
distStatusSelect.setImmediate(false);
|
71
|
distStatusSelect.setSizeFull();
|
72
|
distStatusSelect.setWidth("100%");
|
73
|
|
74
|
//toggle abbreviated labels
|
75
|
boxToggleAbbreviatedLabels = new CheckBox("Show abbreviated labels", DistributionEditorUtil.isAbbreviatedLabels());
|
76
|
boxToggleAbbreviatedLabels.setImmediate(true);
|
77
|
|
78
|
mainLayout.addComponent(boxToggleAbbreviatedLabels);
|
79
|
mainLayout.addComponent(distStatusSelect);
|
80
|
mainLayout.setExpandRatio(distStatusSelect, 1);
|
81
|
mainLayout.setSizeFull();
|
82
|
|
83
|
//button toolbar
|
84
|
HorizontalLayout buttonContainer = createOkCancelButtons();
|
85
|
|
86
|
mainLayout.addComponent(buttonContainer);
|
87
|
mainLayout.setComponentAlignment(buttonContainer, Alignment.BOTTOM_RIGHT);
|
88
|
|
89
|
return mainLayout;
|
90
|
}
|
91
|
|
92
|
@Override
|
93
|
protected boolean isValid() {
|
94
|
return true;
|
95
|
}
|
96
|
|
97
|
@Override
|
98
|
public void valueChange(ValueChangeEvent event) {
|
99
|
Property property = event.getProperty();
|
100
|
if(property==boxToggleAbbreviatedLabels){
|
101
|
VaadinSession.getCurrent().setAttribute(DistributionEditorUtil.SATTR_ABBREVIATED_LABELS, event.getProperty().getValue());
|
102
|
}
|
103
|
}
|
104
|
|
105
|
@Override
|
106
|
public void buttonClick(ClickEvent event) {
|
107
|
Object source = event.getSource();
|
108
|
if(source==okButton){
|
109
|
VaadinSession.getCurrent().setAttribute(DistributionEditorUtil.SATTR_DISTRIBUTION_STATUS, distStatusSelect.getValue());
|
110
|
distributionTableView.enter(null);
|
111
|
window.close();
|
112
|
}
|
113
|
else if(source==cancelButton){
|
114
|
window.close();
|
115
|
}
|
116
|
}
|
117
|
|
118
|
}
|