CheckBoxTree and TreeSelectionListener

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.

CheckBoxTree and TreeSelectionListener

Postby robross0606 » Fri Nov 04, 2011 7:17 am

I've read as much as I can find on this topic, and there seems to be a lot of it. I'm using the latest 3.2.4 version of JIDE common. My current setup has digin enabled and single event mode disabled. I need to be able to determine which checkboxes have been checked and ALSO which have been unchecked. In other words, I need to tell which checkboxes have changed state.

At startup, the nodes are read in via a custom TreeModel and initial checkbox selections are made during the #treeNodesInserted() callback of the TreeModelListener. I set the intial states using #addSelectionPath(). The nodes appear fine in the tree and are checked as expected. It looks something like this:
Code: Select all
x -- Group
   x -- node
   x -- node
   x -- node
   x -- node
   x -- node


However, the first time I check/uncheck any single "node" in the GUI:

Code: Select all
x -- Group
   x -- node
   x -- node
   O -- node
   x -- node
   x -- node


I get two TreeSelectionEvents:
  • In the first one, "e" shows the "Group" node as areNew=[false] which is correct.
  • A second TreeSelectionEvent has "e" with ALL the node elements showing areNew=[true,true,true,true,true]. These nodes are NOT new so this is making it very difficult to determine which nodes have been checked and which ones have been unchecked.
robross0606
 
Posts: 23
Joined: Wed Nov 02, 2011 5:14 pm

Re: CheckBoxTree and TreeSelectionListener

Postby robross0606 » Fri Nov 04, 2011 7:24 am

I think what's happening is that, because "digin" mode reflects ALL "node" elements being checked by a single event on "Group", the subsequent uncheck of a single "node" element triggers follow-up events showing all the "node" elements asNew. I have yet with a combination of code that can elegantly react to this behavior.
robross0606
 
Posts: 23
Joined: Wed Nov 02, 2011 5:14 pm

Re: CheckBoxTree and TreeSelectionListener

Postby JIDE Support » Fri Nov 04, 2011 8:38 am

You could also invoke CheckBoxTreeSelectionModel#setSingleEventMode(true) to fire only one event in that case. Please give JIDE CheckBoxTreeDemo a try for your reference.

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

Re: CheckBoxTree and TreeSelectionListener

Postby robross0606 » Fri Nov 04, 2011 8:46 am

I have given all the demos a try. The problem is NONE of these models appears to tell you when an item has ben UNSELECTED. They only tell you when an item has been SELECTED. SingleEventMode does not resolve the problem.
robross0606
 
Posts: 23
Joined: Wed Nov 02, 2011 5:14 pm

Re: CheckBoxTree and TreeSelectionListener

Postby robross0606 » Fri Nov 04, 2011 8:49 am

To clarify, what appears to happen when an item is UNselected is that it disappears from the event's path list. Instead, it is supposed to stay in the path list so you can call TreeSelectionEvent#isAddedPath(path) on that item to see if it is has been selected or not. The problem appears to be that the unselected node simply disappears from the list completely.
robross0606
 
Posts: 23
Joined: Wed Nov 02, 2011 5:14 pm

Re: CheckBoxTree and TreeSelectionListener

Postby JIDE Support » Fri Nov 04, 2011 8:57 am

Your observation is a little bit different with mine. To make sure we are on the same page, a screencast to show my test is uploaded at http://screencast.com/t/M7IRSvUMykZZ FYI. Please let us know if that's not what you want.

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

Re: CheckBoxTree and TreeSelectionListener

Postby robross0606 » Sat Nov 05, 2011 3:10 pm

I was able to figured out the right combination of SingleEventMode and DigIn, along with some code to figure out what has changed. Thanks!
robross0606
 
Posts: 23
Joined: Wed Nov 02, 2011 5:14 pm


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

Who is online

Users browsing this forum: No registered users and 10 guests

cron