如何在RCP应用程序中重新使用菜单eclipse 4.2? [英] How to reuse menus in RCP application for eclipse 4.2?

查看:187
本文介绍了如何在RCP应用程序中重新使用菜单eclipse 4.2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有兼容性层的Eclipse 4.2来重用RCP应用程序的现有部分。

我想重新使用文件菜单在我的RCP应用程序中运行 菜单,所以我打开eclipse的emf编辑器和它的样子。

I'm using Eclipse 4.2 with compatibility layer to reuse existing part for my RCP application.
I want to reuse New from File menu and Run menu in my RCP application, so for that I opens emf-editor for eclipse and its look like.

但是对于新的菜单,它显示的内容类似于 org.eclipse.e4.model.application ....

我的应用程序是外观样式:它的只是java脚本调试器有一些额外的功能。

But for New menu its showing something like org.eclipse.e4.model.application....
My application is look-like: its just java Script debugger with some extra feature.

那么我怎么可以重用这些菜单我RCP应用程序。

So how I can reuse those Menus I my RCP application.

推荐答案

我想我明白你在说什么您在Eclipse Juno上打开了E4实时编辑器,以获取新建和运行菜单项的命令,以便您可以在自己的代码中重用它们。

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?

如果我正确的,那么在E4中你不能再使用Eclipse提供的默认命令了。您需要定义自己的命令。有关详细信息,请参见此处

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.


如果你知道Eclipse 3.x,你可能正在搜索可以重新使用的预定义的
命令。 Eclipse 4平台尽可能地以
的精度。

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不再包含标准命令。你必须
定义所有的命令。

Eclipse 4 does not include standard commands anymore. You have to define all your commands.

所以如果你尝试通过.e4xmi文件添加这些命令,那么您必须使用自己的处理程序来定义自己的命令。

So if you try to add these commands via the .e4xmi file, then you must define your own commands with its own handlers.

如果您仍然希望使用Eclipse提供的命令,还有必须通过plugin.xml文件。既然你说你正在使用兼容性层,你可能还有很多遗留代码,通过plugin.xml添加这些菜单项可能是可以的。虽然,一旦你做了一个艰难的迁移,我相信Eclipse试图减少在plugin.xml中的扩展使用,在这种情况下你必须定义你自己的命令。

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.

所以如果你想添加这些命令,那么你必须通过plugin.xml中的扩展名来实现。

So if you want to add these commands then you must do it via the extensions in the plugin.xml.

要添加新菜单项,请转到 plugin.xml ,在扩展名选项卡中,添加 org.eclipse.ui.menus 。使用locationURI 菜单创建一个菜单:org.eclipse.ui.main.menu 。然后,您必须添加一个菜单,并给它标签文件

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.

这将添加菜单文件到您的RCP。然后,您必须添加新建命令。为了做到这一点,你添加一个命令到刚刚创建的文件菜单。添加命令后,在commandID中,选择浏览并查找 org.eclipse.ui.file.newQuickMenu

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.

所以你的plugin.xml将具有以下代码。

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

这篇关于如何在RCP应用程序中重新使用菜单eclipse 4.2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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