File Source: WizardFrame.java
/*
P/P * Method: com.dmdirc.addons.ui_swing.wizard.WizardFrame__static_init
*/
1 /*
2 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.dmdirc.addons.ui_swing.wizard;
24
25
26 import com.dmdirc.ui.CoreUIUtils;
27
28 import java.util.List;
29
30 import javax.swing.JFrame;
31
32 /**
33 * Basic wizard container.
34 */
35 public final class WizardFrame extends JFrame {
36
37 /**
38 * A version number for this class. It should be changed whenever the class
39 * structure is changed (or anything else that would prevent serialized
40 * objects being unserialized with the new class).
41 */
42 private static final long serialVersionUID = 2;
43 /** Wizard. */
44 private final WizardPanel wizard;
45
46 /**
47 * Creates a new instance of WizardFrame that requires a mainframe.
48 *
49 * @param title Title for the wizard
50 * @param steps Steps for the wizard
51 * @param wizard Wizard to inform of changes
52 */
53 public WizardFrame(final String title, final List<Step> steps,
54 final WizardListener wizard) {
/*
P/P * Method: void com.dmdirc.addons.ui_swing.wizard.WizardFrame(String, List, WizardListener)
*
* Preconditions:
* steps != null
*
* Postconditions:
* this.wizard == &new WizardPanel(WizardFrame#1)
* new ArrayList(StepLayout#1) num objects == 1
* new JButton(initComponents#5) num objects == 1
* new JButton(initComponents#6) num objects == 1
* new JLabel(initComponents#4) num objects == 1
* new JPanel(initComponents#3) num objects == 1
* new ListenerList(WizardPanel#1) num objects == 1
* new StepLayout(WizardPanel#2) num objects == 1
* new TitlePanel(initComponents#1) num objects == 1
* new WizardPanel(WizardFrame#1) num objects == 1
* ...
*/
55 super();
56
57 setTitle(title);
58 setDefaultCloseOperation(DISPOSE_ON_CLOSE);
59 this.wizard = new WizardPanel(title, steps, wizard);
60 layoutComponents();
61 }
62
63 /** Lays out the components. */
64 private void layoutComponents() {
/*
P/P * Method: void layoutComponents()
*/
65 setContentPane(wizard);
66 }
67
68 /** Displays the wizard. */
69 public void display() {
/*
P/P * Method: void display()
*
* Preconditions:
* this.wizard != null
* this.wizard.steps != null
* this.wizard.steps.steps != null
* (soft) this.wizard.next != null
* (soft) this.wizard.prev != null
* (soft) this.wizard.progressLabel != null
* (soft) this.wizard.stepsPanel != null
* (soft) this.wizard.titleLabel != null
*
* Postconditions:
* this.wizard.currentStep == One-of{old this.wizard.currentStep, 0}
* possibly_updated(this.wizard.steps.currentStep)
*/
70 wizard.display();
71 CoreUIUtils.centreWindow(this);
72 setResizable(false);
73 setVisible(true);
74 }
75
76 /** {@inheritDoc} */
77 @Override
78 public void validate() {
/*
P/P * Method: void validate()
*/
79 super.validate();
80 CoreUIUtils.centreWindow(this);
81 }
82
83 /**
84 * Adds a step to the wizard.
85 *
86 * @param step Step to add
87 */
88 public void addStep(final Step step) {
/*
P/P * Method: void addStep(Step)
*
* Preconditions:
* step != null
* this.wizard != null
* this.wizard.stepsPanel != null
*/
89 wizard.addStep(step);
90 }
91
92 /**
93 * Returns the step at the specified index.
94 *
95 * @param stepNumber step number
96 *
97 * @return Specified step.
98 */
99 public Step getStep(final int stepNumber) {
/*
P/P * Method: Step getStep(int)
*
* Preconditions:
* this.wizard != null
* this.wizard.steps != null
* this.wizard.steps.steps != null
*
* Postconditions:
* init'ed(return_value)
*/
100 return wizard.getStep(stepNumber);
101 }
102
103 /**
104 * Returns the current step.
105 *
106 * @return Current step number
107 */
108 public int getCurrentStep() {
/*
P/P * Method: int getCurrentStep()
*
* Preconditions:
* this.wizard != null
* init'ed(this.wizard.currentStep)
*
* Postconditions:
* return_value == this.wizard.currentStep
* init'ed(return_value)
*/
109 return wizard.getCurrentStep();
110 }
111
112 /**
113 * Enables or disables the "next step" button.
114 *
115 * @param newValue boolean true to make "next" button enabled, else false
116 */
117 public void enableNextStep(final boolean newValue) {
/*
P/P * Method: void enableNextStep(bool)
*
* Preconditions:
* this.wizard != null
* this.wizard.next != null
*/
118 wizard.enableNextStep(newValue);
119 }
120
121 /**
122 * Enables or disables the "previous step" button.
123 *
124 * @param newValue boolean true to make "previous" button enabled, else false
125 */
126 public void enablePreviousStep(final boolean newValue) {
/*
P/P * Method: void enablePreviousStep(bool)
*
* Preconditions:
* this.wizard != null
* this.wizard.prev != null
*/
127 wizard.enablePreviousStep(newValue);
128 }
129
130 /**
131 * Adds a step listener to the list.
132 *
133 * @param listener
134 */
135 public void addStepListener(final StepListener listener) {
/*
P/P * Method: void addStepListener(StepListener)
*
* Preconditions:
* this.wizard != null
* this.wizard.stepListeners != null
*/
136 wizard.addStepListener(listener);
137 }
138
139 /**
140 * Removes a step listener from the list.
141 *
142 * @param listener
143 */
144 public void removeStepListener(final StepListener listener) {
/*
P/P * Method: void removeStepListener(StepListener)
*
* Preconditions:
* this.wizard != null
* this.wizard.stepListeners != null
*/
145 wizard.removeStepListener(listener);
146 }
147
148 /**
149 * Adds a wizard listener to the list.
150 *
151 * @param listener
152 */
153 public void addWizardListener(final WizardListener listener) {
/*
P/P * Method: void addWizardListener(WizardListener)
*
* Preconditions:
* this.wizard != null
* this.wizard.stepListeners != null
*/
154 wizard.addWizardListener(listener);
155 }
156
157 /**
158 * Removes a wizard listener from the list.
159 *
160 * @param listener
161 */
162 public void removeWizardListener(final WizardListener listener) {
/*
P/P * Method: void removeWizardListener(WizardListener)
*
* Preconditions:
* this.wizard != null
* this.wizard.stepListeners != null
*/
163 wizard.removeWizardListener(listener);
164 }
165 }
SofCheck Inspector Build Version : 2.17854
| WizardFrame.java |
2009-Jun-25 01:54:24 |
| WizardFrame.class |
2009-Sep-02 17:04:16 |