1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Implementation of the "Show ASCII" action.

This commit is contained in:
Mikhail Khodjaiants 2002-10-22 17:10:49 +00:00
parent a6a656f007
commit 99aa0c76d4
11 changed files with 140 additions and 25 deletions

View file

@ -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.

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

View file

@ -68,6 +68,7 @@ public class CDebugImages
public static final String IMG_LCL_REFRESH_MEMORY = NAME_PREFIX + "refresh_mem.gif"; //$NON-NLS-1$
public static final String IMG_LCL_MEMORY_SAVE = NAME_PREFIX + "memory_save.gif"; //$NON-NLS-1$
public static final String IMG_LCL_MEMORY_CLEAR = NAME_PREFIX + "memory_clear.gif"; //$NON-NLS-1$
public static final String IMG_LCL_SHOW_ASCII = NAME_PREFIX + "show_ascii.gif"; //$NON-NLS-1$
/*
* Set of predefined Image Descriptors.

View file

@ -28,6 +28,7 @@ public interface ICDebugHelpContextIds
public static final String REFRESH_MEMORY_ACTION = PREFIX + "refresh_memory_action_context"; //$NON-NLS-1$
public static final String AUTO_REFRESH_MEMORY_ACTION = PREFIX + "auto_refresh_memory_action_context"; //$NON-NLS-1$
public static final String MEMORY_CLEAR_ACTION = PREFIX + "memory_clear_action_context"; //$NON-NLS-1$
public static final String MEMORY_SHOW_ASCII_ACTION = PREFIX + "memory_show_ascii_action_context"; //$NON-NLS-1$
// Views
public static final String REGISTERS_VIEW = PREFIX + "registers_view_context"; //$NON-NLS-1$

View file

@ -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() );
}
}

View file

@ -35,6 +35,8 @@ public class MemoryPresentation
private List fAddressZones;
private List fChangedZones;
private List fDirtyZones;
private boolean fDisplayAscii = true;
/**
* Constructor for MemoryPresentation.
@ -166,7 +168,10 @@ public class MemoryPresentation
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 @@ public class MemoryPresentation
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 )
@ -436,4 +446,11 @@ public class MemoryPresentation
}
return -1;
}
protected boolean canDisplayAscii()
{
if ( getMemoryBlock() != null )
return getMemoryBlock().displayASCII();
return false;
}
}

View file

@ -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 class MemoryText
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 )

View file

@ -10,6 +10,7 @@ import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
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 @@ public class MemoryView extends AbstractDebugEventHandlerView
add( (RefreshMemoryAction)action );
action = new AutoRefreshMemoryAction( (MemoryViewer)getViewer() );
action.setEnabled( false );
action.setChecked( false );
setAction( "AutoRefreshMemory", action ); //$NON-NLS-1$
add( (AutoRefreshMemoryAction)action );
@ -86,6 +88,12 @@ public class MemoryView extends AbstractDebugEventHandlerView
setAction( "ClearMemory", action ); //$NON-NLS-1$
add( (ClearMemoryAction)action );
action = new ShowAsciiAction( (MemoryViewer)getViewer() );
action.setEnabled( false );
action.setChecked( false );
setAction( "ShowAscii", action ); //$NON-NLS-1$
add( (ShowAsciiAction)action );
// set initial content here, as viewer has to be set
setInitialContent();
}
@ -109,6 +117,10 @@ public class MemoryView extends AbstractDebugEventHandlerView
menu.add( getAction( "RefreshMemory" ) ); //$NON-NLS-1$
menu.add( getAction( "ClearMemory" ) ); //$NON-NLS-1$
menu.add( new Separator( IDebugUIConstants.EMPTY_RENDER_GROUP ) );
menu.add( new Separator( IDebugUIConstants.RENDER_GROUP ) );
menu.add( getAction( "ShowAscii" ) ); //$NON-NLS-1$
menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
}
@ -122,6 +134,9 @@ public class MemoryView extends AbstractDebugEventHandlerView
tbm.add( getAction( "AutoRefreshMemory" ) ); //$NON-NLS-1$
tbm.add( getAction( "RefreshMemory" ) ); //$NON-NLS-1$
tbm.add( getAction( "ClearMemory" ) ); //$NON-NLS-1$
tbm.add( new Separator( IDebugUIConstants.RENDER_GROUP ) );
tbm.add( getAction( "ShowAscii" ) ); //$NON-NLS-1$
}
/* (non-Javadoc)
@ -158,6 +173,7 @@ public class MemoryView extends AbstractDebugEventHandlerView
*/
public void dispose()
{
remove( (ShowAsciiAction)getAction( "ShowAscii" ) );
remove( (ClearMemoryAction)getAction( "ClearMemory" ) );
remove( (RefreshMemoryAction)getAction( "RefreshMemory" ) );
remove( (AutoRefreshMemoryAction)getAction( "AutoRefreshMemory" ) );

View file

@ -193,4 +193,20 @@ public class MemoryViewer extends ContentViewer
{
((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();
}
}