Search in sources :

Example 21 with LogInfo

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

the class ManagerLogInfoListTest method testModelDbLogInfoList.

public void testModelDbLogInfoList() {
    DbLogInfoList bean = new DbLogInfoList();
    bean.addLog(new LogInfo());
    bean.removeLog(new LogInfo());
    bean.removeAllLog();
    bean.getDbLogInfoList();
    bean.getDbLogInfo("aa");
}
Also used : ManagerLogInfo(com.cubrid.cubridmanager.core.logs.model.ManagerLogInfo) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) DbLogInfoList(com.cubrid.cubridmanager.core.logs.model.DbLogInfoList)

Example 22 with LogInfo

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

the class RemoveAllScriptLogAction method run.

/**
	 * Delete all script logs
	 */
public void run() {
    if (!CommonUITool.openConfirmBox(Messages.warningRemoveLog)) {
        return;
    }
    Object[] selected = this.getSelectedObj();
    DelAllLogTask delAllLogTask = new DelAllLogTask(((DefaultCubridNode) selected[0]).getServer().getServerInfo());
    String[] path = new String[((DefaultCubridNode) selected[0]).getChildren().size()];
    for (int i = 0, len = path.length; i < len; i++) {
        path[i] = ((LogInfo) (((DefaultCubridNode) selected[0]).getChildren().get(i).getAdapter(LogInfo.class))).getPath();
    }
    delAllLogTask.setPath(path);
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.removeLogTaskName);
    taskExecutor.addTask(delAllLogTask);
    new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
    if (taskExecutor.isSuccess()) {
        TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
        DefaultCubridNode delNode = ((DefaultCubridNode) selected[0]);
        ICubridNode parentNode = delNode.getParent().getParent();
        parentNode.removeChild(delNode);
        treeViewer.remove(delNode);
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        IWorkbenchPage activePage = window.getActivePage();
        for (int i = 0, len = path.length; i < len; i++) {
            IEditorPart editor = activePage.findEditor(((DefaultCubridNode) selected[0]).getChildren().get(i));
            if (null != editor) {
                activePage.closeEditor(editor, true);
            }
        }
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DelAllLogTask(com.cubrid.cubridmanager.core.logs.task.DelAllLogTask) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorPart(org.eclipse.ui.IEditorPart) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 23 with LogInfo

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

the class RemoveLogAction method run.

/**
	 * Delete log file
	 */
public void run() {
    if (!CommonUITool.openConfirmBox(Messages.warningRemoveLog)) {
        return;
    }
    Object[] selected = this.getSelectedObj();
    if (selected == null || selected.length == 0) {
        return;
    }
    List<String> logPathList = new ArrayList<String>();
    for (int i = 0; i < selected.length; i++) {
        ICubridNode node = (ICubridNode) selected[i];
        if (isLastDbServerLog(node)) {
            continue;
        }
        LogInfo logInfo = (LogInfo) node.getAdapter(LogInfo.class);
        if (logInfo != null && logInfo.getPath() != null && logInfo.getPath().trim().length() > 0) {
            logPathList.add(logInfo.getPath());
        }
    }
    DelAllLogTask delLogTask = new DelAllLogTask(((DefaultCubridNode) selected[0]).getServer().getServerInfo());
    String[] paths = new String[logPathList.size()];
    delLogTask.setPath(logPathList.toArray(paths));
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.removeLogTaskName);
    taskExecutor.addTask(delLogTask);
    new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
    if (taskExecutor.isSuccess()) {
        TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
        for (int i = 0; i < selected.length; i++) {
            ICubridNode delNode = (ICubridNode) selected[i];
            if (isLastDbServerLog(delNode)) {
                continue;
            }
            ICubridNode parentNode = delNode.getParent();
            parentNode.removeChild(delNode);
            treeViewer.remove(delNode);
            IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            IWorkbenchPage activePage = window.getActivePage();
            IEditorPart editor = activePage.findEditor(delNode);
            if (null != editor) {
                activePage.closeEditor(editor, true);
            }
        }
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) DelAllLogTask(com.cubrid.cubridmanager.core.logs.task.DelAllLogTask) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorPart(org.eclipse.ui.IEditorPart) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 24 with LogInfo

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

the class RemoveLogAction method isLastDbServerLog.

/**
	 *
	 * Return whether it is the last database server log path
	 *
	 * @param node ICubridNode
	 * @return boolean
	 */
private boolean isLastDbServerLog(ICubridNode node) {
    LogInfo logInfo = (LogInfo) node.getAdapter(LogInfo.class);
    String logPath = logInfo.getPath();
    String lastDBLog = "";
    if (CubridNodeType.LOGS_SERVER_DATABASE_LOG.equals(node.getType())) {
        String[] path = new String[node.getParent().getChildren().size()];
        for (int j = 0, len = path.length; j < len; j++) {
            LogInfo currLogFile = ((LogInfo) (node.getParent().getChildren().get(j).getAdapter(LogInfo.class)));
            if (lastDBLog.trim().length() == 0) {
                lastDBLog = currLogFile.getPath();
                continue;
            }
            if (lastDBLog.compareTo(currLogFile.getPath()) < 0) {
                lastDBLog = currLogFile.getPath();
            }
        }
    }
    return lastDBLog.equals(logPath);
}
Also used : LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo)

Example 25 with LogInfo

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

the class RemoveAllAccessLogAction method run.

/**
	 * Remove all access log
	 */
public void run() {
    if (!CommonUITool.openConfirmBox(Messages.warningRemoveLog)) {
        return;
    }
    Object[] selected = this.getSelectedObj();
    DelAllLogTask delAllLogTask = new DelAllLogTask(((DefaultCubridNode) selected[0]).getServer().getServerInfo());
    String[] path = new String[((DefaultCubridNode) selected[0]).getChildren().size()];
    for (int i = 0, len = path.length; i < len; i++) {
        path[i] = ((LogInfo) (((DefaultCubridNode) selected[0]).getChildren().get(i).getAdapter(LogInfo.class))).getPath();
    }
    delAllLogTask.setPath(path);
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.removeLogTaskName);
    taskExecutor.addTask(delAllLogTask);
    new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
    if (taskExecutor.isSuccess()) {
        TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
        DefaultCubridNode delNode = ((DefaultCubridNode) selected[0]);
        ICubridNode parentNode = delNode.getParent().getParent();
        parentNode.removeChild(delNode);
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (window == null) {
            return;
        }
        IWorkbenchPage activePage = window.getActivePage();
        for (int i = 0, len = path.length; i < len; i++) {
            IEditorPart editor = activePage.findEditor(((DefaultCubridNode) selected[0]).getChildren().get(i));
            treeViewer.remove(((DefaultCubridNode) selected[0]).getChildren().get(i));
            if (null != editor) {
                activePage.closeEditor(editor, true);
            }
        }
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DelAllLogTask(com.cubrid.cubridmanager.core.logs.task.DelAllLogTask) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorPart(org.eclipse.ui.IEditorPart) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Aggregations

LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)32 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)17 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)12 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)11 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)11 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)11 IEditorPart (org.eclipse.ui.IEditorPart)9 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)9 ManagerLogInfo (com.cubrid.cubridmanager.core.logs.model.ManagerLogInfo)8 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)6 TreeViewer (org.eclipse.jface.viewers.TreeViewer)6 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)6 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)5 DbLogInfoList (com.cubrid.cubridmanager.core.logs.model.DbLogInfoList)5 DelAllLogTask (com.cubrid.cubridmanager.core.logs.task.DelAllLogTask)5 BrokerLogInfos (com.cubrid.cubridmanager.core.logs.model.BrokerLogInfos)4 LogContentInfo (com.cubrid.cubridmanager.core.logs.model.LogContentInfo)4 GetLogListTask (com.cubrid.cubridmanager.core.logs.task.GetLogListTask)4 LogEditorPart (com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart)4