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: import org.eclipse.jface.resource.ImageDescriptor;
17:
18: import org.eclipse.ui.PlatformUI;
19:
20: import org.eclipse.jdt.core.IJavaElement;
21: import org.eclipse.jdt.core.IMethod;
22:
23: import org.eclipse.jdt.internal.corext.util.Messages;
24:
25: import org.eclipse.jdt.ui.JavaElementLabelProvider;
26:
27: import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
28: import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
29:
30: /**
31: * Action used for the type hierarchy forward / backward buttons
32: */
33: class HistoryAction extends Action {
34: private static JavaElementLabelProvider fLabelProvider = new JavaElementLabelProvider(
35: JavaElementLabelProvider.SHOW_POST_QUALIFIED
36: | JavaElementLabelProvider.SHOW_PARAMETERS
37: | JavaElementLabelProvider.SHOW_RETURN_TYPE);
38: private CallHierarchyViewPart fView;
39: private IMethod fMethod;
40:
41: public HistoryAction(CallHierarchyViewPart viewPart, IMethod element) {
42: super ("", AS_RADIO_BUTTON); //$NON-NLS-1$
43: fView = viewPart;
44: fMethod = element;
45:
46: String elementName = getElementLabel(element);
47: setText(elementName);
48: setImageDescriptor(getImageDescriptor(element));
49:
50: setDescription(Messages.format(
51: CallHierarchyMessages.HistoryAction_description,
52: elementName));
53: setToolTipText(Messages.format(
54: CallHierarchyMessages.HistoryAction_tooltip,
55: elementName));
56:
57: PlatformUI.getWorkbench().getHelpSystem().setHelp(this ,
58: IJavaHelpContextIds.CALL_HIERARCHY_HISTORY_ACTION);
59: }
60:
61: private ImageDescriptor getImageDescriptor(IJavaElement elem) {
62: JavaElementImageProvider imageProvider = new JavaElementImageProvider();
63: ImageDescriptor desc = imageProvider.getBaseImageDescriptor(
64: elem, 0);
65: imageProvider.dispose();
66:
67: return desc;
68: }
69:
70: /*
71: * @see Action#run()
72: */
73: public void run() {
74: fView.gotoHistoryEntry(fMethod);
75: }
76:
77: /**
78: * @param element
79: * @return String
80: */
81: private String getElementLabel(IJavaElement element) {
82: Assert.isNotNull(element);
83: return fLabelProvider.getText(element);
84: }
85: }
|