mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Added the Registers and Memory views.
This commit is contained in:
parent
aa3d2c911c
commit
ee8afed69f
33 changed files with 2816 additions and 0 deletions
13
debug/org.eclipse.cdt.debug.ui/.classpath
Normal file
13
debug/org.eclipse.cdt.debug.ui/.classpath
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.core.resources"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.ui"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.debug.ui"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.debug.core"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.cdt.debug.core"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.core.runtime"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.core.boot"/>
|
||||
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
35
debug/org.eclipse.cdt.debug.ui/.project
Normal file
35
debug/org.eclipse.cdt.debug.ui/.project
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.eclipse.cdt.debug.ui</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>org.eclipse.cdt.debug.core</project>
|
||||
<project>org.eclipse.core.boot</project>
|
||||
<project>org.eclipse.core.resources</project>
|
||||
<project>org.eclipse.core.runtime</project>
|
||||
<project>org.eclipse.debug.core</project>
|
||||
<project>org.eclipse.debug.ui</project>
|
||||
<project>org.eclipse.ui</project>
|
||||
</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.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
1
debug/org.eclipse.cdt.debug.ui/build.properties
Normal file
1
debug/org.eclipse.cdt.debug.ui/build.properties
Normal file
|
@ -0,0 +1 @@
|
|||
source.cdebugui.jar = src/
|
Binary file not shown.
After Width: | Height: | Size: 214 B |
Binary file not shown.
After Width: | Height: | Size: 336 B |
Binary file not shown.
After Width: | Height: | Size: 214 B |
Binary file not shown.
After Width: | Height: | Size: 336 B |
11
debug/org.eclipse.cdt.debug.ui/plugin.properties
Normal file
11
debug/org.eclipse.cdt.debug.ui/plugin.properties
Normal file
|
@ -0,0 +1,11 @@
|
|||
######################################################################
|
||||
# (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
# All Rights Reserved.
|
||||
######################################################################
|
||||
|
||||
pluginName=C/C++ Debug UI
|
||||
|
||||
RegistersView.name=Registers
|
||||
MemoryView.name=Memory
|
||||
|
||||
MemoryPreferencePage.name=Memory Views
|
75
debug/org.eclipse.cdt.debug.ui/plugin.xml
Normal file
75
debug/org.eclipse.cdt.debug.ui/plugin.xml
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plugin
|
||||
id="org.eclipse.cdt.debug.ui"
|
||||
name="%pluginName"
|
||||
version="1.0.0"
|
||||
provider-name=""
|
||||
class="org.eclipse.cdt.debug.internal.ui.CDebugUIPlugin">
|
||||
|
||||
<runtime>
|
||||
<library name="cdebugui.jar"/>
|
||||
</runtime>
|
||||
<requires>
|
||||
<import plugin="org.eclipse.core.resources"/>
|
||||
<import plugin="org.eclipse.ui"/>
|
||||
<import plugin="org.eclipse.debug.ui"/>
|
||||
<import plugin="org.eclipse.debug.core"/>
|
||||
<import plugin="org.eclipse.cdt.debug.core"/>
|
||||
</requires>
|
||||
|
||||
|
||||
<!-- Extensions -->
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.debugModelPresentations">
|
||||
<debugModelPresentation
|
||||
class="org.eclipse.cdt.debug.internal.ui.CDTDebugModelPresentation"
|
||||
id="org.eclipse.cdt.debug.internal.ui.CDTDebugModelPresentation">
|
||||
</debugModelPresentation>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.views">
|
||||
<view
|
||||
name="%RegistersView.name"
|
||||
icon="icons/full/cview16/registers_view.gif"
|
||||
category="org.eclipse.debug.ui"
|
||||
class="org.eclipse.cdt.debug.internal.ui.views.registers.RegistersView"
|
||||
id="org.eclipse.cdt.debug.ui.RegistersView">
|
||||
</view>
|
||||
<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>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.perspectiveExtensions">
|
||||
<perspectiveExtension
|
||||
targetID="org.eclipse.debug.ui.DebugPerspective">
|
||||
<view
|
||||
relative="org.eclipse.debug.ui.VariableView"
|
||||
relationship="stack"
|
||||
id="org.eclipse.cdt.debug.ui.RegistersView">
|
||||
</view>
|
||||
</perspectiveExtension>
|
||||
<perspectiveExtension
|
||||
targetID="org.eclipse.debug.ui.DebugPerspective">
|
||||
<view
|
||||
relative="org.eclipse.debug.ui.VariableView"
|
||||
relationship="org.eclipse.cdt.debug.ui.view2"
|
||||
id="org.eclipse.cdt.debug.ui.MemoryView">
|
||||
</view>
|
||||
</perspectiveExtension>
|
||||
</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>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui;
|
||||
|
||||
import org.eclipse.debug.core.model.IValue;
|
||||
import org.eclipse.debug.ui.IDebugModelPresentation;
|
||||
import org.eclipse.debug.ui.IValueDetailListener;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
|
||||
/**
|
||||
*
|
||||
* Responsible for providing labels, images, and editors associated
|
||||
* with debug elements in the CDT debug model.
|
||||
*
|
||||
* @since Jul 22, 2002
|
||||
*/
|
||||
public class CDTDebugModelPresentation extends LabelProvider
|
||||
implements IDebugModelPresentation
|
||||
{
|
||||
private static CDTDebugModelPresentation fInstance = null;
|
||||
|
||||
/**
|
||||
* Constructor for CDTDebugModelPresentation.
|
||||
*/
|
||||
public CDTDebugModelPresentation()
|
||||
{
|
||||
super();
|
||||
fInstance = new CDTDebugModelPresentation();
|
||||
}
|
||||
|
||||
public static CDTDebugModelPresentation getDefault()
|
||||
{
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.IDebugModelPresentation#setAttribute(String, Object)
|
||||
*/
|
||||
public void setAttribute( String attribute, Object value )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.IDebugModelPresentation#computeDetail(IValue, IValueDetailListener)
|
||||
*/
|
||||
public void computeDetail( IValue value, IValueDetailListener listener )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.ISourcePresentation#getEditorInput(Object)
|
||||
*/
|
||||
public IEditorInput getEditorInput( Object element )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.ISourcePresentation#getEditorId(IEditorInput, Object)
|
||||
*/
|
||||
public String getEditorId( IEditorInput input, Object element )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
package org.eclipse.cdt.debug.internal.ui;
|
||||
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval;
|
||||
import org.eclipse.cdt.debug.internal.ui.preferences.MemoryViewPreferencePage;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPluginDescriptor;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.PreferenceConverter;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
|
||||
/**
|
||||
* The main plugin class to be used in the desktop.
|
||||
*/
|
||||
public class CDebugUIPlugin extends AbstractUIPlugin
|
||||
{
|
||||
//The shared instance.
|
||||
private static CDebugUIPlugin plugin;
|
||||
//Resource bundle.
|
||||
private ResourceBundle resourceBundle;
|
||||
|
||||
/**
|
||||
* The constructor.
|
||||
*/
|
||||
public CDebugUIPlugin( IPluginDescriptor descriptor )
|
||||
{
|
||||
super( descriptor );
|
||||
plugin = this;
|
||||
try
|
||||
{
|
||||
resourceBundle =
|
||||
ResourceBundle.getBundle( "org.eclipse.cdt.debug.ui.CDebugUIPluginResources" );
|
||||
}
|
||||
catch( MissingResourceException x )
|
||||
{
|
||||
resourceBundle = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance.
|
||||
*/
|
||||
public static CDebugUIPlugin getDefault()
|
||||
{
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the workspace instance.
|
||||
*/
|
||||
public static IWorkspace getWorkspace()
|
||||
{
|
||||
return ResourcesPlugin.getWorkspace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string from the plugin's resource bundle,
|
||||
* or 'key' if not found.
|
||||
*/
|
||||
public static String getResourceString(String key)
|
||||
{
|
||||
ResourceBundle bundle = CDebugUIPlugin.getDefault().getResourceBundle();
|
||||
try
|
||||
{
|
||||
return bundle.getString( key );
|
||||
}
|
||||
catch ( MissingResourceException e )
|
||||
{
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the plugin's resource bundle,
|
||||
*/
|
||||
public ResourceBundle getResourceBundle()
|
||||
{
|
||||
return resourceBundle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which returns the unique identifier of this plugin.
|
||||
*/
|
||||
public static String getUniqueIdentifier()
|
||||
{
|
||||
if ( getDefault() == null )
|
||||
{
|
||||
// If the default instance is not yet initialized,
|
||||
// return a static identifier. This identifier must
|
||||
// match the plugin id defined in plugin.xml
|
||||
return "org.eclipse.cdt.debug.ui"; //$NON-NLS-1$
|
||||
}
|
||||
return getDefault().getDescriptor().getUniqueIdentifier();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the a color based on the type of output.
|
||||
* Valid types:
|
||||
* <li>CHANGED_REGISTER_RGB</li>
|
||||
*/
|
||||
public static Color getPreferenceColor( String type )
|
||||
{
|
||||
return ColorManager.getDefault().getColor(
|
||||
PreferenceConverter.getColor( getDefault().getPreferenceStore(), type ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AbstractUIPlugin#initializeDefaultPreferences
|
||||
*/
|
||||
protected void initializeDefaultPreferences( IPreferenceStore pstore )
|
||||
{
|
||||
MemoryViewPreferencePage.initDefaults( pstore );
|
||||
}
|
||||
|
||||
public static CDTDebugModelPresentation getDebugModelPresentation()
|
||||
{
|
||||
return CDTDebugModelPresentation.getDefault();
|
||||
}
|
||||
|
||||
public void addBlock( IFormattedMemoryRetrieval mbr, IFormattedMemoryBlock memoryBlock )
|
||||
{
|
||||
}
|
||||
|
||||
public void removeBlock( IFormattedMemoryRetrieval mbr, IFormattedMemoryBlock memoryBlock )
|
||||
{
|
||||
}
|
||||
|
||||
public void removeAllBlocks( IFormattedMemoryRetrieval mbr )
|
||||
{
|
||||
}
|
||||
|
||||
public IFormattedMemoryBlock getBlock( IFormattedMemoryRetrieval mbr, int index )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public IFormattedMemoryBlock[] getBlocks( IFormattedMemoryRetrieval mbr )
|
||||
{
|
||||
return new IFormattedMemoryBlock[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui;
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter type comment.
|
||||
*
|
||||
* @since Jul 30, 2002
|
||||
*/
|
||||
public class CDebugUIUtils
|
||||
{
|
||||
static public String toHexAddressString( long address )
|
||||
{
|
||||
String tmp = Long.toHexString( address );
|
||||
char[] prefix = new char[10 - tmp.length()];
|
||||
prefix[0] = '0';
|
||||
prefix[1] = 'x';
|
||||
for ( int i = 2; i < prefix.length; ++i )
|
||||
prefix[i] = '0';
|
||||
return new String( prefix ) + tmp;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
/**
|
||||
*
|
||||
* Color manager for C/C++ Debug UI.
|
||||
*
|
||||
* @since Jul 23, 2002
|
||||
*/
|
||||
public class ColorManager
|
||||
{
|
||||
private static ColorManager fgColorManager;
|
||||
|
||||
private ColorManager()
|
||||
{
|
||||
}
|
||||
|
||||
public static ColorManager getDefault()
|
||||
{
|
||||
if ( fgColorManager == null )
|
||||
{
|
||||
fgColorManager = new ColorManager();
|
||||
}
|
||||
return fgColorManager;
|
||||
}
|
||||
|
||||
protected Map fColorTable = new HashMap( 10 );
|
||||
|
||||
public Color getColor( RGB rgb )
|
||||
{
|
||||
Color color = (Color)fColorTable.get( rgb );
|
||||
if ( color == null )
|
||||
{
|
||||
color = new Color( Display.getCurrent(), rgb );
|
||||
fColorTable.put( rgb, color );
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
Iterator e = fColorTable.values().iterator();
|
||||
while( e.hasNext() )
|
||||
((Color)e.next()).dispose();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui;
|
||||
|
||||
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
|
||||
|
||||
/**
|
||||
*
|
||||
* Help context ids for the C/C++ debug ui.
|
||||
* <p>
|
||||
* This interface contains constants only; it is not intended to be implemented
|
||||
* or extended.
|
||||
* </p>
|
||||
*
|
||||
* @since Jul 23, 2002
|
||||
*/
|
||||
public interface ICDebugHelpContextIds
|
||||
{
|
||||
public static final String PREFIX = ICDebugUIConstants.PLUGIN_ID + "."; //$NON-NLS-1$
|
||||
|
||||
// Views
|
||||
public static final String REGISTERS_VIEW = PREFIX + "registers_view_context"; //$NON-NLS-1$
|
||||
public static final String MEMORY_VIEW = PREFIX + "memory_view_context"; //$NON-NLS-1$
|
||||
|
||||
// Preference pages
|
||||
public static final String MEMORY_PREFERENCE_PAGE = PREFIX + "memory_preference_page_context"; //$NON-NLS-1$
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui;
|
||||
|
||||
/**
|
||||
*
|
||||
* Definitions of the internal constants for C/C++ Debug UI plug-in.
|
||||
*
|
||||
* @since Jul 25, 2002
|
||||
*/
|
||||
public interface ICDebugUIInternalConstants
|
||||
{
|
||||
/*
|
||||
* Memory view constants.
|
||||
*/
|
||||
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;
|
||||
|
||||
public static final int DEFAULT_MEMORY_NUMBER_OF_BYTES = 512;
|
||||
public static final int DEFAULT_MEMORY_SIZE = MEMORY_SIZE_BYTE;
|
||||
public static final int DEFAULT_MEMORY_FORMAT = MEMORY_FORMAT_HEX;
|
||||
public static final int DEFAULT_MEMORY_BYTES_PER_ROW = MEMORY_BYTES_PER_ROW_16;
|
||||
public static final boolean DEFAULT_MEMORY_DISPLAY_ASCII = true;
|
||||
}
|
|
@ -0,0 +1,178 @@
|
|||
package org.eclipse.cdt.debug.internal.ui.preferences;
|
||||
|
||||
/*
|
||||
* (c) Copyright IBM Corp. 2000, 2001.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
import org.eclipse.jface.preference.FieldEditor;
|
||||
import org.eclipse.jface.util.Assert;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
|
||||
/**
|
||||
* A field editor for a combo box that allows the drop-down selection of one of a list of items.
|
||||
*/
|
||||
public class ComboFieldEditor extends FieldEditor {
|
||||
|
||||
/**
|
||||
* The <code>Combo</code> widget.
|
||||
*/
|
||||
private Combo fCombo;
|
||||
|
||||
/**
|
||||
* The value (not the name) of the currently selected item in the Combo widget.
|
||||
*/
|
||||
private String fValue;
|
||||
|
||||
/**
|
||||
* The names (labels) and underlying values to populate the combo widget. These should be
|
||||
* arranged as: { {name1, value1}, {name2, value2}, ...}
|
||||
*/
|
||||
private String[][] fEntryNamesAndValues;
|
||||
|
||||
public ComboFieldEditor(String name, String labelText, String[][] entryNamesAndValues, Composite parent) {
|
||||
init(name, labelText);
|
||||
Assert.isTrue(checkArray(entryNamesAndValues));
|
||||
fEntryNamesAndValues = entryNamesAndValues;
|
||||
createControl(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether given <code>String[][]</code> is of "type"
|
||||
* <code>String[][2]</code>.
|
||||
*
|
||||
* @return <code>true</code> if it is ok, and <code>false</code> otherwise
|
||||
*/
|
||||
private boolean checkArray(String[][] table) {
|
||||
if (table == null) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < table.length; i++) {
|
||||
String[] array = table[i];
|
||||
if (array == null || array.length != 2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FieldEditor#adjustForNumColumns(int)
|
||||
*/
|
||||
protected void adjustForNumColumns(int numColumns) {
|
||||
if ( numColumns <= 1 )
|
||||
return;
|
||||
int span = numColumns;
|
||||
Control control = getLabelControl();
|
||||
if (control != null) {
|
||||
((GridData)control.getLayoutData()).horizontalSpan = 1;
|
||||
--span;
|
||||
}
|
||||
((GridData)fCombo.getLayoutData()).horizontalSpan = span;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FieldEditor#doFillIntoGrid(Composite, int)
|
||||
*/
|
||||
protected void doFillIntoGrid(Composite parent, int numColumns) {
|
||||
Control control = getLabelControl(parent);
|
||||
GridData gd = new GridData();
|
||||
gd.horizontalSpan = numColumns;
|
||||
control.setLayoutData(gd);
|
||||
control = getComboBoxControl(parent);
|
||||
gd = new GridData();
|
||||
gd.horizontalSpan = numColumns;
|
||||
control.setLayoutData(gd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FieldEditor#doLoad()
|
||||
*/
|
||||
protected void doLoad() {
|
||||
updateComboForValue(getPreferenceStore().getString(getPreferenceName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FieldEditor#doLoadDefault()
|
||||
*/
|
||||
protected void doLoadDefault() {
|
||||
updateComboForValue(getPreferenceStore().getDefaultString(getPreferenceName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FieldEditor#doStore()
|
||||
*/
|
||||
protected void doStore() {
|
||||
if (fValue == null) {
|
||||
getPreferenceStore().setToDefault(getPreferenceName());
|
||||
return;
|
||||
}
|
||||
|
||||
getPreferenceStore().setValue(getPreferenceName(), fValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FieldEditor#getNumberOfControls()
|
||||
*/
|
||||
public int getNumberOfControls() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazily create and return the Combo control.
|
||||
*/
|
||||
public Combo getComboBoxControl(Composite parent) {
|
||||
if (fCombo == null) {
|
||||
fCombo = new Combo(parent, SWT.READ_ONLY);
|
||||
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
|
||||
fCombo.add(fEntryNamesAndValues[i][0], i);
|
||||
}
|
||||
|
||||
fCombo.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent evt) {
|
||||
String oldValue = fValue;
|
||||
String name = fCombo.getText();
|
||||
fValue = getValueForName(name);
|
||||
setPresentsDefaultValue(false);
|
||||
fireValueChanged(VALUE, oldValue, fValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
return fCombo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the name (label) of an entry, return the corresponding value.
|
||||
*/
|
||||
protected String getValueForName(String name) {
|
||||
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
|
||||
String[] entry = fEntryNamesAndValues[i];
|
||||
if (name.equals(entry[0])) {
|
||||
return entry[1];
|
||||
}
|
||||
}
|
||||
return fEntryNamesAndValues[0][0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name in the combo widget to match the specified value.
|
||||
*/
|
||||
protected void updateComboForValue(String value) {
|
||||
fValue = value;
|
||||
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
|
||||
if (value.equals(fEntryNamesAndValues[i][1])) {
|
||||
fCombo.setText(fEntryNamesAndValues[i][0]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (fEntryNamesAndValues.length > 0) {
|
||||
fValue = fEntryNamesAndValues[0][1];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.preferences;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.ICDebugUIInternalConstants;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.FontData;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
/**
|
||||
*
|
||||
* Constants defining the keys to be used for accessing preferences
|
||||
* inside the debug ui plugin's preference bundle.
|
||||
*
|
||||
* In descriptions (of the keys) below describe the preference
|
||||
* stored at the given key. The type indicates type of the stored preferences
|
||||
*
|
||||
* The preference store is loaded by the plugin (CDebugUIPlugin).
|
||||
* @see CDebugUIPlugin.initializeDefaultPreferences(IPreferenceStore) - for initialization of the store
|
||||
*
|
||||
* @since Jul 23, 2002
|
||||
*/
|
||||
public interface ICDebugPreferenceConstants
|
||||
{
|
||||
/**
|
||||
* The RGB for the color to be used to indicate changed registers
|
||||
*/
|
||||
public static final String CHANGED_REGISTER_RGB = "Changed.Register.RGB"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The default values for the memory view parameters.
|
||||
*/
|
||||
public static final String DEFAULT_MEMORY_PADDING_CHAR = ".";
|
||||
public static final FontData DEFAULT_MEMORY_FONT = Display.getDefault().getSystemFont().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";
|
||||
public static final String PREF_MEMORY_SIZE = "Memory.Size";
|
||||
public static final String PREF_MEMORY_FORMAT = "Memory.Format";
|
||||
public static final String PREF_MEMORY_BYTES_PER_ROW = "Memory.BytesPerRow";
|
||||
public static final String PREF_MEMORY_DISPLAY_ASCII = "Memory.DisplayASCII";
|
||||
public static final String PREF_MEMORY_PADDING_CHAR = "Memory.PaddingChar";
|
||||
|
||||
/**
|
||||
* 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$
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.preferences;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||
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.graphics.RGB;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.eclipse.ui.help.WorkbenchHelp;
|
||||
import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter type comment.
|
||||
*
|
||||
* @since Jul 25, 2002
|
||||
*/
|
||||
public class MemoryViewPreferencePage extends FieldEditorPreferencePage
|
||||
implements IWorkbenchPreferencePage
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor for MemoryViewPreferencePage.
|
||||
* @param style
|
||||
*/
|
||||
public MemoryViewPreferencePage()
|
||||
{
|
||||
super( GRID );
|
||||
setDescription( "Debug Memory View Settings." );
|
||||
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, "Text Color:", getFieldEditorParent() );
|
||||
ColorFieldEditor background = new ColorFieldEditor( ICDebugPreferenceConstants.MEMORY_BACKGROUND_RGB, "Background Color:", getFieldEditorParent() );
|
||||
ColorFieldEditor address = new ColorFieldEditor( ICDebugPreferenceConstants.MEMORY_ADDRESS_RGB, "Address Color:", getFieldEditorParent() );
|
||||
ColorFieldEditor changed = new ColorFieldEditor( ICDebugPreferenceConstants.MEMORY_CHANGED_RGB, "Changed Value Color:", getFieldEditorParent() );
|
||||
ColorFieldEditor dirty = new ColorFieldEditor( ICDebugPreferenceConstants.MEMORY_DIRTY_RGB, "Modified Value Color:", getFieldEditorParent() );
|
||||
|
||||
FontFieldEditor font = new FontFieldEditor( ICDebugPreferenceConstants.MEMORY_FONT, "Font:", getFieldEditorParent() );
|
||||
|
||||
addField( foreground );
|
||||
addField( background );
|
||||
addField( address );
|
||||
addField( changed );
|
||||
addField( dirty );
|
||||
addField( font );
|
||||
|
||||
StringFieldEditor paddingChar = new StringFieldEditor( ICDebugPreferenceConstants.PREF_MEMORY_PADDING_CHAR, "Padding Character:", 1, getFieldEditorParent() );
|
||||
paddingChar.setTextLimit( 1 );
|
||||
addField( paddingChar );
|
||||
}
|
||||
|
||||
/* (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 );
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,220 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.views;
|
||||
|
||||
import org.eclipse.debug.core.DebugEvent;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.IDebugEventSetListener;
|
||||
import org.eclipse.debug.ui.AbstractDebugView;
|
||||
import org.eclipse.jface.viewers.IBasicPropertyConstants;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
|
||||
/**
|
||||
*
|
||||
* Handles debug events, updating a view and viewer.
|
||||
*
|
||||
* @since Jul 23, 2002
|
||||
*/
|
||||
public abstract class AbstractDebugEventHandler implements IDebugEventSetListener
|
||||
{
|
||||
/**
|
||||
* This event handler's view
|
||||
*/
|
||||
private AbstractDebugView fView;
|
||||
|
||||
/**
|
||||
* Constructs an event handler for the given view.
|
||||
*
|
||||
* @param view debug view
|
||||
*/
|
||||
public AbstractDebugEventHandler( AbstractDebugView view )
|
||||
{
|
||||
setView( view );
|
||||
DebugPlugin plugin = DebugPlugin.getDefault();
|
||||
plugin.addDebugEventListener( this );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IDebugEventSetListener#handleDebugEvents(DebugEvent[])
|
||||
*/
|
||||
public void handleDebugEvents( final DebugEvent[] events )
|
||||
{
|
||||
if ( !isAvailable() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
Runnable r = new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if ( isAvailable() )
|
||||
{
|
||||
doHandleDebugEvents( events );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getView().asyncExec( r );
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation specific handling of debug events.
|
||||
* Subclasses should override.
|
||||
*/
|
||||
protected abstract void doHandleDebugEvents( DebugEvent[] events );
|
||||
|
||||
/**
|
||||
* Helper method for inserting the given element - must be called in UI thread
|
||||
*/
|
||||
protected void insert( Object element )
|
||||
{
|
||||
if ( isAvailable() )
|
||||
{
|
||||
final Object parent =
|
||||
(
|
||||
(ITreeContentProvider)getTreeViewer().getContentProvider()).getParent( element );
|
||||
// a parent can be null for a debug target or process that has not yet been associated
|
||||
// with a launch
|
||||
if ( parent != null )
|
||||
{
|
||||
getView().showViewer();
|
||||
getTreeViewer().add( parent, element );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to remove the given element - must be called in UI thread.
|
||||
*/
|
||||
protected void remove( Object element )
|
||||
{
|
||||
if ( isAvailable() )
|
||||
{
|
||||
getView().showViewer();
|
||||
getTreeViewer().remove( element );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to update the label of the given element - must be called in UI thread
|
||||
*/
|
||||
protected void labelChanged( Object element )
|
||||
{
|
||||
if ( isAvailable() )
|
||||
{
|
||||
getView().showViewer();
|
||||
getTreeViewer().update( element,
|
||||
new String[] { IBasicPropertyConstants.P_TEXT } );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the given element in the viewer - must be called in UI thread.
|
||||
*/
|
||||
protected void refresh( Object element )
|
||||
{
|
||||
if ( isAvailable() )
|
||||
{
|
||||
getView().showViewer();
|
||||
getTreeViewer().refresh( element );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the viewer - must be called in UI thread.
|
||||
*/
|
||||
public void refresh()
|
||||
{
|
||||
if ( isAvailable() )
|
||||
{
|
||||
getView().showViewer();
|
||||
getTreeViewer().refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to select and reveal the given element - must be called in UI thread
|
||||
*/
|
||||
protected void selectAndReveal( Object element )
|
||||
{
|
||||
if ( isAvailable() )
|
||||
{
|
||||
getViewer().setSelection( new StructuredSelection( element ), true );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* De-registers this event handler from the debug model.
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
DebugPlugin plugin = DebugPlugin.getDefault();
|
||||
plugin.removeDebugEventListener( this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the view this event handler is
|
||||
* updating.
|
||||
*
|
||||
* @return debug view
|
||||
*/
|
||||
protected AbstractDebugView getView()
|
||||
{
|
||||
return fView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the view this event handler is updating.
|
||||
*
|
||||
* @param view debug view
|
||||
*/
|
||||
private void setView( AbstractDebugView view )
|
||||
{
|
||||
fView = view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the viewer this event handler is updating.
|
||||
*
|
||||
* @return viewer
|
||||
*/
|
||||
protected Viewer getViewer()
|
||||
{
|
||||
return getView().getViewer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this event handler's viewer as a tree
|
||||
* viewer or <code>null</code> if none.
|
||||
*
|
||||
* @return this event handler's viewer as a tree
|
||||
* viewer or <code>null</code> if none
|
||||
*/
|
||||
protected TreeViewer getTreeViewer()
|
||||
{
|
||||
if ( getViewer() instanceof TreeViewer )
|
||||
{
|
||||
return (TreeViewer)getViewer();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this event handler's viewer is
|
||||
* currently available.
|
||||
*
|
||||
* @return whether this event handler's viewer is
|
||||
* currently available
|
||||
*/
|
||||
protected boolean isAvailable()
|
||||
{
|
||||
return getView().isAvailable();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.views;
|
||||
|
||||
import org.eclipse.debug.ui.AbstractDebugView;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
/**
|
||||
*
|
||||
* A debug view that uses an event handler to update its view/viewer.
|
||||
*
|
||||
* @since Jul 23, 2002
|
||||
*/
|
||||
public abstract class AbstractDebugEventHandlerView extends AbstractDebugView
|
||||
{
|
||||
/**
|
||||
* Event handler for this view
|
||||
*/
|
||||
private AbstractDebugEventHandler fEventHandler;
|
||||
|
||||
/**
|
||||
* Sets the event handler for this view
|
||||
*
|
||||
* @param eventHandler event handler
|
||||
*/
|
||||
protected void setEventHandler( AbstractDebugEventHandler eventHandler )
|
||||
{
|
||||
fEventHandler = eventHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event handler for this view
|
||||
*
|
||||
* @return The event handler for this view
|
||||
*/
|
||||
protected AbstractDebugEventHandler getEventHandler()
|
||||
{
|
||||
return fEventHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IWorkbenchPart#dispose()
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
if ( getEventHandler() != null )
|
||||
{
|
||||
getEventHandler().dispose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* (c) Copyright IBM Corp. 2000, 2001.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.views;
|
||||
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
|
||||
/**
|
||||
* A plugable exception handler.
|
||||
*/
|
||||
public interface IDebugExceptionHandler
|
||||
{
|
||||
/**
|
||||
* Handles the given debug exception.
|
||||
*
|
||||
* @param e debug exception
|
||||
*/
|
||||
public abstract void handleException( DebugException e );
|
||||
}
|
|
@ -0,0 +1,182 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.views.memory;
|
||||
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval;
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
|
||||
import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.KeyAdapter;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
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.
|
||||
*
|
||||
* @since Jul 25, 2002
|
||||
*/
|
||||
public class MemoryControlArea extends Composite
|
||||
{
|
||||
private MemoryPresentation fPresentation;
|
||||
private int fIndex = 0;
|
||||
private IFormattedMemoryRetrieval fInput = null;
|
||||
private IFormattedMemoryBlock fMemoryBlock = null;
|
||||
|
||||
private Text fAddressText;
|
||||
private MemoryText fMemoryText;
|
||||
/**
|
||||
* Constructor for MemoryControlArea.
|
||||
* @param parent
|
||||
* @param style
|
||||
*/
|
||||
public MemoryControlArea( Composite parent, int style, int index )
|
||||
{
|
||||
super( parent, style );
|
||||
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 );
|
||||
fIndex = index;
|
||||
fPresentation = createPresentation();
|
||||
fAddressText = createAddressText( this );
|
||||
fMemoryText = createMemoryText( this, style, fPresentation );
|
||||
}
|
||||
|
||||
private MemoryPresentation createPresentation()
|
||||
{
|
||||
IPreferenceStore pstore = CDebugUIPlugin.getDefault().getPreferenceStore();
|
||||
char[] paddingCharStr = pstore.getString( ICDebugPreferenceConstants.PREF_MEMORY_PADDING_CHAR ).toCharArray();
|
||||
char paddingChar = ( paddingCharStr.length > 0 ) ? paddingCharStr[0] : '.';
|
||||
return new MemoryPresentation();
|
||||
}
|
||||
|
||||
public MemoryPresentation getPresentation()
|
||||
{
|
||||
return fPresentation;
|
||||
}
|
||||
|
||||
private Text createAddressText( Composite parent )
|
||||
{
|
||||
Composite composite = new Composite( parent, SWT.NONE );
|
||||
composite.setLayout( new GridLayout( 2, false ) );
|
||||
composite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
|
||||
// create label
|
||||
Label label = new Label( composite, SWT.RIGHT );
|
||||
label.setText( "Address: " );
|
||||
label.pack();
|
||||
|
||||
// create address text
|
||||
Text text = new Text( composite, SWT.BORDER );
|
||||
text.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
|
||||
text.addKeyListener( new KeyAdapter()
|
||||
{
|
||||
public void keyReleased( KeyEvent e )
|
||||
{
|
||||
if ( e.character == SWT.CR && e.stateMask == 0 )
|
||||
handleAddressEnter();
|
||||
}
|
||||
} );
|
||||
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 );
|
||||
}
|
||||
|
||||
private void handleAddressEnter()
|
||||
{
|
||||
String address = fAddressText.getText().trim();
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
// updatePresentation( event );
|
||||
// fMemoryText.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public void setInput( IFormattedMemoryRetrieval input )
|
||||
{
|
||||
fInput = input;
|
||||
fMemoryBlock = CDebugUIPlugin.getDefault().getBlock( fInput, fIndex );
|
||||
fPresentation.setMemoryBlock( fMemoryBlock );
|
||||
refresh();
|
||||
}
|
||||
|
||||
private void refresh()
|
||||
{
|
||||
fAddressText.setText( fPresentation.getStartAddress() );
|
||||
fMemoryText.refresh();
|
||||
}
|
||||
/*
|
||||
private void updatePresentation( PropertyChangeEvent event )
|
||||
{
|
||||
if ( event.getProperty().equals( ICDebugPreferenceConstants.PREF_MEMORY_SIZE ) )
|
||||
{
|
||||
fPresentation.setSize( CDebugUIPlugin.getDefault().getPreferenceStore().getInt( ICDebugPreferenceConstants.PREF_MEMORY_SIZE ) );
|
||||
}
|
||||
else if ( event.getProperty().equals( ICDebugPreferenceConstants.PREF_MEMORY_BYTES_PER_ROW ) )
|
||||
{
|
||||
fPresentation.setBytesPerRow( CDebugUIPlugin.getDefault().getPreferenceStore().getInt( ICDebugPreferenceConstants.PREF_MEMORY_BYTES_PER_ROW ) );
|
||||
}
|
||||
else if ( event.getProperty().equals( ICDebugPreferenceConstants.PREF_MEMORY_DISPLAY_ASCII ) )
|
||||
{
|
||||
fPresentation.setDisplayASCII( CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_MEMORY_DISPLAY_ASCII ) );
|
||||
}
|
||||
else if ( event.getProperty().equals( ICDebugPreferenceConstants.PREF_MEMORY_FORMAT ) )
|
||||
{
|
||||
fPresentation.setFormat( CDebugUIPlugin.getDefault().getPreferenceStore().getInt( ICDebugPreferenceConstants.PREF_MEMORY_FORMAT ) );
|
||||
}
|
||||
else if ( event.getProperty().equals( ICDebugPreferenceConstants.PREF_MEMORY_PADDING_CHAR ) )
|
||||
{
|
||||
fPresentation.setPaddingChar( CDebugUIPlugin.getDefault().getPreferenceStore().getString( ICDebugPreferenceConstants.PREF_MEMORY_PADDING_CHAR ).charAt( 0 ) );
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,261 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.views.memory;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryBlockRow;
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
|
||||
/**
|
||||
*
|
||||
* Provides rendering methods to the MemoryText widget.
|
||||
*
|
||||
* @since Jul 25, 2002
|
||||
*/
|
||||
public class MemoryPresentation
|
||||
{
|
||||
static final private char NOT_AVAILABLE_CHAR = '?';
|
||||
|
||||
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 List fDirtyZones;
|
||||
|
||||
/**
|
||||
* Constructor for MemoryPresentation.
|
||||
*/
|
||||
public MemoryPresentation()
|
||||
{
|
||||
fAddressZones = new LinkedList();
|
||||
fChangedZones = new LinkedList();
|
||||
fDirtyZones = 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 = fBlock.getRows();
|
||||
String text = new String();
|
||||
for ( int i = 0; i < rows.length; ++i )
|
||||
{
|
||||
int offset = text.length();
|
||||
text += getRowText( rows[i] );
|
||||
fAddressZones.add( new Point( offset, offset + getAddressLength() ) );
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public int getItemSize( int offset )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void setItem( int offset, String item )
|
||||
{
|
||||
}
|
||||
|
||||
public String[] getText( Point[] zones )
|
||||
{
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
public boolean isAcceptable( char ch, int offset )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public Point[] getAddressZones()
|
||||
{
|
||||
return (Point[])fAddressZones.toArray( new Point[0] );
|
||||
}
|
||||
|
||||
public Point[] getChangedZones()
|
||||
{
|
||||
return (Point[])fChangedZones.toArray( new Point[0] );
|
||||
}
|
||||
|
||||
public Point[] getDirtyZones()
|
||||
{
|
||||
return (Point[])fDirtyZones.toArray( new Point[0] );
|
||||
}
|
||||
|
||||
public String getStartAddress()
|
||||
{
|
||||
return ( fBlock != null ) ? getAddressString( fBlock.getStartAddress() ) : "";
|
||||
}
|
||||
|
||||
private String getInterval( int length )
|
||||
{
|
||||
char[] chars = new char[length];
|
||||
for ( int i = 0; i < chars.length; ++i )
|
||||
chars[i] = ' ';
|
||||
return new String( chars );
|
||||
}
|
||||
|
||||
private String getAddressString( long address )
|
||||
{
|
||||
return CDebugUIUtils.toHexAddressString( address );
|
||||
}
|
||||
|
||||
private String getRowText( IFormattedMemoryBlockRow row )
|
||||
{
|
||||
String result = getAddressString( row.getAddress() ) +
|
||||
getInterval( INTERVAL_BETWEEN_ADDRESS_AND_DATA );
|
||||
String[] items = row.getData();
|
||||
for ( int i = 0; i < items.length; ++i )
|
||||
result += items[i] + getInterval( INTERVAL_BETWEEN_DATA_ITEMS );
|
||||
result += getInterval( INTERVAL_BETWEEN_DATA_AND_ASCII ) + row.getASCII() + '\n';
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
private String getItemString( int offset )
|
||||
{
|
||||
byte[] data = getDataBytes();
|
||||
String item = new String( data, offset, getSize() );
|
||||
String result = "";
|
||||
switch( fFormat )
|
||||
{
|
||||
case ICDebugUIInternalConstants.MEMORY_FORMAT_HEX:
|
||||
for ( int i = 0; i < getSize(); ++i )
|
||||
result += new String( charToBytes( item.charAt( i ) ) );
|
||||
break;
|
||||
case ICDebugUIInternalConstants.MEMORY_FORMAT_BINARY:
|
||||
for ( int i = 0; i < getSize(); ++i )
|
||||
result += prepend( Integer.toBinaryString( data[offset + i] ), '0', 8 );
|
||||
break;
|
||||
case ICDebugUIInternalConstants.MEMORY_FORMAT_OCTAL:
|
||||
for ( int i = 0; i < getSize(); ++i )
|
||||
result += Integer.toOctalString( data[offset + i] );
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String getASCIIString( int offset )
|
||||
{
|
||||
byte[] data = getDataBytes();
|
||||
char[] ascii = new char[getBytesPerRow()];
|
||||
for ( int i = 0; i < ascii.length; ++i )
|
||||
{
|
||||
ascii[i] = ( data.length > offset + i ) ? getChar( data[offset + i] ) : fNotAvailableChar;
|
||||
}
|
||||
return new String( ascii );
|
||||
}
|
||||
|
||||
private char getChar( byte charByte )
|
||||
{
|
||||
char ch = (char)charByte;
|
||||
if ( ch == fNotAvailableChar )
|
||||
return fNotAvailableChar;
|
||||
return ( Character.isISOControl( ch ) ) ? fPaddingChar : ch;
|
||||
}
|
||||
|
||||
private char[] charToBytes( char ch )
|
||||
{
|
||||
return new char[]{ charFromByte( (char)(ch >>> 4) ),
|
||||
charFromByte( (char)(ch & 0x0f) ) };
|
||||
}
|
||||
|
||||
private char charFromByte( char value )
|
||||
{
|
||||
if ( value >= 0x0 && value <= 0x9 )
|
||||
return (char)(value + '0');
|
||||
if ( value >= 0xa && value <= 0xf )
|
||||
return (char)(value - 0xa + 'a');
|
||||
return '0';
|
||||
}
|
||||
|
||||
private byte[] getDataBytes()
|
||||
{
|
||||
return new byte[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
||||
/*
|
||||
byte[] result = new byte[0];
|
||||
if ( fBlock != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
result = fBlock.getBytes();
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return result;
|
||||
*/
|
||||
/*
|
||||
}
|
||||
*/
|
||||
private String resize( String item, char ch, int size )
|
||||
{
|
||||
char[] chars = new char[size - item.length()];
|
||||
for ( int i = 0; i < chars.length; ++i )
|
||||
chars[i] = ch;
|
||||
return String.valueOf( chars ).concat( item );
|
||||
}
|
||||
/*
|
||||
private int getRowLength()
|
||||
{
|
||||
return getAddressLength() +
|
||||
INTERVAL_BETWEEN_ADDRESS_AND_DATA +
|
||||
(getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS ) * getNumberOfDataItems() +
|
||||
( ( displayASCII() ) ? INTERVAL_BETWEEN_DATA_AND_ASCII +
|
||||
getBytesPerRow() : 0 ) + 1;
|
||||
}
|
||||
*/
|
||||
private int getAddressLength()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
/*
|
||||
private int getDataItemLength()
|
||||
{
|
||||
int result = 0;
|
||||
switch( getFormat() )
|
||||
{
|
||||
case ICDebugUIInternalConstants.MEMORY_FORMAT_HEX:
|
||||
result = 2 * getSize();
|
||||
break;
|
||||
case ICDebugUIInternalConstants.MEMORY_FORMAT_BINARY:
|
||||
result = 8 * getSize();
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getNumberOfDataItems()
|
||||
{
|
||||
return getBytesPerRow() / getSize();
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,234 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.views.memory;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
private void handleExtendedModify( ExtendedModifyEvent event )
|
||||
{
|
||||
if ( event.length != 1 )
|
||||
return;
|
||||
int offset = fText.getCaretOffset() - 1;
|
||||
int size = fPresentation.getItemSize( offset );
|
||||
fPresentation.setItem( offset, fText.getText().substring( offset, offset + size ) );
|
||||
Point[] zones = fPresentation.getDirtyZones();
|
||||
refresh( zones, fPresentation.getText( zones ) );
|
||||
}
|
||||
|
||||
public void refresh()
|
||||
{
|
||||
fText.setFont( new Font( fText.getDisplay(), getFontData() ) );
|
||||
fText.setBackground( getBackgroundColor() );
|
||||
fText.setForeground( getForegroundColor() );
|
||||
fText.setText( fPresentation.getText() );
|
||||
List list = new LinkedList();
|
||||
Point[] zones = fPresentation.getChangedZones();
|
||||
for ( int i = 0; i < zones.length; ++i )
|
||||
list.add( new StyleRange( zones[i].x,
|
||||
zones[i].y - zones[i].x + 1,
|
||||
getChangedColor(),
|
||||
getBackgroundColor() ) );
|
||||
zones = fPresentation.getAddressZones();
|
||||
for ( int i = 0; i < zones.length; ++i )
|
||||
list.add( new StyleRange( zones[i].x,
|
||||
zones[i].y - zones[i].x + 1,
|
||||
getAddressColor(),
|
||||
getBackgroundColor() ) );
|
||||
zones = fPresentation.getDirtyZones();
|
||||
for ( int i = 0; i < zones.length; ++i )
|
||||
list.add( new StyleRange( zones[i].x,
|
||||
zones[i].y - zones[i].x + 1,
|
||||
getDirtyColor(),
|
||||
getBackgroundColor() ) );
|
||||
fText.setStyleRanges( (StyleRange[])list.toArray( new StyleRange[list.size()] ) );
|
||||
fText.redraw();
|
||||
}
|
||||
|
||||
private void refresh( Point[] zones, String[] items )
|
||||
{
|
||||
int count = ( zones.length < items.length ) ? zones.length : items.length;
|
||||
for ( int i = 0; i < count; ++i )
|
||||
{
|
||||
fText.replaceTextRange( zones[i].x,
|
||||
zones[i].y - zones[i].x + 1,
|
||||
items[i] );
|
||||
fText.setStyleRange( new StyleRange( zones[i].x,
|
||||
zones[i].y - zones[i].x + 1,
|
||||
getDirtyColor(),
|
||||
getBackgroundColor() ) );
|
||||
fText.redrawRange( zones[i].x, zones[i].y - zones[i].x + 1, false );
|
||||
}
|
||||
}
|
||||
|
||||
private void handleVerifyKey( VerifyEvent event )
|
||||
{
|
||||
if ( event.character == SWT.LF ||
|
||||
event.character == SWT.CR ||
|
||||
event.character == SWT.BS ||
|
||||
event.character == SWT.DEL ||
|
||||
!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 );
|
||||
}
|
||||
|
||||
private Color getDirtyColor()
|
||||
{
|
||||
return CDebugUIPlugin.getPreferenceColor( ICDebugPreferenceConstants.MEMORY_DIRTY_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()
|
||||
{
|
||||
List list = new LinkedList();
|
||||
Point[] zones = fPresentation.getChangedZones();
|
||||
for ( int i = 0; i < zones.length; ++i )
|
||||
list.add( new StyleRange( zones[i].x,
|
||||
zones[i].y - zones[i].x + 1,
|
||||
getChangedColor(),
|
||||
getBackgroundColor() ) );
|
||||
fText.setStyleRanges( (StyleRange[])list.toArray( new StyleRange[list.size()] ) );
|
||||
}
|
||||
|
||||
public void setAddressColor()
|
||||
{
|
||||
List list = new LinkedList();
|
||||
Point[] zones = fPresentation.getAddressZones();
|
||||
for ( int i = 0; i < zones.length; ++i )
|
||||
list.add( new StyleRange( zones[i].x,
|
||||
zones[i].y - zones[i].x + 1,
|
||||
getAddressColor(),
|
||||
getBackgroundColor() ) );
|
||||
fText.setStyleRanges( (StyleRange[])list.toArray( new StyleRange[list.size()] ) );
|
||||
}
|
||||
|
||||
public void setDirtyColor()
|
||||
{
|
||||
List list = new LinkedList();
|
||||
Point[] zones = fPresentation.getDirtyZones();
|
||||
for ( int i = 0; i < zones.length; ++i )
|
||||
list.add( new StyleRange( zones[i].x,
|
||||
zones[i].y - zones[i].x + 1,
|
||||
getDirtyColor(),
|
||||
getBackgroundColor() ) );
|
||||
fText.setStyleRanges( (StyleRange[])list.toArray( new StyleRange[list.size()] ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.views.memory;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||
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.ICDebugUIConstants;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IDebugElement;
|
||||
import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
|
||||
import org.eclipse.debug.ui.IDebugModelPresentation;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
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.widgets.Composite;
|
||||
import org.eclipse.ui.ISelectionListener;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
|
||||
/**
|
||||
*
|
||||
* This view shows the content of the memory blocks associated
|
||||
* with the selected debug target.
|
||||
*
|
||||
* @since Jul 24, 2002
|
||||
*/
|
||||
public class MemoryView extends AbstractDebugEventHandlerView
|
||||
implements ISelectionListener,
|
||||
IPropertyChangeListener,
|
||||
IDebugExceptionHandler
|
||||
{
|
||||
private IDebugModelPresentation fModelPresentation = 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 );
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
||||
/* (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 )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.AbstractDebugView#configureToolBar(IToolBarManager)
|
||||
*/
|
||||
protected void configureToolBar( IToolBarManager tbm )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
|
||||
*/
|
||||
public void selectionChanged( IWorkbenchPart part, ISelection 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()
|
||||
{
|
||||
getSite().getPage().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
|
||||
CDebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener( this );
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
protected void setViewerInput( IStructuredSelection ssel )
|
||||
{
|
||||
IMemoryBlockRetrieval memoryBlockRetrieval = null;
|
||||
if ( ssel.size() == 1 )
|
||||
{
|
||||
Object input = ssel.getFirstElement();
|
||||
if ( input instanceof IDebugElement )
|
||||
{
|
||||
memoryBlockRetrieval = (IMemoryBlockRetrieval)((IDebugElement)input).getDebugTarget();
|
||||
}
|
||||
}
|
||||
|
||||
Object current = getViewer().getInput();
|
||||
if ( current == null && memoryBlockRetrieval == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( current != null && current.equals( memoryBlockRetrieval ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
showViewer();
|
||||
getViewer().setInput( memoryBlockRetrieval );
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
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 )
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.views.memory;
|
||||
|
||||
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 )
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.views.memory;
|
||||
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval;
|
||||
import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
|
||||
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.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
|
||||
/**
|
||||
*
|
||||
* Memory viewer.
|
||||
*
|
||||
* @since Jul 24, 2002
|
||||
*/
|
||||
public class MemoryViewer extends ContentViewer
|
||||
{
|
||||
static final private int NUMBER_OF_TABS = 4;
|
||||
|
||||
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 )
|
||||
{
|
||||
super();
|
||||
fParent = parent;
|
||||
}
|
||||
|
||||
/* (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 );
|
||||
GridData gridData = new GridData();
|
||||
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( "Memory " + (i + 1) );
|
||||
fMemoryControlAreas[i] = new MemoryControlArea( fTabFolder, SWT.NONE, i );
|
||||
tabItem.setControl( fMemoryControlAreas[i] );
|
||||
}
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.Viewer#setSelection(ISelection, boolean)
|
||||
*/
|
||||
public void setSelection(ISelection selection, boolean reveal)
|
||||
{
|
||||
}
|
||||
|
||||
public void propertyChange( PropertyChangeEvent event )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
if ( input instanceof IFormattedMemoryRetrieval )
|
||||
{
|
||||
for ( int i = 0; i < fMemoryControlAreas.length; ++i )
|
||||
fMemoryControlAreas[i].setInput( (IFormattedMemoryRetrieval)input );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.views.registers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||
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.ICDebugUIConstants;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.internal.ui.DelegatingModelPresentation;
|
||||
import org.eclipse.debug.ui.IDebugModelPresentation;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
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.TreeViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.ui.ISelectionListener;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
|
||||
/**
|
||||
*
|
||||
* This view shows registers and their values for a particular stack frame.
|
||||
*
|
||||
* @since Jul 23, 2002
|
||||
*/
|
||||
public class RegistersView extends AbstractDebugEventHandlerView
|
||||
implements ISelectionListener,
|
||||
IPropertyChangeListener,
|
||||
IDebugExceptionHandler
|
||||
{
|
||||
/**
|
||||
* The model presentation used as the label provider for the tree viewer.
|
||||
*/
|
||||
private DelegatingModelPresentation fModelPresentation;
|
||||
|
||||
protected static final String VARIABLES_SELECT_ALL_ACTION = SELECT_ALL_ACTION + ".Registers"; //$NON-NLS-1$
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(Composite)
|
||||
*/
|
||||
protected Viewer createViewer( Composite parent )
|
||||
{
|
||||
fModelPresentation = new DelegatingModelPresentation();
|
||||
CDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( this );
|
||||
|
||||
// add tree viewer
|
||||
final TreeViewer vv = new RegistersViewer( parent, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL );
|
||||
vv.setContentProvider( createContentProvider() );
|
||||
vv.setLabelProvider( getModelPresentation() );
|
||||
vv.setUseHashlookup( true );
|
||||
setAction( SELECT_ALL_ACTION, getAction( VARIABLES_SELECT_ALL_ACTION ) );
|
||||
getViewSite().getActionBars().updateActionBars();
|
||||
|
||||
// listen to selection in debug view
|
||||
getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
|
||||
setEventHandler( createEventHandler( vv ) );
|
||||
|
||||
return vv;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.AbstractDebugView#createActions()
|
||||
*/
|
||||
protected void createActions()
|
||||
{
|
||||
// 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.REGISTERS_VIEW;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.AbstractDebugView#fillContextMenu(IMenuManager)
|
||||
*/
|
||||
protected void fillContextMenu( IMenuManager menu )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.AbstractDebugView#configureToolBar(IToolBarManager)
|
||||
*/
|
||||
protected void configureToolBar( IToolBarManager tbm )
|
||||
{
|
||||
}
|
||||
|
||||
/* (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 )
|
||||
{
|
||||
String propertyName= event.getProperty();
|
||||
if ( propertyName.equals( ICDebugPreferenceConstants.CHANGED_REGISTER_RGB ) )
|
||||
{
|
||||
getEventHandler().refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/* (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()
|
||||
{
|
||||
getSite().getPage().removeSelectionListener( ICDebugUIConstants.ID_REGISTERS_VIEW, this );
|
||||
CDebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener( this );
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates this view's content provider.
|
||||
*
|
||||
* @return a content provider
|
||||
*/
|
||||
protected IContentProvider createContentProvider()
|
||||
{
|
||||
RegistersViewContentProvider cp = new RegistersViewContentProvider();
|
||||
cp.setExceptionHandler( this );
|
||||
return cp;
|
||||
}
|
||||
|
||||
protected IDebugModelPresentation getModelPresentation()
|
||||
{
|
||||
if ( fModelPresentation == null )
|
||||
{
|
||||
fModelPresentation = new DelegatingModelPresentation();
|
||||
}
|
||||
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 RegistersViewEventHandler( this );
|
||||
}
|
||||
|
||||
protected void setViewerInput( IStructuredSelection ssel )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.views.registers;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
|
||||
/**
|
||||
*
|
||||
* Provide the contents for a registers viewer.
|
||||
*
|
||||
* @since Jul 23, 2002
|
||||
*/
|
||||
public class RegistersViewContentProvider implements ITreeContentProvider
|
||||
{
|
||||
/**
|
||||
* Handler for exceptions as content is retrieved
|
||||
*/
|
||||
private IDebugExceptionHandler fExceptionHandler = null;
|
||||
|
||||
/**
|
||||
* Constructor for RegistersViewContentProvider.
|
||||
*/
|
||||
public RegistersViewContentProvider()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(Object)
|
||||
*/
|
||||
public Object[] getChildren( Object parentElement )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(Object)
|
||||
*/
|
||||
public Object getParent( Object element )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(Object)
|
||||
*/
|
||||
public boolean hasChildren( Object element )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(Object)
|
||||
*/
|
||||
public Object[] getElements( Object inputElement )
|
||||
{
|
||||
return getChildren( inputElement );
|
||||
}
|
||||
|
||||
/* (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 )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an exception handler for this content provider.
|
||||
*
|
||||
* @param handler debug exception handler or <code>null</code>
|
||||
*/
|
||||
protected void setExceptionHandler( IDebugExceptionHandler handler )
|
||||
{
|
||||
fExceptionHandler = handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exception handler for this content provider.
|
||||
*
|
||||
* @return debug exception handler or <code>null</code>
|
||||
*/
|
||||
protected IDebugExceptionHandler getExceptionHandler()
|
||||
{
|
||||
return fExceptionHandler;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.views.registers;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler;
|
||||
import org.eclipse.debug.core.DebugEvent;
|
||||
import org.eclipse.debug.core.model.IVariable;
|
||||
import org.eclipse.debug.ui.AbstractDebugView;
|
||||
|
||||
/**
|
||||
*
|
||||
* Updates the registers view
|
||||
*
|
||||
* @since Jul 23, 2002
|
||||
*/
|
||||
public class RegistersViewEventHandler extends AbstractDebugEventHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor for RegistersViewEventHandler.
|
||||
* @param view
|
||||
*/
|
||||
public RegistersViewEventHandler( 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.SUSPEND :
|
||||
if ( event.getDetail() != DebugEvent.EVALUATION_IMPLICIT )
|
||||
{
|
||||
// Don't refresh everytime an implicit evaluation finishes
|
||||
refresh();
|
||||
// return since we've done a complete refresh
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case DebugEvent.CHANGE :
|
||||
if ( event.getDetail() == DebugEvent.STATE )
|
||||
{
|
||||
// only process variable state changes
|
||||
if ( event.getSource() instanceof IVariable )
|
||||
{
|
||||
refresh( event.getSource() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
refresh();
|
||||
// return since we've done a complete refresh
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.views.registers;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IVariable;
|
||||
import org.eclipse.debug.internal.ui.DebugUIPlugin;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Item;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.eclipse.swt.widgets.Widget;
|
||||
|
||||
/**
|
||||
*
|
||||
* Registers viewer. As the user steps through code, this
|
||||
* viewer renders registers that have changed with a
|
||||
* different foreground color thereby drawing attention
|
||||
* to the values that have changed.
|
||||
*
|
||||
* @since Jul 23, 2002
|
||||
*/
|
||||
public class RegistersViewer extends TreeViewer
|
||||
{
|
||||
|
||||
private Item fNewItem;
|
||||
|
||||
/**
|
||||
* Constructor for RegistersViewer.
|
||||
* @param parent
|
||||
*/
|
||||
public RegistersViewer( Composite parent )
|
||||
{
|
||||
super( parent );
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for RegistersViewer.
|
||||
* @param parent
|
||||
* @param style
|
||||
*/
|
||||
public RegistersViewer( Composite parent, int style )
|
||||
{
|
||||
super( parent, style );
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for RegistersViewer.
|
||||
* @param tree
|
||||
*/
|
||||
public RegistersViewer( Tree tree )
|
||||
{
|
||||
super( tree );
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the view, and then do another pass to
|
||||
* update the foreground color for values that have changed
|
||||
* since the last refresh. Values that have not
|
||||
* changed are drawn with the default system foreground color.
|
||||
* If the viewer has no selection, ensure that new items
|
||||
* are visible.
|
||||
*
|
||||
* @see Viewer#refresh()
|
||||
*/
|
||||
public void refresh()
|
||||
{
|
||||
getControl().setRedraw( false );
|
||||
super.refresh();
|
||||
|
||||
Item[] children = getChildren( getControl() );
|
||||
if ( children != null )
|
||||
{
|
||||
Color c = CDebugUIPlugin.getPreferenceColor( ICDebugPreferenceConstants.CHANGED_REGISTER_RGB );
|
||||
for( int i = 0; i < children.length; i++ )
|
||||
{
|
||||
updateColor( (TreeItem)children[i], c );
|
||||
}
|
||||
}
|
||||
|
||||
getControl().setRedraw( true );
|
||||
|
||||
if ( getSelection().isEmpty() && getNewItem() != null )
|
||||
{
|
||||
if ( !getNewItem().isDisposed() )
|
||||
{
|
||||
//ensure that new items are visible
|
||||
showItem( getNewItem() );
|
||||
}
|
||||
setNewItem( null );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the color of the given item as well
|
||||
* as all of its children. If the item corresponds
|
||||
* to a variable that has changed in value,
|
||||
* it is rendered with the <code>CHANGED_VARIABLE_RGB</code>
|
||||
* generated foreground color, otherwise the default system
|
||||
* color is used.
|
||||
*
|
||||
* @param item tree item
|
||||
*/
|
||||
protected void updateColor( TreeItem item, Color c )
|
||||
{
|
||||
if ( item.getData() instanceof IVariable )
|
||||
{
|
||||
IVariable var = (IVariable)item.getData();
|
||||
try
|
||||
{
|
||||
if ( var.hasValueChanged() )
|
||||
{
|
||||
item.setForeground( c );
|
||||
}
|
||||
else
|
||||
{
|
||||
item.setForeground( null );
|
||||
}
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
DebugUIPlugin.log( e );
|
||||
}
|
||||
}
|
||||
TreeItem[] children = item.getItems();
|
||||
for( int i = 0; i < children.length; i++ )
|
||||
{
|
||||
updateColor( children[i], c );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AbstractTreeViewer#newItem(Widget, int, int)
|
||||
*/
|
||||
protected Item newItem( Widget parent, int style, int index )
|
||||
{
|
||||
if ( index != -1 )
|
||||
{
|
||||
//ignore the dummy items
|
||||
setNewItem( super.newItem( parent, style, index ) );
|
||||
return getNewItem();
|
||||
}
|
||||
return super.newItem( parent, style, index );
|
||||
}
|
||||
|
||||
protected Item getNewItem()
|
||||
{
|
||||
return fNewItem;
|
||||
}
|
||||
|
||||
protected void setNewItem( Item newItem )
|
||||
{
|
||||
fNewItem = newItem;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.ui;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugUIPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* Constant definitions for C/C++ Debug UI plug-in.
|
||||
*
|
||||
* @since Jul 23, 2002
|
||||
*/
|
||||
public interface ICDebugUIConstants
|
||||
{
|
||||
/**
|
||||
* C/C++ Debug UI plug-in identifier (value <code>"org.eclipse.cdt.debug.ui"</code>).
|
||||
*/
|
||||
public static final String PLUGIN_ID = CDebugUIPlugin.getUniqueIdentifier();
|
||||
|
||||
// Debug views
|
||||
|
||||
/**
|
||||
* Registers view identifier (value <code>"org.eclipse.cdt.debug.ui.RegitersView"</code>).
|
||||
*/
|
||||
public static final String ID_REGISTERS_VIEW = "org.eclipse.cdt.debug.ui.RegitersView"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Memory view identifier (value <code>"org.eclipse.cdt.debug.ui.MemoryView"</code>).
|
||||
*/
|
||||
public static final String ID_MEMORY_VIEW = "org.eclipse.cdt.debug.ui.MemoryView"; //$NON-NLS-1$
|
||||
}
|
Loading…
Add table
Reference in a new issue