Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2006-07-12 04:57:35 +0000
committerslewis2006-07-12 04:57:35 +0000
commitde31eefad8254c33dab3a62b7c3e1e316332c0ad (patch)
tree66288134299a659cb3b4b86a929f27e26fbf1178
parentfbd2a59fbc6a1463aec11be411cd9c1047676ace (diff)
downloadorg.eclipse.ecf-ECF_0_8_8_I20060711.tar.gz
org.eclipse.ecf-ECF_0_8_8_I20060711.tar.xz
org.eclipse.ecf-ECF_0_8_8_I20060711.zip
Added support for browser viewing of URLs in textECF_0_8_8_I20060711
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/util/BrowserHelper.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/util/BrowserHelper.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/util/BrowserHelper.java
new file mode 100644
index 000000000..1de439ebd
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/util/BrowserHelper.java
@@ -0,0 +1,45 @@
+/****************************************************************************
+* Copyright (c) 2004 Composent, Inc. and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* Composent, Inc. - initial API and implementation
+*****************************************************************************/
+package org.eclipse.ecf.ui.util;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+
+public class BrowserHelper {
+
+ public BrowserHelper(final String url) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ try {
+ IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
+ URL anURL = new URL(url);
+ support.createBrowser(IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR,
+ anURL.toExternalForm(), null, null).openURL(anURL);
+ } catch (PartInitException e) {
+ MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+ "Browser Initialization Error", e.getLocalizedMessage());
+ } catch (MalformedURLException e) {
+ MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+ "Malformed URL Error", e.getLocalizedMessage());
+ } catch (Exception e) {
+ MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+ "Unexpected Browser Error", e.getLocalizedMessage());
+ }
+ }
+ });
+ }
+}

Back to the top