Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / main / java / org / gvsig / gui / beans / wizard / WizardPanelWithLogo.java @ 40561

History | View | Annotate | Download (5.13 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.gui.beans.wizard;
25

    
26
import java.awt.BorderLayout;
27
import java.awt.Color;
28

    
29
import javax.swing.ImageIcon;
30
import javax.swing.JLabel;
31
import javax.swing.JPanel;
32
import javax.swing.JSeparator;
33

    
34
import jwizardcomponent.CancelAction;
35
import jwizardcomponent.DefaultJWizardComponents;
36
import jwizardcomponent.FinishAction;
37
import jwizardcomponent.common.SimpleButtonPanel;
38

    
39
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
40
import org.gvsig.gui.beans.wizard.panel.OptionPanelContainer;
41

    
42
public class WizardPanelWithLogo extends JPanel {
43

    
44
    private static final long serialVersionUID = 7506729926181935234L;
45
    public final static int ACTION_PREVIOUS = 0;
46
    public final static int ACTION_NEXT = 1;
47
    public final static int ACTION_CANCEL = 2;
48
    public final static int ACTION_FINISH = 3;
49

    
50
    DefaultJWizardComponents wizardComponents;
51

    
52
    JPanel buttonPanel;
53
    JLabel statusLabel = new JLabel();
54

    
55
    ImageIcon logo;
56

    
57
    public WizardPanelWithLogo(ImageIcon logo) {
58
        this.logo = logo;
59
        wizardComponents = new DefaultJWizardComponents();
60
        init();
61
    }
62

    
63
    public WizardPanelWithLogo() {
64
        wizardComponents = new DefaultJWizardComponents();
65
        this.logo = null;
66
        init();
67
    }
68

    
69
    private void init() {
70

    
71
        this.setLayout(new BorderLayout());
72
        if (logo != null) {
73
            JPanel logoPanel = new JPanel();
74
            logoPanel.add(new JLabel(logo));
75
            logoPanel.setBackground(Color.WHITE);
76
            this.add(logoPanel, BorderLayout.WEST);
77
        }
78

    
79
        this.add(wizardComponents.getWizardPanelsContainer(),
80
            BorderLayout.CENTER);
81

    
82
        JPanel auxPanel = new JPanel(new BorderLayout());
83
        auxPanel.add(new JSeparator(), BorderLayout.NORTH);
84

    
85
        buttonPanel = new SimpleButtonPanel(wizardComponents);
86
        auxPanel.add(buttonPanel);
87
        this.add(auxPanel, BorderLayout.SOUTH);
88

    
89
        wizardComponents.setFinishAction(new FinishAction(wizardComponents) {
90

    
91
            public void performAction() {
92
                // dispose();
93
            }
94
        });
95
        wizardComponents.setCancelAction(new CancelAction(wizardComponents) {
96

    
97
            public void performAction() {
98
                // dispose();
99
            }
100
        });
101
    }
102

    
103
    public void doAction(int action) {
104
        switch (action) {
105
        case ACTION_NEXT:
106
            getWizardComponents().getNextButton().getActionListeners()[0]
107
                .actionPerformed(null);
108
            break;
109
        case ACTION_PREVIOUS:
110
            getWizardComponents().getBackButton().getActionListeners()[0]
111
                .actionPerformed(null);
112
            break;
113
        }
114
    }
115

    
116
    public DefaultJWizardComponents getWizardComponents() {
117
        return wizardComponents;
118
    }
119

    
120
    public void setWizardComponents(DefaultJWizardComponents aWizardComponents) {
121
        wizardComponents = aWizardComponents;
122
    }
123

    
124
    @Override
125
    public void show() {
126
        wizardComponents.updateComponents();
127
        super.setVisible(true);
128
    }
129

    
130
    public void addOptionPanel(OptionPanel optionPanel) {
131
        getWizardComponents().addWizardPanel(
132
            new OptionPanelContainer(getWizardComponents(), optionPanel));
133
    }
134

    
135
    public void setNextButtonEnabled(boolean isEnabled) {
136
        getWizardComponents().getNextButton().setEnabled(isEnabled);
137
    }
138

    
139
    public void setFinishButtonEnabled(boolean isVisible) {
140
        getWizardComponents().getFinishButton().setEnabled(isVisible);
141
    }
142

    
143
    public void setCancelButtonEnabled(boolean isVisible) {
144
        getWizardComponents().getCancelButton().setEnabled(isVisible);
145
    }
146

    
147
    private void setFinishAction(FinishAction finishAction) {
148
        getWizardComponents().setFinishAction(finishAction);
149
    }
150

    
151
    private void setCancelAction(CancelAction cancelAction) {
152
        getWizardComponents().setCancelAction(cancelAction);
153
    }
154

    
155
    public void setWizardListener(WizardPanel wizardPanel) {
156
        setFinishAction(new WizardPanelFinishAction(getWizardComponents(),
157
            wizardPanel));
158
        setCancelAction(new WizardPanelCancelAction(getWizardComponents(),
159
            wizardPanel));
160
    }
161

    
162
    public void setBackButtonEnabled(boolean isEnabled) {
163
        getWizardComponents().getBackButton().setEnabled(isEnabled);
164
    }
165
}