Statistics
| Revision:

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 / exportto / swing / prov / jdbc / panel / JDBCConnectionPanel.java @ 43355

History | View | Annotate | Download (3.42 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
package org.gvsig.exportto.swing.prov.jdbc.panel;
25
26 41486 jjdelcerro
import javax.swing.JComponent;
27 41598 jjdelcerro
import org.gvsig.exportto.swing.prov.jdbc.ExporttoJDBCOptions;
28 40435 jjdelcerro
29
import org.slf4j.Logger;
30
import org.slf4j.LoggerFactory;
31
32
import org.gvsig.exportto.swing.spi.ExporttoPanelValidationException;
33
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel;
34 41486 jjdelcerro
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
35 40435 jjdelcerro
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters;
36 41486 jjdelcerro
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
37 43020 jjdelcerro
import org.gvsig.fmap.dal.swing.DALSwingLocator;
38
import org.gvsig.fmap.dal.swing.DataSwingManager;
39 41486 jjdelcerro
import org.gvsig.tools.ToolsLocator;
40
import org.gvsig.tools.i18n.I18nManager;
41 40435 jjdelcerro
42
/**
43
 * @author gvSIG Team
44
 * @version $Id$
45
 *
46
 */
47 41632 jjdelcerro
public class JDBCConnectionPanel  implements ExporttoSwingProviderPanel {
48 40435 jjdelcerro
49
    private static final long serialVersionUID = -3278172717881233447L;
50
51 41486 jjdelcerro
    private static final Logger LOG = LoggerFactory.getLogger(JDBCConnectionPanel.class);
52 43020 jjdelcerro
    private org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionPanel connectionPanel;
53 41598 jjdelcerro
    private final ExporttoJDBCOptions provider;
54 40435 jjdelcerro
55 41598 jjdelcerro
    public JDBCConnectionPanel(ExporttoJDBCOptions provider) {
56 41486 jjdelcerro
        this.provider = provider;
57
        initComponents();
58 40435 jjdelcerro
    }
59
60 41486 jjdelcerro
    private void initComponents() {
61 43020 jjdelcerro
        DataSwingManager manager = DALSwingLocator.getSwingManager();
62
        this.connectionPanel = manager.createJDBCConnectionPanel();
63 40435 jjdelcerro
    }
64 41488 jjdelcerro
65 43020 jjdelcerro
    @Override
66 41488 jjdelcerro
    public void enterPanel() {
67
        // Default do nothing
68
    }
69
70 41486 jjdelcerro
    public JDBCServerExplorerParameters getServerExplorerParameters() {
71
        return this.connectionPanel.getServerExplorerParameters();
72 40435 jjdelcerro
    }
73 41486 jjdelcerro
74 43020 jjdelcerro
    @Override
75 40435 jjdelcerro
    public String getPanelTitle() {
76 41486 jjdelcerro
        I18nManager i18nManager = ToolsLocator.getI18nManager();
77
        return i18nManager.getTranslation("connection_params");
78 40435 jjdelcerro
    }
79 41486 jjdelcerro
80 43020 jjdelcerro
    @Override
81 40435 jjdelcerro
    public boolean isValidPanel() throws ExporttoPanelValidationException {
82 41632 jjdelcerro
        DBServerExplorerParameters connection = this.connectionPanel.getServerExplorerParameters();
83 43355 jjdelcerro
        if( connection==null ) {
84
            return false;
85
        }
86 41486 jjdelcerro
        try {
87
            connection.validate();
88
            return true;
89
        } catch (ValidateDataParametersException ex) {
90
            throw new ExporttoPanelValidationException(ex.getMessageStack(),ex);
91
        } catch(Exception ex) {
92
            return false;
93
        }
94 40435 jjdelcerro
    }
95
96 43020 jjdelcerro
    @Override
97 41486 jjdelcerro
    public JComponent asJComponent() {
98 43020 jjdelcerro
        return this.connectionPanel.asJComponent();
99 40435 jjdelcerro
    }
100
101
}