blob: 34e5d3db0b5e67a8b7f9194baece20fc787e1597 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
package org.eclipse.debug.internal.ui;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.debug.core.*;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.help.WorkbenchHelp;
/**
* Removes all breakpoints from the source (markers) and remove all
* breakpoints from processes
*/
public class RemoveAllBreakpointsAction extends Action implements IBreakpointListener {
private static final String PREFIX= "remove_all_breakpoints_action.";
private static final String ERROR= "error.";
private static final String STATUS= PREFIX + "status";
public RemoveAllBreakpointsAction() {
super(DebugUIUtils.getResourceString(PREFIX + TEXT));
setToolTipText(DebugUIUtils.getResourceString(PREFIX + TOOL_TIP_TEXT));
setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_REMOVE_ALL));
setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_REMOVE_ALL));
setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_REMOVE_ALL));
WorkbenchHelp.setHelp(
this,
new Object[] { IDebugHelpContextIds.REMOVE_ALL_ACTION });
}
/**
* @see IAction
*/
public void run() {
final IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
final IBreakpoint[] breakpoints= breakpointManager.getBreakpoints();
final MultiStatus ms= new MultiStatus(DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(), IDebugStatusConstants.REQUEST_FAILED, DebugUIUtils.getResourceString(STATUS), null);
IWorkspaceRunnable r = new IWorkspaceRunnable() {
public void run(IProgressMonitor pm) {
for (int i= 0; i < breakpoints.length; i++) {
try {
breakpointManager.removeBreakpoint(breakpoints[i], true);
} catch (CoreException e) {
ms.merge(e.getStatus());
}
}
}
};
try {
ResourcesPlugin.getWorkspace().run(r, null);
} catch (CoreException e) {
ms.merge(e.getStatus());
}
if (!ms.isOK()) {
DebugUIUtils.errorDialog(DebugUIPlugin.getActiveWorkbenchWindow().getShell(), PREFIX + ERROR, ms);
}
}
/**
* @see IBreakpointListener
*/
public void breakpointAdded(IBreakpoint breakpoint) {
breakpointAltered();
}
/**
* @see IBreakpointListener
*/
public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
}
/**
* @see IBreakpointListener
*/
public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
breakpointAltered();
}
protected void breakpointAltered() {
boolean enable= DebugPlugin.getDefault().getBreakpointManager().getBreakpoints().length == 0 ? false : true;
setEnabled(enable);
}
}
|