mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Bug 228063: applied patch from Pawel Piech (WindRiver).
This commit is contained in:
parent
72f98fc936
commit
532bcc93b8
1 changed files with 55 additions and 38 deletions
|
@ -7,16 +7,21 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Pawel Piech (WindRiver) - https://bugs.eclipse.org/bugs/show_bug.cgi?id=228063
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
||||||
|
import org.eclipse.cdt.debug.core.model.ISteppingModeTarget;
|
||||||
|
import org.eclipse.cdt.debug.core.model.ITargetProperties;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
|
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
|
||||||
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
|
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
|
||||||
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
|
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
|
||||||
import org.eclipse.debug.core.model.IDebugElement;
|
import org.eclipse.debug.core.model.IDebugElement;
|
||||||
import org.eclipse.debug.core.model.IDebugTarget;
|
import org.eclipse.debug.core.model.IDebugTarget;
|
||||||
|
import org.eclipse.debug.core.model.IDisconnect;
|
||||||
|
import org.eclipse.debug.core.model.ITerminate;
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
@ -31,7 +36,7 @@ import org.eclipse.ui.actions.ActionDelegate;
|
||||||
*/
|
*/
|
||||||
public class ToggleInstructionStepModeActionDelegate extends ActionDelegate implements IViewActionDelegate, IPropertyChangeListener {
|
public class ToggleInstructionStepModeActionDelegate extends ActionDelegate implements IViewActionDelegate, IPropertyChangeListener {
|
||||||
|
|
||||||
private ICDebugTarget fTarget = null;
|
private ISteppingModeTarget fTarget = null;
|
||||||
|
|
||||||
private IAction fAction = null;
|
private IAction fAction = null;
|
||||||
|
|
||||||
|
@ -62,12 +67,13 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
|
||||||
* @see org.eclipse.ui.IActionDelegate2#dispose()
|
* @see org.eclipse.ui.IActionDelegate2#dispose()
|
||||||
*/
|
*/
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
ICDebugTarget target = getTarget();
|
ISteppingModeTarget target = getTarget();
|
||||||
if ( target != null )
|
if ( target != null && target instanceof ITargetProperties ) {
|
||||||
target.removePropertyChangeListener( this );
|
((ITargetProperties)target).removePropertyChangeListener( this );
|
||||||
setTarget( null );
|
}
|
||||||
setAction( null );
|
setTarget( null );
|
||||||
}
|
setAction( null );
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
|
* @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
|
||||||
|
@ -83,18 +89,18 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
|
||||||
*/
|
*/
|
||||||
public void run( IAction action ) {
|
public void run( IAction action ) {
|
||||||
boolean enabled = getAction().isChecked();
|
boolean enabled = getAction().isChecked();
|
||||||
ICDebugTarget target = getTarget();
|
ISteppingModeTarget target = getTarget();
|
||||||
if ( target != null ) {
|
if ( target != null ) {
|
||||||
target.enableInstructionStepping( enabled );
|
target.enableInstructionStepping( enabled );
|
||||||
if ( enabled ) {
|
if ( enabled ) {
|
||||||
try {
|
try {
|
||||||
getView().getSite().getPage().showView( ICDebugUIConstants.ID_DISASSEMBLY_VIEW );
|
getView().getSite().getPage().showView( ICDebugUIConstants.ID_DISASSEMBLY_VIEW );
|
||||||
}
|
}
|
||||||
catch( PartInitException e ) {
|
catch( PartInitException e ) {
|
||||||
CDebugUIPlugin.log( e.getStatus() );
|
CDebugUIPlugin.log( e.getStatus() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -108,30 +114,41 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
|
||||||
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
|
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
|
||||||
*/
|
*/
|
||||||
public void selectionChanged( IAction action, ISelection selection ) {
|
public void selectionChanged( IAction action, ISelection selection ) {
|
||||||
ICDebugTarget newTarget = null;
|
ISteppingModeTarget newTarget = null;
|
||||||
if ( selection instanceof IStructuredSelection ) {
|
if ( selection instanceof IStructuredSelection ) {
|
||||||
newTarget = getTargetFromSelection( ((IStructuredSelection)selection).getFirstElement() );
|
newTarget = getTargetFromSelection( ((IStructuredSelection)selection).getFirstElement() );
|
||||||
}
|
}
|
||||||
ICDebugTarget oldTarget = getTarget();
|
ISteppingModeTarget oldTarget = getTarget();
|
||||||
if ( oldTarget != null && !oldTarget.equals( newTarget ) ) {
|
if ( oldTarget != null && !oldTarget.equals( newTarget ) ) {
|
||||||
oldTarget.removePropertyChangeListener( this );
|
if ( oldTarget instanceof ITargetProperties ) {
|
||||||
setTarget( null );
|
((ITargetProperties)oldTarget).removePropertyChangeListener( this );
|
||||||
action.setChecked( false );
|
}
|
||||||
}
|
setTarget( null );
|
||||||
if ( newTarget != null && !newTarget.isTerminated() && !newTarget.isDisconnected() ) {
|
action.setChecked( false );
|
||||||
setTarget( newTarget );
|
}
|
||||||
newTarget.addPropertyChangeListener( this );
|
if ( newTarget != null && !isTerminated( newTarget ) ) {
|
||||||
action.setChecked( newTarget.isInstructionSteppingEnabled() );
|
setTarget( newTarget );
|
||||||
}
|
if ( newTarget instanceof ITargetProperties ) {
|
||||||
action.setEnabled( newTarget != null && newTarget.supportsInstructionStepping()
|
((ITargetProperties)newTarget).addPropertyChangeListener( this );
|
||||||
&& !newTarget.isTerminated() && !newTarget.isDisconnected() );
|
}
|
||||||
|
action.setChecked( newTarget.isInstructionSteppingEnabled() );
|
||||||
|
}
|
||||||
|
action.setEnabled(
|
||||||
|
newTarget != null
|
||||||
|
&& newTarget.supportsInstructionStepping()
|
||||||
|
&& !isTerminated( newTarget ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICDebugTarget getTarget() {
|
private boolean isTerminated( ISteppingModeTarget target ) {
|
||||||
|
return ( (target instanceof ITerminate && ((ITerminate)target).isTerminated())
|
||||||
|
|| (target instanceof IDisconnect && ((IDisconnect)target).isDisconnected()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private ISteppingModeTarget getTarget() {
|
||||||
return this.fTarget;
|
return this.fTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTarget( ICDebugTarget target ) {
|
private void setTarget( ISteppingModeTarget target ) {
|
||||||
this.fTarget = target;
|
this.fTarget = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue