updated build.xml
[phpeclipse.git] / net.sourceforge.phpeclipse.webbrowser / src / net / sourceforge / phpeclipse / webbrowser / views / BrowserView.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpeclipse.webbrowser.views;
12
13 import net.sourceforge.phpeclipse.webbrowser.internal.WebBrowser;
14 import net.sourceforge.phpeclipse.webbrowser.internal.WebBrowserUtil;
15
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.widgets.Composite;
24 import org.eclipse.ui.part.ViewPart;
25
26 /**
27  * <code>BrowserView</code> is a simple demonstration of the SWT Browser widget. It consists of a workbench view and tab folder
28  * where each tab in the folder allows the user to interact with a control.
29  * 
30  * @see ViewPart
31  */
32 public class BrowserView extends ViewPart {
33   public final static String ID_BROWSER = "net.sourceforge.phpeclipse.webbrowser.views";
34
35   WebBrowser instance = null;
36
37   /**
38    * Create the example
39    * 
40    * @see ViewPart#createPartControl
41    */
42   public void createPartControl(Composite frame) {
43     try {
44       if (WebBrowserUtil.canUseInternalWebBrowser()) {
45         instance = new WebBrowser(frame, true, true);
46       }
47     } catch (Exception e) {
48       instance = null;
49     }
50   }
51
52   /**
53    * Called when we must grab focus.
54    * 
55    * @see org.eclipse.ui.part.ViewPart#setFocus
56    */
57   public void setFocus() {
58     if (instance != null) {
59       instance.setFocus();
60     }
61   }
62
63   /**
64    * Called when the View is to be disposed
65    */
66   public void dispose() {
67     if (instance != null) {
68       instance.dispose();
69       instance = null;
70     }
71     super.dispose();
72   }
73
74   public void setUrl(final String url) {
75     if (instance != null) {
76       instance.setURL(url);
77 //      try {
78 //        ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
79 //          public void run(IProgressMonitor monitor) throws CoreException {
80 //            instance.setURL(url);
81 //          }
82 //        }, null);
83 //      } catch (CoreException e) {
84 //        // TODO Auto-generated catch block
85 //        e.printStackTrace();
86 //      }
87     }
88   }
89
90   public void refresh() {
91     if (instance != null) {
92       instance.refresh();
93 //      try {
94 //        ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
95 //          public void run(IProgressMonitor monitor) throws CoreException {
96 //            instance.refresh();
97 //          }
98 //        }, null);
99 //      } catch (CoreException e) {
100 //        // TODO Auto-generated catch block
101 //        e.printStackTrace();
102 //      }
103     }
104   }
105 }