KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > navigator > ResourceNavigatorAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.views.navigator;
12
13 import org.eclipse.jface.viewers.Viewer;
14 import org.eclipse.swt.widgets.Shell;
15 import org.eclipse.ui.IWorkbench;
16 import org.eclipse.ui.IWorkbenchWindow;
17 import org.eclipse.ui.PlatformUI;
18 import org.eclipse.ui.actions.SelectionProviderAction;
19
20 /**
21  * Superclass of all actions provided by the resource navigator.
22  */

23 public abstract class ResourceNavigatorAction extends SelectionProviderAction {
24
25     private IResourceNavigator navigator;
26
27     /**
28      * Creates a new instance of the class.
29      */

30     public ResourceNavigatorAction(IResourceNavigator navigator, String JavaDoc label) {
31         super(navigator.getViewer(), label);
32         this.navigator = navigator;
33     }
34
35     /**
36      * Returns the resource navigator for which this action was created.
37      */

38     public IResourceNavigator getNavigator() {
39         return navigator;
40     }
41
42     /**
43      * Returns the resource viewer
44      */

45     protected Viewer getViewer() {
46         return getNavigator().getViewer();
47     }
48
49     /**
50      * Returns the shell to use within actions.
51      */

52     protected Shell getShell() {
53         return getNavigator().getSite().getShell();
54     }
55
56     /**
57      * Returns the workbench.
58      */

59     protected IWorkbench getWorkbench() {
60         return PlatformUI.getWorkbench();
61     }
62
63     /**
64      * Returns the workbench window.
65      */

66     protected IWorkbenchWindow getWorkbenchWindow() {
67         return getNavigator().getSite().getWorkbenchWindow();
68     }
69 }
70
Popular Tags