Issue with Selection listeners in 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.

Issue with Selection listeners in CheckBoxTree

Postby mandar.j » Sun Aug 05, 2012 10:05 am

Hi,

I am using a CheckBoxTree with selection listeners. I want to enable a button when I select a checkbox from tree ( with multiple selections) and after selection if I deselect all of selected checkboxes, then the button should be disabled back. I tried to implement this but just couldn't succeed.

Also, when I get all the selectedPaths, I could see that it also contains a path which I had selected earlier but deselected later. Is there any way to avoid that kind of deselected (once selected but later deselected) path not to appear in the list of selected paths?

Could you please help me to resolve these above two issues?

I am trying with below code:

Code: Select all
                tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
         //Do Nothing
        }
      });   
      
      tree.getCheckBoxTreeSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
         public void valueChanged(TreeSelectionEvent e) {
            if (!tree.isSelectionEmpty()) {
               button1.setEnabled(true);
               button2.setEnabled(true);
            }
                        
         }
      });


Thanks,
Mandar
mandar.j
 
Posts: 8
Joined: Fri Jul 27, 2012 12:57 am

Re: Issue with Selection listeners in CheckBoxTree

Postby mandar.j » Sun Aug 05, 2012 11:43 am

Hi,

I could fix this issue with following piece of code:

Code: Select all
public void valueChanged(TreeSelectionEvent e) {
 TreePath[] paths = e.getPaths();

 for (int i = 0; i < paths.length; i++) {
   TreePath path = e.getPath();
   if (e.isAddedPath(i)) {
           button1.enable(true);
        }
        else {
           button1.enable(false);
       }
 }
}


Thanks,
Mandar
mandar.j
 
Posts: 8
Joined: Fri Jul 27, 2012 12:57 am

Re: Issue with Selection listeners in CheckBoxTree

Postby JIDE Support » Mon Aug 06, 2012 10:29 am

Glad to know that you have figured a way out. Please feel free to let us know if you have any further question.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 36500
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 5 guests

cron