Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extGeoDB / src / com / iver / cit / gvsig / vectorialdb / DBResourceManager.java @ 27723

History | View | Annotate | Download (3.53 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.resource.Resource;
35
import org.gvsig.fmap.dal.resource.ResourceManager;
36
import org.gvsig.fmap.dal.resource.ResourceNotification;
37
import org.gvsig.fmap.dal.resource.db.DBParameters;
38
import org.gvsig.fmap.dal.store.jdbc.JDBCResource;
39
import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters;
40
import org.gvsig.fmap.data.feature.db.DBExplorerParameters;
41
import org.gvsig.tools.observer.Observable;
42
import org.gvsig.tools.observer.Observer;
43

    
44
import com.iver.andami.PluginServices;
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(DBExplorerParameters explorerParameters) {
87
                ResourceManager rManager = DALLocator.getResourceManager();
88
                Resource res;
89

    
90

    
91

    
92
                return null;
93
        }
94

    
95
        private JDBCResource getResource(DBParameters storeParameters) {
96
                ResourceManager rManager = DALLocator.getResourceManager();
97

    
98
                return null;
99
        }
100

    
101
//        public boolean isConnected(DBParameters dbParameters);
102
//
103
//
104
//        public boolean isConnected(DBExplorerParameters explorerParameters) {
105
//                DBResourceManager res = this.getResource(explorerParameters);
106
//                if (res == null) {
107
//                        return false;
108
//                }
109
//                return res.isOpen();
110
//        }
111
//
112
//        public boolean isConnected(DBExplorer explorer) {
113
//                JDBCResource res = this.getResource(explorer.getParameters());
114
//                if (res == null) {
115
//                        return false;
116
//                }
117
//                return res.isOpen();
118
//        }
119

    
120
}
121