Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Preventing TreeItem to expand/collapse(Is this possible to achieve?)
icon5.gif  Preventing TreeItem to expand/collapse [message #549916] Wed, 28 July 2010 13:02 Go to next message
Albert Pikus is currently offline Albert PikusFriend
Messages: 70
Registered: October 2009
Member
Hi, everybody,

I wonder if it is possible to prevent TreeItem to expand/collapse when [+]/[-] is clicked. Setting event.doit to false doesn't work.

I tried to prevent expanding/collapsing with both typed listener (TreeListener) and untyped listener, but with no success.


Any advise would be greatly appreciated.


Best regards,

Albert
Re: Preventing TreeItem to expand/collapse [message #553717 is a reply to message #549916] Wed, 18 August 2010 14:36 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
Hi, sorry for the late reply,

There isn't a way to veto an expand/collapse by the user, other than to
listen for the Expand/Collapse event and invoke the opposite API to
re-expand/re-collapse the item, which can show a flash.

I could not find existing Feature Requests for a better way to do this, so
if you want you can log one or two with swt at
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform
&component=SWT&bug_severity=enhancement .

Grant


"Albert" <albert.pikus@gmail.com> wrote in message
news:i2p9oj$v7s$1@build.eclipse.org...
> Hi, everybody,
>
> I wonder if it is possible to prevent TreeItem to expand/collapse when
> [+]/[-] is clicked. Setting event.doit to false doesn't work.
> I tried to prevent expanding/collapsing with both typed listener
> (TreeListener) and untyped listener, but with no success.
>
>
> Any advise would be greatly appreciated.
>
>
> Best regards,
>
> Albert
>
Re: Preventing TreeItem to expand/collapse [message #555092 is a reply to message #549916] Wed, 25 August 2010 12:48 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
Pls do follow what Grant suggested...

At many places, i also needed such functionality but then again i found that by default these type of functionalities are not there in the OS controls for a reason..

Its like this,why would any body would have a tree with expandable tree element and dont want to expand it,if he dont want to expand any element of the tree, then he would desable the tree control,if he does not want a single element to be expanded ,then wouldnt it be better to show it without children...

it all depends on your business logic....


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Preventing TreeItem to expand/collapse [message #634066 is a reply to message #549916] Wed, 20 October 2010 12:37 Go to previous message
Albert Pikus is currently offline Albert PikusFriend
Messages: 70
Registered: October 2009
Member
Hi,

thank you both for your replies.

I solved this like Grant suggested, but there is of course this "flash" that occurs when preventing TreeItem to collapse by re-expanding it immediately after the collapse.

I can certainly see a use case when this feature could be useful, although vijay's remark on expanding is true; I need this functionality just to prevent collapse, while preventing expanding of TreeItem can be achieved by other means.

I guess I will just have to live with the above mentioned solution, thank you again for your answers!


Best regards,

Albert
Previous Topic:How to not hide cursor when typing
Next Topic:Remove a button item from a table
Goto Forum:
  


Current Time: Sun Dec 17 21:44:29 GMT 2017

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

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