svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / vectorialdb / DBResourceManager.java @ 25089
History | View | Annotate | Download (3.3 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2008 IVER T.I {{Task}}
|
26 |
*/
|
27 |
|
28 |
/**
|
29 |
*
|
30 |
*/
|
31 |
package com.iver.cit.gvsig.vectorialdb; |
32 |
|
33 |
import org.gvsig.fmap.dal.DALLocator; |
34 |
import org.gvsig.fmap.dal.exception.InitializeException; |
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.tools.observer.Observable; |
39 |
import org.gvsig.tools.observer.Observer; |
40 |
|
41 |
import com.iver.andami.PluginServices; |
42 |
|
43 |
//TODO comentado para que compile
|
44 |
public class DBResourceManager implements Observer { |
45 |
private boolean checking = false; |
46 |
|
47 |
public DBResourceManager(){
|
48 |
|
49 |
} |
50 |
public void update(Observable observable, Object notification) { |
51 |
if (!(notification instanceof ResourceNotification)) { |
52 |
return;
|
53 |
} |
54 |
ResourceNotification resNot = (ResourceNotification) notification; |
55 |
if (!resNot.getType().equals(ResourceNotification.PREPARE)){
|
56 |
return;
|
57 |
} |
58 |
if (!(resNot.getResource() instanceof JDBCResource)){ |
59 |
return;
|
60 |
} |
61 |
JDBCResource res = (JDBCResource)resNot.getResource(); |
62 |
if (!checking && res.getPassword()== null){ |
63 |
checking = true;
|
64 |
JPasswordDlg passwordPanel=new JPasswordDlg();
|
65 |
passwordPanel.setMessage(PluginServices.getText(this,"falta_por_introducir_la_clave_en_la_conexion")); |
66 |
PluginServices.getMDIManager().addCentredWindow(passwordPanel); |
67 |
try {
|
68 |
res.setPassword(passwordPanel.getPassword()); |
69 |
} catch (InitializeException e) {
|
70 |
throw new RuntimeException(e); |
71 |
} |
72 |
if(!res.testConnection()){
|
73 |
checking=false;
|
74 |
try {
|
75 |
res.setPassword(null);
|
76 |
} catch (InitializeException e) {
|
77 |
e.printStackTrace(); |
78 |
} |
79 |
} |
80 |
checking=false;
|
81 |
} |
82 |
} |
83 |
|
84 |
private JDBCResource getResource(DBExplorerParameters explorerParameters) {
|
85 |
ResourceManager rManager = DALLocator.getResourceManager(); |
86 |
Resource res; |
87 |
|
88 |
|
89 |
|
90 |
return null; |
91 |
} |
92 |
|
93 |
private JDBCResource getResource(DBParameters storeParameters) {
|
94 |
ResourceManager rManager = DALLocator.getResourceManager(); |
95 |
|
96 |
return null; |
97 |
} |
98 |
|
99 |
// public boolean isConnected(DBParameters dbParameters);
|
100 |
//
|
101 |
//
|
102 |
// public boolean isConnected(DBExplorerParameters explorerParameters) {
|
103 |
// DBResourceManager res = this.getResource(explorerParameters);
|
104 |
// if (res == null) {
|
105 |
// return false;
|
106 |
// }
|
107 |
// return res.isOpen();
|
108 |
// }
|
109 |
//
|
110 |
// public boolean isConnected(DBExplorer explorer) {
|
111 |
// JDBCResource res = this.getResource(explorer.getParameters());
|
112 |
// if (res == null) {
|
113 |
// return false;
|
114 |
// }
|
115 |
// return res.isOpen();
|
116 |
// }
|
117 |
|
118 |
} |
119 |
|