2
votes

I'm working for a short time on the libraries of eclipse 4.x someone could tell me how can I open a view through from the context menu? Thank you in advance.

1
Are you asking how to add things to a context menu or how to show a view? Are you using an Eclipse 4 RCP with an application model or Eclipse 3.x compatibility mode. - greg-449
how to show a view using Eclipse 4 but with the menu action! - epock
Sorry in Eclipse RCP 4.x the views = the parts! - epock
So you want to open an MPart from a context menu? - greg-449

1 Answers

1
votes

To show a part anywhere you should define a command in the application model and a handler for the command. To show a part in the handler use:

@Execute
public void execute(EPartService partService)
{
  MPart mpart = partService.showPart(part id, PartState.ACTIVATE);
}

In the application Part definition for your part add a Popup Menu to the Menus section. In the popup menu define a HandledMenuItem for your command.

To register the popup menu as the context menu for a control (tree, table etc) use:

@Inject
private EMenuService;

...

menuService.registerContextMenu(control, menu id);