01: /*******************************************************************************
02: * Copyright (c) 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - Initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.browser;
11:
12: import java.net.URL;
13:
14: import org.eclipse.ui.IWorkbenchPage;
15: import org.eclipse.ui.IWorkbenchWindow;
16: import org.eclipse.ui.PartInitException;
17:
18: /**
19: * An instance of a running Web browser.
20: */
21: public class InternalBrowserViewInstance extends
22: InternalBrowserInstance {
23: public InternalBrowserViewInstance(String id, int style,
24: String name, String tooltip) {
25: super (WebBrowserUtil.encodeStyle(id, style), style, name,
26: tooltip);
27: }
28:
29: public void openURL(URL url) throws PartInitException {
30: IWorkbenchWindow workbenchWindow = WebBrowserUIPlugin
31: .getInstance().getWorkbench()
32: .getActiveWorkbenchWindow();
33: final IWorkbenchPage page = workbenchWindow.getActivePage();
34: WebBrowserView view = (WebBrowserView) part;
35: if (view == null) {
36: try {
37: view = (WebBrowserView) page.showView(
38: WebBrowserView.WEB_BROWSER_VIEW_ID, getId(),
39: IWorkbenchPage.VIEW_CREATE);
40: hookPart(page, view);
41: } catch (Exception e) {
42: Trace.trace(Trace.SEVERE,
43: "Error opening Web browser", e); //$NON-NLS-1$
44: }
45: }
46: if (view != null) {
47: page.bringToTop(view);
48: view.setURL(url.toExternalForm());
49: }
50: }
51:
52: public boolean close() {
53: return ((WebBrowserView) part).close();
54: }
55: }
|