Search in sources :

Example 1 with GetManagerLogListTask

use of com.cubrid.cubridmanager.core.logs.task.GetManagerLogListTask in project cubrid-manager by CUBRID.

the class RemoveAllManagerLogAction method refreshLogEditor.

/**
	 *
	 * Refresh the log editor
	 *
	 * @param node ICubridNode
	 */
private void refreshLogEditor(ICubridNode node) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage activePage = window.getActivePage();
    IEditorPart editor = activePage.findEditor(node);
    if (null != editor) {
        GetManagerLogListTask task = new GetManagerLogListTask(node.getServer().getServerInfo());
        TaskExecutor taskExecutor = new CommonTaskExec(Messages.viewLogJobName);
        taskExecutor.addTask(task);
        new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
        ManagerLogInfos managerLogInfos = (ManagerLogInfos) task.getLogContent();
        try {
            editor = window.getActivePage().openEditor(node, LogEditorPart.ID);
            ((LogEditorPart) editor).setManagerLogInfo(managerLogInfos, false);
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) GetManagerLogListTask(com.cubrid.cubridmanager.core.logs.task.GetManagerLogListTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ManagerLogInfos(com.cubrid.cubridmanager.core.logs.model.ManagerLogInfos) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) LogEditorPart(com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart)

Example 2 with GetManagerLogListTask

use of com.cubrid.cubridmanager.core.logs.task.GetManagerLogListTask in project cubrid-manager by CUBRID.

the class ManagerLogViewAction method run.

/**
	 * Open the log editor and show log conent
	 */
public void run() {
    final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    if (cubridNode == null) {
        Object[] obj = this.getSelectedObj();
        if (!isSupported(obj[0])) {
            setEnabled(false);
            return;
        }
        cubridNode = (ICubridNode) obj[0];
    }
    final GetManagerLogListTask task = new GetManagerLogListTask(cubridNode.getServer().getServerInfo());
    TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {

        public IStatus exec(IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                cubridNode = null;
                return Status.CANCEL_STATUS;
            }
            for (ITask t : taskList) {
                t.execute();
                final String msg = t.getErrorMsg();
                if (monitor.isCanceled()) {
                    cubridNode = null;
                    return Status.CANCEL_STATUS;
                }
                if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
                    cubridNode = null;
                    return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
                } else {
                    Display.getDefault().syncExec(new Runnable() {

                        public void run() {
                            ManagerLogInfos managerLogInfos = (ManagerLogInfos) task.getLogContent();
                            IEditorPart editorPart = LayoutUtil.getEditorPart(cubridNode, LogEditorPart.ID);
                            if (editorPart != null) {
                                window.getActivePage().closeEditor(editorPart, false);
                            }
                            try {
                                IEditorPart editor = window.getActivePage().openEditor(cubridNode, LogEditorPart.ID);
                                ((LogEditorPart) editor).setManagerLogInfo(managerLogInfos, true);
                            } catch (PartInitException e) {
                                LOGGER.error(e.getMessage(), e);
                            }
                        }
                    });
                }
                if (monitor.isCanceled()) {
                    cubridNode = null;
                    return Status.CANCEL_STATUS;
                }
            }
            cubridNode = null;
            return Status.OK_STATUS;
        }
    };
    taskJobExecutor.addTask(task);
    String jobName = Messages.viewLogJobName + " - " + cubridNode.getName() + "@" + cubridNode.getServer().getName();
    taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITask(com.cubrid.common.core.task.ITask) ManagerLogInfos(com.cubrid.cubridmanager.core.logs.model.ManagerLogInfos) IEditorPart(org.eclipse.ui.IEditorPart) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) GetManagerLogListTask(com.cubrid.cubridmanager.core.logs.task.GetManagerLogListTask) PartInitException(org.eclipse.ui.PartInitException)

Example 3 with GetManagerLogListTask

use of com.cubrid.cubridmanager.core.logs.task.GetManagerLogListTask in project cubrid-manager by CUBRID.

the class LogEditorPart method managerConnect.

/**
	 * each page of manager log connect
	 *
	 */
public void managerConnect() {
    GetManagerLogListTask task = null;
    if (charsetName == null) {
        task = new GetManagerLogListTask(this.cubridNode.getServer().getServerInfo());
    } else {
        task = new GetManagerLogListTask(this.cubridNode.getServer().getServerInfo(), charsetName);
    }
    TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {

        public IStatus exec(IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return Status.CANCEL_STATUS;
            }
            for (final 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);
                } else {
                    Display.getDefault().asyncExec(new Runnable() {

                        public void run() {
                            GetManagerLogListTask getLogListTask = (GetManagerLogListTask) task;
                            ManagerLogInfos managerLogInfos = (ManagerLogInfos) getLogListTask.getLogContent();
                            setManagerLogInfo(managerLogInfos, false);
                        }
                    });
                }
                if (monitor.isCanceled()) {
                    return Status.CANCEL_STATUS;
                }
            }
            return Status.OK_STATUS;
        }
    };
    taskJobExecutor.addTask(task);
    String jobName = Messages.viewLogJobName + " - " + cubridNode.getName() + "@" + cubridNode.getServer().getName();
    taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITask(com.cubrid.common.core.task.ITask) GetManagerLogListTask(com.cubrid.cubridmanager.core.logs.task.GetManagerLogListTask) ManagerLogInfos(com.cubrid.cubridmanager.core.logs.model.ManagerLogInfos)

Aggregations

ManagerLogInfos (com.cubrid.cubridmanager.core.logs.model.ManagerLogInfos)3 GetManagerLogListTask (com.cubrid.cubridmanager.core.logs.task.GetManagerLogListTask)3 ITask (com.cubrid.common.core.task.ITask)2 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 IEditorPart (org.eclipse.ui.IEditorPart)2 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)2 PartInitException (org.eclipse.ui.PartInitException)2 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1 LogEditorPart (com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1