|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Re: TableComparatorChooser & SelectionI've created an issue for this here:
https://glazedlists.dev.java.net/issues/show_bug.cgi?id=464 I also added a test case that demonstrates this issue: EventTableModelTest.guiTestChangeSelectionByKeysInSortedState_FixMe() Holger > > Hi, > > I'm using the TableComparatorChooser to sort my rows and stumbled upon an > annoying issue. The selection stays when sorting, but when using the arrow > keys to navigate to the next/previous row, the first row of the table is > selected instead of the next/previous row of the current selection. I've > noticed that when sorting the rows, the anchor/lead selection index is set > to -1 which causes this incorrect behaviour. It seems that the selection > model's state is incorrect. Having a selection without anchor or lead > indexes looks wrong in my humble understanding of the swing table model. > > Is there any proper work around? Is this a real bug? > > ps: I did use the model & selectionmodel on the correct lists and did a > search through the list for an answer but came up with nothing... > > Kind Regards, > Jan > -- > View this message in context: http://www.nabble.com/TableComparatorChooser---Selection-tp21663753p21663753.html > Sent from the GlazedLists - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > ____________________________________________________________________ Psssst! Schon vom neuen WEB.DE MultiMessenger gehört? Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: TableComparatorChooser & Selection
Holger Brands wrote:
Hello,I've created an issue for this here: https://glazedlists.dev.java.net/issues/show_bug.cgi?id=464 I also added a test case that demonstrates this issue: EventTableModelTest.guiTestChangeSelectionByKeysInSortedState_FixMe() HolgerHi, I'm using the TableComparatorChooser to sort my rows and stumbled upon an annoying issue. The selection stays when sorting, but when using the arrow keys to navigate to the next/previous row, the first row of the table is selected instead of the next/previous row of the current selection. I've noticed that when sorting the rows, the anchor/lead selection index is set to -1 which causes this incorrect behaviour. It seems that the selection model's state is incorrect. Having a selection without anchor or lead indexes looks wrong in my humble understanding of the swing table model. Is there any proper work around? Is this a real bug? ps: I did use the model & selectionmodel on the correct lists and did a search through the list for an answer but came up with nothing... Kind Regards, Jan -- View this message in context: http://www.nabble.com/TableComparatorChooser---Selection-tp21663753p21663753.html Sent from the GlazedLists - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@...____________________________________________________________________ Psssst! Schon vom neuen WEB.DE MultiMessenger gehört? Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... I've recently had the need to get this particular selection issue working better so that rows selected via the keyboard do not reset when the sorted list reorders itself. I've attached a patch which fixes the problem within the context of my own use cases. It appears to me that the lead and anchor indices should be looked up from the source reorder map rather than reset to a value of -1 in the ListSelection class. However, if this is not a good general solution, I would welcome any feedback as to the correct one which properly honors JTable's expected list selection behavior and I will try to improve it further. Thanks, Brian M. ### Eclipse Workspace Patch 1.0 #P glazed-cvs Index: source/ca/odell/glazedlists/ListSelection.java =================================================================== RCS file: /cvs/glazedlists/source/ca/odell/glazedlists/ListSelection.java,v retrieving revision 1.25 diff -u -r1.25 ListSelection.java --- source/ca/odell/glazedlists/ListSelection.java 15 Mar 2009 12:36:58 -0000 1.25 +++ source/ca/odell/glazedlists/ListSelection.java 18 Jun 2009 00:22:07 -0000 @@ -11,7 +11,6 @@ import ca.odell.glazedlists.matchers.Matcher; import java.util.*; - /** * A class to provide index-based selection features. This class maintains two * lists derived from a single {@link EventList}: @@ -162,12 +161,16 @@ int currentIndex = barcode.getColourIndex(c, DESELECTED); deselectReorderMap[currentIndex] = previousIndex; } + + final int oldIndex = sourceReorderMap[c]; + if (oldIndex == anchorSelectionIndex){ + anchorSelectionIndex = c; + } + if (oldIndex == leadSelectionIndex){ + leadSelectionIndex = c; + } } - // adjust other internal state - anchorSelectionIndex = -1; - leadSelectionIndex = -1; - // fire the reorder on the selected list addSelectedReorder(selectReorderMap); commitSelected(); @@ -179,7 +182,6 @@ // all reordering events are assumed to have changed the selection selectionChanged = true; - // handle non-reordering events } else { // prepare a sequence of changes Index: test/ca/odell/glazedlists/swing/DefaultEventTableModelTest.java =================================================================== RCS file: /cvs/glazedlists/test/ca/odell/glazedlists/swing/DefaultEventTableModelTest.java,v retrieving revision 1.6 diff -u -r1.6 DefaultEventTableModelTest.java --- test/ca/odell/glazedlists/swing/DefaultEventTableModelTest.java 25 Apr 2009 16:06:36 -0000 1.6 +++ test/ca/odell/glazedlists/swing/DefaultEventTableModelTest.java 18 Jun 2009 00:22:07 -0000 @@ -390,6 +390,8 @@ selectionModel.setSelectionInterval(1, 1); assertEquals(Arrays.asList(labels.get(1)), selectionModel.getSelected()); assertEquals(labels, sortedLabels); + assertEquals(1, selectionModel.getLeadSelectionIndex()); + assertEquals(1, selectionModel.getAnchorSelectionIndex()); TableComparatorChooser.install(table, sortedLabels, TableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD); // sort the table by the first column clickColumnHeader(table, 0); @@ -399,8 +401,9 @@ // check current indexes of selection model assertEquals(2, selectionModel.getMinSelectionIndex()); assertEquals(2, selectionModel.getMaxSelectionIndex()); - // this could be the problem for the following failure: the lead selection index is -1 - assertEquals(-1, selectionModel.getLeadSelectionIndex()); + // lead and anchor selection should track to the new index + assertEquals(2, selectionModel.getLeadSelectionIndex()); + assertEquals(2, selectionModel.getAnchorSelectionIndex()); // call the action that is triggered on an UP-arrow-key press final Action action = table.getActionMap().get("selectPreviousRow"); assertNotNull("Action 'selectPreviousRow' not found", action); @@ -409,6 +412,8 @@ assertEquals(1, selectionModel.getMinSelectionIndex()); assertEquals(1, selectionModel.getMaxSelectionIndex()); assertEquals(Arrays.asList(labels.get(0)), selectionModel.getSelected()); + assertEquals(1, selectionModel.getLeadSelectionIndex()); + assertEquals(1, selectionModel.getAnchorSelectionIndex()); } /** --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free embeddable forum powered by Nabble | Forum Help |