blob: 880e3eae9f04d6a9e6940173ce19d3a57df8b084 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
package org.openslx.dozmod.gui.wizard;
import javax.swing.JPanel;
public abstract class WizardPage extends JPanel {
private final String title;
private String description = null;
private String message = null;
private boolean isError = false;
private boolean isComplete = false;
private Wizard wizard = null;
/**
* Whether the user is allowed to go back to this page once they clicked
* next.
*/
protected boolean canComeBack = true;
public WizardPage(String title) {
this.title = title;
}
public String getTitle() {
return this.title;
}
private void updateHeader() {
if (this.wizard != null)
this.wizard.updateHeader();
}
/*
* Feedback from the pages
*/
/**
* Called when the user wants to advance to the next page. You have the
* chance to run some sanity checks and return false if you want to prevent
* the user from switching the page, but in general it is recommended to
* disable the next button as long as there are errors in the current page.
*
* @return true allows to flip the page, false cancels
*/
protected boolean goNext() {
return isComplete;
}
/**
* Called when the page is being shown. This can be caused by three possible events:
* 1) The wizard opens and this is the fist page
* 2) The user clicked "Previous" and this is the previous page
* 3) The user clicked "Next" and this is the next page
*/
protected void onPageEnter() {
}
/**
* Called when the page is being hidden. This can be caused by three possible events:
* 1) The user clicked finish and this is the page currently displayed
* 2) The user clicked "Previous" and this is the current page
* 3) The user clicked "Next" and this is the current page
*/
protected void onPageLeave() {
}
/*
* Setters from derived classes
*/
protected void setPageComplete(boolean b) {
isComplete = b;
if (wizard != null)
wizard.updateButtons();
}
protected void setDescription(String description) {
this.description = description;
this.updateHeader();
}
protected void setErrorMessage(String message) {
this.message = message;
this.isError = true;
this.updateHeader();
}
protected void setWarningMessage(String message) {
this.message = message;
this.isError = false;
this.updateHeader();
}
/*
* Setters from Wizard
*/
void setWizard(Wizard wizard) {
if (this.wizard != null)
throw new IllegalStateException("Parent Wizard already set");
this.wizard = wizard;
}
}
|