Search in sources :

Example 41 with ITask

use of com.cubrid.common.core.task.ITask 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 42 with ITask

use of com.cubrid.common.core.task.ITask 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 43 with ITask

use of com.cubrid.common.core.task.ITask 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 44 with ITask

use of com.cubrid.common.core.task.ITask in project cubrid-manager by CUBRID.

the class CreateOrEditSerialDialog method createSerial.

/**
	 * Execute task and create serial
	 *
	 * @param buttonId the button id
	 */
private void createSerial(final int buttonId) {
    // FIXME move this logic to core module
    serialName = serialNameText.getText();
    final String startVal = startValText.getText();
    final String incrementVal = incrementValText.getText();
    final String minVal = minValText.getText();
    final String maxVal = maxValText.getText();
    final boolean isNoMinValue = noMinValueBtn.getSelection();
    final boolean isNoMaxValue = noMaxValueBtn.getSelection();
    final boolean isCycle = cycleButton.getSelection();
    final String cacheCount = isSupportCache ? cacheCountText.getText().trim() : null;
    final boolean isNoCache = isSupportCache ? noCacheBtn.getSelection() : false;
    if (editedNode == null) {
        taskName = Messages.bind(Messages.createSerialTaskName, serialName);
    } else {
        taskName = Messages.bind(Messages.editSerialTaskName, serialName);
    }
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
            for (ITask task : taskList) {
                if (task instanceof CreateOrEditSerialTask) {
                    CreateOrEditSerialTask createSerialTask = (CreateOrEditSerialTask) task;
                    if (editedNode == null) {
                        createSerialTask.createSerial(serialName, startVal, incrementVal, maxVal, minVal, isCycle, isNoMinValue, isNoMaxValue, cacheCount, isNoCache);
                    } else {
                        createSerialTask.editSerial(serialName, startVal, incrementVal, maxVal, minVal, isCycle, isNoMinValue, isNoMaxValue, cacheCount, isNoCache);
                    }
                }
                final String msg = task.getErrorMsg();
                if (monitor.isCanceled()) {
                    return false;
                }
                if (openErrorBox(getShell(), msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
            }
            return true;
        }
    };
    DatabaseInfo databaseInfo = database.getDatabaseInfo();
    CreateOrEditSerialTask task = new CreateOrEditSerialTask(databaseInfo);
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (taskExcutor.isSuccess()) {
        setReturnCode(buttonId);
        close();
    }
}
Also used : TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CreateOrEditSerialTask(com.cubrid.cubridmanager.core.cubrid.serial.task.CreateOrEditSerialTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)

Example 45 with ITask

use of com.cubrid.common.core.task.ITask in project cubrid-manager by CUBRID.

the class SchemaCompareDialog method buttonPressed.

/**
	 * Call this method when the button in button bar is pressed
	 *
	 * @param buttonId
	 *            the button id
	 */
protected void buttonPressed(int buttonId) {
    isCanceled = false;
    if (buttonId == COMPARE_ID) {
        if (!isSelectedAllSideDatabases()) {
            CommonUITool.openWarningBox(com.cubrid.common.ui.compare.Messages.errNeedSelectCompareDb);
            return;
        }
        if (isSelectedSameDatabases()) {
            CommonUITool.openWarningBox(com.cubrid.common.ui.compare.Messages.errSelectSameCompareDb);
            return;
        }
        final List<String> origDbLabel = new ArrayList<String>();
        for (int i = 0; i < selections.size(); i++) {
            origDbLabel.add(leftCombo.getItem(i));
        }
        final int leftIndex = leftCombo.getSelectionIndex();
        final int rightIndex = rightCombo.getSelectionIndex();
        final List<String> rightDbLabel = new ArrayList<String>();
        final List<CubridDatabase> sourceDBList = new ArrayList<CubridDatabase>();
        final List<CubridDatabase> targetDBList = new ArrayList<CubridDatabase>();
        final List<TableSchemaCompareEditorInput> editorInput = new ArrayList<TableSchemaCompareEditorInput>();
        ITask reportBugTask = new AbstractUITask() {

            public void cancel() {
                isCanceled = true;
            }

            public void finish() {
            }

            public boolean isCancel() {
                return isCanceled;
            }

            public boolean isSuccess() {
                return true;
            }

            public void execute(IProgressMonitor monitor) {
                // FIXME logic code move to core module
                CubridDatabase leftDb = (CubridDatabase) selections.get(leftIndex);
                sourceDBList.add(leftDb);
                List<TableDetailInfo> leftDbTableInfoList = TableSchemaCompareUtil.getTableInfoList(leftDb);
                TableSchemaCompareRunner thread = null;
                CubridDatabase rightDb = (CubridDatabase) selections.get(rightIndex);
                targetDBList.add(rightDb);
                rightDbLabel.add(origDbLabel.get(rightIndex));
                thread = new TableSchemaCompareRunner(SchemaCompareDialog.this, leftDb, rightDb, leftDbTableInfoList);
                thread.start();
                try {
                    thread.join();
                } catch (InterruptedException e) {
                    LOGGER.error(e.getMessage(), e);
                }
                TableSchemaCompareEditorInput input = thread.getInput();
                editorInput.add(input);
            }
        };
        TaskExecutor taskExecutor = new CommonTaskExec(Messages.titleSchemaComparison);
        taskExecutor.addTask(reportBugTask);
        new ExecTaskWithProgress(taskExecutor).exec();
        if (taskExecutor.isSuccess()) {
            for (int i = 0; i < rightDbLabel.size(); i++) {
                if (isCanceled) {
                    return;
                }
                showSchemaCompareEditor(editorInput.get(i));
            }
            if (isCanceled) {
                return;
            }
            super.buttonPressed(IDialogConstants.OK_ID);
        }
    }
    super.buttonPressed(buttonId);
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) ITask(com.cubrid.common.core.task.ITask) ArrayList(java.util.ArrayList) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) TableSchemaCompareEditorInput(com.cubrid.common.ui.compare.schema.control.TableSchemaCompareEditorInput) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) TableSchemaCompareRunner(com.cubrid.common.ui.compare.schema.TableSchemaCompareRunner)

Aggregations

ITask (com.cubrid.common.core.task.ITask)85 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)49 IStatus (org.eclipse.core.runtime.IStatus)37 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)35 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)35 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)28 ArrayList (java.util.ArrayList)27 Status (org.eclipse.core.runtime.Status)23 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)20 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)17 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)15 Map (java.util.Map)15 Display (org.eclipse.swt.widgets.Display)15 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)14 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)14 List (java.util.List)14 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)13 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)13 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)12 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)11