Search in sources :

Example 26 with IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project webtools.servertools by eclipse.

the class OpenBrowserWorkbenchAction method run.

/**
 * Performs this action.
 * <p>
 * This method is called when the delegating action has been triggered.
 * Implement this method to do the actual work.
 * </p>
 *
 * @param action the action proxy that handles the presentation portion of the
 *   action
 */
public void run(IAction action) {
    try {
        IWorkbenchBrowserSupport browserSupport = ServerUIPlugin.getInstance().getWorkbench().getBrowserSupport();
        IWebBrowser browser = browserSupport.createBrowser(IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR, null, null, null);
        browser.openURL(null);
    } catch (Exception e) {
        if (Trace.SEVERE) {
            Trace.trace(Trace.STRING_SEVERE, "Error opening browser", e);
        }
    }
}
Also used : IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser)

Example 27 with IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project archi by archimatetool.

the class WebBrowserAction method run.

@Override
public void run() {
    IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
    try {
        IWebBrowser browser = support.getExternalBrowser();
        if (browser != null) {
            URL url = new URL(fUrl);
            browser.openURL(url);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) URL(java.net.URL)

Example 28 with IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project archi by archimatetool.

the class HTMLReportExporter method export.

public void export() throws Exception {
    File targetFolder = askSaveFolder();
    if (targetFolder == null) {
        return;
    }
    Exception[] exception = new Exception[1];
    // Since this can take a while, show the busy dialog
    IRunnableWithProgress runnable = monitor -> {
        try {
            // $NON-NLS-1$
            File file = createReport(targetFolder, "index.html", monitor);
            // Open it in external Browser
            IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
            IWebBrowser browser = support.getExternalBrowser();
            // This method supports network URLs
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            browser.openURL(new URL("file", null, file.getAbsolutePath().replace(" ", "%20")));
        } catch (Exception ex) {
            // Catch OOM and SWT exceptions
            exception[0] = ex;
        }
    };
    try {
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
        dialog.run(false, true, runnable);
    } catch (Exception ex) {
        exception[0] = ex;
    }
    if (exception[0] instanceof CancelledException) {
        MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.HTMLReportExporter_2, exception[0].getMessage());
    } else if (exception[0] != null) {
        throw exception[0];
    }
}
Also used : ImageLoader(org.eclipse.swt.graphics.ImageLoader) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ModelReferencedImage(com.archimatetool.editor.diagram.util.ModelReferencedImage) URL(java.net.URL) IArchimateModel(com.archimatetool.model.IArchimateModel) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) Map(java.util.Map) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IArchimateConcept(com.archimatetool.model.IArchimateConcept) Bundle(org.osgi.framework.Bundle) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) IDiagramModel(com.archimatetool.model.IDiagramModel) NLS(org.eclipse.osgi.util.NLS) PlatformUI(org.eclipse.ui.PlatformUI) IDiagramModelContainer(com.archimatetool.model.IDiagramModelContainer) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) EObject(org.eclipse.emf.ecore.EObject) Display(org.eclipse.swt.widgets.Display) BrowserEditorInput(com.archimatetool.editor.browser.BrowserEditorInput) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) List(java.util.List) ST(org.stringtemplate.v4.ST) Rectangle(org.eclipse.draw2d.geometry.Rectangle) StringUtils(com.archimatetool.editor.utils.StringUtils) ArchiReportsPlugin(com.archimatetool.reports.ArchiReportsPlugin) SWT(org.eclipse.swt.SWT) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) IIdentifier(com.archimatetool.model.IIdentifier) STGroupFile(org.stringtemplate.v4.STGroupFile) IFolder(com.archimatetool.model.IFolder) FileUtils(com.archimatetool.editor.utils.FileUtils) ArchiPlugin(com.archimatetool.editor.ArchiPlugin) IBrowserEditor(com.archimatetool.editor.browser.IBrowserEditor) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) EditorManager(com.archimatetool.editor.ui.services.EditorManager) Image(org.eclipse.swt.graphics.Image) HashMap(java.util.HashMap) IBrowserEditorInput(com.archimatetool.editor.browser.IBrowserEditorInput) ImageData(org.eclipse.swt.graphics.ImageData) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) OutputStreamWriter(java.io.OutputStreamWriter) Hashtable(java.util.Hashtable) ImageFactory(com.archimatetool.editor.ui.ImageFactory) Iterator(java.util.Iterator) DiagramUtils(com.archimatetool.editor.diagram.util.DiagramUtils) FolderType(com.archimatetool.model.FolderType) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) StringRenderer(org.stringtemplate.v4.StringRenderer) File(java.io.File) FileLocator(org.eclipse.core.runtime.FileLocator) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Platform(org.eclipse.core.runtime.Platform) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) STGroupFile(org.stringtemplate.v4.STGroupFile) File(java.io.File) IOException(java.io.IOException) URL(java.net.URL) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 29 with IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project ecf by eclipse.

the class SendMessageRosterEntryContribution method showURL.

private void showURL(String string) {
    IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
    IWebBrowser browser;
    try {
        browser = support.createBrowser(null);
        browser.openURL(new URL(string));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) URL(java.net.URL)

Example 30 with IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project ecf by eclipse.

the class OpenBrowserCommand method execute.

/* (non-Javadoc)
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
	 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    // get service
    final IServiceInfo serviceInfo = DiscoveryHandlerUtil.getActiveIServiceInfoChecked(event);
    final URI location = serviceInfo.getLocation();
    // open browser view or reuse existing if already open
    final IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
    try {
        final URL url = location.toURL();
        support.createBrowser(url.toExternalForm()).openURL(url);
    } catch (PartInitException e) {
        throw new ExecutionException(e.getMessage(), e);
    } catch (MalformedURLException e) {
        throw new ExecutionException(e.getMessage(), e);
    }
    return null;
}
Also used : MalformedURLException(java.net.MalformedURLException) IServiceInfo(org.eclipse.ecf.discovery.IServiceInfo) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) PartInitException(org.eclipse.ui.PartInitException) ExecutionException(org.eclipse.core.commands.ExecutionException) URI(java.net.URI) URL(java.net.URL)

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