【问题标题】:Command Expression for active debug session?活动调试会话的命令表达式?
【发布时间】:2017-04-22 09:10:25
【问题描述】:

我添加了扩展点org.eclipse.ui.menus 以在调试视图中创建一个新按钮。

效果很好,但是这个特殊的按钮现在总是可见的。如何添加检查调试会话当前是否正在运行的visibleWhen 条件?

我检查了Command Core Expressions,但没有找到任何可能适用于这种情况的表达式。

【问题讨论】:

    标签: eclipse eclipse-plugin eclipse-cdt eclipse-pde


    【解决方案1】:

    org.eclipse.jdt.debug.ui 插件中的菜单使用如下表达式:

    <visibleWhen
          checkEnabled="false">
       <and>
          <systemTest
               property="org.eclipse.jdt.debug.ui.debuggerActive"
               value="true">
          </systemTest>
    
          ... other tests ...
    
        </and>
    </visibleWhen>
    

    【讨论】:

    • 谢谢格雷格。我忘了提到我正在使用 CDT,我想这就是为什么它在我的情况下不起作用(我认为调试视图完全独立于 CDT)。那么,您知道如何在 CDT 中执行此操作吗?
    • 我对CDT一无所知。
    【解决方案2】:

    CDT 中有一个很好的示例项目,介绍了如何开始自定义 DSF。请查看它的 plugin.xml 并按照那里定义的命令 ID 的使用:org.eclipse.cdt.examples.dsf.gdb.command.showVersion

    这是该代码中的visibleWhen 之一。

            <visibleWhen
                  checkEnabled="false">
               <and>
                  <reference
                        definitionId="org.eclipse.cdt.debug.ui.testIsDebugActionSetActive">
                  </reference>
                  <with variable="org.eclipse.core.runtime.Platform">
                     <test property="org.eclipse.core.runtime.bundleState"
                        args="org.eclipse.cdt.examples.dsf.gdb"
                        value="ACTIVE">
                     </test>
                  </with>
               </and>
            </visibleWhen>
    

    【讨论】:

      猜你喜欢
      • 2013-07-07
      • 2014-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多