Search in sources :

Example 1 with JobFamily

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);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) Point(org.eclipse.swt.graphics.Point)

Example 2 with JobFamily

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;
}
Also used : JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) Shell(org.eclipse.swt.widgets.Shell) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) IEditorReference(org.eclipse.ui.IEditorReference) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) Job(org.eclipse.core.runtime.jobs.Job)

Example 3 with JobFamily

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);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) AddVolumeDbTask(com.cubrid.cubridmanager.core.cubrid.dbspace.task.AddVolumeDbTask) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) CheckDirTask(com.cubrid.cubridmanager.core.cubrid.database.task.CheckDirTask)

Example 4 with JobFamily

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);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) GetEnvInfoTask(com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask) EnvInfo(com.cubrid.cubridmanager.core.common.model.EnvInfo)

Example 5 with JobFamily

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);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) List(java.util.List) ArrayList(java.util.ArrayList) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)

Aggregations

JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)44 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)24 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)19 ITask (com.cubrid.common.core.task.ITask)14 Job (org.eclipse.core.runtime.jobs.Job)14 ArrayList (java.util.ArrayList)12 IStatus (org.eclipse.core.runtime.IStatus)12 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)7 List (java.util.List)7 CheckDirTask (com.cubrid.cubridmanager.core.cubrid.database.task.CheckDirTask)6 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)5 CommonUpdateTask (com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)5 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)5 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)5 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)4 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)4 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 CheckFileTask (com.cubrid.cubridmanager.core.cubrid.database.task.CheckFileTask)4