changeset 1363:a7050a4850da

RT-22900: Cell selected property fires too frequently when selection changes
author jgiles
date Mon, 25 Jun 2012 14:12:25 +1200
parents 00b1f42f76da
children 561c62db83f9
files javafx-ui-controls/src/javafx/scene/control/Cell.java javafx-ui-controls/src/javafx/scene/control/ListCell.java javafx-ui-controls/src/javafx/scene/control/TableCell.java javafx-ui-controls/src/javafx/scene/control/TreeCell.java
diffstat 4 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/javafx/scene/control/Cell.java	Mon Jun 25 14:07:38 2012 +1200
+++ b/javafx-ui-controls/src/javafx/scene/control/Cell.java	Mon Jun 25 14:12:25 2012 +1200
@@ -28,7 +28,6 @@
 import javafx.beans.InvalidationListener;
 import javafx.beans.Observable;
 import javafx.beans.property.BooleanProperty;
-import javafx.beans.property.BooleanPropertyBase;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleBooleanProperty;
 import javafx.beans.property.SimpleObjectProperty;
@@ -383,7 +382,6 @@
     // --- selected
     private ReadOnlyBooleanWrapper selected = new ReadOnlyBooleanWrapper() {
         @Override protected void invalidated() {
-            updateSelected(get()); // TODO what is this here for???
             impl_pseudoClassStateChanged(PSEUDO_CLASS_SELECTED);
         }
 
--- a/javafx-ui-controls/src/javafx/scene/control/ListCell.java	Mon Jun 25 14:07:38 2012 +1200
+++ b/javafx-ui-controls/src/javafx/scene/control/ListCell.java	Mon Jun 25 14:12:25 2012 +1200
@@ -448,9 +448,13 @@
     }
 
     private void updateSelection() {
+        if (isEmpty()) return;
         if (getIndex() == -1 || getListView() == null) return;
         if (getListView().getSelectionModel() == null) return;
         
+        boolean isSelected = getListView().getSelectionModel().isSelected(getIndex());
+        if (isSelected() == isSelected) return;
+        
         updateSelected(getListView().getSelectionModel().isSelected(getIndex()));
     }
 
--- a/javafx-ui-controls/src/javafx/scene/control/TableCell.java	Mon Jun 25 14:07:38 2012 +1200
+++ b/javafx-ui-controls/src/javafx/scene/control/TableCell.java	Mon Jun 25 14:12:25 2012 +1200
@@ -424,11 +424,13 @@
          * TableRow class might pick up the need to set an entire row to be
          * selected.
          */
+        if (isEmpty()) return;
         if (getIndex() == -1 || getTableView() == null) return;
         if (getTableView().getSelectionModel() == null) return;
         
         boolean isSelected = isInCellSelectionMode() &&
                 getTableView().getSelectionModel().isSelected(getIndex(), getTableColumn());
+        if (isSelected() == isSelected) return;
 
         updateSelected(isSelected);
     }
--- a/javafx-ui-controls/src/javafx/scene/control/TreeCell.java	Mon Jun 25 14:07:38 2012 +1200
+++ b/javafx-ui-controls/src/javafx/scene/control/TreeCell.java	Mon Jun 25 14:12:25 2012 +1200
@@ -410,10 +410,14 @@
     }
 
     private void updateSelection() {
+        if (isEmpty()) return;
         if (getIndex() == -1 || getTreeView() == null) return;
         if (getTreeView().getSelectionModel() == null) return;
         
-        updateSelected(getTreeView().getSelectionModel().isSelected(getIndex()));
+        boolean isSelected = getTreeView().getSelectionModel().isSelected(getIndex());
+        if (isSelected() == isSelected) return;
+        
+        updateSelected(isSelected);
     }
 
     private void updateFocus() {