use of com.cubrid.common.ui.spi.progress.TaskJobExecutor in project cubrid-manager by CUBRID.
the class DatabaseStatusEditor method loadData.
/**
*
* Load data
*
* @return <code>true</code> whether it is successful;<code>false</code>
* otherwise
*/
public boolean loadData() {
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
@SuppressWarnings("unchecked")
@Override
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
for (ITask t : taskList) {
t.execute();
final String msg = t.getErrorMsg();
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
} else {
final DbSpaceInfoList dbSpaceInfoList = ((CommonQueryTask<? extends DbSpaceInfoList>) t).getResultModel();
Display.getDefault().syncExec(new Runnable() {
public void run() {
database.getDatabaseInfo().setDbSpaceInfoList(dbSpaceInfoList);
if (scrolledComp == null || scrolledComp.isDisposed()) {
return;
}
initial();
paintComp();
scrolledComp.setContent(parentComp);
scrolledComp.setExpandHorizontal(true);
scrolledComp.setExpandVertical(true);
}
});
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
}
return Status.OK_STATUS;
}
};
CommonQueryTask<? extends DbSpaceInfoList> task = DbSpaceInfoList.useOld(database.getServer().getServerInfo().getEnvInfo()) ? new CommonQueryTask<DbSpaceInfoListOld>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListOld()) : new CommonQueryTask<DbSpaceInfoListNew>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListNew());
task.setDbName(database.getName());
taskJobExecutor.addTask(task);
String serverName = database.getServer().getName();
String dbName = database.getName();
String jobName = Messages.viewDbStatusJobName + " - " + dbName + "@" + serverName;
taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
return true;
}
Aggregations