Search in sources :

Example 1 with CubridViewPart

use of com.cubrid.common.ui.spi.part.CubridViewPart in project cubrid-manager by CUBRID.

the class WorkbenchContrItem method closeAllEditorAndViewInDatabase.

/**
	 * Close all editor and view part related with this CUBRID Manager database
	 * node,not include query editor
	 *
	 * @param databaseNode the CubridDatabase object
	 * @param eventType CubridNodeChangedEventType
	 */
public void closeAllEditorAndViewInDatabase(CubridDatabase databaseNode, CubridNodeChangedEventType eventType) {
    IWorkbenchPage page = LayoutUtil.getActivePage();
    if (page == null) {
        return;
    }
    IEditorReference[] editorRefArr = page.getEditorReferences();
    for (int i = 0; editorRefArr != null && i < editorRefArr.length; i++) {
        IEditorReference editorRef = editorRefArr[i];
        try {
            IEditorInput editorInput = editorRef.getEditorInput();
            if (!(editorInput instanceof ISchemaNode)) {
                continue;
            }
            ISchemaNode schemaNode = ((ISchemaNode) editorInput);
            ISchemaNode dbNode = schemaNode.getDatabase();
            if (dbNode.getId().equals(databaseNode.getId())) {
                page.closeEditor(editorRef.getEditor(false), true);
            }
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage());
        }
    }
    IViewReference[] viewRefArr = page.getViewReferences();
    if (viewRefArr == null || viewRefArr.length == 0) {
        return;
    }
    for (IViewReference viewRef : viewRefArr) {
        IViewPart viewPart = viewRef.getView(false);
        if (!(viewPart instanceof CubridViewPart)) {
            continue;
        }
        CubridViewPart cubridViewPart = (CubridViewPart) viewPart;
        ICubridNode cubridNode = cubridViewPart.getCubridNode();
        if (!(cubridNode instanceof ISchemaNode)) {
            continue;
        }
        ICubridNode cubridDatabaseNode = ((ISchemaNode) cubridNode).getDatabase();
        if (cubridDatabaseNode.getId().equals(databaseNode.getId())) {
            page.hideView(viewPart);
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) IEditorReference(org.eclipse.ui.IEditorReference) CubridViewPart(com.cubrid.common.ui.spi.part.CubridViewPart) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorInput(org.eclipse.ui.IEditorInput)

Example 2 with CubridViewPart

use of com.cubrid.common.ui.spi.part.CubridViewPart in project cubrid-manager by CUBRID.

the class LayoutUtil method closeAllCubridEditorAndView.

/**
	 * 
	 * Close all opened editor and view part related with CUBRID Manager,not
	 * include query editor
	 * 
	 */
public static void closeAllCubridEditorAndView() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    if (workbench == null) {
        return;
    }
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return;
    }
    IEditorReference[] editorRefArr = page.getEditorReferences();
    if (editorRefArr != null && editorRefArr.length > 0) {
        for (IEditorReference editorRef : editorRefArr) {
            try {
                IEditorInput editorInput = editorRef.getEditorInput();
                if (editorInput instanceof ICubridNode) {
                    window.getActivePage().closeEditor(editorRef.getEditor(false), true);
                }
            } catch (PartInitException e) {
                LOGGER.error(e.getMessage());
            }
        }
    }
    IViewReference[] viewRefArr = page.getViewReferences();
    if (viewRefArr != null && viewRefArr.length > 0) {
        for (IViewReference viewRef : viewRefArr) {
            IViewPart viewPart = viewRef.getView(false);
            if (viewPart instanceof CubridViewPart) {
                page.hideView(viewPart);
            }
        }
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) IEditorReference(org.eclipse.ui.IEditorReference) CubridViewPart(com.cubrid.common.ui.spi.part.CubridViewPart) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 3 with CubridViewPart

use of com.cubrid.common.ui.spi.part.CubridViewPart in project cubrid-manager by CUBRID.

the class CubridWorkbenchContrItem method closeAllEditorAndViewInDatabase.

/**
	 * Close all editor and view part related with this CUBRID Manager database
	 * node,not include query editor
	 *
	 * @param databaseNode the CubridDatabase object
	 * @param eventType CubridNodeChangedEventType
	 */
public void closeAllEditorAndViewInDatabase(CubridDatabase databaseNode, CubridNodeChangedEventType eventType) {
    IWorkbenchPage page = LayoutUtil.getActivePage();
    if (page == null) {
        return;
    }
    IEditorReference[] editorRefArr = page.getEditorReferences();
    for (int i = 0; editorRefArr != null && i < editorRefArr.length; i++) {
        IEditorReference editorRef = editorRefArr[i];
        try {
            IEditorInput editorInput = editorRef.getEditorInput();
            if (!(editorInput instanceof ISchemaNode)) {
                continue;
            }
            ISchemaNode schemaNode = ((ISchemaNode) editorInput);
            ISchemaNode dbNode = schemaNode.getDatabase();
            String type = schemaNode.getType();
            boolean isDbSpaceEditor = NodeType.contains(type, new String[] { CubridNodeType.DATABASE, CubridNodeType.DBSPACE_FOLDER, CubridNodeType.GENERIC_VOLUME_FOLDER, CubridNodeType.GENERIC_VOLUME, CubridNodeType.DATA_VOLUME_FOLDER, CubridNodeType.DATA_VOLUME, CubridNodeType.INDEX_VOLUME_FOLDER, CubridNodeType.INDEX_VOLUME, CubridNodeType.TEMP_VOLUME_FOLDER, CubridNodeType.TEMP_VOLUME, CubridNodeType.LOG_VOLUEM_FOLDER, CubridNodeType.ACTIVE_LOG_FOLDER, CubridNodeType.ACTIVE_LOG, CubridNodeType.ARCHIVE_LOG_FOLDER, CubridNodeType.ARCHIVE_LOG });
            boolean isClose = true;
            if (isDbSpaceEditor) {
                isClose = !databaseNode.isLogined() || CubridNodeChangedEventType.NODE_REMOVE == eventType || CubridNodeChangedEventType.DATABASE_LOGOUT == eventType;
            }
            if (!isClose) {
                continue;
            }
            if (dbNode.getId().equals(databaseNode.getId())) {
                page.closeEditor(editorRef.getEditor(false), true);
            }
        } catch (Exception e) {
            LOGGER.error("", e);
        }
    }
    IViewReference[] viewRefArr = page.getViewReferences();
    if (viewRefArr == null || viewRefArr.length == 0) {
        return;
    }
    for (IViewReference viewRef : viewRefArr) {
        IViewPart viewPart = viewRef.getView(false);
        if (!(viewPart instanceof CubridViewPart)) {
            continue;
        }
        CubridViewPart cubridViewPart = (CubridViewPart) viewPart;
        ICubridNode cubridNode = cubridViewPart.getCubridNode();
        if (!(cubridNode instanceof ISchemaNode)) {
            continue;
        }
        ICubridNode cubridDatabaseNode = ((ISchemaNode) cubridNode).getDatabase();
        if (cubridDatabaseNode.getId().equals(databaseNode.getId())) {
            page.hideView(viewPart);
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) PartInitException(org.eclipse.ui.PartInitException) IEditorReference(org.eclipse.ui.IEditorReference) CubridViewPart(com.cubrid.common.ui.spi.part.CubridViewPart) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorInput(org.eclipse.ui.IEditorInput)

Example 4 with CubridViewPart

use of com.cubrid.common.ui.spi.part.CubridViewPart in project cubrid-manager by CUBRID.

the class CubridWorkbenchContrItem method closeAllEditorAndViewInServer.

/**
	 * Close all editor and view part related with this CUBRID Manager server
	 * node,not include query editor
	 *
	 * @param serverNode the ICubridNode object
	 * @param isSaved the boolean value,if can be saved
	 * @return boolean whether all editors are closed
	 */
public static boolean closeAllEditorAndViewInServer(ICubridNode serverNode, boolean isSaved) {
    boolean isCloseAll = true;
    IWorkbenchPage page = LayoutUtil.getActivePage();
    if (page == null) {
        return isCloseAll;
    }
    IEditorReference[] editorRefArr = page.getEditorReferences();
    if (editorRefArr != null && editorRefArr.length > 0) {
        for (IEditorReference editorRef : editorRefArr) {
            try {
                IEditorInput editorInput = editorRef.getEditorInput();
                if (!(editorInput instanceof ICubridNode)) {
                    continue;
                }
                ICubridNode node = ((ICubridNode) editorInput).getServer();
                if (node != null && node.getId().equals(serverNode.getId())) {
                    boolean isClosed = page.closeEditor(editorRef.getEditor(false), isSaved);
                    if (!isClosed) {
                        isCloseAll = false;
                    }
                }
            } catch (PartInitException e) {
                LOGGER.error("", e);
            }
        }
    }
    IViewReference[] viewRefArr = page.getViewReferences();
    if (viewRefArr != null && viewRefArr.length > 0) {
        for (IViewReference viewRef : viewRefArr) {
            IViewPart viewPart = viewRef.getView(false);
            if (!(viewPart instanceof CubridViewPart)) {
                continue;
            }
            CubridViewPart cubridViewPart = (CubridViewPart) viewPart;
            ICubridNode cubridNode = cubridViewPart.getCubridNode();
            if (cubridNode == null) {
                continue;
            }
            ICubridNode cubridServerNode = cubridNode.getServer();
            if (cubridServerNode.getId().equals(serverNode.getId())) {
                page.hideView(viewPart);
            }
        }
    }
    return isCloseAll;
}
Also used : IViewPart(org.eclipse.ui.IViewPart) IEditorReference(org.eclipse.ui.IEditorReference) CubridViewPart(com.cubrid.common.ui.spi.part.CubridViewPart) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 5 with CubridViewPart

use of com.cubrid.common.ui.spi.part.CubridViewPart in project cubrid-manager by CUBRID.

the class WorkbenchContrItem method processNodeRemoveWhenRefreshContainer.

/**
	 * When refresh the container node and if this child node is deleted, then
	 * close it's editor or view part
	 *
	 * @param eventNode ICubridNode
	 * @param page IWorkbenchPage
	 */
protected void processNodeRemoveWhenRefreshContainer(ICubridNode eventNode, IWorkbenchPage page) {
    synchronized (this) {
        IEditorReference[] editorRefArr = page.getEditorReferences();
        if (editorRefArr != null && editorRefArr.length > 0) {
            for (IEditorReference editorRef : editorRefArr) {
                try {
                    IEditorInput editorInput = editorRef.getEditorInput();
                    if (editorInput instanceof ICubridNode) {
                        ICubridNode editorNode = (ICubridNode) editorInput;
                        ICubridNode parentNode = editorNode.getParent();
                        if (editorNode != null && parentNode != null && parentNode.getId().equals(eventNode.getId()) && eventNode.getChild(editorNode.getId()) == null) {
                            processNodeRemove(editorNode, page);
                        }
                    }
                } catch (PartInitException e1) {
                    LOGGER.error(e1.getMessage());
                }
            }
        }
        IViewReference[] viewRefArr = page.getViewReferences();
        if (viewRefArr != null && viewRefArr.length > 0) {
            for (IViewReference viewRef : viewRefArr) {
                IViewPart viewPart = viewRef.getView(false);
                if (viewPart instanceof CubridViewPart) {
                    ICubridNode viewPartNode = ((CubridViewPart) viewPart).getCubridNode();
                    if (viewPartNode == null) {
                        continue;
                    }
                    ICubridNode parentNode = viewPartNode.getParent();
                    if (viewPartNode != null && parentNode != null && parentNode.getId().equals(eventNode.getId()) && eventNode.getChild(viewPartNode.getId()) == null) {
                        processNodeRemove(viewPartNode, page);
                    }
                }
            }
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) IEditorReference(org.eclipse.ui.IEditorReference) CubridViewPart(com.cubrid.common.ui.spi.part.CubridViewPart) IViewReference(org.eclipse.ui.IViewReference) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)7 CubridViewPart (com.cubrid.common.ui.spi.part.CubridViewPart)7 IViewPart (org.eclipse.ui.IViewPart)7 IViewReference (org.eclipse.ui.IViewReference)7 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)6 IEditorInput (org.eclipse.ui.IEditorInput)5 IEditorReference (org.eclipse.ui.IEditorReference)5 PartInitException (org.eclipse.ui.PartInitException)5 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)2 ArrayList (java.util.ArrayList)1 IWorkbench (org.eclipse.ui.IWorkbench)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1