KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > browser > BrowserLauncher


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - Initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.browser;
12
13 import java.net.MalformedURLException JavaDoc;
14
15 import org.eclipse.core.runtime.IPath;
16 import org.eclipse.jface.dialogs.MessageDialog;
17 import org.eclipse.ui.IEditorLauncher;
18 import org.eclipse.ui.PartInitException;
19 import org.eclipse.ui.PlatformUI;
20 import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
21
22 public class BrowserLauncher implements IEditorLauncher {
23
24     public BrowserLauncher() {
25         // do nothing
26
}
27
28     public void open(IPath file) {
29         IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
30         try {
31             if (WebBrowserPreference.getBrowserChoice()== WebBrowserPreference.INTERNAL)
32                 support.createBrowser(IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR,
33                         file.toPortableString(), null, null).openURL(file.toFile().toURL());
34             else
35                 support.createBrowser(IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR,
36                         DefaultBrowserSupport.SHARED_ID, null, null).openURL(file.toFile().toURL());
37         }
38         catch (MalformedURLException JavaDoc e) {
39             // ignore
40
}
41         catch (PartInitException e) {
42             MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
43                     Messages.errorDialogTitle, e.getLocalizedMessage());
44         }
45     }
46 }
47
Popular Tags