Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to determine which layout() method I should call ?(I want to know how to call the appropriate layout() method when I have to refresh different parts of my shell)
How to determine which layout() method I should call ? [message #516323] Tue, 23 February 2010 15:38 Go to next message
H.ORTIZ  is currently offline H.ORTIZ Friend
Messages: 22
Registered: July 2009
Junior Member
Hi,

To simplify, I can say that my application consists in a Shell divided vertically in two parts: on the left there is a selection tree containing several items and on the right a Composite using a StackLayout. When the user clickes on a tree item, the composite on the right displays a specific composite.

Once an item has been chosen, its associated composite will be present as long as the application runs in the StackLayout. So, when the user has clicked on most of the tree items, there is a lot of composites stored in the StackLayout.

My refresh method consists in calling:

shell.layout(true, true)


and I noticed that the execution time of this method is increasing with the number of "stacked" composites. It seems like this method refreshes also "hidden" composites and not only the one on the top of the stack.

My question is: which layout method (and with which parameters) of the Shell class should I use to avoid this problem ?

Thanks,
Helene

[Updated on: Tue, 23 February 2010 15:40]

Report message to a moderator

Re: How to determine which layout() method I should call ? [message #516359 is a reply to message #516323] Tue, 23 February 2010 17:21 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
Why are you doing Shell.layout(true,true)

all u need to do is

stacklayout.topcontrol=selectedComposite;
shell.layout();

by the way having a composite for each tree element is a bit too heavy..try to fix that...


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: How to determine which layout() method I should call ? [message #516609 is a reply to message #516359] Wed, 24 February 2010 14:59 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
To change the top control on the right-side Composite it should be good
enough to invoke composite.layout() rather than shell.layout().

Changing the stack's top Composite should not impose a significant
performance penalty, even if there are many Composites in the stack, since
the only ones that should matter are the ones being hidden and shown. How
many items does the Tree have (ie.- how many different Composites can end up
in the stack on the right)? And does each Composite have many Controls?
Does performance improve if the number of Controls on each Composite is
significantly reduced?

Grant


"vijay" <vijay.rajonline@gmail.com> wrote in message
news:hm12pv$q1c$1@build.eclipse.org...
> Why are you doing Shell.layout(true,true)
>
> all u need to do is
>
> stacklayout.topcontrol=selectedComposite;
> shell.layout();
>
> by the way having a composite for each tree element is a bit too
heavy..try to fix that...
> --
> ---------------------
> Regards,
> Vijay
Re: How to determine which layout() method I should call ? [message #516870 is a reply to message #516609] Thu, 25 February 2010 12:16 Go to previous messageGo to next message
H.ORTIZ  is currently offline H.ORTIZ Friend
Messages: 22
Registered: July 2009
Junior Member
Quote:

To change the top control on the right-side Composite it should be good
enough to invoke composite.layout() rather than shell.layout().



Ok, thanks for your advice


Quote:

Changing the stack's top Composite should not impose a significant
performance penalty, even if there are many Composites in the stack, since
the only ones that should matter are the ones being hidden and shown. How
many items does the Tree have (ie.- how many different Composites can end up
in the stack on the right)? And does each Composite have many Controls?
Does performance improve if the number of Controls on each Composite is
significantly reduced?



The tree has about 50 items. Each composite has between 20 and 100 controls.
For the last question ("Does performance improve if the number of Controls on each Composite is significantly reduced?"), I will do some tests.


Concerning the different available layout methods (with no parameter, with one parameter, with two parameters), I read the Javadoc several times and I must admit that I don't really understand which one is appropriate for which case. When does it is useful to "flush the cached information" ? It is more or less costly to do it ?

Thanks for all that,
Helene

Re: How to determine which layout() method I should call ? [message #516874 is a reply to message #516870] Thu, 25 February 2010 12:30 Go to previous message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
when ever you know that you changed somthing on your control like adding,removing or size increase/decreasing you should call layout(true) layout(true,true)

Difference between layout(true) layout(true,true)
is self evident from java doc...
layout(true,true) recursively calculates the childrens layout also negating catched layout info...


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay

[Updated on: Thu, 25 February 2010 12:34]

Report message to a moderator

Previous Topic:Custom Cocoa widget with SWT OSX Coca
Next Topic:Strange selection problem
Goto Forum:
  


Current Time: Sat Dec 07 15:46:35 GMT 2024

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

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

Back to the top