changeset 3295:5dc2154688af

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/8.0/scrum/controls/jfx/rt
author jgiles
date Tue, 16 Apr 2013 11:28:53 +1200
parents 8997822f6482 4f184a258645
children 57ebcb03f2ac
files
diffstat 3 files changed, 144 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TableViewBehaviorBase.java	Mon Apr 15 14:49:40 2013 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TableViewBehaviorBase.java	Tue Apr 16 11:28:53 2013 +1200
@@ -720,6 +720,9 @@
             fm.focus(newFocusOwner, focusedCell.getTableColumn());
         } else if (isShiftDown && getAnchor() != null && ! selectionPathDeviated) {
             int newRow = fm.getFocusedIndex() + delta;
+            
+            // we don't let the newRow go outside the bounds of the data
+            newRow = Math.max(Math.min(getItemCount() - 1, newRow), 0);
 
             int start = Math.min(getAnchor().getRow(), newRow);
             int end = Math.max(getAnchor().getRow(), newRow);
--- a/javafx-ui-controls/test/javafx/scene/control/TableViewKeyInputTest.java	Mon Apr 15 14:49:40 2013 -0700
+++ b/javafx-ui-controls/test/javafx/scene/control/TableViewKeyInputTest.java	Tue Apr 16 11:28:53 2013 +1200
@@ -1683,4 +1683,70 @@
         assertEquals(0, tableView.getFocusModel().getFocusedIndex());
         assertEquals("Apple", tableView.getFocusModel().getFocusedItem());
     }
+    
+    @Test public void test_rt27583_cellSelection_1() {
+        sm.setCellSelectionEnabled(true);
+        sm.setSelectionMode(SelectionMode.MULTIPLE);
+        
+        sm.select(0, col0);
+        assertTrue(fm.isFocused(0, col0));
+        
+        // focus should not go out the top of the table
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(1, col0));
+        keyboard.doUpArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(0, col0));
+        keyboard.doUpArrowPress(KeyModifier.SHIFT);
+        assertTrue(debug(), fm.isFocused(0, col0));
+        
+    }
+    
+    @Test public void test_rt27583_cellSelection_2() {
+        sm.setCellSelectionEnabled(true);
+        sm.setSelectionMode(SelectionMode.MULTIPLE);
+        
+        sm.select(9, col0);
+        assertTrue(fm.isFocused(9, col0));
+        
+        // focus should not go out the bottom of the table
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(10, col0));
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(11, col0));
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(debug(), fm.isFocused(11, col0));
+    }
+    
+    @Test public void test_rt27583_rowSelection_1() {
+        sm.setCellSelectionEnabled(false);
+        sm.setSelectionMode(SelectionMode.MULTIPLE);
+        
+        sm.select(0);
+        assertTrue(fm.isFocused(0));
+        
+        // focus should not go out the top of the table
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(1));
+        keyboard.doUpArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(0));
+        keyboard.doUpArrowPress(KeyModifier.SHIFT);
+        assertTrue(debug(), fm.isFocused(0));
+        
+    }
+    
+    @Test public void test_rt27583_rowSelection_2() {
+        sm.setCellSelectionEnabled(false);
+        sm.setSelectionMode(SelectionMode.MULTIPLE);
+        
+        sm.select(9);
+        assertTrue(fm.isFocused(9));
+        
+        // focus should not go out the bottom of the table
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(10));
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(11));
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(debug(), fm.isFocused(11));
+    }
 }
--- a/javafx-ui-controls/test/javafx/scene/control/TreeTableViewKeyInputTest.java	Mon Apr 15 14:49:40 2013 -0700
+++ b/javafx-ui-controls/test/javafx/scene/control/TreeTableViewKeyInputTest.java	Tue Apr 16 11:28:53 2013 +1200
@@ -31,12 +31,17 @@
 import com.sun.javafx.scene.control.infrastructure.KeyModifier;
 import com.sun.javafx.scene.control.infrastructure.StageLoader;
 import com.sun.javafx.scene.control.skin.TreeTableViewSkin;
+import com.sun.javafx.scene.control.test.Person;
 
 import static org.junit.Assert.*;
 
 import java.util.List;
+
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
 import javafx.scene.Group;
 import javafx.scene.Scene;
+import javafx.scene.control.cell.TreeItemPropertyValueFactory;
 import javafx.scene.input.KeyCode;
 
 import javafx.stage.Stage;
@@ -2235,4 +2240,74 @@
         assertEquals(0, tableView.getFocusModel().getFocusedIndex());
         assertEquals(root, tableView.getFocusModel().getFocusedItem());
     }
+    
+    @Test public void test_rt27583_cellSelection_1() {
+        sm.setCellSelectionEnabled(true);
+        sm.setSelectionMode(SelectionMode.MULTIPLE);
+        
+        sm.select(0, col0);
+        assertTrue(fm.isFocused(0, col0));
+        
+        // focus should not go out the top of the table
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(1, col0));
+        keyboard.doUpArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(0, col0));
+        keyboard.doUpArrowPress(KeyModifier.SHIFT);
+        assertTrue(debug(), fm.isFocused(0, col0));
+        
+    }
+    
+    @Test public void test_rt27583_cellSelection_2() {
+        sm.setCellSelectionEnabled(true);
+        sm.setSelectionMode(SelectionMode.MULTIPLE);
+        
+        sm.select(10, col0);
+        assertTrue(fm.isFocused(10, col0));
+        
+        // focus should not go out the bottom of the table
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(11, col0));
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(12, col0));
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(13, col0));
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(debug(), fm.isFocused(13, col0));
+    }
+    
+    @Test public void test_rt27583_rowSelection_1() {
+        sm.setCellSelectionEnabled(false);
+        sm.setSelectionMode(SelectionMode.MULTIPLE);
+        
+        sm.select(0);
+        assertTrue(fm.isFocused(0));
+        
+        // focus should not go out the top of the table
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(1));
+        keyboard.doUpArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(0));
+        keyboard.doUpArrowPress(KeyModifier.SHIFT);
+        assertTrue(debug(), fm.isFocused(0));
+        
+    }
+    
+    @Test public void test_rt27583_rowSelection_2() {
+        sm.setCellSelectionEnabled(false);
+        sm.setSelectionMode(SelectionMode.MULTIPLE);
+        
+        sm.select(10);
+        assertTrue(fm.isFocused(10));
+        
+        // focus should not go out the bottom of the table
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(11));
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(12));
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(fm.isFocused(13));
+        keyboard.doDownArrowPress(KeyModifier.SHIFT);
+        assertTrue(debug(), fm.isFocused(13));
+    }
 }