1 11 12 package org.eclipse.debug.internal.ui.views.memory.renderings; 13 14 import java.lang.reflect.Method ; 15 16 import org.eclipse.debug.core.DebugException; 17 import org.eclipse.debug.internal.ui.DebugPluginImages; 18 import org.eclipse.debug.internal.ui.DebugUIMessages; 19 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 20 import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil; 21 import org.eclipse.debug.ui.IDebugUIConstants; 22 import org.eclipse.debug.ui.memory.AbstractTableRendering; 23 import org.eclipse.jface.action.Action; 24 import org.eclipse.ui.PlatformUI; 25 26 31 public class ResetToBaseAddressAction extends Action { 32 33 private AbstractBaseTableRendering fRendering; 34 35 public ResetToBaseAddressAction(AbstractBaseTableRendering rendering) { 36 fRendering = rendering; 37 setText(DebugUIMessages.ResetMemoryBlockAction_title); 38 setToolTipText(DebugUIMessages.ResetMemoryBlockAction_tootip); 39 40 setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_RESET_MEMORY)); 41 setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_LCL_RESET_MEMORY)); 42 setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_RESET_MEMORY)); 43 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugUIConstants.PLUGIN_ID + ".ResetBaseAddressContextAction_context"); } 45 46 51 public void run() { 52 53 Class renderingClass = fRendering.getClass(); 59 try { 60 Method method = renderingClass.getMethod("reset", new Class []{}); if (method.getDeclaringClass().equals(AbstractTableRendering.class)) 62 { 63 try { 65 fRendering.resetRendering(); 66 } catch (DebugException e) { 67 MemoryViewUtil.openError(DebugUIMessages.AbstractTableRendering_12, DebugUIMessages.AbstractTableRendering_13, e); } 69 return; 70 } 71 } catch (SecurityException e) { 72 } catch (NoSuchMethodException e) { 73 try { 74 fRendering.resetRendering(); 76 } catch (DebugException e1) { 77 MemoryViewUtil.openError(DebugUIMessages.AbstractTableRendering_12, DebugUIMessages.AbstractTableRendering_13, e); } 79 } 80 81 if(fRendering instanceof AbstractTableRendering) 82 { 83 ((AbstractTableRendering)fRendering).reset(); 85 } 86 } 87 } 88 | Popular Tags |