changeset 109:5ad9a8a11d2b

RT-15529: TableView does not allow selection in empty cells, even in row-selection mode
author Jonathan Giles
date Fri, 02 Dec 2011 08:27:07 +1000
parents 31fb596f444a
children 963d7c07346e
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css javafx-ui-controls/src/javafx/scene/control/Cell.java javafx-ui-controls/src/javafx/scene/control/TableCell.java
diffstat 3 files changed, 23 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Thu Dec 01 12:59:24 2011 +1000
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Fri Dec 02 08:27:07 2011 +1000
@@ -2387,20 +2387,21 @@
     -fx-background-insets: 0 1 0 0, 1 2 1 1, 2 3 2 2;
 }
 
-.table-view:focused .table-cell:filled:focused:selected {
+.table-view:focused .table-row-cell:filled .table-cell:focused:selected {
     -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
     -fx-background-insets: 0 1 0 0, 1 2 1 1, 2 3 2 2;
     -fx-background: -fx-accent;
     -fx-text-fill: -fx-selection-bar-text;
 }
 
-.table-view:focused .table-cell:filled:selected, .table-view:cell-selection .table-cell:filled:hover:selected {
+.table-view:focused .table-row-cell:filled .table-cell:selected, .table-view:cell-selection .table-row-cell:filled .table-cell:hover:selected {
     -fx-background: -fx-accent;
     -fx-background-color: -fx-selection-bar;
     -fx-text-fill: -fx-selection-bar-text;
-}
-
-.table-view:focused .table-cell:filled:focused:selected:hover {
+    -fx-background-insets: 0 0 1 0;
+}
+
+.table-view:focused .table-row-cell:filled .table-cell:focused:selected:hover {
     -fx-background: -fx-accent;
     -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
     -fx-background-insets: 0 1 0 0, 1 2 1 1, 2 3 2 2;
@@ -2408,7 +2409,7 @@
 }
 
 /* When the TableView is _not_ focused, we show alternate selection colors */
-.table-cell:filled:selected:focused, .table-cell:filled:selected {
+ .table-row-cell:filled .table-cell:selected:focused,  .table-row-cell:filled .table-cell:selected {
     -fx-background-color: lightgray;
     -fx-text-fill: -fx-selection-bar-text;
 }
@@ -2422,12 +2423,13 @@
     -fx-background-insets: 0, 1.4;
 }*/
 
-.table-view:cell-selection .table-cell:filled:hover {
+.table-view:cell-selection  .table-row-cell:filled .table-cell:hover {
     -fx-background-color: -fx-cell-hover-color;
     -fx-text-fill: -fx-text-inner-color;
-}
-
-.table-view:cell-selection .table-cell:filled:focused:hover {
+    -fx-background-insets: 0 0 1 0;
+}
+
+.table-view:cell-selection .table-row-cell:filled .table-cell:focused:hover {
     -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-cell-hover-color;
     -fx-background-insets: 0 1 0 0, 1 2 1 1, 2 3 2 2;
     -fx-text-fill: -fx-text-inner-color;
--- a/javafx-ui-controls/src/javafx/scene/control/Cell.java	Thu Dec 01 12:59:24 2011 +1000
+++ b/javafx-ui-controls/src/javafx/scene/control/Cell.java	Fri Dec 02 08:27:07 2011 +1000
@@ -398,7 +398,7 @@
      */
     public final ReadOnlyBooleanProperty selectedProperty() { return selected.getReadOnlyProperty(); }
 
-    private void setSelected(boolean value) { selected.set(value); }
+    void setSelected(boolean value) { selected.set(value); }
     
     /**
      * Returns whether this cell is currently selected or not.
--- a/javafx-ui-controls/src/javafx/scene/control/TableCell.java	Thu Dec 01 12:59:24 2011 +1000
+++ b/javafx-ui-controls/src/javafx/scene/control/TableCell.java	Fri Dec 02 08:27:07 2011 +1000
@@ -369,7 +369,16 @@
      * Overriding methods                                                      *
      *                                                                         *
      **************************************************************************/
-    
+
+    /** {@inheritDoc} */
+    @Override public void updateSelected(boolean selected) {
+        // copied from Cell, with the first conditional clause below commented 
+        // out, as it is valid for an empty TableCell to be selected, as long 
+        // as the parent TableRow is not empty (see RT-15529).
+        /*if (selected && isEmpty()) return;*/
+        if (getTableRow() == null || getTableRow().isEmpty()) return;
+        setSelected(selected);
+    }
 
 
     /* *************************************************************************