Search in sources :

Example 31 with IEditorInput

use of org.eclipse.ui.IEditorInput in project cubrid-manager by CUBRID.

the class LayoutUtil method getEditorParts.

/**
	 * 
	 * Get the editor parts of this CUBRID node
	 * 
	 * @param cubridNode the ICubridNode object
	 * @return List<IEditorPart>
	 */
public static List<IEditorPart> getEditorParts(ICubridNode cubridNode) {
    List<IEditorPart> partList = new ArrayList<IEditorPart>();
    IWorkbenchPage page = getActivePage();
    if (page == null) {
        return partList;
    }
    IEditorReference[] editorRefArr = page.getEditorReferences();
    if (editorRefArr == null || editorRefArr.length == 0) {
        return partList;
    }
    for (IEditorReference editorRef : editorRefArr) {
        try {
            IEditorInput editorInput = editorRef.getEditorInput();
            if (editorInput instanceof ICubridNode) {
                ICubridNode node = (ICubridNode) editorInput;
                if (node.getId().equals(cubridNode.getId())) {
                    partList.add(editorRef.getEditor(false));
                }
            }
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage());
        }
    }
    return partList;
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) ArrayList(java.util.ArrayList) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 32 with IEditorInput

use of org.eclipse.ui.IEditorInput in project ow by vtst.

the class AbstractEditorRegistry method addEditor.

private synchronized void addEditor(ITextEditor textEditor) {
    IEditorInput editorInput = textEditor.getEditorInput();
    if (!(editorInput instanceof IFileEditorInput))
        return;
    IFile file = ((IFileEditorInput) editorInput).getFile();
    IDocument document = textEditor.getDocumentProvider().getDocument(editorInput);
    if (file == null || document == null)
        return;
    editorToFile.put(textEditor, file);
    editorToDocument.put(textEditor, document);
    boolean newlyOpenedFile = fileToEditors.put(file, textEditor);
    if (documentToEditors.put(document, textEditor)) {
        DocumentListener listener = makeDocumentListener(document);
        documentToListener.put(document, listener);
        document.addDocumentListener(listener);
        documentToFile.put(document, file);
    }
    if (newlyOpenedFile) {
        triggerFileOpenListener(file);
    }
}
Also used : IDocumentListener(org.eclipse.jface.text.IDocumentListener) NullDocumentListener(net.vtst.ow.eclipse.js.closure.util.listeners.NullDocumentListener) IFile(org.eclipse.core.resources.IFile) IFileEditorInput(org.eclipse.ui.IFileEditorInput) IEditorInput(org.eclipse.ui.IEditorInput) IDocument(org.eclipse.jface.text.IDocument)

Example 33 with IEditorInput

use of org.eclipse.ui.IEditorInput in project cubrid-manager by CUBRID.

the class MonitorDashboardEditor method initializeGraphicalViewer.

/**
	 * initialize viewer
	 * 
	 * @see org.eclipse.gef.ui.parts.GraphicalEditor.initializeGraphicalViewer
	 */
protected void initializeGraphicalViewer() {
    IEditorInput input = this.getEditorInput();
    if (input instanceof ICubridNode) {
        ICubridNode node = (ICubridNode) input;
        Dashboard dashboard = (Dashboard) node.getAdapter(Dashboard.class);
        getGraphicalViewer().setContents(dashboard);
        dashboard.refresh();
    }
}
Also used : Dashboard(com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorInput(org.eclipse.ui.IEditorInput)

Example 34 with IEditorInput

use of org.eclipse.ui.IEditorInput 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 35 with IEditorInput

use of org.eclipse.ui.IEditorInput 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)

Aggregations

IEditorInput (org.eclipse.ui.IEditorInput)71 IFile (org.eclipse.core.resources.IFile)26 PartInitException (org.eclipse.ui.PartInitException)21 IEditorPart (org.eclipse.ui.IEditorPart)19 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)17 IEditorReference (org.eclipse.ui.IEditorReference)14 CoreException (org.eclipse.core.runtime.CoreException)13 ArrayList (java.util.ArrayList)11 IViewPart (org.eclipse.ui.IViewPart)11 FileEditorInput (org.eclipse.ui.part.FileEditorInput)10 Shell (org.eclipse.swt.widgets.Shell)9 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)8 IFileEditorInput (org.eclipse.ui.IFileEditorInput)8 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)8 File (java.io.File)7 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)7 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)7 Item (org.talend.core.model.properties.Item)7 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)6 IProject (org.eclipse.core.resources.IProject)6