01: package net.refractions.udig.catalog.ui.preferences;
02:
03: import net.refractions.udig.catalog.ui.wizard.DataBaseRegistryWizardPage;
04:
05: import org.eclipse.swt.layout.GridData;
06: import org.eclipse.swt.widgets.Composite;
07: import org.eclipse.swt.widgets.Event;
08: import org.eclipse.swt.widgets.Listener;
09:
10: public abstract class AbstractProprietaryDatastoreWizardPage extends
11: DataBaseRegistryWizardPage {
12:
13: public AbstractProprietaryDatastoreWizardPage(String wizardPageTitle) {
14: super (wizardPageTitle);
15: }
16:
17: private AbstractProprietaryJarPreferencePage preferences;
18:
19: public final void createControl(final Composite parent) {
20: preferences = getPreferencePage();
21: preferences.setListener(new Listener() {
22:
23: public void handleEvent(Event event) {
24: getControl().dispose();
25: advanced = null;
26: advancedKey = null;
27: host = null;
28: pass = null;
29: port = null;
30: schema = null;
31: user = null;
32: createControl(parent);
33: parent.layout();
34: setMessage(getRestartMessage());
35: }
36:
37: });
38: if (!preferences.installed()) {
39: setMessage(getDriversMessage());
40: preferences.createControl(parent);
41: GridData data = new GridData();
42: data.grabExcessHorizontalSpace = true;
43: data.grabExcessVerticalSpace = true;
44: preferences.getControl().setLayoutData(data);
45: setControl(preferences.getControl());
46: } else {
47: super .createControl(parent);
48: doCreateWizardPage(parent);
49: }
50: }
51:
52: @Override
53: public final boolean isPageComplete() {
54: if (!preferences.installed())
55: return false;
56:
57: return doIsPageComplete();
58: }
59:
60: protected abstract boolean doIsPageComplete();
61:
62: /**
63: * Called by createControl() to create wizard page must NOT call {@link #createControl(Composite)}.
64: *
65: * @param parent
66: */
67: protected abstract void doCreateWizardPage(Composite parent);
68:
69: protected abstract AbstractProprietaryJarPreferencePage getPreferencePage();
70:
71: /**
72: * Example: "An error will occur because the Oracle drivers were not loaded. Please restart application"
73: *
74: * @return restart message
75: */
76: protected abstract String getRestartMessage();
77:
78: /**
79: * Example: "Install Oracle drivers for client"
80: *
81: * @return message indicating that drivers need to be loaded.
82: */
83: protected abstract String getDriversMessage();
84: }
|