Author: knopp
Date: Thu Sep  4 15:19:58 2008
New Revision: 692277

URL: http://svn.apache.org/viewvc?rev=692277&view=rev
Log:
generify tree

Modified:
    
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tree/DefaultAbstractTree.java
    
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tree/Tree.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/BaseTree.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/ITreeState.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LabelIconPanel.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LabelTree.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LinkIconPanel.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LinkTree.java

Modified: 
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tree/DefaultAbstractTree.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tree/DefaultAbstractTree.java?rev=692277&r1=692276&r2=692277&view=diff
==============================================================================
--- 
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tree/DefaultAbstractTree.java
 (original)
+++ 
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tree/DefaultAbstractTree.java
 Thu Sep  4 15:19:58 2008
@@ -52,7 +52,7 @@
  * This class allows you to choose between 3 types of links. [EMAIL PROTECTED]
  * DefaultAbstractTree#setLinkType(org
  * .apache.wicket.extensions.markup.html.tree.DefaultAbstractTree.LinkType)}
- * 
+ *
  * @author Matej Knopp
  */
 public abstract class DefaultAbstractTree extends AbstractTree
@@ -92,7 +92,7 @@
 
                /**
                 * Construct.
-                * 
+                *
                 * @param name
                 */
                public LinkType(String name)
@@ -103,14 +103,14 @@
 
        /**
         * Helper class for calling an action from a link.
-        * 
+        *
         * @author Matej Knopp
         */
        protected interface ILinkCallback extends IClusterable
        {
                /**
                 * Called when the click is executed.
-                * 
+                *
                 * @param target
                 *            The ajax request target
                 */
@@ -140,7 +140,7 @@
 
        /**
         * Tree constructor.
-        * 
+        *
         * @param id
         *            The component id
         */
@@ -152,13 +152,13 @@
 
        /**
         * Tree constructor.
-        * 
+        *
         * @param id
         *            The component id
         * @param model
         *            The tree model
         */
-       public DefaultAbstractTree(String id, IModel<?> model)
+       public DefaultAbstractTree(String id, IModel<TreeModel> model)
        {
                super(id, model);
                init();
@@ -166,21 +166,22 @@
 
        /**
         * Tree constructor.
-        * 
+        *
         * @param id
         *            The component id
         * @param model
         *            The tree model
         */
+       @SuppressWarnings("unchecked")
        public DefaultAbstractTree(String id, TreeModel model)
        {
-               super(id, new Model<Serializable>((Serializable)model));
+               super(id, new Model((Serializable)model));
                init();
        }
 
        /**
         * Returns the current type of links on tree items.
-        * 
+        *
         * @return The link type
         */
        public LinkType getLinkType()
@@ -191,7 +192,7 @@
        /**
         * Sets the type of links on tree items. After the link type is 
changed, the whole tree is
         * rebuild and re-rendered.
-        * 
+        *
         * @param linkType
         *            type of links
         */
@@ -206,7 +207,7 @@
 
        /**
         * Returns the resource reference of default stylesheet.
-        * 
+        *
         * @return The package resource reference
         */
        protected ResourceReference getCSS()
@@ -216,7 +217,7 @@
 
        /**
         * Returns the resource reference of default closed tree folder.
-        * 
+        *
         * @return The package resource reference
         */
        protected ResourceReference getFolderClosed()
@@ -226,7 +227,7 @@
 
        /**
         * Returns the resource reference of default open tree folder.
-        * 
+        *
         * @return The package resource reference
         */
        protected ResourceReference getFolderOpen()
@@ -236,7 +237,7 @@
 
        /**
         * Returns the resource reference of default tree item (not folder).
-        * 
+        *
         * @return The package resource reference
         */
        protected ResourceReference getItem()
@@ -246,7 +247,7 @@
 
        /**
         * Returns the resource reference for icon of specified tree node.
-        * 
+        *
         * @param node
         *            The node
         * @return The package resource reference
@@ -274,7 +275,7 @@
         * Creates the indentation element. This element should be placed as 
first element in the tree
         * item markup to ensure proper indentation of the tree item. This 
implementation also takes
         * care of lines that connect nodes.
-        * 
+        *
         * @param parent
         *            The component parent
         * @param id
@@ -331,7 +332,7 @@
         * Creates an image placed on junction link. This image actually 
consists of two spans with
         * different css classes. These classes are specified according to the 
stylesheet to make the
         * junction image look well together with lines connecting nodes.
-        * 
+        *
         * @param parent
         *            The component parent
         * @param id
@@ -377,17 +378,17 @@
        /**
         * Creates the junction link for given node. Also (optionally) creates 
the junction image. If
         * the node is a leaf (it has no children), the created junction link 
is non-functional.
-        * 
+        *
         * @param parent
         *            parent component of the link
-        * 
+        *
         * @param id
         *            wicket:id of the component
-        * 
+        *
         * @param imageId
         *            wicket:id of the image. this can be null, in that case 
image is not created. image
         *            is supposed to be placed on the link (link is parent of 
image)
-        * 
+        *
         * @param node
         *            tree node for which the link should be created.
         * @return The link component
@@ -448,7 +449,7 @@
        /**
         * Creates a link of type specified by current linkType. When the links 
is clicked it calls the
         * specified callback.
-        * 
+        *
         * @param parent
         *            The parent component
         * @param id
@@ -462,7 +463,7 @@
        {
                if (getLinkType() == LinkType.REGULAR)
                {
-                       return new Link(id)
+                       return new Link<Void>(id)
                        {
                                private static final long serialVersionUID = 1L;
 
@@ -478,7 +479,7 @@
                }
                else if (getLinkType() == LinkType.AJAX)
                {
-                       return new AjaxLink(id)
+                       return new AjaxLink<Void>(id)
                        {
                                private static final long serialVersionUID = 1L;
 
@@ -495,7 +496,7 @@
                }
                else
                {
-                       return new AjaxFallbackLink(id)
+                       return new AjaxFallbackLink<Void>(id)
                        {
                                private static final long serialVersionUID = 1L;
 
@@ -515,7 +516,7 @@
        /**
         * Creates the icon for current node. By default uses image reference 
specified by
         * [EMAIL PROTECTED] DefaultAbstractTree#getNodeIcon(TreeNode)}.
-        * 
+        *
         * @param parent
         *            The parent component
         * @param id
@@ -543,7 +544,7 @@
 
        /**
         * Creates a link that can be used to select / deselect the specified 
node.
-        * 
+        *
         * @param parent
         *            The parent component
         * @param id
@@ -570,10 +571,10 @@
        /**
         * Callback function called after user clicked on an junction link. The 
node has already been
         * expanded/collapsed (depending on previous status).
-        * 
+        *
         * @param target
         *            Request target - may be null on non-ajax call
-        * 
+        *
         * @param node
         *            Node for which this callback is relevant
         */
@@ -583,10 +584,10 @@
 
        /**
         * This callback method is called after user has selected / deselected 
the given node.
-        * 
+        *
         * @param target
         *            Request target - may be null on non-ajax call
-        * 
+        *
         * @param node
         *            Node for which this this callback is fired.
         */
@@ -608,7 +609,7 @@
 
        /**
         * Returns whether the provided node is last child of it's parent.
-        * 
+        *
         * @param node
         *            The node
         * @return whether the provided node is the last child

Modified: 
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tree/Tree.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tree/Tree.java?rev=692277&r1=692276&r2=692277&view=diff
==============================================================================
--- 
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tree/Tree.java
 (original)
+++ 
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tree/Tree.java
 Thu Sep  4 15:19:58 2008
@@ -57,7 +57,7 @@
         * @param model
         *            The tree model
         */
-       public Tree(String id, IModel<?> model)
+       public Tree(String id, IModel<TreeModel> model)
        {
                super(id, model);
        }

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java?rev=692277&r1=692276&r2=692277&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java
 Thu Sep  4 15:19:58 2008
@@ -29,6 +29,7 @@
 
 import org.apache.wicket.Component;
 import org.apache.wicket.IRequestTarget;
+import org.apache.wicket.MarkupContainer;
 import org.apache.wicket.ResourceReference;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.behavior.HeaderContributor;
@@ -49,7 +50,7 @@
  * This class encapsulates the logic for displaying and (partial) updating the 
tree. Actual
  * presentation is out of scope of this class. User should derive they own 
tree (if needed) from
  * [EMAIL PROTECTED] BaseTree} (recommended).
- *
+ * 
  * @author Matej Knopp
  */
 public abstract class AbstractTree extends Panel
@@ -60,7 +61,7 @@
 {
 
        /**
-        *
+        * 
         */
        private static final long serialVersionUID = 1L;
 
@@ -71,7 +72,7 @@
        {
                /**
                 * Visits the tree item.
-                *
+                * 
                 * @param item
                 *            the item to visit
                 */
@@ -106,7 +107,7 @@
 
                /**
                 * Construct.
-                *
+                * 
                 * @param id
                 *            The component id
                 * @param node
@@ -117,7 +118,7 @@
                 */
                public TreeItem(TreeItem parent, String id, final Object node, 
int level)
                {
-                       super(id, new Model((Serializable)node));
+                       super(id, new Model<Serializable>((Serializable)node));
 
                        this.parent = parent;
 
@@ -141,7 +142,7 @@
                 * @return The children
                 */
                public List<TreeItem> getChildren()
-               {                       
+               {
                        return children;
                }
 
@@ -167,7 +168,7 @@
 
                /**
                 * Sets the children.
-                *
+                * 
                 * @param children
                 *            The children
                 */
@@ -178,7 +179,7 @@
 
                /**
                 * Whether to render children.
-                *
+                * 
                 * @return whether to render children
                 */
                protected final boolean isRenderChildren()
@@ -237,6 +238,11 @@
                        }
                }
 
+               public Object getModelObject()
+               {
+                       return getDefaultModelObject();
+               }
+
                @Override
                public void renderHead(final HtmlHeaderContainer container)
                {
@@ -250,7 +256,7 @@
                                        public void visitItem(TreeItem item)
                                        {
                                                // write header contributions 
from the children of item
-                                               item.visitChildren(new 
Component.IVisitor()
+                                               item.visitChildren(new 
Component.IVisitor<Component>()
                                                {
                                                        public Object 
component(Component component)
                                                        {
@@ -279,7 +285,7 @@
                protected void onDetach()
                {
                        super.onDetach();
-                       Object object = getDefaultModelObject();
+                       Object object = getModelObject();
                        if (object instanceof IDetachable)
                        {
                                ((IDetachable)object).detach();
@@ -348,7 +354,7 @@
 
                /**
                 * Construct.
-                *
+                * 
                 * @param id
                 *            The component id
                 */
@@ -367,14 +373,14 @@
                        // nodeToItemMAp
                        if (component instanceof TreeItem)
                        {
-                               
nodeToItemMap.remove(((TreeItem)component).getDefaultModelObject());
+                               
nodeToItemMap.remove(((TreeItem)component).getModelObject());
                        }
                        super.remove(component);
                }
 
                /**
                 * renders the tree items, making sure that items are rendered 
in the order they should be
-                *
+                * 
                 * @param markupStream
                 */
                @Override
@@ -470,7 +476,7 @@
 
        /**
         * Tree constructor
-        *
+        * 
         * @param id
         *            The component id
         */
@@ -482,13 +488,13 @@
 
        /**
         * Tree constructor
-        *
+        * 
         * @param id
         *            The component id
         * @param model
         *            The tree model
         */
-       public AbstractTree(String id, IModel model)
+       public AbstractTree(String id, IModel<TreeModel> model)
        {
                super(id, model);
                init();
@@ -507,8 +513,48 @@
        }
 
        /**
+        * 
+        * @return model
+        */
+       @SuppressWarnings("unchecked")
+       public IModel<TreeModel> getModel()
+       {
+               return (IModel<TreeModel>)getDefaultModel();
+       }
+
+       /**
+        * @return treemodel
+        */
+       public TreeModel getModelObject()
+       {
+               return (TreeModel)getDefaultModelObject();
+       }
+
+       /**
+        * 
+        * @param model
+        * @return this
+        */
+       public MarkupContainer setModel(IModel<TreeModel> model)
+       {
+               setDefaultModel(model);
+               return this;
+       }
+
+       /**
+        * 
+        * @param model
+        * @return this
+        */
+       public MarkupContainer setModelObject(TreeModel model)
+       {
+               setDefaultModelObject(model);
+               return this;
+       }
+
+       /**
         * Returns the TreeState of this tree.
-        *
+        * 
         * @return Tree state instance
         */
        public ITreeState getTreeState()
@@ -558,7 +604,7 @@
                        // has been called
                        if (rootItem == null)
                        {
-                               Object rootNode = 
((TreeModel)getDefaultModelObject()).getRoot();
+                               Object rootNode = getModelObject().getRoot();
                                if (rootNode != null)
                                {
                                        if (isRootLess())
@@ -669,7 +715,7 @@
 
        /**
         * Determines whether the TreeNode needs to be rebuilt if it is 
selected or deselected
-        *
+        * 
         * @return true if the node should be rebuilt after (de)selection, 
false otherwise
         */
        protected boolean isForceRebuildOnSelectionChange()
@@ -679,7 +725,7 @@
 
        /**
         * Sets whether the root of the tree should be visible.
-        *
+        * 
         * @param rootLess
         *            whether the root should be visible
         */
@@ -692,9 +738,9 @@
 
                        // if the tree is in rootless mode, make sure the root 
node is
                        // expanded
-                       if (rootLess == true && getDefaultModelObject() != null)
+                       if (rootLess == true && getModelObject() != null)
                        {
-                               
getTreeState().expandNode(((TreeModel)getDefaultModelObject()).getRoot());
+                               
getTreeState().expandNode(getModelObject().getRoot());
                        }
                }
        }
@@ -713,7 +759,7 @@
                {
                        if (rootItem != null)
                        {
-                               
invalidateNode(rootItem.getDefaultModelObject(), true);
+                               invalidateNode(rootItem.getModelObject(), true);
                        }
                }
                else
@@ -738,10 +784,10 @@
        /**
         * Marks the last but one visible child node of the given item as 
dirty, if give child is the
         * last item of parent.
-        *
+        * 
         * We need this to refresh the previous visible item in case the 
inserted / deleted item was
         * last. The reason is that the line shape of previous item changes 
from L to |- .
-        *
+        * 
         * @param parent
         * @param child
         */
@@ -757,7 +803,7 @@
 
                                // invalidate the node and it's children, so 
that they are
                                // redrawn
-                               
invalidateNodeWithChildren(item.getDefaultModelObject());
+                               
invalidateNodeWithChildren(item.getModelObject());
 
                        }
                }
@@ -772,7 +818,7 @@
                {
                        return;
                }
-               
+
                // get the parent node of inserted nodes
                Object parent = e.getTreePath().getLastPathComponent();
 
@@ -782,12 +828,12 @@
 
                        if (parentItem != null)
                        {
-                       
+
                                if (parentItem.getChildren() == null || 
parentItem.getChildren().isEmpty())
                                {
                                        invalidateNode(parent, true);
                                }
-       
+
                                for (int i = 0; i < e.getChildren().length; ++i)
                                {
                                        Object node = e.getChildren()[i];
@@ -795,12 +841,12 @@
                                        TreeItem item = newTreeItem(parentItem, 
node, parentItem.getLevel() + 1);
                                        itemContainer.add(item);
                                        parentItem.getChildren().add(index, 
item);
-       
+
                                        markTheLastButOneChildDirty(parentItem, 
item);
-       
+
                                        if (!dirtyItems.contains(item))
                                                dirtyItems.add(item);
-       
+
                                        if (!dirtyItemsCreateDOM.contains(item))
                                                dirtyItemsCreateDOM.add(item);
                                }
@@ -817,14 +863,15 @@
                {
                        return;
                }
-               
+
                // get the parent node of inserted nodes
                Object parent = e.getTreePath().getLastPathComponent();
                TreeItem parentItem = nodeToItemMap.get(parent);
 
                if (parentItem != null && isNodeVisible(parent) && 
isNodeExpanded(parent))
                {
-                       boolean nonEmpty = parentItem.getChildren() != null && 
!parentItem.getChildren().isEmpty();
+                       boolean nonEmpty = parentItem.getChildren() != null &&
+                               !parentItem.getChildren().isEmpty();
                        for (int i = 0; i < e.getChildren().length; ++i)
                        {
                                Object node = e.getChildren()[i];
@@ -842,16 +889,16 @@
                                                        removeItem(item);
 
                                                        // deselect the node
-                                                       
getTreeState().selectNode(item.getDefaultModelObject(), false);
+                                                       
getTreeState().selectNode(item.getModelObject(), false);
                                                }
                                        });
-                                       
+
                                        parentItem.getChildren().remove(item);
-                                       
+
                                        removeItem(item);
 
-                                       
getTreeState().selectNode(item.getDefaultModelObject(), false);                 
                
-                                       
+                                       
getTreeState().selectNode(item.getModelObject(), false);
+
                                }
                        }
                        if (nonEmpty && parentItem.getChildren().isEmpty())
@@ -870,7 +917,7 @@
                {
                        return;
                }
-               
+
                // get the parent node of changed nodes
                Object node = e.getTreePath().getLastPathComponent();
 
@@ -902,7 +949,7 @@
 
        /**
         * Allows to intercept adding dirty components to AjaxRequestTarget.
-        *
+        * 
         * @param target
         * @param component
         */
@@ -943,9 +990,9 @@
                        // inserted.
                        while (dirtyItemsCreateDOM.isEmpty() == false)
                        {
-                               for (Iterator i = 
dirtyItemsCreateDOM.iterator(); i.hasNext();)
+                               for (Iterator<TreeItem> i = 
dirtyItemsCreateDOM.iterator(); i.hasNext();)
                                {
-                                       TreeItem item = (TreeItem)i.next();
+                                       TreeItem item = i.next();
                                        TreeItem parent = item.getParentItem();
                                        int index = 
parent.getChildren().indexOf(item);
                                        TreeItem previous;
@@ -986,9 +1033,9 @@
                        }
 
                        // iterate through dirty items
-                       for (Iterator i = dirtyItems.iterator(); i.hasNext();)
+                       for (Iterator<TreeItem> i = dirtyItems.iterator(); 
i.hasNext();)
                        {
-                               TreeItem item = (TreeItem)i.next();
+                               TreeItem item = i.next();
 
                                // does the item need to rebuild children?
                                if (item.getChildren() == null)
@@ -1017,7 +1064,7 @@
         * the component on page. Make sure that the tree model has fired the 
proper listener functions.
         * <p>
         * <b>You can only call this method once in a request.</b>
-        *
+        * 
         * @param target
         *            Ajax request target used to send the update to the page
         */
@@ -1033,7 +1080,7 @@
 
        /**
         * Returns whether the given node is expanded.
-        *
+        * 
         * @param node
         *            The node to inspect
         * @return true if the node is expanded, false otherwise
@@ -1041,7 +1088,7 @@
        protected final boolean isNodeExpanded(Object node)
        {
                // In root less mode the root node is always expanded
-               if (isRootLess() && rootItem != null && 
rootItem.getDefaultModelObject().equals(node))
+               if (isRootLess() && rootItem != null && 
rootItem.getModelObject().equals(node))
                {
                        return true;
                }
@@ -1052,7 +1099,7 @@
        /**
         * Creates the TreeState, which is an object where the current state of 
tree (which nodes are
         * expanded / collapsed, selected, ...) is stored.
-        *
+        * 
         * @return Tree state instance
         */
        protected ITreeState newTreeState()
@@ -1074,10 +1121,10 @@
        /**
         * This method is called after creating every TreeItem. This is the 
place for adding components
         * on item (junction links, labels, icons...)
-        *
+        * 
         * @param item
         *            newly created tree item. The node can be obtained as 
item.getModelObject()
-        *
+        * 
         * @param level
         *            how deep the component is in tree hierarchy (0 for root 
item)
         */
@@ -1086,7 +1133,7 @@
        /**
         * Builds the children for given TreeItem. It recursively traverses 
children of it's TreeNode
         * and creates TreeItem for every visible TreeNode.
-        *
+        * 
         * @param item
         *            The parent tree item
         */
@@ -1095,11 +1142,10 @@
                List<TreeItem> items;
 
                // if the node is expanded
-               if (isNodeExpanded(item.getDefaultModelObject()))
+               if (isNodeExpanded(item.getModelObject()))
                {
                        // build the items for children of the items' treenode.
-                       items = buildTreeItems(item, 
nodeChildren(item.getDefaultModelObject()),
-                               item.getLevel() + 1);
+                       items = buildTreeItems(item, 
nodeChildren(item.getModelObject()), item.getLevel() + 1);
                }
                else
                {
@@ -1112,7 +1158,7 @@
 
        /**
         * Builds (recursively) TreeItems for the given Iterator of TreeNodes.
-        *
+        * 
         * @param parent
         * @param nodes
         *            The nodes to build tree items for
@@ -1148,7 +1194,7 @@
        private final void checkModel()
        {
                // find out whether the model object (the TreeModel) has been 
changed
-               TreeModel model = (TreeModel)getDefaultModelObject();
+               TreeModel model = getModelObject();
                if (model != previousModel)
                {
                        if (previousModel != null)
@@ -1184,7 +1230,7 @@
 
        /**
         * Returns the javascript used to delete removed elements.
-        *
+        * 
         * @return The javascript
         */
        private String getElementsDeleteJavascript()
@@ -1219,7 +1265,7 @@
 
        /**
         * returns the short version of item id (just the number part).
-        *
+        * 
         * @param item
         *            The tree item
         * @return The id
@@ -1257,7 +1303,7 @@
 
        /**
         * INTERNAL
-        *
+        * 
         * @param node
         */
        public final void markNodeDirty(Object node)
@@ -1267,7 +1313,7 @@
 
        /**
         * INTERNAL
-        *
+        * 
         * @param node
         */
        public final void markNodeChildrenDirty(Object node)
@@ -1279,7 +1325,7 @@
                        {
                                public void visitItem(TreeItem item)
                                {
-                                       
invalidateNode(item.getDefaultModelObject(), false);
+                                       invalidateNode(item.getModelObject(), 
false);
                                }
                        });
                }
@@ -1288,7 +1334,7 @@
        /**
         * Invalidates single node (without children). On the next render, this 
node will be updated.
         * Node will not be rebuilt, unless forceRebuild is true.
-        *
+        * 
         * @param node
         *            The node to invalidate
         * @param forceRebuild
@@ -1308,7 +1354,7 @@
                                {
                                        // recreate the item
                                        int level = item.getLevel();
-                                       List children = item.getChildren();
+                                       List<TreeItem> children = 
item.getChildren();
                                        String id = item.getId();
 
                                        // store the parent of old item
@@ -1354,7 +1400,7 @@
        /**
         * Invalidates node and it's children. On the next render, the node and 
children will be
         * updated. Node children will be rebuilt.
-        *
+        * 
         * @param node
         *            The node to invalidate
         */
@@ -1391,7 +1437,7 @@
 
        /**
         * Returns whether the given node is visible, e.g. all it's parents are 
expanded.
-        *
+        * 
         * @param node
         *            The node to inspect
         * @return true if the node is visible, false otherwise
@@ -1416,9 +1462,9 @@
 
        /**
         * Returns parent node of given node.
-        *
+        * 
         * @param node
-        * @return
+        * @return parent node
         */
        public Object getParentNode(Object node)
        {
@@ -1430,13 +1476,13 @@
                else
                {
                        TreeItem parent = item.getParentItem();
-                       return parent == null ? null : 
parent.getDefaultModelObject();
+                       return parent == null ? null : parent.getModelObject();
                }
        }
 
        /**
         * Creates a tree item for given node.
-        *
+        * 
         * @param parent
         * @param node
         *            The tree node
@@ -1451,7 +1497,7 @@
 
        /**
         * Creates a tree item for given node with specified id.
-        *
+        * 
         * @param parent
         * @param node
         *            The tree node
@@ -1468,7 +1514,7 @@
 
        /**
         * Return the representation of node children as Iterator interface.
-        *
+        * 
         * @param node
         *            The tree node
         * @return iterable presentation of node children
@@ -1485,16 +1531,30 @@
                return nodes.iterator();
        }
 
+       /**
+        * @param parent
+        * @param index
+        * @return child
+        */
        public final Object getChildAt(Object parent, int index)
        {
                return getTreeModel().getChild(parent, index);
        }
 
+       /**
+        * 
+        * @param node
+        * @return boolean
+        */
        public final boolean isLeaf(Object node)
        {
                return getTreeModel().isLeaf(node);
        }
 
+       /**
+        * @param parent
+        * @return child count
+        */
        public final int getChildCount(Object parent)
        {
                return getTreeModel().getChildCount(parent);
@@ -1502,7 +1562,7 @@
 
        private TreeModel getTreeModel()
        {
-               return (TreeModel)getDefaultModelObject();
+               return getModelObject();
        }
 
        /**
@@ -1512,7 +1572,7 @@
        private final void rebuildDirty()
        {
                // go through dirty items
-               for (Iterator i = dirtyItems.iterator(); i.hasNext();)
+               for (Iterator<TreeItem> i = dirtyItems.iterator(); i.hasNext();)
                {
                        TreeItem item = (TreeItem)i.next();
                        // item children need to be rebuilt
@@ -1526,7 +1586,7 @@
        /**
         * Removes the item, appends it's id to deleteIds. This is called when 
a items parent is being
         * deleted or rebuilt.
-        *
+        * 
         * @param item
         *            The item to remove
         */
@@ -1550,7 +1610,7 @@
                        deleteIds.append(",");
                }
 
-               if (item.getParent() != null) 
+               if (item.getParent() != null)
                {
                        // remove the id
                        // note that this doesn't update item's parent's 
children list
@@ -1571,7 +1631,7 @@
 
        /**
         * Call the callback#visitItem method for the given item and all it's 
children.
-        *
+        * 
         * @param item
         *            The tree item
         * @param callback
@@ -1585,7 +1645,7 @@
 
        /**
         * Call the callback#visitItem method for every child of given item.
-        *
+        * 
         * @param item
         *            The tree item
         * @param callback
@@ -1595,7 +1655,7 @@
        {
                if (item.getChildren() != null)
                {
-                       for (Iterator i = item.getChildren().iterator(); 
i.hasNext();)
+                       for (Iterator<TreeItem> i = 
item.getChildren().iterator(); i.hasNext();)
                        {
                                TreeItem child = (TreeItem)i.next();
                                visitItemAndChildren(child, callback);
@@ -1606,7 +1666,7 @@
        /**
         * Returns the component associated with given node, or null, if node 
is not visible. This is
         * useful in situations when you want to touch the node element in html.
-        *
+        * 
         * @param node
         *            Tree node
         * @return Component associated with given node, or null if node is not 
visible.

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/BaseTree.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/BaseTree.java?rev=692277&r1=692276&r2=692277&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/BaseTree.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/BaseTree.java
 Thu Sep  4 15:19:58 2008
@@ -16,6 +16,8 @@
  */
 package org.apache.wicket.markup.html.tree;
 
+import javax.swing.tree.TreeModel;
+
 import org.apache.wicket.Component;
 import org.apache.wicket.IClusterable;
 import org.apache.wicket.IComponentBorder;
@@ -62,7 +64,7 @@
         * @param id
         * @param model
         */
-       public BaseTree(String id, IModel model)
+       public BaseTree(String id, IModel<TreeModel> model)
        {
                super(id, model);
 
@@ -96,6 +98,7 @@
         * @see 
org.apache.wicket.markup.html.tree.AbstractTree#populateTreeItem(org.apache.wicket.markup.html.WebMarkupContainer,
         *      int)
         */
+       @SuppressWarnings("unchecked")
        @Override
        protected void populateTreeItem(WebMarkupContainer item, int level)
        {
@@ -106,7 +109,8 @@
                item.add(junctionLink);
 
                // add node component
-               Component nodeComponent = newNodeComponent(NODE_COMPONENT_ID, 
item.getDefaultModel());
+               Component nodeComponent = newNodeComponent(NODE_COMPONENT_ID,
+                       (IModel<Object>)item.getDefaultModel());
                item.add(nodeComponent);
 
                // add behavior that conditionally adds the "selected" CSS 
class name
@@ -166,7 +170,7 @@
         *            model that returns the node
         * @return component for node
         */
-       protected abstract Component newNodeComponent(String id, IModel model);
+       protected abstract Component newNodeComponent(String id, IModel<Object> 
model);
 
        /**
         * Returns whether the provided node is last child of it's parent.
@@ -417,7 +421,7 @@
        {
                if (getLinkType() == LinkType.REGULAR)
                {
-                       return new Link(id)
+                       return new Link<Void>(id)
                        {
                                private static final long serialVersionUID = 1L;
 
@@ -433,7 +437,7 @@
                }
                else if (getLinkType() == LinkType.AJAX)
                {
-                       return new AjaxLink(id)
+                       return new AjaxLink<Void>(id)
                        {
                                private static final long serialVersionUID = 1L;
 
@@ -449,7 +453,7 @@
                }
                else
                {
-                       return new AjaxFallbackLink(id)
+                       return new AjaxFallbackLink<Void>(id)
                        {
                                private static final long serialVersionUID = 1L;
 

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/ITreeState.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/ITreeState.java?rev=692277&r1=692276&r2=692277&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/ITreeState.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/ITreeState.java
 Thu Sep  4 15:19:58 2008
@@ -66,7 +66,7 @@
         * 
         * @return The collection of selected nodes
         */
-       Collection getSelectedNodes();
+       Collection<Object> getSelectedNodes();
 
        /**
         * Returns whether multiple nodes can be selected.

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LabelIconPanel.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LabelIconPanel.java?rev=692277&r1=692276&r2=692277&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LabelIconPanel.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LabelIconPanel.java
 Thu Sep  4 15:19:58 2008
@@ -43,7 +43,7 @@
         *            model that is used to access the TreeNode
         * @param tree
         */
-       public LabelIconPanel(String id, IModel model, BaseTree tree)
+       public LabelIconPanel(String id, IModel<Object> model, BaseTree tree)
        {
                super(id, model);
 
@@ -59,7 +59,7 @@
         * 
         * @param tree
         */
-       protected void addComponents(IModel model, BaseTree tree)
+       protected void addComponents(IModel<Object> model, BaseTree tree)
        {
                add(newImageComponent("icon", tree, model));
                add(newContentComponent("content", tree, model));
@@ -74,7 +74,7 @@
         * @return icon image component
         */
        protected Component newImageComponent(String componentId, final 
BaseTree tree,
-               final IModel model)
+               final IModel<Object> model)
        {
                return new Image(componentId)
                {
@@ -96,7 +96,7 @@
         * @param model
         * @return content component
         */
-       protected Component newContentComponent(String componentId, BaseTree 
tree, IModel model)
+       protected Component newContentComponent(String componentId, BaseTree 
tree, IModel<Object> model)
        {
                return new Label(componentId, model);
        }
@@ -134,7 +134,7 @@
         * @param nodeModel
         * @return wrapped model
         */
-       protected IModel wrapNodeModel(IModel nodeModel)
+       protected IModel<Object> wrapNodeModel(IModel<Object> nodeModel)
        {
                return nodeModel;
        }

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LabelTree.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LabelTree.java?rev=692277&r1=692276&r2=692277&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LabelTree.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LabelTree.java
 Thu Sep  4 15:19:58 2008
@@ -50,7 +50,7 @@
         * @param model
         *            model that provides the [EMAIL PROTECTED] TreeModel}
         */
-       public LabelTree(String id, IModel model)
+       public LabelTree(String id, IModel<TreeModel> model)
        {
                super(id, model);
        }
@@ -62,6 +62,7 @@
         * @param model
         *            Tree model
         */
+       @SuppressWarnings("unchecked")
        public LabelTree(String id, TreeModel model)
        {
                super(id, new Model((Serializable)model));
@@ -71,13 +72,14 @@
         * @see 
org.apache.wicket.markup.html.tree.BaseTree#newNodeComponent(java.lang.String,
         *      org.apache.wicket.model.IModel)
         */
-       protected Component newNodeComponent(String id, IModel model)
+       protected Component newNodeComponent(String id, IModel<Object> model)
        {
                return new LabelIconPanel(id, model, this)
                {
                        private static final long serialVersionUID = 1L;
 
-                       protected Component newContentComponent(String 
componentId, BaseTree tree, IModel model)
+                       protected Component newContentComponent(String 
componentId, BaseTree tree,
+                               IModel<Object> model)
                        {
                                return super.newContentComponent(componentId, 
tree, getNodeTextModel(model));
                        }
@@ -102,7 +104,7 @@
         *            model representing the current tree node
         * @return model used for text
         */
-       protected IModel getNodeTextModel(IModel nodeModel)
+       protected IModel<Object> getNodeTextModel(IModel<Object> nodeModel)
        {
                return nodeModel;
        }

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LinkIconPanel.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LinkIconPanel.java?rev=692277&r1=692276&r2=692277&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LinkIconPanel.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LinkIconPanel.java
 Thu Sep  4 15:19:58 2008
@@ -38,7 +38,7 @@
         *            model that is used to access the TreeNode
         * @param tree
         */
-       public LinkIconPanel(String id, IModel model, BaseTree tree)
+       public LinkIconPanel(String id, IModel<Object> model, BaseTree tree)
        {
                super(id, model, tree);
        }
@@ -48,7 +48,7 @@
         *      org.apache.wicket.markup.html.tree.BaseTree)
         */
        @Override
-       protected void addComponents(final IModel model, final BaseTree tree)
+       protected void addComponents(final IModel<Object> model, final BaseTree 
tree)
        {
                BaseTree.ILinkCallback callback = new BaseTree.ILinkCallback()
                {

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LinkTree.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LinkTree.java?rev=692277&r1=692276&r2=692277&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LinkTree.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/LinkTree.java
 Thu Sep  4 15:19:58 2008
@@ -54,7 +54,7 @@
         * @param model
         *            model that provides the [EMAIL PROTECTED] TreeModel}
         */
-       public LinkTree(String id, IModel model)
+       public LinkTree(String id, IModel<TreeModel> model)
        {
                super(id, model);
        }
@@ -67,6 +67,7 @@
         * @param model
         *            Tree model
         */
+       @SuppressWarnings("unchecked")
        public LinkTree(String id, TreeModel model)
        {
                super(id, new Model((Serializable)model));
@@ -77,7 +78,7 @@
         *      org.apache.wicket.model.IModel)
         */
        @Override
-       protected Component newNodeComponent(String id, IModel model)
+       protected Component newNodeComponent(String id, IModel<Object> model)
        {
                return new LinkIconPanel(id, model, LinkTree.this)
                {
@@ -91,7 +92,8 @@
                        }
 
                        @Override
-                       protected Component newContentComponent(String 
componentId, BaseTree tree, IModel model)
+                       protected Component newContentComponent(String 
componentId, BaseTree tree,
+                               IModel<Object> model)
                        {
                                return new Label(componentId, 
getNodeTextModel(model));
                        }


Reply via email to