This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
|Summary:||When selecting multiple checkable Outline nodes, pressing space should check/uncheck all of them|
|Component:||Outline&TreeTable||Assignee:||Martin Entlicher <mentlicher>|
|OS:||Mac OS X|
|Issue Type:||DEFECT||Exception Reporter:|
|Attachments:||The workaround I'm currently using to emulate the desired behavior|
Description ebakke 2014-04-18 15:52:29 UTC
When OutlineView is used to display checkable nodes , the check state can be changed with the keyboard by selecting a row and pressing space. However, if multiple rows are selected and space is pressed, only the first row is checked/unchecked. I think the correct behavior on spacebar is to uncheck every selected row if any of the selected rows are already selected, or select every row if none of the selected rows are already selected. (Note that this is _not_ the same as simply inverting the state of every selected node--instead, they should all be switched on or off together.)  http://bits.netbeans.org/dev/javadoc/org-openide-explorer/org/openide/explorer/view/CheckableNode.html
Comment 1 Martin Entlicher 2014-07-30 11:56:20 UTC
Fixed by changeset: 276909:5f0571d4a9c1 http://hg.netbeans.org/core-main/rev/5f0571d4a9c1
Comment 2 ebakke 2014-07-30 15:22:11 UTC
Created attachment 148421 [details] The workaround I'm currently using to emulate the desired behavior
Comment 3 ebakke 2014-07-30 15:22:43 UTC
I had a little hard time understanding the patch, though I'm not familiar with the ETable internals. According to the Javadoc for JTable.editCellAt, it returns "false if for any reason the cell cannot be edited, or if the indices are invalid". If the doc is accurate, that means something is done with the other selected rows only if the first row was not editable? On the other hand, if editCellAt actually returns the state of the checkbox, then the patch would allow other selected rows to be changed only if the selected checkbox is in one particular state. I would expect a correct implementation to have two for loops: a first one to loop over the selected nodes to find out whether all the nodes should be turned either on or off, and then a second loop to actually turn all nodes on or off in tandem. I've attached the code I'm currently using to emulate this logic from outside the OutlineView itself. (Sorry to bug you--but thanks for the bugfixes!)
Comment 4 Martin Entlicher 2014-07-30 16:29:08 UTC
It's true, that this implementation toggles individual check boxes regardless of the state of others. Therefore it does not "synchronize" the state. JTable by default toggles just one checkbox, like the original behavior of Outline. I did not find an app to see how others solve it, but I've found this description: "In Leopard, you can toggle the state of an item on the Sync tab of the .Mac System Preferences pane with a tap on the Space Bar. I drag-selected a few entries (Bookmarks, Calendars, Contacts), and pressing the Space Bar would toggle all of them. Also, Option-clicking turned all of them on, and Shift-Option-clicking turned them all off." at http://hints.macworld.com/article.php?story=20071026142431774 I do not have an access to a Mac offhand, but it looks like they toggle the buttons independently on a space key. To this fix: yes, if the first cell is editable, others are ignored, because the space is written to the cell editor of the first cell. If the cell is not editable, editCellAt() returns false regardless of the state of the checkbox. Therefore, all checkboxes get toggled. To synchronize the state of checkboxes, IMHO explicit actions like Select All/Unselect All are a more obvious solution.
Comment 5 Quality Engineering 2014-07-31 08:58:53 UTC
Integrated into 'main-silver', will be available in build *201407310738* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/5f0571d4a9c1 User: email@example.com Log: #243922: Handle actions on all selected nodes.
Comment 6 ebakke 2014-07-31 12:53:50 UTC
Interesting--I could not, either, find a single live example of a multi-selectable checkbox list on either Windows or MacOS. So I may have remembered wrong. Separate "select all"/"unselect all" boxes are nice to have in UIs, but they don't generalize well to trees of checkboxes, which the Outline is capable of showing. (my own app is showing such a tree, and the data model requires child nodes to be checkable independently of their parent nodes). I have found space-to-check-all/none to be more useful during multiple selection than space-to-toggle-individual-nodes. But it's easy enough to workaround with a KeyListener. Nevertheless, thanks for yet another Outline improvement! I use this component a lot in my platform app.