KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > actions > ActionGroup


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.actions;
12
13 import org.eclipse.jface.action.IMenuManager;
14 import org.eclipse.ui.IActionBars;
15
16 /**
17  * An <code>ActionGroup</code> represents a group of actions
18  * which are added to a context menu, or the action bars of a part, together.
19  * The group is given a context which can be used to determine which actions
20  * are added, and what their enabled state should be.
21  * <p>
22  * This class is intended only as a convenience for managing groups of actions.
23  * Clients are not required to use this class in order to add actions to context
24  * menus or action bars.
25  * </p>
26  * <p>
27  * Clients should subclass this class and extend or override the appropriate fill methods.
28  * </p>
29  *
30  * @since 2.0
31  */

32 public abstract class ActionGroup {
33
34     /**
35      * The action context, used to determine which actions are added,
36      * and what their enabled state should be.
37      */

38     private ActionContext context;
39
40     /**
41      * Returns the context used to determine which actions are added,
42      * and what their enabled state should be.
43      */

44     public ActionContext getContext() {
45         return context;
46     }
47
48     /**
49      * Sets the context used to determine which actions are added,
50      * and what their enabled state should be.
51      *
52      * @param context the context to use
53      */

54     public void setContext(ActionContext context) {
55         this.context = context;
56     }
57
58     /**
59      * Adds the applicable actions to a context menu,
60      * based on the state of the <code>ActionContext</code>.
61      * <p>
62      * The default implementation does nothing.
63      * Subclasses may override or extend this method.
64      * </p>
65      *
66      * @param menu the context menu manager
67      */

68     public void fillContextMenu(IMenuManager menu) {
69         // do nothing
70
}
71
72     /**
73      * Adds the applicable actions to a part's action bars,
74      * including setting any global action handlers.
75      * <p>
76      * The default implementation does nothing.
77      * Subclasses may override or extend this method.
78      * </p>
79      *
80      * @param actionBars the part's action bars
81      */

82     public void fillActionBars(IActionBars actionBars) {
83         // do nothing
84
}
85
86     /**
87      * Updates the state of the actions added to the action bars,
88      * including any global action handlers,
89      * based on the state of the <code>ActionContext</code>.
90      * <p>
91      * The default implementation does nothing.
92      * Subclasses may override or extend this method.
93      * </p>
94      */

95     public void updateActionBars() {
96         // do nothing
97
}
98
99     /**
100      * This method is called by the user of an action group to signal that the group is
101      * no longer needed. Subclasses typically implement this method to deregister
102      * any listeners or to free other resources.
103      * <p>
104      * The default implementation calls <code>setContext(null)</code>.
105      * Subclasses may extend this method.
106      * </p>
107      */

108     public void dispose() {
109         setContext(null);
110     }
111 }
112
Popular Tags