01: package net.refractions.udig.catalog.ui.workflow;
02:
03: import org.eclipse.jface.resource.ImageDescriptor;
04: import org.eclipse.jface.wizard.IWizardPage;
05: import org.eclipse.jface.wizard.WizardPage;
06:
07: public abstract class WorkflowWizardPage extends WizardPage {
08:
09: Workflow.State state;
10:
11: protected WorkflowWizardPage(String pageName, String title,
12: ImageDescriptor titleImage) {
13: super (pageName, title, titleImage);
14: }
15:
16: protected WorkflowWizardPage(String pageName) {
17: super (pageName);
18: }
19:
20: public Workflow.State getState() {
21: return state;
22: }
23:
24: public void setState(Workflow.State state) {
25: this .state = state;
26: }
27:
28: @Override
29: public WorkflowWizard getWizard() {
30: return (WorkflowWizard) super .getWizard();
31: }
32:
33: /**
34: * Called immediately after a page has been shown in the wizard. At the
35: * time this method is called, the page can be sure that its ui has been
36: * created (via a call to #createContents()) and that it's state has been
37: * set (via #setState()). Default implementation does nothing, subclass
38: * should override.
39: */
40: public void shown() {
41: //do nothing
42: }
43:
44: /**
45: * This method returns true if there are more states in the workflow, and
46: * the current page is complete. Subclasses should extend this method in the
47: * following way.
48: *
49: * <pre>
50: * <code>
51: * public boolean canFlipToNextPage() {
52: * boolean flip = super.canFlipToNextPage();
53: * if (flip) {
54: * //validate user input (usually checking state of ui)
55: * if (...) {
56: * return true;
57: * }
58: * }
59: *
60: * return false;
61: * }
62: * </code>
63: * </pre>
64: */
65: @Override
66: public boolean canFlipToNextPage() {
67: boolean complete = isPageComplete();
68: boolean more = false;
69: if (state != null)
70: more = state.getWorkflow().hasMoreStates();
71:
72: return complete && more;
73: }
74:
75: }
|