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