Search in sources :

Example 81 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec 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 82 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec 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 83 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec 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)

Example 84 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.

the class RemoveAllManagerLogAction method run.

/**
	 * Remove all manager logs
	 */
public void run() {
    if (!CommonUITool.openConfirmBox(Messages.warningRemoveManagerLog)) {
        return;
    }
    Object[] selected = this.getSelectedObj();
    String sendStr;
    if (((DefaultCubridNode) selected[0]).getId().indexOf("Access log") >= 0) {
        sendStr = "deleteaccesslog";
    } else {
        sendStr = "deleteerrorlog";
    }
    DelManagerLogTask delAllLogTask = new DelManagerLogTask(((DefaultCubridNode) selected[0]).getServer().getServerInfo(), sendStr);
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.removeLogTaskName);
    taskExecutor.addTask(delAllLogTask);
    new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
    if (taskExecutor.isSuccess()) {
        refreshLogEditor((ICubridNode) selected[0]);
        CommonUITool.openInformationBox(Messages.msgSuccess, Messages.msgDeleteAllLog);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) DelManagerLogTask(com.cubrid.cubridmanager.core.logs.task.DelManagerLogTask)

Example 85 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec 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

CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)106 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)106 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)81 TreeViewer (org.eclipse.jface.viewers.TreeViewer)31 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)24 ArrayList (java.util.ArrayList)24 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)23 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)18 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)14 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)13 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)13 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)12 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)11 IEditorPart (org.eclipse.ui.IEditorPart)11 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)9 HashMap (java.util.HashMap)9 AbstractUITask (com.cubrid.common.core.task.AbstractUITask)8 Map (java.util.Map)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)8