Creating a sidebar - how can I resize a view programatically? [message #507446] |
Wed, 13 January 2010 09:30  |
Eclipse User |
|
|
|
Hello
I want to implement a sidebar that opens and closes (Notes 8.x has such a thing).
I have experimented with a sticky view. I can use hideView() and showView() via an external toggle, to make the 'sidebar' go away and come back, but of course, this rebuilds the view each time.
What I would like to do is to shrink the view so that its width (in my case) is zero, and then restore it to its original/previous width.
Regards, John
|
|
|
|
Re: Creating a sidebar - how can I resize a view programatically? [message #507653 is a reply to message #507446] |
Thu, 14 January 2010 04:32   |
Eclipse User |
|
|
|
Thanks Paul.
Hmmm... 'minimize', makes a lot of sense, duh!
I found a way to do this in a forum entry from 2007:
page.setPartState(myView, IWorkbenchPage.STATE_MINIMIZED);
This hides the view contents, reduces the width of the view to the same point that you can drag it to, but the leaves the view's tab showing. Same goes for a non-sticky view. (This is 3.5.1).
This is what happens when I press the minimize icon.Yet in the IDE, minimize does indeed close a view completely (and shows a list of minimised views). So, I guess there is something extra in the IDE. I'll have a search in the IDE's code, but if you know the area to look in, a pointer would be helpful - unless you actually know what I have to do.
Thanks, John
|
|
|
Re: Creating a sidebar - how can I resize a view programatically? [message #507816 is a reply to message #507446] |
Thu, 14 January 2010 13:53  |
Eclipse User |
|
|
|
Paul
I discovered what determines the minimum width of a view - by chance - when I was investigating Presentations. A StackPresentation has a (deprecated) method computeMinimumSize(), which returns a Point. (This might be invoked directly, or from computePreferredSize() ) It's the Point's 'x' value that determines the minimum width that you see when dragging a view's edge towards its opposite - and when using page.setPartState(myView, IWorkbenchPage.STATE_MINIMIZED);
I assume if this were the only variation wanted on the default Presentation, you could create a new one that subclasses the default and just change the min size.
However, I discovered an unfortunate characteristic of the sticky view. When it gets resized, that size only applies to the perspective that was visible when it was resized. Switch perspective and you see the sticky view as it was on that perspective.
I suppose this could be handled by a combination of a stickViewManager (that knows its expanded or not state) and use of a PerspectiveListener, that makes sure the sticky view is consistent.
Does that make sense - or am I inventing a wheel of a slightly different shape?
Regards, John
|
|
|
Powered by
FUDForum. Page generated in 0.07989 seconds