Friday, January 11, 2008

How to open a view from an action and maximize it programmatically

You want to open an rcp view to be maximized over the open parteditors in order to gain user's focus on that? That is how to do it:


IWorkbenchPage activePage = window.getActivePage();
if (activePage.findView(SimulationViewer.ID) == null) {
try {
// open the view
activePage.showView(SimulationViewer.ID);
// and maximize it
activePage.toggleZoom(activePage.findViewReference(SimulationViewer.ID));
} catch (PartInitException es) {
es.printStackTrace();
}
}


The view will be maximized if it wasn't and vice versa.

Have to find out how to deal with the fact that when I close the view the other views of the group stay maximized, whereas the user will want to get back to its part editors. Any idea?

No comments: