01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 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: * Sebastian Davids <sdavids@gmx.de> - Images for menu items (27481)
11: *******************************************************************************/package org.eclipse.ui.views.navigator;
12:
13: import org.eclipse.jface.resource.ImageDescriptor;
14: import org.eclipse.jface.viewers.IStructuredSelection;
15: import org.eclipse.swt.events.KeyEvent;
16: import org.eclipse.ui.actions.ActionGroup;
17: import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
18:
19: /**
20: * This is the action group for all the resource navigator actions.
21: * It delegates to several subgroups for most of the actions.
22: *
23: * @see GotoActionGroup
24: * @see OpenActionGroup
25: * @see RefactorActionGroup
26: * @see SortAndFilterActionGroup
27: * @see WorkspaceActionGroup
28: *
29: * @since 2.0
30: */
31: public abstract class ResourceNavigatorActionGroup extends ActionGroup {
32:
33: /**
34: * The resource navigator.
35: */
36: protected IResourceNavigator navigator;
37:
38: /**
39: * Constructs a new navigator action group and creates its actions.
40: *
41: * @param navigator the resource navigator
42: */
43: public ResourceNavigatorActionGroup(IResourceNavigator navigator) {
44: this .navigator = navigator;
45: makeActions();
46: }
47:
48: /**
49: * Returns the image descriptor with the given relative path.
50: */
51: protected ImageDescriptor getImageDescriptor(String relativePath) {
52: return IDEWorkbenchPlugin.getIDEImageDescriptor(relativePath);
53:
54: }
55:
56: /**
57: * Returns the resource navigator.
58: */
59: public IResourceNavigator getNavigator() {
60: return navigator;
61: }
62:
63: /**
64: * Handles a key pressed event by invoking the appropriate action.
65: * Does nothing by default.
66: */
67: public void handleKeyPressed(KeyEvent event) {
68: }
69:
70: /**
71: * Makes the actions contained in this action group.
72: */
73: protected abstract void makeActions();
74:
75: /**
76: * Runs the default action in the group.
77: * Does nothing by default.
78: *
79: * @param selection the current selection
80: */
81: public void runDefaultAction(IStructuredSelection selection) {
82: }
83:
84: }
|