Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.impl / src / main / java / org / gvsig / exportto / swing / impl / wizard / DefaultWizardContainer.java @ 41488

History | View | Annotate | Download (3.52 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 modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.exportto.swing.impl.wizard;
24

    
25
import javax.swing.JPanel;
26
import org.gvsig.exportto.swing.impl.panel.MessagePanel;
27

    
28
import org.slf4j.Logger;
29
import org.slf4j.LoggerFactory;
30

    
31
import org.gvsig.exportto.swing.spi.ExporttoPanelValidationException;
32
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel;
33
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException;
34
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
35
import org.gvsig.i18n.Messages;
36
import org.gvsig.tools.ToolsLocator;
37
import org.gvsig.tools.i18n.I18nManager;
38

    
39
/**
40
 * @author gvSIG Team
41
 * @version $Id$
42
 *
43
 */
44
public class DefaultWizardContainer implements OptionPanel {
45

    
46
    private static final Logger LOG = LoggerFactory
47
            .getLogger(DefaultWizardContainer.class);
48

    
49
    private ExporttoSwingProviderPanel exporttoSwingProviderPanel = null;
50

    
51
    public DefaultWizardContainer(
52
            ExporttoSwingProviderPanel exporttoSwingProviderPanel) {
53
        super();
54
        this.exporttoSwingProviderPanel = exporttoSwingProviderPanel;
55
    }
56

    
57
    public String getPanelTitle() {
58
        return exporttoSwingProviderPanel.getPanelTitle();
59
    }
60

    
61
    public void nextPanel() throws NotContinueWizardException {
62
        try {
63
            if (!this.exporttoSwingProviderPanel.isValidPanel()) {
64
                throw new NotContinueWizardException(
65
                        Messages.getText("_Invalid_values_in_form"),
66
                        exporttoSwingProviderPanel.asJComponent(),
67
                        false);
68
            }
69
        } catch (ExporttoPanelValidationException e) {
70
            LOG.info("Invalid form values.");
71
            throw new NotContinueWizardException(
72
                    Messages.getText("_Invalid_values_in_form"),
73
                    e, exporttoSwingProviderPanel.asJComponent());
74
        }
75
    }
76

    
77
    public void lastPanel() {
78
        // TODO Auto-generated method stub
79

    
80
    }
81

    
82
    public void updatePanel() {
83
        try {
84
            this.exporttoSwingProviderPanel.enterPanel();
85
        } catch (Exception ex) {
86
            LOG.warn("Fail the call to enterPanel.", ex);
87
            I18nManager i18nManager = ToolsLocator.getI18nManager();
88
            MessagePanel.showMessage(
89
                    i18nManager.getTranslation("_Warning"),
90
                    i18nManager.getTranslation("_There_have_been_problems_filling_data_in_panel") +
91
                            " (" + this.exporttoSwingProviderPanel.getPanelTitle() +")" ,
92
                    ex,
93
                    null
94
            );
95
        }
96
    }
97

    
98
    public JPanel getJPanel() {
99
        return (JPanel) exporttoSwingProviderPanel.asJComponent();
100
    }
101

    
102
}