01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.views.navigator;
11:
12: import org.eclipse.jface.viewers.Viewer;
13: import org.eclipse.swt.widgets.Shell;
14: import org.eclipse.ui.IWorkbench;
15: import org.eclipse.ui.IWorkbenchWindow;
16: import org.eclipse.ui.PlatformUI;
17: import org.eclipse.ui.actions.SelectionProviderAction;
18:
19: /**
20: * Superclass of all actions provided by the resource navigator.
21: */
22: public abstract class ResourceNavigatorAction extends
23: SelectionProviderAction {
24:
25: private IResourceNavigator navigator;
26:
27: /**
28: * Creates a new instance of the class.
29: */
30: public ResourceNavigatorAction(IResourceNavigator navigator,
31: String label) {
32: super (navigator.getViewer(), label);
33: this .navigator = navigator;
34: }
35:
36: /**
37: * Returns the resource navigator for which this action was created.
38: */
39: public IResourceNavigator getNavigator() {
40: return navigator;
41: }
42:
43: /**
44: * Returns the resource viewer
45: */
46: protected Viewer getViewer() {
47: return getNavigator().getViewer();
48: }
49:
50: /**
51: * Returns the shell to use within actions.
52: */
53: protected Shell getShell() {
54: return getNavigator().getSite().getShell();
55: }
56:
57: /**
58: * Returns the workbench.
59: */
60: protected IWorkbench getWorkbench() {
61: return PlatformUI.getWorkbench();
62: }
63:
64: /**
65: * Returns the workbench window.
66: */
67: protected IWorkbenchWindow getWorkbenchWindow() {
68: return getNavigator().getSite().getWorkbenchWindow();
69: }
70: }
|