【问题标题】:Eclipse plug-in: how to activate terminate button in Debug viewEclipse 插件:如何在 Debug 视图中激活终止按钮
【发布时间】: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


    【解决方案1】:

    除非您扩展平台调试支持,否则您无法挂接到调试视图中的终止按钮 - 至少没有用于此的 API。您可以在不扩展的情况下侵入调试框架的内部来添加支持,但扩展可能比这容易得多,并且可以在 Eclipse 的未来版本中使用

    【讨论】:

    • 所以扩展 Launch 类并创建自定义启动对象不会激活 Debug 视图中的 Terminate 按钮?
    • 看来我误解了你的问题。如果您使用的是 Launch 类,那么您正在使用该框架。确保你所有的 IDebugTarget 正确地实现了 terminate() 和 canTerminate() 方法。
    • 好的,我已经添加了我的代码。我现在没有使用 Launch 类,我使用的是启动配置委托类,我需要能够终止我的启动。
    猜你喜欢
    • 1970-01-01
    • 2023-03-31
    • 2010-11-15
    • 1970-01-01
    • 2023-02-15
    • 2013-07-09
    • 1970-01-01
    • 2020-01-18
    • 1970-01-01
    相关资源
    最近更新 更多