use of com.cubrid.common.ui.spi.progress.JobFamily in project cubrid-manager by CUBRID.
the class PstmtSQLDialog method updateData.
/**
* Update the data
*
* @param parameterList List<PstmtParameter>
*/
private void updateData(List<List<PstmtParameter>> jobList) {
beginTimestamp = System.currentTimeMillis();
String jobName = Messages.executeSqlJobName;
JobFamily jobFamily = new JobFamily();
String serverName = database.getServer().getServerInfo().getServerName();
String dbName = database.getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
TaskJobExecutor taskExec = new CommonTaskJobExec(this);
for (int i = 0; i < jobList.size(); i++) {
List<PstmtParameter> parameterList = jobList.get(i);
PstmtDataTask task = new PstmtDataTask(sqlTxt.getText(), database, parameterList, null, i + 1);
taskExec.addTask(task);
}
taskExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
use of com.cubrid.common.ui.spi.progress.JobFamily in project cubrid-manager by CUBRID.
the class ApplicationWorkbenchWindowAdvisor method preWindowShellClose.
/**
* Performs arbitrary actions as the window's shell is being closed
* directly, and possibly veto the close.
*
* @return <code>true</code> to allow the window to close, and
* <code>false</code> to prevent the window from closing
* @see org.eclipse.ui.IWorkbenchWindow#close
* @see WorkbenchAdvisor#preShutdown()
*/
public boolean preWindowShellClose() {
Shell shell = getWindowConfigurer().getWindow().getShell();
GeneralPreference.setMaximizeWindowOnStartUp(shell.getMaximized());
if (timer != null) {
timer.cancel();
HeartBeatTaskManager.getInstance().cancel();
}
/*Close the information window*/
InfoWindowManager.dispose();
/*All opened queryEditor*/
List<QueryEditorPart> editorPartList = QueryEditorUtil.getAllQueryEditorPart();
boolean isNeedSaveQueryEditor = isNeedSaveQueryEditor(editorPartList);
boolean hasJobRunning = false;
final JobFamily jobFamily = new JobFamily();
jobFamily.setServerName(JobFamily.ALL_SERVER);
Job[] jobs = Job.getJobManager().find(jobFamily);
if (jobs.length > 0) {
hasJobRunning = true;
}
boolean isExit = false;
if (hasJobRunning) {
isExit = CommonUITool.openConfirmBox(getWindowConfigurer().getWindow().getShell(), Messages.msgExistConfirmWithJob);
if (isExit) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
try {
Job.getJobManager().cancel(jobFamily);
} catch (Exception e) {
LOGGER.error("Stopping background jobs was failed.", e);
}
}
});
if (isNeedSaveQueryEditor) {
processSaveQueryEditor();
}
}
} else {
if (isNeedSaveQueryEditor) {
processSaveQueryEditor();
return true;
} else {
if (GeneralPreference.isAlwaysExit()) {
return true;
}
MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(getWindowConfigurer().getWindow().getShell(), com.cubrid.common.ui.common.Messages.titleExitConfirm, Messages.msgExistConfirm, com.cubrid.common.ui.common.Messages.msgToggleExitConfirm, false, CommonUIPlugin.getDefault().getPreferenceStore(), GeneralPreference.IS_ALWAYS_EXIT);
isExit = dialog.getReturnCode() == 0 ? true : false;
}
}
if (isExit) {
for (List<IEditorReference> list : perspectiveEditorMap.values()) {
IEditorReference[] references = new IEditorReference[list.size()];
list.toArray(references);
getWindowConfigurer().getWindow().getActivePage().closeEditors(references, false);
}
}
return isExit;
}
use of com.cubrid.common.ui.spi.progress.JobFamily 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.JobFamily 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.JobFamily 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