use of com.cubrid.cubridmanager.ui.cubrid.database.dialog.RenameDatabaseDialog in project cubrid-manager by CUBRID.
the class RenameDatabaseAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
final CubridDatabase database = (CubridDatabase) obj[0];
ISelectionProvider provider = this.getSelectionProvider();
final TreeViewer viewer = (TreeViewer) provider;
String serverName = database.getServer().getName();
String dbName = database.getName();
final String jobName = serverName + "-" + dbName + "-" + Messages.msgRenameDBRearJobName;
final RenameDatabaseDialog dialog = new RenameDatabaseDialog(getShell(), new ITaskExecutorInterceptor() {
public void completeAll() {
QueryOptions.removePref(database.getDatabaseInfo());
CommonUITool.openInformationBox(Messages.titleSuccess, Messages.bind(Messages.msgRenameDBComplete, jobName));
CommonUITool.refreshNavigatorTree(viewer, database.getParent());
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
dialog.setDatabase(database);
final Shell shell = getShell();
TaskExecutor taskExcutor = new TaskExecutor() {
@SuppressWarnings("unchecked")
public boolean exec(final IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return false;
}
monitor.beginTask(Messages.getDbSpaceInfoTaskName, IProgressMonitor.UNKNOWN);
for (ITask task : taskList) {
task.execute();
final String msg = task.getErrorMsg();
if (openErrorBox(shell, msg, monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
if (task instanceof CommonQueryTask) {
dbSpaceInfo = ((CommonQueryTask<DbSpaceInfoList>) task).getResultModel();
}
}
return true;
}
};
dbSpaceInfo = new DbSpaceInfoList();
CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfo);
task.setDbName(database.getLabel());
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (taskExcutor.isSuccess()) {
dialog.setDbSpaceInfoList(dbSpaceInfo);
dialog.open();
}
}
Aggregations