forked from eclipse-jdt/eclipse.jdt.debug
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clear all conditions in breakpoints eclipse-jdt#549
Provides additional right click menu option for disabling all the conditions set in breakpoints. Will be useful for disabling every conditions in breakpoints by keeping the condition in the text editor itself. Enhancement eclipse-jdt#549
- Loading branch information
Showing
8 changed files
with
150 additions
and
7 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
...debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/RemoveAllCondtionalBreakpoints.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 IBM Corporation. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBM - Initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.jdt.internal.debug.ui.actions; | ||
|
||
import org.eclipse.core.resources.IWorkspace; | ||
import org.eclipse.core.resources.IWorkspaceRunnable; | ||
import org.eclipse.core.resources.ResourcesPlugin; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.core.runtime.Status; | ||
import org.eclipse.core.runtime.jobs.Job; | ||
import org.eclipse.debug.core.DebugPlugin; | ||
import org.eclipse.debug.core.model.IBreakpoint; | ||
import org.eclipse.debug.internal.ui.DebugUIPlugin; | ||
import org.eclipse.debug.internal.ui.actions.breakpoints.RemoveAllTriggerPointsAction; | ||
import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants; | ||
import org.eclipse.jdt.internal.debug.core.breakpoints.JavaLineBreakpoint; | ||
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; | ||
import org.eclipse.jface.action.IAction; | ||
import org.eclipse.jface.dialogs.IDialogConstants; | ||
import org.eclipse.jface.dialogs.MessageDialogWithToggle; | ||
import org.eclipse.jface.preference.IPreferenceStore; | ||
import org.eclipse.ui.IWorkbenchWindow; | ||
|
||
|
||
public class RemoveAllCondtionalBreakpoints extends RemoveAllTriggerPointsAction { | ||
public RemoveAllCondtionalBreakpoints() { | ||
super(); | ||
} | ||
@Override | ||
protected boolean isEnabled() { | ||
for (IBreakpoint breakpoint : DebugPlugin.getDefault().getBreakpointManager().getBreakpoints()) { | ||
if (breakpoint instanceof JavaLineBreakpoint javaBreakpoint) { | ||
try { | ||
if (javaBreakpoint.isConditionEnabled()) { | ||
return true; | ||
} | ||
} catch (CoreException e) { | ||
DebugUIPlugin.log(e); | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void run(IAction action) { | ||
IWorkbenchWindow window = JDIDebugUIPlugin.getActiveWorkbenchWindow(); | ||
if (window == null) { | ||
return; | ||
} | ||
IPreferenceStore store = JDIDebugUIPlugin.getDefault().getPreferenceStore(); | ||
boolean prompt = store.getBoolean(IJavaDebugUIConstants.PREF_PROMPT_REMOVE_ALL_CONDITIONAL_BREAKPOINTS); | ||
boolean proceed = true; | ||
if (prompt) { | ||
MessageDialogWithToggle mdwt = MessageDialogWithToggle.openYesNoQuestion(window.getShell(), ActionMessages.ClearAllCondtionsInBreakpointsAction_0, ActionMessages.ClearAllCondtionsInBreakpointsAction_1, ActionMessages.ClearAllCondtionsInBreakpointsAction_2, !prompt, null, null); | ||
if (mdwt.getReturnCode() != IDialogConstants.YES_ID) { | ||
proceed = false; | ||
} else { | ||
store.setValue(IJavaDebugUIConstants.PREF_PROMPT_REMOVE_ALL_CONDITIONAL_BREAKPOINTS, !mdwt.getToggleState()); | ||
} | ||
} | ||
if (proceed) { | ||
new Job(ActionMessages.ClearAllCondtionsInBreakpointsAction_1) { | ||
@Override | ||
protected IStatus run(IProgressMonitor monitor) { | ||
try { | ||
for (IBreakpoint breakpoint : DebugPlugin.getDefault().getBreakpointManager().getBreakpoints()) { | ||
if (breakpoint instanceof JavaLineBreakpoint javaBp) { | ||
if (javaBp.isConditionEnabled()) { | ||
javaBp.setConditionEnabled(false); | ||
} | ||
} | ||
} | ||
refreshAllBreakpoints(); | ||
} catch (Exception e) { | ||
DebugUIPlugin.log(e); | ||
return Status.CANCEL_STATUS; | ||
} | ||
return Status.OK_STATUS; | ||
} | ||
}.schedule(); | ||
} | ||
} | ||
|
||
private void refreshAllBreakpoints() { | ||
IWorkspaceRunnable runnable = monitor -> { | ||
for (IBreakpoint breakpoint : DebugPlugin.getDefault().getBreakpointManager().getBreakpoints()) { | ||
try { | ||
breakpoint.getMarker().setAttribute(IBreakpoint.ENABLED, breakpoint.isEnabled()); | ||
} catch (CoreException e) { | ||
DebugPlugin.log(e); | ||
} | ||
} | ||
}; | ||
try { | ||
ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null); | ||
} catch (CoreException e) { | ||
DebugPlugin.log(e); | ||
} | ||
} | ||
|
||
} |