Re: Checkbox tree component

2012-03-06 Thread javanrell
Hi all, 
I made some changes based on the CheckBoxIconPanel.java posted by Doug,
basically I added behavior to update all parents or childrens when we check
or uncheck a node:
 * When we check a node, we verify all its brothers, if they are all checked
then we check its parent and recursively.
 * When we check a non leaf node we check all its children recursively.
 * When we uncheck a node we uncheck all its parents until the root.
I hope it will useful for someone.

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the License); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import javax.swing.tree.TreeNode;

import org.apache.wicket.MarkupContainer;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.tree.BaseTree;
import org.apache.wicket.markup.html.tree.LabelIconPanel;
import org.apache.wicket.model.IModel;

/**
 * Simple panel that contains a link with icon and a link with a label.
 * 
 * @author Matej Knopp
 */
public class CheckBoxIconPanel extends LabelIconPanel {
private static final long serialVersionUID = 1L;

/**
 * Constructs the panel.
 * 
 * @param id
 *component id
 * @param model
 *model that is used to access the TreeNode
 * @param tree
 */
public CheckBoxIconPanel(String id, IModel model, CheckBoxTree tree) {
super(id, model, tree);
}

/**
 * @see
org.apache.wicket.markup.html.tree.LabelIconPanel#addComponents(org.apache.wicket.model.IModel,
 *  org.apache.wicket.markup.html.tree.BaseTree)
 */
protected void addComponents(final IModel model, final BaseTree tree) {
final CheckBoxTree cbTree = (CheckBoxTree)tree;
CheckBoxTree.ICheckCallback callback = new 
CheckBoxTree.ICheckCallback() {
private static final long serialVersionUID = 1L;

public void onUpdate(AjaxRequestTarget target) {
onNodeCheckUpdated((TreeNode)model.getObject(), 
cbTree, target);
}
};

add(newImageComponent(icon, tree, model));

IModel dataModel = 
cbTree.newCheckBoxModel((TreeNode)model.getObject());
MarkupContainer cb = null;
add( cb = cbTree.newCheckBox(checkbox, dataModel, callback) );
add(newContentComponent(content, tree, model));
}

/**
 * Handler invoked when the checkbox is clicked. By default makes the 
node
selected
 * 
 * @param node
 * @param tree
 * @param target
 */
protected void onNodeCheckUpdated(TreeNode node, CheckBoxTree tree,
AjaxRequestTarget target) {
if (tree.getTreeState().isNodeSelected(node)) {
deselectAllParent(node, tree);
selectAllChildren(node, tree, false);
} else {
selectAllChildren(node, tree, true);
updateSelectionIfLastSelected(node, tree);
}   
tree.updateTree(target);
}

/**
 * When a node of leaf is selected we search for all its brothers, if 
all
are selected too we select the parent and recursively until the root.
 * 
 * @param node
 * @param tree
 * @param target
 */
protected void updateSelectionIfLastSelected(TreeNode node, CheckBoxTree
tree) {
TreeNode parent = node.getParent(); 
while(parent != null) {
int childCount = parent.getChildCount();
for (int i = 0; i  childCount; i++) {

if(!tree.getTreeState().isNodeSelected(parent.getChildAt(i))) {
return;
}
}
tree.getTreeState().selectNode(parent, true);
parent = parent.getParent();
}
}

/**
 * When a node / leaf is deselected all its parent are deselected too.
 * 
 

Re: Checkbox tree component

2010-01-20 Thread prati

Hi i also am having same kind of problem.
I got checkboxes in tree panel ,how to iterate over the selected nodes on
checkbox click.

Thanks
Partibha

Edi wrote:
 
 I am not able to configure the above example Doug.
 
 Could you give me .war file. please
 
 thanks and regards,
 edi
 
 
 Doug Leeper wrote:
 
 If the tree is pre-loaded, it is easier.  When the checkbox is selected,
 iterate through the children nodes and set its state to selected.
 
 The dynamically loaded is alot trickier...as you would have to load the
 tree from the selected node and then iterate and set the children notes
 to selected.
 
 Are you sure you want to select the children nodes or is it the parent
 nodes you want to select?
 
 
 

-- 
View this message in context: 
http://old.nabble.com/Checkbox-tree-component-tp13433102p27250675.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Checkbox tree component

2009-04-17 Thread CrocodileShoes

Hi guys,

I've been fighting with trees for a week now and nearly have it doing what I
require.  However there is one thing I can't figure out.

-My tree is build using data from an external source.
-When I click a checkbox in the tree my tree model is completely
restructured based upon data from an external source.
-The tree is rebuilt from the root node downwards and the treemodel updated
via a call to it's setRoot() using the new root as the argument.

What I want is for the node that was checked to stay checked, that is,
persist across the tree update.  This obviously happens by default, that is,
without rebuilding the from the root node, but I don't know how to update
the tree without doing that.

Any ideas?



-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tp13433102p23098936.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Checkbox tree component

2009-04-17 Thread Edi

Hello Doug,

I am not able to configure the above example Doug.

Could you give me .war file. please

thanks and regards,
edi 
-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tp13433102p23109331.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Checkbox tree component

2009-04-16 Thread Edi

I am not able to configure the above example Doug.

Could you give me .war file. please

thanks and regards,
edi


Doug Leeper wrote:
 
 If the tree is pre-loaded, it is easier.  When the checkbox is selected,
 iterate through the children nodes and set its state to selected.
 
 The dynamically loaded is alot trickier...as you would have to load the
 tree from the selected node and then iterate and set the children notes to
 selected.
 
 Are you sure you want to select the children nodes or is it the parent
 nodes you want to select?
 

-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tp13433102p23074091.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Checkbox tree component

2008-07-07 Thread vishy_sb

Hey Doug,

I was able to get the check boxes to work. Thanks for your help on that.
However there is another problem that I am not able to get to work.

I have created another panel with a checkbox tree in it and i want that
panel to show only when I check one of the child nodes in my main checkbox
tree. i.e. I have Panel1 and Panel2 for a page both having a checkbox tree
component in them say checkboxtree1 and checkboxtree2 respectively. I want
the Panel2 to show up (along with the tree) only when a node of the
checkboxtree1 is selected. I tried to add the panel dynamically in the
onNodeCheckUpdated() method of the main panel but it doesn't work like that. 

Any ideas about how i can get this to work.

Regards,
vishy_sb


Doug Leeper wrote:
 
 If the tree is pre-loaded, it is easier.  When the checkbox is selected,
 iterate through the children nodes and set its state to selected.
 
 The dynamically loaded is alot trickier...as you would have to load the
 tree from the selected node and then iterate and set the children notes to
 selected.
 
 Are you sure you want to select the children nodes or is it the parent
 nodes you want to select?
 

-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tp13433102p18326913.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox tree component

2008-07-07 Thread Doug Leeper

I am sure there are a couple of ways to do this.

First thing that comes to mind is to override the Panel2.isVisible() method
and return true if there are any nodes selected in CBTree1.

for instance:

Panel checkBoxPanel2 = new Panel( checkBoxPanel2 ) {
public boolean isVisible() {
 return /** cbTree1 Selection State **/;
}
};

To determine the cbTree1 Selection State, either you iterator through the
entire tree to determine if a node is selected via the TreeState or capture
the number of nodes selected/deselected via TreeStateListener.

By overridding isVisible(), no matter if you are refreshing the entire page
or via Ajax, the checkBoxPanel2 visibility would be handled correctly.

Hope that helps.
- Doug
-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tp13433102p18327178.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox tree component

2008-06-28 Thread Doug Leeper

If the tree is pre-loaded, it is easier.  When the checkbox is selected,
iterate through the children nodes and set its state to selected.

The dynamically loaded is alot trickier...as you would have to load the tree
from the selected node and then iterate and set the children notes to
selected.

Are you sure you want to select the children nodes or is it the parent nodes
you want to select?
-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tp13433102p18173927.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox tree component

2008-06-26 Thread vishy_sb

Hey Doug,

I am fairly new to wicket. I am trying to use the checkbox tree component
and it seems to be working well. However I would like to check or uncheck
all the child nodes if the parent node is selected(i.e. if the check box in
front of the parent node is checked or unchecked). Kindly let me know how
can I implement that.

Thanks,
vishy_sb


Doug Leeper wrote:
 
 Ok here it is.  I have also included my use of it.  While it won't compile
 for you...you will at least see how I have used it.
 
  http://www.nabble.com/file/p13439520/CheckBoxIconPanel.html
 CheckBoxIconPanel.html 
  http://www.nabble.com/file/p13439520/CheckBoxIconPanel.java
 CheckBoxIconPanel.java 
  http://www.nabble.com/file/p13439520/CheckBoxTree.java CheckBoxTree.java 
 
 My use of CheckBoxTree...
 
  http://www.nabble.com/file/p13439520/ProductCategoriesPanel.html
 ProductCategoriesPanel.html 
  http://www.nabble.com/file/p13439520/ProductCategoriesPanel.java
 ProductCategoriesPanel.java 
 
 

-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tp13433102p18145468.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox tree component

2008-06-26 Thread Doug Leeper

It depends.

Are you building the entire tree up front or are you building the child
nodes dynamically (i.e. when the parent node is selected/expanded)?
-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tp13433102p18147561.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox tree component

2008-06-26 Thread vishy_sb

Well currently I am testing the tree using a model which creates the entire
tree up front... however for the final implementation I would be building
the child nodes dynamically  hence I guess I would be using both of
them

Thanks for the quick reply


Doug Leeper wrote:
 
 It depends.
 
 Are you building the entire tree up front or are you building the child
 nodes dynamically (i.e. when the parent node is selected/expanded)?
 

-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tp13433102p18147660.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox tree component

2007-12-10 Thread Benjamin Keil


Doug Leeper wrote:
 
 When does this occur?
 - the first time the page is displayed
 - after you do some user interaction?  if so, are you using Ajax in the
 user interaction?
 

This happens on the initial loading of the page, and I tried setting the
CheckType to Ajax and to Regular.  It happens in both cases (except you get
CheckBoxTree$2 instead of $3).

-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tp13433102p14267352.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox tree component

2007-12-07 Thread Mats Norén
Doug, great work!
Can I just ask you a question, what does your implementation of the
CategoryTreeModel look like?
I've been trying all sorts of approaches for doing a similar category
tree but I've never liked / got the model approach to work in a nice
fashion. :)

/Regards Mats

On Oct 27, 2007 6:04 AM, Doug Leeper [EMAIL PROTECTED] wrote:

 Ok here it is.  I have also included my use of it.  While it won't compile
 for you...you will at least see how I have used it.

 http://www.nabble.com/file/p13439520/CheckBoxIconPanel.html
 CheckBoxIconPanel.html
 http://www.nabble.com/file/p13439520/CheckBoxIconPanel.java
 CheckBoxIconPanel.java
 http://www.nabble.com/file/p13439520/CheckBoxTree.java CheckBoxTree.java

 My use of CheckBoxTree...

 http://www.nabble.com/file/p13439520/ProductCategoriesPanel.html
 ProductCategoriesPanel.html
 http://www.nabble.com/file/p13439520/ProductCategoriesPanel.java
 ProductCategoriesPanel.java

 --
 View this message in context: 
 http://www.nabble.com/Checkbox-tree-component-tf4699092.html#a13439520

 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox tree component

2007-12-05 Thread Benjamin Keil

Hello All!

  This CheckBox tree is very cool.  But I'm having some strange interactions
with the web server: when I run under Jetty everything goes smoothly, but
when I deploy to tomcat, I get a bunch of unrendered component exceptions
for the component with id checkbox and whose class is some deeply nested
anonymous inner class.

  Does anyone have any idea what could possibly be the difference between
the two containers?  I believe that I'm running with servlet-api-2.5 in both
Jetty and Tomcat.  My web.xml has version=2.5 in its webapp tag.  I'm
not getting unredered component complaints for anything else anywhere in my
site.  I'm totally baffled.

Any help would be greatly appreciated,
Ciao,
Ben.
-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tf4699092.html#a14184918
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox tree component

2007-12-05 Thread Benjamin Keil

Thanks for the hint, but, yes the wicket jars are the latest ones:

wicket-1.3.0-rc1.jar
wicket-datetime-1.3.0-rc1.jar
wicket-extensions-1.3.0-rc1.jar
wicket-ioc-1.3.0-rc1.jar
wicket-spring-1.3.0-rc1.jar
wicket-spring-annot-1.3.0-rc1.jar

And it's the same set of jars under Jetty.

So, I'm still really baffled.
Thanks :) :) :)
Ben.

-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tf4699092.html#a14185226
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox tree component

2007-12-05 Thread Doug Leeper

Could you post the stacktrace?

-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tf4699092.html#a14186249
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox tree component

2007-11-16 Thread dstruck

Doug, thanks for putting this together.

David


Doug Leeper wrote:
 
 Ok here it is.  I have also included my use of it.  While it won't compile
 for you...you will at least see how I have used it.
 
  http://www.nabble.com/file/p13439520/CheckBoxIconPanel.html
 CheckBoxIconPanel.html 
  http://www.nabble.com/file/p13439520/CheckBoxIconPanel.java
 CheckBoxIconPanel.java 
  http://www.nabble.com/file/p13439520/CheckBoxTree.java CheckBoxTree.java 
 
 My use of CheckBoxTree...
 
  http://www.nabble.com/file/p13439520/ProductCategoriesPanel.html
 ProductCategoriesPanel.html 
  http://www.nabble.com/file/p13439520/ProductCategoriesPanel.java
 ProductCategoriesPanel.java 
 
 

-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tf4699092.html#a13804534
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox tree component

2007-11-16 Thread Doug Leeper

Glad to have helped!
-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tf4699092.html#a13804839
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox tree component

2007-10-26 Thread Doug Leeper

I was just about to tackle this.  If I get something together I will forward
the code.

- Doug
-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tf4699092.html#a13436155
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox tree component

2007-10-26 Thread Doug Leeper

Ok here it is.  I have also included my use of it.  While it won't compile
for you...you will at least see how I have used it.

http://www.nabble.com/file/p13439520/CheckBoxIconPanel.html
CheckBoxIconPanel.html 
http://www.nabble.com/file/p13439520/CheckBoxIconPanel.java
CheckBoxIconPanel.java 
http://www.nabble.com/file/p13439520/CheckBoxTree.java CheckBoxTree.java 

My use of CheckBoxTree...

http://www.nabble.com/file/p13439520/ProductCategoriesPanel.html
ProductCategoriesPanel.html 
http://www.nabble.com/file/p13439520/ProductCategoriesPanel.java
ProductCategoriesPanel.java 

-- 
View this message in context: 
http://www.nabble.com/Checkbox-tree-component-tf4699092.html#a13439520
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]