Search in sources :

Example 31 with IEditorDescriptor

use of org.eclipse.ui.IEditorDescriptor in project azure-tools-for-java by Microsoft.

the class UIHelperImpl method openItem.

@Override
public <T extends StorageServiceTreeItem> void openItem(Object projectObject, final StorageAccount storageAccount, final T item, String itemType, String itemName, String iconName) {
    // Display.getDefault().syncExec(new Runnable() {
    // @Override
    // public void run() {
    // try {
    // BlobExplorerView view = (BlobExplorerView) PlatformUI
    // .getWorkbench().getActiveWorkbenchWindow()
    // .getActivePage().showView("com.microsoft.azureexplorer.views.BlobExplorerView");
    // view.init(storageAccount, (BlobContainer) blobContainer);
    // } catch (PartInitException e) {
    // Activator.getDefault().log("Error opening container", e);
    // }
    // }
    // });
    IWorkbench workbench = PlatformUI.getWorkbench();
    IEditorDescriptor editorDescriptor = workbench.getEditorRegistry().findEditor(type2Editor.get(item.getClass()));
    try {
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IEditorPart newEditor = page.openEditor(new StorageEditorInput(storageAccount.name(), StorageClientSDKManager.getConnectionString(storageAccount), item), editorDescriptor.getId());
    } catch (PartInitException e) {
        Activator.getDefault().log("Error opening " + item.getName(), e);
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) StorageEditorInput(com.microsoft.azuretools.azureexplorer.editors.StorageEditorInput) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException)

Example 32 with IEditorDescriptor

use of org.eclipse.ui.IEditorDescriptor in project azure-tools-for-java by Microsoft.

the class UIHelperImpl method refreshQueue.

@Override
public void refreshQueue(Object projectObject, final StorageAccount storageAccount, final Queue queue) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    final IEditorDescriptor editorDescriptor = workbench.getEditorRegistry().findEditor("com.microsoft.azuretools.azureexplorer.editors.QueueFileEditor");
    DefaultLoader.getIdeHelper().invokeLater(new Runnable() {

        @Override
        public void run() {
        // TODO
        // try {
        // IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        // QueueFileEditor newEditor = (QueueFileEditor) page.openEditor(new StorageEditorInput(storageAccount, queue), editorDescriptor.getId());
        // newEditor.fillGrid();
        // } catch (PartInitException e) {
        // Activator.getDefault().log("Error opening container", e);
        // }
        }
    });
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor)

Example 33 with IEditorDescriptor

use of org.eclipse.ui.IEditorDescriptor in project xtext-eclipse by eclipse.

the class OriginalEditorSelector method getXtextEditor.

protected IEditorDescriptor getXtextEditor(URI uri) {
    IResourceServiceProvider serviceProvider = resourceServiceProviderRegistry.getResourceServiceProvider(uri);
    if (serviceProvider != null) {
        XtextEditorInfo editorInfo = serviceProvider.get(XtextEditorInfo.class);
        if (editorInfo != null) {
            IEditorRegistry editorRegistry = workbench.getEditorRegistry();
            IEditorDescriptor result = editorRegistry.findEditor(editorInfo.getEditorId());
            // null is ok
            return result;
        }
    }
    return null;
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) XtextEditorInfo(org.eclipse.xtext.ui.editor.XtextEditorInfo) IEditorRegistry(org.eclipse.ui.IEditorRegistry)

Example 34 with IEditorDescriptor

use of org.eclipse.ui.IEditorDescriptor in project xtext-eclipse by eclipse.

the class ClassFileBasedOpenerContributor method collectSourceFileOpeners.

@Override
public boolean collectSourceFileOpeners(IEditorPart editor, IAcceptor<FileOpener> acceptor) {
    if (!(editor instanceof XtextEditor) && editor.getEditorInput() != null) {
        try {
            IClassFile classFile = Adapters.adapt(editor, IClassFile.class);
            if (classFile == null) {
                return false;
            }
            ITrace trace = traceForTypeRootProvider.getTraceToSource(classFile);
            if (trace == null) {
                return false;
            }
            for (ILocationInResource location : trace.getAllAssociatedLocations()) {
                String name = location.getAbsoluteResourceURI().getURI().lastSegment();
                IEditorDescriptor editorDescriptor = IDE.getEditorDescriptor(name);
                acceptor.accept(createEditorOpener(editor.getEditorInput(), editorDescriptor.getId()));
                return true;
            }
        } catch (PartInitException e) {
            LOG.error(e.getMessage(), e);
        }
    }
    return false;
}
Also used : IClassFile(org.eclipse.jdt.core.IClassFile) XtextEditor(org.eclipse.xtext.ui.editor.XtextEditor) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) ITrace(org.eclipse.xtext.generator.trace.ITrace) PartInitException(org.eclipse.ui.PartInitException) ILocationInResource(org.eclipse.xtext.generator.trace.ILocationInResource)

Example 35 with IEditorDescriptor

use of org.eclipse.ui.IEditorDescriptor in project xtext-eclipse by eclipse.

the class XtextEditor method getDefaultImage.

@Override
public Image getDefaultImage() {
    IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
    IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
    ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;
    return imageDesc != null ? imageHelper.getImage(imageDesc) : super.getDefaultImage();
}
Also used : IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IEditorRegistry(org.eclipse.ui.IEditorRegistry)

Aggregations

IEditorDescriptor (org.eclipse.ui.IEditorDescriptor)74 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)34 PartInitException (org.eclipse.ui.PartInitException)34 FileEditorInput (org.eclipse.ui.part.FileEditorInput)27 IWorkbench (org.eclipse.ui.IWorkbench)25 IEditorPart (org.eclipse.ui.IEditorPart)21 IFile (org.eclipse.core.resources.IFile)19 IEditorRegistry (org.eclipse.ui.IEditorRegistry)18 CoreException (org.eclipse.core.runtime.CoreException)10 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)10 IEditorInput (org.eclipse.ui.IEditorInput)8 IContentType (org.eclipse.core.runtime.content.IContentType)7 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)7 AbstractTextEditor (org.eclipse.ui.texteditor.AbstractTextEditor)7 Image (org.eclipse.swt.graphics.Image)5 InputStream (java.io.InputStream)4 BadLocationException (org.eclipse.jface.text.BadLocationException)4 Path (org.eclipse.core.runtime.Path)3 IContentDescription (org.eclipse.core.runtime.content.IContentDescription)3 JavaModelException (org.eclipse.jdt.core.JavaModelException)3