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 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40559 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * 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 | 40559 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | 43925 | jjdelcerro | package org.gvsig.export.jdbc.swing.panels; |
25 | 40435 | jjdelcerro | |
26 | 41486 | jjdelcerro | import javax.swing.JComponent; |
27 | 43925 | jjdelcerro | 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 | 40435 | jjdelcerro | |
32 | import org.slf4j.Logger; |
||
33 | import org.slf4j.LoggerFactory; |
||
34 | |||
35 | 41486 | jjdelcerro | import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
36 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
37 | 41486 | jjdelcerro | import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
38 | 43020 | jjdelcerro | import org.gvsig.fmap.dal.swing.DALSwingLocator; |
39 | import org.gvsig.fmap.dal.swing.DataSwingManager; |
||
40 | 41486 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
41 | import org.gvsig.tools.i18n.I18nManager; |
||
42 | 40435 | jjdelcerro | |
43 | /**
|
||
44 | * @author gvSIG Team
|
||
45 | * @version $Id$
|
||
46 | *
|
||
47 | */
|
||
48 | 43925 | jjdelcerro | public class JDBCConnectionPanel |
49 | implements ExportPanel
|
||
50 | { |
||
51 | 40435 | jjdelcerro | |
52 | private static final long serialVersionUID = -3278172717881233447L; |
||
53 | |||
54 | 41486 | jjdelcerro | private static final Logger LOG = LoggerFactory.getLogger(JDBCConnectionPanel.class); |
55 | 43020 | jjdelcerro | private org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionPanel connectionPanel;
|
56 | 43925 | jjdelcerro | private final ExportJDBCParameters parameters; |
57 | private final JExportProcessPanel processPanel; |
||
58 | 40435 | jjdelcerro | |
59 | 43925 | jjdelcerro | public JDBCConnectionPanel(
|
60 | JExportProcessPanel processPanel, |
||
61 | ExportJDBCParameters parameters |
||
62 | ) { |
||
63 | this.processPanel = processPanel;
|
||
64 | this.parameters = parameters;
|
||
65 | 41486 | jjdelcerro | initComponents(); |
66 | 40435 | jjdelcerro | } |
67 | |||
68 | 41486 | jjdelcerro | private void initComponents() { |
69 | 43020 | jjdelcerro | DataSwingManager manager = DALSwingLocator.getSwingManager(); |
70 | this.connectionPanel = manager.createJDBCConnectionPanel();
|
||
71 | 40435 | jjdelcerro | } |
72 | 41488 | jjdelcerro | |
73 | 43020 | jjdelcerro | @Override
|
74 | 43968 | jjdelcerro | public void previousPanel() { |
75 | |||
76 | } |
||
77 | |||
78 | @Override
|
||
79 | 41488 | jjdelcerro | public void enterPanel() { |
80 | // Default do nothing
|
||
81 | } |
||
82 | |||
83 | 41486 | jjdelcerro | public JDBCServerExplorerParameters getServerExplorerParameters() {
|
84 | return this.connectionPanel.getServerExplorerParameters(); |
||
85 | 40435 | jjdelcerro | } |
86 | 43925 | jjdelcerro | |
87 | 43020 | jjdelcerro | @Override
|
88 | 43925 | jjdelcerro | public String getIdPanel() { |
89 | return this.getClass().getCanonicalName(); |
||
90 | } |
||
91 | |||
92 | @Override
|
||
93 | public String getTitlePanel() { |
||
94 | 41486 | jjdelcerro | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
95 | return i18nManager.getTranslation("connection_params"); |
||
96 | 40435 | jjdelcerro | } |
97 | 43925 | jjdelcerro | |
98 | 43020 | jjdelcerro | @Override
|
99 | 43968 | jjdelcerro | public void nextPanel() { |
100 | 43925 | jjdelcerro | this.parameters.setExplorerParameters(this.getServerExplorerParameters()); |
101 | } |
||
102 | |||
103 | @Override
|
||
104 | public boolean validatePanel() throws ExportPanelValidationException { |
||
105 | 41632 | jjdelcerro | DBServerExplorerParameters connection = this.connectionPanel.getServerExplorerParameters();
|
106 | 43355 | jjdelcerro | if( connection==null ) { |
107 | return false; |
||
108 | } |
||
109 | 41486 | jjdelcerro | try {
|
110 | connection.validate(); |
||
111 | 43925 | jjdelcerro | this.parameters.setExplorerParameters(this.getServerExplorerParameters()); |
112 | 41486 | jjdelcerro | return true; |
113 | } catch (ValidateDataParametersException ex) {
|
||
114 | 43925 | jjdelcerro | throw new ExportPanelValidationException(ex.getMessageStack(),ex); |
115 | 41486 | jjdelcerro | } catch(Exception ex) { |
116 | return false; |
||
117 | } |
||
118 | 40435 | jjdelcerro | } |
119 | |||
120 | 43020 | jjdelcerro | @Override
|
121 | 41486 | jjdelcerro | public JComponent asJComponent() { |
122 | 43020 | jjdelcerro | return this.connectionPanel.asJComponent(); |
123 | 40435 | jjdelcerro | } |
124 | |||
125 | } |