changeset 136:3ec084f7363e

RT-14451: TableView: Shift-Home and Shift-End do not work as expected
author jgiles
date Fri, 09 Dec 2011 15:45:10 +1000
parents 2053e699ee06
children 0d10aa415470
files javafx-ui-controls/src/javafx/scene/control/TableView.java javafx-ui-controls/test/javafx/scene/control/ListViewTest.java javafx-ui-controls/test/javafx/scene/control/TableViewTest.java javafx-ui-controls/test/javafx/scene/control/TreeViewTest.java
diffstat 4 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/javafx/scene/control/TableView.java	Fri Dec 09 15:16:46 2011 +1000
+++ b/javafx-ui-controls/src/javafx/scene/control/TableView.java	Fri Dec 09 15:45:10 2011 +1000
@@ -2014,7 +2014,7 @@
                 int lastIndex = -1;
                 List<TablePosition> positions = new ArrayList<TablePosition>();
 
-                if (row > 0 && row < rowCount) {
+                if (row >= 0 && row < rowCount) {
                     positions.add(new TablePosition(getTableView(), row, null));
                     lastIndex = row;
                 }
--- a/javafx-ui-controls/test/javafx/scene/control/ListViewTest.java	Fri Dec 09 15:16:46 2011 +1000
+++ b/javafx-ui-controls/test/javafx/scene/control/ListViewTest.java	Fri Dec 09 15:45:10 2011 +1000
@@ -318,4 +318,11 @@
         listView.edit(1);
         assertEquals(1, listView.getEditingIndex());
     }
+    
+    @Test public void test_rt14451() {
+        listView.getItems().addAll("Apple", "Orange", "Banana");
+        listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
+        listView.getSelectionModel().selectRange(0, 2); // select from 0 (inclusive) to 2 (exclusive)
+        assertEquals(2, listView.getSelectionModel().getSelectedIndices().size());
+    }
 }
--- a/javafx-ui-controls/test/javafx/scene/control/TableViewTest.java	Fri Dec 09 15:16:46 2011 +1000
+++ b/javafx-ui-controls/test/javafx/scene/control/TableViewTest.java	Fri Dec 09 15:45:10 2011 +1000
@@ -405,4 +405,11 @@
         table.edit(1, first);
         assertEquals(new TablePosition(table, 1, first), table.getEditingCell());
     }
+    
+    @Test public void test_rt14451() {
+        table.getItems().addAll("Apple", "Orange", "Banana");
+        table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
+        table.getSelectionModel().selectRange(0, 2); // select from 0 (inclusive) to 2 (exclusive)
+        assertEquals(2, table.getSelectionModel().getSelectedIndices().size());
+    }
 }
--- a/javafx-ui-controls/test/javafx/scene/control/TreeViewTest.java	Fri Dec 09 15:16:46 2011 +1000
+++ b/javafx-ui-controls/test/javafx/scene/control/TreeViewTest.java	Fri Dec 09 15:45:10 2011 +1000
@@ -401,4 +401,11 @@
         treeView.edit(root);
         assertEquals(root, treeView.getEditingItem());
     }
+    
+    @Test public void test_rt14451() {
+        installChildren();
+        treeView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
+        treeView.getSelectionModel().selectRange(0, 2); // select from 0 (inclusive) to 2 (exclusive)
+        assertEquals(2, treeView.getSelectionModel().getSelectedIndices().size());
+    }
 }