blob: 3e23f13b0154958b4f9b63c47564c4254c0acdbe [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.debug.internal.ui.actions;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.IBreakpointsListener;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchWindow;
/**
* Removes all breakpoints from the source (markers) and remove all
* breakpoints from processes
*/
public class RemoveAllBreakpointsAction extends AbstractRemoveAllActionDelegate implements IBreakpointsListener {
protected void doAction() {
IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints= breakpointManager.getBreakpoints();
try {
breakpointManager.removeBreakpoints(breakpoints, true);
} catch (CoreException e) {
IWorkbenchWindow window= DebugUIPlugin.getActiveWorkbenchWindow();
if (window != null) {
DebugUIPlugin.errorDialog(window.getShell(), ActionMessages.getString("RemoveAllBreakpointsAction.Removing_all_breakpoints_4"),ActionMessages.getString("RemoveAllBreakpointsAction.Exceptions_occurred_removing_breakpoints._5"), e); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
protected void update() {
getAction().setEnabled(
DebugPlugin.getDefault().getBreakpointManager().hasBreakpoints());
}
/**
* @see IBreakpointsListener#breakpointsAdded(IBreakpoint[])
*/
public void breakpointsAdded(IBreakpoint[] breakpoints) {
if (getAction() != null && !getAction().isEnabled()){
update();
}
}
/**
* @see IBreakpointsListener#breakpointsChanged(IBreakpoint[], IMarkerDelta[])
*/
public void breakpointsChanged(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
}
/**
* @see IBreakpointsListener#breakpointsRemoved(IBreakpoint[], IMarkerDelta[])breakpointRemoved(IBreakpoint, IMarkerDelta)
*/
public void breakpointsRemoved(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
if (getAction() != null) {
update();
}
}
/**
* @see IViewActionDelegate#init(IViewPart)
*/
public void init(IViewPart view) {
super.init(view);
DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
}
public void dispose() {
DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
super.dispose();
}
}