Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » ExpandBar Collapse/Expand Listener Post Setting of expanded
ExpandBar Collapse/Expand Listener Post Setting of expanded [message #1697849] Tue, 09 June 2015 03:36 Go to next message
Mike Standfuss is currently offline Mike StandfussFriend
Messages: 3
Registered: June 2015
Junior Member
I am trying to do a Composite that has its ExpandItems dynamically sized to fit the entire contents of the ClientArea, but that each item is also weighted like a SashForm. The problem is that when the Collapse/Expand listener is fired the ExpandItem that is collapsing/expanding's expanded flag is not set until after the listener is fired.

(ExpandItem.WM_LBUTTONUP)
event.item = focusItem;
sendEvent (focusItem.expanded ? SWT.Collapse : SWT.Expand, event);
focusItem.expanded = !focusItem.expanded;

So say I have three items with weights of 2 | 3 | 5 , and the total height is 100. The second item is expanded and the other two are collapsed, then the second item gets its height set to 100 (minus the headers and spacing but round numbers are nice). Then the third item gets expanded, I want to be able to set the height on the first to 0, the second to 25 and the third to 75. How I thought of to do this is first loop through each item and check if its expanded or not then add the weights of the expanded items together and divvy the heights based on weight. But when looping through only the second items expanded flag will be set to true until after the listener is done.

First thought was to do a listener on the parent's resizing, but then the heights would be dependent on that being resized after the item is expanded or collapsed which I would have to do manually after the listener setting it to +1 and back to original or something.

Any other thoughts that I could do that would be less hacky? I would just extend the ExpandBar and reverse the order of those lines myself but that Composite is not meant to be extended. Maybe there is another way and I just havent thought of it yet. Any ideas would be appreciated.
Re: ExpandBar Collapse/Expand Listener Post Setting of expanded [message #1699392 is a reply to message #1697849] Wed, 24 June 2015 03:01 Go to previous messageGo to next message
Mike Standfuss is currently offline Mike StandfussFriend
Messages: 3
Registered: June 2015
Junior Member
I think I am going to take a look at using Nebula's PGroup in a sashform with weights instead, was never able to think of a great workaround for this one.

https://eclipse.org/nebula/widgets/pgroup/pgroup.php
Re: ExpandBar Collapse/Expand Listener Post Setting of expanded [message #1752594 is a reply to message #1699392] Wed, 25 January 2017 14:02 Go to previous message
Peter Holmdahl is currently offline Peter HolmdahlFriend
Messages: 1
Registered: January 2017
Junior Member
I had a similar problem, so not really a solution for what you described.
I want to auto-size the left most column of a Tree whenever an item is expanded.
A hack-ish solution to this is to add a control listener on event SWT.Expand, then run an UIJob shceduled something like 20ms in the future (setSystem(true)). The job gets hold of the first column of the tree and calls pack() on it.
To get the column to size before anything is expanded, add a focus listener which checks to see if the viewer (for the tree, if any, otherwise do something else.. ) has any input and if so pack() the first column. That listener can then be removed since it served its purpose.
Previous Topic:Issue with Visio Viewer
Next Topic:SWT Table Object vs. Linux
Goto Forum:
  


Current Time: Fri Apr 19 04:35:13 GMT 2024

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

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

Back to the top