changeset 4227:3d9f1fb7ad9c

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/8.0/scrum/controls/jfx/rt
author jgiles
date Wed, 10 Jul 2013 15:00:51 +1200
parents 35f439b88db8 d0280a126217
children 734434df77c4
files
diffstat 9 files changed, 154 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TableViewBehavior.java	Tue Jul 09 16:39:36 2013 -0700
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TableViewBehavior.java	Wed Jul 10 15:00:51 2013 +1200
@@ -117,7 +117,7 @@
     }
 
     /** {@inheritDoc}  */
-    @Override protected TableSelectionModel<T, TableColumn<T, ?>> getSelectionModel() {
+    @Override protected TableSelectionModel<T> getSelectionModel() {
         return getControl().getSelectionModel();
     }
 
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TableViewBehaviorBase.java	Tue Jul 09 16:39:36 2013 -0700
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TableViewBehaviorBase.java	Wed Jul 10 15:00:51 2013 +1200
@@ -320,7 +320,7 @@
      * Returns the selection model for the underlying UI control (which must extend
      * from TableSelectionModel).
      */
-    protected abstract TableSelectionModel<T,TC> getSelectionModel();
+    protected abstract TableSelectionModel<T> getSelectionModel();
     
     /**
      * Returns an observable list of all cells that are currently selected in
@@ -450,7 +450,7 @@
      *************************************************************************/ 
     
     protected void scrollUp() {
-        TableSelectionModel<T,TC> sm = getSelectionModel();
+        TableSelectionModel<T> sm = getSelectionModel();
         if (sm == null || getSelectedCells().isEmpty()) return;
         
         TablePositionBase<TC> selectedCell = getSelectedCells().get(0);
@@ -465,7 +465,7 @@
     }
 
     protected void scrollDown() {
-        TableSelectionModel<T,TC> sm = getSelectionModel();
+        TableSelectionModel<T> sm = getSelectionModel();
         if (sm == null || getSelectedCells().isEmpty()) return;
         
         TablePositionBase<TC> selectedCell = getSelectedCells().get(0);
@@ -587,7 +587,7 @@
     }
     
     protected void clearSelectionOutsideRange(int start, int end) {
-        TableSelectionModel<T,?> sm = getSelectionModel();
+        TableSelectionModel<T> sm = getSelectionModel();
         if (sm == null) return;
         
         int min = Math.min(start, end);
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TreeTableViewBehavior.java	Tue Jul 09 16:39:36 2013 -0700
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TreeTableViewBehavior.java	Wed Jul 10 15:00:51 2013 +1200
@@ -131,7 +131,7 @@
     }
 
     /** {@inheritDoc}  */
-    @Override protected TableSelectionModel<TreeItem<T>, TreeTableColumn<T, ?>> getSelectionModel() {
+    @Override protected TableSelectionModel<TreeItem<T>> getSelectionModel() {
         return getControl().getSelectionModel();
     }
 
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TreeTableRowSkin.java	Tue Jul 09 16:39:36 2013 -0700
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TreeTableRowSkin.java	Wed Jul 10 15:00:51 2013 +1200
@@ -66,6 +66,7 @@
     private SimpleObjectProperty<ObservableList<TreeItem<T>>> itemsProperty;
     private TreeItem<?> treeItem;
     private boolean disclosureNodeDirty = true;
+    private Node graphic;
 
     private TreeTableViewSkin treeTableViewSkin;
     
@@ -187,9 +188,17 @@
         
         // check for graphic missing
         ObjectProperty<Node> graphicProperty = graphicProperty();
-        Node graphic = graphicProperty == null ? null : graphicProperty.get();
-        if (graphic != null && ! getChildren().contains(graphic)) {
-            getChildren().add(graphic);
+        Node newGraphic = graphicProperty == null ? null : graphicProperty.get();
+        if (newGraphic != null) {
+            // RT-30466: remove the old graphic
+            if (newGraphic != graphic) {
+                getChildren().remove(graphic);
+            }
+
+            if (! getChildren().contains(newGraphic)) {
+                getChildren().add(newGraphic);
+                graphic = newGraphic;
+            }
         }
         
         // check disclosure node
--- a/modules/controls/src/main/java/javafx/scene/control/TableSelectionModel.java	Tue Jul 09 16:39:36 2013 -0700
+++ b/modules/controls/src/main/java/javafx/scene/control/TableSelectionModel.java	Wed Jul 10 15:00:51 2013 +1200
@@ -33,35 +33,33 @@
  * table-like controls (most notably {@link TableView} and {@link TreeTableView}.
  * 
  * @param <T> The type of the underlying data model for the UI control.
- * @param <TC> The concrete subclass of {@link TableColumnBase} that is used by the
- *      underlying UI control (e.g. {@link TableColumn} or {@link TreeTableColumn}.
  * @since JavaFX 8.0
  */
-public abstract class TableSelectionModel<T, TC extends TableColumnBase<T,?>> extends MultipleSelectionModelBase<T> {
+public abstract class TableSelectionModel<T> extends MultipleSelectionModelBase<T> {
     
     /**
      * Convenience function which tests whether the given row and column index
      * is currently selected in this table instance.
      */
-    public abstract boolean isSelected(int row, TC column);
+    public abstract boolean isSelected(int row, TableColumnBase<T,?> column);
 
     /**
      * Selects the cell at the given row/column intersection.
      */
-    public abstract void select(int row, TC column);
+    public abstract void select(int row, TableColumnBase<T,?> column);
 
     /**
      * Clears all selection, and then selects the cell at the given row/column
      * intersection.
      */
-    public abstract void clearAndSelect(int row, TC column);
+    public abstract void clearAndSelect(int row, TableColumnBase<T,?> column);
 
     /**
      * Removes selection from the specified row/column position (in view indexes).
      * If this particular cell (or row if the column value is -1) is not selected,
      * nothing happens.
      */
-    public abstract void clearSelection(int row, TC column);
+    public abstract void clearSelection(int row, TableColumnBase<T,?> column);
 
     /**
      * Selects the cell to the left of the currently selected cell.
--- a/modules/controls/src/main/java/javafx/scene/control/TableView.java	Tue Jul 09 16:39:36 2013 -0700
+++ b/modules/controls/src/main/java/javafx/scene/control/TableView.java	Wed Jul 10 15:00:51 2013 +1200
@@ -1512,7 +1512,7 @@
      * allow for special support for TableView controls.
      * @since JavaFX 2.0
      */
-    public static abstract class TableViewSelectionModel<S> extends TableSelectionModel<S, TableColumn<S,?>> {
+    public static abstract class TableViewSelectionModel<S> extends TableSelectionModel<S> {
 
         /***********************************************************************
          *                                                                     *
@@ -1564,6 +1564,65 @@
 
         /***********************************************************************
          *                                                                     *
+         * Generic (type erasure) bridging                                     *
+         *                                                                     *
+         **********************************************************************/
+
+        // --- isSelected
+        /** {@inheritDoc} */
+        @Override public boolean isSelected(int row, TableColumnBase<S, ?> column) {
+            return isSelected(row, (TableColumn)column);
+        }
+
+        /**
+         * Convenience function which tests whether the given row and column index
+         * is currently selected in this table instance.
+         */
+        public abstract boolean isSelected(int row, TableColumn<S, ?> column);
+
+
+        // --- select
+        /** {@inheritDoc} */
+        @Override public void select(int row, TableColumnBase<S, ?> column) {
+            select(row, (TableColumn)column);
+        }
+
+        /**
+         * Selects the cell at the given row/column intersection.
+         */
+        public abstract void select(int row, TableColumn<S, ?> column);
+
+
+        // --- clearAndSelect
+        /** {@inheritDoc} */
+        @Override public void clearAndSelect(int row, TableColumnBase<S,?> column) {
+            clearAndSelect(row, (TableColumn) column);
+        }
+
+        /**
+         * Clears all selection, and then selects the cell at the given row/column
+         * intersection.
+         */
+        public abstract void clearAndSelect(int row, TableColumn<S,?> column);
+
+
+        // --- clearSelection
+        /** {@inheritDoc} */
+        @Override public void clearSelection(int row, TableColumnBase<S,?> column) {
+            clearSelection(row, (TableColumn) column);
+        }
+
+        /**
+         * Removes selection from the specified row/column position (in view indexes).
+         * If this particular cell (or row if the column value is -1) is not selected,
+         * nothing happens.
+         */
+        public abstract void clearSelection(int row, TableColumn<S, ?> column);
+
+
+
+        /***********************************************************************
+         *                                                                     *
          * Public API                                                          *
          *                                                                     *
          **********************************************************************/
@@ -1579,7 +1638,7 @@
          * Convenience method that returns getTableView().getItems().
          * @return The items list of the current TableView.
          */
-        protected ObservableList<S> getTableModel()  {
+        protected List<S> getTableModel()  {
             return tableView.getItems();
         }
 
@@ -1796,7 +1855,7 @@
             tableView.itemsProperty().addListener(weakItemsPropertyListener);
             
             // watching for changes to the items list content
-            ObservableList<S> items = getTableModel();
+            ObservableList<S> items = getTableView().getItems();//getTableModel();
             if (items != null) {
                 items.addListener(weakItemsContentListener);
             }
--- a/modules/controls/src/main/java/javafx/scene/control/TreeTableView.java	Tue Jul 09 16:39:36 2013 -0700
+++ b/modules/controls/src/main/java/javafx/scene/control/TreeTableView.java	Wed Jul 10 15:00:51 2013 +1200
@@ -207,7 +207,7 @@
  * normal JavaBean properties too, although there is a caveat to this, so refer 
  * to the class documentation for more information). When this is not the case, 
  * it is necessary to provide a custom cell value factory. More information
- * about cell value factories can be found in the {@link TreeTableColumns} API 
+ * about cell value factories can be found in the {@link TreeTableColumn} API
  * documentation, but briefly, here is how a TreeTableColumns could be specified:
  * 
  * <pre>
@@ -259,7 +259,7 @@
  * 
  * <p>You can create custom {@link TreeTableCell} instances per column by assigning 
  * the appropriate function to the TreeTableColumns
- * {@link TreeTableColumns#cellFactoryProperty() cell factory} property.
+ * {@link TreeTableColumn#cellFactoryProperty() cell factory} property.
  * 
  * <p>See the {@link Cell} class documentation for a more complete
  * description of how to write custom Cells.
@@ -1457,7 +1457,7 @@
      * Instructs the TreeTableView to begin editing the given TreeItem, if 
      * the TreeTableView is {@link #editableProperty() editable}. Once
      * this method is called, if the current 
-     * {@link #cellFactoryProperty() cell factory} is set up to support editing,
+     * {@link javafx.scene.control.TreeTableColumn#cellFactoryProperty()} cell factory} is set up to support editing,
      * the Cell will switch its visual state to enable the user input to take place.
      * 
      * @param item The TreeItem in the TreeTableView that should be edited.
@@ -1916,7 +1916,7 @@
          * TreeTableColumn and delta values being set and stored in this immutable
          * instance.
          * 
-         * @param table The TreeTableView upon which the resize operation is occurring.
+         * @param treeTable The TreeTableView upon which the resize operation is occurring.
          * @param column The column upon which the resize is occurring, or null
          *      if this ResizeFeatures instance is being created as a result of a
          *      TreeTableView resize operation.
@@ -2018,8 +2018,8 @@
      * allow for special support for TableView controls.
      * @since JavaFX 8.0
      */
-    public static abstract class TreeTableViewSelectionModel<S> extends 
-            TableSelectionModel<TreeItem<S>, TreeTableColumn<S, ?>> {
+    public static abstract class TreeTableViewSelectionModel<S> extends
+            TableSelectionModel<TreeItem<S>> {
 
         /***********************************************************************
          *                                                                     *
@@ -2040,7 +2040,7 @@
         /**
          * Builds a default TableViewSelectionModel instance with the provided
          * TableView.
-         * @param tableView The TableView upon which this selection model should
+         * @param treeTableView The TableView upon which this selection model should
          *      operate.
          * @throws NullPointerException TableView can not be null.
          */
@@ -2451,7 +2451,7 @@
             clearAndSelect(row, null);
         }
 
-        @Override public void clearAndSelect(int row, TreeTableColumn<S,?> column) {
+        @Override public void clearAndSelect(int row, TableColumnBase column) {
             quietClearSelection();
             select(row, column);
         }
@@ -2460,7 +2460,7 @@
             select(row, null);
         }
 
-        @Override public void select(int row, TreeTableColumn<S,?> column) {
+        @Override public void select(int row, TableColumnBase column) {
             // TODO we need to bring in the TreeView selection stuff here...
             if (row < 0 || row >= getRowCount()) return;
 
@@ -2472,7 +2472,7 @@
 //            // if a column is given, I return
 //            if (! isCellSelectionEnabled() && column != null) return;
 
-            TreeTablePosition pos = new TreeTablePosition(getTreeTableView(), row, column);
+            TreeTablePosition pos = new TreeTablePosition(getTreeTableView(), row, (TreeTableColumn)column);
             
             if (! selectedCells.contains(pos)) {
                 if (getSelectionMode() == SelectionMode.SINGLE) {
@@ -2483,7 +2483,7 @@
 
 //            setSelectedIndex(row);
             updateSelectedIndex(row);
-            focus(row, column);
+            focus(row, (TreeTableColumn)column);
             
             int changeIndex = selectedCellsSeq.indexOf(pos);
             selectedCellsSeq.callObservers(new NonIterableChange.SimpleAddChange<TreeTablePosition<S,?>>(changeIndex, changeIndex+1, selectedCellsSeq));
@@ -2649,8 +2649,8 @@
             clearSelection(index, null);
         }
 
-        @Override public void clearSelection(int row, TreeTableColumn<S,?> column) {
-            TreeTablePosition tp = new TreeTablePosition(getTreeTableView(), row, column);
+        @Override public void clearSelection(int row, TableColumnBase column) {
+            TreeTablePosition tp = new TreeTablePosition(getTreeTableView(), row, (TreeTableColumn)column);
 
             boolean csMode = isCellSelectionEnabled();
             
@@ -2680,7 +2680,7 @@
             return isSelected(index, null);
         }
 
-        @Override public boolean isSelected(int row, TreeTableColumn<S,?> column) {
+        @Override public boolean isSelected(int row, TableColumnBase column) {
             // When in cell selection mode, we currently do NOT support selecting
             // entire rows, so a isSelected(row, null) 
             // should always return false.
@@ -2894,7 +2894,7 @@
          * Creates a default TableViewFocusModel instance that will be used to
          * manage focus of the provided TableView control.
          * 
-         * @param tableView The tableView upon which this focus model operates.
+         * @param treeTableView The tableView upon which this focus model operates.
          * @throws NullPointerException The TableView argument can not be null.
          */
         public TreeTableViewFocusModel(final TreeTableView<S> treeTableView) {
--- a/modules/controls/src/main/java/javafx/scene/control/cell/CheckBoxTreeTableCell.java	Tue Jul 09 16:39:36 2013 -0700
+++ b/modules/controls/src/main/java/javafx/scene/control/cell/CheckBoxTreeTableCell.java	Wed Jul 10 15:00:51 2013 +1200
@@ -78,7 +78,7 @@
      * column will be bound bidirectionally. This means that the  CheckBox in 
      * the cell will set/unset this property based on user interactions, and the 
      * CheckBox will reflect the state of the {@code ObservableValue<Boolean>}, 
-     * if it changes externally).</li>
+     * if it changes externally).
      * 
      * @return A {@link Callback} that will return a {@link TreeTableCell} that is 
      *      able to work on the type of element contained within the TreeTableColumn.
--- a/modules/controls/src/test/java/javafx/scene/control/TreeTableViewTest.java	Tue Jul 09 16:39:36 2013 -0700
+++ b/modules/controls/src/test/java/javafx/scene/control/TreeTableViewTest.java	Wed Jul 10 15:00:51 2013 +1200
@@ -63,6 +63,8 @@
 import javafx.scene.control.cell.TreeItemPropertyValueFactory;
 import javafx.scene.layout.HBox;
 import javafx.scene.layout.StackPane;
+import javafx.scene.paint.Color;
+import javafx.scene.shape.Circle;
 import javafx.stage.Stage;
 import javafx.util.Callback;
 
@@ -2137,4 +2139,55 @@
         assertEquals("Root", cell.getItem());
         assertEquals(50, cell.getHeight(), 0.00);
     }
+
+    @Test public void test_rt30466() {
+        final Node graphic1 = new Circle(6.75, Color.RED);
+        final Node graphic2 = new Circle(6.75, Color.GREEN);
+
+        installChildren();
+
+        TreeTableColumn<String,String> firstNameCol = new TreeTableColumn<>("First Name");
+        firstNameCol.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<String, String>, ObservableValue<String>>() {
+            @Override public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<String, String> param) {
+                return new ReadOnlyStringWrapper(param.getValue().getValue());
+            }
+        });
+
+        treeTableView.getColumns().add(firstNameCol);
+
+        TreeTableRow cell = (TreeTableRow) VirtualFlowTestUtils.getCell(treeTableView, 0);
+        assertEquals("Root", cell.getItem());
+
+        // set the first graphic - which we expect to see as a child of the cell
+        root.setGraphic(graphic1);
+        cell = (TreeTableRow) VirtualFlowTestUtils.getCell(treeTableView, 0);
+        boolean matchGraphic1 = false;
+        boolean matchGraphic2 = false;
+        for (Node n : cell.getChildrenUnmodifiable()) {
+            if (n == graphic1) {
+                matchGraphic1 = true;
+            }
+            if (n == graphic2) {
+                matchGraphic2 = true;
+            }
+        }
+        assertTrue(matchGraphic1);
+        assertFalse(matchGraphic2);
+
+        // set the second graphic - which we also expect to see - but of course graphic1 should not be a child any longer
+        root.setGraphic(graphic2);
+        cell = (TreeTableRow) VirtualFlowTestUtils.getCell(treeTableView, 0);
+        matchGraphic1 = false;
+        matchGraphic2 = false;
+        for (Node n : cell.getChildrenUnmodifiable()) {
+            if (n == graphic1) {
+                matchGraphic1 = true;
+            }
+            if (n == graphic2) {
+                matchGraphic2 = true;
+            }
+        }
+        assertFalse(matchGraphic1);
+        assertTrue(matchGraphic2);
+    }
 }