mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Implementing Memory view formatting actions.
This commit is contained in:
parent
655d0606bb
commit
08451dae9e
6 changed files with 242 additions and 4 deletions
|
@ -1,3 +1,12 @@
|
|||
2002-10-24 Mikhail Khodjaiants
|
||||
Implementing Memory view formatting actions.
|
||||
* MemoryActionSelectionGroup.java: implementation of a toggle action group.
|
||||
* MemorySizeAction.java: implementation of the "Memory Unit Size" menu item.
|
||||
* MemoryView.java: add new actions to the view.
|
||||
* MemoryViewer.java: support for new action.
|
||||
* ICDebugHelpContextIds.java: help context id for the new action.
|
||||
* ICDebugUIConstants.java: new menu group - "Format".
|
||||
|
||||
2002-10-23 Mikhail Khodjaiants
|
||||
* DebuggerConsoleActionDelegate.java: The debugger/inferrior console should become visible when checking "Show Debug Console".
|
||||
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
/**
|
||||
* Enter type comment.
|
||||
*
|
||||
* @since: Oct 22, 2002
|
||||
*/
|
||||
public class MemoryActionSelectionGroup
|
||||
{
|
||||
private List fActions;
|
||||
private IAction fSelection = null;
|
||||
|
||||
/**
|
||||
* Constructor for MemoryActionSelectionGroup.
|
||||
*/
|
||||
public MemoryActionSelectionGroup()
|
||||
{
|
||||
fActions = new ArrayList();
|
||||
}
|
||||
|
||||
public IAction getCurrentSelection()
|
||||
{
|
||||
return fSelection;
|
||||
}
|
||||
|
||||
public void setCurrentSelection( IAction selection )
|
||||
{
|
||||
Iterator it = fActions.iterator();
|
||||
while( it.hasNext() )
|
||||
{
|
||||
IAction action = (IAction)it.next();
|
||||
if ( !action.equals( selection ) )
|
||||
{
|
||||
action.setChecked( false );
|
||||
}
|
||||
}
|
||||
if ( fActions.contains( selection ) )
|
||||
{
|
||||
fSelection = selection;
|
||||
}
|
||||
else
|
||||
{
|
||||
fSelection = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void addAction( IAction action )
|
||||
{
|
||||
fActions.add( action );
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
fActions.clear();
|
||||
fSelection = null;
|
||||
}
|
||||
|
||||
public IAction[] getActions()
|
||||
{
|
||||
return (IAction[])fActions.toArray( new IAction[fActions.size()] );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.memory.MemoryViewer;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.ui.texteditor.IUpdate;
|
||||
|
||||
/**
|
||||
* Enter type comment.
|
||||
*
|
||||
* @since: Oct 22, 2002
|
||||
*/
|
||||
public class MemorySizeAction extends Action implements IUpdate
|
||||
{
|
||||
private MemoryActionSelectionGroup fGroup;
|
||||
private MemoryViewer fMemoryViewer;
|
||||
private int fId = 0;
|
||||
|
||||
/**
|
||||
* Constructor for MemorySizeAction.
|
||||
*/
|
||||
public MemorySizeAction( MemoryActionSelectionGroup group,
|
||||
MemoryViewer viewer,
|
||||
int id )
|
||||
{
|
||||
super( getLabel( id ) );
|
||||
fGroup = group;
|
||||
fMemoryViewer = viewer;
|
||||
fId = id;
|
||||
setChecked( false );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.texteditor.IUpdate#update()
|
||||
*/
|
||||
public void update()
|
||||
{
|
||||
setEnabled( fMemoryViewer.canUpdate() );
|
||||
setChecked( fMemoryViewer.getCurrentWordSize() == fId );
|
||||
/*
|
||||
if ( isChecked() )
|
||||
{
|
||||
fGroup.setCurrentSelection( this );
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private static String getLabel( int id )
|
||||
{
|
||||
String label = "";
|
||||
switch( id )
|
||||
{
|
||||
case( IFormattedMemoryBlock.MEMORY_SIZE_BYTE ):
|
||||
label = "1 byte";
|
||||
break;
|
||||
case( IFormattedMemoryBlock.MEMORY_SIZE_HALF_WORD ):
|
||||
label = "2 bytes";
|
||||
break;
|
||||
case( IFormattedMemoryBlock.MEMORY_SIZE_WORD ):
|
||||
label = "4 bytes";
|
||||
break;
|
||||
case( IFormattedMemoryBlock.MEMORY_SIZE_DOUBLE_WORD ):
|
||||
label = "8 bytes";
|
||||
break;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.action.IAction#run()
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
fGroup.setCurrentSelection( this );
|
||||
}
|
||||
|
||||
public String getActionId()
|
||||
{
|
||||
return "MemorySize" + fId;
|
||||
}
|
||||
}
|
|
@ -6,9 +6,12 @@
|
|||
package org.eclipse.cdt.debug.internal.ui.views.memory;
|
||||
|
||||
import org.eclipse.cdt.debug.core.ICMemoryManager;
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
|
||||
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.MemoryActionSelectionGroup;
|
||||
import org.eclipse.cdt.debug.internal.ui.actions.MemorySizeAction;
|
||||
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;
|
||||
|
@ -23,6 +26,7 @@ import org.eclipse.debug.ui.IDebugUIConstants;
|
|||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
import org.eclipse.jface.action.MenuManager;
|
||||
import org.eclipse.jface.action.Separator;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
|
@ -36,6 +40,7 @@ import org.eclipse.swt.widgets.Control;
|
|||
import org.eclipse.ui.ISelectionListener;
|
||||
import org.eclipse.ui.IWorkbenchActionConstants;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.texteditor.IUpdate;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -50,6 +55,7 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
IDebugExceptionHandler
|
||||
{
|
||||
private IDebugModelPresentation fModelPresentation = null;
|
||||
private MemoryActionSelectionGroup fMemorySizeGroup = null;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(Composite)
|
||||
|
@ -94,6 +100,9 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
setAction( "ShowAscii", action ); //$NON-NLS-1$
|
||||
add( (ShowAsciiAction)action );
|
||||
|
||||
fMemorySizeGroup = new MemoryActionSelectionGroup();
|
||||
createSizeActionGroup( fMemorySizeGroup );
|
||||
|
||||
// set initial content here, as viewer has to be set
|
||||
setInitialContent();
|
||||
}
|
||||
|
@ -113,15 +122,30 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
{
|
||||
menu.add( new Separator( ICDebugUIConstants.EMPTY_MEMORY_GROUP ) );
|
||||
menu.add( new Separator( ICDebugUIConstants.MEMORY_GROUP ) );
|
||||
menu.add( getAction( "AutoRefreshMemory" ) ); //$NON-NLS-1$
|
||||
menu.add( getAction( "RefreshMemory" ) ); //$NON-NLS-1$
|
||||
menu.add( getAction( "ClearMemory" ) ); //$NON-NLS-1$
|
||||
|
||||
menu.add( new Separator( ICDebugUIConstants.EMPTY_FORMAT_GROUP ) );
|
||||
menu.add( new Separator( ICDebugUIConstants.FORMAT_GROUP ) );
|
||||
|
||||
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 ) );
|
||||
|
||||
menu.appendToGroup( ICDebugUIConstants.MEMORY_GROUP, getAction( "AutoRefreshMemory" ) ); //$NON-NLS-1$
|
||||
menu.appendToGroup( ICDebugUIConstants.MEMORY_GROUP, getAction( "RefreshMemory" ) ); //$NON-NLS-1$
|
||||
menu.appendToGroup( ICDebugUIConstants.MEMORY_GROUP, getAction( "ClearMemory" ) ); //$NON-NLS-1$
|
||||
|
||||
MenuManager subMenu = new MenuManager( "Memory Unit Size " );
|
||||
{
|
||||
IAction[] actions = fMemorySizeGroup.getActions();
|
||||
for ( int i = 0; i < actions.length; ++i )
|
||||
{
|
||||
subMenu.add( actions[i] );
|
||||
}
|
||||
}
|
||||
menu.appendToGroup( ICDebugUIConstants.FORMAT_GROUP, subMenu );
|
||||
|
||||
menu.appendToGroup( IDebugUIConstants.RENDER_GROUP, getAction( "ShowAscii" ) ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -173,10 +197,14 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
*/
|
||||
public void dispose()
|
||||
{
|
||||
removeActionGroup( fMemorySizeGroup );
|
||||
fMemorySizeGroup.dispose();
|
||||
|
||||
remove( (ShowAsciiAction)getAction( "ShowAscii" ) );
|
||||
remove( (ClearMemoryAction)getAction( "ClearMemory" ) );
|
||||
remove( (RefreshMemoryAction)getAction( "RefreshMemory" ) );
|
||||
remove( (AutoRefreshMemoryAction)getAction( "AutoRefreshMemory" ) );
|
||||
|
||||
getSite().getPage().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
|
||||
CDebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener( this );
|
||||
super.dispose();
|
||||
|
@ -257,4 +285,29 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
super.createContextMenu( ((MemoryControlArea)items[i].getControl()).getMemoryText().getControl() );
|
||||
}
|
||||
}
|
||||
|
||||
private void createSizeActionGroup( MemoryActionSelectionGroup group )
|
||||
{
|
||||
int[] ids = new int[] { IFormattedMemoryBlock.MEMORY_SIZE_BYTE,
|
||||
IFormattedMemoryBlock.MEMORY_SIZE_HALF_WORD,
|
||||
IFormattedMemoryBlock.MEMORY_SIZE_WORD,
|
||||
IFormattedMemoryBlock.MEMORY_SIZE_DOUBLE_WORD };
|
||||
for ( int i = 0; i < ids.length; ++i )
|
||||
{
|
||||
MemorySizeAction action = new MemorySizeAction( group, (MemoryViewer)getViewer(), ids[i] );
|
||||
action.setEnabled( false );
|
||||
setAction( action.getActionId(), action ); //$NON-NLS-1$
|
||||
add( action );
|
||||
group.addAction( action );
|
||||
}
|
||||
}
|
||||
|
||||
private void removeActionGroup( MemoryActionSelectionGroup group )
|
||||
{
|
||||
IAction[] actions = group.getActions();
|
||||
for ( int i = 0; i < actions.length; ++i )
|
||||
{
|
||||
remove( (IUpdate)actions[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,4 +209,10 @@ public class MemoryViewer extends ContentViewer
|
|||
{
|
||||
return ((MemoryControlArea)fTabFolder.getSelection().getControl()).getPresentation().canDisplayAscii();
|
||||
}
|
||||
|
||||
public int getCurrentWordSize()
|
||||
{
|
||||
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
|
||||
return ( block != null ) ? block.getWordSize() : 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,4 +59,15 @@ public interface ICDebugUIConstants
|
|||
* Identifier for a memory group in a menu (value <code>"memoryGroup"</code>).
|
||||
*/
|
||||
public static final String MEMORY_GROUP = "memoryGroup"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Identifier for an empty group preceeding a
|
||||
* format group in a menu (value <code>"emptyFormatGroup"</code>).
|
||||
*/
|
||||
public static final String EMPTY_FORMAT_GROUP = "emptyFormatGroup"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Identifier for a format group in a menu (value <code>"formatGroup"</code>).
|
||||
*/
|
||||
public static final String FORMAT_GROUP = "formatGroup"; //$NON-NLS-1$
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue