Eclipse plug-in: how to activate terminate button in Debug view
I am writing a plug-in to extend Eclipse for a custom programming language. I have all the launch configuration working and any program in the custom language launches correctly but I cannot seem to activate the Terminate button in the Debug view.
From what I have researched, I know that implementing the Debugger framework provides for the Terminate action but say, I do not want to implement the framework at this stage and would just like to have the option of terminating the program instead of having to cancel via the Task Manager. Is that possible to do? Or is the Debugger Framework the only way to do this?
Here is the code from the LaunchConfigurationDelegate class,
public void launch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
// getting the resource from the workspace
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
List<String> filenames = configuration.getAttribute(RELATIVE_PATH,
Collections.EMPTY_LIST);
List<String> rawPaths = configuration.getAttribute(RAW_PATH,
Collections.EMPTY_LIST);
List<String> projPaths = configuration.getAttribute(PROJECT_PATH,
Collections.EMPTY_LIST);
//CustomRunner is the interface to manage the custom language execution
CustomRunner runner = null;
try {
CustomOutputHandler outHand = new CustomOutputHandler();
runner = new CustomRunner(new File(projPaths.get(0)));
runner.setOutputHandler(outHand);
for (int i = 0; i < filenames.size(); i++) {
IPath temp = new Path(filenames.get(i));
IResource CustomFile = root.findMember(temp);
if (CustomFile == null) {
String msg = "The file "
开发者_StackOverflow中文版 + "<"
+ temp.toString()
+ ">"
+ " could not be found in the workspace.\nIt may have been deleted or renamed.";
throw new FileNotFoundException(msg);
}
CustomFile.deleteMarkers(IMarker.PROBLEM, false,
IResource.DEPTH_INFINITE);
CustomErrorHandler errHand = new CustomErrorHandler(CustomFile);
runner.setErrorHandler(errHand);
//Runs the custom language file
runner.run(rawPaths.get(i));
}
After that there is just a bunch of catch blocks.
I need to be able to now terminate this launch via the Debug view and in the case of Run mode via the Run menu's terminate command.
I do not have any DebugTarget right now at this stage. And my question is: Is there another way to terminate this launch without extending the Debug Framework?
I did try launch.Terminate() in this launch method but that did not work.
Unless you extend the Platform-debug support you cannot hook into the Terminate button in the Debug view - at least there isn't an API for that. You can hack into the internals of the debug framework to add support without extending, but extending might be lot easier than that and will work in the future versions of Eclipse
精彩评论