mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 358382 - Instruction stepping mode button becomes disabled
This commit is contained in:
parent
b82f3de2e3
commit
b32dd2799c
2 changed files with 44 additions and 17 deletions
|
@ -272,6 +272,17 @@
|
||||||
helpContextId="move_to_line_action_context"
|
helpContextId="move_to_line_action_context"
|
||||||
label="%GlobalMoveToLineAction.label"
|
label="%GlobalMoveToLineAction.label"
|
||||||
menubarPath="org.eclipse.ui.run/stepGroup"/>
|
menubarPath="org.eclipse.ui.run/stepGroup"/>
|
||||||
|
<action
|
||||||
|
class="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
|
||||||
|
helpContextId="toggle_instruction_step_mode_action_context"
|
||||||
|
icon="icons/elcl16/instr_step.gif"
|
||||||
|
id="org.eclipse.cdt.debug.ui.actions.ToggleInstructionStepMode"
|
||||||
|
label="%ToggleInstructionStepModeAction.label"
|
||||||
|
menubarPath="org.eclipse.ui.run/stepGroup"
|
||||||
|
state="false"
|
||||||
|
style="toggle"
|
||||||
|
toolbarPath="org.eclipse.debug.ui.main.toolbar/renderGroup">
|
||||||
|
</action>
|
||||||
</actionSet>
|
</actionSet>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
|
@ -398,7 +409,6 @@
|
||||||
style="toggle"
|
style="toggle"
|
||||||
id="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
|
id="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
|
||||||
class="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
|
class="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
|
||||||
enablesFor="1"
|
|
||||||
icon="icons/elcl16/instr_step.gif"
|
icon="icons/elcl16/instr_step.gif"
|
||||||
helpContextId="toggle_instruction_step_mode_action_context"
|
helpContextId="toggle_instruction_step_mode_action_context"
|
||||||
label="%ToggleInstructionStepModeAction.label"
|
label="%ToggleInstructionStepModeAction.label"
|
||||||
|
@ -897,7 +907,6 @@
|
||||||
class="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
|
class="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
|
||||||
disabledIcon="icons/dlcl16/instr_step.gif"
|
disabledIcon="icons/dlcl16/instr_step.gif"
|
||||||
icon="icons/elcl16/instr_step.gif"
|
icon="icons/elcl16/instr_step.gif"
|
||||||
enablesFor="1"
|
|
||||||
label="%ToggleInstructionStepModeAction.label"
|
label="%ToggleInstructionStepModeAction.label"
|
||||||
helpContextId="toggle_instruction_step_mode_action_context"
|
helpContextId="toggle_instruction_step_mode_action_context"
|
||||||
tooltip="%ToggleInstructionStepModeAction.tooltip">
|
tooltip="%ToggleInstructionStepModeAction.tooltip">
|
||||||
|
|
|
@ -23,25 +23,33 @@ 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.IDisconnect;
|
||||||
import org.eclipse.debug.core.model.ITerminate;
|
import org.eclipse.debug.core.model.ITerminate;
|
||||||
|
import org.eclipse.debug.ui.DebugUITools;
|
||||||
|
import org.eclipse.debug.ui.contexts.DebugContextEvent;
|
||||||
|
import org.eclipse.debug.ui.contexts.IDebugContextListener;
|
||||||
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;
|
||||||
import org.eclipse.swt.widgets.Event;
|
import org.eclipse.swt.widgets.Event;
|
||||||
import org.eclipse.ui.IViewActionDelegate;
|
import org.eclipse.ui.IViewActionDelegate;
|
||||||
import org.eclipse.ui.IViewPart;
|
import org.eclipse.ui.IViewPart;
|
||||||
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
||||||
import org.eclipse.ui.PartInitException;
|
import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.actions.ActionDelegate;
|
import org.eclipse.ui.actions.ActionDelegate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns instruction step mode on/off for selected target.
|
* Turns instruction step mode on/off for selected target.
|
||||||
*/
|
*/
|
||||||
public class ToggleInstructionStepModeActionDelegate extends ActionDelegate implements IViewActionDelegate, IPropertyChangeListener {
|
public class ToggleInstructionStepModeActionDelegate extends ActionDelegate
|
||||||
|
implements IViewActionDelegate, IWorkbenchWindowActionDelegate, IPropertyChangeListener, IDebugContextListener
|
||||||
|
{
|
||||||
|
|
||||||
private ISteppingModeTarget fTarget = null;
|
private ISteppingModeTarget fTarget = null;
|
||||||
|
|
||||||
private IAction fAction = null;
|
private IAction fAction = null;
|
||||||
|
|
||||||
private IViewPart fView;
|
private IWorkbenchWindow fWindow = null;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
|
* @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
|
||||||
|
@ -63,14 +71,22 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void init( IViewPart view ) {
|
public void init( IViewPart view ) {
|
||||||
fView = view;
|
fWindow = view.getSite().getWorkbenchWindow();
|
||||||
|
DebugUITools.getDebugContextManager().getContextService(fWindow).addDebugContextListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(IWorkbenchWindow window) {
|
||||||
|
fWindow = window;
|
||||||
|
DebugUITools.getDebugContextManager().getContextService(fWindow).addDebugContextListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.ui.IActionDelegate2#dispose()
|
* @see org.eclipse.ui.IActionDelegate2#dispose()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
DebugUITools.getDebugContextManager().getContextService(fWindow).removeDebugContextListener(this);
|
||||||
ISteppingModeTarget target = getTarget();
|
ISteppingModeTarget target = getTarget();
|
||||||
if ( target != null && target instanceof ITargetProperties ) {
|
if ( target != null && target instanceof ITargetProperties ) {
|
||||||
((ITargetProperties)target).removePropertyChangeListener( this );
|
((ITargetProperties)target).removePropertyChangeListener( this );
|
||||||
|
@ -100,7 +116,10 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
|
||||||
target.enableInstructionStepping( enabled );
|
target.enableInstructionStepping( enabled );
|
||||||
if ( enabled && target instanceof ICDebugTarget ) {
|
if ( enabled && target instanceof ICDebugTarget ) {
|
||||||
try {
|
try {
|
||||||
getView().getSite().getPage().showView( ICDebugUIConstants.ID_DSF_DISASSEMBLY_VIEW );
|
IWorkbenchPage page = fWindow.getActivePage();
|
||||||
|
if (page != null) {
|
||||||
|
page.showView( ICDebugUIConstants.ID_DSF_DISASSEMBLY_VIEW );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch( PartInitException e ) {
|
catch( PartInitException e ) {
|
||||||
CDebugUIPlugin.log( e.getStatus() );
|
CDebugUIPlugin.log( e.getStatus() );
|
||||||
|
@ -117,11 +136,11 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
|
||||||
run( action );
|
run( action );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void selectionChanged( IAction action, ISelection selection ) {
|
public void debugContextChanged(DebugContextEvent event) {
|
||||||
|
if (fAction == null) return;
|
||||||
|
|
||||||
|
ISelection selection = event.getContext();
|
||||||
ISteppingModeTarget newTarget = null;
|
ISteppingModeTarget newTarget = null;
|
||||||
if ( selection instanceof IStructuredSelection ) {
|
if ( selection instanceof IStructuredSelection ) {
|
||||||
newTarget = getTargetFromSelection( ((IStructuredSelection)selection).getFirstElement() );
|
newTarget = getTargetFromSelection( ((IStructuredSelection)selection).getFirstElement() );
|
||||||
|
@ -132,16 +151,16 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
|
||||||
((ITargetProperties)oldTarget).removePropertyChangeListener( this );
|
((ITargetProperties)oldTarget).removePropertyChangeListener( this );
|
||||||
}
|
}
|
||||||
setTarget( null );
|
setTarget( null );
|
||||||
action.setChecked( false );
|
fAction.setChecked( false );
|
||||||
}
|
}
|
||||||
if ( newTarget != null && !isTerminated( newTarget ) ) {
|
if ( newTarget != null && !isTerminated( newTarget ) ) {
|
||||||
setTarget( newTarget );
|
setTarget( newTarget );
|
||||||
if ( newTarget instanceof ITargetProperties ) {
|
if ( newTarget instanceof ITargetProperties ) {
|
||||||
((ITargetProperties)newTarget).addPropertyChangeListener( this );
|
((ITargetProperties)newTarget).addPropertyChangeListener( this );
|
||||||
}
|
}
|
||||||
action.setChecked( newTarget.isInstructionSteppingEnabled() );
|
fAction.setChecked( newTarget.isInstructionSteppingEnabled() );
|
||||||
}
|
}
|
||||||
action.setEnabled(
|
fAction.setEnabled(
|
||||||
newTarget != null
|
newTarget != null
|
||||||
&& newTarget.supportsInstructionStepping()
|
&& newTarget.supportsInstructionStepping()
|
||||||
&& !isTerminated( newTarget ) );
|
&& !isTerminated( newTarget ) );
|
||||||
|
@ -183,8 +202,7 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
|
||||||
}
|
}
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IViewPart getView() {
|
|
||||||
return fView;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue