Search in sources :

Example 1 with LogEditorPart

use of com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart 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 2 with LogEditorPart

use of com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart 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 3 with LogEditorPart

use of com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart in project cubrid-manager by CUBRID.

the class ResetAdminLogAction 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) {
        LogInfo logInfo = (LogInfo) node.getAdapter(LogInfo.class);
        TaskExecutor taskExecutor = new CommonTaskExec(Messages.viewLogJobName);
        GetLogListTask task = new GetLogListTask(node.getServer().getServerInfo());
        task.setPath(logInfo.getPath());
        task.setStart("1");
        task.setEnd("100");
        taskExecutor.addTask(task);
        new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
        LogContentInfo logContentInfo = (LogContentInfo) task.getLogContent();
        try {
            editor = window.getActivePage().openEditor(node, LogEditorPart.ID);
            ((LogEditorPart) editor).setTableInfo(logContentInfo, true);
        } 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) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) GetLogListTask(com.cubrid.cubridmanager.core.logs.task.GetLogListTask) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) LogEditorPart(com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart)

Example 4 with LogEditorPart

use of com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart in project cubrid-manager by CUBRID.

the class TimeSetAction method run.

/**
	 * Open dialog
	 */
public void run() {
    TimeSetDialog timeSetDialog = new TimeSetDialog(getShell());
    timeSetDialog.create();
    timeSetDialog.getShell().setSize(580, 275);
    if (timeSetDialog.open() == Dialog.OK) {
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (window == null) {
            return;
        }
        Object[] obj = this.getSelectedObj();
        if (!isSupported(obj[0])) {
            setEnabled(false);
            return;
        }
        ICubridNode node = (ICubridNode) obj[0];
        LogInfo logInfo = (LogInfo) node.getAdapter(LogInfo.class);
        GetLogListTask task = new GetLogListTask(node.getServer().getServerInfo());
        task.setPath(logInfo.getPath());
        task.setStart("1");
        task.setEnd("100");
        TaskExecutor taskExcutor = new CommonTaskExec(Messages.loadLogTaskName);
        taskExcutor.addTask(task);
        new ExecTaskWithProgress(taskExcutor).exec();
        if (!taskExcutor.isSuccess()) {
            return;
        }
        LogContentInfo logContentInfo = (LogContentInfo) task.getLogContent();
        IEditorPart editor;
        try {
            editor = window.getActivePage().openEditor(node, LogEditorPart.ID);
            ((LogEditorPart) editor).setTableInfo(logContentInfo, true);
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorPart(org.eclipse.ui.IEditorPart) TimeSetDialog(com.cubrid.cubridmanager.ui.logs.dialog.TimeSetDialog) 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) PartInitException(org.eclipse.ui.PartInitException) LogEditorPart(com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart)

Example 5 with LogEditorPart

use of com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart 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)

Aggregations

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