KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2005 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.URL JavaDoc;
14
15 import org.eclipse.ui.IWorkbenchPage;
16 import org.eclipse.ui.IWorkbenchWindow;
17 import org.eclipse.ui.PartInitException;
18 /**
19  * An instance of a running Web browser.
20  */

21 public class InternalBrowserViewInstance extends InternalBrowserInstance {
22     public InternalBrowserViewInstance(String JavaDoc id, int style, String JavaDoc name, String JavaDoc tooltip) {
23         super(WebBrowserUtil.encodeStyle(id, style), style, name, tooltip);
24     }
25
26     public void openURL(URL JavaDoc url) throws PartInitException {
27         IWorkbenchWindow workbenchWindow = WebBrowserUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow();
28         final IWorkbenchPage page = workbenchWindow.getActivePage();
29         WebBrowserView view = (WebBrowserView)part;
30         if (view == null) {
31             try {
32                 view = (WebBrowserView)page.showView(WebBrowserView.WEB_BROWSER_VIEW_ID, getId(), IWorkbenchPage.VIEW_CREATE);
33                 hookPart(page, view);
34             } catch (Exception JavaDoc e) {
35                 Trace.trace(Trace.SEVERE, "Error opening Web browser", e); //$NON-NLS-1$
36
}
37         }
38         if (view!=null) {
39             page.bringToTop(view);
40             view.setURL(url.toExternalForm());
41         }
42     }
43
44     public boolean close() {
45         return ((WebBrowserView)part).close();
46     }
47 }
Popular Tags