1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Relocated plugin to the plugins directory.

Repackaged to .traditional
Restructured, moving AbstractPane, AddressPane, DataPane and TextPane to their own files.
This commit is contained in:
Ted Williams 2007-03-14 04:55:18 +00:00
parent 4de8c38ea8
commit 94f8ff9cbf
17 changed files with 4685 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.dd.debug.memory.renderings.traditional</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,14 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Traditional Memory Rendering
Bundle-SymbolicName: org.eclipse.dd.debug.memory.renderings.traditional;singleton:=true
Bundle-Version: 0.9.0.qualifier
Bundle-Localization: plugin
Require-Bundle: org.eclipse.debug.core,
org.eclipse.debug.ui,
org.eclipse.core.runtime,
org.eclipse.swt,
org.eclipse.jface,
org.eclipse.ui
Eclipse-LazyStart: true
Bundle-Activator: org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRenderingPlugin

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -0,0 +1,30 @@
<?eclipse version="3.0"?>
<plugin>
<extension point="org.eclipse.debug.ui.memoryRenderings">
<renderingType
name="Traditional"
id="org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRendering"
class="org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRenderingTypeDelegate">
</renderingType>
<renderingBindings
renderingIds="org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRendering"
defaultIds="org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRendering">
<enablement>
<instanceof value="org.eclipse.debug.core.model.IMemoryBlockExtension"/>
</enablement>
</renderingBindings>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
class="org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRenderingPreferencePage"
id="org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRenderingPreferencePage"
name="Traditional Memory Rendering"/>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer class="org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRenderingPreferenceInitializer"/>
</extension>
</plugin>

View file

@ -0,0 +1,636 @@
package org.eclipse.dd.debug.memory.renderings.traditional;
import java.math.BigInteger;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.MemoryByte;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT;
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.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Caret;
public abstract class AbstractPane extends Canvas
{
protected Rendering fRendering;
// selection state
protected boolean fSelectionInProgress = false;
protected BigInteger fSelectionStartAddress = null;
protected int fSelectionStartAddressSubPosition;
// caret
protected Caret fCaret = null;
protected int fSubCellCaretPosition = 0; // character may not fall on
// byte boundary
protected boolean fCaretEnabled = false;
protected BigInteger fCaretAddress = null;
// storage
protected int fRowCount = 0;
protected boolean fPaneVisible = true;
public AbstractPane(Rendering rendering)
{
super(rendering, SWT.DOUBLE_BUFFERED);
fRendering = rendering;
try
{
fCaretAddress = rendering.getMemoryBlock().getBigBaseAddress();
}
catch(Exception e)
{
// do nothing
}
// pref
this.setFont(fRendering.getFont());
GC gc = new GC(this);
gc.setFont(this.getFont());
fCaret = new Caret(this, SWT.NONE);
fCaret.setSize(1, gc.stringExtent("|").y); //$NON-NLS-1$
gc.dispose();
this.addPaintListener(new PaintListener()
{
public void paintControl(PaintEvent pe)
{
AbstractPane.this.paint(pe);
}
});
this.addMouseListener(new MouseListener()
{
public void mouseUp(MouseEvent me)
{
positionCaret(me.x, me.y);
fCaret.setVisible(true);
if(me.button == 1)
{
endSelection(me.x, me.y);
}
}
public void mouseDown(MouseEvent me)
{
AbstractPane.this.forceFocus();
positionCaret(me.x, me.y);
fCaret.setVisible(false);
if(me.button == 1)
{
// if shift is down and we have an existing start address,
// append selection
if((me.stateMask & SWT.SHIFT) != 0
&& fRendering.getSelection().getStart() != null)
{
// if the pane doesn't have a selection start (the
// selection was created in a different pane)
// then initialize the pane's selection start to the
// rendering's selection start
if(AbstractPane.this.fSelectionStartAddress == null)
AbstractPane.this.fSelectionStartAddress = fRendering
.getSelection().getStart();
AbstractPane.this.fSelectionInProgress = true;
AbstractPane.this.appendSelection(me.x, me.y);
}
else
{
// start a new selection
AbstractPane.this.startSelection(me.x, me.y);
}
}
}
public void mouseDoubleClick(MouseEvent me)
{
}
});
this.addMouseMoveListener(new MouseMoveListener()
{
public void mouseMove(MouseEvent me)
{
if(fSelectionInProgress)
{
appendSelection(me.x, me.y);
}
}
});
this.addKeyListener(new KeyListener()
{
public void keyPressed(KeyEvent ke)
{
if((ke.stateMask & SWT.SHIFT) != 0)
{
switch(ke.keyCode)
{
case SWT.ARROW_RIGHT:
case SWT.ARROW_LEFT:
case SWT.ARROW_UP:
case SWT.ARROW_DOWN:
case SWT.PAGE_DOWN:
case SWT.PAGE_UP:
if(fRendering.getSelection().getStart() == null)
{
fRendering.getSelection().setStart(fCaretAddress.add(BigInteger.valueOf(
fRendering.getAddressesPerColumn())), fCaretAddress);
}
break;
}
}
if(ke.keyCode == SWT.ARROW_RIGHT)
{
fSubCellCaretPosition++;
if(fSubCellCaretPosition >= getCellCharacterCount())
{
fSubCellCaretPosition = 0;
// Ensure that caret is within the addressable range
BigInteger newCaretAddress = fCaretAddress.add(BigInteger
.valueOf(getNumberOfBytesRepresentedByColumn() / fRendering.getAddressableSize()));
if(newCaretAddress.compareTo(fRendering.getMemoryBlockEndAddress()) > 0)
{
fSubCellCaretPosition = getCellCharacterCount();
}
else
{
setCaretAddress(newCaretAddress);
}
}
updateCaret();
ensureCaretWithinViewport();
}
else if(ke.keyCode == SWT.ARROW_LEFT || ke.keyCode == SWT.BS)
{
fSubCellCaretPosition--;
if(fSubCellCaretPosition < 0)
{
fSubCellCaretPosition = getCellCharacterCount() - 1;
// Ensure that caret is within the addressable range
BigInteger newCaretAddress = fCaretAddress.subtract(BigInteger
.valueOf(getNumberOfBytesRepresentedByColumn() / fRendering.getAddressableSize()));
if(newCaretAddress.compareTo(fRendering.getMemoryBlockStartAddress()) < 0)
{
fSubCellCaretPosition = 0;
}
else
{
setCaretAddress(newCaretAddress);
}
}
updateCaret();
ensureCaretWithinViewport();
}
else if(ke.keyCode == SWT.ARROW_DOWN)
{
// Ensure that caret is within the addressable range
BigInteger newCaretAddress = fCaretAddress.add(BigInteger
.valueOf(fRendering.getAddressableCellsPerRow()));
setCaretAddress(newCaretAddress);
updateCaret();
ensureCaretWithinViewport();
}
else if(ke.keyCode == SWT.ARROW_UP)
{
// Ensure that caret is within the addressable range
BigInteger newCaretAddress = fCaretAddress.subtract(BigInteger
.valueOf(fRendering.getAddressableCellsPerRow()));
setCaretAddress(newCaretAddress);
updateCaret();
ensureCaretWithinViewport();
}
else if(ke.keyCode == SWT.PAGE_DOWN)
{
// Ensure that caret is within the addressable range
BigInteger newCaretAddress = fCaretAddress.add(BigInteger
.valueOf(fRendering.getAddressableCellsPerRow()
* (fRendering.getRowCount() - 1)));
setCaretAddress(newCaretAddress);
updateCaret();
ensureCaretWithinViewport();
}
else if(ke.keyCode == SWT.PAGE_UP)
{
// Ensure that caret is within the addressable range
BigInteger newCaretAddress = fCaretAddress.subtract(BigInteger
.valueOf(fRendering.getAddressableCellsPerRow()
* (fRendering.getRowCount() - 1)));
setCaretAddress(newCaretAddress);
updateCaret();
ensureCaretWithinViewport();
}
else if(ke.keyCode == SWT.ESC)
{
fRendering.getViewportCache().clearEditBuffer();
}
else if(ke.character == '\r')
{
fRendering.getViewportCache().writeEditBuffer();
}
else if(Rendering.isValidEditCharacter(ke.character))
{
editCell(fCaretAddress, fSubCellCaretPosition, ke.character);
}
if((ke.stateMask & SWT.SHIFT) != 0)
{
switch(ke.keyCode)
{
case SWT.ARROW_RIGHT:
case SWT.ARROW_LEFT:
case SWT.ARROW_UP:
case SWT.ARROW_DOWN:
case SWT.PAGE_DOWN:
case SWT.PAGE_UP:
fRendering.getSelection().setEnd(fCaretAddress.add(BigInteger.valueOf(
fRendering.getAddressesPerColumn())),
fCaretAddress);
break;
}
}
else if(ke.keyCode != SWT.SHIFT)
// if shift key, keep selection, we might add to it
{
fRendering.getSelection().clear();
}
}
public void keyReleased(KeyEvent ke)
{
// do nothing
}
});
this.addFocusListener(new FocusListener()
{
public void focusLost(FocusEvent fe)
{
IPreferenceStore store = TraditionalRenderingPlugin.getDefault().getPreferenceStore();
if(TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE_ON_ENTER_ONLY
.equals(store.getString(TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE)))
{
fRendering.getViewportCache().clearEditBuffer();
}
else
{
fRendering.getViewportCache().writeEditBuffer();
}
// clear the pane local selection start
AbstractPane.this.fSelectionStartAddress = null;
}
public void focusGained(FocusEvent fe)
{
}
});
}
protected boolean isPaneVisible()
{
return fPaneVisible;
}
protected void setPaneVisible(boolean visible)
{
fPaneVisible = visible;
this.setVisible(visible);
}
protected int getNumberOfBytesRepresentedByColumn()
{
return fRendering.getBytesPerColumn();
}
protected void editCell(BigInteger address, int subCellPosition,
char character)
{
// do nothing
}
// Set the caret address
protected void setCaretAddress(BigInteger caretAddress)
{
// Ensure that caret is within the addressable range
if((caretAddress.compareTo(fRendering.getMemoryBlockStartAddress()) >= 0) &&
(caretAddress.compareTo(fRendering.getMemoryBlockEndAddress()) <= 0))
{
fCaretAddress = caretAddress;
}
else if(caretAddress.compareTo(fRendering.getMemoryBlockStartAddress()) < 0)
{
// calculate offset from the beginning of the row
int cellOffset = fCaretAddress.subtract(fRendering.getViewportStartAddress()).intValue();
int row = cellOffset / (fRendering.getBytesPerRow() / fRendering.getBytesPerCharacter());
cellOffset -= row * fRendering.getBytesPerRow() / fRendering.getBytesPerCharacter();
fCaretAddress = fRendering.getMemoryBlockStartAddress().add(
BigInteger.valueOf(cellOffset / fRendering.getAddressableSize()));
}
else if(caretAddress.compareTo(fRendering.getMemoryBlockEndAddress()) > 0)
{
// calculate offset from the end of the row
int cellOffset = fCaretAddress.subtract(fRendering.getViewportEndAddress()).intValue() + 1;
int row = cellOffset / (fRendering.getBytesPerRow() / fRendering.getBytesPerCharacter());
cellOffset -= row * fRendering.getBytesPerRow()/ fRendering.getBytesPerCharacter();
fCaretAddress = fRendering.getMemoryBlockEndAddress().add(
BigInteger.valueOf(cellOffset / fRendering.getAddressableSize()));
}
}
protected boolean isOdd(int value)
{
return (value / 2) * 2 == value;
}
protected void updateCaret()
{
try
{
if(fCaretAddress != null)
{
Point cellPosition = getCellLocation(fCaretAddress);
if(cellPosition != null)
{
fCaret.setLocation(cellPosition.x + fSubCellCaretPosition
* getCellCharacterWidth(), cellPosition.y);
}
}
}
catch(Exception e)
{
fRendering
.logError(
TraditionalRenderingMessages
.getString("TraditionalRendering.FAILURE_POSITION_CURSOR"), e); //$NON-NLS-1$
}
}
protected void ensureCaretWithinViewport() // TODO getAddressableSize() > 1 ?
{
// determine if caret is before the viewport start
// if so, scroll viewport up by appropriate rows
if(fCaretAddress.compareTo(fRendering.getViewportStartAddress()) < 0)
{
BigInteger difference = fRendering.getViewportStartAddress()
.subtract(fCaretAddress);
BigInteger rows = difference.divide(BigInteger.valueOf(fRendering.getBytesPerRow()));
if(rows.multiply(
BigInteger.valueOf(fRendering.getBytesPerRow())).compareTo(difference) != 0)
rows = rows.add(BigInteger.valueOf(1));
fRendering.setViewportStartAddress(fRendering.getViewportStartAddress()
.subtract(rows.multiply(BigInteger.valueOf(fRendering.getBytesPerRow()))));
fRendering.ensureViewportAddressDisplayable();
fRendering.gotoAddress(fRendering.getViewportStartAddress());
}
// determine if caret is after the viewport end
// if so, scroll viewport down by appropriate rows
else if(fCaretAddress.compareTo(fRendering.getViewportEndAddress()) >= 0)
{
BigInteger difference = fCaretAddress.subtract(fRendering
.getViewportEndAddress().subtract(BigInteger.valueOf(1)));
BigInteger rows = difference.divide(BigInteger.valueOf(fRendering.getBytesPerRow()));
if(rows.multiply(
BigInteger.valueOf(fRendering.getBytesPerRow())).compareTo(difference) != 0)
rows = rows.add(BigInteger.valueOf(1));
fRendering.setViewportStartAddress(fRendering.getViewportStartAddress().add(
rows.multiply(BigInteger.valueOf(fRendering.getBytesPerRow()))));
fRendering.ensureViewportAddressDisplayable();
fRendering.gotoAddress(fRendering.getViewportStartAddress());
}
}
protected void advanceCursor()
{
fSubCellCaretPosition++;
if(fSubCellCaretPosition >= getCellCharacterCount())
{
fSubCellCaretPosition = 0;
fCaretAddress = fCaretAddress.add(BigInteger
.valueOf(getNumberOfBytesRepresentedByColumn() / fRendering.getAddressableSize()));
}
updateCaret();
ensureCaretWithinViewport();
}
protected void positionCaret(int x, int y)
{
// do nothing
}
protected int getRowCount()
{
return fRowCount;
}
protected void setRowCount()
{
fRowCount = getBounds().height / getCellHeight();
}
protected void settingsChanged()
{
fSubCellCaretPosition = 0;
}
protected void startSelection(int x, int y)
{
try
{
BigInteger address = getViewportAddress(x / getCellWidth(), y
/ getCellHeight());
if(address != null)
{
this.fSelectionStartAddress = address;
Point cellPosition = getCellLocation(address);
if(cellPosition != null)
{
int offset = x - cellPosition.x;
fSelectionStartAddressSubPosition = offset
/ getCellCharacterWidth();
}
fRendering.getSelection().clear();
fRendering.getSelection().setStart(address.add(BigInteger.valueOf(
fRendering.getBytesPerColumn() / fRendering.getAddressableSize())), address);
fSelectionInProgress = true;
}
}
catch(DebugException e)
{
fRendering
.logError(
TraditionalRenderingMessages
.getString("TraditionalRendering.FAILURE_START_SELECTION"), e); //$NON-NLS-1$
}
}
protected void endSelection(int x, int y)
{
appendSelection(x, y);
fSelectionInProgress = false;
}
protected void appendSelection(int x, int y)
{
try
{
BigInteger address = getViewportAddress(x / getCellWidth(), y
/ getCellHeight());
if(address.compareTo(this.fSelectionStartAddress) == 0)
{
// deal with sub cell selection
Point cellPosition = getCellLocation(address);
int offset = x - cellPosition.x;
int subCellCharacterPosition = offset / getCellCharacterWidth();
if(Math.abs(subCellCharacterPosition
- this.fSelectionStartAddressSubPosition) > this
.getCellCharacterCount() / 4)
{
fRendering.getSelection().setEnd(address.add(BigInteger
.valueOf(fRendering.getAddressesPerColumn())), address);
}
else
{
fRendering.getSelection().setEnd(null, null);
}
}
else
{
fRendering.getSelection().setEnd(address.add(BigInteger
.valueOf(fRendering.getAddressesPerColumn())), address);
}
if(fRendering.getSelection().getEnd() != null)
{
this.fCaretAddress = fRendering.getSelection().getEnd();
this.fSubCellCaretPosition = 0;
}
updateCaret();
}
catch(DebugException e)
{
fRendering
.logError(
TraditionalRenderingMessages
.getString("TraditionalRendering.FAILURE_APPEND_SELECTION"), e); //$NON-NLS-1$
}
}
protected void paint(PaintEvent pe)
{
fRowCount = getBounds().height / getCellHeight();
}
abstract protected BigInteger getViewportAddress(int col, int row)
throws DebugException;
protected Point getCellLocation(BigInteger address)
{
return null;
}
protected String getCellText(MemoryByte bytes[])
{
return null;
}
abstract protected int getCellWidth();
abstract protected int getCellCharacterCount();
private int fCellHeight = -1; // called often, cache
protected int getCellHeight()
{
if(fCellHeight == -1)
{
fCellHeight = getCellTextHeight()
+ (fRendering.getCellPadding() * 2);
}
return fCellHeight;
}
private int fCharacterWidth = -1; // called often, cache
protected int getCellCharacterWidth()
{
if(fCharacterWidth == -1)
{
GC gc = new GC(this);
gc.setFont(fRendering.getFont());
fCharacterWidth = gc.getAdvanceWidth('F');
gc.dispose();
}
return fCharacterWidth;
}
private int fTextHeight = -1; // called often, cache
protected int getCellTextHeight()
{
if(fTextHeight == -1)
{
GC gc = new GC(this);
gc.setFont(fRendering.getFont());
FontMetrics fontMetrics = gc.getFontMetrics();
fTextHeight = fontMetrics.getHeight();
gc.dispose();
}
return fTextHeight;
}
}

View file

@ -0,0 +1,232 @@
package org.eclipse.dd.debug.memory.renderings.traditional;
import java.math.BigInteger;
import org.eclipse.debug.core.DebugException;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
public class AddressPane extends AbstractPane
{
public AddressPane(Rendering parent)
{
super(parent);
}
protected BigInteger getViewportAddress(int col, int row)
throws DebugException
{
BigInteger address = fRendering.getViewportStartAddress();
address = address.add(BigInteger.valueOf((row
* fRendering.getColumnCount() + col)
* fRendering.getAddressesPerColumn()));
return address;
}
protected void appendSelection(int x, int y)
{
try
{
BigInteger address = getViewportAddress(x / getCellWidth(), y
/ getCellHeight());
if(address.compareTo(this.fSelectionStartAddress) == 0)
{
fRendering.getSelection().setEnd(null, null);
}
else
{
fRendering.getSelection().setEnd(address.add(BigInteger
.valueOf(fRendering.getAddressesPerColumn() * fRendering.getColumnCount())), address);
}
}
catch(DebugException e)
{
fRendering
.logError(
TraditionalRenderingMessages
.getString("TraditionalRendering.FAILURE_APPEND_SELECTION"), e); //$NON-NLS-1$
}
}
public Point computeSize(int wHint, int hHint)
{
return new Point(getCellWidth() + fRendering.getRenderSpacing(), 100);
}
protected int getCellCharacterCount()
{
// two characters per byte of hex address
return fRendering.getAddressBytes() * 2
+ 2; // 0x
}
protected int getCellWidth()
{
GC gc = new GC(this);
gc.setFont(fRendering.getFont());
int width = gc.getAdvanceWidth('0');
gc.dispose();
return getCellCharacterCount() * width
+ (fRendering.getCellPadding() * 2);
}
private int getColumnCount()
{
return 0;
}
private BigInteger getCellAddressAt(int x, int y) throws DebugException
{
BigInteger address = fRendering.getViewportStartAddress();
int col = x / getCellWidth();
int row = y / getCellHeight();
if(col > getColumnCount())
return null;
address = address.add(BigInteger.valueOf(row
* fRendering.getColumnCount() * fRendering.getAddressesPerColumn()
/ fRendering.getBytesPerCharacter()));
address = address.add(BigInteger.valueOf(col
* fRendering.getAddressesPerColumn()));
return address;
}
protected Point getCellLocation(BigInteger cellAddress)
{
try
{
BigInteger address = fRendering.getViewportStartAddress();
int cellOffset = cellAddress.subtract(address).intValue();
cellOffset *= fRendering.getAddressableSize();
int row = cellOffset
/ (fRendering.getColumnCount() * fRendering.getBytesPerColumn() / fRendering
.getBytesPerCharacter());
cellOffset -= row * fRendering.getColumnCount()
* fRendering.getBytesPerColumn()
/ fRendering.getBytesPerCharacter();
int col = cellOffset / fRendering.getBytesPerColumn()
/ fRendering.getBytesPerCharacter();
int x = col * getCellWidth() + fRendering.getCellPadding();
int y = row * getCellHeight() + fRendering.getCellPadding();
return new Point(x, y);
}
catch(Exception e)
{
fRendering
.logError(
TraditionalRenderingMessages
.getString("TraditionalRendering.FAILURE_DETERMINE_CELL_LOCATION"), e); //$NON-NLS-1$
return null;
}
}
protected int getNumberOfBytesRepresentedByColumn()
{
return fRendering.getBytesPerRow();
}
protected void positionCaret(int x, int y)
{
try
{
BigInteger cellAddress = getCellAddressAt(x, y);
if(cellAddress != null)
{
Point cellPosition = getCellLocation(cellAddress);
int offset = x - cellPosition.x;
int x2 = offset / getCellCharacterWidth();
if(x2 >= this.getCellCharacterCount())
{
cellAddress = cellAddress.add(BigInteger.valueOf(this
.getNumberOfBytesRepresentedByColumn()));
x2 = 0;
cellPosition = getCellLocation(cellAddress);
}
fCaret.setLocation(cellPosition.x + x2
* getCellCharacterWidth(), cellPosition.y);
this.fCaretAddress = cellAddress;
this.fSubCellCaretPosition = x2;
}
}
catch(Exception e)
{
fRendering
.logError(
TraditionalRenderingMessages
.getString("TraditionalRendering.FAILURE_POSITION_CURSOR"), e); //$NON-NLS-1$
}
}
protected void paint(PaintEvent pe)
{
super.paint(pe);
GC gc = pe.gc;
FontMetrics fontMetrics = gc.getFontMetrics();
int textHeight = fontMetrics.getHeight();
int cellHeight = textHeight + (fRendering.getCellPadding() * 2);
try
{
BigInteger start = fRendering.getViewportStartAddress();
for(int i = 0; i < this.getBounds().height / cellHeight; i++)
{
gc.setForeground(fRendering.getTraditionalRendering().getColorText());
BigInteger lineAddress = start.add(BigInteger.valueOf(i
* fRendering.getColumnCount()
* fRendering.getAddressesPerColumn()));
if(fRendering.getSelection().isSelected(lineAddress))
{
gc.setBackground(fRendering.getTraditionalRendering().getColorSelection());
gc.fillRectangle(fRendering.getCellPadding() * 2,
cellHeight * i, getCellWidth(), cellHeight);
gc.setForeground(fRendering.getTraditionalRendering().getColorBackground());
}
else
{
gc.setBackground(fRendering.getTraditionalRendering().getColorBackground());
gc.fillRectangle(fRendering.getCellPadding() * 2,
cellHeight * i, getCellWidth(), cellHeight);
gc.setForeground(fRendering.getTraditionalRendering().getColorText());
}
gc.drawText(fRendering.getAddressString(lineAddress),
fRendering.getCellPadding() * 2, cellHeight * i
+ fRendering.getCellPadding());
}
}
catch(Exception e)
{
fRendering.logError(TraditionalRenderingMessages
.getString("TraditionalRendering.FAILURE_PAINT"), e); //$NON-NLS-1$
}
}
}

View file

@ -0,0 +1,341 @@
package org.eclipse.dd.debug.memory.renderings.traditional;
import java.math.BigInteger;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.eclipse.debug.core.model.MemoryByte;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
public class DataPane extends AbstractPane
{
public DataPane(Rendering parent)
{
super(parent);
}
protected String getCellText(MemoryByte bytes[])
{
return fRendering.getRadixText(bytes, fRendering.getRadix(), fRendering
.isLittleEndian());
}
protected void editCell(BigInteger address, int subCellPosition,
char character)
{
try
{
MemoryByte bytes[] = fRendering.getBytes(fCaretAddress, fRendering
.getBytesPerColumn());
String cellText = getCellText(bytes);
if(cellText == null)
return;
StringBuffer cellTextBuffer = new StringBuffer(cellText);
cellTextBuffer.setCharAt(subCellPosition, character);
BigInteger value = new BigInteger(cellTextBuffer.toString().trim(),
fRendering.getNumericRadix(fRendering.getRadix()));
final boolean isSignedType = fRendering.getRadix() == Rendering.RADIX_DECIMAL_SIGNED;
final boolean isSigned = isSignedType
&& value.compareTo(BigInteger.valueOf(0)) < 0;
int bitCount = value.bitLength();
if(isSignedType)
bitCount++;
if(bitCount > fRendering.getBytesPerColumn() * 8)
return;
int byteLen = fRendering.getBytesPerColumn();
byte[] byteData = new byte[byteLen];
for(int i = 0; i < byteLen; i++)
{
int bits = 255;
if(isSignedType && i == byteLen - 1)
bits = 127;
byteData[i] = (byte) (value.and(BigInteger.valueOf(bits))
.intValue() & bits);
value = value.shiftRight(8);
}
if(isSigned)
byteData[byteLen - 1] |= 128;
boolean shouldReorderBytes = fRendering.isLittleEndian() == bytes[0].isBigEndian(); // swapped in presentation
if(!bytes[0].isBigEndian()) // swapped by BigInteger/java endianness
shouldReorderBytes = !shouldReorderBytes;
if(shouldReorderBytes)
{
byte[] byteDataSwapped = new byte[byteData.length];
for(int i = 0; i < byteData.length; i++)
byteDataSwapped[i] = byteData[byteData.length - 1 - i];
byteData = byteDataSwapped;
}
if(byteData.length != bytes.length)
return;
TraditionalMemoryByte bytesToSet[] = new TraditionalMemoryByte[bytes.length];
for(int i = 0; i < byteData.length; i++)
{
bytesToSet[i] = new TraditionalMemoryByte(byteData[i]);
bytesToSet[i].setBigEndian(bytes[i].isBigEndian());
if(bytes[i].getValue() != byteData[i])
{
bytesToSet[i].setEdited(true);
}
else
{
bytesToSet[i].setChanged(bytes[i].isChanged());
}
}
fRendering.getViewportCache().setEditedValue(address, bytesToSet);
advanceCursor();
redraw();
}
catch(Exception e)
{
// do nothing
}
}
protected int getCellWidth()
{
return getCellCharacterCount() * getCellCharacterWidth()
+ (fRendering.getCellPadding() * 2);
}
protected int getCellCharacterCount()
{
return fRendering.getRadixCharacterCount(fRendering.getRadix(),
fRendering.getBytesPerColumn());
}
public Point computeSize(int wHint, int hHint)
{
return new Point(fRendering.getColumnCount() * getCellWidth()
+ fRendering.getRenderSpacing(), 100);
}
private BigInteger getCellAddressAt(int x, int y) throws DebugException
{
BigInteger address = fRendering.getViewportStartAddress();
int col = x / getCellWidth();
int row = y / getCellHeight();
if(col >= fRendering.getColumnCount())
return null;
address = address.add(BigInteger.valueOf(row
* fRendering.getColumnCount() * fRendering.getAddressesPerColumn()));
address = address.add(BigInteger.valueOf(col
* fRendering.getAddressesPerColumn()));
return address;
}
protected Point getCellLocation(BigInteger cellAddress)
{
try
{
BigInteger address = fRendering.getViewportStartAddress();
int cellOffset = cellAddress.subtract(address).intValue();
cellOffset *= fRendering.getAddressableSize();
int row = cellOffset
/ (fRendering.getColumnCount() * fRendering.getBytesPerColumn());
cellOffset -= row * fRendering.getColumnCount()
* fRendering.getBytesPerColumn();
int col = cellOffset / fRendering.getBytesPerColumn();
int x = col * getCellWidth() + fRendering.getCellPadding();
int y = row * getCellHeight() + fRendering.getCellPadding();
return new Point(x, y);
}
catch(Exception e)
{
fRendering
.logError(
TraditionalRenderingMessages
.getString("TraditionalRendering.FAILURE_DETERMINE_CELL_LOCATION"), e); //$NON-NLS-1$
return null;
}
}
protected void positionCaret(int x, int y)
{
try
{
BigInteger cellAddress = getCellAddressAt(x, y);
if(cellAddress != null)
{
Point cellPosition = getCellLocation(cellAddress);
int offset = x - cellPosition.x;
int subCellCharacterPosition = offset / getCellCharacterWidth();
if(subCellCharacterPosition == this.getCellCharacterCount())
{
cellAddress = cellAddress.add(BigInteger.valueOf(fRendering
.getAddressesPerColumn()));
subCellCharacterPosition = 0;
cellPosition = getCellLocation(cellAddress);
}
fCaret.setLocation(cellPosition.x + subCellCharacterPosition
* getCellCharacterWidth(), cellPosition.y);
this.fCaretAddress = cellAddress;
this.fSubCellCaretPosition = subCellCharacterPosition;
}
}
catch(Exception e)
{
fRendering
.logError(
TraditionalRenderingMessages
.getString("TraditionalRendering.FAILURE_POSITION_CURSOR"), e); //$NON-NLS-1$
}
}
protected BigInteger getViewportAddress(int col, int row)
throws DebugException
{
BigInteger address = fRendering.getViewportStartAddress();
address = address.add(BigInteger.valueOf((row
* fRendering.getColumnCount() + col)
* fRendering.getAddressesPerColumn()));
return address;
}
protected void paint(PaintEvent pe)
{
super.paint(pe);
IMemoryBlockExtension memoryBlock = fRendering.getMemoryBlock();
// TODO what if it is null?
GC gc = pe.gc;
gc.setFont(fRendering.getFont());
int cellHeight = getCellHeight();
int cellWidth = getCellWidth();
int columns = fRendering.getColumnCount();
try
{
BigInteger start = fRendering.getViewportStartAddress();
for(int i = 0; i < this.getBounds().height / cellHeight; i++)
{
for(int col = 0; col < columns; col++)
{
if(isOdd(col))
gc.setForeground(fRendering.getTraditionalRendering().getColorText());
else
gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate());
BigInteger cellAddress = start.add(BigInteger.valueOf((i
* fRendering.getColumnCount() + col)
* fRendering.getAddressesPerColumn()));
MemoryByte bytes[] = fRendering.getBytes(cellAddress,
fRendering.getBytesPerColumn());
if(fRendering.getSelection().isSelected(cellAddress))
{
gc.setBackground(fRendering.getTraditionalRendering().getColorSelection());
gc.fillRectangle(cellWidth * col
+ fRendering.getCellPadding(), cellHeight * i,
cellWidth, cellHeight);
gc.setForeground(fRendering.getTraditionalRendering().getColorBackground());
}
else
{
gc.setBackground(fRendering.getTraditionalRendering().getColorBackground());
gc.fillRectangle(cellWidth * col
+ fRendering.getCellPadding(), cellHeight * i,
cellWidth, cellHeight);
// TODO consider adding finer granularity?
boolean anyByteChanged = false;
for(int n = 0; n < bytes.length && !anyByteChanged; n++)
if(bytes[n].isChanged())
anyByteChanged = true;
// TODO consider adding finer granularity?
boolean anyByteEditing = false;
for(int n = 0; n < bytes.length && !anyByteEditing; n++)
if(bytes[n] instanceof TraditionalMemoryByte)
if(((TraditionalMemoryByte) bytes[n]).isEdited())
anyByteEditing = true;
if(anyByteEditing)
gc.setForeground(fRendering.getTraditionalRendering().getColorEdit());
else if(anyByteChanged)
gc.setForeground(fRendering.getTraditionalRendering().getColorChanged());
else if(isOdd(col))
gc.setForeground(fRendering.getTraditionalRendering().getColorText());
else
gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate());
gc.setBackground(fRendering.getTraditionalRendering().getColorBackground());
}
gc.drawText(getCellText(bytes), cellWidth * col
+ fRendering.getCellPadding(), cellHeight * i
+ fRendering.getCellPadding());
BigInteger cellEndAddress = cellAddress.add(BigInteger
.valueOf(fRendering.getAddressesPerColumn()));
cellEndAddress = cellEndAddress.subtract(BigInteger
.valueOf(1));
if(fCaretEnabled)
{
if(cellAddress.compareTo(fCaretAddress) <= 0
&& cellEndAddress.compareTo(fCaretAddress) >= 0)
{
int x = cellWidth * col
+ fRendering.getCellPadding()
+ fSubCellCaretPosition
* this.getCellCharacterWidth();
int y = cellHeight * i
+ fRendering.getCellPadding();
fCaret.setLocation(x, y);
}
}
if(fRendering.isDebug())
gc.drawRectangle(cellWidth * col
+ fRendering.getCellPadding(), cellHeight * i
+ fRendering.getCellPadding(), cellWidth,
cellHeight);
}
}
}
catch(Exception e)
{
fRendering.logError(TraditionalRenderingMessages
.getString("TraditionalRendering.FAILURE_PAINT"), e); //$NON-NLS-1$
}
}
}

View file

@ -0,0 +1,299 @@
package org.eclipse.dd.debug.memory.renderings.traditional;
import java.math.BigInteger;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.eclipse.debug.core.model.MemoryByte;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
public class TextPane extends AbstractPane
{
public TextPane(Rendering parent)
{
super(parent);
}
protected int getCellCharacterCount()
{
return fRendering.getBytesPerColumn()
/ fRendering.getBytesPerCharacter();
}
protected String getCellText(MemoryByte bytes[])
{
return fRendering.formatText(bytes, fRendering
.isLittleEndian(), fRendering.getTextMode());
}
protected void editCell(BigInteger address, int subCellPosition,
char character)
{
try
{
MemoryByte bytes[] = fRendering.getBytes(fCaretAddress, fRendering
.getBytesPerColumn());
String cellText = getCellText(bytes);
if(cellText == null)
return;
StringBuffer cellTextBuffer = new StringBuffer(cellText);
cellTextBuffer.setCharAt(subCellPosition, character);
byte byteData[] = cellTextBuffer.toString().getBytes();
if(byteData.length != bytes.length)
return;
TraditionalMemoryByte bytesToSet[] = new TraditionalMemoryByte[bytes.length];
for(int i = 0; i < byteData.length; i++)
{
bytesToSet[i] = new TraditionalMemoryByte(byteData[i]);
if(bytes[i].getValue() != byteData[i])
{
bytesToSet[i].setEdited(true);
}
else
{
bytesToSet[i].setChanged(bytes[i].isChanged());
}
}
fRendering.getViewportCache().setEditedValue(address, bytesToSet);
advanceCursor();
redraw();
}
catch(Exception e)
{
// this is ok
}
}
protected int getCellWidth()
{
GC gc = new GC(this);
gc.setFont(fRendering.getFont());
int width = gc.getAdvanceWidth('F');
gc.dispose();
return fRendering.getBytesPerColumn()
/ fRendering.getBytesPerCharacter() * width;
}
public Point computeSize(int wHint, int hHint)
{
return new Point(fRendering.getColumnCount() * getCellWidth()
+ fRendering.getRenderSpacing(), 100);
}
protected Point getCellLocation(BigInteger cellAddress)
{
try
{
BigInteger address = fRendering.getViewportStartAddress();
int cellOffset = cellAddress.subtract(address).intValue();
cellOffset *= fRendering.getAddressableSize();
int row = cellOffset
/ (fRendering.getColumnCount() * fRendering.getBytesPerColumn() / fRendering
.getBytesPerCharacter());
cellOffset -= row * fRendering.getColumnCount()
* fRendering.getBytesPerColumn()
/ fRendering.getBytesPerCharacter();
int col = cellOffset / fRendering.getBytesPerColumn()
/ fRendering.getBytesPerCharacter();
int x = col * getCellWidth() + fRendering.getCellPadding();
int y = row * getCellHeight() + fRendering.getCellPadding();
return new Point(x, y);
}
catch(Exception e)
{
fRendering
.logError(
TraditionalRenderingMessages
.getString("TraditionalRendering.FAILURE_DETERMINE_CELL_LOCATION"), e); //$NON-NLS-1$
return null;
}
}
private BigInteger getCellAddressAt(int x, int y) throws DebugException
{
BigInteger address = fRendering.getViewportStartAddress();
int col = x / getCellWidth();
int row = y / getCellHeight();
if(col >= fRendering.getColumnCount())
return null;
address = address.add(BigInteger.valueOf(row
* fRendering.getColumnCount() * fRendering.getAddressesPerColumn()
/ fRendering.getBytesPerCharacter()));
address = address.add(BigInteger.valueOf(col
* fRendering.getAddressesPerColumn()));
return address;
}
protected void positionCaret(int x, int y)
{
try
{
BigInteger cellAddress = getCellAddressAt(x, y);
if(cellAddress != null)
{
Point cellPosition = getCellLocation(cellAddress);
int offset = x - cellPosition.x;
int x2 = offset / getCellCharacterWidth();
if(x2 == this.getCellCharacterCount())
{
cellAddress = cellAddress.add(BigInteger.valueOf(fRendering
.getAddressesPerColumn()));
x2 = 0;
cellPosition = getCellLocation(cellAddress);
}
fCaret.setLocation(cellPosition.x + x2
* getCellCharacterWidth(), cellPosition.y);
this.fCaretAddress = cellAddress;
this.fSubCellCaretPosition = x2;
}
}
catch(Exception e)
{
fRendering
.logError(
TraditionalRenderingMessages
.getString("TraditionalRendering.FAILURE_POSITION_CURSOR"), e); //$NON-NLS-1$
}
}
protected BigInteger getViewportAddress(int col, int row)
throws DebugException
{
BigInteger address = fRendering.getViewportStartAddress();
address = address.add(BigInteger.valueOf((row
* fRendering.getColumnCount() + col)
* fRendering.getAddressesPerColumn()
/ fRendering.getBytesPerCharacter()));
return address;
}
protected void paint(PaintEvent pe)
{
super.paint(pe);
IMemoryBlockExtension memoryBlock = fRendering.getMemoryBlock();
// FIXME what if it is null?
GC gc = pe.gc;
gc.setFont(fRendering.getFont());
int cellHeight = getCellHeight();
int cellWidth = getCellWidth();
final int columns = fRendering.getColumnCount();
final boolean isLittleEndian = fRendering.isLittleEndian();
gc.setForeground(fRendering.getTraditionalRendering().getColorBackground());
gc.fillRectangle(columns * cellWidth, 0, this.getBounds().width, this
.getBounds().height);
try
{
BigInteger start = fRendering.getViewportStartAddress();
for(int i = 0; i < this.getBounds().height / cellHeight; i++)
{
for(int col = 0; col < columns; col++)
{
if(isOdd(col))
gc.setForeground(fRendering.getTraditionalRendering().getColorText());
else
gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate());
BigInteger cellAddress = start.add(BigInteger.valueOf((i
* columns + col)
* fRendering.getAddressesPerColumn()));
MemoryByte bytes[] = fRendering.getBytes(cellAddress,
fRendering.getBytesPerColumn());
if(fRendering.getSelection().isSelected(cellAddress))
{
gc.setBackground(fRendering.getTraditionalRendering().getColorSelection());
gc.fillRectangle(cellWidth * col, cellHeight * i,
cellWidth, cellHeight);
gc.setForeground(fRendering.getTraditionalRendering().getColorBackground());
}
else
{
gc.setBackground(fRendering.getTraditionalRendering().getColorBackground());
gc.fillRectangle(cellWidth * col, cellHeight * i,
cellWidth, cellHeight);
// TODO reuse, this could be in the abstract base
// TODO consider adding finer granularity?
boolean anyByteChanged = false;
for(int n = 0; n < bytes.length && !anyByteChanged; n++)
if(bytes[n].isChanged())
anyByteChanged = true;
// TODO consider adding finer granularity?
boolean anyByteEditing = false;
for(int n = 0; n < bytes.length && !anyByteEditing; n++)
if(bytes[n] instanceof TraditionalMemoryByte)
if(((TraditionalMemoryByte) bytes[n]).isEdited())
anyByteEditing = true;
if(anyByteEditing)
gc.setForeground(fRendering.getTraditionalRendering().getColorEdit());
else if(anyByteChanged)
gc.setForeground(fRendering.getTraditionalRendering().getColorChanged());
else if(isOdd(col))
gc.setForeground(fRendering.getTraditionalRendering().getColorText());
else
gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate());
gc.setBackground(fRendering.getTraditionalRendering().getColorBackground());
}
gc.drawText(fRendering.formatText(bytes,
isLittleEndian, fRendering.getTextMode()), cellWidth * col, cellHeight * i
+ fRendering.getCellPadding());
if(fRendering.isDebug())
gc.drawRectangle(cellWidth * col, cellHeight * i
+ fRendering.getCellPadding(), cellWidth,
cellHeight);
}
}
}
catch(Exception e)
{
fRendering.logError(TraditionalRenderingMessages
.getString("TraditionalRendering.FAILURE_PAINT"), e); //$NON-NLS-1$
}
}
}

View file

@ -0,0 +1,43 @@
/*******************************************************************************
* Copyright (c) 2006 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Ted R Williams (Wind River Systems, Inc.) - initial implementation
*
*******************************************************************************/
package org.eclipse.dd.debug.memory.renderings.traditional;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class TraditionalRenderingMessages
{
private static final String BUNDLE_NAME = "org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRendering_messages"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
private TraditionalRenderingMessages()
{
}
public static String getString(String key)
{
// TODO Auto-generated method stub
try
{
return RESOURCE_BUNDLE.getString(key);
}
catch(MissingResourceException e)
{
return '!' + key + '!';
}
}
}

View file

@ -0,0 +1,22 @@
package org.eclipse.dd.debug.memory.renderings.traditional;
import org.eclipse.ui.plugin.AbstractUIPlugin;
public class TraditionalRenderingPlugin extends AbstractUIPlugin
{
private static TraditionalRenderingPlugin plugin;
public TraditionalRenderingPlugin()
{
super();
plugin = this;
}
/**
* Returns the shared instance.
*/
public static TraditionalRenderingPlugin getDefault() {
return plugin;
}
}

View file

@ -0,0 +1,32 @@
package org.eclipse.dd.debug.memory.renderings.traditional;
/**
* Constant definitions for plug-in preferences
*/
public class TraditionalRenderingPreferenceConstants {
public static final String MEM_COLOR_CHANGED = "memoryColorChanged";
public static final String MEM_USE_GLOBAL_BACKGROUND = "memUseGlobalBackground";
public static final String MEM_COLOR_BACKGROUND = "memoryColorBackground";
public static final String MEM_COLOR_EDIT = "memoryColorEdit";
public static final String MEM_COLOR_TEXT = "memoryColorText";
public static final String MEM_USE_GLOBAL_SELECTION = "memUseGlobalSelection";
public static final String MEM_COLOR_SELECTION = "memoryColorSelection";
public static final String MEM_USE_GLOBAL_TEXT = "memUseGlobalText";
public static final String MEM_LIGHTEN_DARKEN_ALTERNATE_CELLS = "memoryColorScaleTextAlternate";
public static final String MEM_EDIT_BUFFER_SAVE = "memoryEditBufferSave";
public static final String MEM_EDIT_BUFFER_SAVE_ON_ENTER_ONLY = "saveOnEnterCancelOnFocusLost";
public static final String MEM_EDIT_BUFFER_SAVE_ON_ENTER_OR_FOCUS_LOST = "saveOnEnterOrFocusLost";
}

View file

@ -0,0 +1,49 @@
package org.eclipse.dd.debug.memory.renderings.traditional;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
/**
* Class used to initialize default preference values.
*/
public class TraditionalRenderingPreferenceInitializer extends AbstractPreferenceInitializer {
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
public void initializeDefaultPreferences() {
IPreferenceStore store = TraditionalRenderingPlugin.getDefault()
.getPreferenceStore();
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_TEXT, true);
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_BACKGROUND, true);
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_SELECTION, true);
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_COLOR_CHANGED, "255,0,0");
Color systemSelection = Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION);
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_COLOR_SELECTION, systemSelection.getRed()
+ "," + systemSelection.getGreen() + "," + systemSelection.getBlue());
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_LIGHTEN_DARKEN_ALTERNATE_CELLS, "5");
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_COLOR_EDIT, "0,255,0");
Color systemText = Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_COLOR_TEXT, systemText.getRed()
+ "," + systemText.getGreen() + "," + systemText.getBlue());
Color systemBackground = Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_COLOR_BACKGROUND, systemBackground.getRed()
+ "," + systemBackground.getGreen() + "," + systemBackground.getBlue());
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE,
TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE_ON_ENTER_ONLY);
}
}

View file

@ -0,0 +1,80 @@
package org.eclipse.dd.debug.memory.renderings.traditional;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ColorFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
import org.eclipse.jface.preference.ScaleFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
/**
* This class represents a preference page that
* is contributed to the Preferences dialog. By
* subclassing <samp>FieldEditorPreferencePage</samp>, we
* can use the field support built into JFace that allows
* us to create a page that is small and knows how to
* save, restore and apply itself.
* <p>
* This page is used to modify preferences only. They
* are stored in the preference store that belongs to
* the main plug-in class. That way, preferences can
* be accessed directly via the preference store.
*/
public class TraditionalRenderingPreferencePage
extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {
public TraditionalRenderingPreferencePage() {
super(GRID);
setPreferenceStore(TraditionalRenderingPlugin.getDefault().getPreferenceStore());
//setDescription("Traditional Memory Rendering");
}
/**
* Creates the field editors. Field editors are abstractions of
* the common GUI blocks needed to manipulate various types
* of preferences. Each field editor knows how to save and
* restore itself.
*/
public void createFieldEditors() {
addField(new BooleanFieldEditor(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_TEXT,
"Use Global Te&xt Color", getFieldEditorParent()));
addField(new ColorFieldEditor(TraditionalRenderingPreferenceConstants.MEM_COLOR_TEXT,
"&Text Color:", getFieldEditorParent()));
addField(new ScaleFieldEditor(TraditionalRenderingPreferenceConstants.MEM_LIGHTEN_DARKEN_ALTERNATE_CELLS,
"Brighten Alternate Cells", getFieldEditorParent(), 0, 8, 1, 1));
addField(new BooleanFieldEditor(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_BACKGROUND,
"Use Global B&ackground Color", getFieldEditorParent()));
addField(new ColorFieldEditor(TraditionalRenderingPreferenceConstants.MEM_COLOR_BACKGROUND,
"&Background Color:", getFieldEditorParent()));
addField(new ColorFieldEditor(TraditionalRenderingPreferenceConstants.MEM_COLOR_CHANGED,
"&Changed Color:", getFieldEditorParent()));
addField(new ColorFieldEditor(TraditionalRenderingPreferenceConstants.MEM_COLOR_EDIT,
"&Edit Color:", getFieldEditorParent()));
addField(new BooleanFieldEditor(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_SELECTION,
"Use Global Se&lection Color", getFieldEditorParent()));
addField(new ColorFieldEditor(TraditionalRenderingPreferenceConstants.MEM_COLOR_SELECTION,
"&Selection Color:", getFieldEditorParent()));
addField(new RadioGroupFieldEditor(TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE,
"Edit Buffer", 1, new String[][] { { "Save on E&nter, Cancel on Focus Lost", "saveOnEnterCancelOnFocusLost" },
{ "Save on Enter or Focus L&ost", "saveOnEnterOrFocusLost" } }, getFieldEditorParent()));
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
public void init(IWorkbench workbench) {
}
}

View file

@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright (c) 2006 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Ted R Williams (Wind River Systems, Inc.) - initial implementation
*
*******************************************************************************/
package org.eclipse.dd.debug.memory.renderings.traditional;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.ui.memory.IMemoryRendering;
import org.eclipse.debug.ui.memory.IMemoryRenderingTypeDelegate;
public class TraditionalRenderingTypeDelegate
implements IMemoryRenderingTypeDelegate
{
public IMemoryRendering createRendering(String id) throws CoreException {
return new TraditionalRendering(id);
}
}

View file

@ -0,0 +1,36 @@
TraditionalRendering.GO_TO_ADDRESS=Go To Address
TraditionalRendering.RESET_TO_BASE_ADDRESS=Reset To Base Address
TraditionalRendering.REFRESH=Refresh
TraditionalRendering.ADDRESS=Address
TraditionalRendering.BINARY=Binary
TraditionalRendering.TEXT=Text
TraditionalRendering.1_BYTE=1 byte
TraditionalRendering.2_BYTES=2 bytes
TraditionalRendering.4_BYTES=4 bytes
TraditionalRendering.8_BYTES=8 bytes
TraditionalRendering.ISO-8859-1=ISO-8859-1
TraditionalRendering.USASCII=US-ASCII
TraditionalRendering.UTF8=UTF-8
TraditionalRendering.UTF16=UTF-16
TraditionalRendering.BIG=Big
TraditionalRendering.LITTLE=Little
TraditionalRendering.HEX=Hex
TraditionalRendering.DECIMAL_SIGNED=Decimal Signed
TraditionalRendering.DECIMAL_UNSIGNED=Decimal Unsigned
TraditionalRendering.OCTAL=Octal
TraditionalRendering.PANES=Panes
TraditionalRendering.ENDIAN=Endian
TraditionalRendering.CELL_SIZE=Cell Size
TraditionalRendering.RADIX=Radix
TraditionalRendering.RENDERING_NAME=Traditional
TraditionalRendering.FAILURE_RETRIEVE_START_ADDRESS=Failure in retrieving start address.
TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD=Called on non-dispatch thread
TraditionalRendering.FAILURE_READ_MEMORY=Failed reading memory.
TraditionalRendering.FAILURE_WRITE_MEMORY=Error writing memory.
TraditionalRendering.FAILURE_DETERMINE_ADDRESS_SIZE=Failed to determine address size.
TraditionalRendering.FAILURE_POSITION_CURSOR=Failed to position cursor.
TraditionalRendering.FAILURE_START_SELECTION=Failed to start selection.
TraditionalRendering.FAILURE_APPEND_SELECTION=Failed to append selection.
TraditionalRendering.FAILURE_DETERMINE_CELL_LOCATION=Failed to determine cell location.
TraditionalRendering.FAILURE_PAINT=Failed to paint.
TraditionalRendering.FAILURE_COPY_OPERATION=Failed copy operation.