1 11 package org.eclipse.debug.internal.ui.actions.breakpoints; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.core.runtime.IProgressMonitor; 16 import org.eclipse.debug.core.DebugPlugin; 17 import org.eclipse.debug.core.IBreakpointManager; 18 import org.eclipse.debug.core.IBreakpointManagerListener; 19 import org.eclipse.debug.internal.ui.DebugPluginImages; 20 import org.eclipse.debug.internal.ui.DebugUIPlugin; 21 import org.eclipse.debug.internal.ui.IDebugHelpContextIds; 22 import org.eclipse.debug.internal.ui.actions.ActionMessages; 23 import org.eclipse.debug.ui.IDebugUIConstants; 24 import org.eclipse.jface.action.Action; 25 import org.eclipse.jface.action.IAction; 26 import org.eclipse.jface.operation.IRunnableWithProgress; 27 import org.eclipse.jface.viewers.ISelection; 28 import org.eclipse.ui.IWorkbenchWindow; 29 import org.eclipse.ui.IWorkbenchWindowActionDelegate; 30 import org.eclipse.ui.PlatformUI; 31 32 40 public class SkipAllBreakpointsAction extends Action implements IWorkbenchWindowActionDelegate, IBreakpointManagerListener { 41 42 private IAction fAction; 44 45 public SkipAllBreakpointsAction() { 46 super(ActionMessages.SkipAllBreakpointsAction_0); 47 setToolTipText(ActionMessages.SkipAllBreakpointsAction_0); 48 setDescription(ActionMessages.SkipAllBreakpointsAction_2); 49 setImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_SKIP_BREAKPOINTS)); 50 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.SKIP_ALL_BREAKPOINT_ACTION); 51 updateActionCheckedState(); 52 } 53 54 57 public void run(){ 58 final IBreakpointManager manager = getBreakpointManager(); 59 IRunnableWithProgress runnable = new IRunnableWithProgress() { 60 public void run(IProgressMonitor monitor) throws InvocationTargetException , InterruptedException { 61 if(!monitor.isCanceled()) { 62 manager.setEnabled(!manager.isEnabled()); 63 } 64 } 65 }; 66 67 try { 68 DebugUIPlugin.getDefault().getWorkbench().getProgressService().busyCursorWhile(runnable); 69 } 70 catch (InvocationTargetException e) {} 71 catch (InterruptedException e) {} 72 } 73 74 78 public void updateActionCheckedState() { 79 if (fAction != null) { 80 fAction.setChecked(!getBreakpointManager().isEnabled()); 81 } else { 82 setChecked(!getBreakpointManager().isEnabled()); 83 } 84 } 85 86 91 public static IBreakpointManager getBreakpointManager() { 92 return DebugPlugin.getDefault().getBreakpointManager(); 93 } 94 95 98 public void dispose() { 99 getBreakpointManager().removeBreakpointManagerListener(this); 100 } 101 102 105 public void init(IWorkbenchWindow window) { 106 updateActionCheckedState(); 107 getBreakpointManager().addBreakpointManagerListener(this); 108 } 109 110 113 public void run(IAction action) { 114 run(); 115 } 116 117 120 public void selectionChanged(IAction action, ISelection selection) { 121 fAction = action; 122 } 123 124 127 public void breakpointManagerEnablementChanged(boolean enabled) { 128 if (fAction != null) { 129 fAction.setChecked(!enabled); 130 } 131 } 132 } 133 | Popular Tags |