Eclipse 4 RCP Application (standalone!): Add “show view” in menu

有些话、适合烂在心里 提交于 2019-12-07 03:06:30

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.

There is currently no way to do that, except keeping track of the parts yourself and reopening them with the EPartService

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!