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

History | View | Annotate | Download (3.35 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 org.gvsig.exportto.swing.prov.jdbc.ExporttoJDBCOptions;
28

    
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
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
35
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters;
36
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
37
import org.gvsig.fmap.dal.swing.DALSwingLocator;
38
import org.gvsig.fmap.dal.swing.DataSwingManager;
39
import org.gvsig.tools.ToolsLocator;
40
import org.gvsig.tools.i18n.I18nManager;
41

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

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

    
51
    private static final Logger LOG = LoggerFactory.getLogger(JDBCConnectionPanel.class);
52
    private org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionPanel connectionPanel;
53
    private final ExporttoJDBCOptions provider;
54

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

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

    
93
    @Override
94
    public JComponent asJComponent() {
95
        return this.connectionPanel.asJComponent();
96
    }
97

    
98
}