1 |
f1e283f5
|
Andreas Kohlbecker
|
package eu.etaxonomy.cdm.vaadin.view.distributionStatus;
|
2 |
58dba687
|
Patrick Plitzner
|
|
3 |
|
|
import com.vaadin.ui.AbstractLayout;
|
4 |
|
|
import com.vaadin.ui.AbstractOrderedLayout;
|
5 |
|
|
import com.vaadin.ui.Button;
|
6 |
|
|
import com.vaadin.ui.CustomComponent;
|
7 |
|
|
import com.vaadin.ui.HorizontalLayout;
|
8 |
|
|
import com.vaadin.ui.Window;
|
9 |
|
|
|
10 |
29078af6
|
Andreas Kohlbecker
|
import eu.etaxonomy.cdm.vaadin.view.distributionStatus.settings.SettingsPresenter;
|
11 |
58dba687
|
Patrick Plitzner
|
|
12 |
|
|
@SuppressWarnings("serial")
|
13 |
|
|
public abstract class AbstractSettingsDialogWindow extends CustomComponent {
|
14 |
|
|
|
15 |
|
|
protected Button okButton;
|
16 |
|
|
protected Button cancelButton;
|
17 |
|
|
protected final SettingsPresenter presenter;
|
18 |
|
|
protected Window window;
|
19 |
|
|
protected AbstractOrderedLayout mainLayout;
|
20 |
|
|
|
21 |
|
|
public AbstractSettingsDialogWindow() {
|
22 |
|
|
buildMainLayout();
|
23 |
|
|
presenter = new SettingsPresenter();
|
24 |
|
|
init();
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
protected abstract AbstractLayout buildMainLayout();
|
28 |
|
|
|
29 |
|
|
protected abstract void init();
|
30 |
|
|
|
31 |
|
|
protected HorizontalLayout createOkCancelButtons() {
|
32 |
|
|
HorizontalLayout buttonToolBar = new HorizontalLayout();
|
33 |
|
|
// cancelButton
|
34 |
|
|
cancelButton = new Button();
|
35 |
|
|
cancelButton.setCaption("Cancel");
|
36 |
|
|
cancelButton.setImmediate(true);
|
37 |
|
|
cancelButton.addStyleName("dialogButton");
|
38 |
|
|
buttonToolBar.addComponent(cancelButton);
|
39 |
c964d5e8
|
Patrick Plitzner
|
|
40 |
58dba687
|
Patrick Plitzner
|
// okButton
|
41 |
|
|
okButton = new Button();
|
42 |
|
|
okButton.setCaption("OK");
|
43 |
|
|
okButton.setImmediate(true);
|
44 |
|
|
okButton.addStyleName("dialogButton");
|
45 |
|
|
buttonToolBar.addComponent(okButton);
|
46 |
|
|
return buttonToolBar;
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
public Window createWindow() {
|
50 |
|
|
window = new Window();
|
51 |
|
|
window.setModal(true);
|
52 |
|
|
window.setWidth("60%");
|
53 |
|
|
window.setHeight("80%");
|
54 |
c964d5e8
|
Patrick Plitzner
|
window.setCaption("Distribution Settings");
|
55 |
58dba687
|
Patrick Plitzner
|
window.setContent(mainLayout);
|
56 |
|
|
return window;
|
57 |
|
|
}
|
58 |
c964d5e8
|
Patrick Plitzner
|
|
59 |
41f187f1
|
Patrick Plitzner
|
/**
|
60 |
|
|
* Update OK/Cancel button depending on {@link #isValid()}
|
61 |
|
|
*/
|
62 |
|
|
protected void updateButtons(){
|
63 |
|
|
okButton.setEnabled(isValid());
|
64 |
|
|
}
|
65 |
c964d5e8
|
Patrick Plitzner
|
|
66 |
41f187f1
|
Patrick Plitzner
|
/**
|
67 |
c964d5e8
|
Patrick Plitzner
|
* Evaluates if this dialog has all necessary values set in
|
68 |
41f187f1
|
Patrick Plitzner
|
* a correct state
|
69 |
|
|
* @return <code>true</code> if the status of this dialog is valid
|
70 |
|
|
*/
|
71 |
|
|
protected abstract boolean isValid();
|
72 |
58dba687
|
Patrick Plitzner
|
|
73 |
7b2a0df1
|
Andreas Kohlbecker
|
}
|