use of com.cubrid.cubridquery.ui.connection.dialog.RenameConnectionDialog in project cubrid-manager by CUBRID.
the class RenameConnectionAction method doRun.
/**
* Perform rename Table
*
* @param cubridDatabase
* @param table
*/
private void doRun(CubridDatabase database) {
RenameConnectionDialog dlg = new RenameConnectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), database);
int ret = dlg.open();
if (ret == IDialogConstants.OK_ID) {
/*Fire the database logout*/
try {
CubridDatabase orignDatabase = database.clone();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(orignDatabase, CubridNodeChangedEventType.DATABASE_LOGOUT));
} catch (CloneNotSupportedException e) {
LOGGER.error(e.getMessage());
}
database.setLabel(dlg.getNewName());
database.setLogined(false);
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer == null) {
LOGGER.error("Error: Can't find the navigator view:" + CubridQueryNavigatorView.ID);
return;
}
// Refresh the tree view
database.removeAllChild();
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
setEnabled(false);
// Save the data
ServerInfo preServerInfo = (database == null || database.getServer() == null) ? null : database.getServer().getServerInfo();
QueryOptions.removePref(preServerInfo);
CQBGroupNodePersistManager.getInstance().saveAllGroupNode();
CQBDBNodePersistManager.getInstance().saveDatabases();
ActionManager.getInstance().fireSelectionChanged(getSelection());
LayoutManager.getInstance().fireSelectionChanged(getSelection());
}
}
Aggregations