Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2012-04-03 09:51:38 -0400
committerPawel Piech2012-04-03 14:50:34 -0400
commitb32dd2799ca37c55b83c91f2cc94d2a5de440102 (patch)
treea6a4a24e74b3157a931dde4ff8bf5d04a9d3d858 /debug/org.eclipse.cdt.debug.ui/src/org
parentb82f3de2e3bb2e6de7040602a5edba2e22af4310 (diff)
downloadorg.eclipse.cdt-b32dd2799ca37c55b83c91f2cc94d2a5de440102.tar.gz
org.eclipse.cdt-b32dd2799ca37c55b83c91f2cc94d2a5de440102.tar.xz
org.eclipse.cdt-b32dd2799ca37c55b83c91f2cc94d2a5de440102.zip
Bug 358382 - Instruction stepping mode button becomes disabled
Diffstat (limited to 'debug/org.eclipse.cdt.debug.ui/src/org')
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleInstructionStepModeActionDelegate.java48
1 files changed, 33 insertions, 15 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleInstructionStepModeActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleInstructionStepModeActionDelegate.java
index c7cb99c91b..d1197073c8 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleInstructionStepModeActionDelegate.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleInstructionStepModeActionDelegate.java
@@ -23,25 +23,33 @@ import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IDisconnect;
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.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IViewActionDelegate;
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.actions.ActionDelegate;
/**
* 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 IAction fAction = null;
- private IViewPart fView;
+ private IWorkbenchWindow fWindow = null;
/* (non-Javadoc)
* @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
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)
* @see org.eclipse.ui.IActionDelegate2#dispose()
*/
@Override
public void dispose() {
+ DebugUITools.getDebugContextManager().getContextService(fWindow).removeDebugContextListener(this);
ISteppingModeTarget target = getTarget();
if ( target != null && target instanceof ITargetProperties ) {
((ITargetProperties)target).removePropertyChangeListener( this );
@@ -100,7 +116,10 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
target.enableInstructionStepping( enabled );
if ( enabled && target instanceof ICDebugTarget ) {
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 ) {
CDebugUIPlugin.log( e.getStatus() );
@@ -117,11 +136,11 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
run( action );
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
- */
@Override
- public void selectionChanged( IAction action, ISelection selection ) {
+ public void debugContextChanged(DebugContextEvent event) {
+ if (fAction == null) return;
+
+ ISelection selection = event.getContext();
ISteppingModeTarget newTarget = null;
if ( selection instanceof IStructuredSelection ) {
newTarget = getTargetFromSelection( ((IStructuredSelection)selection).getFirstElement() );
@@ -132,16 +151,16 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
((ITargetProperties)oldTarget).removePropertyChangeListener( this );
}
setTarget( null );
- action.setChecked( false );
+ fAction.setChecked( false );
}
if ( newTarget != null && !isTerminated( newTarget ) ) {
setTarget( newTarget );
if ( newTarget instanceof ITargetProperties ) {
((ITargetProperties)newTarget).addPropertyChangeListener( this );
}
- action.setChecked( newTarget.isInstructionSteppingEnabled() );
+ fAction.setChecked( newTarget.isInstructionSteppingEnabled() );
}
- action.setEnabled(
+ fAction.setEnabled(
newTarget != null
&& newTarget.supportsInstructionStepping()
&& !isTerminated( newTarget ) );
@@ -183,8 +202,7 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
}
return target;
}
-
- private IViewPart getView() {
- return fView;
- }
+
+
+
}

Back to the top