Search in sources :

Example 61 with IEditorReference

use of org.eclipse.ui.IEditorReference in project dbeaver by dbeaver.

the class NavigatorHandlerObjectDelete method deleteNewObject.

private boolean deleteNewObject(IWorkbenchWindow workbenchWindow, DBNDatabaseNode node) throws DBException {
    for (final IEditorReference editorRef : workbenchWindow.getActivePage().getEditorReferences()) {
        final IEditorPart editor = editorRef.getEditor(false);
        if (editor instanceof IDatabaseEditor) {
            final IDatabaseEditorInput editorInput = ((IDatabaseEditor) editor).getEditorInput();
            if (editorInput.getDatabaseObject() == node.getObject()) {
                ConfirmResult confirmResult = confirmObjectDelete(workbenchWindow, node, false, null, false);
                if (confirmResult == ConfirmResult.NO) {
                    return true;
                }
                // Just close editor
                // It should dismiss new object and remove navigator node
                workbenchWindow.getActivePage().closeEditor(editor, false);
                return true;
            }
        }
    }
    return false;
}
Also used : IDatabaseEditorInput(org.jkiss.dbeaver.ui.editors.IDatabaseEditorInput) IEditorReference(org.eclipse.ui.IEditorReference) IEditorPart(org.eclipse.ui.IEditorPart) IDatabaseEditor(org.jkiss.dbeaver.ui.editors.IDatabaseEditor)

Example 62 with IEditorReference

use of org.eclipse.ui.IEditorReference in project erlide_eclipse by erlang.

the class ClearAllCachesAction method clearAllCaches.

public static void clearAllCaches() {
    final String cacheFileOSPath = ErlangEngine.getInstance().getStateDir();
    final File cacheFile = new File(cacheFileOSPath);
    cacheFile.delete();
    for (final IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) {
        for (final IWorkbenchPage page : window.getPages()) {
            for (final IEditorReference editor : page.getEditorReferences()) {
                final IEditorPart ed = editor.getEditor(false);
                if (ed instanceof ErlangEditor) {
                    ((ErlangEditor) ed).resetAndCacheScannerAndParser();
                }
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) File(java.io.File) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor)

Example 63 with IEditorReference

use of org.eclipse.ui.IEditorReference in project erlide_eclipse by erlang.

the class EditorTracker method clearAllAnnotations.

/**
 * clears coverage annotations from all files opened in the editor
 */
@Override
public void clearAllAnnotations() {
    final IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
    coverage.removeAll();
    for (final IWorkbenchWindow w : windows) {
        for (final IWorkbenchPage page : w.getPages()) {
            for (final IEditorReference editor : page.getEditorReferences()) {
                clearAnnotations(editor.getPart(false));
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 64 with IEditorReference

use of org.eclipse.ui.IEditorReference in project erlide_eclipse by erlang.

the class EditorTracker method addAnnotations.

/**
 * Marks coverage of all tested modules (if they are opened)
 */
@Override
public void addAnnotations() {
    final IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
    createAnnotationMap();
    for (final IWorkbenchWindow w : windows) {
        for (final IWorkbenchPage page : w.getPages()) {
            for (final IEditorReference editor : page.getEditorReferences()) {
                if (editor.isDirty()) {
                    continue;
                }
                annotateEditor(editor.getEditor(false));
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 65 with IEditorReference

use of org.eclipse.ui.IEditorReference in project core by jcryptool.

the class EditorsManager method getEditorContent.

/**
 * Looks up editor with this title and reads out its content.
 *
 * @param title the title of the editor to look up.
 * @return the streamed content of the editor; or <code>null</code> if no editor with this title is available.
 * @throws EditorNotFoundException if no active workbench page could be found.
 */
public InputStream getEditorContent(final String title) throws EditorNotFoundException {
    IWorkbenchPage[] pages = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPages();
    if (0 == pages.length) {
        // $NON-NLS-1$
        throw new EditorNotFoundException("Could not find active workbench page.");
    }
    IEditorReference[] refs = pages[0].getEditorReferences();
    IEditorPart ip = null;
    for (IEditorReference er : refs) {
        if (er.getTitle().equals(title)) {
            ip = er.getEditor(true);
            break;
        }
    }
    if (null != ip) {
        return getContentInputStream(ip);
    }
    return null;
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart)

Aggregations

IEditorReference (org.eclipse.ui.IEditorReference)174 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)83 IEditorPart (org.eclipse.ui.IEditorPart)78 PartInitException (org.eclipse.ui.PartInitException)59 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)55 IFile (org.eclipse.core.resources.IFile)50 IEditorInput (org.eclipse.ui.IEditorInput)49 ArrayList (java.util.ArrayList)34 FileEditorInput (org.eclipse.ui.part.FileEditorInput)28 Item (org.talend.core.model.properties.Item)17 IWorkbench (org.eclipse.ui.IWorkbench)14 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 PersistenceException (org.talend.commons.exception.PersistenceException)13 IOException (java.io.IOException)12 CoreException (org.eclipse.core.runtime.CoreException)12 ProcessItem (org.talend.core.model.properties.ProcessItem)11 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)10 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)10 Path (org.eclipse.core.runtime.Path)10 IProcess2 (org.talend.core.model.process.IProcess2)10