01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
10: * (report 36180: Callers/Callees view)
11: *******************************************************************************/package org.eclipse.jdt.internal.ui.callhierarchy;
12:
13: import org.eclipse.core.runtime.Assert;
14:
15: import org.eclipse.jface.action.Action;
16:
17: import org.eclipse.ui.PlatformUI;
18:
19: import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
20: import org.eclipse.jdt.internal.ui.JavaPluginImages;
21:
22: /**
23: * Toggles the call direction of the call hierarchy (i.e. toggles between showing callers and callees.)
24: */
25: class ToggleCallModeAction extends Action {
26:
27: private CallHierarchyViewPart fView;
28: private int fMode;
29:
30: public ToggleCallModeAction(CallHierarchyViewPart v, int mode) {
31: super ("", AS_RADIO_BUTTON); //$NON-NLS-1$
32: if (mode == CallHierarchyViewPart.CALL_MODE_CALLERS) {
33: setText(CallHierarchyMessages.ToggleCallModeAction_callers_label);
34: setDescription(CallHierarchyMessages.ToggleCallModeAction_callers_description);
35: setToolTipText(CallHierarchyMessages.ToggleCallModeAction_callers_tooltip);
36: JavaPluginImages.setLocalImageDescriptors(this ,
37: "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 ,
43: "ch_callees.gif"); //$NON-NLS-1$
44: } else {
45: Assert.isTrue(false);
46: }
47: fView = v;
48: fMode = mode;
49: PlatformUI
50: .getWorkbench()
51: .getHelpSystem()
52: .setHelp(
53: this ,
54: IJavaHelpContextIds.CALL_HIERARCHY_TOGGLE_CALL_MODE_ACTION);
55: }
56:
57: public int getMode() {
58: return fMode;
59: }
60:
61: /*
62: * @see Action#actionPerformed
63: */
64: public void run() {
65: fView.setCallMode(fMode); // will toggle the checked state
66: }
67:
68: }
|