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 @ 43968
History | View | Annotate | Download (3.97 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 |
|
52 |
private static final long serialVersionUID = -3278172717881233447L; |
53 |
|
54 |
private static final Logger LOG = LoggerFactory.getLogger(JDBCConnectionPanel.class); |
55 |
private org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionPanel connectionPanel;
|
56 |
private final ExportJDBCParameters parameters; |
57 |
private final JExportProcessPanel processPanel; |
58 |
|
59 |
public JDBCConnectionPanel(
|
60 |
JExportProcessPanel processPanel, |
61 |
ExportJDBCParameters parameters |
62 |
) { |
63 |
this.processPanel = processPanel;
|
64 |
this.parameters = parameters;
|
65 |
initComponents(); |
66 |
} |
67 |
|
68 |
private void initComponents() { |
69 |
DataSwingManager manager = DALSwingLocator.getSwingManager(); |
70 |
this.connectionPanel = manager.createJDBCConnectionPanel();
|
71 |
} |
72 |
|
73 |
@Override
|
74 |
public void previousPanel() { |
75 |
|
76 |
} |
77 |
|
78 |
@Override
|
79 |
public void enterPanel() { |
80 |
// Default do nothing
|
81 |
} |
82 |
|
83 |
public JDBCServerExplorerParameters getServerExplorerParameters() {
|
84 |
return this.connectionPanel.getServerExplorerParameters(); |
85 |
} |
86 |
|
87 |
@Override
|
88 |
public String getIdPanel() { |
89 |
return this.getClass().getCanonicalName(); |
90 |
} |
91 |
|
92 |
@Override
|
93 |
public String getTitlePanel() { |
94 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
95 |
return i18nManager.getTranslation("connection_params"); |
96 |
} |
97 |
|
98 |
@Override
|
99 |
public void nextPanel() { |
100 |
this.parameters.setExplorerParameters(this.getServerExplorerParameters()); |
101 |
} |
102 |
|
103 |
@Override
|
104 |
public boolean validatePanel() throws ExportPanelValidationException { |
105 |
DBServerExplorerParameters connection = this.connectionPanel.getServerExplorerParameters();
|
106 |
if( connection==null ) { |
107 |
return false; |
108 |
} |
109 |
try {
|
110 |
connection.validate(); |
111 |
this.parameters.setExplorerParameters(this.getServerExplorerParameters()); |
112 |
return true; |
113 |
} catch (ValidateDataParametersException ex) {
|
114 |
throw new ExportPanelValidationException(ex.getMessageStack(),ex); |
115 |
} catch(Exception ex) { |
116 |
return false; |
117 |
} |
118 |
} |
119 |
|
120 |
@Override
|
121 |
public JComponent asJComponent() { |
122 |
return this.connectionPanel.asJComponent(); |
123 |
} |
124 |
|
125 |
} |