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);
}
}
}
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();
}
}
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];
}
}
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();
}
}
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;
}
Aggregations