Index:
ChangeLog =================================================================== RCS
file: /home/tools/org.eclipse.cdt.debug.ui/ChangeLog,v retrieving revision
1.42 diff -u -r1.42 ChangeLog --- ChangeLog 27 Nov 2002 15:50:38
-0000 1.42 +++ ChangeLog 28 Nov 2002 19:16:00 -0000 @@ -1,3
+1,12 @@ +2002-11-28 Mikhail Khodjaiants + Live editing of the memory
view. + * SaveMemoryChangesAction.java - removed + *
MemoryPresentation.java + * MemoryControlArea.java + *
MemoryText.java + * MemoryViewer.java + *
MemoryView.java + 2002-11-27 Mikhail
Khodjaiants Render debug target as suspended if no reason is
specified. * CDTDebugModelPresentation.java Index:
src/org/eclipse/cdt/debug/internal/ui/actions/SaveMemoryChangesAction.java =================================================================== RCS
file:
src/org/eclipse/cdt/debug/internal/ui/actions/SaveMemoryChangesAction.java diff
-N
src/org/eclipse/cdt/debug/internal/ui/actions/SaveMemoryChangesAction.java ---
src/org/eclipse/cdt/debug/internal/ui/actions/SaveMemoryChangesAction.java 30
Oct 2002 22:01:01 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00
-0000 @@ -1,54 +0,0 @@ -/* - *(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(); - } -} Index:
src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryControlArea.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryControlArea.java,v retrieving
revision 1.19 diff -u -r1.19 MemoryControlArea.java ---
src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryControlArea.java 26
Nov 2002 16:38:03 -0000 1.19 +++
src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryControlArea.java 28
Nov 2002 19:16:01 -0000 @@ -424,27 +424,7
@@ } } } - - 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()
); - } - } - } - + private
void
updateToolTipText() { setTabItemToolTipText(
fAddressText.getText().trim() ); 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.12 diff -u -r1.12 MemoryPresentation.java ---
src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java 20
Nov 2002 21:51:38 -0000 1.12 +++
src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java 28
Nov 2002 19:16:01 -0000 @@ -6,7 +6,6 @@ package
org.eclipse.cdt.debug.internal.ui.views.memory; -import
java.util.ArrayList; import java.util.Arrays; import
java.util.LinkedList; import java.util.List; @@ -18,6 +17,7
@@ import
org.eclipse.cdt.debug.internal.ui.CDebugUIUtils; import
org.eclipse.debug.core.DebugException; import
org.eclipse.swt.graphics.Point; +import
org.eclipse.swt.widgets.Display; /** * @@
-378,46 +378,8 @@ return
getMemoryBlock().displayASCII(); return
false; } - - protected
MemoryText.TextReplacement[] textChanged( int offset, char newChar, char[]
replacedText ) - { - ArrayList list = new
ArrayList(); - if ( getMemoryBlock() != null
) - { - int index = getDataItemIndex( offset
); - if ( index != -1
) - { - char[] chars =
getDataItemChars( index ); - if ( isInDataArea( offset
) ) - { - int
charIndex = getOffsetInDataItem( offset, index
); - chars[charIndex] =
newChar; - } - if (
isInAsciiArea( offset )
) - { - chars =
CDebugUtils.getByteText( (byte)newChar
); - } - try - { - String
text = new String( chars
); - getMemoryBlock().setItemValue( index, text
); - list.add( new MemoryText.TextReplacement(
getDataItemOffset( index ), text ) ); - if (
displayASCII()
) - { - //
Ascii is enabled only when the word size is one
byte - list.add( getAsciiTextReplacement(
index, chars )
); - } - } - catch(
DebugException e
) - { - //
ignore - } - } - } - return
(MemoryText.TextReplacement[])list.toArray( new
MemoryText.TextReplacement[list.size()]
); - } - private int getDataItemIndex( int offset
) + protected int getDataItemIndex( int offset
) { int row = offset /
getRowLength(); int pos = offset % getRowLength() -
getAddressLength() - INTERVAL_BETWEEN_ADDRESS_AND_DATA; @@ -472,20 +434,7
@@ } return
-1; } - - private MemoryText.TextReplacement
getAsciiTextReplacement( int itemIndex, char[] chars
) - { - int row = itemIndex /
getNumberOfDataItemsInRow(); - int col = itemIndex %
getNumberOfDataItemsInRow(); - int offset = row * getRowLength()
+ - getAddressLength() +
INTERVAL_BETWEEN_ADDRESS_AND_DATA + -
getNumberOfDataItemsInRow() * (getDataItemLength() +
INTERVAL_BETWEEN_DATA_ITEMS) + -
INTERVAL_BETWEEN_DATA_AND_ASCII + col; - byte newValue =
CDebugUtils.textToByte( chars ); - char ch = (
Character.isISOControl( (char)newValue ) || newValue < 0 ) ?
getPaddingCharacter() : (char)newValue; - return new
MemoryText.TextReplacement( offset, new String( new char[]{ ch } )
); - } - + public void
dispose() { if ( fAddressZones != null
) @@ -497,16 +446,7
@@ fChangedZones.clear(); } } - - protected
boolean isDirty() - { - if ( getMemoryBlock() != null
) - { - return
getMemoryBlock().isDirty(); - } - return
false; - } - + private String
getDataItemPresentation( String item
) { switch( getDataFormat() ) @@ -570,5
+510,53 @@ return
getMemoryBlock().isStartAddressChanged(); } return
false; + } + + protected String getNewItemValue( int
offset, char newChar ) + { + if ( getMemoryBlock() != null
) + { + int index = getDataItemIndex( offset
); + if ( index != -1
) + { + char[] chars =
getDataItemChars( index ); + if ( isInDataArea( offset
) ) + { + int
charIndex = getOffsetInDataItem( offset, index
); + chars[charIndex] =
newChar; + } + if (
isInAsciiArea( offset )
) + { + chars =
CDebugUtils.getByteText( (byte)newChar
); + } + return new String(
chars ); + } + } + return
null; + } + + protected void setItemValue( int offset, char
ch ) + { + if ( getMemoryBlock() != null
) + { + int index = getDataItemIndex( offset
); + if ( index != -1
) + { + String newValue =
getNewItemValue( offset, ch ); + if ( newValue != null
) + { + try + { + getMemoryBlock().setItemValue(
index, newValue
); + return; + } + catch(
DebugException e
) + { + Display.getDefault().beep(); + } + } + } + } + Display.getDefault().beep(); } } 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.10 diff -u -r1.10 MemoryText.java ---
src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryText.java 20 Nov
2002 21:51:38 -0000 1.10 +++
src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryText.java 28 Nov
2002 19:16:00 -0000 @@ -33,38 +33,6 @@ */ public class
MemoryText { - /** - * - * The
instance of this class specifies the text replacement - * that has to
be applied to the StyledText widget. - * - * @since Oct 29,
2002 - */ - public static class
TextReplacement - { - private int
fStart; - private String
fText; - - /** - * Constructor for
TextReplacement. - */ - public TextReplacement( int
start, String text ) - { - fStart =
start; - fText =
text; - } - - public int
getStart() - { - return
fStart; - } - - public String
getText() - { - return
fText; - } - } - private StyledText
fText = null; private MemoryPresentation fPresentation =
null; private boolean fUpdating = false; @@ -118,16 +86,19
@@ return; if ( event.length !=
1 ) return; - TextReplacement[] trs =
fPresentation.textChanged( event.start,
-
fText.getText().charAt( event.start
), -
event.replacedText.toCharArray() ); int caretOffset =
fText.getCaretOffset(); - update( trs
); + fText.getCaret().setVisible( false ); + char ch
= fText.getText().charAt( event.start ); + restoreText(
event.start, event.length, event.replacedText
); + fPresentation.setItemValue( event.start, ch
); fText.setCaretOffset( caretOffset
); + fText.getCaret().setVisible( true
); } public void
refresh() { + int offset =
fText.getCaretOffset(); + fText.getCaret().setVisible( false
); fText.setFont( new Font( fText.getDisplay(),
getFontData() ) ); fText.setBackground(
getBackgroundColor() ); fText.setForeground(
getForegroundColor() ); @@ -151,7 +122,8
@@
getBackgroundColor() )
); } fText.redraw(); - updateTitle(); + fText.setCaretOffset(
offset ); + fText.getCaret().setVisible( true
); } private void refresh( Point[]
zones, String[] items ) @@ -170,7 +142,6
@@ */ fText.redrawRange( zones[i].x,
zones[i].y - zones[i].x + 1, false
); } - updateTitle(); } protected
void handleVerifyKey( VerifyEvent event ) @@ -295,7 +266,7
@@ { return
fText; } - +/* protected void
update( TextReplacement[] trs ) { fUpdating
= true; @@ -304,18 +275,24
@@ fText.replaceTextRange( trs[i].getStart(),
trs[i].getText().length(),
trs[i].getText()
); -/* fText.setStyleRange( new StyleRange(
trs[i].getStart(),
trs[i].getText().length(),
getDirtyColor(),
getBackgroundColor() )
); -*/ fText.redrawRange( trs[i].getStart(),
trs[i].getText().length(), false
); } + saveChanges(); fUpdating
=
false; updateTitle(); } - +*/ + private
void restoreText( int start, int length, String text
) + { + fUpdating =
true; + fText.replaceTextRange( start, length, text
); + fUpdating = false; + } +/* private
void updateTitle() { if ( fText.getParent()
instanceof MemoryControlArea ) @@ -332,4 +309,13
@@ ((MemoryControlArea)fText.getParent()).setTitle(
title ); } } + + private
void saveChanges() + { + if ( fText.getParent() instanceof
MemoryControlArea
) + { + ((MemoryControlArea)fText.getParent()).saveChanges(); + } + } +*/ } 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.13 diff -u -r1.13 MemoryView.java ---
src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryView.java 13 Nov
2002 18:49:29 -0000 1.13 +++
src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryView.java 28 Nov
2002 19:16:00 -0000 @@ -15,7 +15,6 @@ 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.preferences.ICDebugPreferenceConstants; import
org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler; @@ -100,11
+99,6 @@ setAction( "ClearMemory", action );
//$NON-NLS-1$ add( (ClearMemoryAction)action
); - action = "" SaveMemoryChangesAction(
(MemoryViewer)getViewer() ); - action.setEnabled( false
); - setAction( "SaveMemoryChanges", action );
//$NON-NLS-1$ - add( (SaveMemoryChangesAction)action
); - action = "" ShowAsciiAction(
(MemoryViewer)getViewer() ); action.setEnabled( false
); action.setChecked(
CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean(
ICDebugPreferenceConstants.PREF_MEMORY_SHOW_ASCII ) ); @@ -151,7 +145,6
@@ 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( "Format" ); { @@ -196,7 +189,6
@@ 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$ @@ -244,7 +236,6
@@ fMemoryNumberOfColumnsGroup.dispose(); remove(
(ShowAsciiAction)getAction( "ShowAscii" ) ); - remove(
(SaveMemoryChangesAction)getAction( "SaveMemoryChanges" )
); 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.17 diff -u -r1.17 MemoryViewer.java ---
src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewer.java 21 Nov
2002 20:50:06 -0000 1.17 +++
src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryViewer.java 28 Nov
2002 19:16:00 -0000 @@ -217,12 +217,7
@@ { ((MemoryControlArea)fTabFolder.getSelection().getControl()).clear(); } - - public
void
saveChanges() - { - ((MemoryControlArea)fTabFolder.getSelection().getControl()).saveChanges(); - } - + public
void
refreshMemoryBlock() { ((MemoryControlArea)fTabFolder.getSelection().getControl()).refreshMemoryBlock();
|