Eclipse插件:如何使用组合键为Eclipse插件创建新菜单? [英] Eclipse plug-in: How to create a new menu for eclipse plugin with key combination?

查看:89
本文介绍了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

例如,在月食中,当我用鼠标右键单击工作台时,我看到一个弹出菜单,其中包含:撤消,还原文件,保存,剪切,复制..."等等,但是我需要创建一个新菜单eclipse菜单的内容,因此,当我按"F3 +右键单击"(示例)时,我需要查看带有动作的弹出菜单...这是我的问题,我需要创建一个新菜单并使用键/来调用它鼠标组合...

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...).

我希望有人能帮助我.

非常感谢;)

推荐答案

我假设您想在编辑器中查看此菜单(而不是在视图中,因为那会稍有不同).您在这里要做的大多数事情是通过在插件的plugin.xml中声明它们来扩展Eclipse扩展点.

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.

非常感谢,Eclipse附带了一些扩展点向导来帮助您入门.要到达那里,请执行以下操作

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

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

这是实现keybindinds所需完成的一系列非常粗糙的步骤(是的,它比需要的复杂得多).有关更多详细信息,您可以转到此处:

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

这篇关于Eclipse插件:如何使用组合键为Eclipse插件创建新菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆