KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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  * Sebastian Davids <sdavids@gmx.de> - Images for menu items (27481)
11  *******************************************************************************/

12 package org.eclipse.ui.views.navigator;
13
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.eclipse.jface.viewers.IStructuredSelection;
16 import org.eclipse.swt.events.KeyEvent;
17 import org.eclipse.ui.actions.ActionGroup;
18 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
19
20 /**
21  * This is the action group for all the resource navigator actions.
22  * It delegates to several subgroups for most of the actions.
23  *
24  * @see GotoActionGroup
25  * @see OpenActionGroup
26  * @see RefactorActionGroup
27  * @see SortAndFilterActionGroup
28  * @see WorkspaceActionGroup
29  *
30  * @since 2.0
31  */

32 public abstract class ResourceNavigatorActionGroup extends ActionGroup {
33
34     /**
35      * The resource navigator.
36      */

37     protected IResourceNavigator navigator;
38     
39     /**
40      * Constructs a new navigator action group and creates its actions.
41      *
42      * @param navigator the resource navigator
43      */

44     public ResourceNavigatorActionGroup(IResourceNavigator navigator) {
45         this.navigator = navigator;
46         makeActions();
47     }
48
49     /**
50      * Returns the image descriptor with the given relative path.
51      */

52     protected ImageDescriptor getImageDescriptor(String JavaDoc relativePath) {
53        return IDEWorkbenchPlugin.getIDEImageDescriptor(relativePath);
54      
55     }
56
57     /**
58      * Returns the resource navigator.
59      */

60     public IResourceNavigator getNavigator() {
61         return navigator;
62     }
63
64     /**
65      * Handles a key pressed event by invoking the appropriate action.
66      * Does nothing by default.
67      */

68     public void handleKeyPressed(KeyEvent event) {
69     }
70
71     /**
72      * Makes the actions contained in this action group.
73      */

74     protected abstract void makeActions();
75
76     /**
77      * Runs the default action in the group.
78      * Does nothing by default.
79      *
80      * @param selection the current selection
81      */

82     public void runDefaultAction(IStructuredSelection selection) {
83     }
84
85 }
86
Popular Tags