use of com.cubrid.common.ui.spi.progress.TaskJobExecutor in project cubrid-manager by CUBRID.
the class AddVolumeDialog method performTask.
/**
* perform the task
*
* @param addVolumeDbInfo AddVolumeDbInfo
*/
private void performTask(AddVolumeDbInfo addVolumeDbInfo) {
// Checks the path
String sPathText = pathText.getText().trim();
ServerInfo serverInfo = selection.getServer().getServerInfo();
CheckDirTask checkDirTask = new CheckDirTask(serverInfo);
checkDirTask.setDirectory(new String[] { sPathText });
CubridDatabase database = selection.getDatabase();
AddVolumeDbTask addVolumeTask = new AddVolumeDbTask(database.getServer().getServerInfo());
addVolumeTask.setDbname(database.getName());
addVolumeTask.setVolname(addVolumeDbInfo.getVolname());
addVolumeTask.setPurpose(addVolumeDbInfo.getPurpose());
addVolumeTask.setPath(addVolumeDbInfo.getPath());
addVolumeTask.setNumberofpages(addVolumeDbInfo.getNumberofpage());
addVolumeTask.setSizeNeedMb(addVolumeDbInfo.getSize_need_mb());
// Gets the database space info
DbSpaceInfoList dbSpaceInfo = new DbSpaceInfoList();
final CommonQueryTask<DbSpaceInfoList> dbSpaceInfoTask = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfo);
dbSpaceInfoTask.setDbName(database.getLabel());
JobFamily jobFamily = new JobFamily();
String serverName = selection.getServer().getName();
String dbName = selection.getDatabase().getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
jobName = Messages.msgAddVolRearJobName + " - " + dbName + "@" + serverName;
TaskJobExecutor taskExec = new CommonTaskJobExec(this);
taskExec.addTask(checkDirTask);
taskExec.addTask(addVolumeTask);
taskExec.addTask(dbSpaceInfoTask);
taskExec.schedule(dbName, jobFamily, true, Job.SHORT);
}
use of com.cubrid.common.ui.spi.progress.TaskJobExecutor in project cubrid-manager by CUBRID.
the class VolumeFolderInfoEditor method loadData.
/**
* load the editor data
*
* @return boolean
*/
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 model = ((CommonQueryTask<? extends DbSpaceInfoList>) t).getResultModel();
Display.getDefault().syncExec(new Runnable() {
public void run() {
database.getDatabaseInfo().setDbSpaceInfoList(model);
if (scrolledComp == null || scrolledComp.isDisposed()) {
return;
}
initialize();
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.viewVolumeInfoJobName + " - " + volumeFolderName + "@" + dbName + "@" + serverName;
taskJobExecutor.schedule(jobName, null, false, Job.LONG);
return true;
}
use of com.cubrid.common.ui.spi.progress.TaskJobExecutor in project cubrid-manager by CUBRID.
the class VolumeInformationEditor method loadData.
/**
* load the data
*
* @return boolean
*/
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 model = ((CommonQueryTask<? extends DbSpaceInfoList>) t).getResultModel();
Display.getDefault().syncExec(new Runnable() {
public void run() {
database.getDatabaseInfo().setDbSpaceInfoList(model);
if (scrolledComp == null || scrolledComp.isDisposed()) {
return;
}
initial();
paintComp();
scrolledComp.setContent(parentComp);
scrolledComp.setExpandHorizontal(true);
scrolledComp.setExpandVertical(true);
scrolledComp.setMinHeight(800);
scrolledComp.setMinWidth(800);
}
});
}
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 jobName = Messages.viewVolumeInfoJobName + " - " + dbSpaceInfo.getSpacename() + "@" + database.getName() + "@" + database.getServer().getName();
taskJobExecutor.schedule(jobName, null, false, Job.LONG);
return true;
}
use of com.cubrid.common.ui.spi.progress.TaskJobExecutor 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.TaskJobExecutor 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);
}
Aggregations