1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 02:06:01 +02:00

Applied patch for 186405. Fixed some problems with breakpoint actions.

This commit is contained in:
John Cortell 2007-05-14 15:53:36 +00:00
parent c875ab1d89
commit 97d6043d03
7 changed files with 416 additions and 287 deletions

View file

@ -14,7 +14,6 @@ import java.io.ByteArrayOutputStream;
import java.io.StringReader; import java.io.StringReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.StringTokenizer;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; 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.IConfigurationElement;
import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint; 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.Platform;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.IBreakpoint;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
@ -96,22 +99,52 @@ public class BreakpointActionManager {
return false; return false;
} }
public void executeActions(IBreakpoint breakpoint, IAdaptable context) { public void executeActions(final IBreakpoint breakpoint, final IAdaptable context) {
if (breakpoint != null) { if (breakpoint != null) {
IMarker marker = breakpoint.getMarker(); IMarker marker = breakpoint.getMarker();
String actionNames = marker.getAttribute(BREAKPOINT_ACTION_ATTRIBUTE, ""); //$NON-NLS-1$ String actionNames = marker.getAttribute(BREAKPOINT_ACTION_ATTRIBUTE, ""); //$NON-NLS-1$
StringTokenizer tok = new StringTokenizer(actionNames, ","); //$NON-NLS-1$ final String[] actions = actionNames.split(",");
while (tok.hasMoreTokens()) { if (actions.length > 0){
String actionName = tok.nextToken(); Job job = new Job("Execute breakpoint actions") {
IBreakpointAction action = findBreakpointAction(actionName); public IStatus run(final IProgressMonitor monitor) {
if (action != null) { return doExecuteActions(breakpoint, context, actions, monitor);
action.execute(breakpoint, context); }
};
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) {
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) { public IBreakpointAction findBreakpointAction(String name) {
for (Iterator iter = getBreakpointActions().iterator(); iter.hasNext();) { for (Iterator iter = getBreakpointActions().iterator(); iter.hasNext();) {
IBreakpointAction action = (IBreakpointAction) iter.next(); IBreakpointAction action = (IBreakpointAction) iter.next();

View file

@ -1,44 +1,46 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Nokia and others. * Copyright (c) 2007 Nokia and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Nokia - initial API and implementation * Nokia - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.core.breakpointactions; package org.eclipse.cdt.debug.core.breakpointactions;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.model.IBreakpoint; 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 * Interface implemented by plug-ins that wish to contribute breakpoint actions.
* CONTRIBUTIONS USING THIS INTERFACE WILL NEED TO BE REVISED TO WORK WITH *
* FUTURE VERSIONS OF CDT. * 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 interface IBreakpointAction {
public String getMemento(); public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor);
public void initializeFromMemento(String data); public String getMemento();
public String getDefaultName(); public void initializeFromMemento(String data);
public String getSummary(); public String getDefaultName();
public String getTypeName(); public String getSummary();
public String getIdentifier(); public String getTypeName();
public String getName(); public String getIdentifier();
public void setName(String name); public String getName();
} public void setName(String name);
}

View file

@ -22,9 +22,15 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction; import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.ILaunchManager;
@ -39,18 +45,38 @@ public class ExternalToolAction extends AbstractBreakpointAction {
private String externalToolName = new String(""); //$NON-NLS-1$ private String externalToolName = new String(""); //$NON-NLS-1$
public void execute(IBreakpoint breakpoint, IAdaptable context) { public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor) {
IStatus errorStatus = null;
ILaunchManager lcm = DebugPlugin.getDefault().getLaunchManager(); ILaunchManager lcm = DebugPlugin.getDefault().getLaunchManager();
try { try {
boolean launched = false;
ILaunchConfiguration[] launchConfigurations = lcm.getLaunchConfigurations(); ILaunchConfiguration[] launchConfigurations = lcm.getLaunchConfigurations();
for (int i = 0; i < launchConfigurations.length; i++) { for (int i = 0; i < launchConfigurations.length; i++) {
if (launchConfigurations[i].getName().equals(externalToolName)) { if (launchConfigurations[i].getName().equals(externalToolName)) {
DebugUITools.launch(launchConfigurations[i], ILaunchManager.RUN_MODE); DebugUITools.launch(launchConfigurations[i], ILaunchManager.RUN_MODE);
launched = true;
break;
} }
} }
if (!launched) {
String errorMsg = MessageFormat.format(Messages.getString("ExternalToolAction.error.0"), new Object[] { externalToolName }); //$NON-NLS-1$
errorStatus = new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, null);
}
} catch (CoreException e) { } catch (CoreException e) {
errorStatus = e.getStatus();
} catch (Exception e) {
errorStatus = new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e );
}
if (errorStatus != null) {
String errorMsg = MessageFormat.format(Messages.getString("ExternalToolAction.error.1"), new Object[] { externalToolName }); //$NON-NLS-1$
MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, null );
ms.add(errorStatus);
return ms;
} }
return Status.OK_STATUS;
} }
public String getDefaultName() { public String getDefaultName() {

View file

@ -11,8 +11,8 @@
package org.eclipse.cdt.debug.ui.breakpointactions; package org.eclipse.cdt.debug.ui.breakpointactions;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import java.text.MessageFormat;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
@ -22,9 +22,14 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction; import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction;
import org.eclipse.cdt.debug.core.breakpointactions.ILogActionEnabler; import org.eclipse.cdt.debug.core.breakpointactions.ILogActionEnabler;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole; import org.eclipse.ui.console.IConsole;
@ -49,7 +54,12 @@ public class LogAction extends AbstractBreakpointAction {
this.evaluateExpression = evaluateExpression; this.evaluateExpression = evaluateExpression;
} }
public void execute(IBreakpoint breakpoint, IAdaptable context) { /*
* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction#execute(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.runtime.IAdaptable, org.eclipse.core.runtime.IProgressMonitor)
*/
public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor) {
IStatus result = Status.OK_STATUS;
try { try {
openConsole(Messages.getString("LogAction.ConsoleTitle")); //$NON-NLS-1$ openConsole(Messages.getString("LogAction.ConsoleTitle")); //$NON-NLS-1$
String logMessage = getMessage(); String logMessage = getMessage();
@ -63,11 +73,11 @@ public class LogAction extends AbstractBreakpointAction {
MessageConsoleStream stream = console.newMessageStream(); MessageConsoleStream stream = console.newMessageStream();
stream.println(logMessage); stream.println(logMessage);
stream.close(); stream.close();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); String errorMsg = MessageFormat.format(Messages.getString("LogAction.error.0"), new Object[] {getSummary()}); //$NON-NLS-1$
result = new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, e );
} }
return result;
} }
private void openConsole(String consoleName) { private void openConsole(String consoleName) {

View file

@ -22,9 +22,17 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction; import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction;
import org.eclipse.cdt.debug.core.breakpointactions.IResumeActionEnabler; import org.eclipse.cdt.debug.core.breakpointactions.IResumeActionEnabler;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.IBreakpoint;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
@ -33,16 +41,50 @@ import org.xml.sax.helpers.DefaultHandler;
public class ResumeAction extends AbstractBreakpointAction { public class ResumeAction extends AbstractBreakpointAction {
final int INCRIMENT_MSEC = 100;
int pauseTime = 0; int pauseTime = 0;
public void execute(IBreakpoint breakpoint, IAdaptable context) { /*
* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction#execute(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.runtime.IAdaptable, org.eclipse.core.runtime.IProgressMonitor)
*/
public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor) {
IStatus errorStatus = null;
long endTime = System.currentTimeMillis() + getPauseTime()*1000;
IResumeActionEnabler enabler = (IResumeActionEnabler) context.getAdapter(IResumeActionEnabler.class); IResumeActionEnabler enabler = (IResumeActionEnabler) context.getAdapter(IResumeActionEnabler.class);
if (enabler != null)
if (enabler != null) {
try { try {
enabler.resume(); monitor.beginTask(getName(), getPauseTime()*1000/INCRIMENT_MSEC);
long currentTime = System.currentTimeMillis();
while (!monitor.isCanceled() && currentTime < endTime ){
monitor.setTaskName(MessageFormat.format(Messages.getString("ResumeAction.SummaryResumeTime"), new Object[] { new Long((endTime - currentTime)/1000) })); //$NON-NLS-1$)
monitor.worked(1);
Thread.sleep(INCRIMENT_MSEC);
currentTime = System.currentTimeMillis();
}
if (!monitor.isCanceled()) {
monitor.setTaskName( Messages.getString("ResumeAction.SummaryImmediately")); //$NON-NLS-1$)
enabler.resume();
}
monitor.worked(1);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); errorStatus = new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e );
} }
} else
errorStatus = new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), IInternalCDebugUIConstants.INTERNAL_ERROR, Messages.getString("ResumeAction.error.0"), null ); //$NON-NLS-1$
if (errorStatus != null) {
MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, Messages.getString("ResumeAction.error.1"), null ); //$NON-NLS-1$
ms.add( errorStatus);
errorStatus = ms;
} else {
errorStatus = monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
}
return errorStatus;
} }
public String getDefaultName() { public String getDefaultName() {

View file

@ -1,178 +1,188 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Nokia and others. * Copyright (c) 2007 Nokia and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Nokia - initial API and implementation * Nokia - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.ui.breakpointactions; package org.eclipse.cdt.debug.ui.breakpointactions;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import java.text.MessageFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem; import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.DataLine; import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.DataLine;
import javax.sound.sampled.SourceDataLine; import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException; import javax.sound.sampled.SourceDataLine;
import javax.xml.parsers.DocumentBuilder; import javax.sound.sampled.UnsupportedAudioFileException;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder;
import javax.xml.transform.OutputKeys; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer; import javax.xml.transform.OutputKeys;
import javax.xml.transform.TransformerFactory; import javax.xml.transform.Transformer;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction;
import org.w3c.dom.Document; import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
import org.w3c.dom.Element; import org.eclipse.core.runtime.IAdaptable;
import org.xml.sax.InputSource; import org.eclipse.core.runtime.IProgressMonitor;
import org.xml.sax.helpers.DefaultHandler; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
public class SoundAction extends AbstractBreakpointAction { import org.eclipse.debug.core.model.IBreakpoint;
import org.w3c.dom.Document;
static public void playSoundFile(final File soundFile) { import org.w3c.dom.Element;
import org.xml.sax.InputSource;
class SoundPlayer extends Thread { import org.xml.sax.helpers.DefaultHandler;
public void run() { public class SoundAction extends AbstractBreakpointAction {
AudioInputStream soundStream;
try { static public void playSoundFile(final File soundFile) {
soundStream = AudioSystem.getAudioInputStream(soundFile);
AudioFormat audioFormat = soundStream.getFormat(); class SoundPlayer extends Thread {
DataLine.Info dataLineInfo = new DataLine.Info(SourceDataLine.class, audioFormat);
SourceDataLine sourceDataLine = (SourceDataLine) AudioSystem.getLine(dataLineInfo); public void run() {
byte[] soundBuffer = new byte[5000]; AudioInputStream soundStream;
sourceDataLine.open(audioFormat); try {
sourceDataLine.start(); soundStream = AudioSystem.getAudioInputStream(soundFile);
int dataCount = 0; AudioFormat audioFormat = soundStream.getFormat();
DataLine.Info dataLineInfo = new DataLine.Info(SourceDataLine.class, audioFormat);
while ((dataCount = soundStream.read(soundBuffer, 0, soundBuffer.length)) != -1) { SourceDataLine sourceDataLine = (SourceDataLine) AudioSystem.getLine(dataLineInfo);
if (dataCount > 0) { byte[] soundBuffer = new byte[5000];
sourceDataLine.write(soundBuffer, 0, dataCount); sourceDataLine.open(audioFormat);
} sourceDataLine.start();
} int dataCount = 0;
sourceDataLine.drain();
sourceDataLine.close(); while ((dataCount = soundStream.read(soundBuffer, 0, soundBuffer.length)) != -1) {
if (dataCount > 0) {
} catch (UnsupportedAudioFileException e) { sourceDataLine.write(soundBuffer, 0, dataCount);
// TODO Auto-generated catch block }
e.printStackTrace(); }
} catch (IOException e) { sourceDataLine.drain();
// TODO Auto-generated catch block sourceDataLine.close();
e.printStackTrace();
} catch (LineUnavailableException e) { } catch (UnsupportedAudioFileException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} } catch (IOException e) {
// TODO Auto-generated catch block
} e.printStackTrace();
} catch (LineUnavailableException e) {
} // TODO Auto-generated catch block
; e.printStackTrace();
}
if (soundFile.exists()) {
}
new SoundPlayer().start();
} }
}
if (soundFile.exists()) {
private File soundFile; new SoundPlayer().start();
}
public SoundAction() { }
}
private File soundFile;
public void execute(IBreakpoint breakpoint, IAdaptable context) {
playSoundFile(soundFile); public SoundAction() {
} }
public String getDefaultName() { public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor) {
// if (soundFile != null) { if (soundFile == null || !soundFile.exists()) {
// return MessageFormat.format("Play {0}", new Object[] String errorMsg = MessageFormat.format(Messages.getString("SoundAction.error.0"), new Object[] {getSummary()}); //$NON-NLS-1$
// {soundFile.getName()}); return new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, null);
// } }
return "Untitled Sound Action"; //$NON-NLS-1$
} playSoundFile(soundFile);
return Status.OK_STATUS;
public File getSoundFile() { }
return soundFile;
} public String getDefaultName() {
// if (soundFile != null) {
public String getSummary() { // return MessageFormat.format("Play {0}", new Object[]
if (soundFile == null) // {soundFile.getName()});
return new String(""); //$NON-NLS-1$ // }
return soundFile.getAbsolutePath(); return "Untitled Sound Action"; //$NON-NLS-1$
} }
public String getTypeName() { public File getSoundFile() {
return Messages.getString("SoundAction.ActionTypeName"); //$NON-NLS-1$ return soundFile;
} }
public String getMemento() { public String getSummary() {
String soundData = new String(""); //$NON-NLS-1$ if (soundFile == null)
if (soundFile != null) { return new String(""); //$NON-NLS-1$
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); return soundFile.getAbsolutePath();
DocumentBuilder docBuilder = null; }
try {
docBuilder = dfactory.newDocumentBuilder(); public String getTypeName() {
Document doc = docBuilder.newDocument(); return Messages.getString("SoundAction.ActionTypeName"); //$NON-NLS-1$
}
Element rootElement = doc.createElement("soundData"); //$NON-NLS-1$
rootElement.setAttribute("file", soundFile.getAbsolutePath()); //$NON-NLS-1$ public String getMemento() {
String soundData = new String(""); //$NON-NLS-1$
doc.appendChild(rootElement); if (soundFile != null) {
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
ByteArrayOutputStream s = new ByteArrayOutputStream(); DocumentBuilder docBuilder = null;
try {
TransformerFactory factory = TransformerFactory.newInstance(); docBuilder = dfactory.newDocumentBuilder();
Transformer transformer = factory.newTransformer(); Document doc = docBuilder.newDocument();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ Element rootElement = doc.createElement("soundData"); //$NON-NLS-1$
rootElement.setAttribute("file", soundFile.getAbsolutePath()); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s); doc.appendChild(rootElement);
transformer.transform(source, outputTarget);
ByteArrayOutputStream s = new ByteArrayOutputStream();
soundData = s.toString("UTF8"); //$NON-NLS-1$
TransformerFactory factory = TransformerFactory.newInstance();
} catch (Exception e) { Transformer transformer = factory.newTransformer();
e.printStackTrace(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
} transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
}
return soundData; DOMSource source = new DOMSource(doc);
} StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
public void initializeFromMemento(String data) {
Element root = null; soundData = s.toString("UTF8"); //$NON-NLS-1$
DocumentBuilder parser;
try { } catch (Exception e) {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); e.printStackTrace();
parser.setErrorHandler(new DefaultHandler()); }
root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement(); }
String value = root.getAttribute("file"); //$NON-NLS-1$ return soundData;
if (value == null) }
throw new Exception();
soundFile = new File(value); public void initializeFromMemento(String data) {
} catch (Exception e) { Element root = null;
e.printStackTrace(); DocumentBuilder parser;
} try {
} parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
public String getIdentifier() { root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement();
return "org.eclipse.cdt.debug.ui.breakpointactions.SoundAction"; //$NON-NLS-1$ String value = root.getAttribute("file"); //$NON-NLS-1$
} if (value == null)
throw new Exception();
public void setSoundFile(File soundFile) { soundFile = new File(value);
this.soundFile = soundFile; } catch (Exception e) {
} e.printStackTrace();
}
} }
public String getIdentifier() {
return "org.eclipse.cdt.debug.ui.breakpointactions.SoundAction"; //$NON-NLS-1$
}
public void setSoundFile(File soundFile) {
this.soundFile = soundFile;
}
}

View file

@ -1,45 +1,51 @@
ActionsPropertyPage.1=Actions for this breakpoint: ActionsPropertyPage.1=Actions for this breakpoint:
ActionsPropertyPage.2=Available actions: ActionsPropertyPage.2=Available actions:
ActionsPreferencePage.0=Actions available for any breakpoint in the workspace: ActionsPreferencePage.0=Actions available for any breakpoint in the workspace:
PreferenceInitializer.1=Default value PreferenceInitializer.1=Default value
GlobalActionsList.0=Name GlobalActionsList.0=Name
GlobalActionsList.1=Type GlobalActionsList.1=Type
GlobalActionsList.2=Summary GlobalActionsList.2=Summary
GlobalActionsList.3=Attach GlobalActionsList.3=Attach
GlobalActionsList.4=New... GlobalActionsList.4=New...
GlobalActionsList.5=Edit... GlobalActionsList.5=Edit...
GlobalActionsList.6=Delete GlobalActionsList.6=Delete
ActionsList.0=Name ActionsList.0=Name
ActionsList.1=Type ActionsList.1=Type
ActionsList.2=Summary ActionsList.2=Summary
ActionsList.3=Remove ActionsList.3=Remove
ActionsList.4=Up ActionsList.4=Up
ActionsList.5=Down ActionsList.5=Down
ActionDialog.0=New Breakpoint Action ActionDialog.0=New Breakpoint Action
ActionDialog.1=Action name: ActionDialog.1=Action name:
ActionDialog.2=Action type: ActionDialog.2=Action type:
SoundActionComposite.4=Select a sound to play when the breakpoint is hit: SoundActionComposite.4=Select a sound to play when the breakpoint is hit:
SoundActionComposite.5=Choose a sound file: SoundActionComposite.5=Choose a sound file:
SoundActionComposite.6=Browse... SoundActionComposite.6=Browse...
SoundActionComposite.7=Play Sound SoundActionComposite.7=Play Sound
SoundActionComposite.9=That sound file does not exist. SoundActionComposite.9=That sound file does not exist.
SoundAction.ActionTypeName=Sound Action SoundAction.error.0=Missing sound file "{0}"
LogActionComposite.0=Message to log when the breakpoint is hit: SoundAction.ActionTypeName=Sound Action
LogActionComposite.1=Evaluate as expression LogActionComposite.0=Message to log when the breakpoint is hit:
LogAction.ConsoleTitle=Log Action Messages LogActionComposite.1=Evaluate as expression
LogAction.UntitledName=Untitled Log Action LogAction.ConsoleTitle=Log Action Messages
LogAction.TypeName=Log Action LogAction.UntitledName=Untitled Log Action
LogAction.TypeName=Log Action
ExternalToolActionComposite.ToolLabel=External Tool: LogAction.error.0=Could not execute log action: "{0}".
ExternalToolActionComposite.DialogTitle=External Tools
ExternalToolActionComposite.DialogMessage=Choose an External Tool to run ExternalToolActionComposite.ToolLabel=External Tool:
ExternalToolActionComposite.ChooseButtonTitle=Choose... ExternalToolActionComposite.DialogTitle=External Tools
ExternalToolActionComposite.ExternalToolsButtonTitle=External Tools... ExternalToolActionComposite.DialogMessage=Choose an External Tool to run
ExternalToolAction.Summary=Run {0} ExternalToolActionComposite.ChooseButtonTitle=Choose...
ExternalToolAction.TypeName=External Tool Action ExternalToolActionComposite.ExternalToolsButtonTitle=External Tools...
ResumeAction.UntitledName=Untitled Resume Action ExternalToolAction.Summary=Run {0}
ResumeAction.SummaryImmediately=Resume immediately ExternalToolAction.error.0=There is no launch configuration named "{0}".
ResumeActionComposite.ResumeAfterLabel=Resume after ExternalToolAction.error.1=Could not launch "{0}".
ResumeAction.SummaryResumeTime=Resume after {0} seconds ExternalToolAction.TypeName=External Tool Action
ResumeActionComposite.Seconds=seconds ResumeAction.UntitledName=Untitled Resume Action
ResumeAction.TypeName=Resume Action ResumeAction.SummaryImmediately=Resume immediately
ResumeActionComposite.ResumeAfterLabel=Resume after
ResumeAction.SummaryResumeTime=Resume after {0} seconds
ResumeActionComposite.Seconds=seconds
ResumeAction.TypeName=Resume Action
ResumeAction.error.0=IResumeActionEnabler not registered in context.
ResumeAction.error.1=Could not resume.