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 @ 41488

History | View | Annotate | Download (3.11 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.exportto.swing.prov.jdbc.panel;
25

    
26
import javax.swing.JComponent;
27
import javax.swing.JPanel;
28
import org.gvsig.exportto.swing.prov.jdbc.ExporttoJDBCProvider;
29

    
30
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
32

    
33
import org.gvsig.exportto.swing.spi.ExporttoPanelValidationException;
34
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel;
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.tools.ToolsLocator;
39
import org.gvsig.tools.i18n.I18nManager;
40

    
41
/**
42
 * @author gvSIG Team
43
 * @version $Id$
44
 * 
45
 */
46
public class JDBCConnectionPanel extends JPanel implements ExporttoSwingProviderPanel {
47

    
48
    private static final long serialVersionUID = -3278172717881233447L;
49

    
50
    private static final Logger LOG = LoggerFactory.getLogger(JDBCConnectionPanel.class);
51
    private DBConnectionPanel connectionPanel = null;
52
    private final ExporttoJDBCProvider provider;
53

    
54

    
55
    public JDBCConnectionPanel(ExporttoJDBCProvider provider) {
56
        this.provider = provider;
57
        initComponents();
58
    }
59

    
60
    private void initComponents() {
61
        this.connectionPanel = new DBConnectionPanel();
62
    }
63
    
64
    public void enterPanel() {
65
        // Default do nothing
66
    }
67
    
68
    public JDBCServerExplorerParameters getServerExplorerParameters() {
69
        return this.connectionPanel.getServerExplorerParameters();
70
    }
71
    
72
    public String getPanelTitle() {
73
        I18nManager i18nManager = ToolsLocator.getI18nManager();
74
        return i18nManager.getTranslation("connection_params");
75
    }
76
    
77
    public boolean isValidPanel() throws ExporttoPanelValidationException {
78
        DBServerExplorerParameters connection = this.connectionPanel.getConnection();
79
        try {
80
            connection.validate();
81
            return true;
82
        } catch (ValidateDataParametersException ex) {
83
            throw new ExporttoPanelValidationException(ex.getMessageStack(),ex);
84
        } catch(Exception ex) {
85
            return false;
86
        }
87
    }
88

    
89
    public JComponent asJComponent() {
90
        return this.connectionPanel;
91
    }
92

    
93
}