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 / export / swing / impl / WizardOptionPanelAdapter.java @ 45324

History | View | Annotate | Download (4.74 KB)

1 43925 jjdelcerro
/**
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.export.swing.impl;
24
25
import javax.swing.JPanel;
26 44044 jjdelcerro
import org.gvsig.export.swing.JExportProcessPanel;
27 43925 jjdelcerro
import org.gvsig.export.swing.spi.ExportPanel;
28
import org.gvsig.export.swing.spi.ExportPanelValidationException;
29
30
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
32
33
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException;
34
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
35
import org.gvsig.tools.ToolsLocator;
36
import org.gvsig.tools.i18n.I18nManager;
37
38
/**
39
 * @author gvSIG Team
40
 * @version $Id$
41
 *
42
 */
43
public class WizardOptionPanelAdapter implements OptionPanel {
44
45
    private static final Logger LOG = LoggerFactory.getLogger(WizardOptionPanelAdapter.class);
46
47
    private final ExportPanel exportPanel;
48 44044 jjdelcerro
    private final DefaultJExportProcessPanel processPanel;
49 43925 jjdelcerro
50 44044 jjdelcerro
    public WizardOptionPanelAdapter(DefaultJExportProcessPanel processPanel, ExportPanel exportPanel) {
51 43925 jjdelcerro
        super();
52
        this.exportPanel = exportPanel;
53 44044 jjdelcerro
        this.processPanel= processPanel;
54 43925 jjdelcerro
    }
55 44044 jjdelcerro
56 43925 jjdelcerro
    @Override
57
    public String getPanelTitle() {
58
        return exportPanel.getTitlePanel();
59
    }
60
61
    @Override
62
    public void nextPanel() throws NotContinueWizardException {
63
        I18nManager i18n = ToolsLocator.getI18nManager();
64
        boolean valid;
65
        try {
66
            valid = this.exportPanel.validatePanel();
67
        } catch (ExportPanelValidationException ex) {
68
            LOG.info("Export form, invalid values.", ex);
69
            throw new NotContinueWizardException(
70
                    i18n.getTranslation("_Invalid_values_in_form"),
71
                    ex,
72
                    exportPanel.asJComponent()
73
            );
74
        }
75
        if( !valid ) {
76
            throw new NotContinueWizardException(
77
                    i18n.getTranslation("_Invalid_values_in_form"),
78
                    exportPanel.asJComponent(),
79
                    true
80
            );
81
        }
82
        try {
83 44044 jjdelcerro
            this.processPanel.setLastAcction(JExportProcessPanel.BUTTON_NEXT);
84 43968 jjdelcerro
            this.exportPanel.nextPanel();
85 43925 jjdelcerro
        } catch (Exception ex) {
86 44314 jjdelcerro
            LOG.warn("Fail the call to nextPanel.", ex);
87 43925 jjdelcerro
            MessagePanel.showMessage(
88
                    i18n.getTranslation("_Warning"),
89
                    i18n.getTranslation("_There_have_been_problems_retrieving_panel_data") +
90
                            " (" + this.exportPanel.getTitlePanel() +")" ,
91
                    ex,
92
                    null
93
            );
94
        }
95
    }
96
97
    @Override
98
    public void lastPanel() {
99 43968 jjdelcerro
        try {
100 44044 jjdelcerro
            this.processPanel.setLastAcction(JExportProcessPanel.BUTTON_BACK);
101 43968 jjdelcerro
            this.exportPanel.previousPanel();
102
        } catch (Exception ex) {
103
            LOG.warn("Fail the call to previousPanel.", ex);
104
            I18nManager i18nManager = ToolsLocator.getI18nManager();
105
            MessagePanel.showMessage(
106
                    i18nManager.getTranslation("_Warning"),
107
                    i18nManager.getTranslation("_There_have_been_problems_filling_data_in_panel") +
108
                            " (" + this.exportPanel.getTitlePanel() +")" ,
109
                    ex,
110
                    null
111
            );
112
        }
113 43925 jjdelcerro
    }
114
115
    @Override
116
    public void updatePanel() {
117
        try {
118
            this.exportPanel.enterPanel();
119
        } catch (Exception ex) {
120
            LOG.warn("Fail the call to enterPanel.", ex);
121
            I18nManager i18nManager = ToolsLocator.getI18nManager();
122
            MessagePanel.showMessage(
123
                    i18nManager.getTranslation("_Warning"),
124
                    i18nManager.getTranslation("_There_have_been_problems_filling_data_in_panel") +
125
                            " (" + this.exportPanel.getTitlePanel() +")" ,
126
                    ex,
127
                    null
128
            );
129
        }
130
    }
131
132
    @Override
133
    public JPanel getJPanel() {
134
        return (JPanel) exportPanel.asJComponent();
135
    }
136
137
}