mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
Implementation of the "Auto-Refresh" and "Refresh" actions for the memory view.
This commit is contained in:
parent
e3b2ddf78d
commit
8cb3a11b6a
8 changed files with 132 additions and 10 deletions
|
@ -1,3 +1,13 @@
|
|||
2002-10-21 Mikhail Khodjaiants
|
||||
Implementation of the "Auto-Refresh" and "Refresh" actions for the memory view.
|
||||
* AutoRefreshMemoryAction.java
|
||||
* RefreshMemoryAction.java
|
||||
* ICDebugHelpContextIds.java
|
||||
* MemoryControlArea.java
|
||||
* MemoryView.java
|
||||
* MemoryViewer.java
|
||||
* MemoryViewEventHandler.java
|
||||
|
||||
2002-10-20 Mikhail Khodjaiants
|
||||
Display the memory changes in different color in the memory view.
|
||||
* MemoryControlArea.java
|
||||
|
|
|
@ -26,6 +26,7 @@ public interface ICDebugHelpContextIds
|
|||
public static final String CHANGE_REGISTER_VALUE_ACTION = PREFIX + "change_register_value_action_context"; //$NON-NLS-1$
|
||||
public static final String SHOW_TYPES_ACTION = PREFIX + "show_types_action_context"; //$NON-NLS-1$
|
||||
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$
|
||||
|
||||
// Views
|
||||
public static final String REGISTERS_VIEW = PREFIX + "registers_view_context"; //$NON-NLS-1$
|
||||
|
|
|
@ -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 AutoRefreshMemoryAction extends SelectionProviderAction implements IUpdate
|
||||
{
|
||||
private MemoryViewer fMemoryViewer;
|
||||
|
||||
/**
|
||||
* Constructor for AutoRefreshMemoryAction.
|
||||
* @param provider
|
||||
* @param text
|
||||
*/
|
||||
public AutoRefreshMemoryAction( MemoryViewer viewer )
|
||||
{
|
||||
super( viewer, "Auto-Refresh" );
|
||||
fMemoryViewer = viewer;
|
||||
CDebugImages.setLocalImageDescriptors( this, CDebugImages.IMG_LCL_AUTO_REFRESH_MEMORY );
|
||||
setDescription( "Automatically Refresh Memory Block" );
|
||||
setToolTipText( "Auto-Refresh" );
|
||||
WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.AUTO_REFRESH_MEMORY_ACTION );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.texteditor.IUpdate#update()
|
||||
*/
|
||||
public void update()
|
||||
{
|
||||
setEnabled( fMemoryViewer.canUpdate() );
|
||||
setChecked( !fMemoryViewer.isFrozen() );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.action.IAction#run()
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
fMemoryViewer.setFrozen( !isChecked() );
|
||||
}
|
||||
}
|
|
@ -11,14 +11,17 @@ import org.eclipse.cdt.debug.internal.ui.views.memory.MemoryViewer;
|
|||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.actions.SelectionProviderAction;
|
||||
import org.eclipse.ui.help.WorkbenchHelp;
|
||||
import org.eclipse.ui.texteditor.IUpdate;
|
||||
|
||||
/**
|
||||
* Enter type comment.
|
||||
*
|
||||
* @since: Oct 18, 2002
|
||||
*/
|
||||
public class RefreshMemoryAction extends SelectionProviderAction
|
||||
public class RefreshMemoryAction extends SelectionProviderAction implements IUpdate
|
||||
{
|
||||
private MemoryViewer fMemoryViewer;
|
||||
|
||||
/**
|
||||
* Constructor for RefreshMemoryAction.
|
||||
* @param provider
|
||||
|
@ -26,8 +29,11 @@ public class RefreshMemoryAction extends SelectionProviderAction
|
|||
*/
|
||||
public RefreshMemoryAction( MemoryViewer viewer )
|
||||
{
|
||||
super( viewer, "Refresh Memory Block" );
|
||||
super( viewer, "Refresh" );
|
||||
fMemoryViewer = viewer;
|
||||
CDebugImages.setLocalImageDescriptors( this, CDebugImages.IMG_LCL_REFRESH_MEMORY );
|
||||
setDescription( "Refresh Memory Block" );
|
||||
setToolTipText( "Refresh" );
|
||||
WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.REFRESH_MEMORY_ACTION );
|
||||
}
|
||||
|
||||
|
@ -38,4 +44,12 @@ public class RefreshMemoryAction extends SelectionProviderAction
|
|||
{
|
||||
super.selectionChanged( selection );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.texteditor.IUpdate#update()
|
||||
*/
|
||||
public void update()
|
||||
{
|
||||
setEnabled( fMemoryViewer.canUpdate() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.swt.widgets.Text;
|
|||
*/
|
||||
public class MemoryControlArea extends Composite
|
||||
{
|
||||
private MemoryView fMemoryView;
|
||||
private MemoryPresentation fPresentation;
|
||||
private int fIndex = 0;
|
||||
private ICMemoryManager fMemoryManager = null;
|
||||
|
@ -49,9 +50,10 @@ public class MemoryControlArea extends Composite
|
|||
* @param parent
|
||||
* @param style
|
||||
*/
|
||||
public MemoryControlArea( Composite parent, int style, int index )
|
||||
public MemoryControlArea( Composite parent, int style, int index, MemoryView view )
|
||||
{
|
||||
super( parent, style );
|
||||
fMemoryView = view;
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.marginHeight = 0;
|
||||
layout.marginWidth = 0;
|
||||
|
@ -130,6 +132,7 @@ public class MemoryControlArea extends Composite
|
|||
CDebugUIPlugin.errorDialog( "Unable to get memory block.", e.getStatus() );
|
||||
}
|
||||
refresh();
|
||||
fMemoryView.updateObjects();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,9 +247,6 @@ public class MemoryControlArea extends Composite
|
|||
getNumberOfColumns(),
|
||||
getPaddingChar() ) );
|
||||
getPresentation().setMemoryBlock( getMemoryBlock() );
|
||||
|
||||
//getMemoryBlock().setFrozen( false );
|
||||
|
||||
}
|
||||
setMemoryTextState();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ package org.eclipse.cdt.debug.internal.ui.views.memory;
|
|||
|
||||
import org.eclipse.cdt.debug.core.ICMemoryManager;
|
||||
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.RefreshMemoryAction;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandlerView;
|
||||
|
@ -27,6 +28,7 @@ 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.custom.CTabItem;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.ui.ISelectionListener;
|
||||
|
@ -53,7 +55,7 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
protected Viewer createViewer( Composite parent )
|
||||
{
|
||||
CDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( this );
|
||||
final MemoryViewer viewer = new MemoryViewer( parent );
|
||||
final MemoryViewer viewer = new MemoryViewer( parent, this );
|
||||
viewer.setContentProvider( createContentProvider() );
|
||||
viewer.setLabelProvider( getModelPresentation() );
|
||||
|
||||
|
@ -71,6 +73,12 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
IAction action = new RefreshMemoryAction( (MemoryViewer)getViewer() );
|
||||
action.setEnabled( false );
|
||||
setAction( "RefreshMemory", action ); //$NON-NLS-1$
|
||||
add( (RefreshMemoryAction)action );
|
||||
|
||||
action = new AutoRefreshMemoryAction( (MemoryViewer)getViewer() );
|
||||
action.setChecked( false );
|
||||
setAction( "AutoRefreshMemory", action ); //$NON-NLS-1$
|
||||
add( (AutoRefreshMemoryAction)action );
|
||||
|
||||
// set initial content here, as viewer has to be set
|
||||
setInitialContent();
|
||||
|
@ -91,6 +99,7 @@ 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( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
|
||||
|
@ -103,6 +112,7 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
{
|
||||
tbm.add( new Separator( this.getClass().getName() ) );
|
||||
tbm.add( new Separator( ICDebugUIConstants.MEMORY_GROUP ) );
|
||||
tbm.add( getAction( "AutoRefreshMemory" ) ); //$NON-NLS-1$
|
||||
tbm.add( getAction( "RefreshMemory" ) ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
@ -140,6 +150,8 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
*/
|
||||
public void dispose()
|
||||
{
|
||||
remove( (RefreshMemoryAction)getAction( "RefreshMemory" ) );
|
||||
remove( (AutoRefreshMemoryAction)getAction( "AutoRefreshMemory" ) );
|
||||
getSite().getPage().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
|
||||
CDebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener( this );
|
||||
super.dispose();
|
||||
|
@ -164,6 +176,7 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
}
|
||||
showViewer();
|
||||
getViewer().setInput( mm );
|
||||
updateObjects();
|
||||
}
|
||||
|
||||
private IContentProvider createContentProvider()
|
||||
|
@ -213,6 +226,10 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
*/
|
||||
protected void createContextMenu( Control menuControl )
|
||||
{
|
||||
super.createContextMenu( ((MemoryControlArea)((MemoryViewer)getViewer()).getTabFolder().getSelection().getControl()).getMemoryText().getControl() );
|
||||
CTabItem[] items = ((MemoryViewer)getViewer()).getTabFolder().getItems();
|
||||
for ( int i = 0; i < items.length; ++i )
|
||||
{
|
||||
super.createContextMenu( ((MemoryControlArea)items[i].getControl()).getMemoryText().getControl() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ public class MemoryViewEventHandler extends AbstractDebugEventHandler
|
|||
if ( event.getSource() instanceof IFormattedMemoryBlock && event.getDetail() == DebugEvent.CONTENT )
|
||||
{
|
||||
refresh( event.getSource() );
|
||||
getView().updateObjects();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -30,6 +30,7 @@ public class MemoryViewer extends ContentViewer
|
|||
{
|
||||
static final private int NUMBER_OF_TABS = 4;
|
||||
|
||||
protected MemoryView fView = null;
|
||||
protected Composite fParent = null;
|
||||
protected CTabFolder fTabFolder = null;
|
||||
private Composite fControl = null;
|
||||
|
@ -38,10 +39,11 @@ public class MemoryViewer extends ContentViewer
|
|||
/**
|
||||
* Constructor for MemoryViewer.
|
||||
*/
|
||||
public MemoryViewer( Composite parent )
|
||||
public MemoryViewer( Composite parent, MemoryView view )
|
||||
{
|
||||
super();
|
||||
fParent = parent;
|
||||
fView = view;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -63,17 +65,19 @@ public class MemoryViewer extends ContentViewer
|
|||
{
|
||||
CTabItem tabItem = new CTabItem( fTabFolder, SWT.NONE );
|
||||
tabItem.setText( "Memory " + (i + 1) );
|
||||
fMemoryControlAreas[i] = new MemoryControlArea( fTabFolder, SWT.NONE, i );
|
||||
fMemoryControlAreas[i] = new MemoryControlArea( fTabFolder, SWT.NONE, i, fView );
|
||||
tabItem.setControl( fMemoryControlAreas[i] );
|
||||
}
|
||||
fTabFolder.addSelectionListener( new SelectionListener()
|
||||
{
|
||||
public void widgetSelected( SelectionEvent e )
|
||||
{
|
||||
fView.updateObjects();
|
||||
}
|
||||
|
||||
public void widgetDefaultSelected( SelectionEvent e )
|
||||
{
|
||||
fView.updateObjects();
|
||||
}
|
||||
} );
|
||||
fTabFolder.setSelection( 0 );
|
||||
|
@ -158,4 +162,24 @@ public class MemoryViewer extends ContentViewer
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return ( ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock() != null );
|
||||
}
|
||||
|
||||
public boolean isFrozen()
|
||||
{
|
||||
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
|
||||
return ( block != null ) ? block.isFrozen() : true;
|
||||
}
|
||||
|
||||
public void setFrozen( boolean frozen )
|
||||
{
|
||||
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
|
||||
if ( block != null )
|
||||
{
|
||||
block.setFrozen( frozen );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue