1 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.resource.ImageDescriptor; 18 19 import org.eclipse.ui.PlatformUI; 20 21 import org.eclipse.jdt.core.IJavaElement; 22 import org.eclipse.jdt.core.IMethod; 23 24 import org.eclipse.jdt.internal.corext.util.Messages; 25 26 import org.eclipse.jdt.ui.JavaElementLabelProvider; 27 28 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 29 import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider; 30 31 34 class HistoryAction extends Action { 35 private static JavaElementLabelProvider fLabelProvider = new JavaElementLabelProvider(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); fView = viewPart; 44 fMethod = element; 45 46 String elementName = getElementLabel(element); 47 setText(elementName); 48 setImageDescriptor(getImageDescriptor(element)); 49 50 setDescription(Messages.format(CallHierarchyMessages.HistoryAction_description, elementName)); 51 setToolTipText(Messages.format(CallHierarchyMessages.HistoryAction_tooltip, elementName)); 52 53 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_HISTORY_ACTION); 54 } 55 56 private ImageDescriptor getImageDescriptor(IJavaElement elem) { 57 JavaElementImageProvider imageProvider = new JavaElementImageProvider(); 58 ImageDescriptor desc = imageProvider.getBaseImageDescriptor(elem, 0); 59 imageProvider.dispose(); 60 61 return desc; 62 } 63 64 67 public void run() { 68 fView.gotoHistoryEntry(fMethod); 69 } 70 71 75 private String getElementLabel(IJavaElement element) { 76 Assert.isNotNull(element); 77 return fLabelProvider.getText(element); 78 } 79 } 80 | Popular Tags |