1
|
package eu.etaxonomy.cdm.vaadin.view.distributionStatus;
|
2
|
|
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
|
import eu.etaxonomy.cdm.i18n.Messages;
|
11
|
import eu.etaxonomy.cdm.vaadin.view.distributionStatus.settings.SettingsPresenterBase;
|
12
|
|
13
|
@SuppressWarnings("serial")
|
14
|
public abstract class SettingsDialogWindowBase<P extends SettingsPresenterBase> extends CustomComponent {
|
15
|
|
16
|
protected Button okButton;
|
17
|
protected Button cancelButton;
|
18
|
protected final P presenter;
|
19
|
protected Window window;
|
20
|
protected AbstractOrderedLayout mainLayout;
|
21
|
|
22
|
public SettingsDialogWindowBase() {
|
23
|
buildMainLayout();
|
24
|
presenter = getPresenter();
|
25
|
init();
|
26
|
}
|
27
|
|
28
|
protected abstract P getPresenter();
|
29
|
|
30
|
protected abstract AbstractLayout buildMainLayout();
|
31
|
|
32
|
protected abstract void init();
|
33
|
|
34
|
protected HorizontalLayout createOkCancelButtons() {
|
35
|
HorizontalLayout buttonToolBar = new HorizontalLayout();
|
36
|
// cancelButton
|
37
|
cancelButton = new Button();
|
38
|
cancelButton.setCaption(Messages.getLocalizedString(Messages.SettingsDialogWindowBase_CANCEL));
|
39
|
cancelButton.setImmediate(true);
|
40
|
cancelButton.addStyleName("dialogButton"); //$NON-NLS-1$
|
41
|
buttonToolBar.addComponent(cancelButton);
|
42
|
|
43
|
// okButton
|
44
|
okButton = new Button();
|
45
|
okButton.setCaption(Messages.getLocalizedString(Messages.SettingsDialogWindowBase_OK));
|
46
|
okButton.setImmediate(true);
|
47
|
okButton.addStyleName("dialogButton"); //$NON-NLS-1$
|
48
|
buttonToolBar.addComponent(okButton);
|
49
|
return buttonToolBar;
|
50
|
}
|
51
|
|
52
|
public Window createWindow(String caption) {
|
53
|
window = new Window();
|
54
|
window.setModal(true);
|
55
|
window.setWidth("60%"); //$NON-NLS-1$
|
56
|
window.setHeight("80%"); //$NON-NLS-1$
|
57
|
window.setCaption(caption);
|
58
|
window.setContent(mainLayout);
|
59
|
return window;
|
60
|
}
|
61
|
|
62
|
/**
|
63
|
* Update OK/Cancel button depending on {@link #isValid()}
|
64
|
*/
|
65
|
protected void updateButtons(){
|
66
|
okButton.setEnabled(isValid());
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* Evaluates if this dialog has all necessary values set in
|
71
|
* a correct state
|
72
|
* @return <code>true</code> if the status of this dialog is valid
|
73
|
*/
|
74
|
protected abstract boolean isValid();
|
75
|
|
76
|
}
|