Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Maximize/restore a view programmatically
Maximize/restore a view programmatically [message #269795] Thu, 02 September 2004 13:02 Go to next message
Maya Barnea is currently offline Maya Barnea
Messages: 6
Registered: July 2009
Junior Member
Is there a way to maximize/restore a view programmatically?
Re: Maximize/restore a view programmatically [message #269827 is a reply to message #269795] Thu, 02 September 2004 14:12 Go to previous messageGo to next message
Eclipse User
Originally posted by: Ines_Khelifi.ca.ibm.com

Maya Barnea wrote:

> Is there a way to maximize/restore a view programmatically?

Take a look at the API for the "ActionFactory" class
(org.eclipse.ui.actions.ActionFactory).

Here is quick example:

ActionFactory.IWorkbenchAction maximizeAction =
ActionFactory.MAXIMIZE.create(workbenchWindow);
maximizeAction.run(); // Will maximize the active part

Ines
Re: Maximize/restore a view programmatically [message #832803 is a reply to message #269827] Fri, 30 March 2012 15:57 Go to previous message
Chris Mooney is currently offline Chris Mooney
Messages: 1
Registered: March 2012
Junior Member
I recently found a solution for doing this within the view that you are trying to control:

class MyView extends ViewPart {

	/**
	 * @param state  one of the IWorkbenchPage STATE_* values: STATE_MAXIMIZED, 
         * STATE_MINIMIZED, STATE_RESTORED
	 */
	private void setViewState(int state) {
		IWorkbenchPage page 
                    = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		int currentState = page.getPartState(page.getReference(this));
		if(currentState != state) {
			page.activate(this);
			page.setPartState(page.getReference(this), state);
		}
	}

}


Adding this method to your view class will let you maximize the view by calling:

setViewState(IWorkbenchPage STATE_MAXIMIZED)


restore it by calling:

setViewState(IWorkbenchPage STATE_RESTORED)


and of course minimize it by calling:

setViewState(IWorkbenchPage STATE_MINIMIZED)


The effect will be that if you maximize this view, all other views get minimized, restore it and all the views go back to their previous state, and minimize and the other views will fight it out for real-estate Smile

share and enjoy!
Previous Topic:javadoc generation and ${tags}
Next Topic:Eclipse freezes/hangs before Workspace selection
Goto Forum:
  


Current Time: Wed Oct 22 01:57:54 GMT 2014

Powered by FUDForum. Page generated in 0.01672 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software