mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Implementation of the 'SaveMemoryChanges' action.
This commit is contained in:
parent
f5a02f5aab
commit
18d7a22ac2
7 changed files with 105 additions and 1 deletions
|
@ -1,3 +1,13 @@
|
|||
2002-10-30 Mikhail Khodjaiants
|
||||
Implementation of the 'SaveMemoryChanges' action.
|
||||
* SaveMemoryChangesAction.java
|
||||
* CDebugImages.java
|
||||
* ICDebugHelpConstants.java
|
||||
* MemoryControlArea.java
|
||||
* MemoryText.java
|
||||
* MemoryViewer.java
|
||||
* MemoryView.java
|
||||
|
||||
2002-10-30 Alain Magloire
|
||||
|
||||
* src/.../ui/CDebugUIPlugin.java (selectionChanged):
|
||||
|
|
|
@ -66,7 +66,7 @@ public class CDebugImages
|
|||
public static final String IMG_LCL_CHANGE_REGISTER_VALUE = NAME_PREFIX + "change_reg_value_co.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_LCL_AUTO_REFRESH_MEMORY = NAME_PREFIX + "autorefresh_mem.gif"; //$NON-NLS-1$
|
||||
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_SAVE = NAME_PREFIX + "memory_update.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$
|
||||
|
||||
|
|
|
@ -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_SAVE_ACTION = PREFIX + "memory_save_action_context"; //$NON-NLS-1$
|
||||
public static final String MEMORY_SHOW_ASCII_ACTION = PREFIX + "memory_show_ascii_action_context"; //$NON-NLS-1$
|
||||
|
||||
// Views
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
*(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 30, 2002
|
||||
*/
|
||||
public class SaveMemoryChangesAction extends SelectionProviderAction implements IUpdate
|
||||
{
|
||||
private MemoryViewer fMemoryViewer;
|
||||
|
||||
/**
|
||||
* Constructor for SaveMemoryChangesAction.
|
||||
* @param provider
|
||||
* @param text
|
||||
*/
|
||||
public SaveMemoryChangesAction( MemoryViewer viewer )
|
||||
{
|
||||
super( viewer, "Save Changes" );
|
||||
fMemoryViewer = viewer;
|
||||
CDebugImages.setLocalImageDescriptors( this, CDebugImages.IMG_LCL_MEMORY_SAVE );
|
||||
setDescription( "Save Changes" );
|
||||
setToolTipText( "Save Changes" );
|
||||
WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.MEMORY_SAVE_ACTION );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.texteditor.IUpdate#update()
|
||||
*/
|
||||
public void update()
|
||||
{
|
||||
setEnabled( fMemoryViewer.canSave() );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.action.IAction#run()
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
fMemoryViewer.saveChanges();
|
||||
}
|
||||
}
|
|
@ -371,4 +371,24 @@ public class MemoryControlArea extends Composite
|
|||
tabItems[fIndex].setText( title );
|
||||
}
|
||||
}
|
||||
|
||||
protected void saveChanges()
|
||||
{
|
||||
if ( getMemoryBlock() != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
getMemoryBlock().saveChanges();
|
||||
String title = getTitle();
|
||||
if ( title.charAt( 0 ) == '*' )
|
||||
{
|
||||
setTitle( title.substring( 1 ) );
|
||||
}
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
CDebugUIPlugin.errorDialog( "Unable to save memory changes.", e.getStatus() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.debug.internal.ui.actions.MemoryActionSelectionGroup;
|
|||
import org.eclipse.cdt.debug.internal.ui.actions.MemoryNumberOfColumnAction;
|
||||
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.SaveMemoryChangesAction;
|
||||
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;
|
||||
|
@ -96,6 +97,11 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
setAction( "ClearMemory", action ); //$NON-NLS-1$
|
||||
add( (ClearMemoryAction)action );
|
||||
|
||||
action = new SaveMemoryChangesAction( (MemoryViewer)getViewer() );
|
||||
action.setEnabled( false );
|
||||
setAction( "SaveMemoryChanges", action ); //$NON-NLS-1$
|
||||
add( (SaveMemoryChangesAction)action );
|
||||
|
||||
action = new ShowAsciiAction( (MemoryViewer)getViewer() );
|
||||
action.setEnabled( false );
|
||||
action.setChecked( false );
|
||||
|
@ -139,6 +145,7 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
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$
|
||||
menu.appendToGroup( ICDebugUIConstants.MEMORY_GROUP, getAction( "SaveMemoryChanges" ) ); //$NON-NLS-1$
|
||||
|
||||
MenuManager subMenu = new MenuManager( "Memory Unit Size " );
|
||||
{
|
||||
|
@ -173,6 +180,7 @@ 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( getAction( "SaveMemoryChanges" ) ); //$NON-NLS-1$
|
||||
|
||||
tbm.add( new Separator( IDebugUIConstants.RENDER_GROUP ) );
|
||||
tbm.add( getAction( "ShowAscii" ) ); //$NON-NLS-1$
|
||||
|
@ -218,6 +226,7 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
fMemoryNumberOfColumnsGroup.dispose();
|
||||
|
||||
remove( (ShowAsciiAction)getAction( "ShowAscii" ) );
|
||||
remove( (SaveMemoryChangesAction)getAction( "SaveMemoryChanges" ) );
|
||||
remove( (ClearMemoryAction)getAction( "ClearMemory" ) );
|
||||
remove( (RefreshMemoryAction)getAction( "RefreshMemory" ) );
|
||||
remove( (AutoRefreshMemoryAction)getAction( "AutoRefreshMemory" ) );
|
||||
|
|
|
@ -175,6 +175,11 @@ public class MemoryViewer extends ContentViewer
|
|||
return ( ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock() != null );
|
||||
}
|
||||
|
||||
public boolean canSave()
|
||||
{
|
||||
return ( ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock() != null );
|
||||
}
|
||||
|
||||
public boolean isFrozen()
|
||||
{
|
||||
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
|
||||
|
@ -195,6 +200,11 @@ public class MemoryViewer extends ContentViewer
|
|||
((MemoryControlArea)fTabFolder.getSelection().getControl()).clear();
|
||||
}
|
||||
|
||||
public void saveChanges()
|
||||
{
|
||||
((MemoryControlArea)fTabFolder.getSelection().getControl()).saveChanges();
|
||||
}
|
||||
|
||||
public boolean showAscii()
|
||||
{
|
||||
return ((MemoryControlArea)fTabFolder.getSelection().getControl()).getPresentation().displayASCII();
|
||||
|
|
Loading…
Add table
Reference in a new issue