Revision 11193
trunk/extensions/extSDE/src/com/iver/cit/gvsig/sde/SingleSDEConnectionExtension.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
package com.iver.cit.gvsig.sde; |
|
44 |
|
|
45 |
import java.sql.SQLException; |
|
46 |
import java.util.ArrayList; |
|
47 |
|
|
48 |
import javax.swing.JOptionPane; |
|
49 |
|
|
50 |
import org.apache.log4j.Logger; |
|
51 |
|
|
52 |
import com.iver.andami.PluginServices; |
|
53 |
import com.iver.andami.plugins.Extension; |
|
54 |
import com.iver.cit.gvsig.sde.gui.sdewizard2.ConnectionSettings; |
|
55 |
import com.iver.cit.gvsig.sde.gui.sdewizard2.ConnectionWithParamsSDE; |
|
56 |
import com.iver.cit.gvsig.sde.gui.sdewizard2.SDEConnectionManagerDialog; |
|
57 |
import com.iver.cit.gvsig.sde.gui.sdewizard2.SingleSDEConnectionManager; |
|
58 |
import com.iver.utiles.NotExistInXMLEntity; |
|
59 |
import com.iver.utiles.XMLEntity; |
|
60 |
|
|
61 |
|
|
62 |
/** |
|
63 |
* This extension allows the user to access the single connection manager dialog. |
|
64 |
* |
|
65 |
* @see com.iver.cit.gvsig.fmap.drivers.jdbc.utils.SingleJDBCConnectionManager |
|
66 |
* |
|
67 |
* @author jldominguez |
|
68 |
* |
|
69 |
*/ |
|
70 |
public class SingleSDEConnectionExtension extends Extension { |
|
71 |
private static Logger logger = Logger.getLogger(SingleSDEConnectionExtension.class.getName()); |
|
72 |
|
|
73 |
/** |
|
74 |
* This method simply loads the connections stored in gvSIG's persistence file |
|
75 |
* as closed connections |
|
76 |
*/ |
|
77 |
public void initialize() { |
|
78 |
loadPersistenceConnections(); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* The only command available is the one to open the connection manager |
|
83 |
* dialog ("GESTOR_SDE") |
|
84 |
*/ |
|
85 |
public void execute(String actionCommand) { |
|
86 |
if (actionCommand.compareToIgnoreCase("GESTOR_SDE") == 0) { |
|
87 |
SDEConnectionManagerDialog dlg = new SDEConnectionManagerDialog(); |
|
88 |
dlg.showDialog(); |
|
89 |
saveAllToPersistence(); |
|
90 |
|
|
91 |
return; |
|
92 |
} |
|
93 |
} |
|
94 |
public boolean isEnabled() { |
|
95 |
return true; |
|
96 |
} |
|
97 |
|
|
98 |
public boolean isVisible() { |
|
99 |
return true; |
|
100 |
} |
|
101 |
private void saveAllToPersistence() { |
|
102 |
XMLEntity xml = PluginServices.getPluginServices(this).getPersistentXML(); |
|
103 |
xml.remove("sde-connections"); |
|
104 |
|
|
105 |
ConnectionWithParamsSDE[] all = SingleSDEConnectionManager.instance() |
|
106 |
.getAllConnections(); |
|
107 |
|
|
108 |
if (all == null) { |
|
109 |
return; |
|
110 |
} |
|
111 |
|
|
112 |
for (int i = 0; i < all.length; i++) { |
|
113 |
addToPersistence(all[i]); |
|
114 |
} |
|
115 |
} |
|
116 |
|
|
117 |
|
|
118 |
private void addToPersistence(ConnectionWithParamsSDE cwp) { |
|
119 |
if (cwp == null) { |
|
120 |
return; |
|
121 |
} |
|
122 |
|
|
123 |
ConnectionSettings _cs = new ConnectionSettings(); |
|
124 |
|
|
125 |
_cs.setHost(cwp.getHost()); |
|
126 |
_cs.setPort(cwp.getPort()); |
|
127 |
_cs.setDb(cwp.getDb()); |
|
128 |
_cs.setDriver(cwp.getDrvName()); |
|
129 |
_cs.setUser(cwp.getUser()); |
|
130 |
_cs.setName(cwp.getName()); |
|
131 |
|
|
132 |
String newstr = _cs.toString(); |
|
133 |
|
|
134 |
XMLEntity xml = PluginServices.getPluginServices(this).getPersistentXML(); |
|
135 |
|
|
136 |
String[] old = null; |
|
137 |
|
|
138 |
if (xml.contains("sde-connections")) { |
|
139 |
old = xml.getStringArrayProperty("sde-connections"); |
|
140 |
} |
|
141 |
|
|
142 |
ArrayList oldl = stringArrayToArrayList(old); |
|
143 |
oldl.add(newstr); |
|
144 |
|
|
145 |
String[] newarr = (String[]) oldl.toArray(new String[0]); |
|
146 |
|
|
147 |
xml.remove("sde-connections"); |
|
148 |
xml.putProperty("sde-connections", newarr); |
|
149 |
PluginServices.getPluginServices(this).setPersistentXML(xml); |
|
150 |
} |
|
151 |
private ArrayList stringArrayToArrayList(String[] arr) { |
|
152 |
ArrayList resp = new ArrayList(); |
|
153 |
|
|
154 |
if ((arr != null) && (arr.length > 0)) { |
|
155 |
for (int i = 0; i < arr.length; i++) { |
|
156 |
resp.add(arr[i]); |
|
157 |
} |
|
158 |
} |
|
159 |
|
|
160 |
return resp; |
|
161 |
} |
|
162 |
|
|
163 |
private void loadPersistenceConnections() { |
|
164 |
XMLEntity xml = PluginServices.getPluginServices(this).getPersistentXML(); |
|
165 |
|
|
166 |
if (xml == null) { |
|
167 |
xml = new XMLEntity(); |
|
168 |
} |
|
169 |
|
|
170 |
if (!xml.contains("sde-connections")) { |
|
171 |
String[] servers = new String[0]; |
|
172 |
xml.putProperty("sde-connections", servers); |
|
173 |
} |
|
174 |
|
|
175 |
// add drivers to connection manager |
|
176 |
String[] servers = null; |
|
177 |
|
|
178 |
try { |
|
179 |
servers = xml.getStringArrayProperty("sde-connections"); |
|
180 |
} |
|
181 |
catch (NotExistInXMLEntity e) { |
|
182 |
System.err.println( |
|
183 |
"Error while getting projects sde-connections: " + |
|
184 |
e.getMessage()); |
|
185 |
|
|
186 |
return; |
|
187 |
} |
|
188 |
|
|
189 |
for (int i = 0; i < servers.length; i++) { |
|
190 |
ConnectionSettings cs = new ConnectionSettings(); |
|
191 |
boolean params_ok = true; |
|
192 |
try { |
|
193 |
cs.setFromString(servers[i]); |
|
194 |
} catch (Exception ex) { |
|
195 |
logger.error("Found misconfigured connection: " + servers[i]); |
|
196 |
params_ok = false; |
|
197 |
} |
|
198 |
if (params_ok) addDisconnected(cs); |
|
199 |
} |
|
200 |
} |
|
201 |
|
|
202 |
|
|
203 |
private void addDisconnected(ConnectionSettings _cs) { |
|
204 |
try { |
|
205 |
SingleSDEConnectionManager.instance() |
|
206 |
.getConnection(_cs.getDriver(), |
|
207 |
_cs.getUser(), null, _cs.getName(), _cs.getHost(), |
|
208 |
_cs.getPort(), _cs.getDb(), false); |
|
209 |
} |
|
210 |
catch (SQLException e) { |
|
211 |
System.err.println("While getting connection: " + e.getMessage()); |
|
212 |
showConnectionErrorMessage(e.getMessage()); |
|
213 |
} |
|
214 |
} |
|
215 |
|
|
216 |
private void showConnectionErrorMessage(String _msg) { |
|
217 |
String msg = (_msg.length() > 300) ? "" : (": " + _msg); |
|
218 |
String title = PluginServices.getText(this, "connection_error"); |
|
219 |
JOptionPane.showMessageDialog(null, title + msg, title, |
|
220 |
JOptionPane.ERROR_MESSAGE); |
|
221 |
} |
|
222 |
|
|
223 |
|
|
224 |
public void terminate() { |
|
225 |
SingleSDEConnectionManager.instance().closeAllBeforeTerminate(); |
|
226 |
} |
|
227 |
|
|
228 |
} |
|
0 | 229 |
trunk/extensions/extSDE/src/com/iver/cit/gvsig/sde/ExtSDE.java | ||
---|---|---|
2 | 2 |
* Created on 22-jun-2005 |
3 | 3 |
* |
4 | 4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
7 |
*
|
|
7 |
* |
|
8 | 8 |
* This program is free software; you can redistribute it and/or |
9 | 9 |
* modify it under the terms of the GNU General Public License |
10 | 10 |
* as published by the Free Software Foundation; either version 2 |
11 | 11 |
* of the License, or (at your option) any later version. |
12 |
*
|
|
12 |
* |
|
13 | 13 |
* This program is distributed in the hope that it will be useful, |
14 | 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | 16 |
* GNU General Public License for more details. |
17 |
*
|
|
17 |
* |
|
18 | 18 |
* You should have received a copy of the GNU General Public License |
19 | 19 |
* along with this program; if not, write to the Free Software |
20 | 20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 |
*
|
|
21 |
* |
|
22 | 22 |
* For more information, contact: |
23 | 23 |
* |
24 | 24 |
* Generalitat Valenciana |
... | ... | |
30 | 30 |
* +34 963862235 |
31 | 31 |
* gvsig@gva.es |
32 | 32 |
* www.gvsig.gva.es |
33 |
*
|
|
33 |
* |
|
34 | 34 |
* or |
35 |
*
|
|
35 |
* |
|
36 | 36 |
* IVER T.I. S.A |
37 | 37 |
* Salamanca 50 |
38 | 38 |
* 46005 Valencia |
39 | 39 |
* Spain |
40 |
*
|
|
40 |
* |
|
41 | 41 |
* +34 963163400 |
42 | 42 |
* dac@iver.es |
43 | 43 |
*/ |
... | ... | |
45 | 45 |
|
46 | 46 |
import com.iver.andami.plugins.Extension; |
47 | 47 |
import com.iver.cit.gvsig.AddLayer; |
48 |
import com.iver.cit.gvsig.sde.gui.sdewizard.WizardSDE; |
|
49 | 48 |
|
50 |
public class ExtSDE implements Extension { |
|
51 | 49 |
|
52 |
public void inicializar() {
|
|
53 |
System.out.println("A?ado Wizard SDE.");
|
|
54 |
AddLayer.addWizard(WizardSDE.class);
|
|
55 |
|
|
56 |
}
|
|
57 |
|
|
50 |
/**
|
|
51 |
* SDE Extension.
|
|
52 |
*
|
|
53 |
* @author Vicente Caballero Navarro |
|
54 |
*/
|
|
55 |
public class ExtSDE extends Extension { |
|
58 | 56 |
public void execute(String actionCommand) { |
59 |
// TODO Auto-generated method stub |
|
60 |
|
|
61 | 57 |
} |
62 | 58 |
|
63 | 59 |
public boolean isEnabled() { |
64 |
// TODO Auto-generated method stub |
|
65 | 60 |
return false; |
66 | 61 |
} |
67 | 62 |
|
68 | 63 |
public boolean isVisible() { |
69 |
// TODO Auto-generated method stub |
|
70 | 64 |
return false; |
71 | 65 |
} |
72 | 66 |
|
67 |
public void initialize() { |
|
68 |
System.out.println("A?ado Wizard SDE."); |
|
69 |
AddLayer.addWizard(com.iver.cit.gvsig.sde.gui.sdewizard2.WizardSDE.class); |
|
70 |
} |
|
73 | 71 |
} |
trunk/extensions/extSDE/src/com/iver/cit/gvsig/sde/gui/sdewizard2/AvailableTablesCheckBoxList.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
package com.iver.cit.gvsig.sde.gui.sdewizard2; |
|
44 |
|
|
45 |
import java.awt.Component; |
|
46 |
import java.awt.event.MouseAdapter; |
|
47 |
import java.awt.event.MouseEvent; |
|
48 |
|
|
49 |
import javax.swing.JList; |
|
50 |
import javax.swing.JOptionPane; |
|
51 |
import javax.swing.ListCellRenderer; |
|
52 |
import javax.swing.ListSelectionModel; |
|
53 |
import javax.swing.UIManager; |
|
54 |
import javax.swing.border.Border; |
|
55 |
import javax.swing.border.EmptyBorder; |
|
56 |
|
|
57 |
import org.apache.log4j.Logger; |
|
58 |
|
|
59 |
import com.iver.andami.PluginServices; |
|
60 |
|
|
61 |
|
|
62 |
/** |
|
63 |
* Utility class to keep the list of available tables. |
|
64 |
* |
|
65 |
* @author jldominguez |
|
66 |
* |
|
67 |
*/ |
|
68 |
public class AvailableTablesCheckBoxList extends JList { |
|
69 |
protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1); |
|
70 |
private static Logger logger = Logger.getLogger(AvailableTablesCheckBoxList.class.getName()); |
|
71 |
private WizardSDE parent = null; |
|
72 |
private TablesListItem actingTable = null; |
|
73 |
|
|
74 |
public AvailableTablesCheckBoxList(WizardSDE p) { |
|
75 |
parent = p; |
|
76 |
|
|
77 |
setCellRenderer(new CellRenderer()); |
|
78 |
|
|
79 |
addMouseListener(new MouseAdapter() { |
|
80 |
public void mousePressed(MouseEvent e) { |
|
81 |
int index = locationToIndex(e.getPoint()); |
|
82 |
|
|
83 |
if (index == -1) { |
|
84 |
return; |
|
85 |
} |
|
86 |
|
|
87 |
actingTable = (TablesListItem) getModel().getElementAt(index); |
|
88 |
|
|
89 |
if ((e.getClickCount() == 2) || (e.getX() < 15)) { |
|
90 |
if (!actingTable.isActivated()) { |
|
91 |
actingTable.activate(); |
|
92 |
} |
|
93 |
|
|
94 |
actingTable.setSelected(!actingTable.isSelected()); |
|
95 |
|
|
96 |
if (actingTable.isSelected()) { |
|
97 |
actingTable.setEnabledPanels(true); |
|
98 |
} |
|
99 |
else { |
|
100 |
actingTable.setEnabledPanels(false); |
|
101 |
} |
|
102 |
|
|
103 |
repaint(); |
|
104 |
} |
|
105 |
|
|
106 |
try { |
|
107 |
parent.setSettingsPanels(actingTable); |
|
108 |
parent.checkFinishable(); |
|
109 |
} |
|
110 |
catch (Exception e1) { |
|
111 |
actingTable.setEnabledPanels(false); |
|
112 |
actingTable.setSelected(false); |
|
113 |
logger.error("While setting selected table: " + |
|
114 |
e1.getMessage(), e1); |
|
115 |
showConnectionErrorMessage(e1.getMessage()); |
|
116 |
} |
|
117 |
} |
|
118 |
}); |
|
119 |
|
|
120 |
setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
121 |
} |
|
122 |
|
|
123 |
private void showConnectionErrorMessage(String _msg) { |
|
124 |
String msg = (_msg.length() > 300) ? "" : (": " + _msg); |
|
125 |
String title = PluginServices.getText(this, "connection_error"); |
|
126 |
JOptionPane.showMessageDialog(this, title + msg, title, |
|
127 |
JOptionPane.ERROR_MESSAGE); |
|
128 |
} |
|
129 |
|
|
130 |
protected class CellRenderer implements ListCellRenderer { |
|
131 |
public Component getListCellRendererComponent(JList list, Object value, |
|
132 |
int index, boolean isSelected, boolean cellHasFocus) { |
|
133 |
TablesListItem checkbox = (TablesListItem) value; |
|
134 |
checkbox.setBackground(isSelected ? getSelectionBackground() |
|
135 |
: getBackground()); |
|
136 |
checkbox.setForeground(isSelected ? getSelectionForeground() |
|
137 |
: getForeground()); |
|
138 |
checkbox.setEnabled(isEnabled()); |
|
139 |
checkbox.setFont(getFont()); |
|
140 |
checkbox.setFocusPainted(false); |
|
141 |
checkbox.setBorderPainted(true); |
|
142 |
checkbox.setBorder(isSelected |
|
143 |
? UIManager.getBorder("List.focusCellHighlightBorder") |
|
144 |
: noFocusBorder); |
|
145 |
|
|
146 |
return checkbox; |
|
147 |
} |
|
148 |
} |
|
149 |
} |
|
0 | 150 |
trunk/extensions/extSDE/src/com/iver/cit/gvsig/sde/gui/sdewizard2/SDEConnectionParamsDialog.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
package com.iver.cit.gvsig.sde.gui.sdewizard2; |
|
44 |
|
|
45 |
import java.awt.Color; |
|
46 |
import java.awt.event.ActionEvent; |
|
47 |
import java.awt.event.ActionListener; |
|
48 |
import java.awt.event.KeyEvent; |
|
49 |
import java.awt.event.KeyListener; |
|
50 |
import java.util.ArrayList; |
|
51 |
|
|
52 |
import javax.swing.JButton; |
|
53 |
import javax.swing.JCheckBox; |
|
54 |
import javax.swing.JComboBox; |
|
55 |
import javax.swing.JLabel; |
|
56 |
import javax.swing.JPanel; |
|
57 |
import javax.swing.JPasswordField; |
|
58 |
import javax.swing.JTextField; |
|
59 |
|
|
60 |
import org.apache.log4j.Logger; |
|
61 |
|
|
62 |
import com.hardcode.driverManager.DriverLoadException; |
|
63 |
import com.iver.andami.PluginServices; |
|
64 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
65 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
66 |
import com.iver.cit.gvsig.fmap.drivers.sde.VectorialSDEDriver; |
|
67 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
|
68 |
|
|
69 |
|
|
70 |
/** |
|
71 |
* Lets the user input the connection parameters. |
|
72 |
* |
|
73 |
* @author jldominguez |
|
74 |
* |
|
75 |
*/ |
|
76 |
public class SDEConnectionParamsDialog extends JPanel implements IWindow, |
|
77 |
ActionListener, KeyListener { |
|
78 |
private static Logger logger = Logger.getLogger(SDEConnectionParamsDialog.class.getName()); |
|
79 |
private WindowInfo winfo = new WindowInfo(8); // MODAL only |
|
80 |
private JButton cancelButton = null; |
|
81 |
private JButton okButton = null; |
|
82 |
private JPanel paramsPanel = null; |
|
83 |
private JComboBox driverComboBox = null; |
|
84 |
private JTextField portTextField = null; |
|
85 |
private JTextField dbTextField = null; |
|
86 |
private JTextField userTextField = null; |
|
87 |
private JPasswordField passwordField = null; |
|
88 |
private JLabel driverLabel = null; |
|
89 |
private JLabel portLabel = null; |
|
90 |
private JLabel dbLabel = null; |
|
91 |
private JLabel userLabel = null; |
|
92 |
private JLabel pwLabel = null; |
|
93 |
private boolean okPressed = false; |
|
94 |
private JTextField urlTextField = null; |
|
95 |
private JLabel urlLabel = null; |
|
96 |
private JCheckBox connectedCheckBox = null; |
|
97 |
private JLabel connectedLabel = null; |
|
98 |
private JLabel connNameLabel = null; |
|
99 |
private JTextField connNameTextField = null; |
|
100 |
|
|
101 |
/** |
|
102 |
* This method initializes |
|
103 |
* |
|
104 |
*/ |
|
105 |
public SDEConnectionParamsDialog() { |
|
106 |
super(); |
|
107 |
initialize(); |
|
108 |
} |
|
109 |
|
|
110 |
public void showDialog() { |
|
111 |
PluginServices.getMDIManager().addWindow(this); |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* This method initializes this |
|
116 |
* |
|
117 |
*/ |
|
118 |
private void initialize() { |
|
119 |
winfo.setWidth(370); |
|
120 |
winfo.setHeight(275 - 25); |
|
121 |
winfo.setTitle(PluginServices.getText(this, "connection_parameters")); |
|
122 |
|
|
123 |
this.setSize(new java.awt.Dimension(360, 287)); |
|
124 |
this.setLayout(null); |
|
125 |
this.add(getCancelButton(), null); |
|
126 |
this.add(getOkButton(), null); |
|
127 |
this.add(getParamsPanel(), null); |
|
128 |
} |
|
129 |
|
|
130 |
public WindowInfo getWindowInfo() { |
|
131 |
return winfo; |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* This method initializes cancelButton |
|
136 |
* |
|
137 |
* @return javax.swing.JButton |
|
138 |
*/ |
|
139 |
private JButton getCancelButton() { |
|
140 |
if (cancelButton == null) { |
|
141 |
cancelButton = new JButton(); |
|
142 |
cancelButton.setText(PluginServices.getText(this, "cancel")); |
|
143 |
cancelButton.addActionListener(this); |
|
144 |
cancelButton.setBounds(new java.awt.Rectangle(185, 250, 106, 26)); |
|
145 |
} |
|
146 |
|
|
147 |
return cancelButton; |
|
148 |
} |
|
149 |
|
|
150 |
/** |
|
151 |
* This method initializes okButton |
|
152 |
* |
|
153 |
* @return javax.swing.JButton |
|
154 |
*/ |
|
155 |
private JButton getOkButton() { |
|
156 |
if (okButton == null) { |
|
157 |
okButton = new JButton(); |
|
158 |
okButton.setText(PluginServices.getText(this, "ok")); |
|
159 |
okButton.addActionListener(this); |
|
160 |
okButton.setBounds(new java.awt.Rectangle(70, 250, 106, 26)); |
|
161 |
} |
|
162 |
|
|
163 |
return okButton; |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* This method initializes paramsPanel |
|
168 |
* |
|
169 |
* @return javax.swing.JPanel |
|
170 |
*/ |
|
171 |
private JPanel getParamsPanel() { |
|
172 |
if (paramsPanel == null) { |
|
173 |
connNameLabel = new JLabel(); |
|
174 |
connNameLabel.setBounds(new java.awt.Rectangle(10, 30, 141, 21)); |
|
175 |
connNameLabel.setText(PluginServices.getText(this, "connection_name") + |
|
176 |
":"); |
|
177 |
connectedLabel = new JLabel(); |
|
178 |
connectedLabel.setBounds(new java.awt.Rectangle(10, 205, 141, 21)); |
|
179 |
connectedLabel.setText(PluginServices.getText(this, "connected") + |
|
180 |
":"); |
|
181 |
urlLabel = new JLabel(); |
|
182 |
urlLabel.setBounds(new java.awt.Rectangle(10, 80, 141, 21)); |
|
183 |
urlLabel.setText(PluginServices.getText(this, "server_url") + ":"); |
|
184 |
pwLabel = new JLabel(); |
|
185 |
pwLabel.setBounds(new java.awt.Rectangle(10, 180, 141, 21)); |
|
186 |
pwLabel.setText(PluginServices.getText(this, "password") + ":"); |
|
187 |
userLabel = new JLabel(); |
|
188 |
userLabel.setBounds(new java.awt.Rectangle(10, 155, 141, 21)); |
|
189 |
userLabel.setText(PluginServices.getText(this, "user") + ":"); |
|
190 |
dbLabel = new JLabel(); |
|
191 |
dbLabel.setBounds(new java.awt.Rectangle(10, 130, 141, 21)); |
|
192 |
dbLabel.setText(PluginServices.getText(this, "database_name") + |
|
193 |
":"); |
|
194 |
portLabel = new JLabel(); |
|
195 |
portLabel.setBounds(new java.awt.Rectangle(10, 105, 141, 21)); |
|
196 |
portLabel.setText(PluginServices.getText(this, "port") + ":"); |
|
197 |
driverLabel = new JLabel(); |
|
198 |
driverLabel.setBounds(new java.awt.Rectangle(10, 55, 141, 21)); |
|
199 |
driverLabel.setText(PluginServices.getText(this, "driver") + ":"); |
|
200 |
paramsPanel = new JPanel(); |
|
201 |
paramsPanel.setBounds(new java.awt.Rectangle(10, 10, 336, 231)); |
|
202 |
paramsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
|
203 |
null, PluginServices.getText(this, "connection_params"), |
|
204 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
|
205 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
206 |
paramsPanel.setLayout(null); |
|
207 |
paramsPanel.add(getPortTextField(), null); |
|
208 |
paramsPanel.add(getDriverComboBox(), null); |
|
209 |
paramsPanel.add(getDbTextField(), null); |
|
210 |
paramsPanel.add(getUserTextField(), null); |
|
211 |
paramsPanel.add(getPasswordField(), null); |
|
212 |
paramsPanel.add(driverLabel, null); |
|
213 |
paramsPanel.add(portLabel, null); |
|
214 |
paramsPanel.add(dbLabel, null); |
|
215 |
paramsPanel.add(userLabel, null); |
|
216 |
paramsPanel.add(pwLabel, null); |
|
217 |
paramsPanel.add(getUrlTextArea(), null); |
|
218 |
paramsPanel.add(urlLabel, null); |
|
219 |
paramsPanel.add(getConnectedCheckBox(), null); |
|
220 |
paramsPanel.add(connectedLabel, null); |
|
221 |
paramsPanel.add(connNameLabel, null); |
|
222 |
paramsPanel.add(getConnNameTextField(), null); |
|
223 |
} |
|
224 |
|
|
225 |
return paramsPanel; |
|
226 |
} |
|
227 |
|
|
228 |
/** |
|
229 |
* This method initializes driverComboBox |
|
230 |
* |
|
231 |
* @return javax.swing.JComboBox |
|
232 |
*/ |
|
233 |
private JComboBox getDriverComboBox() { |
|
234 |
if (driverComboBox == null) { |
|
235 |
driverComboBox = new JComboBox(); |
|
236 |
driverComboBox.addActionListener(this); |
|
237 |
|
|
238 |
String[] drvName = getDriverNames(); |
|
239 |
|
|
240 |
for (int i = 0; i < drvName.length; i++) |
|
241 |
driverComboBox.addItem(drvName[i]); |
|
242 |
|
|
243 |
driverComboBox.setBounds(new java.awt.Rectangle(155, 55, 166, 21)); |
|
244 |
} |
|
245 |
|
|
246 |
return driverComboBox; |
|
247 |
} |
|
248 |
|
|
249 |
/** |
|
250 |
* This method initializes portTextField |
|
251 |
* |
|
252 |
* @return javax.swing.JTextField |
|
253 |
*/ |
|
254 |
private JTextField getPortTextField() { |
|
255 |
if (portTextField == null) { |
|
256 |
portTextField = new JTextField(); |
|
257 |
portTextField.addKeyListener(this); |
|
258 |
portTextField.setBounds(new java.awt.Rectangle(155, 105, 166, 21)); |
|
259 |
} |
|
260 |
|
|
261 |
return portTextField; |
|
262 |
} |
|
263 |
|
|
264 |
/** |
|
265 |
* This method initializes dbTextField |
|
266 |
* |
|
267 |
* @return javax.swing.JTextField |
|
268 |
*/ |
|
269 |
private JTextField getDbTextField() { |
|
270 |
if (dbTextField == null) { |
|
271 |
dbTextField = new JTextField(); |
|
272 |
dbTextField.addKeyListener(this); |
|
273 |
dbTextField.setBounds(new java.awt.Rectangle(155, 130, 166, 21)); |
|
274 |
} |
|
275 |
|
|
276 |
return dbTextField; |
|
277 |
} |
|
278 |
|
|
279 |
/** |
|
280 |
* This method initializes userTextField |
|
281 |
* |
|
282 |
* @return javax.swing.JTextField |
|
283 |
*/ |
|
284 |
private JTextField getUserTextField() { |
|
285 |
if (userTextField == null) { |
|
286 |
userTextField = new JTextField(); |
|
287 |
userTextField.addKeyListener(this); |
|
288 |
userTextField.setBounds(new java.awt.Rectangle(155, 155, 166, 21)); |
|
289 |
} |
|
290 |
|
|
291 |
return userTextField; |
|
292 |
} |
|
293 |
|
|
294 |
/** |
|
295 |
* This method initializes passwordField |
|
296 |
* |
|
297 |
* @return javax.swing.JPasswordField |
|
298 |
*/ |
|
299 |
private JPasswordField getPasswordField() { |
|
300 |
if (passwordField == null) { |
|
301 |
passwordField = new JPasswordField(); |
|
302 |
passwordField.addKeyListener(this); |
|
303 |
passwordField.setBounds(new java.awt.Rectangle(155, 180, 166, 21)); |
|
304 |
} |
|
305 |
|
|
306 |
return passwordField; |
|
307 |
} |
|
308 |
|
|
309 |
private String[] getDriverNames() { |
|
310 |
Class[] classes = new Class[] { VectorialSDEDriver.class }; |
|
311 |
|
|
312 |
ArrayList ret = new ArrayList(); |
|
313 |
String[] driverNames = LayerFactory.getDM().getDriverNames(); |
|
314 |
|
|
315 |
for (int i = 0; i < driverNames.length; i++) { |
|
316 |
for (int j = 0; j < classes.length; j++) { |
|
317 |
if (LayerFactory.getDM().isA(driverNames[i], classes[j])) { |
|
318 |
ret.add(driverNames[i]); |
|
319 |
} |
|
320 |
} |
|
321 |
} |
|
322 |
|
|
323 |
return (String[]) ret.toArray(new String[0]); |
|
324 |
} |
|
325 |
|
|
326 |
public void actionPerformed(ActionEvent arg0) { |
|
327 |
Object src = arg0.getSource(); |
|
328 |
|
|
329 |
if (src == connectedCheckBox) { |
|
330 |
if (connectedCheckBox.isSelected()) { |
|
331 |
passwordField.setEnabled(true); |
|
332 |
passwordField.setBackground(Color.WHITE); |
|
333 |
} |
|
334 |
else { |
|
335 |
passwordField.setText(""); |
|
336 |
passwordField.setEnabled(false); |
|
337 |
passwordField.setBackground(Color.LIGHT_GRAY); |
|
338 |
} |
|
339 |
} |
|
340 |
|
|
341 |
if (src == okButton) { |
|
342 |
okPressed = true; |
|
343 |
PluginServices.getMDIManager().closeWindow(this); |
|
344 |
|
|
345 |
return; |
|
346 |
} |
|
347 |
|
|
348 |
if (src == cancelButton) { |
|
349 |
okPressed = false; |
|
350 |
PluginServices.getMDIManager().closeWindow(this); |
|
351 |
|
|
352 |
return; |
|
353 |
} |
|
354 |
|
|
355 |
if (src == driverComboBox) { |
|
356 |
String driverName = driverComboBox.getSelectedItem().toString(); |
|
357 |
VectorialSDEDriver driver; |
|
358 |
|
|
359 |
try { |
|
360 |
driver = (VectorialSDEDriver) LayerFactory.getDM() |
|
361 |
.getDriver(driverName); |
|
362 |
portTextField.setText("" + driver.getDefaultPort()); |
|
363 |
} |
|
364 |
catch (DriverLoadException e1) { |
|
365 |
portTextField.setText(""); |
|
366 |
} |
|
367 |
|
|
368 |
return; |
|
369 |
} |
|
370 |
} |
|
371 |
|
|
372 |
public boolean isOkPressed() { |
|
373 |
return okPressed; |
|
374 |
} |
|
375 |
|
|
376 |
public boolean hasToBeConnected() { |
|
377 |
return connectedCheckBox.isSelected(); |
|
378 |
} |
|
379 |
|
|
380 |
public String getConnectionDriverName() { |
|
381 |
return driverComboBox.getSelectedItem().toString(); |
|
382 |
} |
|
383 |
|
|
384 |
public String getConnectionServerUrl() { |
|
385 |
return urlTextField.getText(); |
|
386 |
} |
|
387 |
|
|
388 |
public String getConnectionPort() { |
|
389 |
return portTextField.getText(); |
|
390 |
} |
|
391 |
|
|
392 |
public String getConnectionDBName() { |
|
393 |
return dbTextField.getText(); |
|
394 |
} |
|
395 |
|
|
396 |
public String getConnectionUser() { |
|
397 |
return userTextField.getText(); |
|
398 |
} |
|
399 |
|
|
400 |
public String getConnectionPassword() { |
|
401 |
String resp = new String(passwordField.getPassword()); |
|
402 |
|
|
403 |
return resp; |
|
404 |
} |
|
405 |
|
|
406 |
private JTextField getUrlTextArea() { |
|
407 |
if (urlTextField == null) { |
|
408 |
urlTextField = new JTextField(); |
|
409 |
urlTextField.addKeyListener(this); |
|
410 |
urlTextField.setBounds(new java.awt.Rectangle(155, 80, 166, 21)); |
|
411 |
} |
|
412 |
|
|
413 |
return urlTextField; |
|
414 |
} |
|
415 |
|
|
416 |
/** |
|
417 |
* This method initializes connectedCheckBox |
|
418 |
* |
|
419 |
* @return javax.swing.JCheckBox |
|
420 |
*/ |
|
421 |
private JCheckBox getConnectedCheckBox() { |
|
422 |
if (connectedCheckBox == null) { |
|
423 |
connectedCheckBox = new JCheckBox(); |
|
424 |
connectedCheckBox.setSelected(true); |
|
425 |
connectedCheckBox.addActionListener(this); |
|
426 |
connectedCheckBox.setBounds(new java.awt.Rectangle(155, 205, 26, 21)); |
|
427 |
} |
|
428 |
|
|
429 |
return connectedCheckBox; |
|
430 |
} |
|
431 |
|
|
432 |
public String getConnectionName() { |
|
433 |
return getConnNameTextField().getText(); |
|
434 |
} |
|
435 |
|
|
436 |
/** |
|
437 |
* This method initializes connNameTextField |
|
438 |
* |
|
439 |
* @return javax.swing.JTextField |
|
440 |
*/ |
|
441 |
private JTextField getConnNameTextField() { |
|
442 |
if (connNameTextField == null) { |
|
443 |
connNameTextField = new JTextField(); |
|
444 |
connNameTextField.addKeyListener(this); |
|
445 |
connNameTextField.setBounds(new java.awt.Rectangle(155, 30, 166, 21)); |
|
446 |
} |
|
447 |
|
|
448 |
return connNameTextField; |
|
449 |
} |
|
450 |
|
|
451 |
public void keyPressed(KeyEvent e) { |
|
452 |
} |
|
453 |
|
|
454 |
public void keyReleased(KeyEvent e) { |
|
455 |
if (e.getKeyChar() != '\n') { |
|
456 |
return; |
|
457 |
} |
|
458 |
|
|
459 |
Object src = e.getSource(); |
|
460 |
|
|
461 |
if (src == passwordField) { |
|
462 |
ActionEvent aevt = new ActionEvent(okButton, |
|
463 |
ActionEvent.ACTION_PERFORMED, ""); |
|
464 |
actionPerformed(aevt); |
|
465 |
} |
|
466 |
else { |
|
467 |
if (src instanceof JTextField) { |
|
468 |
((JTextField) src).transferFocus(); |
|
469 |
} |
|
470 |
} |
|
471 |
} |
|
472 |
|
|
473 |
public void keyTyped(KeyEvent e) { |
|
474 |
} |
|
475 |
|
|
476 |
public void loadValues(ConnectionWithParamsSDE cwp) { |
|
477 |
getPortTextField().setText(cwp.getPort()); |
|
478 |
selectThisInDriverCombo(cwp.getDrvName()); |
|
479 |
getDbTextField().setText(cwp.getDb()); |
|
480 |
getUserTextField().setText(cwp.getUser()); |
|
481 |
|
|
482 |
if (cwp.getPw() == null) { |
|
483 |
getPasswordField().setText(""); |
|
484 |
} |
|
485 |
else { |
|
486 |
getPasswordField().setText(cwp.getPw()); |
|
487 |
} |
|
488 |
|
|
489 |
getUrlTextArea().setText(cwp.getHost()); |
|
490 |
|
|
491 |
boolean connected = false; |
|
492 |
|
|
493 |
// try { |
|
494 |
connected = (cwp.getConnection() != null) && |
|
495 |
(!cwp.getConnection().isClosed()); |
|
496 |
// } |
|
497 |
// catch (SQLException e) { |
|
498 |
// logger.error("While checking connection: " + e.getMessage()); |
|
499 |
// connected = false; |
|
500 |
// } |
|
501 |
|
|
502 |
getConnectedCheckBox().setSelected(connected); |
|
503 |
getConnNameTextField().setText(cwp.getName()); |
|
504 |
} |
|
505 |
|
|
506 |
private void selectThisInDriverCombo(String drvName) { |
|
507 |
int size = getDriverComboBox().getItemCount(); |
|
508 |
|
|
509 |
for (int i = 0; i < size; i++) { |
|
510 |
Object item = getDriverComboBox().getItemAt(i); |
|
511 |
|
|
512 |
if (item.toString().compareToIgnoreCase(drvName) == 0) { |
|
513 |
getDriverComboBox().setSelectedIndex(i); |
|
514 |
|
|
515 |
return; |
|
516 |
} |
|
517 |
} |
|
518 |
} |
|
519 |
} // @jve:decl-index=0:visual-constraint="10,10" |
|
0 | 520 |
trunk/extensions/extSDE/src/com/iver/cit/gvsig/sde/gui/sdewizard2/ConnectionSettings.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
package com.iver.cit.gvsig.sde.gui.sdewizard2; |
|
44 |
|
|
45 |
import com.hardcode.driverManager.DriverLoadException; |
|
46 |
import com.iver.cit.gvsig.fmap.drivers.DefaultDBDriver; |
|
47 |
import com.iver.cit.gvsig.fmap.drivers.VectorialJDBCDriver; |
|
48 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
|
49 |
|
|
50 |
|
|
51 |
/** |
|
52 |
* |
|
53 |
* Utility class. Keeps connection parameters. |
|
54 |
* |
|
55 |
* @author jldominguez |
|
56 |
* @author Fernando Gonz?lez Cort?s |
|
57 |
*/ |
|
58 |
public class ConnectionSettings { |
|
59 |
private String host; |
|
60 |
private String port; |
|
61 |
private String db; |
|
62 |
private String driver; |
|
63 |
private String user; |
|
64 |
private String name; |
|
65 |
private String passw = null; |
|
66 |
|
|
67 |
public String getDb() { |
|
68 |
return db; |
|
69 |
} |
|
70 |
|
|
71 |
public void setDb(String db) { |
|
72 |
this.db = db; |
|
73 |
} |
|
74 |
|
|
75 |
public String getDriver() { |
|
76 |
return driver; |
|
77 |
} |
|
78 |
|
|
79 |
public void setDriver(String driver) { |
|
80 |
this.driver = driver; |
|
81 |
} |
|
82 |
|
|
83 |
public String getHost() { |
|
84 |
return host; |
|
85 |
} |
|
86 |
|
|
87 |
public void setHost(String host) { |
|
88 |
this.host = host; |
|
89 |
} |
|
90 |
|
|
91 |
public String getPort() { |
|
92 |
return port; |
|
93 |
} |
|
94 |
|
|
95 |
public void setPort(String port) { |
|
96 |
this.port = port; |
|
97 |
} |
|
98 |
|
|
99 |
public String getUser() { |
|
100 |
return user; |
|
101 |
} |
|
102 |
|
|
103 |
public void setUser(String user) { |
|
104 |
this.user = user; |
|
105 |
} |
|
106 |
|
|
107 |
public void setName(String name) { |
|
108 |
this.name = name; |
|
109 |
} |
|
110 |
|
|
111 |
public String getName() { |
|
112 |
return name; |
|
113 |
} |
|
114 |
|
|
115 |
public String toString() { |
|
116 |
return host + "," + port + "," + db + "," + driver + "," + user + "," + |
|
117 |
name; |
|
118 |
} |
|
119 |
|
|
120 |
public void setFromString(String _str) throws Exception { |
|
121 |
String str = _str; |
|
122 |
if (str.endsWith(",")) str = str + " "; |
|
123 |
if (str.startsWith(",")) str = " " + str; |
|
124 |
|
|
125 |
String[] values = str.split(","); |
|
126 |
host = values[0]; |
|
127 |
port = values[1]; |
|
128 |
db = values[2]; |
|
129 |
driver = values[3]; |
|
130 |
user = values[4]; |
|
131 |
name = values[5]; |
|
132 |
|
|
133 |
if (values.length == 7) { |
|
134 |
passw = values[6]; |
|
135 |
} |
|
136 |
} |
|
137 |
|
|
138 |
public String getPassw() { |
|
139 |
return passw; |
|
140 |
} |
|
141 |
|
|
142 |
public void setPassw(String passw) { |
|
143 |
this.passw = passw; |
|
144 |
} |
|
145 |
|
|
146 |
public String getConnectionString() throws DriverLoadException { |
|
147 |
VectorialJDBCDriver vecDriver = (VectorialJDBCDriver) LayerFactory.getDM() |
|
148 |
.getDriver(getDriver()); |
|
149 |
|
|
150 |
if (vecDriver instanceof DefaultDBDriver) { |
|
151 |
return ((DefaultDBDriver) vecDriver).getConnectionString(getHost(), |
|
152 |
getPort(), getDb(), getUser(), getPassw()); |
|
153 |
} |
|
154 |
|
|
155 |
String connectionString = vecDriver.getConnectionStringBeginning() + |
|
156 |
"//" + getHost(); |
|
157 |
connectionString += (":" + getPort()); |
|
158 |
connectionString += ("/" + getDb()); |
|
159 |
|
|
160 |
return connectionString; |
|
161 |
} |
|
162 |
} |
|
0 | 163 |
trunk/extensions/extSDE/src/com/iver/cit/gvsig/sde/gui/sdewizard2/FieldsListItem.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
package com.iver.cit.gvsig.sde.gui.sdewizard2; |
|
44 |
|
|
45 |
import javax.swing.JCheckBox; |
|
46 |
|
|
47 |
|
|
48 |
/** |
|
49 |
* Used to instantiate field list items. Shows the database dependent type name. |
|
50 |
* |
|
51 |
* @author jldominguez |
|
52 |
* |
|
53 |
*/ |
|
54 |
public class FieldsListItem extends JCheckBox { |
|
55 |
private String name = "[No name]"; |
|
56 |
private String type = "[No type]"; |
|
57 |
|
|
58 |
public FieldsListItem(String _name, String _type) { |
|
59 |
name = _name; |
|
60 |
type = _type; |
|
61 |
setText(toString()); |
|
62 |
setSelected(true); |
|
63 |
} |
|
64 |
|
|
65 |
public String toString() { |
|
66 |
return name + " [" + type + "]"; |
|
67 |
} |
|
68 |
|
|
69 |
public String getName() { |
|
70 |
return name; |
|
71 |
} |
|
72 |
} |
|
0 | 73 |
trunk/extensions/extSDE/src/com/iver/cit/gvsig/sde/gui/sdewizard2/SDEConnectionTreeNode.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
package com.iver.cit.gvsig.sde.gui.sdewizard2; |
|
44 |
|
|
45 |
import javax.swing.tree.DefaultMutableTreeNode; |
|
46 |
|
|
47 |
|
|
48 |
/** |
|
49 |
* Utility class used to manage the connection tree. |
|
50 |
* @author jldominguez |
|
51 |
* |
|
52 |
*/ |
|
53 |
public class SDEConnectionTreeNode extends DefaultMutableTreeNode { |
|
54 |
private String label; |
|
55 |
|
|
56 |
public SDEConnectionTreeNode(String drvname) { |
|
57 |
label = drvname; |
|
58 |
setAllowsChildren(true); |
|
59 |
} |
|
60 |
|
|
61 |
public String toString() { |
|
62 |
return label; |
|
63 |
} |
|
64 |
} |
|
0 | 65 |
trunk/extensions/extSDE/src/com/iver/cit/gvsig/sde/gui/sdewizard2/FieldComboItem.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
package com.iver.cit.gvsig.sde.gui.sdewizard2; |
|
44 |
|
|
45 |
|
|
46 |
/** |
|
47 |
* Utility class to deal with combo boxes. |
|
48 |
* |
|
49 |
* @author jldominguez |
|
50 |
* |
|
51 |
*/ |
|
52 |
public class FieldComboItem { |
|
53 |
private String name = ""; |
|
54 |
|
|
55 |
public FieldComboItem(String _name) { |
|
56 |
name = _name; |
|
57 |
} |
|
58 |
|
|
59 |
public String toString() { |
|
60 |
return name; |
|
61 |
} |
|
62 |
} |
|
0 | 63 |
trunk/extensions/extSDE/src/com/iver/cit/gvsig/sde/gui/sdewizard2/TablesListItem.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
package com.iver.cit.gvsig.sde.gui.sdewizard2; |
|
44 |
|
|
45 |
import java.sql.SQLException; |
|
46 |
|
|
47 |
import javax.swing.JCheckBox; |
|
48 |
|
|
49 |
import com.esri.sde.sdk.client.SeConnection; |
|
50 |
import com.esri.sde.sdk.client.SeException; |
|
51 |
import com.esri.sde.sdk.client.SeRegisteredColumn; |
|
52 |
import com.esri.sde.sdk.client.SeTable; |
|
53 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
54 |
import com.iver.cit.gvsig.fmap.drivers.sde.VectorialSDEDriver; |
|
55 |
|
|
56 |
|
|
57 |
/** |
|
58 |
* Utility class that represents a table list item as a selectable check box. |
Also available in: Unified diff