Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Implementation of the "Show ASCII" action

Implementation of the "Show ASCII" action.

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/ChangeLog,v
retrieving revision 1.10
diff -u -r1.10 ChangeLog
--- ChangeLog 22 Oct 2002 02:53:48 -0000 1.10
+++ ChangeLog 22 Oct 2002 17:09:49 -0000
@@ -1,3 +1,15 @@
+2002-10-22 Mikhail Khodjaiants
+ Implementation of the "Show ASCII" action.
+ Action images:
+  show_ascii.gif (clcl, dlcl, elcl).
+ * ShowAsciiAction.java
+ * MemoryPresentation.java
+ * MemoryText.java
+ * MemoryView.java
+ * MemoryViewer.java
+ * CDebugImages.java
+ * ICDebugHelpContextIds.java
+
 2002-10-21 Mikhail Khodjaiants
  Framework tries to refresh memory view before the view controls are created.
  * MemoryViewer.java: Check if CTabFolder has already created when refreshing the view.
Index: icons/full/clcl16/show_ascii.gif
===================================================================
RCS file: icons/full/clcl16/show_ascii.gif
diff -N icons/full/clcl16/show_ascii.gif
Binary files /dev/null and show_ascii.gif differ
Index: icons/full/dlcl16/show_ascii.gif
===================================================================
RCS file: icons/full/dlcl16/show_ascii.gif
diff -N icons/full/dlcl16/show_ascii.gif
Binary files /dev/null and show_ascii.gif differ
Index: icons/full/elcl16/show_ascii.gif
===================================================================
RCS file: icons/full/elcl16/show_ascii.gif
diff -N icons/full/elcl16/show_ascii.gif
Binary files /dev/null and show_ascii.gif differ
Index: src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java,v
retrieving revision 1.7
diff -u -r1.7 CDebugImages.java
--- src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java 18 Oct 2002 22:02:51 -0000 1.7
+++ src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java 22 Oct 2002 17:09:49 -0000
@@ -68,6 +68,7 @@
  public static final String IMG_LCL_REFRESH_MEMORY = NAME_PREFIX + "refresh_mem.gif"; file://$NON-NLS-1$
  public static final String IMG_LCL_MEMORY_SAVE = NAME_PREFIX + "memory_save.gif"; file://$NON-NLS-1$
  public static final String IMG_LCL_MEMORY_CLEAR = NAME_PREFIX + "memory_clear.gif"; file://$NON-NLS-1$
+ public static final String IMG_LCL_SHOW_ASCII = NAME_PREFIX + "show_ascii.gif"; file://$NON-NLS-1$
 
  /*
   * Set of predefined Image Descriptors.
Index: src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java,v
retrieving revision 1.6
diff -u -r1.6 ICDebugHelpContextIds.java
--- src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java 21 Oct 2002 21:49:18 -0000 1.6
+++ src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java 22 Oct 2002 17:09:49 -0000
@@ -28,6 +28,7 @@
  public static final String REFRESH_MEMORY_ACTION = PREFIX + "refresh_memory_action_context"; file://$NON-NLS-1$
  public static final String AUTO_REFRESH_MEMORY_ACTION = PREFIX + "auto_refresh_memory_action_context"; file://$NON-NLS-1$
  public static final String MEMORY_CLEAR_ACTION = PREFIX + "memory_clear_action_context"; file://$NON-NLS-1$
+ public static final String MEMORY_SHOW_ASCII_ACTION = PREFIX + "memory_show_ascii_action_context"; file://$NON-NLS-1$
 
  // Views
  public static final String REGISTERS_VIEW = PREFIX + "registers_view_context"; file://$NON-NLS-1$
Index: src/org/eclipse/cdt/debug/internal/ui/actions/ShowAsciiAction.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/internal/ui/actions/ShowAsciiAction.java
diff -N src/org/eclipse/cdt/debug/internal/ui/actions/ShowAsciiAction.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/internal/ui/actions/ShowAsciiAction.java 22 Oct 2002 17:09:50 -0000
@@ -0,0 +1,55 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+package org.eclipse.cdt.debug.internal.ui.actions;
+
+import org.eclipse.cdt.debug.internal.ui.CDebugImages;
+import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
+import org.eclipse.cdt.debug.internal.ui.views.memory.MemoryViewer;
+import org.eclipse.ui.actions.SelectionProviderAction;
+import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.texteditor.IUpdate;
+
+/**
+ * Enter type comment.
+ *
+ * @since: Oct 21, 2002
+ */
+public class ShowAsciiAction extends SelectionProviderAction implements IUpdate
+{
+ private MemoryViewer fMemoryViewer;
+
+ /**
+  * Constructor for ShowAsciiAction.
+  * @param provider
+  * @param text
+  */
+ public ShowAsciiAction( MemoryViewer viewer )
+ {
+  super( viewer, "Show ASCII" );
+  fMemoryViewer = viewer;
+  CDebugImages.setLocalImageDescriptors( this, CDebugImages.IMG_LCL_SHOW_ASCII );
+  setDescription( "Show ASCII" );
+  setToolTipText( "Show ASCII" );
+  WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.MEMORY_SHOW_ASCII_ACTION );
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.ui.texteditor.IUpdate#update()
+  */
+ public void update()
+ {
+  setEnabled( fMemoryViewer.canShowAscii() );
+  setChecked( fMemoryViewer.showAscii() );
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.jface.action.IAction#run()
+  */
+ public void run()
+ {
+  fMemoryViewer.setShowAscii( isChecked() );
+ }
+}
Index: src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java,v
retrieving revision 1.4
diff -u -r1.4 MemoryPresentation.java
--- src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java 21 Oct 2002 03:42:09 -0000 1.4
+++ src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java 22 Oct 2002 17:09:50 -0000
@@ -35,6 +35,8 @@
  private List fAddressZones;
  private List fChangedZones;
  private List fDirtyZones;

+ private boolean fDisplayAscii = true;
   
  /**
   * Constructor for MemoryPresentation.
@@ -166,7 +168,10 @@
    result.append( getInterval( INTERVAL_BETWEEN_DATA_ITEMS ) );
   }
   result.append( getInterval( INTERVAL_BETWEEN_DATA_AND_ASCII ) );
-  result.append( row.getASCII() );
+  if ( displayASCII() )
+  {
+   result.append( row.getASCII() );
+  }
   result.append( '\n' );
   return result.toString();
  }
@@ -336,13 +341,18 @@
   return 0;
  }
  
- private boolean displayASCII()
+ protected boolean displayASCII()
  {
-  if ( getMemoryBlock() != null )
-   return getMemoryBlock().displayASCII();
+  if ( canDisplayAscii() )
+   return fDisplayAscii;
   return false;
  }
  
+ protected void setDisplayAscii( boolean displayAscii )
+ {
+  fDisplayAscii = displayAscii;
+ }
+
  private int getDataBytesPerRow()
  {
   if ( getMemoryBlock() != null )
@@ -435,5 +445,12 @@
    }
   }
   return -1;
+ }

+ protected boolean canDisplayAscii()
+ {
+  if ( getMemoryBlock() != null )
+   return getMemoryBlock().displayASCII();
+  return false;
  }
 }
Index: src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryText.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryText.java,v
retrieving revision 1.5
diff -u -r1.5 MemoryText.java
--- src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryText.java 21 Oct 2002 03:42:09 -0000 1.5
+++ src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryText.java 22 Oct 2002 17:09:50 -0000
@@ -6,9 +6,6 @@
 
 package org.eclipse.cdt.debug.internal.ui.views.memory;
 
-import java.util.LinkedList;
-import java.util.List;
-
 import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
 import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
 import org.eclipse.jface.preference.IPreferenceStore;
@@ -215,38 +212,38 @@
  
  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()] ) );
+  {
+   fText.setStyleRange( new StyleRange( zones[i].x,
+             zones[i].y - zones[i].x + 1,
+             getChangedColor(),
+             getBackgroundColor() ) );
+  }
  }
  
  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()] ) );
+  {
+   fText.setStyleRange( new StyleRange( zones[i].x,
+             zones[i].y - zones[i].x + 1,
+             getAddressColor(),
+             getBackgroundColor() ) );
+  }
  }
  
  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()] ) );
+  {
+   fText.setStyleRange( new StyleRange( zones[i].x,
+             zones[i].y - zones[i].x + 1,
+             getDirtyColor(),
+             getBackgroundColor() ) );
+  }
  }
  
  protected void setEditable( boolean editable )
Index: src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryView.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryView.java,v
retrieving revision 1.7
diff -u -r1.7 MemoryView.java
--- src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryView.java 21 Oct 2002 21:49:18 -0000 1.7
+++ src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryView.java 22 Oct 2002 17:09:50 -0000
@@ -10,6 +10,7 @@
 import org.eclipse.cdt.debug.internal.ui.actions.AutoRefreshMemoryAction;
 import org.eclipse.cdt.debug.internal.ui.actions.ClearMemoryAction;
 import org.eclipse.cdt.debug.internal.ui.actions.RefreshMemoryAction;
+import org.eclipse.cdt.debug.internal.ui.actions.ShowAsciiAction;
 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;
@@ -77,6 +78,7 @@
   add( (RefreshMemoryAction)action );
 
   action = "" AutoRefreshMemoryAction( (MemoryViewer)getViewer() );
+  action.setEnabled( false );
   action.setChecked( false );
   setAction( "AutoRefreshMemory", action ); file://$NON-NLS-1$
   add( (AutoRefreshMemoryAction)action );
@@ -86,6 +88,12 @@
   setAction( "ClearMemory", action ); file://$NON-NLS-1$
   add( (ClearMemoryAction)action );
 
+  action = "" ShowAsciiAction( (MemoryViewer)getViewer() );
+  action.setEnabled( false );
+  action.setChecked( false );
+  setAction( "ShowAscii", action ); file://$NON-NLS-1$
+  add( (ShowAsciiAction)action );
+
   // set initial content here, as viewer has to be set
   setInitialContent();
  }
@@ -109,6 +117,10 @@
   menu.add( getAction( "RefreshMemory" ) ); file://$NON-NLS-1$
   menu.add( getAction( "ClearMemory" ) ); file://$NON-NLS-1$
 
+  menu.add( new Separator( IDebugUIConstants.EMPTY_RENDER_GROUP ) );
+  menu.add( new Separator( IDebugUIConstants.RENDER_GROUP ) );
+  menu.add( getAction( "ShowAscii" ) ); file://$NON-NLS-1$
+
   menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
  }
 
@@ -122,6 +134,9 @@
   tbm.add( getAction( "AutoRefreshMemory" ) ); file://$NON-NLS-1$
   tbm.add( getAction( "RefreshMemory" ) ); file://$NON-NLS-1$
   tbm.add( getAction( "ClearMemory" ) ); file://$NON-NLS-1$
+
+  tbm.add( new Separator( IDebugUIConstants.RENDER_GROUP ) );
+  tbm.add( getAction( "ShowAscii" ) ); file://$NON-NLS-1$
  }
 
  /* (non-Javadoc)
@@ -158,6 +173,7 @@
   */
  public void dispose()
  {
+  remove( (ShowAsciiAction)getAction( "ShowAscii" ) );
   remove( (ClearMemoryAction)getAction( "ClearMemory" ) );
   remove( (RefreshMemoryAction)getAction( "RefreshMemory" ) );
   remove( (AutoRefreshMemoryAction)getAction( "AutoRefreshMemory" ) );
Index: src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewer.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewer.java,v
retrieving revision 1.8
diff -u -r1.8 MemoryViewer.java
--- src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewer.java 22 Oct 2002 02:53:48 -0000 1.8
+++ src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewer.java 22 Oct 2002 17:09:49 -0000
@@ -193,4 +193,20 @@
  {
   ((MemoryControlArea)fTabFolder.getSelection().getControl()).clear();
  }

+ public boolean showAscii()
+ {
+  return ((MemoryControlArea)fTabFolder.getSelection().getControl()).getPresentation().displayASCII();
+ }

+ public void setShowAscii( boolean show )
+ {
+  ((MemoryControlArea)fTabFolder.getSelection().getControl()).getPresentation().setDisplayAscii( show );
+  ((MemoryControlArea)fTabFolder.getSelection().getControl()).refresh();
+ }

+ public boolean canShowAscii()
+ {
+  return ((MemoryControlArea)fTabFolder.getSelection().getControl()).getPresentation().canDisplayAscii();
+ }
 }


Back to the top