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.
There is currently no way to do that, except keeping track of the parts yourself and reopening them with the EPartService
来源:https://stackoverflow.com/questions/16123345/eclipse-4-rcp-application-standalone-add-show-view-in-menu