45 |
45 |
import org.gvsig.compat.net.ICancellable;
|
46 |
46 |
import org.gvsig.fmap.dal.DALLocator;
|
47 |
47 |
import org.gvsig.fmap.dal.DataManager;
|
|
48 |
import org.gvsig.fmap.dal.DataServerExplorerPool;
|
|
49 |
import org.gvsig.fmap.dal.DataServerExplorerPoolEntry;
|
48 |
50 |
import org.gvsig.fmap.dal.DataStoreParameters;
|
49 |
51 |
import org.gvsig.fmap.dal.exception.DataException;
|
50 |
52 |
import org.gvsig.fmap.dal.exception.InitializeException;
|
... | ... | |
57 |
59 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer;
|
58 |
60 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters;
|
59 |
61 |
import org.gvsig.fmap.dal.store.db.DBStoreParameters;
|
60 |
|
import org.gvsig.geodb.ExtDB_Spatial;
|
61 |
62 |
import org.gvsig.geodb.vectorialdb.wizard.MyExplorer;
|
62 |
63 |
import org.gvsig.geodb.vectorialdb.wizard.VectorialDBConnectionParamsDialog;
|
63 |
64 |
import org.gvsig.raster.postgis.io.PostGISRasterCoreException;
|
... | ... | |
168 |
169 |
* @param sel
|
169 |
170 |
*/
|
170 |
171 |
private void loadVectorialDBDatasourcesCombo(MyExplorer sel) {
|
171 |
|
JComboBox combo = apiUI.getDBCombo();
|
172 |
|
PluginsManager manager = PluginsLocator.getManager();
|
173 |
|
DynObject values = manager.getPlugin(ExtDB_Spatial.class).getPluginProperties();
|
174 |
|
Map connections = (Map) values.getDynValue("db_connections");
|
175 |
|
if (connections != null){
|
176 |
|
Iterator it = connections.entrySet().iterator();
|
|
172 |
JComboBox combo = apiUI.getDBCombo();
|
|
173 |
DataManager dataManager = DALLocator.getDataManager();
|
|
174 |
DataServerExplorerPool explorersPool = dataManager.getDataServerExplorerPool();
|
|
175 |
Iterator it = explorersPool.iterator();
|
177 |
176 |
combo.removeAllItems();
|
178 |
177 |
combo.addItem("");
|
179 |
|
while (it.hasNext()){
|
180 |
|
Map.Entry entry = (Entry) it.next();
|
|
178 |
while ( it.hasNext() ) {
|
|
179 |
DataServerExplorerPoolEntry entry = (DataServerExplorerPoolEntry) it.next();
|
181 |
180 |
MyExplorer myExplorer = new MyExplorer();
|
182 |
|
myExplorer.setDbExplorerParameters((DBServerExplorerParameters) entry.getValue());
|
183 |
|
myExplorer.setName((String) entry.getKey());
|
|
181 |
myExplorer.setDbExplorerParameters((DBServerExplorerParameters) entry.getExplorerParameters());
|
|
182 |
myExplorer.setName(entry.getName());
|
184 |
183 |
combo.addItem(myExplorer);
|
185 |
|
if(sel!=null && sel.getName().equalsIgnoreCase(myExplorer.getName())){
|
186 |
|
combo.setSelectedItem(myExplorer);
|
|
184 |
if ( sel != null && sel.getName().equalsIgnoreCase(myExplorer.getName()) ) {
|
|
185 |
combo.setSelectedItem(myExplorer);
|
187 |
186 |
}
|
188 |
187 |
}
|
189 |
|
} else {
|
190 |
|
connections = new HashMap();
|
191 |
|
values.setDynValue("db_connections", connections);
|
192 |
|
}
|
193 |
188 |
}
|
194 |
189 |
|
195 |
190 |
@Override
|
... | ... | |
346 |
341 |
*/
|
347 |
342 |
@SuppressWarnings("unchecked")
|
348 |
343 |
private MyExplorer addNewConnection() {
|
349 |
|
MyExplorer myExplorer = new MyExplorer();
|
350 |
|
DBServerExplorerParameters resp = null;
|
|
344 |
MyExplorer myExplorer = new MyExplorer();
|
|
345 |
DBServerExplorerParameters resp = null;
|
351 |
346 |
|
352 |
|
VectorialDBConnectionParamsDialog newco = new VectorialDBConnectionParamsDialog();
|
353 |
|
newco.showDialog();
|
|
347 |
VectorialDBConnectionParamsDialog newco = new VectorialDBConnectionParamsDialog();
|
|
348 |
newco.showDialog();
|
354 |
349 |
|
355 |
|
if (newco.isOkPressed()) {
|
356 |
|
try {
|
357 |
|
resp = newco.getParameters();
|
358 |
|
} catch (Exception e) {
|
359 |
|
layerLoaderManager.showConnectionErrorMessage(e.getMessage());
|
360 |
|
return null;
|
361 |
|
}
|
362 |
|
PluginsManager manager = PluginsLocator.getManager();
|
363 |
|
DynObject values = manager.getPlugin(ExtDB_Spatial.class).getPluginProperties();
|
364 |
|
Map connections = (Map) values.getDynValue("db_connections");
|
365 |
|
if(connections == null){
|
366 |
|
connections = new HashMap();
|
367 |
|
values.setDynValue("db_connections", connections);
|
368 |
|
}
|
369 |
|
connections.put(newco.getConnectionName(), resp);
|
370 |
|
|
371 |
|
myExplorer.setDbExplorerParameters(resp);
|
372 |
|
myExplorer.setName(newco.getConnectionName());
|
373 |
|
return myExplorer;
|
374 |
|
} else {
|
375 |
|
return null;
|
376 |
|
}
|
377 |
|
}
|
|
350 |
if ( !newco.isCanceled()) {
|
|
351 |
myExplorer.setDbExplorerParameters(newco.getServerExplorerParameters());
|
|
352 |
myExplorer.setName(newco.getConnectionName());
|
|
353 |
loadVectorialDBDatasourcesCombo(myExplorer);
|
|
354 |
return myExplorer;
|
|
355 |
}
|
|
356 |
return null;
|
|
357 |
}
|
378 |
358 |
|
379 |
359 |
public void valueChanged(ListSelectionEvent e) {
|
380 |
360 |
if (apiUI.isAddTableEvent(e.getSource())) {
|