Sorry for the late reply, but like stated in the other thread,
attachements with issue reports are the way to go.

The main difficulty for me with the tree component is that I hardly
use it myself, and those times that I did use it, the tree sufficed.
So, if you have more needs: keep those patches comming and we'll be
happy to apply them (if the quality is decent of course ;))

Eelco


On 6/1/06, David Leangen <[EMAIL PROTECTED]> wrote:
>
> The Tree component is really cool! Thanks for this!
>
> The problem I mention below is that I was trying to use the Tree
> component in a DataView. I have no particular problems with DataView,
> and the Tree is great by itself.
>
> Originally, since I did not want the root node to be shown, I thought
> I'd make a list Tree components. That's what my question was about. I
> later noticed that I can just make the root node invisible, which is a
> much easier approach.
>
> Just out of curiosity, though, what would I have to do to get this kind
> of multi-level approach to work (not that it's all that useful...)?
>
>
> In the Tree component, this is not yet implemented:
>
>    setSelectionModel( TreeSelectionModel.SINGLE_TREE_SELECTION );
>
> I hacked together a patch (attached to this mail). Would you mind adding
> it, or something similar? I put the collapseAll() into a separate
> protected method so that it can be overridden (which I need to do so I
> can purge nodes no longer used from memory).
>
>
> By the way, the only way I was able to modify the model (i.e. by adding
> and removing nodes) was by calling setTreeModel() with the updated
> model. Is this intended? It somehow doesn't seem all that natural... I
> also get the impression that it requires a lot of extra (i.e. not
> needed) processing. WDTY?
>
>
>
> Cheers,
> Dave
>
>
>
>
> On Tue, 2006-05-30 at 17:59 +0900, David Leangen wrote:
> > This is great! Thanks!!
> >
> > BTW, sorry to ask such a basic question... It's about models again.
> >
> > I noticed that the event is being triggered and the state of the object
> > is being correctly changed. However, upon the subsequent request, the
> > changed state was not "persisted" (so to speak) in the model, and the
> > tree stays unchanged.
> >
> > This is what I have (largely "inspired" from the examples):
> >
> >   add
> >   (
> >       new DataView( "categoryTrees",
> >       new TreeCategoryDataProvider( getServiceManager() ) )
> >       {
> >           private static final long serialVersionUID = 1L;
> >
> >           protected void populateItem( final Item item )
> >           {
> >              MyTreeNode treeNode = (MyTreeNode)item.getModelObject();
> >              TreeModel treeModel = convertToTreeModel( treeNode );
> >              Tree tree = new MeshTree( "categoryTree", treeModel )
> >              {
> >                 private static final long serialVersionUID = 1L;
> >
> >                 protected String getNodeLabel( DefaultMutableTreeNode
> > node )
> >                 {
> >                     final MyTreeNode treeNode =
> > (MyTreeNode)node.getUserObject();
> >                     return treeNode.getLabel();
> >                 }
> >              };
> >
> >              item.add( tree );
> >           }
> >      }
> >  );
> >
> >
> > Convert to TreeModel looks like this:
> >
> >   private TreeModel convertToTreeModel( final MyTreeNode node )
> >   {
> >     try
> >     {
> >        final DefaultMutableTreeNode rootNode = new
> > DefaultMutableTreeNode( node );
> >        List<MyTreeNode> children = null;
> >
> >        // Get the children from the DB
> >        children = node.retrieveChildren();
> >        for( MyTreeNode child : children )
> >        {
> >           rootNode.add( new DefaultMutableTreeNode( child ) );
> >        }
> >
> >        final TreeModel model = new DefaultTreeModel( rootNode );
> >        return model;
> >    }
> >    catch ( FinderException e )
> >    {
> >       throw new RuntimeException( e );
> >    }
> >  }
> >
> >
> >
> > Wondering if you can tell me what I'm doing wrong here...
> >
> > Thanks so much!
> >
> >
> >
> >
> > On Mon, 2006-05-29 at 23:02 -0700, Eelco Hillenius wrote:
> > > That was something that was not build in yet. I added this to the tree
> > > component:
> > >
> > >     /**
> > >      * Expand or collapse all nodes.
> > >      *
> > >      * @param expand
> > >      *            If true, expand all nodes in the tree. Else collapse 
> > > all nodes
> > >      *            in the tree.
> > >      */
> > >     public void expandAll(boolean expand)
> > >     {
> > >             TreeNode root = (TreeNode)getTreeState().getModel().getRoot();
> > >             expandAll(new TreePath(root), expand);
> > >     }
> > >
> > >     private final void expandAll(TreePath parent, boolean expand)
> > >     {
> > >             TreeNode node = (TreeNode)parent.getLastPathComponent();
> > >             if (node.getChildCount() >= 0)
> > >             {
> > >                     for (Enumeration e = node.children(); 
> > > e.hasMoreElements();)
> > >                     {
> > >                             TreeNode n = (TreeNode)e.nextElement();
> > >                             TreePath path = parent.pathByAddingChild(n);
> > >                             expandAll(path, expand);
> > >                     }
> > >             }
> > >
> > >             if (expand)
> > >             {
> > >                     expandPath(parent);
> > >             }
> > >             else
> > >             {
> > >                     collapsePath(parent);
> > >             }
> > >     }
> > >
> > >     /**
> > >      * Ensures that the node identified by the specified path is expanded 
> > > and
> > >      * viewable. If the last item in the path is a leaf, this will have no
> > >      * effect.
> > >      *
> > >      * @param path
> > >      *            the <code>TreePath</code> identifying a node
> > >      */
> > >     public void expandPath(TreePath path)
> > >     {
> > >             // Only expand if not leaf!
> > >             TreeModel model = getTreeState().getModel();
> > >
> > >             if (path != null && model != null &&
> > > !model.isLeaf(path.getLastPathComponent()))
> > >             {
> > >                     setExpandedState(path, true);
> > >             }
> > >     }
> > >
> > >     /**
> > >      * Ensures that the node identified by the specified path is 
> > > collapsed and
> > >      * viewable.
> > >      *
> > >      * @param path
> > >      *            the <code>TreePath</code> identifying a node
> > >      */
> > >     public void collapsePath(TreePath path)
> > >     {
> > >             setExpandedState(path, false);
> > >     }
> > >
> > > and I added two links that use this in the nested example.
> > >
> > > Have fun with it.
> > >
> > > Eelco
> > >
> > >
> > > On 5/29/06, David Leangen <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Hello!
> > > >
> > > > My assumption when using the TreeModel is that the
> > > > wicket.markup.html.Tree is analogous to javax.swing.tree.JTree.
> > > >
> > > > Although I'm not so familiar with JTree (or anything Swing for that
> > > > matter), there are many examples available out there.
> > > >
> > > >
> > > > However, there are a few things that are not so obvious to me right now
> > > > with the Wicket TreeModel.
> > > >
> > > > 1. How do I collapse branches by default?
> > > >
> > > > 2. I tried the following, but it did not seem to do anything:
> > > >    getTreeState().getSelectionModel().setSelectionMode(
> > > >       TreeSelectionModel.SINGLE_TREE_SELECTION );
> > > >
> > > >
> > > > Any hints would be great!
> > > >
> > > >
> > > > Thank you!
> > > > Dave
> > > >
> > > >
> > > >
> > > > -------------------------------------------------------
> > > > All the advantages of Linux Managed Hosting--Without the Cost and Risk!
> > > > Fully trained technicians. The highest number of Red Hat certifications 
> > > > in
> > > > the hosting industry. Fanatical Support. Click to learn more
> > > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
> > > > _______________________________________________
> > > > Wicket-user mailing list
> > > > [email protected]
> > > > https://lists.sourceforge.net/lists/listinfo/wicket-user
> > > >
> > >
> > >
> > > -------------------------------------------------------
> > > All the advantages of Linux Managed Hosting--Without the Cost and Risk!
> > > Fully trained technicians. The highest number of Red Hat certifications in
> > > the hosting industry. Fanatical Support. Click to learn more
> > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
> > > _______________________________________________
> > > Wicket-user mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
> >
> >
> > -------------------------------------------------------
> > All the advantages of Linux Managed Hosting--Without the Cost and Risk!
> > Fully trained technicians. The highest number of Red Hat certifications in
> > the hosting industry. Fanatical Support. Click to learn more
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
> > _______________________________________________
> > Wicket-user mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
>


_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to