KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > ide > dialogs > MultiStepWizardDialog


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.ide.dialogs;
12
13 import org.eclipse.jface.dialogs.IDialogConstants;
14 import org.eclipse.jface.wizard.WizardDialog;
15 import org.eclipse.swt.widgets.Button;
16 import org.eclipse.swt.widgets.Shell;
17
18 /**
19  * A dialog to show a multi-step wizard to the end user.
20  * <p>
21  * In typical usage, the client instantiates this class with
22  * a multi-step wizard. The dialog serves as the wizard container
23  * and orchestrates the presentation of its pages.
24  * <p>
25  * The standard layout is roughly as follows:
26  * it has an area at the top containing both the
27  * wizard's title, description, and image; the actual wizard page
28  * appears in the middle; below that is a progress indicator
29  * (which is made visible if needed); and at the bottom
30  * of the page is message line and a button bar containing
31  * Help, Next, Back, Finish, and Cancel buttons (or some subset).
32  * </p>
33  * <p>
34  * This class is not intended to be subclassed by clients.
35  * </p>
36  */

37 public class MultiStepWizardDialog extends WizardDialog {
38     private MultiStepWizard multiStepWizard;
39
40     /**
41      * Creates a new wizard dialog for the given wizard.
42      *
43      * @param parentShell the parent shell
44      * @param newWizard the multi-step wizard this dialog is working on
45      */

46     public MultiStepWizardDialog(Shell parentShell, MultiStepWizard newWizard) {
47         super(parentShell, newWizard);
48         multiStepWizard = newWizard;
49         multiStepWizard.setWizardDialog(this);
50     }
51
52     /**
53      * Forces the wizard dialog to close
54      */

55     /* package */void forceClose() {
56         super.finishPressed();
57     }
58
59     /* (non-Javadoc)
60      * Method declared on WizardDialog.
61      */

62     protected void backPressed() {
63         if (multiStepWizard.isConfigureStepMode()) {
64             multiStepWizard.getStepContainer().backPressed();
65         } else {
66             super.backPressed();
67         }
68     }
69
70     /* (non-Javadoc)
71      * Method declared on WizardDialog.
72      */

73     protected void finishPressed() {
74         if (multiStepWizard.isConfigureStepMode()) {
75             boolean success = multiStepWizard.getStepContainer()
76                     .performFinish();
77             if (success) {
78                 multiStepWizard.getStepContainer().processCurrentStep();
79             }
80         } else {
81             super.finishPressed();
82         }
83     }
84
85     /**
86      * Returns the multi-step wizard for this dialog
87      */

88     /* package */MultiStepWizard getMultiStepWizard() {
89         return multiStepWizard;
90     }
91
92     /* (non-Javadoc)
93      * Method declared on WizardDialog.
94      */

95     protected void helpPressed() {
96         if (multiStepWizard.isConfigureStepMode()) {
97             multiStepWizard.getStepContainer().helpPressed();
98         } else {
99             super.helpPressed();
100         }
101     }
102
103     /* (non-Javadoc)
104      * Method declared on WizardDialog.
105      */

106     protected void nextPressed() {
107         if (multiStepWizard.isConfigureStepMode()) {
108             multiStepWizard.getStepContainer().nextPressed();
109         } else {
110             super.nextPressed();
111         }
112     }
113
114     /**
115      * Sets the label for the finish button
116      */

117     /* package */void setFinishLabel(String JavaDoc label) {
118         Button button = getButton(IDialogConstants.FINISH_ID);
119         if (button == null) {
120             return;
121         }
122
123         if (label == null) {
124             if (!button.getText().equals(IDialogConstants.FINISH_LABEL)) {
125                 button.setText(IDialogConstants.FINISH_LABEL);
126                 button.getParent().layout(true);
127             }
128         } else {
129             button.setText(label);
130             button.getParent().layout(true);
131         }
132     }
133
134     /**
135      * Updates everything in the dialog
136      */

137     /* package */void updateAll() {
138         super.update();
139     }
140
141     /**
142      * Updates the layout of the dialog
143      */

144     /* package */void updateLayout() {
145         super.updateSize(getCurrentPage());
146     }
147 }
148
Popular Tags