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