【发布时间】:2011-04-06 11:01:25
【问题描述】:
我正在编写一个插件来为自定义编程语言扩展 Eclipse。我的所有启动配置都正常工作,并且自定义语言中的任何程序都能正确启动,但我似乎无法激活“调试”视图中的“终止”按钮。
根据我的研究,我知道实现 Debugger 框架提供了 Terminate 操作,但是说,我不想在这个阶段实现框架,只想选择终止程序而不是让通过任务管理器取消。那有可能吗?还是调试器框架是唯一的方法?
这是来自 LaunchConfigurationDelegate 类的代码,
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 "
+ "<"
+ 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));
}
之后就是一堆 catch 块。
我现在需要能够通过调试视图终止此启动,并且在运行模式下通过运行菜单的终止命令。
现阶段我没有任何 DebugTarget。我的问题是:是否有另一种方法可以在不扩展调试框架的情况下终止此启动?
我确实在这个启动方法中尝试了 launch.Terminate(),但没有奏效。
【问题讨论】:
标签: java plugins eclipse-plugin