How do I use “org.eclipse.debug.ui.launchShortcuts”?

流过昼夜 提交于 2019-12-21 17:41:19

问题


I have written a custom launcher in Eclipse which I can access via the "Run As" and "Debug As" menu options on the toolbar. I also want to be able to launch via the package explorer and via right clicking on the editor of a file to be launched. I followed the tutorial here to add the shortcut but nothing happens, it does not enter my handling code, nor does it complain regarding the configuration of the extension point.

Here is a snippet from my plugin.xml

<extension point="org.eclipse.debug.ui.launchShortcuts">
  <shortcut
        id     = "org.mylauncher.launchCalcShortcut"
        class  = "org.mylauncher.LaunchCalcShortcut"
        description="Execute calculations"
        icon="icons/launch_16_16.png"
        label="Calculate"
        modes="run, debug" >
        <configurationType id="org.mylauncher.launchCalc"/>
  </shortcut>

I have also played with removing the (optional) icon attribute, and have separately validated the path of the icon.

I've been modifying this configuration for hours now with no good result and it is impossible to debug as it is not running in my own code at all.

Thanks.


回答1:


It seems that the correct answer to this problem is to specify a contextual launch shortcut. Here is my working configuration:

   <extension
     point="org.eclipse.debug.ui.launchShortcuts">

  <shortcut
        class="com.xxxx.CalcLaunchShortcut"
        icon="calc.png"
        id="com.xxxx.CalcLaunchShortcut"
        label="Calc"
        modes="run, debug">
    <contextualLaunch>
         <contextLabel mode="run" label="Run Calculator" />
         <contextLabel mode="debug" label="Debug Calculator" />
         <enablement >
           <with variable="selection">
           <count value="1"/>
          <iterate>
            <adapt type="org.eclipse.core.resources.IResource">
                <and>
                <test property="org.eclipse.core.resources.name" value="*.calc"/>
            </and>
        </adapt>
          </iterate>
           </with>
       </enablement>
     </contextualLaunch>
  </shortcut>



来源:https://stackoverflow.com/questions/10592493/how-do-i-use-org-eclipse-debug-ui-launchshortcuts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!