Showing posts with label IPresentationEngine.MINIMIZED. Show all posts
Showing posts with label IPresentationEngine.MINIMIZED. Show all posts

Monday, September 15, 2014

How to minimize a view programmatically in Eclipse e4 versions/ Adding a view to the trimbar

Below snippet can be used to minimize a view.

IViewPart part = page.showView("com.kk.views.showtasks");
if (part != null) {
 IWorkbenchPartReference myView = page.findViewReference(viewid);
MUIElement element = ((WorkbenchPage) page).getActiveElement(myView);
WorkbenchWindow activeWorkbenchWindow = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
MWindow window = activeWorkbenchWindow.getModel();
if (window != null) {
            EModelService service = window.getContext().get(EModelService.class);
if (service != null) {
element.getTags().add(IPresentationEngine.MINIMIZED);

}
}
}
}

More important thing here is,
element.getTags().add(IPresentationEngine.MINIMIZED);

When above code gets invoked, MinMaxAddon.minimize(..) will be invoked internally to minimize a view. Minimized view will be added as a toolbar item to the trimbar.

MUIElement element = ((WorkbenchPage) page).getActiveElement(myView);
Here element is PartStack element, that means all the elements(Parts) which are there in the partstack will be minimized.