From ee8afed69fe7e9d1923983f6bb467621e0640b61 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Tue, 6 Aug 2002 19:00:46 +0000 Subject: [PATCH] Added the Registers and Memory views. --- debug/org.eclipse.cdt.debug.ui/.classpath | 13 + debug/org.eclipse.cdt.debug.ui/.project | 35 +++ .../org.eclipse.cdt.debug.ui/build.properties | 1 + .../icons/full/cview16/memory_view.gif | Bin 0 -> 214 bytes .../icons/full/cview16/registers_view.gif | Bin 0 -> 336 bytes .../icons/full/eview16/memory_view.gif | Bin 0 -> 214 bytes .../icons/full/eview16/registers_view.gif | Bin 0 -> 336 bytes .../plugin.properties | 11 + debug/org.eclipse.cdt.debug.ui/plugin.xml | 75 +++++ .../ui/CDTDebugModelPresentation.java | 70 +++++ .../cdt/debug/internal/ui/CDebugUIPlugin.java | 146 ++++++++++ .../cdt/debug/internal/ui/CDebugUIUtils.java | 27 ++ .../cdt/debug/internal/ui/ColorManager.java | 58 ++++ .../internal/ui/ICDebugHelpContextIds.java | 31 +++ .../ui/ICDebugUIInternalConstants.java | 45 +++ .../ui/preferences/ComboFieldEditor.java | 178 ++++++++++++ .../ICDebugPreferenceConstants.java | 82 ++++++ .../preferences/MemoryViewPreferencePage.java | 143 ++++++++++ .../ui/views/AbstractDebugEventHandler.java | 220 +++++++++++++++ .../views/AbstractDebugEventHandlerView.java | 58 ++++ .../ui/views/IDebugExceptionHandler.java | 21 ++ .../ui/views/memory/MemoryControlArea.java | 182 ++++++++++++ .../ui/views/memory/MemoryPresentation.java | 261 ++++++++++++++++++ .../internal/ui/views/memory/MemoryText.java | 234 ++++++++++++++++ .../internal/ui/views/memory/MemoryView.java | 175 ++++++++++++ .../memory/MemoryViewContentProvider.java | 39 +++ .../views/memory/MemoryViewEventHandler.java | 36 +++ .../ui/views/memory/MemoryViewer.java | 111 ++++++++ .../ui/views/registers/RegistersView.java | 200 ++++++++++++++ .../RegistersViewContentProvider.java | 98 +++++++ .../registers/RegistersViewEventHandler.java | 69 +++++ .../ui/views/registers/RegistersViewer.java | 162 +++++++++++ .../cdt/debug/ui/ICDebugUIConstants.java | 35 +++ 33 files changed, 2816 insertions(+) create mode 100644 debug/org.eclipse.cdt.debug.ui/.classpath create mode 100644 debug/org.eclipse.cdt.debug.ui/.project create mode 100644 debug/org.eclipse.cdt.debug.ui/build.properties create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/cview16/memory_view.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/cview16/registers_view.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/eview16/memory_view.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/eview16/registers_view.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/plugin.properties create mode 100644 debug/org.eclipse.cdt.debug.ui/plugin.xml create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIPlugin.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIUtils.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ColorManager.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugUIInternalConstants.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ComboFieldEditor.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/MemoryViewPreferencePage.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandler.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandlerView.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/IDebugExceptionHandler.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryControlArea.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryText.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryView.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewContentProvider.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewEventHandler.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewer.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersView.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersViewContentProvider.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersViewEventHandler.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersViewer.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebugUIConstants.java diff --git a/debug/org.eclipse.cdt.debug.ui/.classpath b/debug/org.eclipse.cdt.debug.ui/.classpath new file mode 100644 index 00000000000..a3d0a0656c3 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/.classpath @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/debug/org.eclipse.cdt.debug.ui/.project b/debug/org.eclipse.cdt.debug.ui/.project new file mode 100644 index 00000000000..e9c1dad17ed --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/.project @@ -0,0 +1,35 @@ + + + org.eclipse.cdt.debug.ui + + + org.eclipse.cdt.debug.core + org.eclipse.core.boot + org.eclipse.core.resources + org.eclipse.core.runtime + org.eclipse.debug.core + org.eclipse.debug.ui + org.eclipse.ui + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + diff --git a/debug/org.eclipse.cdt.debug.ui/build.properties b/debug/org.eclipse.cdt.debug.ui/build.properties new file mode 100644 index 00000000000..85962c93d34 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/build.properties @@ -0,0 +1 @@ +source.cdebugui.jar = src/ diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/cview16/memory_view.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/cview16/memory_view.gif new file mode 100644 index 0000000000000000000000000000000000000000..6343974cee6a927f0674270d3ad019d20f031b3d GIT binary patch literal 214 zcmZ?wbhEHb6krfwIKsg2@BhE7-QkyCpN(DQ5x>kUbwz+rjQg&e8~5MdmXsC$_`|*T z-`{-y{nfOH!6aDn@4r7eAwp#_qGbunf6s^fIUn}_&zH4p*Vfk7#>B)J8yo-s|DORB zDE?$&WMGhD&;bd9>||gKUZB>Ok~uHK$}H#gz9?oJuiX1h!p7olqI=^F7G&!f%=BSg znIe?j(KJOtH(>cu=0xioLc3yO7bPjoKK+8rMR}&nohjuieDTije$?Ds^y>Hj2317{ FYXB=+Srh;O literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/cview16/registers_view.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/cview16/registers_view.gif new file mode 100644 index 0000000000000000000000000000000000000000..7b5d835796cbb9e22f98d8dcf1c87f226dd84dda GIT binary patch literal 336 zcmZ?wbhEHb6krfwxXQrL(7-Tdvf7l%>hbaNet!BM9{S$iMqy#LIXR&@*}>UaK{u}~ zfA{8kd|cR{-`{Uv-hOP`q~qHrpWHFy({TJKYxDv z_U#)tZk#xAV)5d|GiT16F=NKGY15`oo!Z{so|&1Mk&%&_n(E}_1k}ht4WRgwg^__l zgFy#m7|2fyY`G3o3Osbg+&v~uDly`6pO*3EQpqHp`2ikVR*G?|`lPLSIfujT(8XKA_Lv2^g+=HJKW}nXRW^|C)!r4@QM>j(J-H#f(1+RYpZ%|caum%7jR$Zb1 literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/eview16/registers_view.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/eview16/registers_view.gif new file mode 100644 index 0000000000000000000000000000000000000000..5ad18fd3b93bf964ea0f90ccd7347af55ae3cc5b GIT binary patch literal 336 zcmZ?wbhEHb6krfw_{zZW|NsBg)YO|dZ@zo??$4h;KyG$+c1}*tv17-MA3uKb8DtRU~XJw0tn{S6vroYO<4#7_xH{bKOZ#;P8$A2E~ zYA#NWHV#g%CRbi|w*Cq1-OjwMEYoMqn9ML$VBY+B%(Ho!nU*bIKAVwy&DwRd{WflL Ib7Zgv0IJ`0sQ>@~ literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties new file mode 100644 index 00000000000..aa654b4164c --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties @@ -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 diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml new file mode 100644 index 00000000000..5ae5893fe9d --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java new file mode 100644 index 00000000000..df685258cd7 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java @@ -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; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIPlugin.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIPlugin.java new file mode 100644 index 00000000000..d265c25b4b1 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIPlugin.java @@ -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: + *
  • CHANGED_REGISTER_RGB
  • + */ + 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]; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIUtils.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIUtils.java new file mode 100644 index 00000000000..fb32ffbd41d --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIUtils.java @@ -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; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ColorManager.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ColorManager.java new file mode 100644 index 00000000000..6afb13c32c8 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ColorManager.java @@ -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(); + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java new file mode 100644 index 00000000000..079a07975ed --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java @@ -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. + *

    + * This interface contains constants only; it is not intended to be implemented + * or extended. + *

    + * + * @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$ +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugUIInternalConstants.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugUIInternalConstants.java new file mode 100644 index 00000000000..e3934ee48fd --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugUIInternalConstants.java @@ -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; +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ComboFieldEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ComboFieldEditor.java new file mode 100644 index 00000000000..841e92f3093 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ComboFieldEditor.java @@ -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 Combo 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 String[][] is of "type" + * String[][2]. + * + * @return true if it is ok, and false 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]; + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java new file mode 100644 index 00000000000..9399f0f75db --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java @@ -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$ +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/MemoryViewPreferencePage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/MemoryViewPreferencePage.java new file mode 100644 index 00000000000..c90e8fdeb19 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/MemoryViewPreferencePage.java @@ -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; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandler.java new file mode 100644 index 00000000000..f3a2ac57a59 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandler.java @@ -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 null if none. + * + * @return this event handler's viewer as a tree + * viewer or null 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(); + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandlerView.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandlerView.java new file mode 100644 index 00000000000..3747acc7459 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandlerView.java @@ -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(); + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/IDebugExceptionHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/IDebugExceptionHandler.java new file mode 100644 index 00000000000..a4a6ba8c1ea --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/IDebugExceptionHandler.java @@ -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 ); +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryControlArea.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryControlArea.java new file mode 100644 index 00000000000..db12afd6027 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryControlArea.java @@ -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 ) ); + } + } +*/ +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java new file mode 100644 index 00000000000..73c63a8c0d1 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java @@ -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(); + } +*/ +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryText.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryText.java new file mode 100644 index 00000000000..272966b4b9f --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryText.java @@ -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()] ) ); + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryView.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryView.java new file mode 100644 index 00000000000..da8c859f4cb --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryView.java @@ -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 ); + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewContentProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewContentProvider.java new file mode 100644 index 00000000000..c14c67121f0 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewContentProvider.java @@ -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 ) + { + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewEventHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewEventHandler.java new file mode 100644 index 00000000000..c02b6253bca --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewEventHandler.java @@ -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 ) + { + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewer.java new file mode 100644 index 00000000000..75b16a66e19 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewer.java @@ -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 ); + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersView.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersView.java new file mode 100644 index 00000000000..be862e7d7e5 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersView.java @@ -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 ); + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersViewContentProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersViewContentProvider.java new file mode 100644 index 00000000000..09d28739864 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersViewContentProvider.java @@ -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 null + */ + protected void setExceptionHandler( IDebugExceptionHandler handler ) + { + fExceptionHandler = handler; + } + + /** + * Returns the exception handler for this content provider. + * + * @return debug exception handler or null + */ + protected IDebugExceptionHandler getExceptionHandler() + { + return fExceptionHandler; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersViewEventHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersViewEventHandler.java new file mode 100644 index 00000000000..f573da16be9 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersViewEventHandler.java @@ -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; + } + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersViewer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersViewer.java new file mode 100644 index 00000000000..e75999d8557 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/registers/RegistersViewer.java @@ -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 CHANGED_VARIABLE_RGB + * 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; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebugUIConstants.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebugUIConstants.java new file mode 100644 index 00000000000..97dd52d26a6 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebugUIConstants.java @@ -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 "org.eclipse.cdt.debug.ui"). + */ + public static final String PLUGIN_ID = CDebugUIPlugin.getUniqueIdentifier(); + + // Debug views + + /** + * Registers view identifier (value "org.eclipse.cdt.debug.ui.RegitersView"). + */ + public static final String ID_REGISTERS_VIEW = "org.eclipse.cdt.debug.ui.RegitersView"; //$NON-NLS-1$ + + /** + * Memory view identifier (value "org.eclipse.cdt.debug.ui.MemoryView"). + */ + public static final String ID_MEMORY_VIEW = "org.eclipse.cdt.debug.ui.MemoryView"; //$NON-NLS-1$ +}