1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Bug 73168: Use memory view provided by Eclipse platform in CDT.

Removed the old memory view.
This commit is contained in:
Mikhail Khodjaiants 2005-01-12 21:23:07 +00:00
parent 3b9ce4e55a
commit 4acb21bc17
35 changed files with 53 additions and 4314 deletions

View file

@ -1,3 +1,16 @@
2005-01-12 Mikhail Khodjaiants
Bug 73168: Use memory view provided by Eclipse platform in CDT.
Removed the old memory view.
* CDebugCorePlugin.java
* CDebugModel.java: removed
* ICMemoryManager.java: removed
* IFormattedMemoryBlock.java: removed
* IFormattedMemoryBlockRow.java: removed
* CMemoryManager.java: removed
* CSignalManager.java
* CDebugTarget.java
* CFormattedMemoryBlock.java: removed
2005-01-12 Mikhail Khodjaiants
Fix bug 82601: Enhance the ICDIMemoryBlock interface.
* CMemoryBlockExtension.java

View file

@ -136,7 +136,7 @@ public class CDebugCorePlugin extends Plugin {
* @param status status to log
*/
public static void log( String message ) {
getDefault().getLog().log( new Status( IStatus.ERROR, CDebugModel.getPluginIdentifier(), INTERNAL_ERROR, message, null ) );
getDefault().getLog().log( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), INTERNAL_ERROR, message, null ) );
}
private void initializeDebugConfiguration() {

View file

@ -1,105 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.cdt.debug.internal.core.model.CFormattedMemoryBlock;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IProcess;
/**
*
* Provides utility methods for creating debug sessions, targets and breakpoints specific to the CDI debug model.
*/
public class CDebugModel {
/**
* Constructor for CDebugModel.
*/
public CDebugModel() {
super();
}
/**
* Returns the identifier for the CDI debug model plug-in
*
* @return plugin identifier
*/
public static String getPluginIdentifier() {
return CDebugCorePlugin.getUniqueIdentifier();
}
/**
* @throws CoreException
* @deprecated
* Use {@link CDIDebugModel#newDebugTarget(ILaunch, ICDITarget, String, IProcess, IProcess, IFile, boolean, boolean, boolean)}.
*/
public static IDebugTarget newDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggeeProcess, final IProcess debuggerProcess, final IFile file, final boolean allowTerminate, final boolean allowDisconnect, final boolean stopInMain ) throws CoreException {
return CDIDebugModel.newDebugTarget( launch, cdiTarget, name, debuggeeProcess, debuggerProcess, file, allowTerminate, allowDisconnect, stopInMain );
}
/**
* @throws CoreException
* @deprecated
* Use {@link CDIDebugModel#newAttachDebugTarget(ILaunch, ICDITarget, String, IProcess, IFile)}.
*/
public static IDebugTarget newAttachDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggerProcess, final IFile file ) throws CoreException {
return CDIDebugModel.newAttachDebugTarget( launch, cdiTarget, name, debuggerProcess, file );
}
/**
* @throws CoreException
* @deprecated
* Use {@link CDIDebugModel#newCoreFileDebugTarget(ILaunch, ICDITarget, String, IProcess, IFile)}.
*/
public static IDebugTarget newCoreFileDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggerProcess, final IFile file ) throws CoreException {
return CDIDebugModel.newCoreFileDebugTarget( launch, cdiTarget, name, debuggerProcess, file );
}
public static IFormattedMemoryBlock createFormattedMemoryBlock( IDebugTarget target, String addressExpression, int format, int wordSize, int numberOfRows, int numberOfColumns, char paddingChar ) throws DebugException {
if ( target != null && target instanceof CDebugTarget ) {
try {
ICDIExpression expression = ((CDebugTarget)target).getCDITarget().createExpression( addressExpression );
ICDIMemoryBlock cdiMemoryBlock = ((CDebugTarget)target).getCDITarget().createMemoryBlock( expression.getExpressionText(), wordSize * numberOfRows * numberOfColumns );
return new CFormattedMemoryBlock( (CDebugTarget)target, cdiMemoryBlock, expression, format, wordSize, numberOfRows, numberOfColumns, paddingChar );
}
catch( CDIException e ) {
throw new DebugException( new Status( IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED, e.getDetailMessage(), null ) );
}
}
return null;
}
public static IFormattedMemoryBlock createFormattedMemoryBlock( IDebugTarget target, String addressExpression, int format, int wordSize, int numberOfRows, int numberOfColumns ) throws DebugException {
if ( target != null && target instanceof CDebugTarget ) {
try {
ICDIExpression expression = ((CDebugTarget)target).getCDITarget().createExpression( addressExpression );
ICDIMemoryBlock cdiMemoryBlock = ((CDebugTarget)target).getCDITarget().createMemoryBlock( expression.getExpressionText(), wordSize * numberOfRows * numberOfColumns );
return new CFormattedMemoryBlock( (CDebugTarget)target, cdiMemoryBlock, expression, format, wordSize, numberOfRows, numberOfColumns );
}
catch( CDIException e ) {
throw new DebugException( new Status( IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED, e.getDetailMessage(), null ) );
}
}
return null;
}
}

View file

@ -1,57 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugException;
/**
* Enter type comment.
*
* @since: Oct 15, 2002
*/
public interface ICMemoryManager extends IAdaptable
{
public static final int MEMORY_SIZE_BYTE = 1;
public static final int MEMORY_SIZE_HALF_WORD = 2;
public static final int MEMORY_SIZE_WORD = 4;
public static final int MEMORY_SIZE_DOUBLE_WORD = 8;
public static final int MEMORY_SIZE_FLOAT = 8;
public static final int MEMORY_SIZE_DOUBLE_FLOAT = 16;
public static final int MEMORY_FORMAT_HEX = 0;
public static final int MEMORY_FORMAT_BINARY = 1;
public static final int MEMORY_FORMAT_OCTAL = 2;
public static final int MEMORY_FORMAT_SIGNED_DECIMAL = 3;
public static final int MEMORY_FORMAT_UNSIGNED_DECIMAL = 4;
public static final int MEMORY_BYTES_PER_ROW_4 = 4;
public static final int MEMORY_BYTES_PER_ROW_8 = 8;
public static final int MEMORY_BYTES_PER_ROW_16 = 16;
public static final int MEMORY_BYTES_PER_ROW_32 = 32;
public static final int MEMORY_BYTES_PER_ROW_64 = 64;
public static final int MEMORY_BYTES_PER_ROW_128 = 128;
int[] getSupportedFormats() throws DebugException;
void setBlockAt( int index, IFormattedMemoryBlock memoryBlock ) throws DebugException;
void removeBlock( IFormattedMemoryBlock memoryBlock ) throws DebugException;
void removeBlock( int index ) throws DebugException;
void removeAllBlocks() throws DebugException;
IFormattedMemoryBlock getBlock( int index );
IFormattedMemoryBlock[] getBlocks();
}

View file

@ -1,143 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IMemoryBlock;
/**
*
* A contiguos segment of memory in an execution context represented
* as a table of values.
*
* @since Jul 31, 2002
*/
public interface IFormattedMemoryBlock extends IMemoryBlock
{
public static final int MEMORY_SIZE_BYTE = 1;
public static final int MEMORY_SIZE_HALF_WORD = 2;
public static final int MEMORY_SIZE_WORD = 4;
public static final int MEMORY_SIZE_DOUBLE_WORD = 8;
public static final int MEMORY_SIZE_FLOAT = 8;
public static final int MEMORY_SIZE_DOUBLE_FLOAT = 16;
public static final int MEMORY_FORMAT_HEX = 0;
public static final int MEMORY_FORMAT_BINARY = 1;
public static final int MEMORY_FORMAT_OCTAL = 2;
public static final int MEMORY_FORMAT_SIGNED_DECIMAL = 3;
public static final int MEMORY_FORMAT_UNSIGNED_DECIMAL = 4;
public static final int MEMORY_NUMBER_OF_COLUMNS_1 = 1;
public static final int MEMORY_NUMBER_OF_COLUMNS_2 = 2;
public static final int MEMORY_NUMBER_OF_COLUMNS_4 = 4;
public static final int MEMORY_NUMBER_OF_COLUMNS_8 = 8;
public static final int MEMORY_NUMBER_OF_COLUMNS_16 = 16;
/**
* Returns the address expression specified to obtain this memory block.
*
* @return the address expression
*/
public String getAddressExpression();
/**
* Returns the format of the memory words of this block.
*
* @return The format of the memory words of this block
*/
int getFormat();
/**
* Returns the size of each memory word in bytes.
*
* @return the size of each memory word in bytes
*/
int getWordSize();
/**
* Returns the number of rows in the output table.
*
* @return the number of rows in the output table
*/
int getNumberOfRows();
/**
* Returns the number of columns in the output table.
*
* @return the number of columns in the output table
*/
int getNumberOfColumns();
/**
* Returns whether each row should include an ASCII dump.
*
* @return whether each row should include an ASCII dump
*/
boolean displayASCII();
/**
* Returns the array of rows.
*
* @return the array of rows
*/
IFormattedMemoryBlockRow[] getRows();
/**
* Sets the value of data item in this block at the specified
* index within this block to the spcified value.
* The index is zero based.
*
* @param index the index of item to change
* @param newValue the new value
* @throws DebugException if this method fails. Reasons include:
*/
void setItemValue( int index, String newValue ) throws DebugException;
char getPaddingCharacter();
public IAddress getRealStartAddress();
IAddress nextRowAddress();
IAddress previousRowAddress();
IAddress nextPageAddress();
IAddress previousPageAddress();
void reformat( int format,
int wordSize,
int numberOfRows,
int numberOfColumns ) throws DebugException;
void reformat( int format,
int wordSize,
int numberOfRows,
int numberOfColumns,
char paddingChar ) throws DebugException;
void dispose();
IAddress[] getChangedAddresses();
boolean isFrozen();
void setFrozen( boolean frozen );
void refresh() throws DebugException;
boolean canChangeFormat( int format );
boolean isLittleEndian();
boolean isStartAddressChanged();
}

View file

@ -1,44 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.cdt.core.IAddress;
/**
*
* Represents a row in the output table of formatted memory block.
*
* @since Jul 31, 2002
*/
public interface IFormattedMemoryBlockRow
{
/**
* Returns the address of this row.
*
* @return the address of this row
*/
IAddress getAddress();
/**
* Returns the array of memory words.
*
* @return the array of memory words
*/
String[] getData();
/**
* Returns the ASCII dump for this row.
*
* @return the ASCII dump for this row
*/
String getASCII();
}

View file

@ -1,153 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core;
import java.util.Arrays;
import org.eclipse.cdt.debug.core.ICMemoryManager;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugTarget;
/**
* Enter type comment.
*
* @since: Oct 15, 2002
*/
public class CMemoryManager implements ICMemoryManager
{
private IFormattedMemoryBlock[] fBlocks = new IFormattedMemoryBlock[4];
private CDebugTarget fDebugTarget;
/**
* Constructor for CMemoryManager.
*/
public CMemoryManager( CDebugTarget target )
{
Arrays.fill( fBlocks, null );
setDebugTarget( target );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICMemoryManager#removeBlock(IFormattedMemoryBlock)
*/
public synchronized void removeBlock( IFormattedMemoryBlock memoryBlock ) throws DebugException
{
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICMemoryManager#removeAllBlocks()
*/
public synchronized void removeAllBlocks() throws DebugException
{
for ( int i = 0; i < fBlocks.length; ++i )
{
if ( fBlocks[i] != null )
{
fBlocks[i].dispose();
fBlocks[i] = null;
}
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICMemoryManager#getBlock(int)
*/
public IFormattedMemoryBlock getBlock( int index )
{
return ( index >= 0 && index < fBlocks.length ) ? fBlocks[index] : null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICMemoryManager#getBlocks()
*/
public IFormattedMemoryBlock[] getBlocks()
{
return fBlocks;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
*/
public Object getAdapter( Class adapter )
{
if ( adapter.equals( ICMemoryManager.class ) )
{
return this;
}
if ( adapter.equals( CMemoryManager.class ) )
{
return this;
}
if ( adapter.equals( IDebugTarget.class ) )
{
return fDebugTarget;
}
return null;
}
public IDebugTarget getDebugTarget()
{
return fDebugTarget;
}
protected void setDebugTarget( CDebugTarget target )
{
fDebugTarget = target;
}
public void dispose()
{
for ( int i = 0; i < fBlocks.length; ++i )
{
if ( fBlocks[i] != null )
{
fBlocks[i].dispose();
fBlocks[i] = null;
}
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICMemoryManager#removeBlock(int)
*/
public synchronized void removeBlock( int index ) throws DebugException
{
IFormattedMemoryBlock block = getBlock( index );
if ( block != null )
{
block.dispose();
}
setBlockAt( index, null );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICMemoryManager#setBlockAt(int, IFormattedMemoryBlock)
*/
public synchronized void setBlockAt( int index, IFormattedMemoryBlock memoryBlock ) throws DebugException
{
IFormattedMemoryBlock block = getBlock( index );
if ( block != null )
{
block.dispose();
}
fBlocks[index] = memoryBlock;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICMemoryManager#getSupportedFormats()
*/
public int[] getSupportedFormats() throws DebugException
{
return new int[0];
}
}

View file

@ -11,7 +11,7 @@
package org.eclipse.cdt.debug.internal.core;
import java.util.ArrayList;
import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDISignal;
import org.eclipse.cdt.debug.core.model.ICSignal;
@ -122,7 +122,7 @@ public class CSignalManager implements IAdaptable {
* Throws a debug exception with the given message, error code, and underlying exception.
*/
protected void throwDebugException( String message, int code, Throwable exception ) throws DebugException {
throw new DebugException( new Status( IStatus.ERROR, CDebugModel.getPluginIdentifier(), code, message, exception ) );
throw new DebugException( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), code, message, exception ) );
}
protected CDebugTarget getDebugTarget() {

View file

@ -23,10 +23,8 @@ import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.core.IBinaryParser.ISymbol;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.ICGlobalVariableManager;
import org.eclipse.cdt.debug.core.ICMemoryManager;
import org.eclipse.cdt.debug.core.ICRegisterManager;
import org.eclipse.cdt.debug.core.ICSharedLibraryManager;
import org.eclipse.cdt.debug.core.cdi.CDIException;
@ -80,9 +78,8 @@ import org.eclipse.cdt.debug.core.model.IRunToAddress;
import org.eclipse.cdt.debug.core.model.IRunToLine;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.internal.core.CBreakpointManager;
import org.eclipse.cdt.debug.internal.core.CMemoryBlockExtensionRetrieval;
import org.eclipse.cdt.debug.internal.core.CGlobalVariableManager;
import org.eclipse.cdt.debug.internal.core.CMemoryManager;
import org.eclipse.cdt.debug.internal.core.CMemoryBlockExtensionRetrieval;
import org.eclipse.cdt.debug.internal.core.CRegisterManager;
import org.eclipse.cdt.debug.internal.core.CSharedLibraryManager;
import org.eclipse.cdt.debug.internal.core.CSignalManager;
@ -155,11 +152,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
*/
private ICDITargetConfiguration fConfig;
/**
* The memory manager for this target.
*/
private CMemoryManager fMemoryManager;
/**
* The disassembly manager for this target.
*/
@ -215,6 +207,9 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
*/
private IAddressFactory fAddressFactory;
/**
* Support for the memory retrival on this target.
*/
private CMemoryBlockExtensionRetrieval fMemoryBlockRetrieval;
/**
@ -252,7 +247,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
initializeThreads( debugEvents );
initializeBreakpoints();
initializeRegisters();
initializeMemoryManager();
initializeSourceManager();
getLaunch().addDebugTarget( this );
fireEventSet( (DebugEvent[])debugEvents.toArray( new DebugEvent[debugEvents.size()] ) );
@ -298,7 +292,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
*/
public void setBreakpoints() {
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] bps = manager.getBreakpoints( CDebugModel.getPluginIdentifier() );
IBreakpoint[] bps = manager.getBreakpoints( CDIDebugModel.getPluginIdentifier() );
for( int i = 0; i < bps.length; i++ ) {
if ( bps[i] instanceof ICBreakpoint && getBreakpointManager().isTargetBreakpoint( (ICBreakpoint)bps[i] ) && !getBreakpointManager().isCDIRegistered( (ICBreakpoint)bps[i] ) ) {
if ( bps[i] instanceof ICAddressBreakpoint ) {
@ -318,10 +312,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
getRegisterManager().initialize();
}
protected void initializeMemoryManager() {
fMemoryManager = new CMemoryManager( this );
}
protected void initializeSourceManager() {
ISourceLocator locator = getLaunch().getSourceLocator();
if ( locator instanceof IAdaptable ) {
@ -791,8 +781,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
return this;
if ( adapter.equals( ICDITarget.class ) )
return fCDITarget;
if ( adapter.equals( ICMemoryManager.class ) )
return getMemoryManager();
if ( adapter.equals( IDebuggerProcessSupport.class ) )
return this;
if ( adapter.equals( IExecFileInfo.class ) )
@ -982,7 +970,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
DebugPlugin.getDefault().getLaunchManager().removeLaunchListener( this );
saveGlobalVariables();
disposeGlobalVariableManager();
disposeMemoryManager();
disposeSharedLibraryManager();
disposeSignalManager();
disposeRegisterManager();
@ -1338,14 +1325,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
return getLaunch().getSourceLocator();
}
protected CMemoryManager getMemoryManager() {
return fMemoryManager;
}
protected void disposeMemoryManager() {
getMemoryManager().dispose();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IExecFileInfo#isLittleEndian()
*/

View file

@ -1,707 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core.model;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDIDestroyedEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
import org.eclipse.cdt.debug.core.cdi.event.ICDIMemoryChangedEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDIResumedEvent;
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
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.core.model.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlockRow;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
/**
* Enter type comment.
*
* @since: Oct 15, 2002
*/
public class CFormattedMemoryBlock extends CDebugElement
implements IFormattedMemoryBlock,
ICDIEventListener
{
class CFormattedMemoryBlockRow implements IFormattedMemoryBlockRow
{
private IAddress fAddress;
private String[] fData;
private String fAscii;
/**
* Constructor for CFormattedMemoryBlockRow.
*/
public CFormattedMemoryBlockRow( IAddress address, String[] data, String ascii )
{
fAddress = address;
fData = data;
fAscii = ascii;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlockRow#getAddress()
*/
public IAddress getAddress()
{
return fAddress;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlockRow#getASCII()
*/
public String getASCII()
{
return fAscii;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlockRow#getData()
*/
public String[] getData()
{
return fData;
}
}
private ICDIExpression fAddressExpression;
private ICDIMemoryBlock fCDIMemoryBlock;
private byte[] fBytes = null;
private int fFormat;
private int fWordSize;
private int fNumberOfRows;
private int fNumberOfColumns;
private boolean fDisplayAscii = true;
private char fPaddingChar = '.';
private List fRows = null;
private IAddress[] fChangedAddresses = new IAddress[0];
private boolean fStartAddressChanged = false;
/**
* Constructor for CFormattedMemoryBlock.
* @param target
*/
public CFormattedMemoryBlock( CDebugTarget target,
ICDIMemoryBlock cdiMemoryBlock,
ICDIExpression addressExpression,
int format,
int wordSize,
int numberOfRows,
int numberOfColumns )
{
this( target, cdiMemoryBlock, addressExpression, format, wordSize, numberOfRows, numberOfColumns, '\0' );
}
/**
* Constructor for CFormattedMemoryBlock.
* @param target
*/
public CFormattedMemoryBlock( CDebugTarget target,
ICDIMemoryBlock cdiMemoryBlock,
ICDIExpression addressExpression,
int format,
int wordSize,
int numberOfRows,
int numberOfColumns,
char paddingChar )
{
super( target );
fCDIMemoryBlock = cdiMemoryBlock;
fAddressExpression = addressExpression;
fFormat = format;
fWordSize = wordSize;
fNumberOfRows = numberOfRows;
fNumberOfColumns = numberOfColumns;
fDisplayAscii = true;
fPaddingChar = paddingChar;
getCDISession().getEventManager().addEventListener( this );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#getFormat()
*/
public int getFormat()
{
return fFormat;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#getWordSize()
*/
public int getWordSize()
{
return fWordSize;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#getNumberOfRows()
*/
public int getNumberOfRows()
{
return fNumberOfRows;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#getNumberOfColumns()
*/
public int getNumberOfColumns()
{
return fNumberOfColumns;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#displayASCII()
*/
public boolean displayASCII()
{
return ( getWordSize() == IFormattedMemoryBlock.MEMORY_SIZE_BYTE &&
/*getFormat() == IFormattedMemoryBlock.MEMORY_FORMAT_HEX &&*/
fDisplayAscii );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#getRows()
*/
public IFormattedMemoryBlockRow[] getRows()
{
if ( fRows == null )
{
fRows = new ArrayList();
try
{
int offset = 0;
byte[] bytes = getBytes();
while( bytes != null && offset < bytes.length )
{
int length = Math.min( fWordSize * fNumberOfColumns, bytes.length - offset );
fRows.add( new CFormattedMemoryBlockRow( getRowAddress( offset ),
createData( bytes, offset, length ),
createAscii( bytes, offset, length ) ) );
offset += length;
}
}
catch( DebugException e )
{
}
}
return (IFormattedMemoryBlockRow[])fRows.toArray( new IFormattedMemoryBlockRow[fRows.size()] );
}
private synchronized void resetBytes()
{
fBytes = null;
}
private void resetRows()
{
fRows = null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#nextRowAddress()
*/
public IAddress nextRowAddress()
{
return ((CDebugTarget)getDebugTarget()).getAddressFactory().getZero();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#previousRowAddress()
*/
public IAddress previousRowAddress()
{
return ((CDebugTarget)getDebugTarget()).getAddressFactory().getZero();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#nextPageAddress()
*/
public IAddress nextPageAddress()
{
return ((CDebugTarget)getDebugTarget()).getAddressFactory().getZero();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#previousPageAddress()
*/
public IAddress previousPageAddress()
{
return ((CDebugTarget)getDebugTarget()).getAddressFactory().getZero();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#reformat(long, int, int, int, int)
*/
public void reformat( int format,
int wordSize,
int numberOfRows,
int numberOfColumns ) throws DebugException
{
resetRows();
fFormat = format;
fWordSize = wordSize;
fNumberOfRows = numberOfRows;
fNumberOfColumns = numberOfColumns;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#reformat(long, int, int, int, int, char)
*/
public void reformat( int format,
int wordSize,
int numberOfRows,
int numberOfColumns,
char paddingChar ) throws DebugException
{
resetRows();
fFormat = format;
fWordSize = wordSize;
fNumberOfRows = numberOfRows;
fNumberOfColumns = numberOfColumns;
fPaddingChar = paddingChar;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlock#getStartAddress()
*/
public long getStartAddress()
{
return 0;
}
public IAddress getRealStartAddress()
{
IAddressFactory factory = ((CDebugTarget)getDebugTarget()).getAddressFactory();
if ( fCDIMemoryBlock != null )
{
return factory.createAddress( fCDIMemoryBlock.getStartAddress() );
}
return factory.getZero();
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlock#getLength()
*/
public long getLength()
{
if ( fCDIMemoryBlock != null )
{
return fCDIMemoryBlock.getLength();
}
return 0;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlock#getBytes()
*/
public synchronized byte[] getBytes() throws DebugException
{
if ( fBytes == null )
{
if ( fCDIMemoryBlock != null )
{
try
{
fBytes = fCDIMemoryBlock.getBytes();
}
catch( CDIException e )
{
targetRequestFailed( e.getMessage(), null );
}
}
}
byte[] copyBytes = null;
if ( fBytes != null )
{
copyBytes = new byte[fBytes.length];
System.arraycopy( fBytes, 0, copyBytes, 0, fBytes.length );
}
return copyBytes;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlock#supportsValueModification()
*/
public boolean supportsValueModification()
{
return false;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlock#setValue(long, byte[])
*/
public void setValue( long offset, byte[] bytes ) throws DebugException
{
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#getPaddingCharacter()
*/
public char getPaddingCharacter()
{
return fPaddingChar;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#dispose()
*/
public void dispose()
{
if ( fCDIMemoryBlock != null )
{
try
{
((CDebugTarget)getDebugTarget()).getCDITarget().removeBlocks( new ICDIMemoryBlock[] { fCDIMemoryBlock } );
}
catch( CDIException e )
{
CDebugCorePlugin.log( e );
}
fCDIMemoryBlock = null;
}
if ( fAddressExpression != null )
{
try
{
fAddressExpression.dispose();
}
catch( CDIException e )
{
CDebugCorePlugin.log( e );
}
fAddressExpression = null;
}
getCDISession().getEventManager().removeEventListener( this );
fireTerminateEvent();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#getAddressExpression()
*/
public String getAddressExpression()
{
return fAddressExpression.getExpressionText();
}
private String[] createData( byte[] bytes, int offset, int length )
{
List data = new ArrayList( length / getWordSize() );
for ( int i = offset; i < offset + length; i += getWordSize() )
{
data.add( createDataItem( bytes, i, Math.min( length + offset - i, getWordSize() ) ) );
}
return (String[])data.toArray( new String[data.size()] );
}
private String createDataItem( byte[] bytes, int offset, int length )
{
StringBuffer sb = new StringBuffer( length * 2 );
for ( int i = offset; i < length + offset; ++i )
{
sb.append( CDebugUtils.getByteText( bytes[i] ) );
}
return sb.toString();
}
private String createAscii( byte[] bytes, int offset, int length )
{
StringBuffer sb = new StringBuffer( length );
for ( int i = offset; i < offset + length; ++i )
{
sb.append( ( Character.isISOControl( (char)bytes[i] ) || bytes[i] < 0 ) ? getPaddingCharacter() : (char)bytes[i] );
}
return sb.toString();
}
/**
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener#handleDebugEvents(ICDIEvent)
*/
public void handleDebugEvents( ICDIEvent[] events )
{
for (int i = 0; i < events.length; i++)
{
ICDIEvent event = events[i];
ICDIObject source = event.getSource();
if (source == null)
continue;
if ( source.getTarget().equals( getCDITarget() ) )
{
if ( event instanceof ICDIResumedEvent )
{
if ( source instanceof ICDITarget )
{
handleResumedEvent( (ICDIResumedEvent)event );
}
}
else if ( event instanceof ICDIMemoryChangedEvent )
{
if ( source instanceof ICDIMemoryBlock && source.equals( getCDIMemoryBlock() ) )
{
handleChangedEvent( (ICDIMemoryChangedEvent)event );
}
}
else if ( event instanceof ICDIChangedEvent )
{
if ( source instanceof ICDIExpression && source.equals( fAddressExpression ) )
{
handleAddressChangedEvent( (ICDIChangedEvent)event );
}
}
else if ( event instanceof ICDIDestroyedEvent )
{
if ( source instanceof ICDIExpression && source.equals( fAddressExpression ) )
{
handleDestroyedEvent( (ICDIDestroyedEvent)event );
}
}
}
}
}
protected ICDIMemoryBlock getCDIMemoryBlock()
{
return fCDIMemoryBlock;
}
protected void setCDIMemoryBlock( ICDIMemoryBlock cdiMemoryBlock )
{
fCDIMemoryBlock = cdiMemoryBlock;
}
private void handleResumedEvent( ICDIResumedEvent event )
{
resetChangedAddresses();
fStartAddressChanged = false;
fireChangeEvent( DebugEvent.CONTENT );
}
private void handleChangedEvent( ICDIMemoryChangedEvent event )
{
resetBytes();
resetRows();
IAddressFactory factory = ((CDebugTarget)getDebugTarget()).getAddressFactory();
BigInteger[] bigs = event.getAddresses();
IAddress[] addresses = new IAddress[bigs.length];
for (int i = 0; i < addresses.length; ++i) {
addresses[i] = factory.createAddress( bigs[i] );
}
setChangedAddresses( addresses );
fireChangeEvent( DebugEvent.CONTENT );
}
private void handleAddressChangedEvent( ICDIChangedEvent event )
{
resetBytes();
resetRows();
fStartAddressChanged = true;
fireChangeEvent( DebugEvent.CONTENT );
}
private void handleDestroyedEvent( ICDIDestroyedEvent event )
{
fireTerminateEvent();
}
public IAddress[] getChangedAddresses()
{
return fChangedAddresses;
}
protected void setChangedAddresses( IAddress[] changedAddresses )
{
fChangedAddresses = changedAddresses;
}
protected void resetChangedAddresses()
{
fChangedAddresses = new IAddress[0];
}
/**
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#isFrozen()
*/
public boolean isFrozen()
{
return getCDIMemoryBlock().isFrozen();
}
/**
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#setFrozen(boolean)
*/
public void setFrozen( boolean frozen )
{
getCDIMemoryBlock().setFrozen( frozen );
}
/**
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#setItemValue(int, String)
*/
public void setItemValue( int index, String newValue ) throws DebugException
{
byte[] bytes = itemToBytes( newValue.toCharArray() );
setBytes( index * getWordSize(), bytes );
resetRows();
}
private void setBytes( int index, byte[] newBytes ) throws DebugException
{
try
{
getCDIMemoryBlock().setValue( index, newBytes );
}
catch( CDIException e )
{
targetRequestFailed( e.getMessage(), null );
}
}
private byte[] itemToBytes( char[] chars )
{
switch( getFormat() )
{
case IFormattedMemoryBlock.MEMORY_FORMAT_HEX:
return hexItemToBytes( chars );
}
return new byte[0];
}
private byte[] hexItemToBytes( char[] chars )
{
byte[] result = new byte[chars.length / 2];
for ( int i = 0; i < result.length; ++i )
{
result[i] = CDebugUtils.textToByte( new char[] { chars[2 * i], chars[2 * i + 1] } );
}
return result;
}
/**
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#isDirty()
*/
/*
public boolean isDirty()
{
if ( fDirtyBytes != null )
{
return fDirtyBytes.isDirty();
}
return false;
}
*/
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#saveChanges()
*/
/*
public void saveChanges() throws DebugException
{
byte[] bytes = getBytes();
if ( bytes != null && fDirtyBytes != null && getCDIMemoryBlock() != null )
{
ByteRange[] ranges = fDirtyBytes.getDirtyRanges( getBytes() );
for ( int i = 0; i < ranges.length; ++i )
{
try
{
getCDIMemoryBlock().setValue( ranges[i].getStart(), ranges[i].getBytes() );
}
catch( CDIException e )
{
targetRequestFailed( e.getMessage(), null );
}
}
fDirtyBytes.reset();
}
}
*/
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#refresh()
*/
public void refresh() throws DebugException
{
if ( getCDIMemoryBlock() != null )
{
try
{
getCDIMemoryBlock().refresh();
}
catch( CDIException e )
{
targetRequestFailed( e.getMessage(), null );
}
}
}
/**
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#canChangeFormat(int)
*/
public boolean canChangeFormat( int format )
{
switch( format )
{
case IFormattedMemoryBlock.MEMORY_FORMAT_HEX:
return true;
case IFormattedMemoryBlock.MEMORY_FORMAT_SIGNED_DECIMAL:
return ( /*getWordSize() != IFormattedMemoryBlock.MEMORY_SIZE_BYTE &&*/
getWordSize() != IFormattedMemoryBlock.MEMORY_SIZE_DOUBLE_WORD );
case IFormattedMemoryBlock.MEMORY_FORMAT_UNSIGNED_DECIMAL:
return ( /*getWordSize() != IFormattedMemoryBlock.MEMORY_SIZE_BYTE &&*/
getWordSize() != IFormattedMemoryBlock.MEMORY_SIZE_DOUBLE_WORD );
}
return false;
}
/**
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#isLittleEndian()
*/
public boolean isLittleEndian()
{
IExecFileInfo info = (IExecFileInfo)getDebugTarget().getAdapter( IExecFileInfo.class );
if ( info != null )
{
return info.isLittleEndian();
}
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#isStartAddressChanged()
*/
public boolean isStartAddressChanged()
{
return fStartAddressChanged;
}
private IAddress getRowAddress(int offset )
{
IAddress result = getRealStartAddress().add(BigInteger.valueOf(offset));
IAddress max = ((CDebugTarget)getDebugTarget()).getAddressFactory().getMax();
if ( result.compareTo(max) > 0 )
{
result = result.add(result.getMaxOffset().negate());
}
return result;
}
}

View file

@ -1,3 +1,31 @@
2005-01-12 Mikhail Khodjaiants
Bug 73168: Use memory view provided by Eclipse platform in CDT.
Removed the old memory view.
* CDebugUIPreferenceInitializer.java
* AutoRefreshMemoryAction.java: removed
* ClearMemoryAction.java: removed
* MemoryActionSelectionGroup.java: removed
* MemoryFormatAction.java: removed
* MemoryNumberOfColumnAction.java: removed
* MemorySizeAction.java: removed
* RefreshMemoryAction.java: removed
* ShowAsciiAction.java: removed
* ActionMessages.properties
* PreferenceMessages.properties
* MemoryViewPreferencePage.java: removed
* ICDebugPreferenceConstants.java
* MemoryControlArea.java: removed
* MemoryPresentation.java: removed
* MemoryText.java: removed
* MemoryView.java: removed
* MemoryViewAction.java: removed
* MemoryViewContentProvider.java: removed
* MemoryViewer.java: removed
* MemoryViewEventHandler.java: removed
* MemoryViewMessages.java: removed
* MemoryViewMessages.properties: removed
* plugin.xml
2005-01-11 Mikhail Khodjaiants
Replaced deprecated methods and constants. Cleanup.
* SWTUtil.java

View file

@ -40,13 +40,6 @@
</extension>
<extension
point="org.eclipse.ui.views">
<view
name="%MemoryView.name"
icon="icons/full/cview16/memory_view.gif"
category="org.eclipse.debug.ui"
class="org.eclipse.cdt.debug.internal.ui.views.memory.MemoryView"
id="org.eclipse.cdt.debug.ui.MemoryView">
</view>
<view
name="%SharedLibrariesView.name"
icon="icons/full/cview16/sharedlibraries_view.gif"
@ -73,15 +66,6 @@
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.debug.ui.DebugPerspective">
<view
relative="org.eclipse.debug.ui.VariableView"
visible="false"
relationship="stack"
id="org.eclipse.cdt.debug.ui.MemoryView">
</view>
<viewShortcut
id="org.eclipse.cdt.debug.ui.MemoryView">
</viewShortcut>
<view
relative="org.eclipse.debug.ui.VariableView"
visible="false"
@ -103,6 +87,9 @@
<viewShortcut
id="org.eclipse.debug.ui.RegisterView">
</viewShortcut>
<viewShortcut
id="org.eclipse.debug.ui.MemoryView">
</viewShortcut>
<view
relative="org.eclipse.ui.views.ContentOutline"
visible="false"
@ -119,12 +106,6 @@
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
name="%MemoryPreferencePage.name"
category="org.eclipse.debug.ui.DebugPreferencePage"
class="org.eclipse.cdt.debug.internal.ui.preferences.MemoryViewPreferencePage"
id="org.eclipse.cdt.debug.ui.MemoryViewPreferencePage">
</page>
<page
name="%CDebugPreferencePage.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
@ -1029,7 +1010,7 @@
<extension
point="org.eclipse.debug.ui.contextViewBindings">
<contextViewBinding
viewId="org.eclipse.cdt.debug.ui.MemoryView"
viewId="org.eclipse.debug.ui.MemoryView"
contextId="org.eclipse.cdt.debug.ui.debugging">
</contextViewBinding>
<contextViewBinding

View file

@ -11,7 +11,6 @@
package org.eclipse.cdt.debug.internal.ui;
import org.eclipse.cdt.debug.internal.ui.preferences.CDebugPreferencePage;
import org.eclipse.cdt.debug.internal.ui.preferences.MemoryViewPreferencePage;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
@ -33,7 +32,6 @@ public class CDebugUIPreferenceInitializer extends AbstractPreferenceInitializer
*/
public void initializeDefaultPreferences() {
IPreferenceStore pstore = CDebugUIPlugin.getDefault().getPreferenceStore();
MemoryViewPreferencePage.initDefaults( pstore );
CDebugPreferencePage.initDefaults( pstore );
}
}

View file

@ -56,15 +56,9 @@ ManageFunctionBreakpointActionDelegate.Error_1=Error
ManageFunctionBreakpointActionDelegate.Operation_failed_1=Operation failed.
SignalActionDelegate.0=Unable to deliver the signal to the target.
SignalActionDelegate.1=Operation failed.
AutoRefreshMemoryAction.0=Auto-Refresh
AutoRefreshMemoryAction.1=Turns on/off the auto-refresh mode.
AutoRefreshMemoryAction.2=Auto-Refresh Mode
RestartActionDelegate.0=Exception(s) occurred attempting to restart.
RestartActionDelegate.1=Restart failed.
RestartActionDelegate.2=Restart
ShowAsciiAction.0=Show ASCII
ShowAsciiAction.1=Displays the ASCII presentation of the memory.
ShowAsciiAction.2=Show the ASCII presentation
AddGlobalsActionDelegate.0=Select Variables:
AddGlobalsActionDelegate.1=Add global variables failed.
VariableFormatActionDelegate.0=Unable to set format.
@ -85,28 +79,9 @@ CastToArrayActionDelegate.7=The length must be greater than 0.
CastToArrayActionDelegate.8=Unable to display this variable as an array.
EnableVariablesActionDelegate.0=Exceptions occurred enabling the variable(s).
EnableVariablesActionDelegate.1=Enable variable(s) failed.
#
# Examples of the display for the following value are "1 byte" and "8 bytes".
# Normally placeholders in {} are not translated, except when they are choice forms,
# where the strings after each "#" are to be translated.
#
MemorySizeAction.0={0, number, integer} {0, choice, 1\#byte|2\#bytes}
MemorySizeAction.1=Unable to change memory unit size.
MemoryFormatAction.0=Unable to change the format.
MemoryFormatAction.1=Hexadecimal
MemoryFormatAction.2=Signed Decimal
MemoryFormatAction.3=Unsigned Decimal
MemoryNumberOfColumnAction.0={0, number, integer} {0, choice, 0\#columns|1\#column|2\#columns}
MemoryNumberOfColumnAction.1=Unable to change the column number.
AddWatchpointActionDelegate.0=Cannot add watchpoint.
AddWatchpointDialog.0=Add Watchpoint
AddWatchpointDialog.1=Expression to watch:
AddWatchpointDialog.2=Access
AddWatchpointDialog.3=Write
AddWatchpointDialog.4=Read
ClearMemoryAction.0=Clear
ClearMemoryAction.1=Clears the current memory block
ClearMemoryAction.2=Clear
RefreshMemoryAction.0=Refreshs the current memory block.
RefreshMemoryAction.1=Refresh
RefreshMemoryAction.2=Refresh

View file

@ -1,57 +0,0 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.views.memory.MemoryViewer;
import org.eclipse.ui.actions.SelectionProviderAction;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.texteditor.IUpdate;
/**
* The "Auto-Refresh" action of the Memory View.
*/
public class AutoRefreshMemoryAction extends SelectionProviderAction implements IUpdate {
private MemoryViewer fMemoryViewer;
/**
* Constructor for AutoRefreshMemoryAction.
*/
public AutoRefreshMemoryAction( MemoryViewer viewer ) {
super( viewer, ActionMessages.getString( "AutoRefreshMemoryAction.0" ) ); //$NON-NLS-1$
fMemoryViewer = viewer;
CDebugImages.setLocalImageDescriptors( this, CDebugImages.IMG_LCL_AUTO_REFRESH );
setDescription( ActionMessages.getString( "AutoRefreshMemoryAction.1" ) ); //$NON-NLS-1$
setToolTipText( ActionMessages.getString( "AutoRefreshMemoryAction.2" ) ); //$NON-NLS-1$
WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.AUTO_REFRESH_MEMORY_ACTION );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
setEnabled( fMemoryViewer.canUpdate() );
setChecked( !fMemoryViewer.isFrozen() );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
fMemoryViewer.setFrozen( !isChecked() );
}
}

View file

@ -1,56 +0,0 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.views.memory.MemoryViewer;
import org.eclipse.ui.actions.SelectionProviderAction;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.texteditor.IUpdate;
/**
* The "Clear" action of the Memory view.
*/
public class ClearMemoryAction extends SelectionProviderAction implements IUpdate {
private MemoryViewer fMemoryViewer;
/**
* Constructor for ClearMemoryAction.
*/
public ClearMemoryAction( MemoryViewer viewer ) {
super( viewer, ActionMessages.getString( "ClearMemoryAction.0" ) ); //$NON-NLS-1$
fMemoryViewer = viewer;
CDebugImages.setLocalImageDescriptors( this, CDebugImages.IMG_LCL_MEMORY_CLEAR );
setDescription( ActionMessages.getString( "ClearMemoryAction.1" ) ); //$NON-NLS-1$
setToolTipText( ActionMessages.getString( "ClearMemoryAction.2" ) ); //$NON-NLS-1$
WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.MEMORY_CLEAR_ACTION );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
setEnabled( fMemoryViewer.canUpdate() );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
fMemoryViewer.clear();
}
}

View file

@ -1,78 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.action.IAction;
/**
* Enter type comment.
*
* @since: Oct 22, 2002
*/
public class MemoryActionSelectionGroup
{
private List fActions;
private IAction fSelection = null;
/**
* Constructor for MemoryActionSelectionGroup.
*/
public MemoryActionSelectionGroup()
{
fActions = new ArrayList();
}
public IAction getCurrentSelection()
{
return fSelection;
}
public void setCurrentSelection( IAction selection )
{
Iterator it = fActions.iterator();
while( it.hasNext() )
{
IAction action = (IAction)it.next();
if ( !action.equals( selection ) )
{
action.setChecked( false );
}
}
if ( fActions.contains( selection ) )
{
fSelection = selection;
}
else
{
fSelection = null;
}
}
public void addAction( IAction action )
{
fActions.add( action );
}
public void dispose()
{
fActions.clear();
fSelection = null;
}
public IAction[] getActions()
{
return (IAction[])fActions.toArray( new IAction[fActions.size()] );
}
}

View file

@ -1,85 +0,0 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.internal.ui.views.memory.MemoryViewer;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.debug.core.DebugException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.texteditor.IUpdate;
/**
* The "Format" action of the Memory view.
*/
public class MemoryFormatAction extends Action implements IUpdate {
private MemoryActionSelectionGroup fGroup;
private MemoryViewer fMemoryViewer;
private int fFormat = 0;
/**
* Constructor for MemoryFormatAction.
*/
public MemoryFormatAction( MemoryActionSelectionGroup group, MemoryViewer viewer, int format ) {
super( getLabel( format ), IAction.AS_CHECK_BOX );
fGroup = group;
fMemoryViewer = viewer;
fFormat = format;
}
/**
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
setEnabled( fMemoryViewer.canChangeFormat( fFormat ) );
setChecked( fMemoryViewer.getCurrentFormat() == fFormat );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
try {
fMemoryViewer.setFormat( fFormat );
fGroup.setCurrentSelection( this );
}
catch( DebugException e ) {
CDebugUIPlugin.errorDialog( ActionMessages.getString( "MemoryFormatAction.0" ), e.getStatus() ); //$NON-NLS-1$
setChecked( false );
}
}
private static String getLabel( int id ) {
String label = ""; //$NON-NLS-1$
switch( id ) {
case (IFormattedMemoryBlock.MEMORY_FORMAT_HEX ):
label = ActionMessages.getString( "MemoryFormatAction.1" ); //$NON-NLS-1$
break;
case (IFormattedMemoryBlock.MEMORY_FORMAT_SIGNED_DECIMAL ):
label = ActionMessages.getString( "MemoryFormatAction.2" ); //$NON-NLS-1$
break;
case (IFormattedMemoryBlock.MEMORY_FORMAT_UNSIGNED_DECIMAL ):
label = ActionMessages.getString( "MemoryFormatAction.3" ); //$NON-NLS-1$
break;
}
return label;
}
public String getActionId() {
return "MemoryFormat" + fFormat; //$NON-NLS-1$
}
}

View file

@ -1,75 +0,0 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import java.text.MessageFormat;
import org.eclipse.cdt.debug.internal.ui.views.memory.MemoryViewer;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.debug.core.DebugException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.texteditor.IUpdate;
/**
* The "Number Of Memory View Coulumns" action.
*/
public class MemoryNumberOfColumnAction extends Action implements IUpdate {
private MemoryActionSelectionGroup fGroup;
private MemoryViewer fMemoryViewer;
private int fNumberOfColumns = 0;
/**
* Constructor for MemoryNumberOfColumnAction.
*/
public MemoryNumberOfColumnAction( MemoryActionSelectionGroup group, MemoryViewer viewer, int numberOfColumns ) {
super( getLabel( numberOfColumns ), IAction.AS_CHECK_BOX );
fGroup = group;
fMemoryViewer = viewer;
fNumberOfColumns = numberOfColumns;
}
private static String getLabel( int numberOfColumns ) {
return MessageFormat.format( ActionMessages.getString( "MemoryNumberOfColumnAction.0" ), new Integer[] { new Integer( numberOfColumns ) } ); //$NON-NLS-1$
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
setEnabled( fMemoryViewer.canUpdate() );
setChecked( fMemoryViewer.getCurrentNumberOfColumns() == fNumberOfColumns );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
try {
fMemoryViewer.setNumberOfColumns( fNumberOfColumns );
fGroup.setCurrentSelection( this );
}
catch( DebugException e ) {
CDebugUIPlugin.errorDialog( ActionMessages.getString( "MemoryNumberOfColumnAction.1" ), e.getStatus() ); //$NON-NLS-1$
setChecked( false );
}
}
public String getActionId() {
return "MemoryNumberOfColumns" + fNumberOfColumns; //$NON-NLS-1$
}
}

View file

@ -1,88 +0,0 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import java.text.MessageFormat;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.internal.ui.views.memory.MemoryViewer;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.debug.core.DebugException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.texteditor.IUpdate;
/**
* The "Memory Unit Size" action.
*/
public class MemorySizeAction extends Action implements IUpdate {
private MemoryActionSelectionGroup fGroup;
private MemoryViewer fMemoryViewer;
private int fId = 0;
/**
* Constructor for MemorySizeAction.
*/
public MemorySizeAction( MemoryActionSelectionGroup group, MemoryViewer viewer, int id ) {
super( getLabel( id ), IAction.AS_CHECK_BOX );
fGroup = group;
fMemoryViewer = viewer;
fId = id;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
setEnabled( fMemoryViewer.canUpdate() );
setChecked( fMemoryViewer.getCurrentWordSize() == fId );
}
private static String getLabel( int id ) {
String label = ""; //$NON-NLS-1$
switch( id ) {
case IFormattedMemoryBlock.MEMORY_SIZE_BYTE:
case IFormattedMemoryBlock.MEMORY_SIZE_HALF_WORD:
case IFormattedMemoryBlock.MEMORY_SIZE_WORD:
case IFormattedMemoryBlock.MEMORY_SIZE_DOUBLE_WORD:
// Examples of the display for the following value are "1 byte" and "8 bytes".
// Normally placeholders in {} are not translated, except when they are choice forms,
// where the strings after each "#" are to be translated.
label = MessageFormat.format( ActionMessages.getString( "MemorySizeAction.0" ), new Integer[] { new Integer( id ) } ); //$NON-NLS-1$
break;
}
return label;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
try {
fMemoryViewer.setWordSize( fId );
fGroup.setCurrentSelection( this );
}
catch( DebugException e ) {
CDebugUIPlugin.errorDialog( ActionMessages.getString( "MemorySizeAction.1" ), e.getStatus() ); //$NON-NLS-1$
setChecked( false );
}
}
public String getActionId() {
return "MemorySize" + fId; //$NON-NLS-1$
}
}

View file

@ -1,56 +0,0 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.views.memory.MemoryViewer;
import org.eclipse.ui.actions.SelectionProviderAction;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.texteditor.IUpdate;
/**
* The "Refresh" action of the Memory view.
*/
public class RefreshMemoryAction extends SelectionProviderAction implements IUpdate {
private MemoryViewer fMemoryViewer;
/**
* Constructor for RefreshMemoryAction.
*/
public RefreshMemoryAction( MemoryViewer viewer ) {
super( viewer, ActionMessages.getString("RefreshMemoryAction.1") ); //$NON-NLS-1$
fMemoryViewer = viewer;
CDebugImages.setLocalImageDescriptors( this, CDebugImages.IMG_LCL_REFRESH );
setDescription( ActionMessages.getString( "RefreshMemoryAction.0" ) ); //$NON-NLS-1$
setToolTipText( ActionMessages.getString("RefreshMemoryAction.2") ); //$NON-NLS-1$
WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.REFRESH_MEMORY_ACTION );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
setEnabled( fMemoryViewer.canUpdate() );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
fMemoryViewer.refreshMemoryBlock();
}
}

View file

@ -1,62 +0,0 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.views.memory.MemoryViewer;
import org.eclipse.ui.actions.SelectionProviderAction;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.texteditor.IUpdate;
/**
* Enter type comment.
*
* @since: Oct 21, 2002
*/
public class ShowAsciiAction extends SelectionProviderAction implements IUpdate {
private MemoryViewer fMemoryViewer;
/**
* Constructor for ShowAsciiAction.
*
* @param provider
* @param text
*/
public ShowAsciiAction( MemoryViewer viewer ) {
super( viewer, ActionMessages.getString( "ShowAsciiAction.0" ) ); //$NON-NLS-1$
fMemoryViewer = viewer;
CDebugImages.setLocalImageDescriptors( this, CDebugImages.IMG_LCL_SHOW_ASCII );
setDescription( ActionMessages.getString( "ShowAsciiAction.1" ) ); //$NON-NLS-1$
setToolTipText( ActionMessages.getString( "ShowAsciiAction.2" ) ); //$NON-NLS-1$
WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.MEMORY_SHOW_ASCII_ACTION );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
setEnabled( fMemoryViewer.canShowAscii() );
setChecked( fMemoryViewer.showAscii() );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
fMemoryViewer.setShowAscii( isChecked() );
}
}

View file

@ -11,11 +11,6 @@
package org.eclipse.cdt.debug.internal.ui.preferences;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
/**
*
@ -31,52 +26,6 @@ import org.eclipse.swt.widgets.Display;
*/
public interface ICDebugPreferenceConstants {
/**
* The default values for the memory view parameters.
*/
public static final String DEFAULT_MEMORY_PADDING_CHAR = "."; //$NON-NLS-1$
public static final FontData DEFAULT_MEMORY_FONT = JFaceResources.getTextFont().getFontData()[0];
public static final RGB DEFAULT_MEMORY_FOREGROUND_RGB = Display.getCurrent().getSystemColor( SWT.COLOR_LIST_FOREGROUND ).getRGB();
public static final RGB DEFAULT_MEMORY_BACKGROUND_RGB = Display.getCurrent().getSystemColor( SWT.COLOR_LIST_BACKGROUND ).getRGB();
public static final RGB DEFAULT_MEMORY_ADDRESS_RGB = Display.getCurrent().getSystemColor( SWT.COLOR_DARK_GRAY ).getRGB();
public static final RGB DEFAULT_MEMORY_CHANGED_RGB = Display.getCurrent().getSystemColor( SWT.COLOR_RED ).getRGB();
public static final RGB DEFAULT_MEMORY_DIRTY_RGB = Display.getCurrent().getSystemColor( SWT.COLOR_BLUE ).getRGB();
public static final String PREF_MEMORY_NUMBER_OF_BYTES = "Memory.NumberOfBytes"; //$NON-NLS-1$
public static final String PREF_MEMORY_SIZE = "Memory.Size"; //$NON-NLS-1$
public static final String PREF_MEMORY_FORMAT = "Memory.Format"; //$NON-NLS-1$
public static final String PREF_MEMORY_BYTES_PER_ROW = "Memory.BytesPerRow"; //$NON-NLS-1$
public static final String PREF_MEMORY_PADDING_CHAR = "Memory.PaddingChar"; //$NON-NLS-1$
/**
* The RGB for the memory text foreground color
*/
public static final String MEMORY_FOREGROUND_RGB = "Memory.Foreground.RGB"; //$NON-NLS-1$
/**
* The RGB for the memory text background color
*/
public static final String MEMORY_BACKGROUND_RGB = "Memory.background.RGB"; //$NON-NLS-1$
/**
* The RGB for the color to be used to indicate address values in the memory view
*/
public static final String MEMORY_ADDRESS_RGB = "Memory.Address.RGB"; //$NON-NLS-1$
/**
* The RGB for the color to be used to indicate changed values in the memory view
*/
public static final String MEMORY_CHANGED_RGB = "Memory.Changed.RGB"; //$NON-NLS-1$
/**
* The RGB for the color to be used to indicate dirty values in the memory view
*/
public static final String MEMORY_DIRTY_RGB = "Memory.Dirty.RGB"; //$NON-NLS-1$
/**
* The name of the font to use for the memory view
*/
public static final String MEMORY_FONT = "Memory.font"; //$NON-NLS-1$
/**
* Boolean preference controlling whether the debugger shows full paths. When <code>true</code> the debugger will show full paths in newly opened views.
*/
@ -91,16 +40,4 @@ public interface ICDebugPreferenceConstants {
* Boolean preference controlling whether primitive types types display char values.
*/
public static final String PREF_SHOW_CHAR_VALUES = ICDebugUIConstants.PLUGIN_ID + ".cDebug.showCharValues"; //$NON-NLS-1$
/**
* Boolean preference controlling whether the memory view shows ASCII characters. When <code>true</code> the memory view will show ASCII characters by
* default.
*/
public static final String PREF_MEMORY_SHOW_ASCII = ICDebugUIConstants.PLUGIN_ID + ".Memory.show_ascii"; //$NON-NLS-1$
/**
* Boolean preference controlling whether the memory view will be refreshed every time when the execution of program stops. When <code>true</code> the
* 'Auto-Refresh' option will be checked.
*/
public static final String PREF_MEMORY_AUTO_REFRESH = ICDebugUIConstants.PLUGIN_ID + ".Memory.auto_refresh"; //$NON-NLS-1$
}

View file

@ -1,139 +0,0 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.preferences;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ColorFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.FontFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.help.WorkbenchHelp;
/**
* The preference page of the Memory view.
*/
public class MemoryViewPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
/**
* Constructor for MemoryViewPreferencePage.
*/
public MemoryViewPreferencePage() {
super( GRID );
setDescription( PreferenceMessages.getString( "MemoryViewPreferencePage.0" ) ); //$NON-NLS-1$
setPreferenceStore( CDebugUIPlugin.getDefault().getPreferenceStore() );
}
/**
* @see PreferencePage#createControl(Composite)
*/
public void createControl( Composite parent ) {
super.createControl( parent );
WorkbenchHelp.setHelp( parent, ICDebugHelpContextIds.MEMORY_PREFERENCE_PAGE );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
*/
protected void createFieldEditors() {
/*
* String[][] sizes = { { "Byte", "1" }, { "Half Word", "2" }, { "Word", "4" }, { "Double Word", "8" }, // { "Float", "8" }, // { "Double Float", "16" }, };
* addField( new ComboFieldEditor( ICDebugPreferenceConstants.PREF_MEMORY_SIZE, "Size:", sizes, getFieldEditorParent() ) );
*
* String[][] formats = { { "Hexadecimal", "0" }, { "Binary", "1" }, // { "Octal", "2" }, // { "Signed Decimal", "3" }, // { "Unsigned Decimal", "4" }, };
* addField( new ComboFieldEditor( ICDebugPreferenceConstants.PREF_MEMORY_FORMAT, "Format:", formats, getFieldEditorParent() ) );
*
* String[][] bytesPerRow = { { "4", "4" }, { "8", "8" }, { "16", "16" }, { "32", "32" }, { "64", "64" }, { "128", "128" } }; addField( new
* ComboFieldEditor( ICDebugPreferenceConstants.PREF_MEMORY_BYTES_PER_ROW, "Bytes Per Row:", bytesPerRow, getFieldEditorParent() ) );
*
* addField( new BooleanFieldEditor( ICDebugPreferenceConstants.PREF_MEMORY_DISPLAY_ASCII, "Display ASCII", getFieldEditorParent() ) );
*/
ColorFieldEditor foreground = new ColorFieldEditor( ICDebugPreferenceConstants.MEMORY_FOREGROUND_RGB, PreferenceMessages.getString( "MemoryViewPreferencePage.1" ), getFieldEditorParent() ); //$NON-NLS-1$
ColorFieldEditor background = new ColorFieldEditor( ICDebugPreferenceConstants.MEMORY_BACKGROUND_RGB, PreferenceMessages.getString( "MemoryViewPreferencePage.2" ), getFieldEditorParent() ); //$NON-NLS-1$
ColorFieldEditor address = new ColorFieldEditor( ICDebugPreferenceConstants.MEMORY_ADDRESS_RGB, PreferenceMessages.getString( "MemoryViewPreferencePage.3" ), getFieldEditorParent() ); //$NON-NLS-1$
ColorFieldEditor changed = new ColorFieldEditor( ICDebugPreferenceConstants.MEMORY_CHANGED_RGB, PreferenceMessages.getString( "MemoryViewPreferencePage.4" ), getFieldEditorParent() ); //$NON-NLS-1$
// ColorFieldEditor dirty = new ColorFieldEditor( ICDebugPreferenceConstants.MEMORY_DIRTY_RGB, "Modified Value Color:", getFieldEditorParent() );
FontFieldEditor font = new FontFieldEditor( ICDebugPreferenceConstants.MEMORY_FONT, PreferenceMessages.getString( "MemoryViewPreferencePage.5" ), getFieldEditorParent() ); //$NON-NLS-1$
addField( foreground );
addField( background );
addField( address );
addField( changed );
// addField( dirty );
addField( font );
StringFieldEditor paddingChar = createPaddingCharacterField();
paddingChar.setTextLimit( 1 );
addField( paddingChar );
createSpacer( getFieldEditorParent(), 1 );
createDefaultSettingsFields();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(IWorkbench)
*/
public void init( IWorkbench workbench ) {
}
protected void createSpacer( Composite composite, int columnSpan ) {
Label label = new Label( composite, SWT.NONE );
GridData gd = new GridData();
gd.horizontalSpan = columnSpan;
label.setLayoutData( gd );
}
public static void initDefaults( IPreferenceStore store ) {
store.setDefault( ICDebugPreferenceConstants.PREF_MEMORY_PADDING_CHAR, ICDebugPreferenceConstants.DEFAULT_MEMORY_PADDING_CHAR );
store.setDefault( ICDebugPreferenceConstants.PREF_MEMORY_AUTO_REFRESH, true );
store.setDefault( ICDebugPreferenceConstants.PREF_MEMORY_SHOW_ASCII, true );
PreferenceConverter.setDefault( store, ICDebugPreferenceConstants.MEMORY_FONT, ICDebugPreferenceConstants.DEFAULT_MEMORY_FONT );
PreferenceConverter.setDefault( store, ICDebugPreferenceConstants.MEMORY_FOREGROUND_RGB, ICDebugPreferenceConstants.DEFAULT_MEMORY_FOREGROUND_RGB );
PreferenceConverter.setDefault( store, ICDebugPreferenceConstants.MEMORY_BACKGROUND_RGB, ICDebugPreferenceConstants.DEFAULT_MEMORY_BACKGROUND_RGB );
PreferenceConverter.setDefault( store, ICDebugPreferenceConstants.MEMORY_ADDRESS_RGB, ICDebugPreferenceConstants.DEFAULT_MEMORY_ADDRESS_RGB );
PreferenceConverter.setDefault( store, ICDebugPreferenceConstants.MEMORY_CHANGED_RGB, ICDebugPreferenceConstants.DEFAULT_MEMORY_CHANGED_RGB );
PreferenceConverter.setDefault( store, ICDebugPreferenceConstants.MEMORY_DIRTY_RGB, ICDebugPreferenceConstants.DEFAULT_MEMORY_DIRTY_RGB );
}
/**
* @see IPreferencePage#performOk()
*/
public boolean performOk() {
boolean ok = super.performOk();
CDebugUIPlugin.getDefault().savePluginPreferences();
return ok;
}
private StringFieldEditor createPaddingCharacterField() {
return new StringFieldEditor( ICDebugPreferenceConstants.PREF_MEMORY_PADDING_CHAR, PreferenceMessages.getString( "MemoryViewPreferencePage.6" ), 1, getFieldEditorParent() ) //$NON-NLS-1$
{
protected boolean doCheckState() {
return (getTextControl().getText().length() == 1);
}
};
}
private void createDefaultSettingsFields() {
addField( new BooleanFieldEditor( ICDebugPreferenceConstants.PREF_MEMORY_AUTO_REFRESH, PreferenceMessages.getString( "MemoryViewPreferencePage.7" ), SWT.NONE, getFieldEditorParent() ) ); //$NON-NLS-1$
addField( new BooleanFieldEditor( ICDebugPreferenceConstants.PREF_MEMORY_SHOW_ASCII, PreferenceMessages.getString( "MemoryViewPreferencePage.8" ), SWT.NONE, getFieldEditorParent() ) ); //$NON-NLS-1$
}
}

View file

@ -25,12 +25,3 @@ CDebugPreferencePage.13=The valid value range is [{0},{1}].
SourcePreferencePage.0=Common source lookup settings.
SourcePreferencePage.1=Source Locations
SourcePreferencePage.2=Search for duplicate source files
MemoryViewPreferencePage.0=The Memory view settings.
MemoryViewPreferencePage.1=Text Color:
MemoryViewPreferencePage.2=Background Color:
MemoryViewPreferencePage.3=Address Color:
MemoryViewPreferencePage.4=Changed Value Color:
MemoryViewPreferencePage.5=Font:
MemoryViewPreferencePage.6=Padding Character:
MemoryViewPreferencePage.7=Auto-Refresh by default
MemoryViewPreferencePage.8=Show ASCII by default

View file

@ -1,480 +0,0 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.memory;
import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.ICMemoryManager;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
/**
* The tab content in the memory view.
*/
public class MemoryControlArea extends Composite implements ITextOperationTarget {
private MemoryView fMemoryView;
private MemoryPresentation fPresentation;
private int fIndex = 0;
private ICMemoryManager fMemoryManager = null;
private Text fAddressText;
private Button fEvaluateButton;
private MemoryText fMemoryText;
private int fFormat = ICMemoryManager.MEMORY_FORMAT_HEX;
private int fWordSize = ICMemoryManager.MEMORY_SIZE_BYTE;
private int fNumberOfRows = 40;
private int fNumberOfColumns = 16;
private char fPaddingChar = '.';
/**
* Constructor for MemoryControlArea.
*
* @param parent
* @param style
*/
public MemoryControlArea( Composite parent, int style, int index, MemoryView view ) {
super( parent, style );
fMemoryView = view;
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
GridData gridData = new GridData( GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL );
setLayout( layout );
setLayoutData( gridData );
setIndex( index );
fPresentation = createPresentation();
fAddressText = createAddressText( this );
fMemoryText = createMemoryText( this, style, fPresentation );
setDefaultPreferences();
updateToolTipText();
}
private void setDefaultPreferences() {
char[] paddingCharStr = CDebugUIPlugin.getDefault().getPreferenceStore().getString( ICDebugPreferenceConstants.PREF_MEMORY_PADDING_CHAR ).toCharArray();
setPaddingChar( (paddingCharStr.length > 0) ? paddingCharStr[0] : '.' );
fPresentation.setDisplayAscii( CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_MEMORY_SHOW_ASCII ) );
}
private MemoryPresentation createPresentation() {
return new MemoryPresentation();
}
public MemoryPresentation getPresentation() {
return fPresentation;
}
private Text createAddressText( Composite parent ) {
Composite composite = new Composite( parent, SWT.NONE );
composite.setLayout( new GridLayout( 3, false ) );
composite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
// create label
Label label = new Label( composite, SWT.RIGHT );
label.setText( MemoryViewMessages.getString( "MemoryControlArea.0" ) ); //$NON-NLS-1$
label.pack();
// create address text
Text text = new Text( composite, SWT.BORDER );
text.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
text.addTraverseListener( new TraverseListener() {
public void keyTraversed( TraverseEvent e ) {
if ( e.detail == SWT.TRAVERSE_RETURN && e.stateMask == 0 ) {
e.doit = false;
handleAddressEnter();
}
}
} );
text.addFocusListener( new FocusListener() {
public void focusGained( FocusEvent e ) {
getMemoryView().updateObjects();
}
public void focusLost( FocusEvent e ) {
getMemoryView().updateObjects();
}
} );
text.addModifyListener( new ModifyListener() {
public void modifyText( ModifyEvent e ) {
handleAddressModification();
}
} );
text.addKeyListener( new KeyListener() {
public void keyPressed( KeyEvent e ) {
getMemoryView().updateObjects();
}
public void keyReleased( KeyEvent e ) {
getMemoryView().updateObjects();
}
} );
text.addMouseListener( new MouseListener() {
public void mouseDoubleClick( MouseEvent e ) {
getMemoryView().updateObjects();
}
public void mouseDown( MouseEvent e ) {
getMemoryView().updateObjects();
}
public void mouseUp( MouseEvent e ) {
getMemoryView().updateObjects();
}
} );
fEvaluateButton = new Button( composite, SWT.PUSH );
fEvaluateButton.setText( MemoryViewMessages.getString( "MemoryControlArea.1" ) ); //$NON-NLS-1$
fEvaluateButton.setToolTipText( MemoryViewMessages.getString( "MemoryControlArea.2" ) ); //$NON-NLS-1$
fEvaluateButton.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
evaluateAddressExpression();
}
} );
return text;
}
private MemoryText createMemoryText( Composite parent, int styles, MemoryPresentation presentation ) {
return new MemoryText( parent, SWT.BORDER | SWT.HIDE_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL, presentation );
}
protected void handleAddressEnter() {
if ( getMemoryManager() != null ) {
String address = fAddressText.getText().trim();
try {
removeBlock();
if ( address.length() > 0 ) {
createBlock( address );
}
}
catch( DebugException e ) {
CDebugUIPlugin.errorDialog( MemoryViewMessages.getString( "MemoryControlArea.3" ), e.getStatus() ); //$NON-NLS-1$
}
refresh();
getMemoryView().updateObjects();
}
}
public void propertyChange( PropertyChangeEvent event ) {
if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_BACKGROUND_RGB ) ) {
fMemoryText.setBackgroundColor();
}
else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_FOREGROUND_RGB ) ) {
fMemoryText.setForegroundColor();
}
else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_FONT ) ) {
fMemoryText.changeFont();
}
else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_ADDRESS_RGB ) ) {
fMemoryText.setAddressColor();
}
else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_CHANGED_RGB ) ) {
fMemoryText.setChangedColor();
}
else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_DIRTY_RGB ) ) {
fMemoryText.setDirtyColor();
}
else if ( event.getProperty().equals( ICDebugPreferenceConstants.PREF_MEMORY_PADDING_CHAR ) ) {
String paddingCharString = (String)event.getNewValue();
setPaddingChar( (paddingCharString.length() > 0) ? paddingCharString.charAt( 0 ) : '.' );
refresh();
}
}
public void setInput( Object input ) {
setMemoryManager( (input instanceof ICMemoryManager) ? (ICMemoryManager)input : null );
getPresentation().setMemoryBlock( getMemoryBlock() );
setState();
refresh();
}
protected void refresh() {
fAddressText.setText( (getPresentation() != null) ? getPresentation().getAddressExpression() : "" ); //$NON-NLS-1$
fMemoryText.refresh();
getMemoryView().updateObjects();
updateToolTipText();
}
protected void setMemoryManager( ICMemoryManager mm ) {
fMemoryManager = mm;
}
protected ICMemoryManager getMemoryManager() {
return fMemoryManager;
}
protected IFormattedMemoryBlock getMemoryBlock() {
return (getMemoryManager() != null) ? getMemoryManager().getBlock( getIndex() ) : null;
}
protected int getIndex() {
return fIndex;
}
protected void setIndex( int index ) {
fIndex = index;
}
private void createBlock( String address ) throws DebugException {
if ( getMemoryManager() != null ) {
getMemoryManager().setBlockAt( getIndex(), CDebugModel.createFormattedMemoryBlock( (IDebugTarget)getMemoryManager().getAdapter( IDebugTarget.class ), address, getFormat(), getWordSize(), getNumberOfRows(), getNumberOfColumns(), getPaddingChar() ) );
getMemoryBlock().setFrozen( !CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_MEMORY_AUTO_REFRESH ) );
getPresentation().setMemoryBlock( getMemoryBlock() );
}
setMemoryTextState();
updateToolTipText();
}
private void removeBlock() throws DebugException {
if ( getMemoryManager() != null ) {
getMemoryManager().removeBlock( getIndex() );
getPresentation().setMemoryBlock( null );
}
setMemoryTextState();
updateToolTipText();
}
public int getFormat() {
return fFormat;
}
public int getNumberOfColumns() {
return fNumberOfColumns;
}
public int getNumberOfRows() {
return fNumberOfRows;
}
public char getPaddingChar() {
return fPaddingChar;
}
public int getWordSize() {
return fWordSize;
}
public void setFormat( int format ) {
fFormat = format;
}
public void setNumberOfColumns( int numberOfColumns ) {
fNumberOfColumns = numberOfColumns;
}
public void setNumberOfRows( int numberOfRows ) {
fNumberOfRows = numberOfRows;
}
public void setPaddingChar( char paddingChar ) {
fPaddingChar = paddingChar;
if ( getMemoryBlock() != null ) {
try {
getMemoryBlock().reformat( getMemoryBlock().getFormat(), getMemoryBlock().getWordSize(), getMemoryBlock().getNumberOfRows(), getMemoryBlock().getNumberOfColumns(), fPaddingChar );
}
catch( DebugException e ) {
// ignore
}
}
}
public void setWordSize( int wordSize ) {
fWordSize = wordSize;
}
private void enableAddressText( boolean enable ) {
fAddressText.setEnabled( enable );
}
protected void setState() {
enableAddressText( getMemoryManager() != null );
setMemoryTextState();
}
private void setMemoryTextState() {
fMemoryText.setEditable( getMemoryManager() != null && getMemoryBlock() != null );
}
protected MemoryText getMemoryText() {
return fMemoryText;
}
protected void clear() {
fAddressText.setText( "" ); //$NON-NLS-1$
handleAddressEnter();
updateToolTipText();
}
/**
* @see org.eclipse.swt.widgets.Widget#dispose()
*/
public void dispose() {
if ( getPresentation() != null ) {
getPresentation().dispose();
}
super.dispose();
}
protected String getTitle() {
if ( getParent() instanceof CTabFolder ) {
CTabItem[] tabItems = ((CTabFolder)getParent()).getItems();
return tabItems[fIndex].getText();
}
return ""; //$NON-NLS-1$
}
protected void setTitle( String title ) {
if ( getParent() instanceof CTabFolder ) {
CTabItem[] tabItems = ((CTabFolder)getParent()).getItems();
tabItems[fIndex].setText( title );
}
}
protected void setTabItemToolTipText( String text ) {
String newText = replaceMnemonicCharacters( text );
if ( getParent() instanceof CTabFolder ) {
CTabItem[] tabItems = ((CTabFolder)getParent()).getItems();
tabItems[fIndex].setToolTipText( MemoryViewMessages.getString( "MemoryControlArea.4" ) + (fIndex + 1) + ((newText.length() > 0) ? (": " + newText) : "") ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
protected void refreshMemoryBlock() {
if ( getMemoryBlock() != null ) {
try {
getMemoryBlock().refresh();
}
catch( DebugException e ) {
CDebugUIPlugin.errorDialog( MemoryViewMessages.getString( "MemoryControlArea.7" ), e.getStatus() ); //$NON-NLS-1$
}
}
}
private void updateToolTipText() {
setTabItemToolTipText( fAddressText.getText().trim() );
}
private String replaceMnemonicCharacters( String text ) {
StringBuffer sb = new StringBuffer( text.length() );
for( int i = 0; i < text.length(); ++i ) {
char ch = text.charAt( i );
sb.append( ch );
if ( ch == '&' ) {
sb.append( ch );
}
}
return sb.toString();
}
protected void handleAddressModification() {
fEvaluateButton.setEnabled( fAddressText.getText().trim().length() > 0 );
}
protected void evaluateAddressExpression() {
if ( getMemoryManager() != null ) {
if ( getMemoryBlock() == null ) {
String expression = fAddressText.getText().trim();
try {
removeBlock();
if ( expression.length() > 0 ) {
createBlock( expression );
}
}
catch( DebugException e ) {
CDebugUIPlugin.errorDialog( MemoryViewMessages.getString( "MemoryControlArea.8" ), e.getStatus() ); //$NON-NLS-1$
}
}
if ( getMemoryBlock() != null ) {
fAddressText.setText( getMemoryBlock().getRealStartAddress().toHexAddressString() );
handleAddressEnter();
}
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.text.ITextOperationTarget#canDoOperation(int)
*/
public boolean canDoOperation( int operation ) {
switch( operation ) {
case CUT:
case COPY:
return (fAddressText != null && fAddressText.isFocusControl() && fAddressText.isEnabled() && fAddressText.getSelectionCount() > 0);
case PASTE:
case SELECT_ALL:
return (fAddressText != null && fAddressText.isFocusControl() && fAddressText.isEnabled());
}
return false;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.text.ITextOperationTarget#doOperation(int)
*/
public void doOperation( int operation ) {
switch( operation ) {
case CUT:
fAddressText.cut();
break;
case COPY:
fAddressText.copy();
break;
case PASTE:
fAddressText.paste();
break;
case SELECT_ALL:
fAddressText.selectAll();
break;
}
}
protected MemoryView getMemoryView() {
return fMemoryView;
}
}

View file

@ -1,558 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.memory;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.ICMemoryManager;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlockRow;
import org.eclipse.debug.core.DebugException;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
/**
*
* Provides rendering methods to the MemoryText widget.
*
* @since Jul 25, 2002
*/
public class MemoryPresentation
{
private static final int INTERVAL_BETWEEN_ADDRESS_AND_DATA = 2;
private static final int INTERVAL_BETWEEN_DATA_ITEMS = 1;
private static final int INTERVAL_BETWEEN_DATA_AND_ASCII = 1;
private IFormattedMemoryBlock fBlock;
private List fAddressZones;
private List fChangedZones;
private boolean fDisplayAscii = true;
/**
* Constructor for MemoryPresentation.
*/
public MemoryPresentation()
{
fAddressZones = new LinkedList();
fChangedZones = new LinkedList();
}
public IFormattedMemoryBlock getMemoryBlock()
{
return fBlock;
}
public void setMemoryBlock( IFormattedMemoryBlock block )
{
fBlock = block;
}
/**
* Returns the string that contains the textual representation of
* the memory according to this presentation.
*
* @return the string that contains the textual representation of the memory
*/
public String getText()
{
fAddressZones.clear();
IFormattedMemoryBlockRow[] rows = ( getMemoryBlock() != null ) ? getMemoryBlock().getRows() : new IFormattedMemoryBlockRow[0];
StringBuffer sb = new StringBuffer();
for ( int i = 0; i < rows.length; ++i )
{
int offset = sb.length();
sb.append( getRowText( rows[i] ) );
fAddressZones.add( new Point( offset, offset + rows[i].getAddress().getCharsNum() ) );
}
return sb.toString();
}
public String[] getText( Point[] zones )
{
return new String[0];
}
public boolean isAcceptable( char ch, int offset )
{
if ( isInAsciiArea( offset ) )
return true;
if ( isInDataArea( offset ) )
return isValidValue( ch );
return false;
}
public Point[] getAddressZones()
{
return (Point[])fAddressZones.toArray( new Point[fAddressZones.size()] );
}
public Point[] getChangedZones()
{
fChangedZones.clear();
IAddress[] changedAddresses = getChangedAddresses();
for ( int i = 0; i < changedAddresses.length; ++i )
{
int dataOffset = getDataItemOffsetByAddress( changedAddresses[i] );
if ( dataOffset != -1 )
{
fChangedZones.add( new Point( dataOffset, dataOffset + getDataItemLength() - 1 ) );
}
if ( displayASCII() )
{
int asciiOffset = getAsciiOffsetByAddress( changedAddresses[i] );
if ( asciiOffset != -1 )
{
fChangedZones.add( new Point( asciiOffset, asciiOffset ) );
}
}
}
return (Point[])fChangedZones.toArray( new Point[fChangedZones.size()] );
}
public String getStartAddress()
{
return ( fBlock != null ) ? fBlock.getRealStartAddress().toHexAddressString() : ""; //$NON-NLS-1$
}
public String getAddressExpression()
{
return ( fBlock != null ) ? fBlock.getAddressExpression() : ""; //$NON-NLS-1$
}
private String getInterval( int length )
{
char[] chars = new char[length];
Arrays.fill( chars, ' ' );
return new String( chars );
}
private String getRowText( IFormattedMemoryBlockRow row )
{
StringBuffer result = new StringBuffer( getRowLength( ) );
result.append( row.getAddress().toHexAddressString() );
result.append( getInterval( INTERVAL_BETWEEN_ADDRESS_AND_DATA ) );
String[] items = row.getData();
for ( int i = 0; i < items.length; ++i )
{
result.append( getDataItemPresentation( items[i] ) );
result.append( getInterval( INTERVAL_BETWEEN_DATA_ITEMS ) );
}
if ( displayASCII() )
{
result.append( getInterval( INTERVAL_BETWEEN_DATA_AND_ASCII ) );
result.append( row.getASCII() );
}
result.append( '\n' );
return result.toString();
}
private int getRowLength()
{
return getAddressLength() +
INTERVAL_BETWEEN_ADDRESS_AND_DATA +
(getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) * getNumberOfDataItemsInRow() +
( ( displayASCII() ) ? INTERVAL_BETWEEN_DATA_AND_ASCII +
getDataBytesPerRow() : 0 ) + 1;
}
private int getAddressLength() {
return fBlock.getRealStartAddress().getCharsNum();
}
private boolean isInAsciiArea( int offset )
{
if ( displayASCII() && getRowLength() != 0 )
{
int pos = offset % getRowLength();
int asciiColumn = getAddressLength() +
INTERVAL_BETWEEN_ADDRESS_AND_DATA +
(getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS ) * getNumberOfDataItemsInRow() +
INTERVAL_BETWEEN_DATA_AND_ASCII;
return ( pos >= asciiColumn && pos < getRowLength() - 1 );
}
return false;
}
private boolean isInDataArea( int offset )
{
if ( getRowLength() != 0 )
{
int pos = offset % getRowLength();
int dataBegin = getAddressLength() + INTERVAL_BETWEEN_ADDRESS_AND_DATA;
int dataEnd = dataBegin + ((getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS ) * getNumberOfDataItemsInRow());
if ( pos >= dataBegin && pos < dataEnd )
return isInDataItem( pos - dataBegin );
}
return false;
}
private boolean isInDataItem( int pos )
{
for ( int i = 0; i < getNumberOfDataItemsInRow(); ++i )
{
if ( pos < i * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) )
return false;
if ( pos >= i * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) &&
pos < (i * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS)) + getDataItemLength() )
return true;
}
return false;
}
private int getDataItemLength()
{
if ( getMemoryBlock() != null )
{
switch( getDataFormat() )
{
case IFormattedMemoryBlock.MEMORY_FORMAT_HEX:
return getMemoryBlock().getWordSize() * 2;
case IFormattedMemoryBlock.MEMORY_FORMAT_SIGNED_DECIMAL:
return getDecimalDataItemLength( getMemoryBlock().getWordSize(), true );
case IFormattedMemoryBlock.MEMORY_FORMAT_UNSIGNED_DECIMAL:
return getDecimalDataItemLength( getMemoryBlock().getWordSize(), false );
}
}
return 0;
}
private int getNumberOfDataItemsInRow()
{
if ( getMemoryBlock() != null )
return getMemoryBlock().getNumberOfColumns();
return 0;
}
protected boolean displayASCII()
{
if ( canDisplayAscii() )
return fDisplayAscii;
return false;
}
protected void setDisplayAscii( boolean displayAscii )
{
fDisplayAscii = displayAscii;
}
private int getDataBytesPerRow()
{
if ( getMemoryBlock() != null )
return getMemoryBlock().getNumberOfColumns() * getMemoryBlock().getWordSize();
return 0;
}
private boolean isValidValue( char ch )
{
switch( getDataFormat() )
{
case ICMemoryManager.MEMORY_FORMAT_HEX:
return isHexadecimal( ch );
case ICMemoryManager.MEMORY_FORMAT_BINARY:
case ICMemoryManager.MEMORY_FORMAT_OCTAL:
case ICMemoryManager.MEMORY_FORMAT_SIGNED_DECIMAL:
case ICMemoryManager.MEMORY_FORMAT_UNSIGNED_DECIMAL:
case -1:
default:
return false;
}
}
private boolean isHexadecimal( char ch )
{
return ( Character.isDigit( ch ) ||
( ch >= 'a' && ch <= 'f' ) ||
( ch >= 'A' && ch <= 'F' ) );
}
private int getDataFormat()
{
if ( getMemoryBlock() != null )
return getMemoryBlock().getFormat();
return IFormattedMemoryBlock.MEMORY_FORMAT_HEX;
}
private IAddress[] getChangedAddresses()
{
return ( getMemoryBlock() != null ) ? getMemoryBlock().getChangedAddresses() : new IAddress[0];
}
private int getDataItemOffsetByAddress( IAddress address )
{
if ( getMemoryBlock() != null )
{
IFormattedMemoryBlockRow[] rows = getMemoryBlock().getRows();
for ( int i = 0; i < rows.length; ++i )
{
int wordSize = getMemoryBlock().getWordSize();
int numberOfColumns = getMemoryBlock().getNumberOfColumns();
if( address.compareTo( rows[i].getAddress()) >=0 &&
address.compareTo( rows[i].getAddress().add(BigInteger.valueOf(wordSize * numberOfColumns))) <0)
{
for ( int j = 1; j <= numberOfColumns; ++j )
{
if( address.compareTo( rows[i].getAddress().add(BigInteger.valueOf( (j - 1) * wordSize))) >=0 &&
address.compareTo( rows[i].getAddress().add(BigInteger.valueOf( j * wordSize))) <0)
{
return (i * getRowLength()) + ((j - 1) * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS)) + address.getCharsNum() + INTERVAL_BETWEEN_ADDRESS_AND_DATA;
}
}
}
}
}
return -1;
}
private int getAsciiOffsetByAddress( IAddress address )
{
if ( getMemoryBlock() != null )
{
IFormattedMemoryBlockRow[] rows = getMemoryBlock().getRows();
if ( rows.length > 0 )
{
IFormattedMemoryBlockRow firstRow = rows[0];
IFormattedMemoryBlockRow lastRow = rows[rows.length - 1];
if (address.compareTo( firstRow.getAddress()) >=0 && address.compareTo( lastRow.getAddress()) <=0)
{
BigInteger asciiOffset = firstRow.getAddress().distanceTo(address);
int asciiRowlength = getMemoryBlock().getWordSize() * getMemoryBlock().getNumberOfColumns();
int numberOfRows = asciiOffset.intValue() / asciiRowlength;
int offsetInRow = asciiOffset.intValue() % asciiRowlength;
return (numberOfRows * getRowLength()) +
address.getCharsNum() + INTERVAL_BETWEEN_ADDRESS_AND_DATA +
(getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) * getMemoryBlock().getNumberOfColumns() +
INTERVAL_BETWEEN_DATA_AND_ASCII + offsetInRow;
}
}
}
return -1;
}
protected boolean canDisplayAscii()
{
if ( getMemoryBlock() != null )
return getMemoryBlock().displayASCII();
return false;
}
protected int getDataItemIndex( int offset )
{
int row = offset / getRowLength();
int pos = offset % getRowLength() - getAddressLength() - INTERVAL_BETWEEN_ADDRESS_AND_DATA;
for ( int i = 0; i < getNumberOfDataItemsInRow(); ++i )
{
if ( pos < i * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) )
return -1;
if ( pos >= i * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) &&
pos < (i * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS)) + getDataItemLength() )
return i + (row * getNumberOfDataItemsInRow());
}
if ( displayASCII() && pos >= getNumberOfDataItemsInRow() * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) + INTERVAL_BETWEEN_DATA_AND_ASCII )
{
return ((pos - ((getNumberOfDataItemsInRow() * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) + INTERVAL_BETWEEN_DATA_AND_ASCII))) * 2 / getDataItemLength()) + row * getNumberOfDataItemsInRow();
}
return -1;
}
private int getDataItemOffset( int index )
{
int row = index / getNumberOfDataItemsInRow();
int pos = index % getNumberOfDataItemsInRow();
return row * getRowLength() +
getAddressLength() + INTERVAL_BETWEEN_ADDRESS_AND_DATA +
pos * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS);
}
private char[] getDataItemChars( int index )
{
if ( getMemoryBlock() != null )
{
int rowNumber = index / getMemoryBlock().getNumberOfColumns();
int pos = index % getMemoryBlock().getNumberOfColumns();
IFormattedMemoryBlockRow[] rows = getMemoryBlock().getRows();
if ( rowNumber < rows.length )
{
String[] data = rows[rowNumber].getData();
if ( pos < data.length )
{
return data[pos].toCharArray();
}
}
}
return new char[0];
}
private int getOffsetInDataItem( int offset, int index )
{
if ( isInDataArea( offset ) )
{
return offset - getDataItemOffset( index );
}
return -1;
}
public void dispose()
{
if ( fAddressZones != null )
{
fAddressZones.clear();
}
if ( fChangedZones != null )
{
fChangedZones.clear();
}
}
private String getDataItemPresentation( String item )
{
switch( getDataFormat() )
{
case IFormattedMemoryBlock.MEMORY_FORMAT_HEX:
return convertToHex( getWordSize(), item );
case IFormattedMemoryBlock.MEMORY_FORMAT_SIGNED_DECIMAL:
return convertToDecimal( getWordSize(), item, true );
case IFormattedMemoryBlock.MEMORY_FORMAT_UNSIGNED_DECIMAL:
return convertToDecimal( getWordSize(), item, false );
}
return ""; //$NON-NLS-1$
}
private int getDecimalDataItemLength( int wordSize, boolean signed )
{
switch( wordSize )
{
case IFormattedMemoryBlock.MEMORY_SIZE_BYTE:
return ( signed ) ? 4 : 3;
case IFormattedMemoryBlock.MEMORY_SIZE_HALF_WORD:
return ( signed ) ? 6 : 5;
case IFormattedMemoryBlock.MEMORY_SIZE_WORD:
return ( signed ) ? 11 : 10;
}
return 0;
}
private int getWordSize()
{
if ( getMemoryBlock() != null )
{
return getMemoryBlock().getWordSize();
}
return 0;
}
/**
* Performs endianness swap (in a brainless, but right most of the time) fashion.
* @param item
* @return
*/
private String convertToHex( int wordsize, String item )
{
if( !getMemoryBlock().isLittleEndian() || wordsize == IFormattedMemoryBlock.MEMORY_SIZE_BYTE )
return item;
int length = item.length();
StringBuffer ret = new StringBuffer( length );
for( int i = length - 2 ; i >= 0 ; i -= 2 )
{
ret.append( item.substring( i, i + 2 ) );
}
return ret.toString();
}
private String convertToDecimal( int wordSize, String item, boolean signed )
{
String result = ""; //$NON-NLS-1$
boolean le = getMemoryBlock().isLittleEndian();
switch( wordSize )
{
case IFormattedMemoryBlock.MEMORY_SIZE_BYTE:
result = Long.toString( ( signed ) ? CDebugUtils.toByte( item.toCharArray(), le ) : CDebugUtils.toUnsignedByte( item.toCharArray(), le ) );
break;
case IFormattedMemoryBlock.MEMORY_SIZE_HALF_WORD:
result = Long.toString( ( signed ) ? CDebugUtils.toShort( item.toCharArray(), le ) : CDebugUtils.toUnsignedShort( item.toCharArray(), le ) );
break;
case IFormattedMemoryBlock.MEMORY_SIZE_WORD:
result = Long.toString( ( signed ) ? CDebugUtils.toInt( item.toCharArray(), le ) : CDebugUtils.toUnsignedInt( item.toCharArray(), le ) );
break;
}
return CDebugUtils.prependString( result, getDataItemLength(), ' ' );
}
protected boolean isStartAddressChanged()
{
if ( getMemoryBlock() != null )
{
return getMemoryBlock().isStartAddressChanged();
}
return false;
}
protected String getNewItemValue( int offset, char newChar )
{
if ( getMemoryBlock() != null )
{
int index = getDataItemIndex(offset );
if ( index != -1 )
{
char[] chars = getDataItemChars( index );
if ( isInDataArea( offset ) )
{
int charIndex = getOffsetInDataItem(offset, index );
chars[charIndex] = newChar;
}
if ( isInAsciiArea( offset ) )
{
chars = CDebugUtils.getByteText( (byte)newChar );
}
return new String( chars );
}
}
return null;
}
protected void setItemValue( int offset, char ch )
{
if ( getMemoryBlock() != null )
{
int index = getDataItemIndex( offset );
if ( index != -1 )
{
String newValue = getNewItemValue(offset, ch );
if ( newValue != null )
{
try
{
getMemoryBlock().setItemValue( index, newValue );
return;
}
catch( DebugException e )
{
Display.getDefault().beep();
}
}
}
}
Display.getDefault().beep();
}
}

View file

@ -1,303 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.memory;
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ExtendedModifyEvent;
import org.eclipse.swt.custom.ExtendedModifyListener;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
/**
*
* A widget that displays the textual content of the memory block.
*
* @since Jul 25, 2002
*/
public class MemoryText
{
private StyledText fText = null;
private MemoryPresentation fPresentation = null;
private boolean fUpdating = false;
/**
* Constructor for MemoryText.
*
* @param parent
* @param style
*/
public MemoryText( Composite parent,
int style,
MemoryPresentation presentation )
{
fText = new StyledText( parent, style );
fText.setLayoutData( new GridData( GridData.FILL_BOTH ) );
fPresentation = presentation;
initialize();
}
private void initialize()
{
// Switch to overwrite mode
fText.invokeAction( SWT.INSERT );
// Unmap INSERT key action to preserve the overwrite mode
fText.setKeyBinding( SWT.INSERT, SWT.NULL );
fText.addExtendedModifyListener(
new ExtendedModifyListener()
{
public void modifyText( ExtendedModifyEvent e )
{
handleExtendedModify( e );
}
} );
fText.addVerifyKeyListener(
new VerifyKeyListener()
{
public void verifyKey( VerifyEvent e )
{
handleVerifyKey( e );
}
} );
refresh();
}
protected void handleExtendedModify( ExtendedModifyEvent event )
{
if ( fUpdating )
return;
if ( event.length != 1 )
return;
int caretOffset = fText.getCaretOffset();
fText.getCaret().setVisible( false );
char ch = fText.getText().charAt( event.start );
restoreText( event.start, event.length, event.replacedText );
fPresentation.setItemValue( event.start, ch );
fText.setCaretOffset( caretOffset );
fText.getCaret().setVisible( true );
}
public void refresh()
{
int offset = fText.getCaretOffset();
fText.getCaret().setVisible( false );
fText.setFont( new Font( fText.getDisplay(), getFontData() ) );
fText.setBackground( getBackgroundColor() );
fText.setForeground( getForegroundColor() );
fText.setText( fPresentation.getText() );
Point[] zones = fPresentation.getChangedZones();
for ( int i = 0; i < zones.length; ++i )
{
fText.setStyleRange( new StyleRange( zones[i].x,
zones[i].y - zones[i].x + 1,
getChangedColor(),
getBackgroundColor() ) );
}
zones = fPresentation.getAddressZones();
boolean isStartAddressChanged = fPresentation.isStartAddressChanged();
for ( int i = 0; i < zones.length; ++i )
{
fText.setStyleRange( new StyleRange( zones[i].x,
zones[i].y - zones[i].x + 1,
( isStartAddressChanged ) ? getChangedColor() : getAddressColor(),
getBackgroundColor() ) );
}
fText.redraw();
fText.setCaretOffset( offset );
fText.getCaret().setVisible( true );
}
protected void handleVerifyKey( VerifyEvent event )
{
if ( event.character == SWT.LF ||
event.character == SWT.CR ||
event.character == SWT.BS ||
event.character == SWT.DEL )
{
event.doit = false;
return;
}
if ( Character.isISOControl( event.character ) )
return;
if ( getSelectionCount() != 0 )
{
event.doit = false;
return;
}
if ( !fPresentation.isAcceptable( event.character, fText.getCaretOffset() ) )
event.doit = false;
}
private FontData getFontData()
{
IPreferenceStore pstore = CDebugUIPlugin.getDefault().getPreferenceStore();
FontData fontData = PreferenceConverter.getFontData( pstore, ICDebugPreferenceConstants.MEMORY_FONT );
return fontData;
}
private Color getForegroundColor()
{
return CDebugUIPlugin.getPreferenceColor( ICDebugPreferenceConstants.MEMORY_FOREGROUND_RGB );
}
private Color getBackgroundColor()
{
return CDebugUIPlugin.getPreferenceColor( ICDebugPreferenceConstants.MEMORY_BACKGROUND_RGB );
}
private Color getAddressColor()
{
return CDebugUIPlugin.getPreferenceColor( ICDebugPreferenceConstants.MEMORY_ADDRESS_RGB );
}
private Color getChangedColor()
{
return CDebugUIPlugin.getPreferenceColor( ICDebugPreferenceConstants.MEMORY_CHANGED_RGB );
}
public void changeFont()
{
Font oldFont = fText.getFont();
fText.setFont( new Font( fText.getDisplay(), getFontData() ) );
oldFont.dispose();
}
public void setForegroundColor()
{
fText.setForeground( CDebugUIPlugin.getPreferenceColor( ICDebugPreferenceConstants.MEMORY_FOREGROUND_RGB ) );
}
public void setBackgroundColor()
{
fText.setBackground( CDebugUIPlugin.getPreferenceColor( ICDebugPreferenceConstants.MEMORY_BACKGROUND_RGB ) );
}
public void setChangedColor()
{
Point[] zones = fPresentation.getChangedZones();
for ( int i = 0; i < zones.length; ++i )
{
fText.setStyleRange( new StyleRange( zones[i].x,
zones[i].y - zones[i].x + 1,
getChangedColor(),
getBackgroundColor() ) );
}
}
public void setAddressColor()
{
Point[] zones = fPresentation.getAddressZones();
for ( int i = 0; i < zones.length; ++i )
{
fText.setStyleRange( new StyleRange( zones[i].x,
zones[i].y - zones[i].x + 1,
getAddressColor(),
getBackgroundColor() ) );
}
}
public void setDirtyColor()
{
/*
Point[] zones = fPresentation.getDirtyZones();
for ( int i = 0; i < zones.length; ++i )
{
fText.setStyleRange( new StyleRange( zones[i].x,
zones[i].y - zones[i].x + 1,
getDirtyColor(),
getBackgroundColor() ) );
}
*/
}
protected void setEditable( boolean editable )
{
fText.setEditable( editable );
}
protected int getSelectionCount()
{
return fText.getSelectionCount();
}
protected Control getControl()
{
return fText;
}
/*
protected void update( TextReplacement[] trs )
{
fUpdating = true;
for ( int i = 0; i < trs.length; ++i )
{
fText.replaceTextRange( trs[i].getStart(),
trs[i].getText().length(),
trs[i].getText() );
fText.setStyleRange( new StyleRange( trs[i].getStart(),
trs[i].getText().length(),
getDirtyColor(),
getBackgroundColor() ) );
fText.redrawRange( trs[i].getStart(), trs[i].getText().length(), false );
}
saveChanges();
fUpdating = false;
updateTitle();
}
*/
private void restoreText( int start, int length, String text )
{
fUpdating = true;
fText.replaceTextRange( start, length, text );
fUpdating = false;
}
/*
private void updateTitle()
{
if ( fText.getParent() instanceof MemoryControlArea )
{
String title = ((MemoryControlArea)fText.getParent()).getTitle();
if ( title.charAt( 0 ) == '*' )
{
title = title.substring( 1 );
}
if ( fPresentation.isDirty() )
{
title = '*' + title;
}
((MemoryControlArea)fText.getParent()).setTitle( title );
}
}
private void saveChanges()
{
if ( fText.getParent() instanceof MemoryControlArea )
{
((MemoryControlArea)fText.getParent()).saveChanges();
}
}
*/
}

View file

@ -1,378 +0,0 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.memory;
import org.eclipse.cdt.debug.core.ICMemoryManager;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.actions.AutoRefreshMemoryAction;
import org.eclipse.cdt.debug.internal.ui.actions.ClearMemoryAction;
import org.eclipse.cdt.debug.internal.ui.actions.MemoryActionSelectionGroup;
import org.eclipse.cdt.debug.internal.ui.actions.MemoryFormatAction;
import org.eclipse.cdt.debug.internal.ui.actions.MemoryNumberOfColumnAction;
import org.eclipse.cdt.debug.internal.ui.actions.MemorySizeAction;
import org.eclipse.cdt.debug.internal.ui.actions.RefreshMemoryAction;
import org.eclipse.cdt.debug.internal.ui.actions.ShowAsciiAction;
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler;
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandlerView;
import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.IUpdate;
/**
* This view shows the content of the memory blocks associated with the selected debug target.
*/
public class MemoryView extends AbstractDebugEventHandlerView implements ISelectionListener, IPropertyChangeListener, IDebugExceptionHandler {
private IDebugModelPresentation fModelPresentation = null;
private MemoryActionSelectionGroup fMemoryFormatGroup = null;
private MemoryActionSelectionGroup fMemorySizeGroup = null;
private MemoryActionSelectionGroup fMemoryNumberOfColumnsGroup = null;
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(Composite)
*/
protected Viewer createViewer( Composite parent ) {
CDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( this );
final MemoryViewer viewer = new MemoryViewer( parent, this );
viewer.setContentProvider( createContentProvider() );
viewer.setLabelProvider( getModelPresentation() );
getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
setEventHandler( createEventHandler( viewer ) );
return viewer;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.AbstractDebugView#createActions()
*/
protected void createActions() {
IAction action = null;
action = new MemoryViewAction( this, ITextOperationTarget.CUT );
String cutStr = MemoryViewMessages.getString( "MemoryView.0" ); //$NON-NLS-1$
action.setText( cutStr );
action.setToolTipText( cutStr );
action.setDescription( cutStr );
setGlobalAction( ITextEditorActionConstants.CUT, (MemoryViewAction)action );
action = new MemoryViewAction( this, ITextOperationTarget.COPY );
String copyStr = MemoryViewMessages.getString( "MemoryView.1" ); //$NON-NLS-1$
action.setText( copyStr );
action.setToolTipText( copyStr );
action.setDescription( copyStr );
setGlobalAction( ITextEditorActionConstants.COPY, (MemoryViewAction)action );
action = new MemoryViewAction( this, ITextOperationTarget.PASTE );
String pasteStr = MemoryViewMessages.getString( "MemoryView.2" ); //$NON-NLS-1$
action.setText( pasteStr );
action.setToolTipText( pasteStr );
action.setDescription( pasteStr );
setGlobalAction( ITextEditorActionConstants.PASTE, (MemoryViewAction)action );
action = new MemoryViewAction( this, ITextOperationTarget.SELECT_ALL );
String selectAllStr = MemoryViewMessages.getString( "MemoryView.3" ); //$NON-NLS-1$
action.setText( selectAllStr );
action.setToolTipText( selectAllStr );
action.setDescription( selectAllStr );
setGlobalAction( ITextEditorActionConstants.SELECT_ALL, (MemoryViewAction)action );
action = new RefreshMemoryAction( (MemoryViewer)getViewer() );
action.setEnabled( false );
setAction( "RefreshMemory", action ); //$NON-NLS-1$
add( (RefreshMemoryAction)action );
action = new AutoRefreshMemoryAction( (MemoryViewer)getViewer() );
action.setEnabled( false );
action.setChecked( CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_MEMORY_AUTO_REFRESH ) );
setAction( "AutoRefreshMemory", action ); //$NON-NLS-1$
add( (AutoRefreshMemoryAction)action );
action = new ClearMemoryAction( (MemoryViewer)getViewer() );
action.setEnabled( false );
setAction( "ClearMemory", action ); //$NON-NLS-1$
add( (ClearMemoryAction)action );
action = new ShowAsciiAction( (MemoryViewer)getViewer() );
action.setEnabled( false );
action.setChecked( CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_MEMORY_SHOW_ASCII ) );
setAction( "ShowAscii", action ); //$NON-NLS-1$
add( (ShowAsciiAction)action );
fMemoryFormatGroup = new MemoryActionSelectionGroup();
createFormatActionGroup( fMemoryFormatGroup );
fMemorySizeGroup = new MemoryActionSelectionGroup();
createSizeActionGroup( fMemorySizeGroup );
fMemoryNumberOfColumnsGroup = new MemoryActionSelectionGroup();
createNumberOfColumnsActionGroup( fMemoryNumberOfColumnsGroup );
// set initial content here, as viewer has to be set
setInitialContent();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.AbstractDebugView#getHelpContextId()
*/
protected String getHelpContextId() {
return ICDebugHelpContextIds.MEMORY_VIEW;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.AbstractDebugView#fillContextMenu(IMenuManager)
*/
protected void fillContextMenu( IMenuManager menu ) {
menu.add( new Separator( ICDebugUIConstants.EMPTY_MEMORY_GROUP ) );
menu.add( new Separator( ICDebugUIConstants.MEMORY_GROUP ) );
menu.add( new Separator( ICDebugUIConstants.EMPTY_FORMAT_GROUP ) );
menu.add( new Separator( ICDebugUIConstants.FORMAT_GROUP ) );
menu.add( new Separator( IDebugUIConstants.EMPTY_RENDER_GROUP ) );
menu.add( new Separator( IDebugUIConstants.RENDER_GROUP ) );
menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
menu.appendToGroup( ICDebugUIConstants.MEMORY_GROUP, getAction( "AutoRefreshMemory" ) ); //$NON-NLS-1$
menu.appendToGroup( ICDebugUIConstants.MEMORY_GROUP, getAction( "RefreshMemory" ) ); //$NON-NLS-1$
menu.appendToGroup( ICDebugUIConstants.MEMORY_GROUP, getAction( "ClearMemory" ) ); //$NON-NLS-1$
MenuManager subMenu = new MenuManager( MemoryViewMessages.getString( "MemoryView.4" ) ); //$NON-NLS-1$
{
IAction[] actions = fMemoryFormatGroup.getActions();
for( int i = 0; i < actions.length; ++i ) {
subMenu.add( actions[i] );
}
}
menu.appendToGroup( ICDebugUIConstants.FORMAT_GROUP, subMenu );
subMenu = new MenuManager( MemoryViewMessages.getString( "MemoryView.5" ) ); //$NON-NLS-1$
{
IAction[] actions = fMemorySizeGroup.getActions();
for( int i = 0; i < actions.length; ++i ) {
subMenu.add( actions[i] );
}
}
menu.appendToGroup( ICDebugUIConstants.FORMAT_GROUP, subMenu );
subMenu = new MenuManager( MemoryViewMessages.getString( "MemoryView.6" ) ); //$NON-NLS-1$
{
IAction[] actions = fMemoryNumberOfColumnsGroup.getActions();
for( int i = 0; i < actions.length; ++i ) {
subMenu.add( actions[i] );
}
}
menu.appendToGroup( ICDebugUIConstants.FORMAT_GROUP, subMenu );
menu.appendToGroup( IDebugUIConstants.RENDER_GROUP, getAction( "ShowAscii" ) ); //$NON-NLS-1$
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.AbstractDebugView#configureToolBar(IToolBarManager)
*/
protected void configureToolBar( IToolBarManager tbm ) {
tbm.add( new Separator( this.getClass().getName() ) );
tbm.add( new Separator( ICDebugUIConstants.MEMORY_GROUP ) );
tbm.add( getAction( "AutoRefreshMemory" ) ); //$NON-NLS-1$
tbm.add( getAction( "RefreshMemory" ) ); //$NON-NLS-1$
tbm.add( getAction( "ClearMemory" ) ); //$NON-NLS-1$
tbm.add( new Separator( IDebugUIConstants.RENDER_GROUP ) );
tbm.add( getAction( "ShowAscii" ) ); //$NON-NLS-1$
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
*/
public void selectionChanged( IWorkbenchPart part, ISelection selection ) {
if ( selection instanceof IStructuredSelection ) {
setViewerInput( (IStructuredSelection)selection );
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(PropertyChangeEvent)
*/
public void propertyChange( PropertyChangeEvent event ) {
((MemoryViewer)getViewer()).propertyChange( event );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler#handleException(DebugException)
*/
public void handleException( DebugException e ) {
}
/**
* Remove myself as a selection listener and preference change listener.
*
* @see IWorkbenchPart#dispose()
*/
public void dispose() {
removeActionGroup( fMemoryFormatGroup );
fMemoryFormatGroup.dispose();
removeActionGroup( fMemorySizeGroup );
fMemorySizeGroup.dispose();
removeActionGroup( fMemoryNumberOfColumnsGroup );
fMemoryNumberOfColumnsGroup.dispose();
remove( (ShowAsciiAction)getAction( "ShowAscii" ) ); //$NON-NLS-1$
remove( (ClearMemoryAction)getAction( "ClearMemory" ) ); //$NON-NLS-1$
remove( (RefreshMemoryAction)getAction( "RefreshMemory" ) ); //$NON-NLS-1$
remove( (AutoRefreshMemoryAction)getAction( "AutoRefreshMemory" ) ); //$NON-NLS-1$
getSite().getPage().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
CDebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener( this );
super.dispose();
}
protected void setViewerInput( IStructuredSelection ssel ) {
ICMemoryManager mm = null;
if ( ssel != null && ssel.size() == 1 ) {
Object input = ssel.getFirstElement();
if ( input instanceof IDebugElement ) {
mm = (ICMemoryManager)((IDebugElement)input).getDebugTarget().getAdapter( ICMemoryManager.class );
}
}
Object current = getViewer().getInput();
if ( current != null && current.equals( mm ) ) {
return;
}
showViewer();
getViewer().setInput( mm );
updateObjects();
}
private IContentProvider createContentProvider() {
return new MemoryViewContentProvider();
}
private IDebugModelPresentation getModelPresentation() {
if ( fModelPresentation == null ) {
fModelPresentation = CDebugUIPlugin.getDebugModelPresentation();
}
return fModelPresentation;
}
/**
* Creates this view's event handler.
*
* @param viewer
* the viewer associated with this view
* @return an event handler
*/
protected AbstractDebugEventHandler createEventHandler( Viewer viewer ) {
return new MemoryViewEventHandler( this );
}
/**
* Initializes the viewer input on creation
*/
protected void setInitialContent() {
ISelection selection = getSite().getPage().getSelection( IDebugUIConstants.ID_DEBUG_VIEW );
if ( selection instanceof IStructuredSelection && !selection.isEmpty() ) {
setViewerInput( (IStructuredSelection)selection );
}
else {
setViewerInput( null );
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.AbstractDebugView#createContextMenu(Control)
*/
protected void createContextMenu( Control menuControl ) {
CTabItem[] items = ((MemoryViewer)getViewer()).getTabFolder().getItems();
for( int i = 0; i < items.length; ++i ) {
super.createContextMenu( ((MemoryControlArea)items[i].getControl()).getMemoryText().getControl() );
}
}
private void createFormatActionGroup( MemoryActionSelectionGroup group ) {
int[] formats = new int[]{ IFormattedMemoryBlock.MEMORY_FORMAT_HEX, IFormattedMemoryBlock.MEMORY_FORMAT_SIGNED_DECIMAL, IFormattedMemoryBlock.MEMORY_FORMAT_UNSIGNED_DECIMAL };
for( int i = 0; i < formats.length; ++i ) {
MemoryFormatAction action = new MemoryFormatAction( group, (MemoryViewer)getViewer(), formats[i] );
action.setEnabled( false );
setAction( action.getActionId(), action ); //$NON-NLS-1$
add( action );
group.addAction( action );
}
}
private void createSizeActionGroup( MemoryActionSelectionGroup group ) {
int[] ids = new int[]{ IFormattedMemoryBlock.MEMORY_SIZE_BYTE, IFormattedMemoryBlock.MEMORY_SIZE_HALF_WORD, IFormattedMemoryBlock.MEMORY_SIZE_WORD, IFormattedMemoryBlock.MEMORY_SIZE_DOUBLE_WORD };
for( int i = 0; i < ids.length; ++i ) {
MemorySizeAction action = new MemorySizeAction( group, (MemoryViewer)getViewer(), ids[i] );
action.setEnabled( false );
setAction( action.getActionId(), action ); //$NON-NLS-1$
add( action );
group.addAction( action );
}
}
private void createNumberOfColumnsActionGroup( MemoryActionSelectionGroup group ) {
int[] nocs = new int[]{ IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_1, IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_2, IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_4, IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_8, IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_16 };
for( int i = 0; i < nocs.length; ++i ) {
MemoryNumberOfColumnAction action = new MemoryNumberOfColumnAction( group, (MemoryViewer)getViewer(), nocs[i] );
action.setEnabled( false );
setAction( action.getActionId(), action ); //$NON-NLS-1$
add( action );
group.addAction( action );
}
}
private void removeActionGroup( MemoryActionSelectionGroup group ) {
IAction[] actions = group.getActions();
for( int i = 0; i < actions.length; ++i ) {
remove( (IUpdate)actions[i] );
}
}
private void setGlobalAction( String actionId, MemoryViewAction action ) {
add( action );
getViewSite().getActionBars().setGlobalActionHandler( actionId, action );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter( Class adapter ) {
if ( ITextOperationTarget.class.equals( adapter ) ) {
return ((MemoryViewer)getViewer()).getTextOperationTarget();
}
return super.getAdapter( adapter );
}
}

View file

@ -1,86 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.memory;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.ui.texteditor.IUpdate;
/**
* Enter type comment.
*
* @since Jun 12, 2003
*/
public class MemoryViewAction extends Action implements IUpdate
{
/** The text operation code */
private int fOperationCode = -1;
/** The text operation target */
private ITextOperationTarget fOperationTarget;
/** The text operation target provider */
private IAdaptable fTargetProvider;
public MemoryViewAction( ITextOperationTarget target, int operationCode )
{
super();
fOperationCode = operationCode;
fOperationTarget = target;
update();
}
public MemoryViewAction( IAdaptable targetProvider, int operationCode )
{
super();
fTargetProvider = targetProvider;
fOperationCode = operationCode;
update();
}
/**
* The <code>TextOperationAction</code> implementation of this
* <code>IUpdate</code> method discovers the operation through the current
* editor's <code>ITextOperationTarget</code> adapter, and sets the
* enabled state accordingly.
*/
public void update()
{
if ( fTargetProvider != null && fOperationCode != -1 )
{
ITextOperationTarget target = getTextOperationTarget();
boolean isEnabled = ( target != null && target.canDoOperation( fOperationCode ) );
setEnabled( isEnabled );
}
}
/**
* The <code>TextOperationAction</code> implementation of this
* <code>IAction</code> method runs the operation with the current
* operation code.
*/
public void run()
{
ITextOperationTarget target = getTextOperationTarget();
if ( fOperationCode != -1 && target != null )
target.doOperation( fOperationCode );
}
private ITextOperationTarget getTextOperationTarget()
{
if ( fOperationTarget == null )
{
if ( fTargetProvider != null )
return (ITextOperationTarget)fTargetProvider.getAdapter( ITextOperationTarget.class );
}
return fOperationTarget;
}
}

View file

@ -1,44 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.memory;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.Viewer;
/**
*
* Enter type comment.
*
* @since Jul 29, 2002
*/
public class MemoryViewContentProvider implements IContentProvider
{
/**
* Constructor for MemoryViewContentProvider.
*/
public MemoryViewContentProvider()
{
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose()
{
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(Viewer, Object, Object)
*/
public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
{
}
}

View file

@ -1,94 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.memory;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.ui.AbstractDebugView;
/**
*
* Enter type comment.
*
* @since Jul 29, 2002
*/
public class MemoryViewEventHandler extends AbstractDebugEventHandler
{
/**
* Constructor for MemoryViewEventHandler.
* @param view
*/
public MemoryViewEventHandler( AbstractDebugView view )
{
super( view );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler#doHandleDebugEvents(DebugEvent[])
*/
protected void doHandleDebugEvents( DebugEvent[] events )
{
for( int i = 0; i < events.length; i++ )
{
DebugEvent event = events[i];
switch( event.getKind() )
{
case DebugEvent.CHANGE:
if ( event.getSource() instanceof IFormattedMemoryBlock && event.getDetail() == DebugEvent.CONTENT )
{
refresh( event.getSource() );
getView().updateObjects();
return;
}
break;
case DebugEvent.TERMINATE:
if ( event.getSource() instanceof IFormattedMemoryBlock )
{
remove( event.getSource() );
getView().updateObjects();
return;
}
break;
}
}
}
/**
* Refresh the given element in the viewer - must be called in UI thread.
*/
protected void refresh( Object element )
{
if ( isAvailable() )
{
getView().showViewer();
((MemoryViewer)getViewer()).refresh( element );
}
}
/**
* Refresh the viewer - must be called in UI thread.
*/
public void refresh()
{
if ( isAvailable() )
{
getView().showViewer();
getViewer().refresh();
}
}
protected void remove( Object element )
{
((MemoryViewer)getViewer()).remove( element );
}
}

View file

@ -1,33 +0,0 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.memory;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class MemoryViewMessages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.views.memory.MemoryViewMessages";//$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
private MemoryViewMessages() {
}
public static String getString( String key ) {
try {
return RESOURCE_BUNDLE.getString( key );
}
catch( MissingResourceException e ) {
return '!' + key + '!';
}
}
}

View file

@ -1,26 +0,0 @@
###############################################################################
# Copyright (c) 2003, 2004 QNX Software Systems and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Common Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/cpl-v10.html
#
# Contributors:
# QNX Software Systems - initial API and implementation
###############################################################################
MemoryViewer.0=Memory
MemoryView.0=Cut
MemoryView.1=Copy
MemoryView.2=Paste
MemoryView.3=Select All
MemoryView.4=Format
MemoryView.5=Memory Unit Size
MemoryView.6=Number Of Columns
MemoryControlArea.0=Address:
MemoryControlArea.1=Evaluate
MemoryControlArea.2=Evaluate expression to address
MemoryControlArea.3=Unable to get the memory block.
MemoryControlArea.4=Memory View
MemoryControlArea.7=Unable to refresh the memory block.
MemoryControlArea.8=Unable to get the memory block.

View file

@ -1,256 +0,0 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.memory;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
import org.eclipse.debug.core.DebugException;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ContentViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
/**
* The viewer of the Memory view.
*/
public class MemoryViewer extends ContentViewer {
static final private int NUMBER_OF_TABS = 4;
protected MemoryView fView = null;
protected Composite fParent = null;
protected CTabFolder fTabFolder = null;
private Composite fControl = null;
private MemoryControlArea[] fMemoryControlAreas = new MemoryControlArea[NUMBER_OF_TABS];
/**
* Constructor for MemoryViewer.
*/
public MemoryViewer( Composite parent, MemoryView view ) {
super();
fParent = parent;
fView = view;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.Viewer#getControl()
*/
public Control getControl() {
if ( fControl == null ) {
fControl = new Composite( fParent, SWT.NONE );
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
fControl.setLayout( layout );
fControl.setLayoutData( new GridData( GridData.FILL_BOTH ) );
fTabFolder = new CTabFolder( fControl, SWT.TOP );
fTabFolder.setLayoutData( new GridData( GridData.FILL_BOTH | GridData.GRAB_VERTICAL ) );
for( int i = 0; i < NUMBER_OF_TABS; ++i ) {
CTabItem tabItem = new CTabItem( fTabFolder, SWT.NONE );
tabItem.setText( MemoryViewMessages.getString( "MemoryViewer.0" ) + ' ' + (i + 1) ); //$NON-NLS-1$
fMemoryControlAreas[i] = new MemoryControlArea( fTabFolder, SWT.NONE, i, fView );
tabItem.setControl( fMemoryControlAreas[i] );
}
fTabFolder.addSelectionListener( new SelectionListener() {
public void widgetSelected( SelectionEvent e ) {
fView.updateObjects();
}
public void widgetDefaultSelected( SelectionEvent e ) {
fView.updateObjects();
}
} );
fTabFolder.setSelection( 0 );
}
return fControl;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
*/
public ISelection getSelection() {
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.Viewer#refresh()
*/
public void refresh() {
if ( fTabFolder != null ) {
CTabItem[] tabItems = fTabFolder.getItems();
for( int i = 0; i < tabItems.length; ++i )
if ( tabItems[i].getControl() instanceof MemoryControlArea )
((MemoryControlArea)tabItems[i].getControl()).refresh();
}
}
public void refresh( Object element ) {
if ( element instanceof IFormattedMemoryBlock ) {
MemoryControlArea mca = getMemoryControlArea( (IFormattedMemoryBlock)element );
if ( mca != null ) {
mca.refresh();
}
}
}
public void remove( Object element ) {
if ( element instanceof IFormattedMemoryBlock ) {
MemoryControlArea mca = getMemoryControlArea( (IFormattedMemoryBlock)element );
if ( mca != null ) {
mca.clear();
}
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.Viewer#setSelection(ISelection, boolean)
*/
public void setSelection( ISelection selection, boolean reveal ) {
}
public void propertyChange( PropertyChangeEvent event ) {
if ( fTabFolder != null ) {
CTabItem[] tabItems = fTabFolder.getItems();
for( int i = 0; i < tabItems.length; ++i )
if ( tabItems[i].getControl() instanceof MemoryControlArea )
((MemoryControlArea)tabItems[i].getControl()).propertyChange( event );
}
}
protected void inputChanged( Object input, Object oldInput ) {
for( int i = 0; i < fMemoryControlAreas.length; ++i )
fMemoryControlAreas[i].setInput( input );
}
protected CTabFolder getTabFolder() {
return fTabFolder;
}
private MemoryControlArea getMemoryControlArea( IFormattedMemoryBlock block ) {
CTabItem[] tabItems = fTabFolder.getItems();
for( int i = 0; i < tabItems.length; ++i ) {
if ( tabItems[i].getControl() instanceof MemoryControlArea && block != null && block.equals( ((MemoryControlArea)tabItems[i].getControl()).getMemoryBlock() ) ) {
return (MemoryControlArea)tabItems[i].getControl();
}
}
return null;
}
public boolean canChangeFormat( int format ) {
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
return (block != null && block.canChangeFormat( format ));
}
public boolean canUpdate() {
return (((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock() != null);
}
public boolean canSave() {
return (((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock() != null);
}
public boolean isFrozen() {
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
return (block != null) ? block.isFrozen() : true;
}
public void setFrozen( boolean frozen ) {
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
if ( block != null ) {
block.setFrozen( frozen );
}
}
public void clear() {
((MemoryControlArea)fTabFolder.getSelection().getControl()).clear();
}
public void refreshMemoryBlock() {
((MemoryControlArea)fTabFolder.getSelection().getControl()).refreshMemoryBlock();
}
public boolean showAscii() {
return ((MemoryControlArea)fTabFolder.getSelection().getControl()).getPresentation().displayASCII();
}
public void setShowAscii( boolean show ) {
((MemoryControlArea)fTabFolder.getSelection().getControl()).getPresentation().setDisplayAscii( show );
((MemoryControlArea)fTabFolder.getSelection().getControl()).refresh();
}
public boolean canShowAscii() {
return ((MemoryControlArea)fTabFolder.getSelection().getControl()).getPresentation().canDisplayAscii();
}
public int getCurrentFormat() {
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
return (block != null) ? block.getFormat() : 0;
}
public void setFormat( int format ) throws DebugException {
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
if ( block != null ) {
block.reformat( format, block.getWordSize(), block.getNumberOfRows(), block.getNumberOfColumns() );
((MemoryControlArea)fTabFolder.getSelection().getControl()).refresh();
}
}
public int getCurrentWordSize() {
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
return (block != null) ? block.getWordSize() : 0;
}
public void setWordSize( int size ) throws DebugException {
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
if ( block != null ) {
block.reformat( block.getFormat(), size, block.getNumberOfRows(), block.getNumberOfColumns() );
((MemoryControlArea)fTabFolder.getSelection().getControl()).refresh();
}
}
public int getCurrentNumberOfColumns() {
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
return (block != null) ? block.getNumberOfColumns() : 0;
}
public void setNumberOfColumns( int numberOfColumns ) throws DebugException {
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
if ( block != null ) {
block.reformat( block.getFormat(), block.getWordSize(), block.getNumberOfRows(), numberOfColumns );
((MemoryControlArea)fTabFolder.getSelection().getControl()).refresh();
}
}
protected ITextOperationTarget getTextOperationTarget() {
return (MemoryControlArea)fTabFolder.getSelection().getControl();
}
}