Search in sources :

Example 21 with IEditorDescriptor

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

the class OpenDeclaration method selectAndRevealDeclaration.

/**
 * Opens an editor for the provided declaration, and in this editor the
 * location of the declaration is revealed and selected.
 *
 * @param declaration
 *                the declaration to reveal
 */
private void selectAndRevealDeclaration(final Location location) {
    IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(location.getFile().getName());
    if (desc == null) {
        targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(TTCNPPEDITORNOTFOUND);
        return;
    }
    try {
        IWorkbenchPage page = targetEditor.getSite().getPage();
        IEditorPart editorPart = page.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(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)

Example 22 with IEditorDescriptor

use of org.eclipse.ui.IEditorDescriptor in project epp.mpc by eclipse.

the class AskMarketplaceForFileSupportStrategy method getEditorDescriptor.

public IEditorDescriptor getEditorDescriptor(final String fileName, final IEditorRegistry editorRegistry) throws CoreException, OperationCanceledException {
    final IEditorDescriptor defaultDescriptor = createDefaultDescriptor(fileName, editorRegistry);
    Job mpcJob = new DiscoverFileSupportJob(editorRegistry, defaultDescriptor, fileName);
    mpcJob.setPriority(Job.INTERACTIVE);
    mpcJob.setUser(false);
    mpcJob.schedule();
    return defaultDescriptor;
}
Also used : IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) Job(org.eclipse.core.runtime.jobs.Job)

Example 23 with IEditorDescriptor

use of org.eclipse.ui.IEditorDescriptor in project webtools.sourceediting by eclipse.

the class WorkspaceFileHyperlink method getEditorLabel.

private String getEditorLabel() throws CoreException {
    final IContentDescription description = fFile.getContentDescription();
    final IEditorDescriptor defaultEditor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(fFile.getName(), description != null ? description.getContentType() : null);
    return defaultEditor != null ? defaultEditor.getLabel() : null;
}
Also used : IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) IContentDescription(org.eclipse.core.runtime.content.IContentDescription)

Example 24 with IEditorDescriptor

use of org.eclipse.ui.IEditorDescriptor in project webtools.sourceediting by eclipse.

the class ExternalFileHyperlink method open.

public void open() {
    if (fHyperlinkFile != null) {
        IEditorInput input = new ExternalFileEditorInput(fHyperlinkFile);
        IEditorDescriptor descriptor;
        try {
            descriptor = IDE.getEditorDescriptor(input.getName(), true);
            if (descriptor != null) {
                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                IDE.openEditor(page, input, descriptor.getId(), true);
            }
        } catch (PartInitException e) {
            Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
        }
    }
}
Also used : IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 25 with IEditorDescriptor

use of org.eclipse.ui.IEditorDescriptor in project webtools.sourceediting by eclipse.

the class URLFileHyperlink method open.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.text.hyperlink.IHyperlink#open()
	 */
public void open() {
    if (fURL != null) {
        IEditorInput input = new StorageEditorInput(new URLStorage(fURL));
        IEditorDescriptor descriptor;
        try {
            descriptor = IDE.getEditorDescriptor(input.getName());
            if (descriptor != null) {
                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                IDE.openEditor(page, input, descriptor.getId(), true);
            }
        } catch (PartInitException e) {
            Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
        }
    }
}
Also used : IStorageEditorInput(org.eclipse.ui.IStorageEditorInput) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

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