voyent
ice : tree - sorting ?  XML
Forum Index -> Components
Author Message
Markus

Joined: 01/Jun/2006 00:00:00
Messages: 7
Offline


hello,

how is it possible to get the children nodes of an <ice : tree component into an alphabetical order?

please give me a short feedback.

thanks in advance.

markus
philip.breau


Joined: 08/May/2006 00:00:00
Messages: 2989
Offline


Hi Markus,

If you mean 'how do you get an alphabetized list from an existing tree?', then I suppose you'll have go through each node of the tree and put each IceUserObject into a collections object which can then be sorted. To get the Enumeration of children from each node call DefaultTreeNode.children(). Put the IceUserObject value of each child into a collection object, then recursively call each child, to get its children, etc.

You can use the TreeSet collections object for automatic sorting (TreeSet(Comparator<? super E> c) ). Just implement a Comparator class for your specific IceUserObject (or inherited) class, adding the compare(T o1, T o2) method which will alphabetize whatever you want, then call the TreeSet constructor with the Comparator. Then anything added to the TreeSet will be automatically sorted.

Thanks,
Philip

.
Markus

Joined: 01/Jun/2006 00:00:00
Messages: 7
Offline


hi philip,

thanks a lot for the detailed feedback.
i`ll try to implement your instructions.

markus
 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team