Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Treeviewer select all the elements
Treeviewer select all the elements [message #312954] Mon, 26 February 2007 12:58 Go to next message
Eclipse UserFriend
Hi,
I would know if it's possible to select all the elements (all the
parents and all the children) in a treeviewer. Because I have tried to
use the following code :
mTreeViewer.getTree().selectAll();
But it seems not working. So there is a solution?

Many thanks in advance.
Re: Treeviewer select all the elements [message #312976 is a reply to message #312954] Mon, 26 February 2007 23:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sateeshhegde.yahoo.co.in

Hi,
I have used the following code and it works, not sure if there is any
other better solution.

treeView = new CheckboxTreeViewer(cmp, SWT.SINGLE);
treeView.addCheckStateListener(new ICheckStateListener() {

public void checkStateChanged(CheckStateChangedEvent event) {

// If the item is checked . . .

if (event.getChecked()) {

// . . . check all its children

treeView.setSubtreeChecked(event.getElement(), true);

}else {

// . . . uncheck all its children

treeView.setSubtreeChecked(event.getElement(), false);

}





}

});
Naiekko wrote:
> Hi,
> I would know if it's possible to select all the elements (all the
> parents and all the children) in a treeviewer. Because I have tried to
> use the following code :
> mTreeViewer.getTree().selectAll();
> But it seems not working. So there is a solution?
>
> Many thanks in advance.
Re: Treeviewer select all the elements [message #312980 is a reply to message #312954] Tue, 27 February 2007 02:59 Go to previous messageGo to next message
Eclipse UserFriend
Naiekko wrote:
> Hi,
> I would know if it's possible to select all the elements (all the
> parents and all the children) in a treeviewer. Because I have tried to
> use the following code :
> mTreeViewer.getTree().selectAll();
> But it seems not working. So there is a solution?

Have you ensured that your table has been created with the SWT.MULTI
flag? Otherwise the selectAll() method has no effect (as documented).

Greetings from Bremen,

Daniel Krügler
Re: Treeviewer select all the elements [message #312981 is a reply to message #312980] Tue, 27 February 2007 03:49 Go to previous message
Eclipse UserFriend
Daniel Krügler a écrit :
> Naiekko wrote:
>> Hi,
>> I would know if it's possible to select all the elements (all the
>> parents and all the children) in a treeviewer. Because I have tried to
>> use the following code :
>> mTreeViewer.getTree().selectAll();
>> But it seems not working. So there is a solution?
>
> Have you ensured that your table has been created with the SWT.MULTI
> flag? Otherwise the selectAll() method has no effect (as documented).
>
> Greetings from Bremen,
>
> Daniel Krügler
>

Yep I forgot to add the SWT.MULTI but I also forgot to add the
expandAll() method on the TreeViewer to have the selection for all the
elements.
Thanks a lot !
Previous Topic:Detecting end of POST_CHANGE?
Next Topic:Tool to translate externalized strings?
Goto Forum:
  


Current Time: Tue Jul 22 08:40:28 EDT 2025

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

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

Back to the top