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
9 changed files
with
260 additions
and
8 deletions.
There are no files selected for viewing
Binary file added
BIN
+284 Bytes
org.eclipse.jdt.debug.ui/icons/full/elcl16/disable_conditional_breakpoints.png
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
2 changes: 1 addition & 1 deletion
2
...se.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIDebugUIPreferenceInitializer.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
111 changes: 111 additions & 0 deletions
111
...bug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/AbstractDisableAllActionDelegate.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,111 @@ | ||
/******************************************************************************* | ||
* 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 Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.jdt.internal.debug.ui.actions; | ||
|
||
import org.eclipse.jface.action.IAction; | ||
import org.eclipse.jface.viewers.ISelection; | ||
import org.eclipse.swt.widgets.Event; | ||
import org.eclipse.ui.IActionDelegate2; | ||
import org.eclipse.ui.IViewActionDelegate; | ||
import org.eclipse.ui.IViewPart; | ||
import org.eclipse.ui.IWorkbenchWindow; | ||
import org.eclipse.ui.IWorkbenchWindowActionDelegate; | ||
|
||
/** | ||
* This class is a base implementation of a 'Disable all' debug action | ||
* | ||
* This class is intended to be extended by clients | ||
* | ||
* @see IViewActionDelegate | ||
* @see IActionDelegate2 | ||
* @see IWorkbenchWindowActionDelegate | ||
*/ | ||
|
||
public abstract class AbstractDisableAllActionDelegate implements IViewActionDelegate, IActionDelegate2, IWorkbenchWindowActionDelegate { | ||
|
||
/** | ||
* The underlying <code>IAction</code> | ||
*/ | ||
private IAction fAction; | ||
|
||
/** | ||
* Needed for reflective creation | ||
*/ | ||
public AbstractDisableAllActionDelegate() { | ||
} | ||
|
||
@Override | ||
public void dispose() { | ||
fAction = null; | ||
} | ||
|
||
@Override | ||
public void init(IAction action) { | ||
fAction = action; | ||
} | ||
|
||
/** | ||
* Returns this delegate's action. | ||
* | ||
* @return the underlying <code>IAction</code> | ||
*/ | ||
protected IAction getAction() { | ||
return fAction; | ||
} | ||
|
||
@Override | ||
public void runWithEvent(IAction action, Event event) { | ||
run(action); | ||
} | ||
|
||
@Override | ||
public void init(IViewPart view) { | ||
initialize(); | ||
update(); | ||
} | ||
|
||
@Override | ||
public void init(IWorkbenchWindow window) { | ||
initialize(); | ||
update(); | ||
} | ||
|
||
/** | ||
* Initializes any listeners, etc. | ||
*/ | ||
protected abstract void initialize(); | ||
|
||
/** | ||
* Update enablement. | ||
*/ | ||
protected void update() { | ||
IAction action = getAction(); | ||
if (action != null) { | ||
action.setEnabled(isEnabled()); | ||
} | ||
} | ||
|
||
/** | ||
* Returns whether this action is enabled | ||
* | ||
* @return true if this action is enabled, false otherwise | ||
*/ | ||
protected abstract boolean isEnabled(); | ||
|
||
@Override | ||
public void selectionChanged(IAction action, ISelection s) { | ||
|
||
} | ||
|
||
} |
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
123 changes: 123 additions & 0 deletions
123
...t.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/DisableCondtionalBreakpoints.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,123 @@ | ||
/******************************************************************************* | ||
* 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.IMarkerDelta; | ||
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.IBreakpointsListener; | ||
import org.eclipse.debug.core.model.IBreakpoint; | ||
import org.eclipse.debug.internal.ui.DebugUIPlugin; | ||
import org.eclipse.jdt.internal.debug.core.breakpoints.JavaLineBreakpoint; | ||
import org.eclipse.jface.action.IAction; | ||
|
||
public class DisableCondtionalBreakpoints extends AbstractDisableAllActionDelegate implements IBreakpointsListener { | ||
public DisableCondtionalBreakpoints() { | ||
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) { | ||
|
||
new Job(ActionMessages.DisableConditionalBreakpoints_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); | ||
} | ||
} | ||
|
||
@Override | ||
protected void initialize() { | ||
DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this); | ||
} | ||
|
||
@Override | ||
public void breakpointsAdded(IBreakpoint[] breakpoints) { | ||
update(); | ||
} | ||
|
||
@Override | ||
public void breakpointsRemoved(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { | ||
if (getAction() != null) { | ||
update(); | ||
} | ||
} | ||
|
||
@Override | ||
public void breakpointsChanged(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { | ||
update(); | ||
} | ||
|
||
@Override | ||
public void dispose() { | ||
DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this); | ||
super.dispose(); | ||
} | ||
|
||
} |