mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 08:55:25 +02:00
This completes the contribution of the memory space support for the memory view.
This commit is contained in:
parent
7bbaad75fa
commit
93b18262ed
8 changed files with 198 additions and 123 deletions
|
@ -12,6 +12,8 @@ package org.eclipse.cdt.debug.core.cdi.model;
|
|||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
|
||||
/**
|
||||
* The memory space manager provides varous memory-space related operations.
|
||||
* The backend implementation of ICDITarget should implement this interface
|
||||
|
@ -30,6 +32,16 @@ public interface ICDIMemorySpaceManagement extends ICDIObject {
|
|||
*/
|
||||
String addressToString(BigInteger address, String memorySpaceID);
|
||||
|
||||
/**
|
||||
* The inverse of addressToString
|
||||
*
|
||||
* @param str - the encoded string (contains memory space + hex address value)
|
||||
* @param memorySpaceID_out the memory space ID
|
||||
* @return the BigInteger part of str; client should return null if the default decoding provided
|
||||
* by CDT is sufficient (<memory-space-id>:<address(hex)>)
|
||||
*/
|
||||
BigInteger stringToAddress(String str, StringBuffer memorySpaceID_out) throws CDIException;
|
||||
|
||||
/**
|
||||
* Provides the memory spaces available.
|
||||
*
|
||||
|
|
|
@ -55,7 +55,10 @@ import org.w3c.dom.NodeList;
|
|||
public class CMemoryBlockRetrievalExtension extends PlatformObject implements IMemoryBlockRetrievalExtension {
|
||||
|
||||
private static final String MEMORY_BLOCK_EXPRESSION_LIST = "memoryBlockExpressionList"; //$NON-NLS-1$
|
||||
private static final String MEMORY_BLOCK_EXPRESSION_ITEM = "memoryBlockExpressionItem"; //$NON-NLS-1$
|
||||
private static final String MEMORY_BLOCK_EXPRESSION = "expression"; //$NON-NLS-1$
|
||||
private static final String MEMORY_BLOCK_MEMSPACEID = "memorySpaceID"; //$NON-NLS-1$
|
||||
private static final String ATTR_MEMORY_BLOCK_MEMSPACEID_TEXT = "text"; //$NON-NLS-1$
|
||||
private static final String ATTR_MEMORY_BLOCK_EXPRESSION_TEXT = "text"; //$NON-NLS-1$
|
||||
|
||||
CDebugTarget fDebugTarget;
|
||||
|
@ -83,35 +86,63 @@ public class CMemoryBlockRetrievalExtension extends PlatformObject implements IM
|
|||
}
|
||||
}
|
||||
|
||||
private void parseMementoExprItem(Element element, List expressions, List memorySpaceIDs) {
|
||||
NodeList list = element.getChildNodes();
|
||||
int length = list.getLength();
|
||||
String exp = null;
|
||||
String memorySpaceID = null;
|
||||
for( int i = 0; i < length; ++i ) {
|
||||
Node node = list.item( i );
|
||||
if ( node.getNodeType() == Node.ELEMENT_NODE ) {
|
||||
Element entry = (Element)node;
|
||||
if ( entry.getNodeName().equalsIgnoreCase( MEMORY_BLOCK_EXPRESSION ) ) {
|
||||
exp = entry.getAttribute( ATTR_MEMORY_BLOCK_EXPRESSION_TEXT );
|
||||
} else if ( entry.getNodeName().equalsIgnoreCase( MEMORY_BLOCK_MEMSPACEID ) ) {
|
||||
memorySpaceID = entry.getAttribute( ATTR_MEMORY_BLOCK_MEMSPACEID_TEXT );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (exp != null) {
|
||||
expressions.add( exp );
|
||||
memorySpaceIDs.add( memorySpaceID );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initializeFromMemento( String memento ) throws CoreException {
|
||||
Element root = DebugPlugin.parseDocument( memento );
|
||||
if ( root.getNodeName().equalsIgnoreCase( MEMORY_BLOCK_EXPRESSION_LIST ) ) {
|
||||
List expressions = new ArrayList();
|
||||
List memorySpaceIDs = new ArrayList();
|
||||
NodeList list = root.getChildNodes();
|
||||
int length = list.getLength();
|
||||
for( int i = 0; i < length; ++i ) {
|
||||
Node node = list.item( i );
|
||||
short type = node.getNodeType();
|
||||
if ( type == Node.ELEMENT_NODE ) {
|
||||
if ( node.getNodeType() == Node.ELEMENT_NODE ) {
|
||||
Element entry = (Element)node;
|
||||
if ( entry.getNodeName().equalsIgnoreCase( MEMORY_BLOCK_EXPRESSION ) ) {
|
||||
String exp = entry.getAttribute( ATTR_MEMORY_BLOCK_EXPRESSION_TEXT );
|
||||
expressions.add( exp );
|
||||
if ( entry.getNodeName().equalsIgnoreCase( MEMORY_BLOCK_EXPRESSION_ITEM ) ) {
|
||||
parseMementoExprItem(entry, expressions, memorySpaceIDs);
|
||||
}
|
||||
}
|
||||
}
|
||||
createMemoryBlocks( (String[])expressions.toArray( new String[expressions.size()] ) );
|
||||
createMemoryBlocks( (String[])expressions.toArray( new String[expressions.size()]) ,
|
||||
(String[])memorySpaceIDs.toArray( new String[memorySpaceIDs.size()]));
|
||||
|
||||
return;
|
||||
}
|
||||
abort( InternalDebugCoreMessages.getString( "CMemoryBlockRetrievalExtension.3" ), null ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private void createMemoryBlocks( String[] expressions ) {
|
||||
private void createMemoryBlocks( String[] expressions, String[] memorySpaceIDs ) {
|
||||
ArrayList list = new ArrayList( expressions.length );
|
||||
for ( int i = 0; i < expressions.length; ++i ) {
|
||||
IAddress address = getDebugTarget().getAddressFactory().createAddress( expressions[i] );
|
||||
if ( address != null ) {
|
||||
list.add( new CMemoryBlockExtension( getDebugTarget(), address.toHexAddressString(), address.getValue() ) );
|
||||
if (memorySpaceIDs[i] == null) {
|
||||
list.add( new CMemoryBlockExtension( getDebugTarget(), address.toHexAddressString(), address.getValue() ) );
|
||||
} else {
|
||||
list.add( new CMemoryBlockExtension( getDebugTarget(), address.getValue(), memorySpaceIDs[i] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
DebugPlugin.getDefault().getMemoryBlockManager().addMemoryBlocks( (IMemoryBlock[])list.toArray( new IMemoryBlock[list.size()] ) );
|
||||
|
@ -120,20 +151,54 @@ public class CMemoryBlockRetrievalExtension extends PlatformObject implements IM
|
|||
public String getMemento() throws CoreException {
|
||||
IMemoryBlock[] blocks = DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks( getDebugTarget() );
|
||||
Document document = DebugPlugin.newDocument();
|
||||
Element element = document.createElement( MEMORY_BLOCK_EXPRESSION_LIST );
|
||||
Element exprList = document.createElement( MEMORY_BLOCK_EXPRESSION_LIST );
|
||||
for ( int i = 0; i < blocks.length; ++i ) {
|
||||
if ( blocks[i] instanceof IMemoryBlockExtension ) {
|
||||
IMemoryBlockExtension memBlockExt = (IMemoryBlockExtension)blocks[i];
|
||||
Element exprItem = document.createElement( MEMORY_BLOCK_EXPRESSION_ITEM );
|
||||
exprList.appendChild(exprItem);
|
||||
|
||||
BigInteger addrBigInt = null;
|
||||
String memorySpaceID = null;
|
||||
if (hasMemorySpaces()) {
|
||||
ICDITarget cdiTarget = fDebugTarget.getCDITarget();
|
||||
StringBuffer sbuf = new StringBuffer();
|
||||
try {
|
||||
addrBigInt = ((ICDIMemorySpaceManagement)cdiTarget).stringToAddress(memBlockExt.getExpression(), sbuf);
|
||||
if (addrBigInt == null) {
|
||||
// Client wants our default decoding; minimum is "<space>:0x?"
|
||||
addrBigInt = stringToAddress(memBlockExt.getExpression(), sbuf);
|
||||
}
|
||||
memorySpaceID = sbuf.toString();
|
||||
}
|
||||
catch( CDIException e ) {
|
||||
CDebugCorePlugin.log( e );
|
||||
addrBigInt = null;
|
||||
}
|
||||
}
|
||||
|
||||
Element child = document.createElement( MEMORY_BLOCK_EXPRESSION );
|
||||
try {
|
||||
child.setAttribute( ATTR_MEMORY_BLOCK_EXPRESSION_TEXT, ((IMemoryBlockExtension)blocks[i]).getBigBaseAddress().toString() );
|
||||
element.appendChild( child );
|
||||
if (addrBigInt != null && memorySpaceID != null) {
|
||||
child.setAttribute( ATTR_MEMORY_BLOCK_EXPRESSION_TEXT, addrBigInt.toString() );
|
||||
}
|
||||
else {
|
||||
child.setAttribute( ATTR_MEMORY_BLOCK_EXPRESSION_TEXT, memBlockExt.getBigBaseAddress().toString() );
|
||||
}
|
||||
exprItem.appendChild( child );
|
||||
}
|
||||
catch( DebugException e ) {
|
||||
CDebugCorePlugin.log( e.getStatus() );
|
||||
}
|
||||
|
||||
if (memorySpaceID != null) {
|
||||
child = document.createElement( MEMORY_BLOCK_MEMSPACEID );
|
||||
child.setAttribute( ATTR_MEMORY_BLOCK_MEMSPACEID_TEXT, memorySpaceID);
|
||||
exprItem.appendChild( child );
|
||||
}
|
||||
}
|
||||
}
|
||||
document.appendChild( element );
|
||||
document.appendChild( exprList );
|
||||
return DebugPlugin.serializeDocument( document );
|
||||
}
|
||||
|
||||
|
@ -284,12 +349,13 @@ public class CMemoryBlockRetrievalExtension extends PlatformObject implements IM
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks the CDI backend to see is memory spaces are supported
|
||||
* Checks the CDI backend to see is memory spaces are supported and actually
|
||||
* available for the target process.
|
||||
*
|
||||
* @return true if the backend supports memory spaces
|
||||
*/
|
||||
public boolean supportsMemorySpaces() {
|
||||
return fDebugTarget.getCDITarget() instanceof ICDIMemorySpaceManagement;
|
||||
public boolean hasMemorySpaces() {
|
||||
return getMemorySpaces().length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -304,4 +370,33 @@ public class CMemoryBlockRetrievalExtension extends PlatformObject implements IM
|
|||
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
/*
|
||||
* static implementation of
|
||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement#addressToString(java.math.BigInteger, java.lang.String)
|
||||
* client may choose not to provide the encoding/decoding and instead use our built-in handling.
|
||||
*
|
||||
*/
|
||||
public static String addressToString(BigInteger address, String memorySpaceID) {
|
||||
return memorySpaceID + ":0x" + address.toString(16);
|
||||
}
|
||||
|
||||
/*
|
||||
* static implementation of
|
||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement#stringToAddr(java.lang.String, java.math.BigInteger, java.lang.StringBuffer)
|
||||
* client may choose not to provide the encoding/decoding and instead use our built-in handling.
|
||||
*/
|
||||
public static BigInteger stringToAddress(String str, StringBuffer memorySpaceID_out) throws CoreException {
|
||||
int index = str.lastIndexOf(':');
|
||||
|
||||
// minimum is "<space>:0x?"
|
||||
if (index == -1 || str.length() <= index + 3 || str.charAt(index+1) != '0' || str.charAt(index+2) != 'x') {
|
||||
IStatus s = new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, InternalDebugCoreMessages.getString( "CMemoryBlockRetrievalExtension.5" ), null );
|
||||
throw new CoreException( s );
|
||||
}
|
||||
|
||||
memorySpaceID_out.setLength(0);
|
||||
memorySpaceID_out.append(str.substring(0, index));
|
||||
return new BigInteger(str.substring(index+3), 16);
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement;
|
|||
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
import org.eclipse.cdt.debug.core.model.IExecFileInfo;
|
||||
import org.eclipse.cdt.debug.internal.core.CMemoryBlockRetrievalExtension;
|
||||
import org.eclipse.debug.core.DebugEvent;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
|
@ -100,8 +101,8 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
|
|||
|
||||
if (fExpression == null)
|
||||
// If the backend supports memory spaces, it should implement ICDIMemorySpaceManagement
|
||||
// If not, we use a default encoding
|
||||
fExpression = memorySpaceID + ':' + baseAddress.toString(16);
|
||||
// Even if it does, it may choose to use our built-in encoding/decoding
|
||||
fExpression = CMemoryBlockRetrievalExtension.addressToString(baseAddress, memorySpaceID);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -40,7 +40,7 @@ public class CMemoryAdapterFactory implements IAdapterFactory {
|
|||
|
||||
if (adapterType.equals(IAddMemoryBlocksTarget.class)) {
|
||||
if (adaptableObject instanceof CMemoryBlockRetrievalExtension) {
|
||||
if (((CMemoryBlockRetrievalExtension)adaptableObject).supportsMemorySpaces())
|
||||
if (((CMemoryBlockRetrievalExtension)adaptableObject).hasMemorySpaces())
|
||||
return fgAddMemoryBlocks;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,14 @@ import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
|
|||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.jface.dialogs.TrayDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.FocusEvent;
|
||||
import org.eclipse.swt.events.FocusListener;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.events.VerifyEvent;
|
||||
import org.eclipse.swt.events.VerifyListener;
|
||||
import org.eclipse.swt.graphics.FontMetrics;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
|
@ -31,7 +33,6 @@ import org.eclipse.swt.widgets.Combo;
|
|||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
/**
|
||||
|
@ -39,25 +40,23 @@ import org.eclipse.ui.PlatformUI;
|
|||
* debug target that supports memory spaces.
|
||||
* <p>
|
||||
* It differs from the platform one in that you can enter an expression or
|
||||
* an memory space + address pair.
|
||||
* an address + memory space pair.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, FocusListener, VerifyListener {
|
||||
public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, SelectionListener {
|
||||
|
||||
private Combo fAddressInput;
|
||||
private Button fAddressRadio;
|
||||
private Combo fMemorySpaceInput;
|
||||
private Combo fExpressionInput;
|
||||
private String fExpression;
|
||||
private Button fExpressionRadio;
|
||||
private String fAddress;
|
||||
private String fMemorySpace;
|
||||
private boolean fExpressionEntered;
|
||||
private boolean fEnteredExpression; // basically, which of the two radio buttons was selected when OK was hit
|
||||
private CMemoryBlockRetrievalExtension fMemRetrieval;
|
||||
private Button fEnterAddr;
|
||||
private Button fEnterExpression;
|
||||
|
||||
private static boolean sfExpressionSetLast = false; // used to persist the default entry-type selection
|
||||
|
||||
|
||||
private static ArrayList sAddressHistory = new ArrayList();
|
||||
private static ArrayList sExpressionHistory = new ArrayList();
|
||||
|
||||
|
@ -96,22 +95,40 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener,
|
|||
composite.setLayoutData(gridData);
|
||||
parent = composite; // for all our widgets, the two-column composite is the real parent
|
||||
|
||||
fEnterAddr = new Button(parent, SWT.RADIO);
|
||||
|
||||
// take this opportunity to get the width of just the radion buton
|
||||
// (w/no text), as we'll need it below
|
||||
int buttonWidth = fEnterAddr.computeSize(SWT.DEFAULT, SWT.DEFAULT, false).x;
|
||||
|
||||
fEnterAddr.setText(Messages.AddMemBlockDlg_enterMemSpaceAndAddr);
|
||||
fAddressRadio = new Button(parent, SWT.RADIO);
|
||||
final int radioButtonWidth = fAddressRadio.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
|
||||
fAddressRadio.setText(Messages.AddMemBlockDlg_enterAddrAndMemSpace);
|
||||
gridData = new GridData(GridData.FILL_HORIZONTAL);
|
||||
gridData.horizontalSpan = 2;
|
||||
fEnterAddr.setLayoutData(gridData);
|
||||
fAddressRadio.setLayoutData(gridData);
|
||||
fAddressRadio.addSelectionListener(this);
|
||||
|
||||
fMemorySpaceInput = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
|
||||
gridData = new GridData();
|
||||
gridData.horizontalIndent = buttonWidth;
|
||||
gridData.horizontalIndent = radioButtonWidth;
|
||||
fMemorySpaceInput.setLayoutData(gridData);
|
||||
fMemorySpaceInput.addFocusListener(this);
|
||||
fMemorySpaceInput.addSelectionListener(this);
|
||||
|
||||
fAddressInput = new Combo(parent, SWT.BORDER);
|
||||
gridData = new GridData(GridData.FILL_HORIZONTAL);
|
||||
GC gc = new GC(fAddressInput);
|
||||
FontMetrics fm = gc.getFontMetrics();
|
||||
// Give enough room for a 64 bit hex address (25 is a guess at the combobox selector)
|
||||
gridData.minimumWidth = gridData.minimumWidth = 18 * fm.getAverageCharWidth() + 25;
|
||||
gc.dispose();
|
||||
fAddressInput.setLayoutData(gridData);
|
||||
fAddressInput.addModifyListener(this);
|
||||
fAddressInput.addVerifyListener(new VerifyListener() {
|
||||
// limit entry to hex or decimal
|
||||
public void verifyText(VerifyEvent e) {
|
||||
e.doit = false;
|
||||
final char c = e.character;
|
||||
if (Character.isDigit(c) || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F') ||
|
||||
c == 'x' || Character.isISOControl(e.character)) {
|
||||
e.doit = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Populate the memory space combobox with the available spaces
|
||||
if (fMemRetrieval != null) {
|
||||
|
@ -123,27 +140,19 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener,
|
|||
fMemorySpaceInput.select(0);
|
||||
}
|
||||
|
||||
fAddressInput = new Combo(parent, SWT.BORDER);
|
||||
gridData = new GridData(GridData.FILL_HORIZONTAL);
|
||||
fAddressInput.setLayoutData(gridData);
|
||||
fAddressInput.addModifyListener(this);
|
||||
fAddressInput.addFocusListener(this);
|
||||
fAddressInput.addVerifyListener(this);
|
||||
|
||||
fEnterExpression = new Button(parent, SWT.RADIO);
|
||||
fEnterExpression.setText(Messages.AddMemBlockDlg_enterExpression);
|
||||
gridData = new GridData(GridData.FILL_HORIZONTAL);
|
||||
fExpressionRadio = new Button(parent, SWT.RADIO);
|
||||
fExpressionRadio.setText(Messages.AddMemBlockDlg_enterExpression);
|
||||
gridData = new GridData();
|
||||
gridData.horizontalSpan = 2;
|
||||
fEnterExpression.setLayoutData(gridData);
|
||||
fExpressionRadio.setLayoutData(gridData);
|
||||
fExpressionRadio.addSelectionListener(this);
|
||||
|
||||
fExpressionInput = new Combo(parent, SWT.BORDER);
|
||||
gridData = new GridData(GridData.FILL_HORIZONTAL);
|
||||
gridData.horizontalSpan = 2;
|
||||
gridData.horizontalIndent = buttonWidth;
|
||||
gridData.horizontalIndent = radioButtonWidth;
|
||||
fExpressionInput.setLayoutData(gridData);
|
||||
fExpressionInput.addModifyListener(this);
|
||||
fExpressionInput.addFocusListener(this);
|
||||
|
||||
|
||||
// add the history into the combo boxes
|
||||
String[] history = getHistory(sExpressionHistory);
|
||||
for (int i = 0; i < history.length; i++)
|
||||
|
@ -153,16 +162,8 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener,
|
|||
for (int i = 0; i < history.length; i++)
|
||||
fAddressInput.add(history[i]);
|
||||
|
||||
fExpressionInput.addFocusListener(this);
|
||||
fExpressionInput.addModifyListener(this);
|
||||
|
||||
fEnterExpression.setSelection(sfExpressionSetLast);
|
||||
fEnterAddr.setSelection(!sfExpressionSetLast);
|
||||
if (sfExpressionSetLast) {
|
||||
fExpressionInput.forceFocus();
|
||||
} else {
|
||||
fAddressInput.forceFocus();
|
||||
}
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
@ -180,8 +181,6 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener,
|
|||
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
|
||||
*/
|
||||
protected void okPressed() {
|
||||
|
||||
fExpressionEntered = fEnterExpression.getSelection();
|
||||
fExpression = fExpressionInput.getText();
|
||||
fAddress = fAddressInput.getText();
|
||||
fMemorySpace = fMemorySpaceInput.getText();
|
||||
|
@ -192,9 +191,7 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener,
|
|||
if (fAddress.length() > 0)
|
||||
addHistory(sAddressHistory, fAddress);
|
||||
|
||||
// this will persist the entry type from one dialog invocation to another
|
||||
sfExpressionSetLast = fExpressionEntered;
|
||||
|
||||
fEnteredExpression = fExpressionRadio.getSelection();
|
||||
super.okPressed();
|
||||
}
|
||||
|
||||
|
@ -202,13 +199,14 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener,
|
|||
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
|
||||
*/
|
||||
public void modifyText(ModifyEvent e) {
|
||||
// if user enters text into one of the two input options, disable/gray the other
|
||||
// to make the mutual exlusivity obvious
|
||||
fAddressInput.setEnabled(fExpressionInput.getText().length() == 0);
|
||||
fEnterAddr.setEnabled(fExpressionInput.getText().length() == 0);
|
||||
fMemorySpaceInput.setEnabled(fExpressionInput.getText().length() == 0);
|
||||
fExpressionInput.setEnabled(fAddressInput.getText().length() == 0);
|
||||
fEnterExpression.setEnabled(fAddressInput.getText().length() == 0);
|
||||
// if user enters text into either the address field or the expression one, automatically
|
||||
// select its associated radio button (and deselect the other, these are mutually exclusive)
|
||||
if (e.widget == fAddressInput ||
|
||||
e.widget == fExpressionInput) {
|
||||
|
||||
fAddressRadio.setSelection(e.widget != fExpressionInput);
|
||||
fExpressionRadio.setSelection(e.widget == fExpressionInput);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -230,8 +228,8 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener,
|
|||
return fMemorySpace;
|
||||
}
|
||||
|
||||
public boolean wasExpressionEntered() {
|
||||
return fExpressionEntered;
|
||||
public boolean enteredExpression() {
|
||||
return fEnteredExpression;
|
||||
}
|
||||
|
||||
private static void addHistory(ArrayList list, String item) {
|
||||
|
@ -247,52 +245,22 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener,
|
|||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
|
||||
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
public void focusGained(FocusEvent e) {
|
||||
// when the user gives focus to one of the combo boxes, shift the radio button state accordingly
|
||||
if (e.widget == fAddressInput || e.widget == fMemorySpaceInput) {
|
||||
fEnterAddr.setSelection(true);
|
||||
fEnterExpression.setSelection(false);
|
||||
}
|
||||
else if (e.widget == fExpressionInput) {
|
||||
fEnterAddr.setSelection(false);
|
||||
fEnterExpression.setSelection(true);
|
||||
}
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
|
||||
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
public void focusLost(FocusEvent e) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
|
||||
*/
|
||||
public void verifyText(VerifyEvent event) {
|
||||
if (event.widget == fAddressInput) {
|
||||
// assume we won't allow it
|
||||
event.doit = false;
|
||||
|
||||
char c = event.character;
|
||||
|
||||
String textAlreadyInControl = ((Combo)event.widget).getText();
|
||||
|
||||
if ((c == 'x') && (textAlreadyInControl.length() == 1)
|
||||
&& textAlreadyInControl.charAt(0) == '0') {
|
||||
// allow 'x' if it's the second character and the first is zero.
|
||||
// Note that this level of verification has a hole; user can use
|
||||
// ISO control characters (e.g., the Delete key) to move the 'x'
|
||||
// in the first slot. Oh well; this doesn't need to be bullet proof
|
||||
event.doit = true;
|
||||
} else if ((c == '\b') || // allow backspace
|
||||
Character.isDigit(c) || ('a' <= c && c <= 'f')
|
||||
|| ('A' <= c && c <= 'F')) {
|
||||
event.doit = true;
|
||||
} else if (Character.isISOControl(c)) {
|
||||
event.doit = true;
|
||||
}
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
// if user selects a memory space, select its associated radio button (and deselect the
|
||||
// other, these are mutually exclusive)
|
||||
if (e.widget == fMemorySpaceInput) {
|
||||
fAddressRadio.setSelection(true);
|
||||
fExpressionRadio.setSelection(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,8 +89,7 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget {
|
|||
if (returnCode == Window.CANCEL)
|
||||
return;
|
||||
|
||||
String input = (dialog.getAddress().length() > 0) ? dialog.getAddress()
|
||||
: dialog.getExpression();
|
||||
String input = dialog.enteredExpression() ? dialog.getExpression() : dialog.getAddress();
|
||||
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
|
@ -105,7 +104,7 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget {
|
|||
final String[] addrsOrExprs = (String[]) list.toArray(new String[list.size()]);
|
||||
|
||||
ParamHolder params;
|
||||
if (dialog.wasExpressionEntered())
|
||||
if (dialog.enteredExpression())
|
||||
params = new ExpressionsHolder(addrsOrExprs);
|
||||
else
|
||||
params = new AddressAndSpaceHolder(addrsOrExprs, dialog.getMemorySpace());
|
||||
|
|
|
@ -22,7 +22,7 @@ public class Messages extends NLS {
|
|||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||
}
|
||||
|
||||
public static String AddMemBlockDlg_enterMemSpaceAndAddr;
|
||||
public static String AddMemBlockDlg_enterAddrAndMemSpace;
|
||||
public static String AddMemBlockDlg_enterExpression;
|
||||
public static String AddMemBlockDlg_or;
|
||||
public static String AddMemBlockDlg_MonitorMemory;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
AddMemBlockDlg_enterMemSpaceAndAddr=Enter memory space and address
|
||||
AddMemBlockDlg_enterAddrAndMemSpace=Enter memory space and address
|
||||
AddMemBlockDlg_enterExpression=Enter expression
|
||||
AddMemBlockDlg_or=or
|
||||
AddMemBlockDlg_MonitorMemory = Monitor Memory
|
||||
|
|
Loading…
Add table
Reference in a new issue