1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpeclipse.webbrowser.views;
13 import net.sourceforge.phpeclipse.webbrowser.internal.WebBrowser;
14 import net.sourceforge.phpeclipse.webbrowser.internal.WebBrowserUtil;
16 import org.eclipse.core.resources.IWorkspaceRunnable;
17 import org.eclipse.core.resources.ResourcesPlugin;
18 import org.eclipse.core.runtime.CoreException;
19 import org.eclipse.core.runtime.IProgressMonitor;
20 import org.eclipse.core.runtime.IStatus;
21 import org.eclipse.core.runtime.Status;
22 import org.eclipse.core.runtime.jobs.Job;
23 import org.eclipse.swt.browser.ProgressListener;
24 import org.eclipse.swt.browser.StatusTextListener;
25 import org.eclipse.swt.browser.TitleListener;
26 import org.eclipse.swt.widgets.Composite;
27 import org.eclipse.ui.part.ViewPart;
30 * <code>BrowserView</code> is a simple demonstration of the SWT Browser widget. It consists of a workbench view and tab folder
31 * where each tab in the folder allows the user to interact with a control.
35 public class BrowserView extends ViewPart {
36 public final static String ID_BROWSER = "net.sourceforge.phpeclipse.webbrowser.views";
38 WebBrowser instance = null;
43 * @see ViewPart#createPartControl
45 public void createPartControl(Composite frame) {
47 if (WebBrowserUtil.canUseInternalWebBrowser()) {
48 instance = new WebBrowser(frame, true, true);
50 } catch (Exception e) {
56 * Called when we must grab focus.
58 * @see org.eclipse.ui.part.ViewPart#setFocus
60 public void setFocus() {
61 if (instance != null) {
67 * Called when the View is to be disposed
69 public void dispose() {
70 if (instance != null) {
77 public void setUrl(final String url) {
78 if (instance != null) {
81 // ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
82 // public void run(IProgressMonitor monitor) throws CoreException {
83 // instance.setURL(url);
86 // } catch (CoreException e) {
87 // // TODO Auto-generated catch block
88 // e.printStackTrace();
93 public void refresh() {
94 if (instance != null) {
97 // ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
98 // public void run(IProgressMonitor monitor) throws CoreException {
99 // instance.refresh();
102 // } catch (CoreException e) {
103 // // TODO Auto-generated catch block
104 // e.printStackTrace();
109 public void addProgressListener(ProgressListener listener) {
110 if (instance != null) {
111 instance.addProgressListener(listener);
115 public void addStatusTextListener(StatusTextListener listener) {
116 if (instance != null) {
117 instance.addStatusTextListener(listener);
121 public void addTitleListener(TitleListener listener) {
122 if (instance != null) {
123 instance.addTitleListener(listener);