Statistics
| Revision:

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

History | View | Annotate | Download (3.32 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
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2010 {Prodevelop}   {Task}
27
 */
28

    
29
package org.gvsig.gui.beans.wizard.panel;
30

    
31
import java.awt.BorderLayout;
32

    
33
import javax.swing.JOptionPane;
34

    
35
import jwizardcomponent.JWizardComponents;
36
import jwizardcomponent.JWizardPanel;
37

    
38
import org.slf4j.Logger;
39
import org.slf4j.LoggerFactory;
40

    
41
/**
42
 * <p>
43
 * This class is a wizard panel that displays the panel returned by the
44
 * {@link OptionPanel#getJPanel()} method int the top of the wizard. It also
45
 * call the other methods when the user clicks a button.
46
 * <p>
47
 * 
48
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
49
 */
50
public class OptionPanelContainer extends JWizardPanel {
51

    
52
    private static final long serialVersionUID = 3947658150325230122L;
53
    private OptionPanel optionPanel = null;
54
    private static final Logger log =
55
        LoggerFactory.getLogger(OptionPanelContainer.class);
56

    
57
    public OptionPanelContainer(JWizardComponents wizardComponents,
58
        OptionPanel optionPanel) {
59
        super(wizardComponents);
60
        this.optionPanel = optionPanel;
61
        setLayout(new BorderLayout());
62
        setBorder(javax.swing.BorderFactory.createCompoundBorder(
63
            javax.swing.BorderFactory.createTitledBorder(optionPanel
64
                .getPanelTitle()), javax.swing.BorderFactory.createEmptyBorder(
65
                5, 5, 5, 5)));
66
        add(optionPanel.getJPanel(), BorderLayout.CENTER);
67
    }
68

    
69
    /*
70
     * (non-Javadoc)
71
     * 
72
     * @see jwizardcomponent.JWizardPanel#back()
73
     */
74
    @Override
75
    public void back() {
76
        optionPanel.lastPanel();
77
        super.back();
78
    }
79

    
80
    /*
81
     * (non-Javadoc)
82
     * 
83
     * @see jwizardcomponent.JWizardPanel#next()
84
     */
85
    @Override
86
    public void next() {
87
        try {
88
            optionPanel.nextPanel();
89
            super.next();
90
        } catch (NotContinueWizardException e) {
91
            // this is not an error and not need to raise a error or
92
            // warning in the log.
93
            log.info("It is not possible to continue with the wizard", e);
94
            if (e.displayMessage()) {
95
                JOptionPane.showMessageDialog(e.getComponent(), e
96
                    .getLocalizedMessageStack());
97
            }
98
        }
99
    }
100

    
101
    /*
102
     * (non-Javadoc)
103
     * 
104
     * @see jwizardcomponent.JWizardPanel#update()
105
     */
106
    @Override
107
    public void update() {
108
        optionPanel.updatePanel();
109
        super.update();
110
    }
111
}