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.swt.browser.ProgressListener;
17 import org.eclipse.swt.browser.StatusTextListener;
18 import org.eclipse.swt.browser.TitleListener;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.ui.part.ViewPart;
23 * <code>BrowserView</code> is a simple demonstration of the SWT Browser widget. It consists of a workbench view and tab folder
24 * where each tab in the folder allows the user to interact with a control.
28 public class BrowserView extends ViewPart {
29 public final static String ID_BROWSER = "net.sourceforge.phpeclipse.webbrowser.views";
31 WebBrowser fInstance = null;
37 * @see ViewPart#createPartControl
39 public void createPartControl(Composite frame) {
41 if (WebBrowserUtil.isInternalBrowserOperational()) {
42 fInstance = new WebBrowser(frame, true, true);
44 } catch (Exception e) {
50 * Called when we must grab focus.
52 * @see org.eclipse.ui.part.ViewPart#setFocus
54 public void setFocus() {
55 if (fInstance != null) {
61 * Called when the View is to be disposed
63 public void dispose() {
64 if (fInstance != null) {
71 public void setUrl(final String url) {
72 if (fInstance != null) {
74 fInstance.setURL(url);
76 // ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
77 // public void run(IProgressMonitor monitor) throws CoreException {
78 // instance.setURL(url);
81 // } catch (CoreException e) {
82 // // TODO Auto-generated catch block
83 // e.printStackTrace();
88 public void refresh() {
89 if (fInstance != null) {
92 // ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
93 // public void run(IProgressMonitor monitor) throws CoreException {
94 // instance.refresh();
97 // } catch (CoreException e) {
98 // // TODO Auto-generated catch block
99 // e.printStackTrace();
104 public void refresh(String url) {
105 if (fInstance != null) {
106 if (fUrl==null || !fUrl.equals(url) ) {
114 public void addProgressListener(ProgressListener listener) {
115 if (fInstance != null) {
116 fInstance.addProgressListener(listener);
120 public void addStatusTextListener(StatusTextListener listener) {
121 if (fInstance != null) {
122 fInstance.addStatusTextListener(listener);
126 public void addTitleListener(TitleListener listener) {
127 if (fInstance != null) {
128 fInstance.addTitleListener(listener);