cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylv...@apache.org>
Subject Re: Tree widget example broken (was Re: svn commit: r289538)
Date Wed, 21 Sep 2005 16:20:16 GMT
Thorsten Scherler wrote:

>El mar, 20-09-2005 a las 17:38 +0200, Sylvain Wallez escribió: 
>  
>
>>Thorsten Scherler wrote:
>>    
>>
>>>That is working fine. :) Very good stuff.
>>>
>>>Any hints how I can implement the binding?
>>>      
>>>
>>The tree widget currently doesn't have child widgets, so binding it 
>>doesn't really make sense.
>>    
>>
>
>It does not provide child widgets in the cforms definition but IMO each
>node of the tree is an option. The file explorer example shows that
>quite nice. You can select nodes and the selected nodes are stored in
>the message, right?
>  
>

The tree widget keeps the paths of selected nodes, but not the nodes 
themselves, to avoid keeping hard references on the tree model. You can 
access the selection using tree.getSelectionPath (single selection) or 
tree.getSelectionPaths (multiple selection).

 From a TreePath, you can then access the actual tree node using 
tree.getModel().getNode(path).

>Now one way to have a binding example is to not use the message wigdet
>but another widget where we store the selected option. Please have a
>look at http://pastebin.com/370003.
>  
>

Didn't knew pastebin. Cool!

>>>From there I would like to change the filesOption.setValue(...) in:
>...
> } else {
>   messages.setValue(count + " files selected");
>   filesOption.setValue(count + " files selected");
> }
>
>to an array that is storing the "files.selectionPath" for all selected
>files. From there we can extracted it in the binding again. Does that
>makes sense?
>  
>

You actually don't need to update the array in the event listener. Just 
use tree.getSelectionPaths() to get the full selection when you need to 
perform your binding.

>I am still looking into a way how to get the selection to an array. Can
>you point me to information about getting the event.source.selection
>into an array?
>  
>

What about:

    TreePath[] paths = tree.getSelectionPaths();
    Object[] objs = new Object[paths.length];
    for (int i = 0; i < paths.length; i++) {
        objs[i] = tree.getModel().getNode(paths[i]);
    }

>>What you should take a lot at though, is the TreeModel which is what 
>>should be provided by the application to fill the tree.
>>    
>>
>
>I looked at the $Sample and actually I am planning to use it in lenya to
>read in the sitetree.xml of a publication. I reckon I just need some
>small modifications.
>  
>

Great! This tree widget is very new, and just awaits users to express 
their needs!

Sylvain

-- 
Sylvain Wallez                        Anyware Technologies
http://people.apache.org/~sylvain     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


Mime
View raw message