Skip to content

Commit f72266a

Browse files
SougandhSmerks
authored andcommitted
Add option to disable all breakpoints except selected ones
This commit introduces a new menu option that allows users to select multiple enabled breakpoints and disable all other breakpoints except the ones selected. This provides more flexibility and control over breakpoint management.
1 parent ab523c2 commit f72266a

File tree

4 files changed

+112
-3
lines changed

4 files changed

+112
-3
lines changed

debug/org.eclipse.debug.ui/plugin.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
###############################################################################
2-
# Copyright (c) 2000, 2020 IBM Corporation and others.
2+
# Copyright (c) 2000, 2025 IBM Corporation and others.
33
#
44
# This program and the accompanying materials
55
# are made available under the terms of the Eclipse Public License 2.0
@@ -83,6 +83,7 @@ DetailPaneFontDefinition.description=The detail pane text font is used in the de
8383
DetailPaneFactoriesExtension.name=Detail Pane Factories
8484
DisableBreakpointsAction.label=&Disable
8585
DisableAllBreakpointsAction.label=Disa&ble All
86+
DisableOtherBreakpointsAction.label=Disable Others
8687
EnableAllBreakpointsAction.label=Ena&ble All
8788
EnableBreakpointsAction.label=&Enable
8889
ExpandAll.label=Expand All

debug/org.eclipse.debug.ui/plugin.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<?eclipse version="3.0"?>
33
<!--
4-
Copyright (c) 2005, 2021 IBM Corporation and others.
4+
Copyright (c) 2005, 2025 IBM Corporation and others.
55
66
This program and the accompanying materials
77
are made available under the terms of the Eclipse Public License 2.0
@@ -1548,6 +1548,15 @@
15481548
menubarPath="breakpointGroup"
15491549
id="org.eclipse.debug.ui.actions.DisableAllBreakpoint">
15501550
</action>
1551+
<action
1552+
label="%DisableOtherBreakpointsAction.label"
1553+
icon="$nl$/icons/full/elcl16/disabled_co.png"
1554+
helpContextId="disable_breakpoint_action_context"
1555+
class="org.eclipse.debug.internal.ui.actions.breakpoints.DisableAllOtherBreakpointsAction"
1556+
menubarPath="breakpointGroup"
1557+
enablesFor="+"
1558+
id="org.eclipse.debug.ui.actions.DisableAllOtherBreakpoint">
1559+
</action>
15511560
<action
15521561
label="%DisableBreakpointsAction.label"
15531562
icon="$nl$/icons/full/elcl16/disabled_co.png"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 IBM Corporation and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* IBM Corporation - initial API and implementation
13+
*******************************************************************************/
14+
package org.eclipse.debug.internal.ui.actions.breakpoints;
15+
16+
import java.util.HashSet;
17+
import java.util.List;
18+
import java.util.Set;
19+
20+
import org.eclipse.core.resources.IWorkspaceRunnable;
21+
import org.eclipse.core.resources.ResourcesPlugin;
22+
import org.eclipse.core.runtime.CoreException;
23+
import org.eclipse.core.runtime.MultiStatus;
24+
import org.eclipse.core.runtime.NullProgressMonitor;
25+
import org.eclipse.debug.core.DebugException;
26+
import org.eclipse.debug.core.DebugPlugin;
27+
import org.eclipse.debug.core.model.IBreakpoint;
28+
import org.eclipse.debug.internal.ui.DebugUIPlugin;
29+
import org.eclipse.debug.internal.ui.actions.ActionMessages;
30+
import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointContainer;
31+
import org.eclipse.jface.action.IAction;
32+
import org.eclipse.jface.viewers.IStructuredSelection;
33+
import org.eclipse.ui.IWorkbenchWindow;
34+
35+
public class DisableAllOtherBreakpointsAction extends EnableBreakpointsAction {
36+
37+
/**
38+
* If this action can enable breakpoints
39+
*
40+
* @return always <code>false</code>
41+
*/
42+
@Override
43+
protected boolean isEnableAction() {
44+
return false;
45+
}
46+
47+
@Override
48+
public void run(IAction action) {
49+
IStructuredSelection selection = getSelection();
50+
if (selection.isEmpty()) {
51+
return;
52+
}
53+
final List<Object> selectedBreakpoints = selection.toList();
54+
final MultiStatus ms = new MultiStatus(DebugUIPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED,
55+
ActionMessages.EnableBreakpointAction_Enable_breakpoint_s__failed_2, null);
56+
IWorkspaceRunnable runnable = monitor -> {
57+
try {
58+
Set<IBreakpoint> excludedBreakpoints = new HashSet<>();
59+
for (Object selectedObj : selectedBreakpoints) {
60+
if (selectedObj instanceof IBreakpoint breakPoint && breakPoint.isEnabled()) {
61+
excludedBreakpoints.add(breakPoint);
62+
}
63+
if (selectedObj instanceof IBreakpointContainer breakPointContainer) {
64+
for (IBreakpoint bp : breakPointContainer.getBreakpoints()) {
65+
if (bp.isEnabled()) {
66+
excludedBreakpoints.add(bp);
67+
}
68+
}
69+
}
70+
}
71+
for (IBreakpoint brk : DebugPlugin.getDefault().getBreakpointManager().getBreakpoints()) {
72+
if (!excludedBreakpoints.contains(brk)) {
73+
brk.setEnabled(false);
74+
}
75+
}
76+
77+
} catch (CoreException e) {
78+
ms.merge(e.getStatus());
79+
}
80+
};
81+
82+
try {
83+
ResourcesPlugin.getWorkspace().run(runnable, null, 0, new NullProgressMonitor());
84+
} catch (CoreException e) {
85+
DebugUIPlugin.log(e);
86+
}
87+
88+
if (!ms.isOK()) {
89+
IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
90+
if (window != null) {
91+
DebugUIPlugin.errorDialog(window.getShell(),
92+
ActionMessages.EnableBreakpointAction_Enabling_breakpoints_3,
93+
ActionMessages.EnableBreakpointAction_Exceptions_occurred_enabling_the_breakpoint_s___4, ms); //
94+
} else {
95+
DebugUIPlugin.log(ms);
96+
}
97+
}
98+
}
99+
}

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/EnableBreakpointsAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public void setEnabled(IBreakpoint[] breakpoints) throws CoreException {
134134
}
135135
}
136136

137-
private IStructuredSelection getSelection() {
137+
protected IStructuredSelection getSelection() {
138138
return (IStructuredSelection)getView().getViewSite().getSelectionProvider().getSelection();
139139
}
140140

0 commit comments

Comments
 (0)