1 11 package org.eclipse.debug.internal.ui.actions; 12 13 14 import org.eclipse.core.resources.IMarkerDelta; 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.runtime.IProgressMonitor; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.core.runtime.Status; 19 import org.eclipse.core.runtime.jobs.Job; 20 import org.eclipse.debug.core.DebugPlugin; 21 import org.eclipse.debug.core.IBreakpointManager; 22 import org.eclipse.debug.core.IBreakpointsListener; 23 import org.eclipse.debug.core.model.IBreakpoint; 24 import org.eclipse.debug.internal.ui.DebugUIPlugin; 25 import org.eclipse.jface.dialogs.MessageDialog; 26 import org.eclipse.ui.IViewPart; 27 import org.eclipse.ui.IWorkbenchWindow; 28 29 33 public class RemoveAllBreakpointsAction extends AbstractRemoveAllActionDelegate implements IBreakpointsListener { 34 35 38 protected void doAction() { 39 final IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager(); 40 final IBreakpoint[] breakpoints= breakpointManager.getBreakpoints(); 41 if (breakpoints.length < 1) { 42 return; 43 } 44 IWorkbenchWindow window= DebugUIPlugin.getActiveWorkbenchWindow(); 45 if (window == null) { 46 return; 47 } 48 boolean proceed = MessageDialog.openQuestion(window.getShell(), ActionMessages.RemoveAllBreakpointsAction_0, ActionMessages.RemoveAllBreakpointsAction_1); if (proceed) { 50 new Job(ActionMessages.RemoveAllBreakpointsAction_2) { protected IStatus run(IProgressMonitor monitor) { 52 try { 53 breakpointManager.removeBreakpoints(breakpoints, true); 54 } catch (CoreException e) { 55 DebugUIPlugin.log(e); 56 return Status.CANCEL_STATUS; 57 } 58 return Status.OK_STATUS; 59 } 60 }.schedule(); 61 } 62 } 63 64 67 protected void update() { 68 getAction().setEnabled( 69 DebugPlugin.getDefault().getBreakpointManager().hasBreakpoints()); 70 } 71 72 75 public void breakpointsAdded(IBreakpoint[] breakpoints) { 76 if (getAction() != null && !getAction().isEnabled()){ 77 update(); 78 } 79 } 80 81 84 public void breakpointsChanged(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { 85 } 86 87 90 public void breakpointsRemoved(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { 91 if (getAction() != null) { 92 update(); 93 } 94 } 95 96 99 public void init(IViewPart view) { 100 super.init(view); 101 DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this); 102 } 103 104 107 public void dispose() { 108 DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this); 109 super.dispose(); 110 } 111 112 113 116 public void init(IWorkbenchWindow window) { 117 super.init(window); 118 DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this); 119 } 120 } 121 | Popular Tags |