Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Maximize/restore a view programmatically
Maximize/restore a view programmatically [message #269795] Thu, 02 September 2004 09:02 Go to next message
Eclipse UserFriend
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 10:12 Go to previous messageGo to next message
Eclipse UserFriend
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 11:57 Go to previous message
Eclipse UserFriend
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 Jul 23 06:19:03 EDT 2025

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

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

Back to the top