Eclipse Kepler RCP主要工具栏操作 [英] Eclipse Kepler RCP Main Toolbar Actions

查看:296
本文介绍了Eclipse Kepler RCP主要工具栏操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google 是我最好的朋友,但是我得到的信息过于分散且不清楚。没有简明的教程来描述我的需求。

Google is my best friend, but the information I'm getting is too scattered and very unclear. There isn't a concise tutorial describing my needs.

我想在我的RCP应用程序的主工具栏中添加操作,但是我需要对每种方法进行详尽的解释。但是,由于这是StackOverflow,所以我会写下所有问题,并希望答案能解决。

I want to add actions to my RCP app's main toolbar, but I need every way of doing this explained thoroughly. But since this is StackOverflow, I will write down the questions off the top of my head, and hope the answers will do.


  • 添加动作的哪种方式?通过 ActionBarAdvisor 或通过 plugin.xml

  • Which is the new and old way of adding actions? Via ActionBarAdvisor or via plugin.xml?

可以使用 plugin.xml 仅将动作添加到主工具栏吗?

Can actions be added to the main toolbar ONLY using plugin.xml?

通过扩展添加动作有几个步骤? (处理程序命令 menuContribution 等)。

How many steps are there to add an action via extensions? (handlers, commands, menuContribution, etc.)

哪个是执行操作的最佳父项? org.eclipse.jface.action.Action org.eclipse.ui.menus.WorkbenchWindowControlContribution ?甚至 org.eclipse.ui.commands.AbstractHandler

Which is the best parent for an action implementation? org.eclipse.jface.action.Action? org.eclipse.ui.menus.WorkbenchWindowControlContribution? Or even org.eclipse.ui.commands.AbstractHandler?

特定于工作台的操作( 保存撤消重做等)?如何添加这些?

What about workbench-specific actions (Save, Undo, Redo etc.)? How are these added?

在Eclipse Kepler IDE中,coolbar看起来很漂亮。您甚至可以移动工具栏。实施方式如何?

In Eclipse Kepler IDE, the coolbar looks beautiful. You can even move toolbars around. How's that implemented? Couldn't find out not even with Plug-in Spy.

因为我有几个 Perspective ,所以甚至连插件间谍都找不到,每个都将在主工具栏上有其自己的贡献。这是否意味着我不得不在任何地方使用 plugin.xml 扩展名?

Since I have several Perspectives, each will come with its own contribution on the main toolbar. Does that mean I'm obliged to use plugin.xml extensions everywhere?



TL; DR :工作台Coolbar动作,包括 Save 和其他 Perspective s。怎么样? ( actionSets 扩展==已弃用)。


TL;DR: Workbench coolbar actions including Save and actions from other Perspectives. How? (actionSets extensions == deprecated).

推荐答案

真正的新方法是使用纯e4 RCP,它将新的应用程序模型与命令和处理程序一起使用! (但是e4不支持很多现有代码)。在e4中,菜单和工具栏在应用程序模型中定义。命令和处理程序的使用方式与传统代码相似(但处理程序的实现方式不同)。

The really new way is to use a pure e4 RCP which uses the new application model with commands and handlers! (but e4 doesn't support a lot of existing code). In e4 menus and toolbars are defined in the application model. Commands and handlers are used in a similar way to traditional code (but handlers are implemented differently).

对于Eclipse 3样式,您已经发现杂乱无章或做事方式。 Eclipse 4.3确实淘汰了一些最旧的版本(现在在 plugin.xml 中进行了标记)。

For Eclipse 3 style as you have found there is a jumble or ways of doing things. Eclipse 4.3 does deprecate some of the oldest (and this is now flagged in the plugin.xml).

如果您正在编写一个使用其自己的 ActionBarAdvisor 的RCP,然后可以在其中定义工具栏项。或者,您可以在 plugin.xml 中为单个插件定义它们。两种方法都很好。 Eclipse本身在Advisor中定义了核心操作,并在其plugin.xml中定义了更多插件。

If you are writing a RCP which uses its own ActionBarAdvisor then you can define your tool bar items there. Or you can define them in the plugin.xml for individual plugins. Both methods are fine. Eclipse itself defines core actions in the advisor with add on plugins defining more in their plugin.xmls.

诸如 Save 之类的操作需要应该在顾问程序中创建由多个部分(例如编辑器)处理的内容,并使用 RetargetAction 。这允许每个单独的部分将其自己的动作与全局定义的动作挂钩。也可以使用命令和多个 c句柄来完成。

Actions such as Save which need to be handled by multiple parts (such as editors) should be created in the advisor and use RetargetAction. This allows each individual part to hook up its own action with the globally defined action. This can also be done with commands and multiple handlers which are closer to the e4 style.

org.eclipse.ui.menus 现在是扩展菜单和工具栏的主要扩展点(忽略所有不赞成使用的部分)。这确实迫使您使用命令处理程序

org.eclipse.ui.menus is now the main extension point for contributing to menus and toolbars (ignoring all the deprecated parts). This does pretty much force you to use commands and handlers.

Eclipse操作栏顾问是 org.eclipse.ui.internal.ide.WorkbenchActionBuilder ,尽管它很大,但可能会有所帮助。

The Eclipse action bar advisor is org.eclipse.ui.internal.ide.WorkbenchActionBuilder which may help although it is big.

我认为开普勒的coolbar是使用新的e4应用程序模型构造的,并使用一些棘手的CSS进行样式设置。

I think the coolbar in Kepler is constructed using the new e4 application model with styling using some tricky CSS.

这篇关于Eclipse Kepler RCP主要工具栏操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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