Search in sources :

Example 41 with TaskJobExecutor

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITask(com.cubrid.common.core.task.ITask) DbSpaceInfoListOld(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListOld) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DbSpaceInfoListNew(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListNew) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Aggregations

TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)41 IStatus (org.eclipse.core.runtime.IStatus)29 ITask (com.cubrid.common.core.task.ITask)28 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)24 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)24 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)18 Status (org.eclipse.core.runtime.Status)15 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)12 ArrayList (java.util.ArrayList)12 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)11 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)10 List (java.util.List)8 CheckDirTask (com.cubrid.cubridmanager.core.cubrid.database.task.CheckDirTask)6 CheckFileTask (com.cubrid.cubridmanager.core.cubrid.database.task.CheckFileTask)6 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)6 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)4 IEditorPart (org.eclipse.ui.IEditorPart)4 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)4 PartInitException (org.eclipse.ui.PartInitException)4 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)3