svn-gvsig-desktop / trunk / libraries / libUIComponent / src / org / gvsig / gui / beans / wizard / WizardPanelWithLogo.java @ 37801
History | View | Annotate | Download (4.2 KB)
1 |
package org.gvsig.gui.beans.wizard; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Color; |
5 |
|
6 |
import javax.swing.ImageIcon; |
7 |
import javax.swing.JLabel; |
8 |
import javax.swing.JPanel; |
9 |
import javax.swing.JSeparator; |
10 |
|
11 |
import jwizardcomponent.CancelAction; |
12 |
import jwizardcomponent.DefaultJWizardComponents; |
13 |
import jwizardcomponent.FinishAction; |
14 |
import jwizardcomponent.common.SimpleButtonPanel; |
15 |
|
16 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
17 |
import org.gvsig.gui.beans.wizard.panel.OptionPanelContainer; |
18 |
|
19 |
public class WizardPanelWithLogo extends JPanel { |
20 |
|
21 |
private static final long serialVersionUID = 7506729926181935234L; |
22 |
public final static int ACTION_PREVIOUS = 0; |
23 |
public final static int ACTION_NEXT = 1; |
24 |
public final static int ACTION_CANCEL = 2; |
25 |
public final static int ACTION_FINISH = 3; |
26 |
|
27 |
DefaultJWizardComponents wizardComponents; |
28 |
|
29 |
JPanel buttonPanel;
|
30 |
JLabel statusLabel = new JLabel(); |
31 |
|
32 |
ImageIcon logo;
|
33 |
|
34 |
public WizardPanelWithLogo(ImageIcon logo) { |
35 |
this.logo = logo;
|
36 |
wizardComponents = new DefaultJWizardComponents();
|
37 |
init(); |
38 |
} |
39 |
|
40 |
public WizardPanelWithLogo() {
|
41 |
wizardComponents = new DefaultJWizardComponents();
|
42 |
this.logo = null; |
43 |
init(); |
44 |
} |
45 |
|
46 |
private void init() { |
47 |
|
48 |
this.setLayout(new BorderLayout()); |
49 |
if (logo != null) { |
50 |
JPanel logoPanel = new JPanel(); |
51 |
logoPanel.add(new JLabel(logo)); |
52 |
logoPanel.setBackground(Color.WHITE);
|
53 |
this.add(logoPanel, BorderLayout.WEST); |
54 |
} |
55 |
|
56 |
this.add(wizardComponents.getWizardPanelsContainer(),
|
57 |
BorderLayout.CENTER);
|
58 |
|
59 |
JPanel auxPanel = new JPanel(new BorderLayout()); |
60 |
auxPanel.add(new JSeparator(), BorderLayout.NORTH); |
61 |
|
62 |
buttonPanel = new SimpleButtonPanel(wizardComponents);
|
63 |
auxPanel.add(buttonPanel); |
64 |
this.add(auxPanel, BorderLayout.SOUTH); |
65 |
|
66 |
wizardComponents.setFinishAction(new FinishAction(wizardComponents) {
|
67 |
|
68 |
public void performAction() { |
69 |
// dispose();
|
70 |
} |
71 |
}); |
72 |
wizardComponents.setCancelAction(new CancelAction(wizardComponents) {
|
73 |
|
74 |
public void performAction() { |
75 |
// dispose();
|
76 |
} |
77 |
}); |
78 |
} |
79 |
|
80 |
public void doAction(int action) { |
81 |
switch (action) {
|
82 |
case ACTION_NEXT:
|
83 |
getWizardComponents().getNextButton().getActionListeners()[0]
|
84 |
.actionPerformed(null);
|
85 |
break;
|
86 |
case ACTION_PREVIOUS:
|
87 |
getWizardComponents().getBackButton().getActionListeners()[0]
|
88 |
.actionPerformed(null);
|
89 |
break;
|
90 |
} |
91 |
} |
92 |
|
93 |
public DefaultJWizardComponents getWizardComponents() {
|
94 |
return wizardComponents;
|
95 |
} |
96 |
|
97 |
public void setWizardComponents(DefaultJWizardComponents aWizardComponents) { |
98 |
wizardComponents = aWizardComponents; |
99 |
} |
100 |
|
101 |
@Override
|
102 |
public void show() { |
103 |
wizardComponents.updateComponents(); |
104 |
super.setVisible(true); |
105 |
} |
106 |
|
107 |
public void addOptionPanel(OptionPanel optionPanel) { |
108 |
getWizardComponents().addWizardPanel( |
109 |
new OptionPanelContainer(getWizardComponents(), optionPanel));
|
110 |
} |
111 |
|
112 |
public void setNextButtonEnabled(boolean isEnabled) { |
113 |
getWizardComponents().getNextButton().setEnabled(isEnabled); |
114 |
} |
115 |
|
116 |
public void setFinishButtonEnabled(boolean isVisible) { |
117 |
getWizardComponents().getFinishButton().setEnabled(isVisible); |
118 |
} |
119 |
|
120 |
public void setCancelButtonEnabled(boolean isVisible) { |
121 |
getWizardComponents().getCancelButton().setEnabled(isVisible); |
122 |
} |
123 |
|
124 |
private void setFinishAction(FinishAction finishAction) { |
125 |
getWizardComponents().setFinishAction(finishAction); |
126 |
} |
127 |
|
128 |
private void setCancelAction(CancelAction cancelAction) { |
129 |
getWizardComponents().setCancelAction(cancelAction); |
130 |
} |
131 |
|
132 |
public void setWizardListener(WizardPanel wizardPanel) { |
133 |
setFinishAction(new WizardPanelFinishAction(getWizardComponents(),
|
134 |
wizardPanel)); |
135 |
setCancelAction(new WizardPanelCancelAction(getWizardComponents(),
|
136 |
wizardPanel)); |
137 |
} |
138 |
|
139 |
public void setBackButtonEnabled(boolean isEnabled) { |
140 |
getWizardComponents().getBackButton().setEnabled(isEnabled); |
141 |
} |
142 |
} |