Search in sources :

Example 46 with IStatus

use of org.eclipse.core.runtime.IStatus in project cubrid-manager by CUBRID.

the class CommonTaskJobExec method exec.

/**
	 * Execute the task
	 * 
	 * @param monitor the monitor
	 * @return <code>true</code>if success;<code>false</code> otherwise
	 */
public IStatus exec(IProgressMonitor monitor) {
    Display.getDefault().syncExec(new Runnable() {

        public void run() {
            setDialogVisible(false);
        }
    });
    if (monitor.isCanceled()) {
        cancel();
        Display.getDefault().syncExec(new Runnable() {

            public void run() {
                closeDialog();
            }
        });
        return Status.CANCEL_STATUS;
    }
    for (final ITask task : taskList) {
        if (task instanceof AbstractUITask) {
            ((AbstractUITask) task).execute(monitor);
        } else {
            task.execute();
        }
        final String msg = task.getErrorMsg();
        if (msg != null && msg.length() > 0 && !monitor.isCanceled() && !isCanceled()) {
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    setDialogVisible(true);
                }
            });
            return new Status(IStatus.ERROR, CommonUIPlugin.PLUGIN_ID, msg);
        } else {
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    taskExeStatus = refresh(task);
                }
            });
        }
        if (taskExeStatus != Status.OK_STATUS) {
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    setDialogVisible(true);
                }
            });
            return taskExeStatus;
        }
        if (monitor.isCanceled()) {
            cancel();
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    closeDialog();
                }
            });
            return Status.CANCEL_STATUS;
        }
    }
    return Status.OK_STATUS;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) ITask(com.cubrid.common.core.task.ITask) AbstractUITask(com.cubrid.common.core.task.AbstractUITask)

Example 47 with IStatus

use of org.eclipse.core.runtime.IStatus in project cubrid-manager by CUBRID.

the class UpdateHandler method doExecute.

protected void doExecute(LoadMetadataRepositoryJob job) {
    if (isNoRepos) {
        return;
    }
    UpdateOperation operation = getProvisioningUI().getUpdateOperation(null, null);
    // check for updates
    IStatus status = operation.resolveModal(null);
    // AUTO check update and there is not update
    if (isAutoCheckUpdate) {
        // user cancelled
        if (status.getSeverity() == IStatus.CANCEL) {
            return;
        }
        // Special case those statuses where we would never want to open a wizard
        if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
            return;
        }
        // there is no plan, so we can't continue.  Report any reason found
        if (operation.getProvisioningPlan() == null && !status.isOK()) {
            return;
        }
    }
    if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
        if (UpdateSingleIUWizard.validFor(operation)) {
            // Special case for only updating a single root
            UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(getProvisioningUI(), operation);
            WizardDialog dialog = new WizardDialog(getShell(), wizard);
            dialog.create();
            dialog.open();
        } else {
            // Open the normal version of the update wizard
            getProvisioningUI().openUpdateWizard(false, operation, job);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) UpdateOperation(org.eclipse.equinox.p2.operations.UpdateOperation) UpdateSingleIUWizard(org.eclipse.equinox.internal.p2.ui.dialogs.UpdateSingleIUWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 48 with IStatus

use of org.eclipse.core.runtime.IStatus in project cubrid-manager by CUBRID.

the class DatabaseDashboardEditor method showLogView.

/**
	 * show sql log view at broker table
	 *
	 * @param type sql type
	 */
public void showLogView(String type) {
    try {
        int i = brokerInfoTable.getSelectionIndex();
        if (i < 0) {
            return;
        }
        final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (window == null) {
            return;
        }
        String brokerName = brokerInfoTable.getItem(i).getText(0);
        String serverId = brokerInfoTable.getItem(i).getText(1);
        //get all log infor
        BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
        final CommonQueryTask<BrokerLogInfos> task = new CommonQueryTask<BrokerLogInfos>(database.getDatabaseInfo().getServerInfo(), CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
        task.setBroker(brokerName);
        task.execute();
        brokerLogInfos = task.getResultModel();
        String logFileName = brokerName + "_" + serverId + "." + type + ".log";
        sqlLogViewPartName = logFileName + "@" + database.getServer().getLabel() + ":" + database.getServer().getMonPort();
        List<LogInfo> logInfoList = brokerLogInfos == null ? null : brokerLogInfos.getBrokerLogInfoList().getLogFileInfoList();
        task.finish();
        //get the current log
        LogInfo logInfo = null;
        if (logInfoList != null && !logInfoList.isEmpty()) {
            for (LogInfo logInfoInlist : logInfoList) {
                if (logFileName.equals(logInfoInlist.getName())) {
                    logInfo = logInfoInlist;
                    break;
                }
            }
        }
        if (logInfo == null) {
            String msg = Messages.bind(com.cubrid.cubridmanager.ui.logs.Messages.errLogFileNoExist, logFileName);
            LOGGER.error(msg);
            //CommonUITool.openErrorBox(msg);
            return;
        }
        final String filePath = logInfo.getPath();
        TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {

            public IStatus exec(IProgressMonitor monitor) {
                if (monitor.isCanceled()) {
                    return Status.CANCEL_STATUS;
                }
                for (ITask task : taskList) {
                    task.execute();
                    final String msg = task.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);
                    }
                    if (task instanceof CheckFileTask) {
                        CheckFileTask checkFileTask = (CheckFileTask) task;
                        final String[] files = checkFileTask.getExistFiles();
                        if (files == null || files.length == 0) {
                            return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, Messages.bind(com.cubrid.cubridmanager.ui.logs.Messages.errLogFileNoExist, filePath));
                        }
                    } else if (task instanceof GetLogListTask) {
                        GetLogListTask getLogListTask = (GetLogListTask) task;
                        final LogContentInfo logContentInfo = (LogContentInfo) getLogListTask.getLogContent();
                        Display.getDefault().syncExec(new Runnable() {

                            public void run() {
                                try {
                                    ICubridNode logInfoNode = new DefaultCubridNode("", "", "");
                                    IEditorPart editor = window.getActivePage().openEditor(logInfoNode, LogEditorPart.ID);
                                    ((LogEditorPart) editor).setTableInfo(logContentInfo, true);
                                    ((LogEditorPart) editor).setShowLogPartName(sqlLogViewPartName);
                                } catch (PartInitException e) {
                                    LOGGER.error(e.getMessage(), e);
                                }
                            }
                        });
                    }
                    if (monitor.isCanceled()) {
                        return Status.CANCEL_STATUS;
                    }
                    task.finish();
                }
                return Status.OK_STATUS;
            }
        };
        CheckFileTask checkFileTask = new CheckFileTask(cubridNode.getServer().getServerInfo());
        checkFileTask.setFile(new String[] { filePath });
        taskJobExecutor.addTask(checkFileTask);
        GetLogListTask getLogListTask = new GetLogListTask(cubridNode.getServer().getServerInfo());
        getLogListTask.setPath(filePath);
        getLogListTask.setStart("1");
        getLogListTask.setEnd("100");
        taskJobExecutor.addTask(getLogListTask);
        String jobName = com.cubrid.cubridmanager.ui.logs.Messages.viewLogJobName + " - " + cubridNode.getName() + "@" + cubridNode.getServer().getName();
        taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
    } catch (Exception e) {
        LOGGER.error(Messages.exportDashboardOpenSQLLogErrMsg, e);
    //			CommonUITool.openErrorBox(Messages.exportDashboardOpenSQLLogErrMsg);
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITask(com.cubrid.common.core.task.ITask) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) BrokerLogInfos(com.cubrid.cubridmanager.core.logs.model.BrokerLogInfos) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) GetLogListTask(com.cubrid.cubridmanager.core.logs.task.GetLogListTask) PartInitException(org.eclipse.ui.PartInitException) CheckFileTask(com.cubrid.cubridmanager.core.cubrid.database.task.CheckFileTask) LogEditorPart(com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart)

Example 49 with IStatus

use of org.eclipse.core.runtime.IStatus in project cubrid-manager by CUBRID.

the class VolumeFolderInfoEditor method loadData.

/**
	 * load the editor data
	 *
	 * @return boolean
	 */
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 model = ((CommonQueryTask<? extends DbSpaceInfoList>) t).getResultModel();
                    Display.getDefault().syncExec(new Runnable() {

                        public void run() {
                            database.getDatabaseInfo().setDbSpaceInfoList(model);
                            if (scrolledComp == null || scrolledComp.isDisposed()) {
                                return;
                            }
                            initialize();
                            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.viewVolumeInfoJobName + " - " + volumeFolderName + "@" + dbName + "@" + serverName;
    taskJobExecutor.schedule(jobName, null, false, Job.LONG);
    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)

Example 50 with IStatus

use of org.eclipse.core.runtime.IStatus in project cubrid-manager by CUBRID.

the class VolumeInformationEditor method loadData.

/**
	 * load the data
	 *
	 * @return boolean
	 */
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 model = ((CommonQueryTask<? extends DbSpaceInfoList>) t).getResultModel();
                    Display.getDefault().syncExec(new Runnable() {

                        public void run() {
                            database.getDatabaseInfo().setDbSpaceInfoList(model);
                            if (scrolledComp == null || scrolledComp.isDisposed()) {
                                return;
                            }
                            initial();
                            paintComp();
                            scrolledComp.setContent(parentComp);
                            scrolledComp.setExpandHorizontal(true);
                            scrolledComp.setExpandVertical(true);
                            scrolledComp.setMinHeight(800);
                            scrolledComp.setMinWidth(800);
                        }
                    });
                }
                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 jobName = Messages.viewVolumeInfoJobName + " - " + dbSpaceInfo.getSpacename() + "@" + database.getName() + "@" + database.getServer().getName();
    taskJobExecutor.schedule(jobName, null, false, Job.LONG);
    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

IStatus (org.eclipse.core.runtime.IStatus)1423 Status (org.eclipse.core.runtime.Status)500 CoreException (org.eclipse.core.runtime.CoreException)369 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)270 File (java.io.File)169 IOException (java.io.IOException)154 ArrayList (java.util.ArrayList)141 IPath (org.eclipse.core.runtime.IPath)138 IFile (org.eclipse.core.resources.IFile)130 Job (org.eclipse.core.runtime.jobs.Job)123 MultiStatus (org.eclipse.core.runtime.MultiStatus)113 InvocationTargetException (java.lang.reflect.InvocationTargetException)106 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)85 IProject (org.eclipse.core.resources.IProject)84 List (java.util.List)83 Path (org.eclipse.core.runtime.Path)52 Test (org.junit.Test)52 IResource (org.eclipse.core.resources.IResource)51 SubMonitor (org.eclipse.core.runtime.SubMonitor)51 Composite (org.eclipse.swt.widgets.Composite)44