File Source: WizardPanel.java
/*
P/P * Method: com.dmdirc.installer.ui.WizardPanel__static_init
*/
1 /*
2 *
3 * Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 package com.dmdirc.installer.ui;
25
26 import com.dmdirc.installer.Step;
27
28 import java.util.List;
29 import javax.swing.JPanel;
30
31 /**
32 * Wizard panel, displays and controls the flow of steps.
33 */
34 public class WizardPanel extends JPanel {
35
36 private static final long serialVersionUID = 7903362315297158222L;
37 private final StepLayout layout;
38 private final InstallerDialog dialog;
39
40 /**
41 * Instantiates a new wizard panel.
42 *
43 * @param dialog Parent installer dialog
44 */
45 public WizardPanel(final InstallerDialog dialog) {
/*
P/P * Method: void com.dmdirc.installer.ui.WizardPanel(InstallerDialog)
*
* Postconditions:
* this.dialog == dialog
* init'ed(this.dialog)
* this.layout == &new StepLayout(WizardPanel#1)
* new ArrayList(StepLayout#1) num objects == 1
* new StepLayout(WizardPanel#1) num objects == 1
* init'ed(this.layout.currentStep)
* init'ed(this.layout.hGap)
* init'ed(this.layout.parent)
* this.layout.steps == &new ArrayList(StepLayout#1)
* init'ed(this.layout.vGap)
*/
46 super();
47
48 this.dialog = dialog;
49 layout = new StepLayout();
50 setLayout(layout);
51 }
52
53 /**
54 * Displays this panel with the specified steps.
55 *
56 * @param steps Steps to display
57 */
58 public void display(final List<SwingStep> steps) {
/*
P/P * Method: void display(List)
*
* Preconditions:
* steps != null
* this.layout != null
* (soft) this.layout.steps != null
*
* Presumptions:
* java.util.Iterator:next(...)@59 != null
*
* Postconditions:
* possibly_updated(this.layout.currentStep)
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@59: {0}, {1}
*/
59 for (SwingStep step : steps) {
60 addStep(step);
61 }
62 display();
63 }
64
65 /**
66 * Displays this panel with the existing steps.
67 */
68 public void display() {
/*
P/P * Method: void display()
*
* Preconditions:
* this.layout != null
* (soft) this.layout.steps != null
*
* Postconditions:
* possibly_updated(this.layout.currentStep)
*/
69 showFirst();
70 }
71
72 /**
73 * Returns the step specified.
74 *
75 * @param step Step index
76 *
77 * @return Step
78 */
79 public Step getStep(final int step) {
/*
P/P * Method: Step getStep(int)
*
* Preconditions:
* this.layout != null
* this.layout.steps != null
*
* Postconditions:
* init'ed(return_value)
*/
80 return layout.getStep(step);
81 }
82
83 /**
84 * Returns the step specified.
85 *
86 * @param stepName Step name
87 *
88 * @return Step
89 */
90 public Step getStep(final String stepName) {
/*
P/P * Method: Step getStep(String)
*
* Preconditions:
* this.layout != null
* this.layout.steps != null
* (soft) stepName != null
*
* Presumptions:
* java.util.Iterator:next(...)@92 != null
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* java.lang.String:equals(...)@93: {0}, {1}
* java.util.Iterator:hasNext(...)@92: {0}, {1}
*/
91 Step step = null;
92 for (SwingStep loopStep : layout.getSteps()) {
93 if (stepName.equals(loopStep.getStepName())) {
94 return loopStep;
95 }
96 }
97 return step;
98 }
99
100 /**
101 * Returns the current Step.
102 *
103 * @return Current step index
104 */
105 public int getCurrentStepIndex() {
/*
P/P * Method: int getCurrentStepIndex()
*
* Preconditions:
* this.layout != null
* init'ed(this.layout.currentStep)
*
* Postconditions:
* return_value == this.layout.currentStep
* init'ed(return_value)
*/
106 return layout.getCurrentStepIndex();
107 }
108
109 /**
110 * Returns the current Step.
111 *
112 * @return Current step index
113 */
114 public String getCurrentStepName() {
/*
P/P * Method: String getCurrentStepName()
*
* Preconditions:
* this.layout != null
* init'ed(this.layout.currentStep)
* this.layout.steps != null
*
* Postconditions:
* init'ed(return_value)
*/
115 return layout.getCurrentStepName();
116 }
117
118 /**
119 * Returns the current Step.
120 *
121 * @return Current step index
122 */
123 public Step getCurrentStep() {
/*
P/P * Method: Step getCurrentStep()
*
* Preconditions:
* this.layout != null
* init'ed(this.layout.currentStep)
* this.layout.steps != null
*
* Postconditions:
* init'ed(return_value)
*/
124 return layout.getCurrentStep();
125 }
126
127 /**
128 * Returns the total number of steps.
129 *
130 * @return Total number of steps
131 */
132 public int getTotalSteps() {
/*
P/P * Method: int getTotalSteps()
*
* Preconditions:
* this.layout != null
* this.layout.steps != null
*
* Postconditions:
* init'ed(return_value)
*/
133 return layout.getSteps().size();
134 }
135
136 /**
137 * Adds a step to this panel.
138 *
139 * @param step Step to add
140 */
141 public void addStep(final SwingStep step) {
/*
P/P * Method: void addStep(SwingStep)
*
* Preconditions:
* step != null
*/
142 add(step, step.getStepName());
143 }
144
145 /**
146 * Shows the first step.
147 */
148 public void showFirst() {
/*
P/P * Method: void showFirst()
*
* Preconditions:
* this.layout != null
* (soft) this.layout.steps != null
*
* Postconditions:
* possibly_updated(this.layout.currentStep)
*/
149 layout.first(this);
150 }
151
152 /**
153 * Shows the last step.
154 */
155 public void showLast() {
/*
P/P * Method: void showLast()
*
* Preconditions:
* this.layout != null
* (soft) this.layout.steps != null
*
* Postconditions:
* possibly_updated(this.layout.currentStep)
*/
156 layout.last(this);
157 }
158
159 /**
160 * Shows the next step.
161 */
162 public void nextStep() {
/*
P/P * Method: void nextStep()
*
* Preconditions:
* this.layout.currentStep <= 232-2
* this.layout != null
* (soft) this.layout.steps != null
*
* Postconditions:
* init'ed(this.layout.currentStep)
*/
163 layout.next(this);
164 }
165
166 /**
167 * Shows the previous step.
168 */
169 public void previousStep() {
/*
P/P * Method: void previousStep()
*
* Preconditions:
* this.layout.currentStep >= -231+1
* this.layout != null
* (soft) this.layout.steps != null
*
* Postconditions:
* init'ed(this.layout.currentStep)
*/
170 layout.previous(this);
171 }
172
173 /**
174 * Shows the specified step.
175 *
176 * @param step Step index
177 */
178 public void showStep(final int step) {
/*
P/P * Method: void showStep(int)
*
* Preconditions:
* this.layout != null
* (soft) this.layout.steps != null
*
* Postconditions:
* possibly_updated(this.layout.currentStep)
*/
179 layout.show(step, this);
180 }
181 }
SofCheck Inspector Build Version : 2.17854
| WizardPanel.java |
2009-Jun-25 01:54:24 |
| WizardPanel.class |
2009-Sep-02 17:04:16 |