460 |
460 |
}
|
461 |
461 |
DataManager dm = DALLocator.getDataManager();
|
462 |
462 |
String err_msg = Messages.getText("connection_error");
|
463 |
|
DBServerExplorer dbExplorer;
|
|
463 |
DBServerExplorer dbExplorer = null;
|
464 |
464 |
try {
|
465 |
465 |
dbExplorer = (DBServerExplorer) dm.openServerExplorer(dbSeverExplorerParameters2.getExplorerName(), dbSeverExplorerParameters2);
|
466 |
466 |
|
... | ... | |
480 |
480 |
getTablesList().setModel(lmodel);
|
481 |
481 |
getTablesScrollPane().setViewportView(tablesList);
|
482 |
482 |
tablesScrollPane.updateUI();
|
483 |
|
} catch (InitializeException e) {
|
484 |
|
logger.info("Error while getting table names: " + e.getMessage(), e);
|
485 |
|
ApplicationLocator.getManager().messageDialog(
|
486 |
|
err_msg + ": " + e.getMessage(),
|
|
483 |
} catch (Exception e) {
|
|
484 |
logger.info("Error while getting table names: " + e.getMessage());
|
|
485 |
|
|
486 |
String remove_question = Messages.getText(
|
|
487 |
"_Remove_connection_parameters_from_list_question");
|
|
488 |
|
|
489 |
int opt = JOptionPane.showConfirmDialog(
|
|
490 |
ApplicationLocator.getManager().getRootComponent(),
|
|
491 |
err_msg + ": " + getLastMessage(e) + "\n" + remove_question,
|
487 |
492 |
err_msg,
|
488 |
|
JOptionPane.ERROR_MESSAGE);
|
489 |
|
return;
|
490 |
|
} catch (DataException e) {
|
491 |
|
logger.info("Error while getting table names: " + e.getMessage(), e);
|
492 |
|
ApplicationLocator.getManager().messageDialog(
|
493 |
|
err_msg + ": " + e.getMessage(),
|
494 |
|
err_msg,
|
495 |
|
JOptionPane.ERROR_MESSAGE);
|
496 |
|
return;
|
497 |
|
} catch (Exception e) {
|
498 |
|
logger.info("Error while getting table names: " + e.getMessage(), e);
|
499 |
|
ApplicationLocator.getManager().messageDialog(
|
500 |
|
err_msg + ": " + e.getMessage(),
|
501 |
|
err_msg,
|
502 |
|
JOptionPane.ERROR_MESSAGE);
|
503 |
|
return;
|
|
493 |
JOptionPane.YES_NO_OPTION);
|
|
494 |
|
|
495 |
if (opt == JOptionPane.YES_OPTION) {
|
|
496 |
removeDBPArameters(dbSeverExplorerParameters2);
|
|
497 |
// dbExplorer.
|
|
498 |
loadVectorialDBDatasourcesCombo(null);
|
|
499 |
}
|
504 |
500 |
}
|
505 |
501 |
}
|
506 |
502 |
|
507 |
|
public void valueChanged(ListSelectionEvent arg0) {
|
|
503 |
/**
|
|
504 |
* Removes DB parameters from list of pre-configured DB parameters
|
|
505 |
* @param dbSeverExplorerParameters2
|
|
506 |
*/
|
|
507 |
private void removeDBPArameters(
|
|
508 |
DBServerExplorerParameters dbparams) {
|
|
509 |
|
|
510 |
PluginsManager manager = PluginsLocator.getManager();
|
|
511 |
DynObject values = manager.getPlugin(ExtDB_Spatial.class).getPluginProperties();
|
|
512 |
Map connections = (Map) values.getDynValue("db_connections");
|
|
513 |
if (connections == null) {
|
|
514 |
return;
|
|
515 |
}
|
|
516 |
|
|
517 |
DBServerExplorerParameters item = null;
|
|
518 |
Iterator it = connections.entrySet().iterator();
|
|
519 |
List<String> toremove = new ArrayList();
|
|
520 |
|
|
521 |
while (it.hasNext()) {
|
|
522 |
Map.Entry entry = (Entry) it.next();
|
|
523 |
item = (DBServerExplorerParameters) entry.getValue();
|
|
524 |
if (dbparams.equals(item)) {
|
|
525 |
toremove.add((String) entry.getKey());
|
|
526 |
}
|
|
527 |
}
|
|
528 |
|
|
529 |
if (toremove.size() == 0) {
|
|
530 |
return;
|
|
531 |
}
|
|
532 |
|
|
533 |
for (int i=0; i<toremove.size(); i++) {
|
|
534 |
connections.remove(toremove.get(i));
|
|
535 |
}
|
|
536 |
values.setDynValue("db_connections", connections);
|
|
537 |
|
|
538 |
}
|
|
539 |
|
|
540 |
|
|
541 |
public void valueChanged(ListSelectionEvent arg0) {
|
508 |
542 |
Object src = arg0.getSource();
|
509 |
543 |
|
510 |
544 |
if (src == tablesList) {
|
... | ... | |
687 |
721 |
public void close() {
|
688 |
722 |
// Nothing to do
|
689 |
723 |
}
|
|
724 |
|
690 |
725 |
|
|
726 |
protected String getLastMessage(Throwable ex) {
|
|
727 |
|
|
728 |
Throwable p = ex;
|
|
729 |
while (p.getCause() != null && p.getCause() != p) {
|
|
730 |
p = p.getCause();
|
|
731 |
}
|
|
732 |
return p.getMessage();
|
|
733 |
}
|
|
734 |
|
691 |
735 |
} // @jve:decl-index=0:visual-constraint="10,10"
|