Eclipse Platform
Release 3.1

org.eclipse.debug.ui.memory
Class AbstractTableRendering

java.lang.Object
  extended byorg.eclipse.core.runtime.PlatformObject
      extended byorg.eclipse.debug.ui.memory.AbstractMemoryRendering
          extended byorg.eclipse.debug.ui.memory.AbstractTableRendering
All Implemented Interfaces:
EventListener, IAdaptable, IMemoryRendering, IPropertyChangeListener
Direct Known Subclasses:
AbstractTextRendering

public abstract class AbstractTableRendering
extends AbstractMemoryRendering
implements IPropertyChangeListener

Abstract implementation of a table rendering.

Clients should subclass from this class if they wish to provide a table rendering.

The label of the rendering is constructed by retrieving the expression from IMemoryBlockExtension. For IMemoryBlock, the label is constructed using the memory block's start address. This rendering manages the change states of its memory bytes if the memory block does not opt to manage the change states. For IMemoryBlockExtension, if the memory block returns false when #supportsChangeManagement() is called, this rendering will calculate the change state for each byte when its content is updated. Clients may manages the change states of its memory block by returning true when #supportsChangeManagement() is called. This will cause this rendering to stop calculating the change states of the memory block. Instead it would rely on the attributes returned in the MemoryByte array to determine if a byte has changed. For IMemoryBlock, this rendering will manage the change states its content. When firing change event, be aware of the following: - whenever a change event is fired, the content provider for Memory View view checks to see if memory has actually changed. - If memory has actually changed, a refresh will commence. Changes to the memory block will be computed and will be shown with the delta icons. - If memory has not changed, content will not be refreshed. However, previous delta information will be erased. The screen will be refreshed to show that no memory has been changed. (All delta icons will be removed.) Please note that these APIs will be called multiple times by the Memory View. To improve performance, debug adapters need to cache the content of its memory block and only retrieve updated data when necessary.

Since:
3.1

Field Summary
static String PROPERTY_COL_SIZE
          Property identifier for the column size in a table rendering
static String PROPERTY_SELECTED_ADDRESS
          Property identifier for the selected address in a table rendering
static String PROPERTY_TOP_ADDRESS
          Property identifier for the top row address in a table rendering
 
Constructor Summary
AbstractTableRendering(String renderingId)
          Constructs a new table rendering of the specified type.
 
Method Summary
 void becomesHidden()
          Notification this rendering has become hidden in its container.
 void becomesVisible()
          Notification this rendering has become visible in its container.
protected  void createActions()
          Create actions for the view tab
 Control createControl(Composite parent)
          Creates the top level control for this rendering under the given parent composite.
 void displayError(DebugException e)
          Displays an error message for the given exception.
 void displayTable()
          Displays the content of the table viewer.
 void dispose()
          Disposes this rendering.
protected  void fillContextMenu(IMenuManager menu)
          Fills the context menu for this rendering
 boolean format(int bytesPerLine, int columnSize)
          Format view tab based on the bytes per line and column.
 Object getAdapter(Class adapter)
          Returns an object which is an instance of the given class associated with this object.
 int getAddressableSize()
          Returns the addressible size of this rendering's memory block in bytes.
 int getAddressableUnitPerColumn()
          Returns the number of addressable units per column.
 int getAddressableUnitPerLine()
          Returns the number of addressable units per row.
abstract  byte[] getBytes(String renderingTypeId, BigInteger address, MemoryByte[] currentValues, String newValue)
          Returns bytes for the given text corresponding to bytes at the given address for the specified rendering type.
 int getBytesPerColumn()
          Returns the number of bytes displayed in a single column cell.
 int getBytesPerLine()
          Returns the number of bytes displayed in a row.
protected  IColorProvider getColorProviderAdapter()
          Returns the color provider for this rendering's memory block or null if none.
 Control getControl()
          Returns the top level control for this rendering.
protected  IFontProvider getFontProviderAdapter()
          Returns the font provider for this rendering's memory block or null if none.
protected  ILabelProvider getLabelProviderAdapter()
          Returns the label provider for this rendering's memory block or null if none.
 int getNumCharsPerByte()
          Returns the number of characters a byte will convert to or -1 if unknown.
 BigInteger getSelectedAddress()
          Returns the currently selected address in this rendering.
 MemoryByte[] getSelectedAsBytes()
          Returns the currently selected content in this rendering as MemoryByte.
 String getSelectedAsString()
          Returns the currently selected content in this rendering as a String.
abstract  String getString(String renderingTypeId, BigInteger address, MemoryByte[] data)
          Returns text for the given memory bytes at the specified address for the specified rendering type.
protected  IMemoryBlockTablePresentation getTablePresentationAdapter()
          Returns the table presentation for this rendering's memory block or null if none.
 TableViewer getTableViewer()
          Returns this rendering's table viewer.
 void goToAddress(BigInteger address)
          Moves the cursor to the specified address.
 boolean isDisplayingError()
          Returns whether the error page is displayed.
 void propertyChange(PropertyChangeEvent event)
          Notification that a property has changed.
 void refresh()
          Refresh the table viewer with the current top visible address.
 void reset()
          Resets this memory rendering.
 void resizeColumnsToPreferredSize()
          Resize column to the preferred size.
 void updateLabels()
          Updates labels of this rendering.
protected  void updateRenderingLabel(boolean showAddress)
          Updates the label of this rendering, optionally displaying the base address of this rendering's memory block.
 
Methods inherited from class org.eclipse.debug.ui.memory.AbstractMemoryRendering
activated, addPropertyChangeListener, createPopupMenu, deactivated, firePropertyChangedEvent, getImage, getLabel, getMemoryBlock, getMemoryRenderingContainer, getPopupMenuManager, getRenderingId, init, isVisible, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_SELECTED_ADDRESS

public static final String PROPERTY_SELECTED_ADDRESS
Property identifier for the selected address in a table rendering

See Also:
Constant Field Values

PROPERTY_COL_SIZE

public static final String PROPERTY_COL_SIZE
Property identifier for the column size in a table rendering

See Also:
Constant Field Values

PROPERTY_TOP_ADDRESS

public static final String PROPERTY_TOP_ADDRESS
Property identifier for the top row address in a table rendering

See Also:
Constant Field Values
Constructor Detail

AbstractTableRendering

public AbstractTableRendering(String renderingId)
Constructs a new table rendering of the specified type.

Parameters:
renderingId - memory rendering type identifier
Method Detail

propertyChange

public void propertyChange(PropertyChangeEvent event)
Description copied from interface: IPropertyChangeListener
Notification that a property has changed.

This method gets called when the observed object fires a property change event.

Specified by:
propertyChange in interface IPropertyChangeListener
Parameters:
event - the property change event object describing which property changed and how

createControl

public Control createControl(Composite parent)
Description copied from interface: IMemoryRendering
Creates the top level control for this rendering under the given parent composite. This method is called after this rendering's init method has been called.

Implementors are responsible for ensuring that the created control can be accessed via getControl

Specified by:
createControl in interface IMemoryRendering
Parameters:
parent - the parent composite

format

public boolean format(int bytesPerLine,
                      int columnSize)
Format view tab based on the bytes per line and column.

Parameters:
bytesPerLine - - number of bytes per line, possible values: 16 * addressableSize
columnSize - - number of bytes per column, possible values: (1 / 2 / 4 / 8 / 16) * addressableSize
Returns:
true if format is successful, false, otherwise

displayTable

public void displayTable()
Displays the content of the table viewer.


displayError

public void displayError(DebugException e)
Displays an error message for the given exception.

Parameters:
e - exception to display

isDisplayingError

public boolean isDisplayingError()
Returns whether the error page is displayed.

Returns:
whether the error page is displayed

getControl

public Control getControl()
Description copied from interface: IMemoryRendering
Returns the top level control for this rendering.

May return null if the control has not been created yet.

Specified by:
getControl in interface IMemoryRendering
Returns:
the top level control or null

getAddressableSize

public int getAddressableSize()
Returns the addressible size of this rendering's memory block in bytes.

Returns:
the addressible size of this rendering's memory block in bytes

resizeColumnsToPreferredSize

public void resizeColumnsToPreferredSize()
Resize column to the preferred size.


fillContextMenu

protected void fillContextMenu(IMenuManager menu)
Fills the context menu for this rendering

Parameters:
menu - menu to fill

getAddressableUnitPerLine

public int getAddressableUnitPerLine()
Returns the number of addressable units per row.

Returns:
number of addressable units per row

getAddressableUnitPerColumn

public int getAddressableUnitPerColumn()
Returns the number of addressable units per column.

Returns:
number of addressable units per column

getBytesPerColumn

public int getBytesPerColumn()
Returns the number of bytes displayed in a single column cell.

Returns:
the number of bytes displayed in a single column cell

getBytesPerLine

public int getBytesPerLine()
Returns the number of bytes displayed in a row.

Returns:
the number of bytes displayed in a row

updateLabels

public void updateLabels()
Updates labels of this rendering.


updateRenderingLabel

protected void updateRenderingLabel(boolean showAddress)
Updates the label of this rendering, optionally displaying the base address of this rendering's memory block.

Parameters:
showAddress - whether to display the base address of this rendering's memory block in this rendering's label

refresh

public void refresh()
Refresh the table viewer with the current top visible address. Update labels in the memory rendering.


getTableViewer

public TableViewer getTableViewer()
Returns this rendering's table viewer.


dispose

public void dispose()
Description copied from interface: IMemoryRendering
Disposes this rendering.

Specified by:
dispose in interface IMemoryRendering
Overrides:
dispose in class AbstractMemoryRendering

goToAddress

public void goToAddress(BigInteger address)
                 throws DebugException
Moves the cursor to the specified address. Will load more memory if the address is not currently visible.

Parameters:
address - address to position cursor at
Throws:
DebugException - if an exception occurrs

createActions

protected void createActions()
Create actions for the view tab


becomesHidden

public void becomesHidden()
Description copied from interface: IMemoryRendering
Notification this rendering has become hidden in its container.

Specified by:
becomesHidden in interface IMemoryRendering
Overrides:
becomesHidden in class AbstractMemoryRendering

becomesVisible

public void becomesVisible()
Description copied from interface: IMemoryRendering
Notification this rendering has become visible in its container. Note that a rendering does not have to be active to be visible.

Specified by:
becomesVisible in interface IMemoryRendering
Overrides:
becomesVisible in class AbstractMemoryRendering

reset

public void reset()
Resets this memory rendering. The cursor will be moved to the base address of the memory block. The table will be positioned to have the base address at the top.


getSelectedAddress

public BigInteger getSelectedAddress()
Returns the currently selected address in this rendering.

Returns:
the currently selected address in this rendering

getSelectedAsString

public String getSelectedAsString()
Returns the currently selected content in this rendering as a String.

Returns:
the currently selected content in this rendering

getSelectedAsBytes

public MemoryByte[] getSelectedAsBytes()
Returns the currently selected content in this rendering as MemoryByte.

Returns:
the currently selected content in array of MemoryByte. Returns an empty array if the selected address is out of buffered range.

getNumCharsPerByte

public int getNumCharsPerByte()
Returns the number of characters a byte will convert to or -1 if unknown.

Returns:
the number of characters a byte will convert to or -1 if unknown

getAdapter

public Object getAdapter(Class adapter)
Description copied from interface: IAdaptable
Returns an object which is an instance of the given class associated with this object. Returns null if no such object can be found.

Specified by:
getAdapter in interface IAdaptable
Overrides:
getAdapter in class PlatformObject
Parameters:
adapter - the class to adapt to
Returns:
the adapted object or null
See Also:
IAdaptable.getAdapter(Class), Platform.getAdapterManager()

getColorProviderAdapter

protected IColorProvider getColorProviderAdapter()
Returns the color provider for this rendering's memory block or null if none.

By default a color provider is obtained by aksing this rendering's memory bock for its IColorProvider adapter. When the color provider is queried for color information, it is provided with a MemoryRenderingElement as an argument.

Returns:
the color provider for this rendering's memory block, or null

getLabelProviderAdapter

protected ILabelProvider getLabelProviderAdapter()
Returns the label provider for this rendering's memory block or null if none.

By default a label provider is obtained by aksing this rendering's memory bock for its ILabelProvider adapter. When the label provider is queried for label information, it is provided with a MemoryRenderingElement as an argument.

Returns:
the label provider for this rendering's memory block, or null

getFontProviderAdapter

protected IFontProvider getFontProviderAdapter()
Returns the font provider for this rendering's memory block or null if none.

By default a font provider is obtained by aksing this rendering's memory bock for its IFontProvider adapter. When the font provider is queried for font information, it is provided with a MemoryRenderingElement as an argument.

Returns:
the font provider for this rendering's memory block, or null

getTablePresentationAdapter

protected IMemoryBlockTablePresentation getTablePresentationAdapter()
Returns the table presentation for this rendering's memory block or null if none.

By default a table presentation is obtained by aksing this rendering's memory bock for its IMemoryBlockTablePresentation adapter.

Returns:
the table presentation for this rendering's memory block, or null

getString

public abstract String getString(String renderingTypeId,
                                 BigInteger address,
                                 MemoryByte[] data)
Returns text for the given memory bytes at the specified address for the specified rendering type. This is called by the label provider for. Subclasses must override.

Parameters:
renderingTypeId - rendering type identifier
address - address where the bytes belong to
data - the bytes
Returns:
a string to represent the memory. Cannot not return null. Returns a string to pad the cell if the memory cannot be converted successfully.

getBytes

public abstract byte[] getBytes(String renderingTypeId,
                                BigInteger address,
                                MemoryByte[] currentValues,
                                String newValue)
Returns bytes for the given text corresponding to bytes at the given address for the specified rendering type. This is called by the cell modifier when modifying bytes in a memory block. Subclasses must convert the string value to an array of bytes. The bytes will be passed to the debug adapter for memory block modification. Returns null if the bytes cannot be formatted properly.

Parameters:
renderingTypeId - rendering type identifier
address - address the bytes begin at
currentValues - current values of the data in bytes format
newValue - the string to be converted to bytes
Returns:
the bytes converted from a string

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.