Revision 33825
tags/v2_0_0_Build_2020/extensions/extGeoDB/distribution/distribution.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>distribution</id> |
|
3 |
<formats> |
|
4 |
<format>dir</format> |
|
5 |
</formats> |
|
6 |
<fileSets> |
|
7 |
<!-- Extructure for the extension --> |
|
8 |
<fileSet> |
|
9 |
<directory>config</directory> |
|
10 |
<outputDirectory>${extension.install.dir.name} |
|
11 |
</outputDirectory> |
|
12 |
</fileSet> |
|
13 |
<fileSet> |
|
14 |
<directory>images</directory> |
|
15 |
<outputDirectory>/${extension.install.dir.name}/images |
|
16 |
</outputDirectory> |
|
17 |
</fileSet> |
|
18 |
</fileSets> |
|
19 |
<files> |
|
20 |
<file> |
|
21 |
<source>package.info</source> |
|
22 |
<outputDirectory>${extension.install.dir.name} |
|
23 |
</outputDirectory> |
|
24 |
</file> |
|
25 |
</files> |
|
26 |
<!-- |
|
27 |
*********************************************************************** |
|
28 |
--> |
|
29 |
<!-- * *--> |
|
30 |
<!-- |
|
31 |
*********************************************************************** |
|
32 |
--> |
|
33 |
<dependencySets> |
|
34 |
<dependencySet> |
|
35 |
<outputDirectory>${extension.install.dir.name}/${library-dir} |
|
36 |
</outputDirectory> |
|
37 |
<includes> |
|
38 |
<include>org.gvsig:org.gvsig.geodb</include> |
|
39 |
<include>org.gvsig:org.gvsig.fmap.dal.db</include> |
|
40 |
<include>org.gvsig:org.gvsig.fmap.dal.db:jar:store.jdbc</include> |
|
41 |
</includes> |
|
42 |
</dependencySet> |
|
43 |
<dependencySet> |
|
44 |
<outputDirectory>${extension.install.dir.name}/${library-dir} |
|
45 |
</outputDirectory> |
|
46 |
<includes> |
|
47 |
<include>org.gvsig:org.gvsig.fmap.dal.db:jar:store.jdbc</include> |
|
48 |
<include>commons-dbcp:commons-dbcp</include> |
|
49 |
<include>commons-collections:commons-collections</include> |
|
50 |
<include>commons-pool:commons-pool</include> |
|
51 |
</includes> |
|
52 |
</dependencySet> |
|
53 |
<dependencySet> |
|
54 |
<outputDirectory>${extension.install.dir.name}/${library-dir} |
|
55 |
</outputDirectory> |
|
56 |
<includes> |
|
57 |
<include>org.gvsig:org.gvsig.fmap.dal.db:jar:store.postgresql</include> |
|
58 |
<include>postgresql:postgresql</include> |
|
59 |
</includes> |
|
60 |
</dependencySet> |
|
61 |
<dependencySet> |
|
62 |
<outputDirectory>${extension.install.dir.name}/${library-dir} |
|
63 |
</outputDirectory> |
|
64 |
<includes> |
|
65 |
<include>org.gvsig:org.gvsig.fmap.dal.db:jar:store.mysql</include> |
|
66 |
<include>mysql:mysql-connector-java</include> |
|
67 |
</includes> |
|
68 |
</dependencySet> |
|
69 |
</dependencySets> |
|
70 |
</assembly> |
tags/v2_0_0_Build_2020/extensions/extGeoDB/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Tue Oct 26 12:06:59 CEST 2010 |
|
3 |
buildNumber=2020 |
tags/v2_0_0_Build_2020/extensions/extGeoDB/config/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<libraries library-dir="lib"/> |
|
4 |
<depends plugin-name="org.gvsig.app"/> |
|
5 |
<resourceBundle name="text"/> |
|
6 |
<extensions> |
|
7 |
<extension class-name="org.gvsig.geodb.SingleVectorialDBConnectionExtension" |
|
8 |
description="Opens DB connections manager" |
|
9 |
active="true"> |
|
10 |
<menu text="Ver/gestor_db" action-command="GESTOR_VECTORIALDB" key="j" |
|
11 |
tooltip="abrir_gestor_de_orig_db" |
|
12 |
position="3"/> |
|
13 |
</extension> |
|
14 |
|
|
15 |
<extension class-name="org.gvsig.geodb.ExtDB_Spatial" |
|
16 |
description="Support to access Spatial databases" |
|
17 |
active="true"> |
|
18 |
</extension> |
|
19 |
<extension class-name="org.gvsig.geodb.ExportToDB" |
|
20 |
description="Exportar a diversos formatos" |
|
21 |
active="true"> |
|
22 |
<menu text="Capa/export_to/postgis" action-command="POSTGIS"/> |
|
23 |
<menu text="Capa/export_to/mysql" action-command="MYSQL"/> |
|
24 |
</extension> |
|
25 |
</extensions> |
|
26 |
</plugin-config> |
|
0 | 27 |
tags/v2_0_0_Build_2020/extensions/extGeoDB/package.info | ||
---|---|---|
1 |
# |
|
2 |
#Tue Oct 26 12:07:00 CEST 2010 |
|
3 |
state=devel |
|
4 |
name=extGeoDB |
|
5 |
official=true |
|
6 |
code=org.gvsig.geodb |
|
7 |
operating-system=all |
|
8 |
architecture=all |
|
9 |
java-version=j1_5 |
|
10 |
gvSIG-version=2.0.0 |
|
11 |
version=2.0-SNAPSHOT |
|
12 |
type=plugin |
|
13 |
build=2020 |
|
14 |
description=Base POM for all GvSIG extension projects. This pom knows\n\t\thow to build and made an extension for GvSIG. The property\n\t\t"build-dir" must be set up correctly. |
tags/v2_0_0_Build_2020/extensions/extGeoDB/src/org/gvsig/geodb/SingleVectorialDBConnectionExtension.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 org.gvsig.geodb; |
|
44 |
|
|
45 |
import java.util.ArrayList; |
|
46 |
|
|
47 |
import javax.swing.JOptionPane; |
|
48 |
|
|
49 |
import org.apache.log4j.Logger; |
|
50 |
import org.gvsig.andami.PluginServices; |
|
51 |
import org.gvsig.andami.plugins.Extension; |
|
52 |
import org.gvsig.geodb.vectorialdb.ConnectionSettings; |
|
53 |
import org.gvsig.utils.NotExistInXMLEntity; |
|
54 |
import org.gvsig.utils.XMLEntity; |
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
/** |
|
59 |
* This extension allows the user to access the single connection manager dialog |
|
60 |
* |
|
61 |
* @see org.gvsig.fmap.drivers.formats.db.utils.SingleVectorialDBConnectionManager |
|
62 |
* |
|
63 |
* @author jldominguez |
|
64 |
* |
|
65 |
*/ |
|
66 |
public class SingleVectorialDBConnectionExtension extends Extension { |
|
67 |
private static Logger logger = Logger.getLogger(SingleVectorialDBConnectionExtension.class.getName()); |
|
68 |
|
|
69 |
/** |
|
70 |
* This method simply loads the connections stored in gvSIG's persistence file |
|
71 |
* as closed connections |
|
72 |
*/ |
|
73 |
public void initialize() { |
|
74 |
loadPersistenceConnections(); |
|
75 |
registerIcons(); |
|
76 |
} |
|
77 |
|
|
78 |
private void registerIcons(){ |
|
79 |
PluginServices.getIconTheme().register( |
|
80 |
"conn-image", |
|
81 |
this.getClass().getClassLoader().getResource("images/conn.png") |
|
82 |
); |
|
83 |
PluginServices.getIconTheme().register( |
|
84 |
"disconn-image", |
|
85 |
this.getClass().getClassLoader().getResource("images/disconn.png") |
|
86 |
); |
|
87 |
|
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* The only command available is the one to open the connection manager |
|
92 |
* dialog ("GESTOR_JDBC") |
|
93 |
*/ |
|
94 |
public void execute(String actionCommand) { |
|
95 |
// FIXME |
|
96 |
// if (actionCommand.compareToIgnoreCase("GESTOR_VECTORIALDB") == 0) { |
|
97 |
// VectorialDBConnectionManagerDialog dlg = new VectorialDBConnectionManagerDialog(); |
|
98 |
// dlg.showDialog(); |
|
99 |
//// saveAllToPersistence(); |
|
100 |
// |
|
101 |
// return; |
|
102 |
// } |
|
103 |
} |
|
104 |
|
|
105 |
public boolean isEnabled() { |
|
106 |
return true; |
|
107 |
} |
|
108 |
|
|
109 |
public boolean isVisible() { |
|
110 |
return true; |
|
111 |
} |
|
112 |
|
|
113 |
public static void saveAllToPersistence() { |
|
114 |
SingleVectorialDBConnectionExtension ext=new SingleVectorialDBConnectionExtension(); |
|
115 |
XMLEntity xml = PluginServices.getPluginServices(ext).getPersistentXML(); |
|
116 |
xml.putProperty("literalDBName",true); |
|
117 |
xml.remove("db-connections"); |
|
118 |
|
|
119 |
// ConnectionWithParams[] all = SingleVectorialDBConnectionManager.instance() |
|
120 |
// .getAllConnections(); |
|
121 |
// |
|
122 |
// if (all == null) { |
|
123 |
// PluginServices.getPluginServices(ext).setPersistentXML(xml); |
|
124 |
// return; |
|
125 |
// } |
|
126 |
// |
|
127 |
// for (int i = 0; i < all.length; i++) { |
|
128 |
// addToPersistence(all[i],ext); |
|
129 |
// } |
|
130 |
} |
|
131 |
|
|
132 |
// private static void addToPersistence(ConnectionWithParams cwp, Extension ext) { |
|
133 |
// if (cwp == null) { |
|
134 |
// return; |
|
135 |
// } |
|
136 |
// |
|
137 |
// ConnectionSettings _cs = new ConnectionSettings(); |
|
138 |
// |
|
139 |
// _cs.setHost(cwp.getHost()); |
|
140 |
// _cs.setPort(cwp.getPort()); |
|
141 |
// _cs.setDb(cwp.getDb()); |
|
142 |
// _cs.setDriver(cwp.getDrvName()); |
|
143 |
// _cs.setUser(cwp.getUser()); |
|
144 |
// _cs.setName(cwp.getName()); |
|
145 |
// |
|
146 |
// String newstr = _cs.toString(); |
|
147 |
// |
|
148 |
// XMLEntity xml = PluginServices.getPluginServices(ext).getPersistentXML(); |
|
149 |
// |
|
150 |
// String[] old = null; |
|
151 |
// |
|
152 |
// if (xml.contains("db-connections")) { |
|
153 |
// old = xml.getStringArrayProperty("db-connections"); |
|
154 |
// } |
|
155 |
// |
|
156 |
// ArrayList oldl = stringArrayToArrayList(old); |
|
157 |
// oldl.add(newstr); |
|
158 |
// |
|
159 |
// String[] newarr = (String[]) oldl.toArray(new String[0]); |
|
160 |
// |
|
161 |
// xml.remove("db-connections"); |
|
162 |
// xml.putProperty("db-connections", newarr); |
|
163 |
// PluginServices.getPluginServices(ext).setPersistentXML(xml); |
|
164 |
// } |
|
165 |
|
|
166 |
private static ArrayList stringArrayToArrayList(String[] arr) { |
|
167 |
ArrayList resp = new ArrayList(); |
|
168 |
|
|
169 |
if ((arr != null) && (arr.length > 0)) { |
|
170 |
for (int i = 0; i < arr.length; i++) { |
|
171 |
resp.add(arr[i]); |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 |
return resp; |
|
176 |
} |
|
177 |
|
|
178 |
private void loadPersistenceConnections() { |
|
179 |
XMLEntity xml = PluginServices.getPluginServices(this).getPersistentXML(); |
|
180 |
boolean literalDBNames; |
|
181 |
|
|
182 |
if (!xml.contains("literalDBName")){ |
|
183 |
// For back compatibility |
|
184 |
literalDBNames = false; |
|
185 |
}else{ |
|
186 |
// For back compatibility: Normaly always true |
|
187 |
literalDBNames = xml.getBooleanProperty("literalDBName"); |
|
188 |
} |
|
189 |
|
|
190 |
if (xml == null) { |
|
191 |
xml = new XMLEntity(); |
|
192 |
} |
|
193 |
|
|
194 |
if (!xml.contains("db-connections")) { |
|
195 |
String[] servers = new String[0]; |
|
196 |
xml.putProperty("db-connections", servers); |
|
197 |
} |
|
198 |
|
|
199 |
// add drivers to connection manager |
|
200 |
String[] servers = null; |
|
201 |
|
|
202 |
try { |
|
203 |
servers = xml.getStringArrayProperty("db-connections"); |
|
204 |
} |
|
205 |
catch (NotExistInXMLEntity e) { |
|
206 |
System.err.println( |
|
207 |
"Error while getting projects db-connections: " + |
|
208 |
e.getMessage()); |
|
209 |
|
|
210 |
return; |
|
211 |
} |
|
212 |
|
|
213 |
for (int i = 0; i < servers.length; i++) { |
|
214 |
ConnectionSettings cs = new ConnectionSettings(); |
|
215 |
boolean params_ok = true; |
|
216 |
try { |
|
217 |
cs.setFromString(servers[i]); |
|
218 |
// For back compatibility |
|
219 |
if (!literalDBNames){ |
|
220 |
cs.setDb(cs.getDb().toLowerCase()); |
|
221 |
} |
|
222 |
} catch (Exception ex) { |
|
223 |
logger.error("Found misconfigured connection: " + servers[i]); |
|
224 |
params_ok = false; |
|
225 |
} |
|
226 |
if (params_ok) { |
|
227 |
addDisconnected(cs); |
|
228 |
} |
|
229 |
} |
|
230 |
|
|
231 |
PluginServices ps= PluginServices.getPluginServices("com.iver.cit.gvsig.jdbc_spatial"); |
|
232 |
if (ps==null) { |
|
233 |
return; |
|
234 |
} |
|
235 |
XMLEntity xmlJDBC =ps.getPersistentXML(); |
|
236 |
|
|
237 |
if (xmlJDBC==null || !xmlJDBC.contains("jdbc-connections")) { |
|
238 |
return; |
|
239 |
} |
|
240 |
|
|
241 |
// add drivers to connection manager |
|
242 |
String[] serversOld = null; |
|
243 |
|
|
244 |
try { |
|
245 |
serversOld = xmlJDBC.getStringArrayProperty("jdbc-connections"); |
|
246 |
} |
|
247 |
catch (NotExistInXMLEntity e) { |
|
248 |
System.err.println( |
|
249 |
"Error while getting projects jdbc-connections: " + |
|
250 |
e.getMessage()); |
|
251 |
|
|
252 |
return; |
|
253 |
} |
|
254 |
|
|
255 |
for (int i = 0; i < serversOld.length; i++) { |
|
256 |
ConnectionSettings cs = new ConnectionSettings(); |
|
257 |
boolean params_ok = true; |
|
258 |
try { |
|
259 |
cs.setFromString(serversOld[i]); |
|
260 |
cs.setDb(cs.getDb().toLowerCase()); |
|
261 |
} catch (Exception ex) { |
|
262 |
logger.error("Found misconfigured connection: " + serversOld[i]); |
|
263 |
params_ok = false; |
|
264 |
} |
|
265 |
if (params_ok) { |
|
266 |
addDisconnected(cs); |
|
267 |
} |
|
268 |
} |
|
269 |
|
|
270 |
|
|
271 |
} |
|
272 |
|
|
273 |
private void addDisconnected(ConnectionSettings _cs) { |
|
274 |
// try { |
|
275 |
// SingleVectorialDBConnectionManager.instance() |
|
276 |
// .getConnection(_cs.getDriver(), |
|
277 |
// _cs.getUser(), null, _cs.getName(), _cs.getHost(), |
|
278 |
// _cs.getPort(), _cs.getDb(), false); |
|
279 |
// } |
|
280 |
// catch (DBException e) { |
|
281 |
// System.err.println("While getting connection: " + e.getMessage()); |
|
282 |
// showConnectionErrorMessage(e.getMessage()); |
|
283 |
// } |
|
284 |
} |
|
285 |
|
|
286 |
private void showConnectionErrorMessage(String _msg) { |
|
287 |
String msg = (_msg.length() > 300) ? "" : (": " + _msg); |
|
288 |
String title = PluginServices.getText(this, "connection_error"); |
|
289 |
JOptionPane.showMessageDialog(null, title + msg, title, |
|
290 |
JOptionPane.ERROR_MESSAGE); |
|
291 |
} |
|
292 |
|
|
293 |
public void terminate() { |
|
294 |
saveAllToPersistence(); |
|
295 |
// SingleVectorialDBConnectionManager.instance().closeAllBeforeTerminate(); |
|
296 |
} |
|
297 |
} |
|
0 | 298 |
tags/v2_0_0_Build_2020/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/JPasswordDlg.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 07-oct-2005 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
21 |
* |
|
22 |
* For more information, contact: |
|
23 |
* |
|
24 |
* Generalitat Valenciana |
|
25 |
* Conselleria d'Infraestructures i Transport |
|
26 |
* Av. Blasco Ib??ez, 50 |
|
27 |
* 46010 VALENCIA |
|
28 |
* SPAIN |
|
29 |
* |
|
30 |
* +34 963862235 |
|
31 |
* gvsig@gva.es |
|
32 |
* www.gvsig.gva.es |
|
33 |
* |
|
34 |
* or |
|
35 |
* |
|
36 |
* IVER T.I. S.A |
|
37 |
* Salamanca 50 |
|
38 |
* 46005 Valencia |
|
39 |
* Spain |
|
40 |
* |
|
41 |
* +34 963163400 |
|
42 |
* dac@iver.es |
|
43 |
*/ |
|
44 |
package org.gvsig.geodb.vectorialdb; |
|
45 |
|
|
46 |
import java.awt.event.KeyEvent; |
|
47 |
|
|
48 |
import javax.swing.JButton; |
|
49 |
import javax.swing.JEditorPane; |
|
50 |
import javax.swing.JPanel; |
|
51 |
import javax.swing.JPasswordField; |
|
52 |
import javax.swing.JTextArea; |
|
53 |
|
|
54 |
import org.gvsig.andami.PluginServices; |
|
55 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
56 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
57 |
|
|
58 |
|
|
59 |
public class JPasswordDlg extends JPanel implements IWindow { |
|
60 |
|
|
61 |
private JPanel jContentPane = null; |
|
62 |
|
|
63 |
private JButton jButtonOK = null; |
|
64 |
|
|
65 |
private JButton jButton1 = null; |
|
66 |
|
|
67 |
private JPasswordField jPasswordField = null; |
|
68 |
|
|
69 |
private String password = null; |
|
70 |
|
|
71 |
private JEditorPane jEditorPane = null; |
|
72 |
|
|
73 |
private JTextArea jLblMensaje = null; |
|
74 |
|
|
75 |
// private WindowEventsHandler windowHandler = new WindowEventsHandler(); |
|
76 |
|
|
77 |
/** |
|
78 |
* This is the default constructor |
|
79 |
*/ |
|
80 |
public JPasswordDlg() { |
|
81 |
super(); |
|
82 |
initialize(); |
|
83 |
} |
|
84 |
|
|
85 |
// class WindowEventsHandler extends WindowAdapter |
|
86 |
// { |
|
87 |
// |
|
88 |
// /* (non-Javadoc) |
|
89 |
// * @see java.awt.event.WindowAdapter#windowActivated(java.awt.event.WindowEvent) |
|
90 |
// */ |
|
91 |
// public void windowActivated(WindowEvent e) { |
|
92 |
// // TODO Auto-generated method stub |
|
93 |
// super.windowActivated(e); |
|
94 |
// jPasswordField.requestFocus(); |
|
95 |
// } |
|
96 |
// |
|
97 |
// } |
|
98 |
/** |
|
99 |
* This method initializes this |
|
100 |
* |
|
101 |
* @return void |
|
102 |
*/ |
|
103 |
private void initialize() { |
|
104 |
this.setSize(287, 172); |
|
105 |
this.setLayout(null); |
|
106 |
this.add(getJContentPane()); |
|
107 |
// this.setModal(true); |
|
108 |
// this.setResizable(false); |
|
109 |
// this.setTitle("Enter Password"); |
|
110 |
// this.setContentPane(getJContentPane()); |
|
111 |
// |
|
112 |
// addWindowListener(windowHandler); |
|
113 |
} |
|
114 |
/** |
|
115 |
* This method initializes jContentPane |
|
116 |
* |
|
117 |
* @return javax.swing.JPanel |
|
118 |
*/ |
|
119 |
private JPanel getJContentPane() { |
|
120 |
if (jContentPane == null) { |
|
121 |
jContentPane = new JPanel(); |
|
122 |
jContentPane.setLayout(null); |
|
123 |
jContentPane.add(getJButton1(), null); |
|
124 |
jContentPane.add(getJButtonOK(), null); |
|
125 |
jContentPane.add(getJPasswordField(), null); |
|
126 |
jContentPane.add(getJLblMensaje(), null); |
|
127 |
jContentPane.setBounds(0,0,300,200); |
|
128 |
} |
|
129 |
return jContentPane; |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* This method initializes jButton |
|
134 |
* |
|
135 |
* @return javax.swing.JButton |
|
136 |
*/ |
|
137 |
private JButton getJButtonOK() { |
|
138 |
if (jButtonOK == null) { |
|
139 |
jButtonOK = new JButton(); |
|
140 |
jButtonOK.setText("OK"); |
|
141 |
jButtonOK.setPreferredSize(new java.awt.Dimension(65, 23)); |
|
142 |
jButtonOK.setBounds(35, 110, 101, 22); |
|
143 |
jButtonOK.addActionListener(new java.awt.event.ActionListener() { |
|
144 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
145 |
System.out.println("actionPerformed()"); // TODO |
|
146 |
// Auto-generated |
|
147 |
// Event stub |
|
148 |
// actionPerformed() |
|
149 |
password = String.copyValueOf(getJPasswordField() |
|
150 |
.getPassword()); |
|
151 |
PluginServices.getMDIManager().closeWindow(JPasswordDlg.this); |
|
152 |
// dispose(); |
|
153 |
} |
|
154 |
}); |
|
155 |
} |
|
156 |
return jButtonOK; |
|
157 |
} |
|
158 |
|
|
159 |
/** |
|
160 |
* This method initializes jButton1 |
|
161 |
* |
|
162 |
* @return javax.swing.JButton |
|
163 |
*/ |
|
164 |
private JButton getJButton1() { |
|
165 |
if (jButton1 == null) { |
|
166 |
jButton1 = new JButton(); |
|
167 |
jButton1.setText("Cancel"); |
|
168 |
jButton1.setBounds(136, 110, 99, 22); |
|
169 |
jButton1.addActionListener(new java.awt.event.ActionListener() { |
|
170 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
171 |
password = null; |
|
172 |
PluginServices.getMDIManager().closeWindow(JPasswordDlg.this); |
|
173 |
// dispose(); |
|
174 |
} |
|
175 |
}); |
|
176 |
} |
|
177 |
return jButton1; |
|
178 |
} |
|
179 |
|
|
180 |
/** |
|
181 |
* This method initializes jPasswordField |
|
182 |
* |
|
183 |
* @return javax.swing.JPasswordField |
|
184 |
*/ |
|
185 |
private JPasswordField getJPasswordField() { |
|
186 |
if (jPasswordField == null) { |
|
187 |
jPasswordField = new JPasswordField(); |
|
188 |
jPasswordField.setPreferredSize(new java.awt.Dimension(60, 22)); |
|
189 |
jPasswordField.setBounds(65, 78, 145, 21); |
|
190 |
jPasswordField.addKeyListener(new java.awt.event.KeyAdapter() { |
|
191 |
public void keyTyped(java.awt.event.KeyEvent e) { |
|
192 |
if (e.getKeyChar() == KeyEvent.VK_ENTER) { |
|
193 |
// System.out.println("INTRO"); |
|
194 |
getJButtonOK().doClick(); |
|
195 |
} |
|
196 |
} |
|
197 |
}); |
|
198 |
} |
|
199 |
return jPasswordField; |
|
200 |
} |
|
201 |
|
|
202 |
/** |
|
203 |
* @return Returns the password. |
|
204 |
*/ |
|
205 |
public String getPassword() { |
|
206 |
return password; |
|
207 |
} |
|
208 |
|
|
209 |
public void setMessage(String str) { |
|
210 |
getJLblMensaje().setText(str); |
|
211 |
} |
|
212 |
|
|
213 |
/** |
|
214 |
* This method initializes jTextArea |
|
215 |
* |
|
216 |
* @return javax.swing.JTextArea |
|
217 |
*/ |
|
218 |
private JTextArea getJLblMensaje() { |
|
219 |
if (jLblMensaje == null) { |
|
220 |
jLblMensaje = new JTextArea(); |
|
221 |
jLblMensaje.setEditable(false); |
|
222 |
jLblMensaje.setForeground(java.awt.Color.black); |
|
223 |
jLblMensaje.setBackground(java.awt.SystemColor.control); |
|
224 |
jLblMensaje.setText("Mensaje"); |
|
225 |
jLblMensaje.setLineWrap(true); |
|
226 |
jLblMensaje.setFont(new java.awt.Font("SansSerif", |
|
227 |
java.awt.Font.PLAIN, 12)); |
|
228 |
jLblMensaje.setPreferredSize(new java.awt.Dimension(270, 50)); |
|
229 |
jLblMensaje.setBounds(9, 6, 266, 68); |
|
230 |
jLblMensaje.setWrapStyleWord(true); |
|
231 |
} |
|
232 |
return jLblMensaje; |
|
233 |
} |
|
234 |
public WindowInfo getWindowInfo() { |
|
235 |
WindowInfo wi=new WindowInfo(WindowInfo.MODALDIALOG|WindowInfo.RESIZABLE); |
|
236 |
wi.setTitle(PluginServices.getText(this,"enter_password")); |
|
237 |
return wi; |
|
238 |
} |
|
239 |
public Object getWindowProfile() { |
|
240 |
// TODO Auto-generated method stub |
|
241 |
return WindowInfo.DIALOG_PROFILE; |
|
242 |
} |
|
243 |
|
|
244 |
} // @jve:decl-index=0:visual-constraint="10,10" |
tags/v2_0_0_Build_2020/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/DlgConnection.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 26-oct-2005 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
21 |
* |
|
22 |
* For more information, contact: |
|
23 |
* |
|
24 |
* Generalitat Valenciana |
|
25 |
* Conselleria d'Infraestructures i Transport |
|
26 |
* Av. Blasco Ib??ez, 50 |
|
27 |
* 46010 VALENCIA |
|
28 |
* SPAIN |
|
29 |
* |
|
30 |
* +34 963862235 |
|
31 |
* gvsig@gva.es |
|
32 |
* www.gvsig.gva.es |
|
33 |
* |
|
34 |
* or |
|
35 |
* |
|
36 |
* IVER T.I. S.A |
|
37 |
* Salamanca 50 |
|
38 |
* 46005 Valencia |
|
39 |
* Spain |
|
40 |
* |
|
41 |
* +34 963163400 |
|
42 |
* dac@iver.es |
|
43 |
*/ |
|
44 |
package org.gvsig.geodb.vectorialdb; |
|
45 |
|
|
46 |
import java.awt.BorderLayout; |
|
47 |
import java.awt.event.ActionListener; |
|
48 |
import java.util.ArrayList; |
|
49 |
import java.util.HashMap; |
|
50 |
import java.util.Iterator; |
|
51 |
import java.util.List; |
|
52 |
|
|
53 |
import javax.swing.JButton; |
|
54 |
import javax.swing.JDialog; |
|
55 |
import javax.swing.JOptionPane; |
|
56 |
import javax.swing.JPanel; |
|
57 |
|
|
58 |
import org.gvsig.andami.PluginServices; |
|
59 |
import org.gvsig.andami.messages.NotificationManager; |
|
60 |
import org.gvsig.fmap.dal.DALLocator; |
|
61 |
import org.gvsig.fmap.dal.DataManager; |
|
62 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
63 |
import org.gvsig.fmap.dal.exception.DataException; |
|
64 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
|
65 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
|
66 |
import org.gvsig.utils.NotExistInXMLEntity; |
|
67 |
import org.gvsig.utils.XMLEntity; |
|
68 |
|
|
69 |
|
|
70 |
public class DlgConnection extends JDialog { |
|
71 |
|
|
72 |
private JPanel jContentPane = null; |
|
73 |
private ConnectionPanel jConnPanel = null; |
|
74 |
private JButton jBtnOK = null; |
|
75 |
private JPanel jPanel1 = null; |
|
76 |
private JButton jBtnCancel = null; |
|
77 |
private ConnectionSettings connSettings = null; |
|
78 |
|
|
79 |
/** |
|
80 |
* This is the default constructor |
|
81 |
*/ |
|
82 |
public DlgConnection() { |
|
83 |
super(); |
|
84 |
initialize(); |
|
85 |
} |
|
86 |
|
|
87 |
private void setPreferences() |
|
88 |
{ |
|
89 |
XMLEntity xml = PluginServices.getPluginServices(this).getPersistentXML(); |
|
90 |
|
|
91 |
if (xml == null) { |
|
92 |
xml = new XMLEntity(); |
|
93 |
} |
|
94 |
|
|
95 |
if (!xml.contains("db-connections")) { |
|
96 |
String[] servers = new String[0]; |
|
97 |
xml.putProperty("db-connections", servers); |
|
98 |
} |
|
99 |
|
|
100 |
try { |
|
101 |
String[] servers = xml.getStringArrayProperty("db-connections"); |
|
102 |
HashMap settings = new HashMap(); |
|
103 |
for (int i = 0; i < servers.length; i++) { |
|
104 |
ConnectionSettings cs = new ConnectionSettings(); |
|
105 |
cs.setFromString(servers[i]); |
|
106 |
settings.put(cs.getName(), cs); |
|
107 |
} |
|
108 |
getJConnPanel().setSettings(settings); |
|
109 |
} catch (NotExistInXMLEntity e) { |
|
110 |
} |
|
111 |
|
|
112 |
} |
|
113 |
/** |
|
114 |
* This method initializes this |
|
115 |
* |
|
116 |
* @return void |
|
117 |
*/ |
|
118 |
private void initialize() { |
|
119 |
this.setSize(320, 332); |
|
120 |
this.setTitle(PluginServices.getText(this, "database_connection")); |
|
121 |
this.setContentPane(getJContentPane()); |
|
122 |
setPreferences(); |
|
123 |
DataManager dm= DALLocator.getDataManager(); |
|
124 |
List explorers = dm.getExplorerProviders(); |
|
125 |
Iterator iter = explorers.iterator(); |
|
126 |
DataServerExplorerParameters exParam = null; |
|
127 |
String name; |
|
128 |
List<String> dbExplores = new ArrayList<String>(explorers.size()); |
|
129 |
while (iter.hasNext()) { |
|
130 |
name = (String) iter.next(); |
|
131 |
try { |
|
132 |
exParam = dm.createServerExplorerParameters(name); |
|
133 |
} catch (DataException e) { |
|
134 |
NotificationManager.addError(e); |
|
135 |
} |
|
136 |
if (exParam instanceof DBServerExplorerParameters) { |
|
137 |
dbExplores.add(name); |
|
138 |
} |
|
139 |
} |
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
jConnPanel |
|
144 |
.setDrivers(dbExplores |
|
145 |
.toArray(new String[dbExplores.size()])); |
|
146 |
} |
|
147 |
|
|
148 |
// private String[] getDriverNames(){ |
|
149 |
// Class[] classes = new Class[] { IVectorialDatabaseDriver.class }; |
|
150 |
// |
|
151 |
// ArrayList ret = new ArrayList(); |
|
152 |
// String[] driverNames = LayerFactory.getDM().getDriverNames(); |
|
153 |
// |
|
154 |
// for (int i = 0; i < driverNames.length; i++) { |
|
155 |
// boolean is = false; |
|
156 |
// |
|
157 |
// for (int j = 0; j < classes.length; j++) { |
|
158 |
// if (LayerFactory.getDM().isA(driverNames[i], classes[j])) { |
|
159 |
// ret.add(driverNames[i]); |
|
160 |
// } |
|
161 |
// } |
|
162 |
// } |
|
163 |
// |
|
164 |
// return (String[]) ret.toArray(new String[0]); |
|
165 |
// |
|
166 |
// } |
|
167 |
|
|
168 |
/** |
|
169 |
* This method initializes jContentPane |
|
170 |
* |
|
171 |
* @return javax.swing.JPanel |
|
172 |
*/ |
|
173 |
private JPanel getJContentPane() { |
|
174 |
if (jContentPane == null) { |
|
175 |
jContentPane = new JPanel(); |
|
176 |
jContentPane.setLayout(new BorderLayout()); |
|
177 |
jContentPane.add(getJConnPanel(), java.awt.BorderLayout.CENTER); |
|
178 |
jContentPane.add(getJPanel1(), java.awt.BorderLayout.SOUTH); |
|
179 |
|
|
180 |
} |
|
181 |
return jContentPane; |
|
182 |
} |
|
183 |
|
|
184 |
/** |
|
185 |
* This method initializes jPanel |
|
186 |
* |
|
187 |
* @return javax.swing.JPanel |
|
188 |
*/ |
|
189 |
private ConnectionPanel getJConnPanel() { |
|
190 |
if (jConnPanel == null) { |
|
191 |
jConnPanel = new ConnectionPanel(); |
|
192 |
} |
|
193 |
return jConnPanel; |
|
194 |
} |
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
/** |
|
199 |
* This method initializes jPanel1 |
|
200 |
* |
|
201 |
* @return javax.swing.JPanel |
|
202 |
*/ |
|
203 |
private JPanel getJPanel1() { |
|
204 |
if (jPanel1 == null) { |
|
205 |
ActionListener okAction = new java.awt.event.ActionListener() { |
|
206 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
207 |
if (!jConnPanel.done()) { |
|
208 |
JOptionPane.showMessageDialog(DlgConnection.this, "No estan todos los datos rellenos", "Error", JOptionPane.ERROR_MESSAGE); |
|
209 |
return; |
|
210 |
} |
|
211 |
jConnPanel.saveConnectionSettings(); |
|
212 |
connSettings = jConnPanel.getConnectionSettings(); |
|
213 |
dispose(); |
|
214 |
} |
|
215 |
}; |
|
216 |
|
|
217 |
ActionListener cancelAction = new java.awt.event.ActionListener() { |
|
218 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
219 |
connSettings = null; |
|
220 |
dispose(); |
|
221 |
} |
|
222 |
}; |
|
223 |
jPanel1 = new AcceptCancelPanel(okAction, cancelAction); |
|
224 |
|
|
225 |
|
|
226 |
} |
|
227 |
return jPanel1; |
|
228 |
} |
|
229 |
|
|
230 |
|
|
231 |
public ConnectionSettings getConnSettings() { |
|
232 |
return connSettings; |
|
233 |
} |
|
234 |
|
|
235 |
} // @jve:decl-index=0:visual-constraint="10,10" |
|
0 | 236 |
tags/v2_0_0_Build_2020/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/DBResourceManager.java | ||
---|---|---|
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 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 IVER T.I {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
*/ |
|
31 |
package org.gvsig.geodb.vectorialdb; |
|
32 |
|
|
33 |
import org.gvsig.andami.PluginServices; |
|
34 |
import org.gvsig.fmap.dal.DALLocator; |
|
35 |
import org.gvsig.fmap.dal.resource.Resource; |
|
36 |
import org.gvsig.fmap.dal.resource.ResourceManager; |
|
37 |
import org.gvsig.fmap.dal.resource.ResourceNotification; |
|
38 |
import org.gvsig.fmap.dal.resource.db.DBParameters; |
|
39 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
|
40 |
import org.gvsig.fmap.dal.store.jdbc.JDBCResource; |
|
41 |
import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters; |
|
42 |
import org.gvsig.tools.observer.Observable; |
|
43 |
import org.gvsig.tools.observer.Observer; |
|
44 |
|
|
45 |
|
|
46 |
//TODO comentado para que compile |
|
47 |
public class DBResourceManager implements Observer { |
|
48 |
private boolean checking = false; |
|
49 |
|
|
50 |
public DBResourceManager(){ |
|
51 |
|
|
52 |
} |
|
53 |
public void update(Observable observable, Object notification) { |
|
54 |
if (!(notification instanceof ResourceNotification)) { |
|
55 |
return; |
|
56 |
} |
|
57 |
ResourceNotification resNot = (ResourceNotification) notification; |
|
58 |
if (!resNot.getType().equals(ResourceNotification.PREPARE)){ |
|
59 |
return; |
|
60 |
} |
|
61 |
if (!(resNot.getResource() instanceof JDBCResource)){ |
|
62 |
return; |
|
63 |
} |
|
64 |
JDBCResource res = (JDBCResource)resNot.getResource(); |
|
65 |
JDBCResourceParameters resPrams = (JDBCResourceParameters) resNot |
|
66 |
.getParameters(); |
|
67 |
if (!checking && resPrams.getPassword() == null) { |
|
68 |
checking = true; |
|
69 |
JPasswordDlg passwordPanel=new JPasswordDlg(); |
|
70 |
passwordPanel.setMessage(PluginServices.getText(this,"falta_por_introducir_la_clave_en_la_conexion")); |
|
71 |
PluginServices.getMDIManager().addCentredWindow(passwordPanel); |
|
72 |
resPrams.setPassword(passwordPanel.getPassword()); |
|
73 |
// TODO check if password is ok ?? |
|
74 |
// if(!res.testConnection()){ |
|
75 |
// checking=false; |
|
76 |
// try { |
|
77 |
// res.setPassword(null); |
|
78 |
// } catch (InitializeException e) { |
|
79 |
// e.printStackTrace(); |
|
80 |
// } |
|
81 |
// } |
|
82 |
// checking=false; |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
private JDBCResource getResource( |
|
87 |
DBServerExplorerParameters explorerParameters) { |
|
88 |
ResourceManager rManager = DALLocator.getResourceManager(); |
|
89 |
Resource res; |
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
return null; |
|
94 |
} |
|
95 |
|
|
96 |
private JDBCResource getResource(DBParameters storeParameters) { |
|
97 |
ResourceManager rManager = DALLocator.getResourceManager(); |
|
98 |
|
|
99 |
return null; |
|
100 |
} |
|
101 |
|
|
102 |
// public boolean isConnected(DBParameters dbParameters); |
|
103 |
// |
|
104 |
// |
|
105 |
// public boolean isConnected(DBExplorerParameters explorerParameters) { |
|
106 |
// DBResourceManager res = this.getResource(explorerParameters); |
|
107 |
// if (res == null) { |
|
108 |
// return false; |
|
109 |
// } |
|
110 |
// return res.isOpen(); |
|
111 |
// } |
|
112 |
// |
|
113 |
// public boolean isConnected(DBExplorer explorer) { |
|
114 |
// JDBCResource res = this.getResource(explorer.getParameters()); |
|
115 |
// if (res == null) { |
|
116 |
// return false; |
|
117 |
// } |
|
118 |
// return res.isOpen(); |
|
119 |
// } |
|
120 |
|
|
121 |
} |
|
122 |
|
tags/v2_0_0_Build_2020/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/ConnectionPanel.java | ||
---|---|---|
1 |
package org.gvsig.geodb.vectorialdb; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Dimension; |
|
5 |
import java.awt.FlowLayout; |
|
6 |
import java.awt.Rectangle; |
|
7 |
import java.awt.event.ActionEvent; |
|
8 |
import java.awt.event.ActionListener; |
|
9 |
import java.util.HashMap; |
|
10 |
import java.util.Iterator; |
|
11 |
|
|
12 |
import javax.swing.DefaultComboBoxModel; |
|
13 |
import javax.swing.JLabel; |
|
14 |
import javax.swing.JPanel; |
|
15 |
import javax.swing.JPasswordField; |
|
16 |
import javax.swing.JTextField; |
|
17 |
import javax.swing.SwingConstants; |
|
18 |
|
|
19 |
import org.gvsig.andami.PluginServices; |
|
20 |
import org.gvsig.fmap.dal.DALLocator; |
|
21 |
import org.gvsig.fmap.dal.DataManager; |
|
22 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
23 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
24 |
import org.gvsig.fmap.dal.resource.db.DBParameters; |
|
25 |
import org.gvsig.utils.NotExistInXMLEntity; |
|
26 |
import org.gvsig.utils.XMLEntity; |
|
27 |
import org.gvsig.utils.swing.JComboBox; |
|
28 |
import org.gvsig.utils.swing.wizard.Step; |
|
29 |
import org.gvsig.utils.swing.wizard.WizardControl; |
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
/** |
|
34 |
* DOCUMENT ME! |
|
35 |
* |
|
36 |
* @author Fernando Gonz?lez Cort?s |
|
37 |
*/ |
|
38 |
public class ConnectionPanel extends JPanel implements Step { |
|
39 |
private static String passw = null; |
|
40 |
|
|
41 |
private JPanel jPanelLabels = null; |
|
42 |
private JLabel jLabel = null; |
|
43 |
private JTextField txtHost = null; |
|
44 |
private JPanel jPanelTexts = null; |
|
45 |
private JTextField txtPort = null; |
|
46 |
private JLabel jLabel1 = null; |
|
47 |
private JLabel jLabel2 = null; |
|
48 |
private JTextField txtUser = null; |
|
49 |
private JLabel jLabel3 = null; |
|
50 |
private JPasswordField txtPassword = null; |
|
51 |
private JLabel jLabel4 = null; |
|
52 |
private JTextField txtBD = null; |
|
53 |
private JLabel jLabel5 = null; |
|
54 |
private JComboBox cmbDriver = null; |
|
55 |
private JLabel jLabel6 = null; |
|
56 |
private org.gvsig.utils.swing.JComboBox cmbName = null; |
|
57 |
private HashMap cs = new HashMap(); |
|
58 |
|
|
59 |
private JPanel jPanel = null; |
|
60 |
|
|
61 |
private JLabel jLabelSchema = null; |
|
62 |
|
|
63 |
private ConnectionPanel XYZ = null; |
|
64 |
|
|
65 |
private JPanel jPanel1 = null; |
|
66 |
|
|
67 |
private JPanel jPanelLabels1 = null; |
|
68 |
|
|
69 |
private JLabel jLabel61 = null; |
|
70 |
|
|
71 |
private JLabel jLabel7 = null; |
|
72 |
|
|
73 |
private JLabel jLabel11 = null; |
|
74 |
|
|
75 |
private JLabel jLabel21 = null; |
|
76 |
|
|
77 |
private JLabel jLabel31 = null; |
|
78 |
|
|
79 |
private JLabel jLabel51 = null; |
|
80 |
|
|
81 |
private JPanel jPanelTexts1 = null; |
|
82 |
|
|
83 |
private JComboBox cmbName1 = null; |
|
84 |
|
|
85 |
private JTextField txtHost1 = null; |
|
86 |
|
|
87 |
private JTextField txtPort1 = null; |
|
88 |
|
|
89 |
private JTextField txtUser1 = null; |
|
90 |
|
|
91 |
private JPasswordField txtPassword1 = null; |
|
92 |
|
|
93 |
private JTextField txtBD1 = null; |
|
94 |
|
|
95 |
private JComboBox cmbDriver1 = null; |
|
96 |
|
|
97 |
private JTextField txtSchema = null; |
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
/** |
|
102 |
* This is the default constructor |
|
103 |
*/ |
|
104 |
public ConnectionPanel() { |
|
105 |
super(); |
|
106 |
initialize(); |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* This method initializes this |
|
111 |
*/ |
|
112 |
private void initialize() { |
|
113 |
this.setLayout(null); |
|
114 |
this.setSize(335, 240); |
|
115 |
this.add(getJPanel(), null); |
|
116 |
|
|
117 |
if (passw != null) { |
|
118 |
txtPassword.setText(passw); |
|
119 |
} |
|
120 |
|
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* This method initializes jPanel |
|
125 |
* |
|
126 |
* @return javax.swing.JPanel |
|
127 |
*/ |
|
128 |
private JPanel getJPanelLabels() { |
|
129 |
if (jPanelLabels == null) { |
|
130 |
String string = PluginServices.getText(this, "schema") + ":"; |
|
131 |
jLabelSchema = new JLabel(); |
|
132 |
jLabelSchema.setName("jLabel4"); |
|
133 |
jLabelSchema.setHorizontalAlignment(SwingConstants.RIGHT); |
|
134 |
jLabelSchema.setHorizontalTextPosition(SwingConstants.RIGHT); |
|
135 |
jLabelSchema.setText(string); |
|
136 |
jLabelSchema.setPreferredSize(new Dimension(140, 19)); |
|
137 |
FlowLayout flowLayout3 = new FlowLayout(); |
|
138 |
flowLayout3.setVgap(15); |
|
139 |
jLabel5 = new JLabel(); |
|
140 |
jLabel4 = new JLabel(); |
|
141 |
jLabel3 = new JLabel(); |
|
142 |
jLabel2 = new JLabel(); |
|
143 |
jLabel1 = new JLabel(); |
|
144 |
jLabel = new JLabel(); |
|
145 |
jPanelLabels = new JPanel(); |
|
146 |
jPanelLabels.setLayout(flowLayout3); |
|
147 |
jPanelLabels.setName("jPanelLabels"); |
|
148 |
jPanelLabels.setPreferredSize(new java.awt.Dimension(150,400)); |
|
149 |
jLabel.setText(PluginServices.getText(this, "host") + ":"); |
|
150 |
jLabel.setPreferredSize(new java.awt.Dimension(140,19)); |
|
151 |
jLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
|
152 |
jLabel.setName("jLabel"); |
|
153 |
jLabel1.setText(PluginServices.getText(this, "puerto")+":"); |
|
154 |
jLabel1.setPreferredSize(new java.awt.Dimension(140,19)); |
|
155 |
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); |
|
156 |
jLabel1.setName("jLabel1"); |
|
157 |
jLabel2.setText(PluginServices.getText(this, "usuario")+":"); |
|
158 |
jLabel2.setName("jLabel2"); |
|
159 |
jLabel2.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
|
160 |
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
|
161 |
jLabel2.setPreferredSize(new java.awt.Dimension(140,19)); |
|
162 |
jLabel3.setText(PluginServices.getText(this, "password")+":"); |
|
163 |
jLabel3.setName("jLabel3"); |
|
164 |
jLabel3.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
|
165 |
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
|
166 |
jLabel3.setPreferredSize(new java.awt.Dimension(140,19)); |
|
167 |
jLabel4.setText(PluginServices.getText(this, "bd")+":"); |
|
168 |
jLabel4.setName("jLabel4"); |
|
169 |
jLabel4.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
|
170 |
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
|
171 |
jLabel4.setPreferredSize(new java.awt.Dimension(140,19)); |
|
172 |
jLabel5.setText(PluginServices.getText(this, "driver")+":"); |
|
173 |
jLabel5.setName("jLabel5"); |
|
174 |
jLabel5.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
|
175 |
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
|
176 |
jLabel5.setPreferredSize(new java.awt.Dimension(140,19)); |
|
177 |
jPanelLabels.add(getJLabel6(), null); |
|
178 |
jPanelLabels.add(jLabel, null); |
|
179 |
jPanelLabels.add(jLabel1, null); |
|
180 |
jPanelLabels.add(jLabel2, null); |
|
181 |
jPanelLabels.add(jLabel3, null); |
|
182 |
jPanelLabels.add(jLabel4, null); |
|
183 |
jPanelLabels.add(jLabelSchema, null); |
|
184 |
jPanelLabels.add(jLabel5, null); |
|
185 |
|
|
186 |
} |
|
187 |
|
|
188 |
return jPanelLabels; |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* This method initializes txtHost |
|
193 |
* |
|
194 |
* @return javax.swing.JTextField |
|
195 |
*/ |
|
196 |
private JTextField getTxtHost() { |
|
197 |
if (txtHost == null) { |
|
198 |
txtHost = new JTextField(); |
|
199 |
txtHost.setPreferredSize(new java.awt.Dimension(170, 19)); |
|
200 |
txtHost.setName("txtHost"); |
|
201 |
} |
|
202 |
|
|
203 |
return txtHost; |
|
204 |
} |
|
205 |
|
|
206 |
/** |
|
207 |
* This method initializes jPanel1 |
|
208 |
* |
|
209 |
* @return javax.swing.JPanel |
|
210 |
*/ |
|
211 |
private JPanel getJPanelTexts() { |
|
212 |
if (jPanelTexts == null) { |
|
213 |
FlowLayout flowLayout2 = new FlowLayout(FlowLayout.LEFT); |
|
214 |
flowLayout2.setVgap(15); |
|
215 |
jPanelTexts = new JPanel(); |
|
216 |
jPanelTexts.setLayout(flowLayout2); |
|
217 |
jPanelTexts.setPreferredSize(new Dimension(200, 300)); |
|
218 |
|
|
219 |
jPanelTexts.setName("jPanelText"); |
|
220 |
jPanelTexts.add(getCmbName(), null); |
|
221 |
jPanelTexts.add(getTxtHost(), null); |
|
222 |
jPanelTexts.add(getTxtPort(), null); |
|
223 |
jPanelTexts.add(getTxtUser(), null); |
|
224 |
jPanelTexts.add(getTxtPassword(), null); |
|
225 |
jPanelTexts.add(getTxtBD(), null); |
|
226 |
jPanelTexts.add(getTxtSchema(), null); |
|
227 |
jPanelTexts.add(getCmbDriver(), null); |
|
228 |
} |
|
229 |
|
|
230 |
return jPanelTexts; |
|
231 |
} |
|
232 |
|
|
233 |
/** |
|
234 |
* This method initializes txtPort |
|
235 |
* |
|
236 |
* @return javax.swing.JTextField |
|
237 |
*/ |
|
238 |
private JTextField getTxtPort() { |
|
239 |
if (txtPort == null) { |
|
240 |
txtPort = new JTextField(); |
|
241 |
txtPort.setPreferredSize(new java.awt.Dimension(40, 19)); |
|
242 |
txtPort.setName("txtPort"); |
|
243 |
txtPort.setText(""); |
|
244 |
txtPort.setHorizontalAlignment(javax.swing.JTextField.LEFT); |
|
245 |
} |
|
246 |
|
|
247 |
return txtPort; |
|
248 |
} |
|
249 |
|
|
250 |
/** |
|
251 |
* This method initializes txtUser |
|
252 |
* |
|
253 |
* @return javax.swing.JTextField |
|
254 |
*/ |
|
255 |
private JTextField getTxtUser() { |
|
256 |
if (txtUser == null) { |
|
257 |
txtUser = new JTextField(); |
|
258 |
txtUser.setPreferredSize(new java.awt.Dimension(170, 19)); |
|
259 |
txtUser.setName("txtUser"); |
|
260 |
} |
|
261 |
|
|
262 |
return txtUser; |
|
263 |
} |
|
264 |
|
|
265 |
/** |
|
266 |
* This method initializes txtPassword |
|
267 |
* |
|
268 |
* @return javax.swing.JTextField |
|
269 |
*/ |
|
270 |
private JPasswordField getTxtPassword() { |
|
271 |
if (txtPassword == null) { |
|
272 |
txtPassword = new JPasswordField(); |
|
273 |
txtPassword.setPreferredSize(new java.awt.Dimension(170, 19)); |
|
274 |
txtPassword.setName("txtPassword"); |
|
275 |
} |
|
276 |
|
|
277 |
return txtPassword; |
|
278 |
} |
|
279 |
|
|
280 |
/** |
|
281 |
* This method initializes txtBD |
|
282 |
* |
|
283 |
* @return javax.swing.JTextField |
|
284 |
*/ |
|
285 |
private JTextField getTxtBD() { |
|
286 |
if (txtBD == null) { |
|
287 |
txtBD = new JTextField(); |
|
288 |
txtBD.setPreferredSize(new java.awt.Dimension(170, 19)); |
|
289 |
txtBD.setName("txtBD"); |
|
290 |
} |
|
291 |
|
|
292 |
return txtBD; |
|
293 |
} |
|
294 |
|
|
295 |
/** |
|
296 |
* DOCUMENT ME! |
|
297 |
* |
|
298 |
* @return DOCUMENT ME! |
|
299 |
*/ |
|
300 |
public String getHost() { |
|
301 |
return getTxtHost().getText(); |
|
302 |
} |
|
303 |
|
|
304 |
/** |
|
305 |
* DOCUMENT ME! |
|
306 |
* |
|
307 |
* @return DOCUMENT ME! |
|
308 |
*/ |
|
309 |
public String getPort() { |
|
310 |
return getTxtPort().getText(); |
|
311 |
} |
|
312 |
|
|
313 |
/** |
|
314 |
* DOCUMENT ME! |
|
315 |
* |
|
316 |
* @return DOCUMENT ME! |
|
317 |
*/ |
|
318 |
public String getUser() { |
|
319 |
return getTxtUser().getText(); |
|
320 |
} |
|
321 |
|
|
322 |
/** |
|
323 |
* DOCUMENT ME! |
|
324 |
* |
|
325 |
* @return DOCUMENT ME! |
|
326 |
*/ |
|
327 |
public String getSettingsName() { |
|
328 |
return getCmbName().getSelectedItem().toString(); |
|
329 |
} |
|
330 |
|
|
331 |
/** |
|
332 |
* DOCUMENT ME! |
|
333 |
* |
|
334 |
* @return DOCUMENT ME! |
|
335 |
*/ |
|
336 |
public String getPassword() { |
|
337 |
passw = String.copyValueOf(getTxtPassword().getPassword()); |
|
338 |
return passw; |
|
339 |
} |
|
340 |
|
|
341 |
/** |
|
342 |
* DOCUMENT ME! |
|
343 |
* |
|
344 |
* @return DOCUMENT ME! |
|
345 |
*/ |
|
346 |
public String getDBName() { |
|
347 |
return getTxtBD().getText(); |
|
348 |
} |
|
349 |
|
|
350 |
/** |
|
351 |
* DOCUMENT ME! |
|
352 |
* |
|
353 |
* @param drivers DOCUMENT ME! |
|
354 |
*/ |
|
355 |
public void setDrivers(String[] drivers) { |
|
356 |
DefaultComboBoxModel model = new DefaultComboBoxModel(); |
|
357 |
|
|
358 |
for (int i = 0; i < drivers.length; i++) { |
|
359 |
model.addElement(drivers[i]); |
|
360 |
} |
|
361 |
|
|
362 |
getCmbDriver().setModel(model); |
|
363 |
|
|
364 |
//Para que refresque el textbox del puerto |
|
365 |
if (drivers.length > 0) { |
|
366 |
cmbDriver.setSelectedIndex(0); |
|
367 |
} |
|
368 |
|
|
369 |
} |
|
370 |
|
|
371 |
|
|
372 |
/** |
|
373 |
* @return ConnectionSettings based on values in this panel |
|
374 |
*/ |
|
375 |
public ConnectionSettings getConnectionSettings() |
|
376 |
{ |
|
377 |
ConnectionSettings cs = new ConnectionSettings(); |
|
378 |
cs.setDb(getDBName()); |
|
379 |
cs.setSchema(getSchema()); |
|
380 |
cs.setDriver(getDriver()); |
|
381 |
cs.setHost(getHost()); |
|
382 |
cs.setPort(getPort()); |
|
383 |
cs.setUser(getUser()); |
|
384 |
cs.setPassw(getPassword()); |
|
385 |
cs.setName(getSettingsName()); |
|
386 |
return cs; |
|
387 |
} |
|
388 |
|
|
389 |
public String getSchema() { |
|
390 |
return txtSchema.getText(); |
|
391 |
} |
|
392 |
|
|
393 |
/** |
|
394 |
* Makes persistent the connection settings of this panel. |
|
395 |
*/ |
|
396 |
public void saveConnectionSettings() |
|
397 |
{ |
|
398 |
ConnectionSettings cs = new ConnectionSettings(); |
|
399 |
cs.setDb(getDBName()); |
|
400 |
cs.setSchema(getSchema()); |
|
401 |
cs.setDriver(getDriver()); |
|
402 |
cs.setHost(getHost()); |
|
403 |
cs.setPort(getPort()); |
|
404 |
cs.setUser(getUser()); |
|
405 |
cs.setPassw(getPassword()); |
|
406 |
cs.setName(getSettingsName()); |
|
407 |
|
|
408 |
PluginServices ps = PluginServices.getPluginServices(this); |
|
409 |
XMLEntity xml = ps.getPersistentXML(); |
|
410 |
|
|
411 |
try { |
|
412 |
String[] connections = xml.getStringArrayProperty("jdbc-connections"); |
|
413 |
String[] newConnections = new String[connections.length + 1]; |
|
414 |
System.arraycopy(connections, 0, newConnections, 0, connections.length); |
Also available in: Unified diff