如何使用命令在帮助中添加备忘单菜单项

How to add cheat sheets menu item in help using commands

我在“帮助”菜单中使用操作添加了作弊 Sheet 菜单项。为此,我收到了针对操作和操作集的弃用警告。这是我以前的代码。

<extension
   point="org.eclipse.ui.actionSets">
   <actionSet
        label="Cheat Sheets"
        visible="true"
        id="org.eclipse.ui.cheatsheets.actionSet">
    <action
        label="Cheat Sheets" 
        class=" org.eclipse.ui.cheatsheets.CheatSheetExtensionFactory:helpMenuAction"
        menubarPath="help/group.tutorials"
        id="org.eclipse.ui.cheatsheets.actions.CheatSheetHelpMenuAction">
    </action>
    </actionSet>

为了删除警告,我决定通过命令添加。这是我的代码

<extension 
point="org.eclipse.ui.menus">
<menuContribution
        locationURI="menu:help?after=Dynamic Help">
     <command
           commandId="org.eclipse.ui.cheatsheets.actions.CheatSheetHelpMenuAction"
           label="Cheat Sheets.."
           style="push">
     </command>
</menuContribution>   

并且我添加了相应的命令

<extension
     point="org.eclipse.ui.commands">
  <command
        defaultHandler="org.eclipse.ui.cheatsheets.CheatSheetExtensionFactory:helpMenuAction"
        id="org.eclipse.ui.cheatsheets.actions.CheatSheetHelpMenuAction"
        name="Cheat sheets">
  </command>  

但我收到以下错误 org.eclipse.ui.internal.cheatsheets.actions.CheatSheetHelpMenuAction cannot be cast to org.eclipse.core.commands.IHandler. 我怎样才能解决这个问题?我不想为此创建新的处理程序。提前致谢!

您无法修复转换,因为操作不适合命令处理程序。似乎没有现成的作弊命令处理程序 sheets,因此您无法将其更改为。

编写自己的处理程序也是不可能的,因为所有作弊 sheet API 都是内部,因此无法使用。

虽然操作集被标记为已弃用,但它们永远不会被删除,因为有太多东西使用它们 - 所以坚持使用操作集。