use of com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor in project cubrid-manager by CUBRID.
the class DeleteTableAction method doRun.
/**
* Do run
*
* @param obj
*/
private void doRun(Object[] obj) {
StringBuilder sb = new StringBuilder();
final List<String> tableList = new ArrayList<String>();
CubridDatabase database = null;
for (int i = 0; i < obj.length; i++) {
DefaultSchemaNode table = (DefaultSchemaNode) obj[i];
database = table.getDatabase();
final String tableName = table.getName();
tableList.add(tableName);
if (i < 100) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(tableName);
}
}
if (obj.length > 100) {
sb.append("...");
}
String message = Messages.bind(Messages.confirmTableDeleteWarn, sb.toString());
if (!CommonUITool.openConfirmBox(message)) {
return;
}
final DelAllRecordsTask task = new DelAllRecordsTask(database.getDatabaseInfo());
TaskJobExecutor taskExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {
public void completeAll() {
int[] rowCount = task.getDeleteRecordsCount();
List<String> rowCountList = new ArrayList<String>();
for (int i = 0; i < rowCount.length; i++) {
rowCountList.add(String.valueOf(rowCount[i]));
}
String message = Messages.bind(Messages.resultTableDeleteInformantion, tableList, rowCountList);
CommonUITool.openInformationBox(Messages.msg_information, message);
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
String[] tableNames = new String[tableList.size()];
tableNames = tableList.toArray(tableNames);
task.setTableName(tableNames);
taskExec.addTask(task);
JobFamily jobFamily = new JobFamily();
String serverName = database.getServer().getName();
String dbName = database.getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
String jobName = Messages.msgDeleteTableDataJobName + " - " + tableList.toString() + "@" + dbName + "@" + serverName;
taskExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
use of com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor 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();
}
}
use of com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor in project cubrid-manager by CUBRID.
the class DBSpaceLabelProvider method loadDbServerData.
public void loadDbServerData() {
final GetEnvInfoTask getEnvInfoTask = new GetEnvInfoTask(serverInfo);
TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {
public void completeAll() {
EnvInfo envInfo = getEnvInfoTask.loadEnvInfo();
StringBuilder sb = new StringBuilder();
if (envInfo != null) {
sb.append(" ").append(Messages.lblHost + serverInfo.getHostAddress() + ":" + serverInfo.getHostMonPort()).append(StringUtil.NEWLINE);
sb.append(" ").append(Messages.lblDBVersion + envInfo.getServerVersion()).append(StringUtil.NEWLINE);
sb.append(" ").append(Messages.lblBrokerVersion + envInfo.getBrokerVersion()).append(StringUtil.NEWLINE);
sb.append(" ").append(Messages.lblCubridPath + envInfo.getRootDir()).append(StringUtil.NEWLINE);
sb.append(" ").append(Messages.lblDBPath + envInfo.getDatabaseDir()).append(StringUtil.NEWLINE);
}
setDbServerData(sb.toString());
finishedCount++;
updateToolBar();
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
taskJobExec.addTask(getEnvInfoTask);
String serverName = serverInfo.getServerName();
String jobName = Messages.taskGetServerInfo + serverName;
JobFamily jobFamily = new JobFamily();
jobFamily.setServerName(serverName);
taskJobExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
use of com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor in project cubrid-manager by CUBRID.
the class DBSpaceLabelProvider method loadBrokerData.
public void loadBrokerData() {
BrokerInfos brokerInfos = new BrokerInfos();
final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {
public void completeAll() {
BrokerInfos brokerInfos = task.getResultModel();
List<BrokerInfo> newBrokerInfoList = null;
if (null != brokerInfos) {
BrokerInfoList list = brokerInfos.getBorkerInfoList();
if (list != null && list.getBrokerInfoList() != null) {
newBrokerInfoList = list.getBrokerInfoList();
}
}
setBrokerData(newBrokerInfoList);
finishedCount++;
updateToolBar();
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
taskJobExec.addTask(task);
String serverName = serverInfo.getServerName();
String jobName = Messages.taskGetBrokerInfo + serverName;
JobFamily jobFamily = new JobFamily();
jobFamily.setServerName(serverName);
taskJobExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
use of com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method loadServerEnvInfo.
/**
* Load Server Environment Info
*/
private void loadServerEnvInfo(final ServerInfo serverInfo, final String key) {
if (serverInfo.isConnected() == false) {
return;
}
final GetEnvInfoTask getEnvInfoTask = new GetEnvInfoTask(serverInfo);
TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {
public void completeAll() {
Object input = serviceTreeViewer.getInput();
ServiceDashboardInfo sDashInfo = getSelectedDashInfo(input, serverInfo.getServerName(), key);
EnvInfo envInfo = getEnvInfoTask.loadEnvInfo();
setEnvData(sDashInfo, envInfo);
serviceTreeViewer.refresh(input);
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
taskJobExec.addTask(getEnvInfoTask);
executeTask(taskJobExec, serverInfo.getServerName(), Messages.taskGetServerEnvInfo);
}
Aggregations