Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable all conditions in breakpoints #549 #550

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion org.eclipse.jdt.debug.ui/plugin.properties
Original file line number Diff line number Diff line change
Expand Up @@ -335,5 +335,6 @@ OpenFromClipboardAction.label = Open from Clipboar&d
OpenFromClipboardAction.tooltip = Opens a Java element or Java Stack Trace from Clipboard
OpenFromClipboardAction.description = Opens a Java element or a Java stack trace from clipboard
OpenFromClipboardAction.name = Open from Clipboard

VariablesView.name = Variables

DisableConditionalBreakpoints.label = Disable Conditional Breakpoints
17 changes: 16 additions & 1 deletion org.eclipse.jdt.debug.ui/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<!--
Copyright (c) 2005, 2022 IBM Corporation and others.
Copyright (c) 2005, 2024 IBM Corporation and others.

This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -3865,6 +3865,21 @@ M4 = Platform-specific fourth key
type="org.eclipse.swt.widgets.Composite"
description="%descriptionSWTComposite"/>
</extension>
<extension
point="org.eclipse.ui.popupMenus">
<viewerContribution
targetID="org.eclipse.debug.ui.BreakpointView"
id="org.eclipse.jdt.debug.ui.disableConditionalBreakpoints">
<action
label="%DisableConditionalBreakpoints.label"
helpContextId="Disable_all_conditional_breakpoints_action_context"
icon="$nl$/icons/full/elcl16/disable_conditional_breakpoints.png"
class="org.eclipse.jdt.internal.debug.ui.actions.DisableCondtionalBreakpoints"
menubarPath="breakpointAdditionalGroup"
id="org.eclipse.jdt.internal.debug.ui.DisableConditionalBreakpointsAction">
</action>
</viewerContribution>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -115,6 +115,6 @@ public interface IJavaDebugUIConstants {
*
* @since 3.3
*/
public static final String PREF_ALLREFERENCES_MAX_COUNT = PLUGIN_ID + ".all_references_max_count"; //$NON-NLS-1$
public static final String PREF_ALLREFERENCES_MAX_COUNT = PLUGIN_ID + ".all_references_max_count"; //$NON-NLS-1$ `

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2020 IBM Corporation and others.
* Copyright (c) 2004, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down
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) {

}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2022 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -175,6 +175,7 @@ public class ActionMessages extends NLS {
public static String Override_Dependencies_button1;
public static String Override_Dependencies_label1;
public static String Override_Dependencies_label2;
public static String DisableConditionalBreakpoints_1;

static {
// load message values from bundle file
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2000, 2022 IBM Corporation and others.
# Copyright (c) 2000, 2024 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -154,4 +154,5 @@ Override_Dependencies_title=Override Dependencies
Override_Dependencies_button=&Override
Override_Dependencies_button1=&Override Dependencies...
Override_Dependencies_label1=Dependencies derived from the Java Build Path:
Override_Dependencies_label2=Dependencies for launching:
Override_Dependencies_label2=Dependencies for launching:
DisableConditionalBreakpoints_1=Disable Conditional Breakpoints
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*******************************************************************************
* 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 {
if (breakpoint instanceof JavaLineBreakpoint javaLB) {
javaLB.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() {
SougandhS marked this conversation as resolved.
Show resolved Hide resolved
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();
}

}
Loading