blob: 719ff862602a155c11b383f5abac01feae534764 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corporation and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
*******************************************************************************/
package org.eclipse.dltk.internal.ui.callhierarchy;
import org.eclipse.core.runtime.Assert;
import org.eclipse.dltk.core.DLTKCore;
import org.eclipse.dltk.ui.DLTKPluginImages;
import org.eclipse.jface.action.Action;
/**
* Toggles the call direction of the call hierarchy (i.e. toggles between showing callers and callees.)
*/
class ToggleCallModeAction extends Action {
private CallHierarchyViewPart fView;
private int fMode;
public ToggleCallModeAction(CallHierarchyViewPart v, int mode) {
super("", AS_RADIO_BUTTON); //$NON-NLS-1$
if (mode == CallHierarchyViewPart.CALL_MODE_CALLERS) {
setText(CallHierarchyMessages.ToggleCallModeAction_callers_label);
setDescription(CallHierarchyMessages.ToggleCallModeAction_callers_description);
setToolTipText(CallHierarchyMessages.ToggleCallModeAction_callers_tooltip);
DLTKPluginImages.setLocalImageDescriptors(this, "ch_callers.png"); //$NON-NLS-1$
} else if (mode == CallHierarchyViewPart.CALL_MODE_CALLEES) {
setText(CallHierarchyMessages.ToggleCallModeAction_callees_label);
setDescription(CallHierarchyMessages.ToggleCallModeAction_callees_description);
setToolTipText(CallHierarchyMessages.ToggleCallModeAction_callees_tooltip);
DLTKPluginImages.setLocalImageDescriptors(this, "ch_callees.png"); //$NON-NLS-1$
} else {
Assert.isTrue(false);
}
fView= v;
fMode= mode;
if (DLTKCore.DEBUG) {
System.err.println("Add help support here..."); //$NON-NLS-1$
}
// PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_TOGGLE_CALL_MODE_ACTION);
}
public int getMode() {
return fMode;
}
@Override
public void run() {
fView.setCallMode(fMode); // will toggle the checked state
}
}