Search in sources :

Example 6 with ManagerLogInfos

use of com.cubrid.cubridmanager.core.logs.model.ManagerLogInfos 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 7 with ManagerLogInfos

use of com.cubrid.cubridmanager.core.logs.model.ManagerLogInfos in project cubrid-manager by CUBRID.

the class GetManagerLogListTask method getLogContentV1.

private ManagerLogInfos getLogContentV1() {
    TreeNode response = getResponse();
    if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
        return null;
    }
    ManagerLogInfos managerLogInfos = new ManagerLogInfos();
    for (int i = 0; i < response.childrenSize(); i++) {
        TreeNode node = response.getChildren().get(i);
        if (node != null && node.getValue("open") != null && node.getValue("open").equals("accesslog")) {
            // for
            ManagerLogInfoList managerLogList = new ManagerLogInfoList();
            String[] users = node.getValues("user");
            String[] tasknames = node.getValues("taskname");
            String[] times = node.getValues("time");
            if (users != null) {
                addLogToManagerLogList(managerLogList, users, tasknames, times);
                managerLogInfos.setAccessLog(managerLogList);
            }
        } else if (node != null && node.getValue("open") != null && node.getValue("open").equals("errorlog")) {
            // for
            ManagerLogInfoList managerLogList = new ManagerLogInfoList();
            String[] users = null;
            users = node.getValues("user");
            String[] tasknames = node.getValues("taskname");
            String[] times = node.getValues("time");
            String[] errornotes = node.getValues("errornote");
            if (users != null) {
                addLogToManagerLogList(managerLogList, users, tasknames, times, errornotes);
                managerLogInfos.setErrorLog(managerLogList);
            }
        }
    }
    return managerLogInfos;
}
Also used : TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode) ManagerLogInfos(com.cubrid.cubridmanager.core.logs.model.ManagerLogInfos) ManagerLogInfoList(com.cubrid.cubridmanager.core.logs.model.ManagerLogInfoList)

Example 8 with ManagerLogInfos

use of com.cubrid.cubridmanager.core.logs.model.ManagerLogInfos 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)8 ManagerLogInfoList (com.cubrid.cubridmanager.core.logs.model.ManagerLogInfoList)5 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 TreeNode (com.cubrid.cubridmanager.core.common.socket.TreeNode)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