KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > callhierarchy > CallHierarchyFiltersActionGroup


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  * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
10  * (report 36180: Callers/Callees view)
11  *******************************************************************************/

12 package org.eclipse.jdt.internal.ui.callhierarchy;
13
14 import org.eclipse.core.runtime.Assert;
15
16 import org.eclipse.jface.action.Action;
17 import org.eclipse.jface.action.IMenuManager;
18 import org.eclipse.jface.action.Separator;
19 import org.eclipse.jface.viewers.StructuredViewer;
20
21 import org.eclipse.ui.IActionBars;
22 import org.eclipse.ui.IViewPart;
23 import org.eclipse.ui.actions.ActionGroup;
24
25 import org.eclipse.jdt.internal.ui.JavaPluginImages;
26
27 /**
28  * Action group to add the filter action to a view part's toolbar
29  * menu.
30  * <p>
31  * This class may be instantiated; it is not intended to be subclassed.
32  * </p>
33  */

34 public class CallHierarchyFiltersActionGroup extends ActionGroup {
35
36     class ShowFilterDialogAction extends Action {
37         ShowFilterDialogAction() {
38             setText(CallHierarchyMessages.ShowFilterDialogAction_text);
39             setImageDescriptor(JavaPluginImages.DESC_ELCL_FILTER);
40             setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_FILTER);
41         }
42         
43         public void run() {
44             openDialog();
45         }
46     }
47
48     private IViewPart fPart;
49
50     /**
51      * Creates a new <code>CustomFiltersActionGroup</code>.
52      *
53      * @param part the view part that owns this action group
54      * @param viewer the viewer to be filtered
55      */

56     public CallHierarchyFiltersActionGroup(IViewPart part, StructuredViewer viewer) {
57         Assert.isNotNull(part);
58         Assert.isNotNull(viewer);
59         fPart= part;
60     }
61
62     /* (non-Javadoc)
63      * Method declared on ActionGroup.
64      */

65     public void fillActionBars(IActionBars actionBars) {
66         fillViewMenu(actionBars.getMenuManager());
67     }
68
69     private void fillViewMenu(IMenuManager viewMenu) {
70         viewMenu.add(new Separator("filters")); //$NON-NLS-1$
71
viewMenu.add(new ShowFilterDialogAction());
72     }
73
74     /* (non-Javadoc)
75      * Method declared on ActionGroup.
76      */

77     public void dispose() {
78         super.dispose();
79     }
80     
81     // ---------- dialog related code ----------
82

83     private void openDialog() {
84         FiltersDialog dialog= new FiltersDialog(
85             fPart.getViewSite().getShell());
86         
87         dialog.open();
88     }
89 }
90
Popular Tags