Eclipse 4 RCP应用程序(独立!):添加“显示视图”在菜单中 [英] Eclipse 4 RCP Application (standalone!): Add "show view" in menu

查看:607
本文介绍了Eclipse 4 RCP应用程序(独立!):添加“显示视图”在菜单中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我独立的RCP应用程序(我开始使用产品配置)中,我想添加一个菜单项显示视图,其中列出了我在持久应用程序模型中定义的所有视图(一个 application.e4xmi 文件)关闭
目前我没有任何顾问正在使用的类。



我所做的是手动添加 HandledMenuItems ,并将 CoreExpression 添加为可见表达式



此表达式测试特殊应用程序上下文中的键值对。这里的问题是每个视图都需要一个特殊的表达式。



解决这个问题的好方法是什么?
还是有一种方法来参数化核心表达?
我可以使用任何预定义的eclipse插件/命令/处理程序吗?



更新:相反,也可以让窗口>在独立的RCP应用程序中显示视图结构 - 就像它存在于Eclipse工作台中一样。有没有办法通过使用任何预定义/可用的方式添加这个菜单(条目)?

解决方案

我不知道这有助于您,因为它是eclipse 3.7代码,但您可以尝试一下。



我向视图菜单添加了动态菜单像这样:

 < menu id =xymenu.views label =%menu.window.label> 
< dynamic class =xymenu.ViewListMenuContributionid =viewlist/>
< / menu>

在该类中,我使用了一个eclipse菜单工具来实际填充菜单:

  @Override 
public void fill(菜单菜单,int索引)
{
super.fill(菜单,索引);

IWorkbenchWindow窗口= PlatformUI。 getObjectBase() ) ;
}

这应该显示当前关闭的所有视图。


In my standalone RCP Application (which I start using a product configuration) I would like to add a menu entry "show view" that lists all views I have defined in my persistent application model (an application.e4xmi file) being closed. Currently I do not have any Advisor Classes in use.

What I did was to manually add HandledMenuItems for each view and added a CoreExpression as Visible-When Expression.

This expression tests for a special key value pair in the application context. The problem here is that I would need a special expression for each view.

What would be a good pattern to solve this problem? Or is there a way to parametrize the core expression? Could I use any predefined eclipse plugins / commands / handlers?

Update: Instead it would also be okay to have the Window > Show View structure in my standalone RCP application - exactly like it exists in the Eclipse workbench. Is there a way to add this menu (entry) by using any predefined / available means?

解决方案

I'm not sure if this helps you, because it's eclipse 3.7 code, but you can give it a try.

I added a dynamic menu contribution to the View menu like so:

<menu id="x.y.menu.views label="%menu.window.label">
  <dynamic class="x.y.menu.ViewListMenuContribution" id="viewlist" />
</menu>

In that class, I used one of the the eclipse menu factories to actually fill the menu:

@Override
public void fill(Menu menu, int index)
{
    super.fill(menu, index);

    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IContributionItem item = ContributionItemFactory.VIEWS_SHORTLIST.create(window);

    if (item != null)
        item.fill(menu, index);
}

This should show all views that are currently closed.

这篇关于Eclipse 4 RCP应用程序(独立!):添加“显示视图”在菜单中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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