1 11 package org.eclipse.debug.internal.ui.actions; 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.ui.IDebugUIConstants; 23 import org.eclipse.jface.action.Action; 24 import org.eclipse.jface.action.IAction; 25 import org.eclipse.jface.operation.IRunnableWithProgress; 26 import org.eclipse.jface.viewers.ISelection; 27 import org.eclipse.ui.IWorkbenchWindow; 28 import org.eclipse.ui.IWorkbenchWindowActionDelegate; 29 import org.eclipse.ui.PlatformUI; 30 31 39 public class SkipAllBreakpointsAction extends Action implements IWorkbenchWindowActionDelegate, IBreakpointManagerListener { 40 41 private IAction fAction; 43 44 public SkipAllBreakpointsAction() { 45 super(ActionMessages.SkipAllBreakpointsAction_0); setToolTipText(ActionMessages.SkipAllBreakpointsAction_0); setDescription(ActionMessages.SkipAllBreakpointsAction_2); setImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_SKIP_BREAKPOINTS)); 49 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.SKIP_ALL_BREAKPOINT_ACTION); 50 updateActionCheckedState(); 51 } 52 53 56 public void run(){ 57 final IBreakpointManager manager = getBreakpointManager(); 58 IRunnableWithProgress runnable = new IRunnableWithProgress() { 59 public void run(IProgressMonitor monitor) throws InvocationTargetException , InterruptedException { 60 if(!monitor.isCanceled()) { 61 manager.setEnabled(!manager.isEnabled()); 62 } 63 } 64 }; 65 66 try { 67 DebugUIPlugin.getDefault().getWorkbench().getProgressService().busyCursorWhile(runnable); 68 } catch (InvocationTargetException e) { 69 } catch (InterruptedException e) { 70 } 71 } 72 73 77 public void updateActionCheckedState() { 78 if (fAction != null) { 79 fAction.setChecked(!getBreakpointManager().isEnabled()); 80 } else { 81 setChecked(!getBreakpointManager().isEnabled()); 82 } 83 } 84 85 90 public static IBreakpointManager getBreakpointManager() { 91 return DebugPlugin.getDefault().getBreakpointManager(); 92 } 93 94 97 public void dispose() { 98 getBreakpointManager().removeBreakpointManagerListener(this); 99 } 100 101 104 public void init(IWorkbenchWindow window) { 105 updateActionCheckedState(); 106 getBreakpointManager().addBreakpointManagerListener(this); 107 } 108 109 112 public void run(IAction action) { 113 run(); 114 } 115 116 119 public void selectionChanged(IAction action, ISelection selection) { 120 fAction= action; 121 } 122 123 126 public void breakpointManagerEnablementChanged(boolean enabled) { 127 if (fAction != null) { 128 fAction.setChecked(!enabled); 129 } 130 } 131 } 132 | Popular Tags |