Search in sources :

Example 1 with LogContentInfo

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

the class GetLogListTask method getLogContent.

/**
	 * get result from the response.
	 * 
	 * @return LogContentInfo
	 */
public LogContentInfo getLogContent() {
    TreeNode response = getResponse();
    if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
        return null;
    }
    LogContentInfo logContentInfo = new LogContentInfo();
    String path = response.getValue("path");
    String total = response.getValue("total");
    String start = response.getValue("start");
    String end = response.getValue("end");
    if (Integer.parseInt(total) == 0) {
        return null;
    }
    logContentInfo.setPath(path);
    logContentInfo.setTotal(total);
    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("log")) {
            String[] lines = node.getValues("line");
            for (int j = 0; j < lines.length; j++) {
                String str = lines[j];
                // if (str != null && str.trim().length() > 0) {
                if (str != null) {
                    logContentInfo.addLine(str);
                }
            }
        } else {
            if (node != null) {
                if (null == start) {
                    start = node.getValue("start");
                    end = node.getValue("end");
                }
            }
        }
    }
    if (start != null && start.trim().length() > 0) {
        logContentInfo.setStart(start);
    }
    if (end != null && end.trim().length() > 0) {
        logContentInfo.setEnd(end);
    }
    return logContentInfo;
}
Also used : TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo)

Example 2 with LogContentInfo

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

the class LogEditorPart method connect.

/**
	 * Each page of log connect
	 *
	 * @param isCreateColumn boolean
	 *
	 */
public void connect(final boolean isCreateColumn) {
    GetLogListTask task = null;
    if (charsetName == null) {
        task = new GetLogListTask(this.cubridNode.getServer().getServerInfo());
    } else {
        task = new GetLogListTask(this.cubridNode.getServer().getServerInfo(), charsetName);
    }
    task.setPath(path);
    task.setStart(Long.toString(lineStart));
    task.setEnd(Long.toString(lineEnd));
    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() {
                            if (task instanceof GetLogListTask) {
                                GetLogListTask getLogListTask = (GetLogListTask) task;
                                LogContentInfo logContentInfo = (LogContentInfo) getLogListTask.getLogContent();
                                setTableInfo(logContentInfo, isCreateColumn);
                            }
                        }
                    });
                }
                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) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo) GetLogListTask(com.cubrid.cubridmanager.core.logs.task.GetLogListTask)

Example 3 with LogContentInfo

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

the class LogViewAction method run.

/**
	 * Open the log editor and show log content
	 */
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];
    }
    LogInfo logInfo = (LogInfo) cubridNode.getAdapter(LogInfo.class);
    final String filePath = logInfo.getPath();
    TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {

        public IStatus exec(IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                cubridNode = null;
                return Status.CANCEL_STATUS;
            }
            for (ITask task : taskList) {
                task.execute();
                final String msg = task.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);
                }
                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(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() {
                            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).setTableInfo(logContentInfo, true);
                            } catch (PartInitException e) {
                                LOGGER.error(e.getMessage(), e);
                            }
                        }
                    });
                }
                if (monitor.isCanceled()) {
                    cubridNode = null;
                    return Status.CANCEL_STATUS;
                }
            }
            cubridNode = null;
            return Status.OK_STATUS;
        }
    };
    CheckFileTask checkFileTask = new CheckFileTask(cubridNode.getServer().getServerInfo());
    checkFileTask.setFile(new String[] { filePath });
    taskJobExecutor.addTask(checkFileTask);
    GetLogListTask task = new GetLogListTask(cubridNode.getServer().getServerInfo());
    task.setPath(filePath);
    task.setStart("1");
    task.setEnd("100");
    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) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) IEditorPart(org.eclipse.ui.IEditorPart) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo) 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 4 with LogContentInfo

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

the class CasRunnerResultViewDialog method connectInit.

/**
	 * initialize log view table.
	 *
	 * @param logPath String
	 * @param dbName String
	 * @param node DefaultCubridNode
	 */
public void connectInit(String logPath, String dbName, DefaultCubridNode node) {
    this.selection = node;
    final GetLogListTask taskGetLog = new GetLogListTask(node.getServer().getServerInfo());
    path = logPath;
    this.dbName = dbName;
    taskGetLog.setPath(path + "." + String.valueOf(currentResultFileIndex - 1));
    taskGetLog.setDbName(dbName);
    taskGetLog.setStart("1");
    taskGetLog.setEnd(Long.toString(LINE_NUM_TO_DISPLAY));
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.loadLogTaskName);
    taskExecutor.addTask(taskGetLog);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess()) {
        LogContentInfo logContentInfo = (LogContentInfo) taskGetLog.getLogContent();
        this.setinfo(logContentInfo, selection);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) GetLogListTask(com.cubrid.cubridmanager.core.logs.task.GetLogListTask)

Example 5 with LogContentInfo

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

the class CasRunnerResultViewDialog method connect.

/**
	 * each page of log connect
	 *
	 */
public void connect() {
    final GetLogListTask task = new GetLogListTask(selection.getServer().getServerInfo());
    task.setPath(path + "." + String.valueOf(currentResultFileIndex - 1));
    task.setDbName(dbName);
    task.setStart(Long.toString(lineStart));
    task.setEnd(Long.toString(lineEnd));
    task.execute();
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.loadLogTaskName);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess()) {
        LogContentInfo logContentInfo = (LogContentInfo) task.getLogContent();
        this.setinfo(logContentInfo, selection);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) GetLogListTask(com.cubrid.cubridmanager.core.logs.task.GetLogListTask)

Aggregations

LogContentInfo (com.cubrid.cubridmanager.core.logs.model.LogContentInfo)12 GetLogListTask (com.cubrid.cubridmanager.core.logs.task.GetLogListTask)8 IEditorPart (org.eclipse.ui.IEditorPart)5 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)5 PartInitException (org.eclipse.ui.PartInitException)5 ITask (com.cubrid.common.core.task.ITask)4 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)4 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)4 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)4 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)4 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)4 LogEditorPart (com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IStatus (org.eclipse.core.runtime.IStatus)4 Status (org.eclipse.core.runtime.Status)4 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)2 CheckFileTask (com.cubrid.cubridmanager.core.cubrid.database.task.CheckFileTask)2 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 TreeNode (com.cubrid.cubridmanager.core.common.socket.TreeNode)1