我正在使用带有兼容层的 Eclipse 4.2 来为我的 RCP 应用程序重用现有部分。
我想在我的 RCP 应用程序中重用来自File 菜单和Run菜单的New,因此我打开 Eclipse 的 EMF 编辑器,它看起来像这样:
但是对于新菜单,它显示如下:org.eclipse.e4.model.application....
我的应用程序看起来像这样(它只是带有一些额外功能的 Java 脚本调试器):
那么如何在我的 RCP 应用程序中重用这些菜单呢?
我正在使用带有兼容层的 Eclipse 4.2 来为我的 RCP 应用程序重用现有部分。
我想在我的 RCP 应用程序中重用来自File 菜单和Run菜单的New,因此我打开 Eclipse 的 EMF 编辑器,它看起来像这样:
但是对于新菜单,它显示如下:org.eclipse.e4.model.application....
我的应用程序看起来像这样(它只是带有一些额外功能的 Java 脚本调试器):
那么如何在我的 RCP 应用程序中重用这些菜单呢?
I think I understand what you are saying. You opened the E4 Live Editor on your Eclipse Juno, to get the commands for New and Run menu items so that you can reuse it in your own code?
If I am correct, then in E4 you can no longer use the default commands provided by Eclipse. You need to define your own commands. See here for details.
If you know Eclipse 3.x you are probably searching for the predefined commands which you can re-use. The Eclipse 4 platform tries to be as lean as possible.
Eclipse 4 does not include standard commands anymore. You have to define all your commands.
So if you try to add these commands via the .e4xmi file, then you must define your own commands with its own handlers.
There is a way out if you still wish to use the commands given by Eclipse and that will have to be done via the plugin.xml file. Since you said you are using the compatibility layer, you probably still have a lot of legacy code, and it might be ok to add these menu items via the plugin.xml. Although, once you do a hard migration, I believe Eclipse is trying to reduce the use of extensions in plugin.xml and in that case you will have to define your own commands.
So if you want to add these commands then you must do it via the extensions in the plugin.xml.
To add the New menu item, go to your plugin.xml
, in the Extensions tab, add org.eclipse.ui.menus
. Create a menucontribution with a locationURI of menu:org.eclipse.ui.main.menu
. Then you must add a menu and give it the label File
.
This will add the menu File
to your RCP. Then to this you must add the New
command. In order to do this, you add a command to the File menu you just created. Once you add a command, in commandID you select Browse and look for org.eclipse.ui.file.newQuickMenu
.
So your plugin.xml will have the following code.
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="menu:org.eclipse.ui.main.menu">
<menu
id="fileMenu"
label="File">
<command
commandId="org.eclipse.ui.file.newQuickMenu"
style="push">
</command>....