KickJava   Java API By Example, From Geeks To Geeks.

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


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
18 import org.eclipse.ui.PlatformUI;
19
20 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
21 import org.eclipse.jdt.internal.ui.JavaPluginImages;
22
23 /**
24  * Toggles the call direction of the call hierarchy (i.e. toggles between showing callers and callees.)
25  */

26 class ToggleCallModeAction extends Action {
27
28     private CallHierarchyViewPart fView;
29     private int fMode;
30     
31     public ToggleCallModeAction(CallHierarchyViewPart v, int mode) {
32         super("", AS_RADIO_BUTTON); //$NON-NLS-1$
33
if (mode == CallHierarchyViewPart.CALL_MODE_CALLERS) {
34             setText(CallHierarchyMessages.ToggleCallModeAction_callers_label);
35             setDescription(CallHierarchyMessages.ToggleCallModeAction_callers_description);
36             setToolTipText(CallHierarchyMessages.ToggleCallModeAction_callers_tooltip);
37             JavaPluginImages.setLocalImageDescriptors(this, "ch_callers.gif"); //$NON-NLS-1$
38
} else if (mode == CallHierarchyViewPart.CALL_MODE_CALLEES) {
39             setText(CallHierarchyMessages.ToggleCallModeAction_callees_label);
40             setDescription(CallHierarchyMessages.ToggleCallModeAction_callees_description);
41             setToolTipText(CallHierarchyMessages.ToggleCallModeAction_callees_tooltip);
42             JavaPluginImages.setLocalImageDescriptors(this, "ch_callees.gif"); //$NON-NLS-1$
43
} else {
44             Assert.isTrue(false);
45         }
46         fView= v;
47         fMode= mode;
48         PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_TOGGLE_CALL_MODE_ACTION);
49     }
50     
51     public int getMode() {
52         return fMode;
53     }
54     
55     /*
56      * @see Action#actionPerformed
57      */

58     public void run() {
59         fView.setCallMode(fMode); // will toggle the checked state
60
}
61     
62 }
63
Popular Tags