Eclipse插件:如何使用组合键为Eclipse插件创建新菜单?

发布于 2024-10-07 20:15:13 字数 410 浏览 0 评论 0原文

我一直在寻找这个问题,但找不到。我需要创建一个新的“弹出菜单”并分配一个按下的键(换句话说,我需要按“F3+右键单击”(例如),此操作将出现一个新的弹出菜单,我的操作在我的工作台)。我不需要右键单击子菜单...我需要一个新的单独菜单

示例,在 Eclipse 中,当我在工作台上右键单击鼠标时,我会看到一个弹出菜单,其中包含:“撤消、恢复文件、保存” 、剪切、复制...”等等,但我需要创建一个新菜单而不是 Eclipse 菜单,因此,当我按“F3+右键单击”(示例)时,我需要通过我的操作查看弹出菜单。这是我的问题,我需要创建一个新菜单并用键/鼠标组合调用它...

我一直在阅读论坛,但我不知道在哪里发布这个问题,我也不知道在哪里发布搜索(也许我在搜索中写了一个错误的问题......我想......)。

我希望有人能帮助我。

非常感谢;)

I've been looking about this question but I couldn't find it. I need to create a new "popup menu" and assign a key pressed (in other words, I need press "F3+right-click" (for example) and this action will be appear a new popup menu, with my actions in my workbench). I don't need a submenu for my right-click... i need a new and alone menu

Example, in eclipse, when i right-click with my mouse over workbench I see a popmenu with: "undo, revert file, save, cut, copy..." and more, but i need create a new menu instead of eclipse menu, so, when I press "F3+right-click" (example) i need see my popup-menu with my actions... this is my problem, i need to create a new menu and call it with key/mouse combination...

I've been reading the forums but i don't know where to post this question and I don't know where to search (maybe i write a wrong question in the search... i think...).

I hope someone can help me.

Thank you very much;)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

混吃等死 2024-10-14 20:15:13

我假设您希望在编辑器中看到此菜单(而不是在视图中,因为那会略有不同)。这里您需要做的大部分工作是通过在插件的plugin.xml 中声明扩展点来扩展Eclipse 扩展点。

值得庆幸的是,Eclipse 附带了一些扩展点向导来帮助您开始使用此功能。要到达那里,请执行以下操作

  1. 打开插件的plugin.xml
  2. 转到扩展页面
  3. 单击“添加...”
  4. 单击“扩展向导”
  5. “弹出菜单”向导
  6. 填写完所有详细信息后,还有一些内容你需要做的。
  7. 该向导创建一个对象贡献,它将新的弹出菜单添加到所有视图中指定类型的对象。您可以将其更改为编辑器贡献,以便菜单项将显示在编辑器中。
  8. 最后一步是将此菜单项与键绑定连接。为此,您需要创建一个新的命令扩展。
  9. 从命令扩展点向导开始。
  10. 填写详细信息后,您将获得一个命令、一个处理程序和一个绑定。您可以删除处理程序,因为您会将之前创建的操作连接到刚刚创建的命令。
  11. 从这里开始,您需要填写向导创建的所有 Java 存根类,然后您就可以开始工作了。

这是实现按键绑定所需执行的一组非常粗略的步骤(是的,它比需要的要复杂得多)。有关更多详细信息,您可以访问此处:

http://www.vogella.de/articles/ EclipseCommands/article.html

I assume that you would like to see this menu in an editor (rather than in a view because that would be slightly different). Most of what you need to do here is to extend eclipse extension points through declaring them in the plugin.xml for your plugin.

Thankfully, Eclipse ships with a few extension point wizards to help you get started with this. To get there, do the following

  1. Open the plugin.xml for your plugin
  2. Go to the extensions page
  3. Click on Add...
  4. Click on Extension Wizards
  5. The "Popup Menu" wizard
  6. After filling in all the details, there are still a few more pieces that you need to do.
  7. The wizard creates an Object contribution, that will add the new popup menu to an object of a specified type in all views. You can change this to being an editor contribution, so that the menu item will show in editors instead.
  8. The final step is to connect this menu item with a key-binding. For that, you need to create a new Command extension.
  9. Start with the Command extension point wizard.
  10. After filling in the details, you get a command, a handler, and a binding. You can remove the handler, since you will connect your action created previously to the command you just created.
  11. From here, you need to fill in all of the stub Java classes created by the wizards and you should be in business.

This is a very rough set of steps you need to do to implement the keybindinds (and, yes, it is way more complicated than it needs to be). For more detail, you can go here:

http://www.vogella.de/articles/EclipseCommands/article.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文