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.BrowserManager;
14 import net.sourceforge.phpeclipse.webbrowser.internal.WebBrowser;
15 import net.sourceforge.phpeclipse.webbrowser.internal.WebBrowserUtil;
17 import org.eclipse.swt.browser.ProgressListener;
18 import org.eclipse.swt.browser.StatusTextListener;
19 import org.eclipse.swt.browser.TitleListener;
20 import org.eclipse.swt.widgets.Composite;
21 import org.eclipse.ui.part.ViewPart;
24 * <code>BrowserView</code> is a simple demonstration of the SWT Browser widget. It consists of a workbench view and tab folder
25 * where each tab in the folder allows the user to interact with a control.
29 public class BrowserView extends ViewPart {
30 public final static String ID_BROWSER = "net.sourceforge.phpeclipse.webbrowser.views";
32 WebBrowser fInstance = null;
38 * @see ViewPart#createPartControl
40 public void createPartControl(Composite frame) {
42 if (WebBrowserUtil.isInternalBrowserOperational()) {
43 fInstance = new WebBrowser(frame, true, true);
45 } catch (Exception e) {
51 * Called when we must grab focus.
53 * @see org.eclipse.ui.part.ViewPart#setFocus
55 public void setFocus() {
56 if (fInstance != null) {
62 * Called when the View is to be disposed
64 public void dispose() {
65 if (fInstance != null) {
72 public void setUrl(final String url) {
73 if (fInstance != null) {
75 fInstance.setURL(url);
77 // ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
78 // public void run(IProgressMonitor monitor) throws CoreException {
79 // instance.setURL(url);
82 // } catch (CoreException e) {
83 // // TODO Auto-generated catch block
84 // e.printStackTrace();
89 public void refresh() {
90 if (fInstance != null) {
93 // ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
94 // public void run(IProgressMonitor monitor) throws CoreException {
95 // instance.refresh();
98 // } catch (CoreException e) {
99 // // TODO Auto-generated catch block
100 // e.printStackTrace();
105 public void refresh(String url) {
106 if (fInstance != null) {
107 if (fUrl==null || !fUrl.equals(url) ) {
115 public void addProgressListener(ProgressListener listener) {
116 if (fInstance != null) {
117 fInstance.addProgressListener(listener);
121 public void addStatusTextListener(StatusTextListener listener) {
122 if (fInstance != null) {
123 fInstance.addStatusTextListener(listener);
127 public void addTitleListener(TitleListener listener) {
128 if (fInstance != null) {
129 fInstance.addTitleListener(listener);