KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 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 org.eclipse.jface.viewers.ISelection;
14 import org.eclipse.jface.action.IAction;
15 import org.eclipse.ui.*;
16 import org.eclipse.ui.browser.IWebBrowser;
17 import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
18 /**
19  * Action to open the Web broswer.
20  */

21 public class OpenBrowserWorkbenchAction implements IWorkbenchWindowActionDelegate {
22     /**
23      * OpenBrowserWorkbenchAction constructor comment.
24      */

25     public OpenBrowserWorkbenchAction() {
26         super();
27     }
28
29     /**
30      * Disposes this action delegate. The implementor should unhook any references
31      * to itself so that garbage collection can occur.
32      */

33     public void dispose() {
34         // do nothing
35
}
36
37     /**
38      * Initializes this action delegate with the workbench window it will work in.
39      *
40      * @param window the window that provides the context for this delegate
41      */

42     public void init(IWorkbenchWindow window) {
43         // do nothing
44
}
45
46     /**
47      * Performs this action.
48      * <p>
49      * This method is called when the delegating action has been triggered.
50      * Implement this method to do the actual work.
51      * </p>
52      *
53      * @param action the action proxy that handles the presentation portion of the
54      * action
55      */

56     public void run(IAction action) {
57         try {
58             IWorkbenchBrowserSupport browserSupport = WebBrowserUIPlugin.getInstance().getWorkbench().getBrowserSupport();
59             IWebBrowser browser = browserSupport.createBrowser(IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR, null, null, null);
60             browser.openURL(null);
61         } catch (Exception JavaDoc e) {
62             Trace.trace(Trace.SEVERE, "Error opening browser", e); //$NON-NLS-1$
63
}
64     }
65
66     /**
67      * Notifies this action delegate that the selection in the workbench has changed.
68      * <p>
69      * Implementers can use this opportunity to change the availability of the
70      * action or to modify other presentation properties.
71      * </p>
72      *
73      * @param action the action proxy that handles presentation portion of the action
74      * @param selection the current selection in the workbench
75      */

76     public void selectionChanged(IAction action, ISelection selection) {
77         // do nothing
78
}
79 }
80
Popular Tags