1 11 12 package org.eclipse.debug.internal.ui.views.memory; 13 14 import java.math.BigInteger ; 15 import org.eclipse.debug.core.DebugException; 16 import org.eclipse.debug.internal.ui.DebugUIMessages; 17 import org.eclipse.debug.internal.ui.DebugUIPlugin; 18 import org.eclipse.debug.ui.IDebugUIConstants; 19 import org.eclipse.jface.action.Action; 20 import org.eclipse.jface.window.Window; 21 import org.eclipse.swt.widgets.Shell; 22 import org.eclipse.ui.help.WorkbenchHelp; 23 24 25 30 public class GoToAddressAction extends Action 31 { 32 private ITableMemoryViewTab fViewTab; 33 34 private static final String PREFIX = "GoToAddressAction."; private static final String TITLE = PREFIX + "title"; private static final String GO_TO_ADDRESS_FAILED = PREFIX + "Go_to_address_failed"; private static final String ADDRESS_IS_INVALID = PREFIX + "Address_is_invalid"; private static final String TOOLTIP = PREFIX + "tooltip"; 40 public GoToAddressAction(ITableMemoryViewTab viewTab) 41 { 42 super(DebugUIMessages.getString(TITLE)); 43 fViewTab = viewTab; 44 setToolTipText(DebugUIMessages.getString(TOOLTIP)); 45 46 WorkbenchHelp.setHelp(this, IDebugUIConstants.PLUGIN_ID + ".GoToAddressAction_context"); 48 } 50 53 public void run() 54 { 55 try 56 { 57 Shell shell= DebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(); 58 59 GoToAddressDialog dialog = new GoToAddressDialog(shell); 61 dialog.open(); 62 63 int returnCode = dialog.getReturnCode(); 64 65 if (returnCode == Window.CANCEL) 66 { 67 return; 68 } 69 70 String expression = dialog.getExpression(); 72 73 expression = expression.toUpperCase(); 74 expression = expression.trim(); 75 76 if (expression.startsWith("0X")) { 78 expression = expression.substring(2); 79 } 80 81 BigInteger address = new BigInteger (expression, 16); 83 84 fViewTab.goToAddress(address); 86 } 87 catch (DebugException e) 89 { 90 MemoryViewUtil.openError(DebugUIMessages.getString(GO_TO_ADDRESS_FAILED), 91 DebugUIMessages.getString(GO_TO_ADDRESS_FAILED), e); 92 } 93 catch (NumberFormatException e1) 94 { 95 MemoryViewUtil.openError(DebugUIMessages.getString(GO_TO_ADDRESS_FAILED), 96 DebugUIMessages.getString(ADDRESS_IS_INVALID), null); 97 } 98 } 99 100 } 101 | Popular Tags |