Search in sources :

Example 66 with IEditorDescriptor

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

the class UIHelperImpl method refreshBlobs.

@Override
public void refreshBlobs(Object projectObject, final String accountName, final BlobContainer container) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    final IEditorDescriptor editorDescriptor = workbench.getEditorRegistry().findEditor("com.microsoft.azuretools.azureexplorer.editors.BlobExplorerFileEditor");
    DefaultLoader.getIdeHelper().invokeLater(new Runnable() {

        @Override
        public void run() {
        // TODO
        // try {
        // IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        // BlobExplorerFileEditor newEditor = (BlobExplorerFileEditor) page.openEditor(new StorageEditorInput(storageAccount, container), 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 67 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 ClientStorageAccount clientStorageAccount, 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(clientStorageAccount.getName(), clientStorageAccount.getConnectionString(), 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 68 with IEditorDescriptor

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

the class UIHelperImpl method openContainerRegistryPropertyView.

@Override
public void openContainerRegistryPropertyView(@NotNull ContainerRegistryNode node) {
    String sid = node.getSubscriptionId();
    String resId = node.getResourceId();
    if (Utils.isEmptyString(sid) || Utils.isEmptyString(resId)) {
        return;
    }
    IWorkbench workbench = PlatformUI.getWorkbench();
    ContainerRegistryExplorerEditorInput input = new ContainerRegistryExplorerEditorInput(sid, resId, node.getName());
    IEditorDescriptor descriptor = workbench.getEditorRegistry().findEditor(ContainerRegistryExplorerEditor.ID);
    openEditor(EditorType.CONTAINER_EXPLORER, input, descriptor);
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) ContainerRegistryExplorerEditorInput(com.microsoft.azuretools.azureexplorer.editors.container.ContainerRegistryExplorerEditorInput) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor)

Example 69 with IEditorDescriptor

use of org.eclipse.ui.IEditorDescriptor in project titan.EclipsePlug-ins by eclipse.

the class ReferenceSearchResultView method showMatch.

@Override
protected void showMatch(final Match match, final int currentOffset, final int currentLength) throws PartInitException {
    if (!(match instanceof ReferenceSearchMatch)) {
        return;
    }
    IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
    if (selection != null && !selection.toList().contains(match)) {
        getViewer().setSelection(new StructuredSelection(match));
    }
    IFile file = (IFile) match.getElement();
    IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
    if (desc == null) {
        return;
    }
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorPart part = page.openEditor(new FileEditorInput(file), desc.getId(), false);
    if (part != null && part instanceof ITextEditor) {
        ITextEditor textEditor = (ITextEditor) part;
        textEditor.selectAndReveal(currentOffset, currentLength);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) FileEditorInput(org.eclipse.ui.part.FileEditorInput) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart)

Example 70 with IEditorDescriptor

use of org.eclipse.ui.IEditorDescriptor in project titan.EclipsePlug-ins by eclipse.

the class FindDefinitionAction method showInEditor.

private void showInEditor(final ILocateableNode node) {
    final Location location = node.getLocation();
    final IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(location.getFile().getName());
    if (desc == null) {
        TITANDebugConsole.println("Cannot find the editor");
        return;
    }
    final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    try {
        final IEditorPart editorPart = activePage.openEditor(new FileEditorInput((IFile) location.getFile()), desc.getId());
        if (editorPart != null && (editorPart instanceof AbstractTextEditor)) {
            ((AbstractTextEditor) editorPart).selectAndReveal(location.getOffset(), location.getEndOffset() - location.getOffset());
        }
    } catch (PartInitException e) {
        ErrorReporter.logExceptionStackTrace("Error while opening the editor", e);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) FileEditorInput(org.eclipse.ui.part.FileEditorInput) AbstractTextEditor(org.eclipse.ui.texteditor.AbstractTextEditor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) Location(org.eclipse.titan.designer.AST.Location)

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