mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
Fixing PR 38788: Ctrl-X, Ctrl-C, Ctrl-V, Ctrl-A, Ctrl-Z and Ctrl-Y keys don't work in the address field of the Memory view.
This commit is contained in:
parent
038b3552b2
commit
4f184d5fef
5 changed files with 199 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
|||
2003-06-12 Mikhail Khodjaiants
|
||||
Fixing "trivial" PR 38788: Ctrl-X, Ctrl-C, Ctrl-V, Ctrl-A, Ctrl-Z and Ctrl-Y keys don't work
|
||||
in the address field of the Memory view.
|
||||
* MemoryViewAction.java: new
|
||||
* MemoryControlArea.java
|
||||
* MemoryView.java
|
||||
* MemoryViewer.java
|
||||
|
||||
2003-06-10 Mikhail Khodjaiants
|
||||
Refactoring: moved the type and value related methods from ICVariable to ICType and ICValue.
|
||||
* CDTDebugModelPresentation.java
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.text.ITextOperationTarget;
|
||||
import org.eclipse.ui.texteditor.IUpdate;
|
||||
|
||||
/**
|
||||
* Enter type comment.
|
||||
*
|
||||
* @since Jun 12, 2003
|
||||
*/
|
||||
public class MemoryViewAction extends Action implements IUpdate
|
||||
{
|
||||
/** The text operation code */
|
||||
private int fOperationCode = -1;
|
||||
/** The text operation target */
|
||||
private ITextOperationTarget fOperationTarget;
|
||||
/** The text operation target provider */
|
||||
private IAdaptable fTargetProvider;
|
||||
|
||||
public MemoryViewAction( ITextOperationTarget target, int operationCode )
|
||||
{
|
||||
super();
|
||||
fOperationCode = operationCode;
|
||||
fOperationTarget = target;
|
||||
update();
|
||||
}
|
||||
|
||||
public MemoryViewAction( IAdaptable targetProvider, int operationCode )
|
||||
{
|
||||
super();
|
||||
fTargetProvider = targetProvider;
|
||||
fOperationCode = operationCode;
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>TextOperationAction</code> implementation of this
|
||||
* <code>IUpdate</code> method discovers the operation through the current
|
||||
* editor's <code>ITextOperationTarget</code> adapter, and sets the
|
||||
* enabled state accordingly.
|
||||
*/
|
||||
public void update()
|
||||
{
|
||||
if ( fTargetProvider != null && fOperationCode != -1 )
|
||||
{
|
||||
ITextOperationTarget target = getTextOperationTarget();
|
||||
boolean isEnabled = ( target != null && target.canDoOperation( fOperationCode ) );
|
||||
setEnabled( isEnabled );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>TextOperationAction</code> implementation of this
|
||||
* <code>IAction</code> method runs the operation with the current
|
||||
* operation code.
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
ITextOperationTarget target = getTextOperationTarget();
|
||||
if ( fOperationCode != -1 && target != null )
|
||||
target.doOperation( fOperationCode );
|
||||
}
|
||||
|
||||
private ITextOperationTarget getTextOperationTarget()
|
||||
{
|
||||
if ( fOperationTarget == null )
|
||||
{
|
||||
if ( fTargetProvider != null )
|
||||
return (ITextOperationTarget)fTargetProvider.getAdapter( ITextOperationTarget.class );
|
||||
}
|
||||
return fOperationTarget;
|
||||
}
|
||||
}
|
|
@ -14,10 +14,13 @@ import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
|
|||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
import org.eclipse.jface.text.ITextOperationTarget;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.CTabFolder;
|
||||
import org.eclipse.swt.custom.CTabItem;
|
||||
import org.eclipse.swt.events.FocusEvent;
|
||||
import org.eclipse.swt.events.FocusListener;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
|
@ -37,7 +40,7 @@ import org.eclipse.swt.widgets.Text;
|
|||
*
|
||||
* @since Jul 25, 2002
|
||||
*/
|
||||
public class MemoryControlArea extends Composite
|
||||
public class MemoryControlArea extends Composite implements ITextOperationTarget
|
||||
{
|
||||
private MemoryView fMemoryView;
|
||||
private MemoryPresentation fPresentation;
|
||||
|
@ -120,7 +123,18 @@ public class MemoryControlArea extends Composite
|
|||
}
|
||||
}
|
||||
} );
|
||||
text.addFocusListener( new FocusListener()
|
||||
{
|
||||
public void focusGained( FocusEvent e )
|
||||
{
|
||||
fMemoryView.updateObjects();
|
||||
}
|
||||
|
||||
public void focusLost( FocusEvent e )
|
||||
{
|
||||
fMemoryView.updateObjects();
|
||||
}
|
||||
} );
|
||||
fEvaluateButton = new Button( composite, SWT.PUSH );
|
||||
fEvaluateButton.setText( "Evaluate" );
|
||||
fEvaluateButton.setToolTipText( "Evaluate expression to address" );
|
||||
|
@ -477,4 +491,44 @@ public class MemoryControlArea extends Composite
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.ITextOperationTarget#canDoOperation(int)
|
||||
*/
|
||||
public boolean canDoOperation( int operation )
|
||||
{
|
||||
switch( operation )
|
||||
{
|
||||
case CUT:
|
||||
case COPY:
|
||||
return ( fAddressText != null && fAddressText.isFocusControl() && fAddressText.isEnabled() && fAddressText.getSelectionCount() > 0 );
|
||||
case PASTE:
|
||||
case SELECT_ALL:
|
||||
return ( fAddressText != null && fAddressText.isFocusControl() && fAddressText.isEnabled() );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.ITextOperationTarget#doOperation(int)
|
||||
*/
|
||||
public void doOperation( int operation )
|
||||
{
|
||||
switch( operation )
|
||||
{
|
||||
case CUT:
|
||||
fAddressText.cut();
|
||||
break;
|
||||
case COPY:
|
||||
fAddressText.copy();
|
||||
break;
|
||||
case PASTE:
|
||||
fAddressText.paste();
|
||||
break;
|
||||
case SELECT_ALL:
|
||||
fAddressText.setSelection( 0, fAddressText.getCharCount() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.debug.internal.ui.actions.MemoryActionSelectionGroup;
|
|||
import org.eclipse.cdt.debug.internal.ui.actions.MemoryFormatAction;
|
||||
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.MemoryViewAction;
|
||||
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.preferences.ICDebugPreferenceConstants;
|
||||
|
@ -31,6 +32,7 @@ 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.text.ITextOperationTarget;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
import org.eclipse.jface.viewers.IContentProvider;
|
||||
|
@ -43,6 +45,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.ITextEditorActionConstants;
|
||||
import org.eclipse.ui.texteditor.IUpdate;
|
||||
|
||||
/**
|
||||
|
@ -83,7 +86,33 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
*/
|
||||
protected void createActions()
|
||||
{
|
||||
IAction action = new RefreshMemoryAction( (MemoryViewer)getViewer() );
|
||||
IAction action = null;
|
||||
|
||||
action = new MemoryViewAction( this, ITextOperationTarget.CUT );
|
||||
action.setText( "Cut" );
|
||||
action.setToolTipText( "Cut" );
|
||||
action.setDescription( "Cut" );
|
||||
setGlobalAction( ITextEditorActionConstants.CUT, (MemoryViewAction)action );
|
||||
|
||||
action = new MemoryViewAction( this, ITextOperationTarget.COPY );
|
||||
action.setText( "Copy" );
|
||||
action.setToolTipText( "Copy" );
|
||||
action.setDescription( "Copy" );
|
||||
setGlobalAction( ITextEditorActionConstants.COPY, (MemoryViewAction)action );
|
||||
|
||||
action = new MemoryViewAction( this, ITextOperationTarget.PASTE );
|
||||
action.setText( "Paste" );
|
||||
action.setToolTipText( "Paste" );
|
||||
action.setDescription( "Paste" );
|
||||
setGlobalAction( ITextEditorActionConstants.PASTE, (MemoryViewAction)action );
|
||||
|
||||
action = new MemoryViewAction( this, ITextOperationTarget.SELECT_ALL );
|
||||
action.setText( "Select All" );
|
||||
action.setToolTipText( "Select All" );
|
||||
action.setDescription( "Select All" );
|
||||
setGlobalAction( ITextEditorActionConstants.SELECT_ALL, (MemoryViewAction)action );
|
||||
|
||||
action = new RefreshMemoryAction( (MemoryViewer)getViewer() );
|
||||
action.setEnabled( false );
|
||||
setAction( "RefreshMemory", action ); //$NON-NLS-1$
|
||||
add( (RefreshMemoryAction)action );
|
||||
|
@ -377,4 +406,23 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
remove( (IUpdate)actions[i] );
|
||||
}
|
||||
}
|
||||
|
||||
private void setGlobalAction( String actionId, MemoryViewAction action )
|
||||
{
|
||||
add( action );
|
||||
getViewSite().getActionBars().setGlobalActionHandler( actionId, action );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
||||
*/
|
||||
public Object getAdapter( Class adapter )
|
||||
{
|
||||
if (ITextOperationTarget.class.equals( adapter ) )
|
||||
{
|
||||
return ((MemoryViewer)getViewer()).getTextOperationTarget();
|
||||
}
|
||||
|
||||
return super.getAdapter(adapter);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.eclipse.cdt.debug.internal.ui.views.memory;
|
|||
import org.eclipse.cdt.debug.core.ICMemoryManager;
|
||||
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.jface.text.ITextOperationTarget;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
import org.eclipse.jface.viewers.ContentViewer;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
|
@ -280,4 +281,9 @@ public class MemoryViewer extends ContentViewer
|
|||
((MemoryControlArea)fTabFolder.getSelection().getControl()).refresh();
|
||||
}
|
||||
}
|
||||
|
||||
protected ITextOperationTarget getTextOperationTarget()
|
||||
{
|
||||
return (MemoryControlArea)fTabFolder.getSelection().getControl();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue