svn-gvsig-desktop / branches / v2_0_0_prep / 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 / ConnectionPanel.java @ 34981
History | View | Annotate | Download (3.85 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.ConnectionSettings; |
42 |
|
43 |
|
44 |
/**
|
45 |
* @author gvSIG Team
|
46 |
* @version $Id$
|
47 |
*
|
48 |
*/
|
49 |
public class ConnectionPanel extends ExporttoSwingProviderPanel { |
50 |
private static final long serialVersionUID = -3278172717881233447L; |
51 |
|
52 |
private static final Logger LOG = |
53 |
LoggerFactory.getLogger(ConnectionPanel.class); |
54 |
|
55 |
private static final DataManager DATA_MANAGER = DALLocator.getDataManager(); |
56 |
private static final ExporttoSwingManager EXPORTTO_SWING_MANAGER = |
57 |
ExporttoSwingLocator.getSwingManager(); |
58 |
|
59 |
private org.gvsig.geodb.vectorialdb.ConnectionPanel connectionPanel = null; |
60 |
|
61 |
public ConnectionPanel() {
|
62 |
super();
|
63 |
initializeComponents(); |
64 |
} |
65 |
|
66 |
private void initializeComponents() { |
67 |
this.setLayout(new BorderLayout()); |
68 |
connectionPanel = new org.gvsig.geodb.vectorialdb.ConnectionPanel();
|
69 |
add(connectionPanel, BorderLayout.CENTER);
|
70 |
initialiceExplorers(); |
71 |
} |
72 |
|
73 |
@SuppressWarnings("rawtypes") |
74 |
private void initialiceExplorers(){ |
75 |
List explorers = DATA_MANAGER.getExplorerProviders();
|
76 |
Iterator iter = explorers.iterator();
|
77 |
DataServerExplorerParameters exParam = null;
|
78 |
String name;
|
79 |
List<String> dbExplores = new ArrayList<String>(explorers.size()); |
80 |
while (iter.hasNext()) {
|
81 |
name = (String) iter.next();
|
82 |
try {
|
83 |
exParam = DATA_MANAGER.createServerExplorerParameters(name); |
84 |
} catch (DataException e) {
|
85 |
LOG.error("Error initilializing the explorer", e);
|
86 |
} |
87 |
if (exParam instanceof DBServerExplorerParameters) { |
88 |
dbExplores.add(name); |
89 |
} |
90 |
} |
91 |
|
92 |
connectionPanel.setDrivers(dbExplores |
93 |
.toArray(new String[dbExplores.size()])); |
94 |
} |
95 |
|
96 |
@Override
|
97 |
public String getPanelTitle() { |
98 |
return EXPORTTO_SWING_MANAGER.getTranslation("connection_params"); |
99 |
} |
100 |
|
101 |
@Override
|
102 |
public boolean isValidPanel() throws ExporttoPanelValidationException { |
103 |
//ConnectionSettings connectionSettings = getConnectionSettings();
|
104 |
//Check parameters...
|
105 |
return true; |
106 |
} |
107 |
|
108 |
public ConnectionSettings getConnectionSettings(){
|
109 |
return connectionPanel.getConnectionSettings();
|
110 |
} |
111 |
|
112 |
} |