0
votes

I would like to programmatically (from a context menu) open a certain view How can I do so?

I can show a view using e3 compatibility layer like this:

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("viewId");

What is the e4 way to do so?

1
This isn't straightforward. You can open a new window showing a specific perspective. - greg-449
Thanks Greg! Can I maybe show the view and detach it immediately after? I found solutions using the PerspectiveHelper or PartService, but they seem to be outdated.. - kerner1000
You have tagged this 'e4' but the code you show is 3.x compatibility mode. So are you doing e4 (using an Application.e4xmi) or 3.x compatibility (using things like the 'org.eclipse.ui.views' extension point)? - greg-449
I do it this way because this is the only solution I found ;) If you can tell me how to do this the e4 way this would be great, Thanks! Our Views/ Parts are registered in a fragment.e4xmi/ Application.e4xmi. - kerner1000
I updated the question, I will open a new one concerning the detached view. - kerner1000

1 Answers

1
votes

In e4 you open any part using EPartService:

@Inject
EPartService partService;


partService.showPart("part id", PartState.ACTIVATE);

The part should be in the Application.e4xmi in the place you want it to show but should have 'To Be Rendered' turned off (leave 'Visible' on).