svn-gvsig-desktop / tags / v2_0_0_Build_2050 / libraries / 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 @ 38688
History | View | Annotate | Download (3.87 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
package org.gvsig.exportto.swing.prov.jdbc.panel; |
23 |
|
24 |
import java.awt.BorderLayout; |
25 |
import java.util.ArrayList; |
26 |
import java.util.Iterator; |
27 |
import java.util.List; |
28 |
|
29 |
import org.slf4j.Logger; |
30 |
import org.slf4j.LoggerFactory; |
31 |
|
32 |
import org.gvsig.exportto.swing.ExporttoSwingLocator; |
33 |
import org.gvsig.exportto.swing.ExporttoSwingManager; |
34 |
import org.gvsig.exportto.swing.spi.ExporttoPanelValidationException; |
35 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel; |
36 |
import org.gvsig.fmap.dal.DALLocator; |
37 |
import org.gvsig.fmap.dal.DataManager; |
38 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
39 |
import org.gvsig.fmap.dal.exception.DataException; |
40 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
41 |
import org.gvsig.geodb.vectorialdb.ConnectionPanel; |
42 |
import org.gvsig.geodb.vectorialdb.ConnectionSettings; |
43 |
|
44 |
/**
|
45 |
* @author gvSIG Team
|
46 |
* @version $Id$
|
47 |
*
|
48 |
*/
|
49 |
public class JDBCConnectionPanel extends ExporttoSwingProviderPanel { |
50 |
|
51 |
private static final long serialVersionUID = -3278172717881233447L; |
52 |
|
53 |
private static final Logger LOG = LoggerFactory |
54 |
.getLogger(JDBCConnectionPanel.class); |
55 |
|
56 |
private static final DataManager DATA_MANAGER = DALLocator.getDataManager(); |
57 |
private static final ExporttoSwingManager EXPORTTO_SWING_MANAGER = |
58 |
ExporttoSwingLocator.getSwingManager(); |
59 |
|
60 |
private org.gvsig.geodb.vectorialdb.ConnectionPanel connectionPanel = null; |
61 |
|
62 |
public JDBCConnectionPanel() {
|
63 |
super();
|
64 |
initializeComponents(); |
65 |
} |
66 |
|
67 |
private void initializeComponents() { |
68 |
this.setLayout(new BorderLayout()); |
69 |
connectionPanel = new ConnectionPanel();
|
70 |
add(connectionPanel, BorderLayout.CENTER);
|
71 |
initialiceExplorers(); |
72 |
} |
73 |
|
74 |
@SuppressWarnings("rawtypes") |
75 |
private void initialiceExplorers() { |
76 |
List explorers = DATA_MANAGER.getExplorerProviders();
|
77 |
Iterator iter = explorers.iterator();
|
78 |
DataServerExplorerParameters exParam = null;
|
79 |
String name;
|
80 |
List<String> dbExplores = new ArrayList<String>(explorers.size()); |
81 |
while (iter.hasNext()) {
|
82 |
name = (String) iter.next();
|
83 |
try {
|
84 |
exParam = DATA_MANAGER.createServerExplorerParameters(name); |
85 |
} catch (DataException e) {
|
86 |
LOG.error("Error initilializing the explorer", e);
|
87 |
} |
88 |
if (exParam instanceof DBServerExplorerParameters) { |
89 |
dbExplores.add(name); |
90 |
} |
91 |
} |
92 |
|
93 |
connectionPanel.setDrivers(dbExplores.toArray(new String[dbExplores |
94 |
.size()])); |
95 |
} |
96 |
|
97 |
@Override
|
98 |
public String getPanelTitle() { |
99 |
return EXPORTTO_SWING_MANAGER.getTranslation("connection_params"); |
100 |
} |
101 |
|
102 |
@Override
|
103 |
public boolean isValidPanel() throws ExporttoPanelValidationException { |
104 |
// ConnectionSettings connectionSettings = getConnectionSettings();
|
105 |
// Check parameters...
|
106 |
return true; |
107 |
} |
108 |
|
109 |
public ConnectionSettings getConnectionSettings() {
|
110 |
return connectionPanel.getConnectionSettings();
|
111 |
} |
112 |
|
113 |
} |