diff options
author | John Cortell | 2007-05-14 15:53:36 +0000 |
---|---|---|
committer | John Cortell | 2007-05-14 15:53:36 +0000 |
commit | 97d6043d036f6dc739c779f54a8830abe4452ff8 (patch) | |
tree | 6c6920cf2672f36ac4f844d6f5b5faf055be0f25 /debug/org.eclipse.cdt.debug.core/src/org | |
parent | c875ab1d89975b558dc016b0d60fcf5c2e6f90f9 (diff) | |
download | org.eclipse.cdt-97d6043d036f6dc739c779f54a8830abe4452ff8.tar.gz org.eclipse.cdt-97d6043d036f6dc739c779f54a8830abe4452ff8.tar.xz org.eclipse.cdt-97d6043d036f6dc739c779f54a8830abe4452ff8.zip |
Applied patch for 186405. Fixed some problems with breakpoint actions.
Diffstat (limited to 'debug/org.eclipse.cdt.debug.core/src/org')
2 files changed, 86 insertions, 51 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java index 911a81d4d97..1df5de7c943 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java @@ -14,7 +14,6 @@ import java.io.ByteArrayOutputStream; import java.io.StringReader; import java.util.ArrayList; import java.util.Iterator; -import java.util.StringTokenizer; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -31,7 +30,11 @@ import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.debug.core.model.IBreakpoint; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -96,20 +99,50 @@ public class BreakpointActionManager { return false; } - public void executeActions(IBreakpoint breakpoint, IAdaptable context) { - + public void executeActions(final IBreakpoint breakpoint, final IAdaptable context) { if (breakpoint != null) { IMarker marker = breakpoint.getMarker(); String actionNames = marker.getAttribute(BREAKPOINT_ACTION_ATTRIBUTE, ""); //$NON-NLS-1$ - StringTokenizer tok = new StringTokenizer(actionNames, ","); //$NON-NLS-1$ - while (tok.hasMoreTokens()) { - String actionName = tok.nextToken(); + final String[] actions = actionNames.split(","); + if (actions.length > 0){ + Job job = new Job("Execute breakpoint actions") { + public IStatus run(final IProgressMonitor monitor) { + return doExecuteActions(breakpoint, context, actions, monitor); + } + }; + job.schedule(); + try { + // wait for actions to execute + job.join(); + }catch (InterruptedException e) + { + e.printStackTrace(); + } + } + } + } + + private IStatus doExecuteActions(final IBreakpoint breakpoint, final IAdaptable context, String[] actions, IProgressMonitor monitor) { + try { + for (int i = 0; i < actions.length && !monitor.isCanceled(); i++) { + String actionName = actions[i]; IBreakpointAction action = findBreakpointAction(actionName); if (action != null) { - action.execute(breakpoint, context); + monitor.setTaskName(action.getSummary()); + IStatus status = action.execute(breakpoint, context, monitor); + if (status.getCode() != IStatus.OK) { + // do not log status if user canceled. + if (status.getCode() != IStatus.CANCEL) + CDebugCorePlugin.log(status); + return status; + } } + monitor.worked(1); } + } catch (Exception e) { + return new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, "Internal Error", e ); } + return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS; } public IBreakpointAction findBreakpointAction(String name) { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IBreakpointAction.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IBreakpointAction.java index d7f35c45338..5e5ae73f633 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IBreakpointAction.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IBreakpointAction.java @@ -1,44 +1,46 @@ -/*******************************************************************************
- * Copyright (c) 2007 Nokia and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nokia - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.core.breakpointactions;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.debug.core.model.IBreakpoint;
-
-/**
- * Interface implemented by plug-ins that wish to contribute breakpoint actions.
- *
- * THIS INTERFACE IS PROVISIONAL AND WILL CHANGE IN THE FUTURE BREAKPOINT ACTION
- * CONTRIBUTIONS USING THIS INTERFACE WILL NEED TO BE REVISED TO WORK WITH
- * FUTURE VERSIONS OF CDT.
- *
- */
-public interface IBreakpointAction {
-
- public void execute(IBreakpoint breakpoint, IAdaptable context);
-
- public String getMemento();
-
- public void initializeFromMemento(String data);
-
- public String getDefaultName();
-
- public String getSummary();
-
- public String getTypeName();
-
- public String getIdentifier();
-
- public String getName();
-
- public void setName(String name);
-
-}
+/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.core.breakpointactions; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.debug.core.model.IBreakpoint; + +/** + * Interface implemented by plug-ins that wish to contribute breakpoint actions. + * + * THIS INTERFACE IS PROVISIONAL AND WILL CHANGE IN THE FUTURE BREAKPOINT ACTION + * CONTRIBUTIONS USING THIS INTERFACE WILL NEED TO BE REVISED TO WORK WITH + * FUTURE VERSIONS OF CDT. + * + */ +public interface IBreakpointAction { + + public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor); + + public String getMemento(); + + public void initializeFromMemento(String data); + + public String getDefaultName(); + + public String getSummary(); + + public String getTypeName(); + + public String getIdentifier(); + + public String getName(); + + public void setName(String name); + +} |