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