KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > ui > actions > NavigateActionGroup


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  *******************************************************************************/

11 package org.eclipse.jdt.ui.actions;
12
13 import org.eclipse.jface.action.IAction;
14 import org.eclipse.jface.action.IMenuManager;
15
16 import org.eclipse.ui.IActionBars;
17 import org.eclipse.ui.IViewPart;
18 import org.eclipse.ui.actions.ActionContext;
19 import org.eclipse.ui.actions.ActionGroup;
20
21 /**
22  * Action group that adds the open and show actions to a context menu and
23  * the action bar's navigate menu. This action group reuses the <code>
24  * OpenEditorActionGroup</code> and <code>OpenViewActionGroup</code>.
25  *
26  * <p>
27  * This class may be instantiated; it is not intended to be subclassed.
28  * </p>
29  *
30  * @since 2.0
31  */

32 public class NavigateActionGroup extends ActionGroup {
33
34     private OpenEditorActionGroup fOpenEditorActionGroup;
35     private OpenViewActionGroup fOpenViewActionGroup;
36     
37     /**
38      * Creates a new <code>NavigateActionGroup</code>. The group requires
39      * that the selection provided by the part's selection provider is of type <code>
40      * org.eclipse.jface.viewers.IStructuredSelection</code>.
41      *
42      * @param part the view part that owns this action group
43      */

44     public NavigateActionGroup(IViewPart part) {
45         fOpenEditorActionGroup= new OpenEditorActionGroup(part);
46         fOpenViewActionGroup= new OpenViewActionGroup(part);
47     }
48
49     /**
50      * Returns the open action managed by this action group.
51      *
52      * @return the open action. Returns <code>null</code> if the group
53      * doesn't provide any open action
54      */

55     public IAction getOpenAction() {
56         return fOpenEditorActionGroup.getOpenAction();
57     }
58     
59     /* (non-Javadoc)
60      * Method declared in ActionGroup
61      */

62     public void dispose() {
63         super.dispose();
64         fOpenEditorActionGroup.dispose();
65         fOpenViewActionGroup.dispose();
66     }
67
68     /* (non-Javadoc)
69      * Method declared in ActionGroup
70      */

71     public void fillActionBars(IActionBars actionBars) {
72         super.fillActionBars(actionBars);
73         fOpenEditorActionGroup.fillActionBars(actionBars);
74         fOpenViewActionGroup.fillActionBars(actionBars);
75     }
76
77     /* (non-Javadoc)
78      * Method declared in ActionGroup
79      */

80     public void fillContextMenu(IMenuManager menu) {
81         super.fillContextMenu(menu);
82         
83         fOpenEditorActionGroup.fillContextMenu(menu);
84         fOpenViewActionGroup.fillContextMenu(menu);
85     }
86
87     /* (non-Javadoc)
88      * Method declared in ActionGroup
89      */

90     public void setContext(ActionContext context) {
91         super.setContext(context);
92         fOpenEditorActionGroup.setContext(context);
93         fOpenViewActionGroup.setContext(context);
94     }
95
96     /* (non-Javadoc)
97      * Method declared in ActionGroup
98      */

99     public void updateActionBars() {
100         super.updateActionBars();
101         fOpenEditorActionGroup.updateActionBars();
102         fOpenViewActionGroup.updateActionBars();
103     }
104 }
105
Popular Tags