Understanding digin mode

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.

Understanding digin mode

Postby sbrattla » Mon Jul 13, 2009 4:56 am

Hi,

I've got a Tree on which i have enabled digin mode. Whenever i select a parent node (with n children), all those childrens (and sub-childrens) are selected/deselected. Fine.

However, say i've got the following structure

ROOT
- PARENT A
- PARENT B
-- Child 1
-- Child 2
--- Child 2.1
--- Child 2.2
- PARENT C

If i deselect Child 2.2, then all nodes in the whole hierarchy is deselected except from Child 2, Parent B and ROOT. I don't understand the reasoning behind this,
as a user most likely is interested in deselecting Child 2.2 (and its children) - not everything above that level and all their siblings.

Am i doing something wrong?

Love to hear some responses on this!
sbrattla
 
Posts: 20
Joined: Wed Apr 01, 2009 2:38 am

Re: Understanding digin mode

Postby JIDE Support » Mon Jul 13, 2009 7:57 am

In digin mode, when you deselect a child, that means its parent is not fully selected since one of its child is deselected. That's why the parent is deselected.

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

Re: Understanding digin mode

Postby sbrattla » Thu Jul 16, 2009 2:39 am

Well, i'm absolutely certain that setDigin() works as intended, but i believe there is an usability issue with the way it was designed. Take the
following tree structure:

ROOT
- Cars
-- Volvo
-- Nissan
--- Primera
--- Maxima
--- Micra
-- Peugot
- Planes
-- Airbus
-- Boeing
--- 747


How things work now:
Let's say that all nodes are selected by default. The way things work now is that when i deselect Micra, all nodes in the tree except from Nissan, Cars and ROOT are deselected. Now, why should 747 under Beoing be deselected as a consequence of deselecting Micra?

How i believe things should work:
What i would expect was that Micra (and all its possible children) would be deselected, and Nissan, Cars and ROOT would be marked as partially selected. This is how all similar checkbox trees from for instance Microsoft Installers work.

Conlusion
Even though the setDigIn() may work as intended (no bugs), i believe it has a flaw from a usability perspective. Deselecting a node should not have consequences for the parent's siblings. Deselecting a node in the hierarchy should deselect all children below that node, and set all nodes on the path to root as partially selected. However, siblings to any node between the selected/deselected node and root should not be affected.

Anyone else have thoughts on this?
sbrattla
 
Posts: 20
Joined: Wed Apr 01, 2009 2:38 am

Re: Understanding digin mode

Postby JIDE Support » Thu Jul 16, 2009 6:25 am

Well. It is an intentional design in CheckBoxTreeSelectionModel. You probably need invoke CheckBoxTreeSelectionModel#isPathSelected(TreePath, boolean) to check if the path is selected if you are listening to the selection events. Hopefully this method can solve the usability issue you mentioned.

The reason we have this design is to improve the performance. If you still don't like this design, please let us know or feel free to replace the selection model with your own.

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

Re: Understanding digin mode

Postby Walter Laan » Fri Jul 17, 2009 12:32 am

Running with Jide 2.6.7, so not sure if the common version has been changed, but it works for me how to describe it should work.
Code: Select all
public class TestCheckBoxTree {
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                CheckBoxTree tree = new CheckBoxTree();
                tree.setDigIn(true);
                tree.getCheckBoxTreeSelectionModel().addSelectionPath(new TreePath(tree.getModel().getRoot()));
                JFrame frame = new JFrame("Test");
                frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                frame.getContentPane().add(new JScrollPane(tree));
                frame.pack();
                frame.setLocationRelativeTo(null);
                frame.setVisible(true);
            }
        });
    }
}

If I expand all, uncheck 'red', only the 'JTree' and 'colors' nodes get partial selected. All other nodes remain selected.
Walter Laan
 
Posts: 383
Joined: Mon May 01, 2006 12:13 am

Re: Understanding digin mode

Postby sbrattla » Mon Aug 03, 2009 8:17 am

Alright,

I created a brand new JFrame, and created a new CheckBoxTree on that frame. It turns out that the CheckBoxTree works as i have
described that it should be. So; in other words - there's nothing wrong with the way the CheckBoxTree handles things.

But, the strange thing here is that somehow in my application, the CheckBoxTree works differently. I do have a custom tree model,
but it implements the TreeModel. Also, all nodes are DefaultMutableTreeNode. Have i missed something basic & essential here?

I'm really puzzled about what it can be. If anyone should feel tempted to have a look, i've posted my custom treemodel below.
sbrattla
 
Posts: 20
Joined: Wed Apr 01, 2009 2:38 am

Re: Understanding digin mode

Postby JIDE Support » Mon Aug 03, 2009 8:55 am

Would you please describe a little bit the unexpected behavior? And, I cannot find the treemodel you mentioned in your post.

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

Re: Understanding digin mode

Postby sbrattla » Fri Aug 07, 2009 12:27 am

Well,

It's really weird. I have my own tree model, call it CustomTreeModel, which implements javax.swing.tree.TreeModel. All objects returned from my CustomTreeModel is of type DefaultMutableTreeNode.
The easiest way to describe the behaviour is to say that it is like an inverted digIn mode. Whenever i select a node in digIn mode, it deselects all other nodes except from to the node i selected
and its path to the root.

Whenever i set up a test tree, using a DefaultTreeModel, everyting works fine. That's way i can stop suspecting that CheckBoxTree doesn't really like "custom" tree models?

I'm using the most recent version of JIDE Common.
sbrattla
 
Posts: 20
Joined: Wed Apr 01, 2009 2:38 am

Re: Understanding digin mode

Postby JIDE Support » Fri Aug 07, 2009 6:51 am

Is it possible for you to send us a test case? It's hard to guess without a test case.

In general, as you may have already seen, our CheckBoxTreeSelectionModel basically only invoke getRoot(), getChildrenCount(), getChild() from the CustomTreeModel. So if you don't like to provide a test case, you can also check those methods and debug into CheckBoxTreeSelectionModel then see what happens inside. The good thing is that you can get the source code of CheckBoxTree from our open source project https://jide-oss.dev.java.net/.

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


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

Who is online

Users browsing this forum: No registered users and 79 guests