svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.prov / org.gvsig.exportto.swing.prov.jdbc / src / main / java / org / gvsig / export / jdbc / swing / panels / JDBCConnectionPanel.java @ 44418
History | View | Annotate | Download (4.09 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.export.jdbc.swing.panels; |
25 |
|
26 |
import javax.swing.JComponent; |
27 |
import org.gvsig.export.jdbc.service.ExportJDBCParameters; |
28 |
import org.gvsig.export.swing.JExportProcessPanel; |
29 |
import org.gvsig.export.swing.spi.ExportPanel; |
30 |
import org.gvsig.export.swing.spi.ExportPanelValidationException; |
31 |
|
32 |
import org.slf4j.Logger; |
33 |
import org.slf4j.LoggerFactory; |
34 |
|
35 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
36 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
37 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
38 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
39 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
40 |
import org.gvsig.tools.ToolsLocator; |
41 |
import org.gvsig.tools.i18n.I18nManager; |
42 |
|
43 |
/**
|
44 |
* @author gvSIG Team
|
45 |
* @version $Id$
|
46 |
*
|
47 |
*/
|
48 |
public class JDBCConnectionPanel |
49 |
implements ExportPanel {
|
50 |
|
51 |
private static final long serialVersionUID = -3278172717881233447L; |
52 |
|
53 |
private static final Logger LOG = LoggerFactory.getLogger(JDBCConnectionPanel.class); |
54 |
private org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionPanel connectionPanel;
|
55 |
private final ExportJDBCParameters parameters; |
56 |
private final JExportProcessPanel processPanel; |
57 |
|
58 |
public JDBCConnectionPanel(
|
59 |
JExportProcessPanel processPanel, |
60 |
ExportJDBCParameters parameters |
61 |
) { |
62 |
this.processPanel = processPanel;
|
63 |
this.parameters = parameters;
|
64 |
initComponents(); |
65 |
} |
66 |
|
67 |
private void initComponents() { |
68 |
DataSwingManager manager = DALSwingLocator.getSwingManager(); |
69 |
this.connectionPanel = manager.createJDBCConnectionPanel();
|
70 |
} |
71 |
|
72 |
@Override
|
73 |
public void previousPanel() { |
74 |
|
75 |
} |
76 |
|
77 |
@Override
|
78 |
public void enterPanel() { |
79 |
if (this.parameters.getExplorerParameters() != null) { |
80 |
this.connectionPanel.setServerExplorerParameters(this.parameters.getExplorerParameters()); |
81 |
} |
82 |
} |
83 |
|
84 |
public JDBCServerExplorerParameters getServerExplorerParameters() {
|
85 |
return this.connectionPanel.getServerExplorerParameters(); |
86 |
} |
87 |
|
88 |
@Override
|
89 |
public String getIdPanel() { |
90 |
return this.getClass().getCanonicalName(); |
91 |
} |
92 |
|
93 |
@Override
|
94 |
public String getTitlePanel() { |
95 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
96 |
return i18nManager.getTranslation("connection_params"); |
97 |
} |
98 |
|
99 |
@Override
|
100 |
public void nextPanel() { |
101 |
this.parameters.setExplorerParameters(this.getServerExplorerParameters()); |
102 |
} |
103 |
|
104 |
@Override
|
105 |
public boolean validatePanel() throws ExportPanelValidationException { |
106 |
DBServerExplorerParameters connection = this.connectionPanel.getServerExplorerParameters();
|
107 |
if (connection == null) { |
108 |
return false; |
109 |
} |
110 |
try {
|
111 |
connection.validate(); |
112 |
this.parameters.setExplorerParameters(this.getServerExplorerParameters()); |
113 |
return true; |
114 |
} catch (ValidateDataParametersException ex) {
|
115 |
throw new ExportPanelValidationException(ex.getMessageStack(), ex); |
116 |
} catch (Exception ex) { |
117 |
return false; |
118 |
} |
119 |
} |
120 |
|
121 |
@Override
|
122 |
public JComponent asJComponent() { |
123 |
return this.connectionPanel.asJComponent(); |
124 |
} |
125 |
|
126 |
} |