Search in sources :

Example 36 with IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project erlide_eclipse by erlang.

the class OpenResultsJob method openInBrowser.

private void openInBrowser(final IFile file) {
    if (file == null) {
        return;
    }
    final IWorkbench wbench = PlatformUI.getWorkbench();
    final IWorkbenchBrowserSupport browserSupport = wbench.getBrowserSupport();
    try {
        file.refreshLocal(IResource.DEPTH_ZERO, null);
    } catch (final CoreException e1) {
    }
    if (file.exists() && file.isAccessible()) {
        try {
            final int style = IWorkbenchBrowserSupport.NAVIGATION_BAR | IWorkbenchBrowserSupport.AS_EDITOR;
            final String name = file.getName();
            final String browserId = getName() + "_" + name;
            IWebBrowser browser;
            browser = browserSupport.createBrowser(style, browserId, name, null);
            try {
                browser.openURL(file.getRawLocationURI().toURL());
            } catch (final MalformedURLException e) {
                // should not happen
                ErlLogger.error(e);
            }
        } catch (final PartInitException e) {
            ErlLogger.error(e);
        }
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) MalformedURLException(java.net.MalformedURLException) CoreException(org.eclipse.core.runtime.CoreException) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

IWorkbenchBrowserSupport (org.eclipse.ui.browser.IWorkbenchBrowserSupport)36 URL (java.net.URL)31 IWebBrowser (org.eclipse.ui.browser.IWebBrowser)29 PartInitException (org.eclipse.ui.PartInitException)21 MalformedURLException (java.net.MalformedURLException)18 GridData (org.eclipse.swt.layout.GridData)7 GridLayout (org.eclipse.swt.layout.GridLayout)6 IOException (java.io.IOException)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 Button (org.eclipse.swt.widgets.Button)5 Composite (org.eclipse.swt.widgets.Composite)5 Label (org.eclipse.swt.widgets.Label)5 Status (org.eclipse.core.runtime.Status)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 CoreException (org.eclipse.core.runtime.CoreException)3 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)3 FormText (org.eclipse.ui.forms.widgets.FormText)3 Hyperlink (com.novocode.naf.swt.custom.Hyperlink)2 File (java.io.File)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2