El mié, 21-09-2005 a las 18:20 +0200, Sylvain Wallez escribió:
> Thorsten Scherler wrote:
...
> >
> >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!
:) It is really handy.
>
> >>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.
Ok.
> >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]);
> }
>
Please stay with me and have a look at http://pastebin.com/370146. I
added a binding file and a custom binding containing above code, but how
can I now produce for each object a node?
+ /*
+ * How to produce for each object a new xml-node?
+ * Like <file>objs[1]</file>, <file>objs[2]</file>, ...
+ */
salu2
--
thorsten
"Together we stand, divided we fall!"
Hey you (Pink Floyd)