Search in sources :

Example 6 with ITaskExecutorInterceptor

use of com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor in project cubrid-manager by CUBRID.

the class ServiceDashboardEditor method loadServerDbInfo.

/**
	 * Load Server Database Info
	 */
private void loadServerDbInfo(final ServerInfo serverInfo, final String key) {
    if (serverInfo.isConnected() == false) {
        return;
    }
    final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
    TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            Object input = serviceTreeViewer.getInput();
            ServiceDashboardInfo sDashInfo = getSelectedDashInfo(input, serverInfo.getServerName(), key);
            List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
            setDbData(sDashInfo, databaseInfoList);
            serviceTreeViewer.refresh(input);
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    taskJobExec.addTask(getDatabaseListTask);
    executeTask(taskJobExec, serverInfo.getServerName(), Messages.taskGetServerDbInfo);
}
Also used : GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) 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) 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)

Example 7 with ITaskExecutorInterceptor

use of com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor in project cubrid-manager by CUBRID.

the class ServiceDashboardEditor method loadServerVolumeData.

/**
	 * Load Server Volume Info
	 */
private void loadServerVolumeData(final ServerInfo serverInfo, final String key) {
    List<String> dbList = serverInfo.getAllDatabaseList();
    if (dbList == null || dbList.size() == 0) {
        return;
    }
    final List<CommonQueryTask<DbSpaceInfoList>> getVolumnTaskList = new ArrayList<CommonQueryTask<DbSpaceInfoList>>();
    for (String dbname : dbList) {
        CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
        task.setDbName(dbname);
        getVolumnTaskList.add(task);
    }
    TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            Object input = serviceTreeViewer.getInput();
            ServiceDashboardInfo sDashInfo = getSelectedDashInfo(input, serverInfo.getServerName(), key);
            setVolumeData(sDashInfo, getVolumnTaskList);
            serviceTreeViewer.refresh(input);
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    for (CommonQueryTask<DbSpaceInfoList> task : getVolumnTaskList) {
        taskJobExec.addTask(task);
    }
    executeTask(taskJobExec, serverInfo.getServerName(), Messages.taskGetServerVolumeInfo);
}
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) ArrayList(java.util.ArrayList) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Example 8 with ITaskExecutorInterceptor

use of com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor in project cubrid-manager by CUBRID.

the class ServiceDashboardEditor method loadServerHostInfo.

/**
	 * Load Server Host Info
	 */
private void loadServerHostInfo(final ServerInfo serverInfo, final String key) {
    final CommonQueryTask<HostStatData> task = new CommonQueryTask<HostStatData>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), new HostStatData());
    TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            Object input = serviceTreeViewer.getInput();
            ServiceDashboardInfo sDashInfo = getSelectedDashInfo(input, serverInfo.getServerName(), key);
            HostStatData hostInfo = task.getResultModel();
            setHostData(sDashInfo, hostInfo);
            serviceTreeViewer.refresh(input);
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    taskJobExec.addTask(task);
    executeTask(taskJobExec, serverInfo.getServerName(), Messages.taskGetServerHostInfo);
}
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) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) HostStatData(com.cubrid.cubridmanager.core.monitoring.model.HostStatData)

Example 9 with ITaskExecutorInterceptor

use of com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor in project cubrid-manager by CUBRID.

the class DBAuthComparator method loadData.

/**
	 * Load the data
	 */
private void loadData() {
    final GetUserListTask getUserTask = new GetUserListTask(database.getDatabaseInfo());
    final GetAllUserAuthorizationsTask getUserAuthTask = new GetAllUserAuthorizationsTask(database.getDatabaseInfo());
    TaskJobExecutor taskExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            final List<UserDetailInfo> userDetailList = new ArrayList<UserDetailInfo>();
            DbUserInfoList userListInfo = getUserTask.getResultModel();
            Map<String, UserDetailInfo> allUserAuthMap = getUserAuthTask.getAllAuthMap();
            if (userListInfo != null) {
                for (DbUserInfo userInfo : userListInfo.getUserList()) {
                    UserDetailInfo userDetailInfo = allUserAuthMap.get(userInfo.getName());
                    if (userDetailInfo == null) {
                        userDetailInfo = new UserDetailInfo();
                        userDetailInfo.setUserName(userInfo.getName());
                    }
                    userDetailList.add(userDetailInfo);
                }
            }
            setTableData(userDetailList);
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    taskExec.addTask(getUserTask);
    taskExec.addTask(getUserAuthTask);
    JobFamily jobFamily = new JobFamily();
    String serverName = database.getServer().getName();
    String dbName = database.getName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    String jobName = Messages.jobLoadUserData + " - " + "@" + dbName + "@" + serverName;
    taskExec.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) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) GetAllUserAuthorizationsTask(com.cubrid.cubridmanager.core.cubrid.user.task.GetAllUserAuthorizationsTask) GetUserListTask(com.cubrid.cubridmanager.core.cubrid.user.task.GetUserListTask) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) List(java.util.List) ArrayList(java.util.ArrayList) DbUserInfoList(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList) DbUserInfoList(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList) Map(java.util.Map) UserDetailInfo(com.cubrid.cubridmanager.core.cubrid.user.model.UserDetailInfo)

Example 10 with ITaskExecutorInterceptor

use of com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor in project cubrid-manager by CUBRID.

the class TruncateTableAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj)) {
        setEnabled(false);
        return;
    }
    StringBuilder sb = new StringBuilder();
    int len = obj.length;
    final List<String> tableList = new ArrayList<String>();
    CubridDatabase database = null;
    for (int i = 0; i < len; i++) {
        ISchemaNode table = (ISchemaNode) obj[i];
        database = table.getDatabase();
        final String tableName = table.getName();
        tableList.add(tableName);
        if (i < 100) {
            if (sb.length() > 0) {
                sb.append(", ");
            }
            sb.append(tableName);
        }
    }
    if (len > 100) {
        sb.append("...");
    }
    String message = Messages.bind(Messages.confirmTableDeleteWarn, sb.toString());
    if (!CommonUITool.openConfirmBox(message)) {
        return;
    }
    final TruncateTableTask task = new TruncateTableTask(database.getDatabaseInfo());
    TaskJobExecutor taskExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            CommonUITool.openInformationBox(Messages.msg_information, Messages.resultTableDeleteInformantion);
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    String[] tableNames = new String[tableList.size()];
    tableNames = tableList.toArray(tableNames);
    task.setTableName(tableNames);
    taskExec.addTask(task);
    JobFamily jobFamily = new JobFamily();
    String serverName = database.getServer().getName();
    String dbName = database.getName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    String jobName = Messages.msgTruncateTableJobName + " - " + tableList.toString() + "@" + dbName + "@" + serverName;
    taskExec.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) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) ArrayList(java.util.ArrayList) TruncateTableTask(com.cubrid.cubridmanager.core.cubrid.table.task.TruncateTableTask) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

ITask (com.cubrid.common.core.task.ITask)13 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)13 IStatus (org.eclipse.core.runtime.IStatus)13 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)12 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)12 ArrayList (java.util.ArrayList)8 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)7 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)6 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)6 List (java.util.List)6 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)4 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)3 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)2 EnvInfo (com.cubrid.cubridmanager.core.common.model.EnvInfo)2 GetEnvInfoTask (com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)2 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)2 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1