Need help displaying partially checked CheckBoxTree

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Need help displaying partially checked CheckBoxTree

Postby olamattsson » Tue Mar 12, 2013 2:51 am

Hi, I'm trying to display a CheckBoxTree with digin mode enabled but I can't find a way to display some non-leaf nodes partially checked.
Either all nodes are checked or none is checked.
I have tried to use CheckBoxTree.getCheckBoxTreeSelectionModel().addSelectionPath(TreePath path)
and CheckBoxTree.getCheckBoxTreeSelectionModel().setSelectionPaths(TreePath[] paths) to set which nodes should be checked but with digIn enabled all nodes become checked.

I need to be able to display a tree like this:
x
|-x
| |-x
| |-0
| |-x
|
|-x
|-x
| |-x
| |-x
| |-0

Where x means a checked (or partially checked parent) node and 0 means unchecked nodes.
I still need the digIn functionality so the user can check/uncheck complete subtrees with one click.
olamattsson
 
Posts: 3
Joined: Fri Mar 08, 2013 6:59 am

Re: Need help displaying partially checked CheckBoxTree

Postby JIDE Support » Tue Mar 12, 2013 8:48 am

Please try to invoke LookAndFeelFactory#installJideExtension() before you instantiate the CheckBoxTree. The partially check image is installed there. Please give JIDE CheckBoxTreeDemo a try for the details.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 36466
Joined: Sun Sep 14, 2003 10:49 am

Re: Need help displaying partially checked CheckBoxTree

Postby olamattsson » Wed Mar 13, 2013 2:54 am

I'm already calling the LookAndFeelFactory.installJideExtension() before I display the tree. It does not solve the problem.

Before I display the tree I build it by adding nodes. After the tree is built I use the tree.getCheckBoxTreeSelectionModel to try to make some nodes checked and leave others unchecked.
So, if my tree contains nodes like this:
root
|-Node 1
|-Node 2
| |
| |-Node 2.1
| |-Node 2.2
|-Node 3
and I want all Nodes except "Node 2.1" to be checked when I display the tree, how can I do that when I have digIn enabled?
If I add the treepaths for all nodes except "Node 2.1" to the checkboxtreeselectionmodel, it will only contain the root node and show every node as checked. Not what I want!!
If I disable digIn, the correct nodes are checked but then the user must check/uncheck every node one by one. Not what I want either.
olamattsson
 
Posts: 3
Joined: Fri Mar 08, 2013 6:59 am

Re: Need help displaying partially checked CheckBoxTree

Postby JIDE Support » Wed Mar 13, 2013 7:52 am

Please check if you ever added the "node 2" or "root" to the check box tree selection model. If so, in digin mode, that means you want to check "node 2.2" as well. Please only add "node 1", "node 2.1" and "node 3" and check if that works for you. If still not, a test case would help us investigate further.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 36466
Joined: Sun Sep 14, 2003 10:49 am

Re: Need help displaying partially checked CheckBoxTree

Postby olamattsson » Wed Mar 13, 2013 8:46 am

Aha, found the problem. The root was added to the selectionmodel.
I use a for loop to iterate over all rows in the tree:
(pseudo code, skipping casts)
Code: Select all
for (int i = 0; i <tree.getRowCount();i++){
    TreePath path = tree.getPathForRow(i);
    if (path.getLastPathComponent().getUserObject().isEnabled()){
        tree.getCheckBoxSelectionModel().addSelectionPath(path)
    }
}

The root is of course row 0, so now I iterate from index 1 instead.
olamattsson
 
Posts: 3
Joined: Fri Mar 08, 2013 6:59 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 3 guests