Search in sources :

Example 76 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class RemoveAllDbLogAction method run.

/**
	 * Remove all database 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()];
    //get last file name
    String lastDBLog = "";
    LogInfo currLogFile;
    for (int i = 0, len = path.length; i < len; i++) {
        currLogFile = ((LogInfo) (((DefaultCubridNode) selected[0]).getChildren().get(i).getAdapter(LogInfo.class)));
        if (lastDBLog.compareTo(currLogFile.getPath()) < 0) {
            lastDBLog = currLogFile.getPath();
        }
    }
    for (int i = 0, len = path.length - 1; i < len; i++) {
        if (!((LogInfo) (((DefaultCubridNode) selected[0]).getChildren().get(i).getAdapter(LogInfo.class))).getPath().equals(lastDBLog)) {
            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()) {
        return;
    }
    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));
        if (!((LogInfo) (((DefaultCubridNode) selected[0]).getChildren().get(i).getAdapter(LogInfo.class))).getPath().equals(lastDBLog)) {
            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 77 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class RemoveAllErrorLogAction method isSupported.

/**
	 * @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
	 *      .lang.Object)
	 * @param obj Object
	 * @return boolean(whether to support)
	 */
public boolean isSupported(Object obj) {
    if (obj instanceof ICubridNode) {
        ICubridNode node = (ICubridNode) obj;
        if (node.getServer() == null) {
            return false;
        }
        ServerUserInfo serverUserInfo = node.getServer().getServerInfo().getLoginedUserInfo();
        if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
            return false;
        }
        if (CubridNodeType.LOGS_BROKER_ERROR_LOG_FOLDER.equals(node.getType())) {
            return true;
        }
    }
    return false;
}
Also used : ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 78 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class RemoveAllErrorLogAction method run.

/**
	 * Remove all error 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);
        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));
            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 79 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class RemoveAllManagerLogAction method isSupported.

/**
	 * @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
	 *      .lang.Object)
	 * @param obj Object
	 * @return boolean(whether to support)
	 */
public boolean isSupported(Object obj) {
    if (obj instanceof ICubridNode) {
        ICubridNode node = (ICubridNode) obj;
        if (node.getServer() == null) {
            return false;
        }
        ServerUserInfo serverUserInfo = node.getServer().getServerInfo().getLoginedUserInfo();
        if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
            return false;
        }
        if (CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(node.getType()) || CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(node.getType())) {
            return true;
        }
    }
    return false;
}
Also used : ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 80 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class AddFunctionAction method run.

/**
	 * Open addFunctionDialog
	 */
public void run() {
    // FIXME logic code move to core module
    Shell shell = getShell();
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISchemaNode node = (ISchemaNode) obj[0];
    CubridDatabase database = node.getDatabase();
    EditFunctionDialog dlg = new EditFunctionDialog(shell);
    dlg.setDatabase(database);
    dlg.setNewFlag(true);
    ISelectionProvider provider = getSelectionProvider();
    if (dlg.open() == IDialogConstants.OK_ID && (provider instanceof TreeViewer)) {
        ICubridNode folderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridSPFolderLoader.SP_FOLDER_ID);
        folderNode = folderNode.getChild(folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridSPFolderLoader.FUNCTION_FOLDER_ID);
        TreeViewer treeViewer = (TreeViewer) provider;
        if (folderNode == null || !folderNode.getLoader().isLoaded()) {
            return;
        }
        String functionName = dlg.getFunctionName().toLowerCase(Locale.getDefault());
        String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + functionName;
        DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
        SPInfo spInfo = new SPInfo(functionName);
        spInfo.setOwner(userInfo.getName());
        ICubridNode newNode = CubridFunctionFolderLoader.createFunctionNode(id, spInfo);
        CommonUITool.addNodeToTree(treeViewer, folderNode, newNode);
    }
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) Shell(org.eclipse.swt.widgets.Shell) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SPInfo(com.cubrid.cubridmanager.core.cubrid.sp.model.SPInfo) EditFunctionDialog(com.cubrid.common.ui.cubrid.procedure.dialog.EditFunctionDialog) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)362 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)67 ArrayList (java.util.ArrayList)67 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)62 TreeViewer (org.eclipse.jface.viewers.TreeViewer)62 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)55 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)55 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)41 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)40 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)33 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)32 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)31 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)27 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)26 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)25 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)25 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)25 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)25 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)23 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)22