changeset 4218:228646313e30

RT-31471: Fixed cell height doesn't affect immidiately for virtual flow controls.
author jgiles
date Tue, 09 Jul 2013 11:59:02 +1200
parents 31136be6a98a
children bacb30cbf1ff
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TreeTableRowSkin.java modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualFlow.java modules/controls/src/test/java/javafx/scene/control/ListViewTest.java modules/controls/src/test/java/javafx/scene/control/TableViewTest.java modules/controls/src/test/java/javafx/scene/control/TreeTableViewTest.java modules/controls/src/test/java/javafx/scene/control/TreeViewTest.java
diffstat 6 files changed, 95 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TreeTableRowSkin.java	Tue Jul 09 11:02:44 2013 +1200
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TreeTableRowSkin.java	Tue Jul 09 11:59:02 2013 +1200
@@ -66,6 +66,8 @@
     private SimpleObjectProperty<ObservableList<TreeItem<T>>> itemsProperty;
     private TreeItem<?> treeItem;
     private boolean disclosureNodeDirty = true;
+
+    private TreeTableViewSkin treeTableViewSkin;
     
     private MultiplePropertyChangeListenerHandler treeItemListener = new MultiplePropertyChangeListenerHandler(new Callback<String, Void>() {
         @Override public Void call(String p) {
@@ -86,7 +88,9 @@
         
         updateTreeItem();
         updateDisclosureNodeRotation(false);
+        updateTableViewSkin();
 
+        registerChangeListener(control.treeTableViewProperty(), "TREE_TABLE_VIEW");
         registerChangeListener(control.indexProperty(), "INDEX");
         registerChangeListener(control.treeItemProperty(), "TREE_ITEM");
         registerChangeListener(control.getTreeTableView().treeColumnProperty(), "TREE_COLUMN");
@@ -95,7 +99,9 @@
     @Override protected void handleControlPropertyChanged(String p) {
         super.handleControlPropertyChanged(p);
 
-        if ("INDEX".equals(p)) {
+        if ("TREE_ABLE_VIEW".equals(p)) {
+            updateTableViewSkin();
+        } else if ("INDEX".equals(p)) {
             updateCells = true;
 //            isDirty = true;
 //            getSkinnable().requestLayout();
@@ -302,7 +308,7 @@
     }
 
     @Override protected boolean isColumnPartiallyOrFullyVisible(TableColumnBase tc) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return treeTableViewSkin == null ? false : treeTableViewSkin.isColumnPartiallyOrFullyVisible(tc);
     }
 
     @Override protected TreeTableColumn<T, ?> getTableColumnBase(TreeTableCell cell) {
@@ -324,7 +330,13 @@
     @Override protected DoubleProperty fixedCellSizeProperty() {
         return getSkinnable().getTreeTableView().fixedCellSizeProperty();
     }
-    
+
+    private void updateTableViewSkin() {
+        TreeTableView tableView = getSkinnable().getTreeTableView();
+        if (tableView.getSkin() instanceof TreeTableViewSkin) {
+            treeTableViewSkin = (TreeTableViewSkin)tableView.getSkin();
+        }
+    }
     
     
     /***************************************************************************
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualFlow.java	Tue Jul 09 11:02:44 2013 +1200
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualFlow.java	Tue Jul 09 11:59:02 2013 +1200
@@ -264,6 +264,7 @@
     public void setFixedCellSize(final double value) {
         this.fixedCellSize = value;
         this.fixedCellSizeEnabled = fixedCellSize > 0;
+        needsCellsLayout = true;
         layoutChildren();
     }
     
--- a/modules/controls/src/test/java/javafx/scene/control/ListViewTest.java	Tue Jul 09 11:02:44 2013 +1200
+++ b/modules/controls/src/test/java/javafx/scene/control/ListViewTest.java	Tue Jul 09 11:59:02 2013 +1200
@@ -646,4 +646,20 @@
         assertEquals(1, listView.getEditingIndex());
         assertTrue(cell.isEditing());
     }
+
+    @Test public void test_rt31471() {
+        final ObservableList names = FXCollections.observableArrayList("Adam", "Alex", "Alfred", "Albert");
+        final ListView listView = new ListView(names);
+
+        IndexedCell cell = VirtualFlowTestUtils.getCell(listView, 0);
+        assertEquals("Adam", cell.getItem());
+
+        listView.setFixedCellSize(50);
+
+        VirtualFlowTestUtils.getVirtualFlow(listView).requestLayout();
+        Toolkit.getToolkit().firePulse();
+
+        assertEquals("Adam", cell.getItem());
+        assertEquals(50, cell.getHeight(), 0.00);
+    }
 }
--- a/modules/controls/src/test/java/javafx/scene/control/TableViewTest.java	Tue Jul 09 11:02:44 2013 +1200
+++ b/modules/controls/src/test/java/javafx/scene/control/TableViewTest.java	Tue Jul 09 11:59:02 2013 +1200
@@ -1365,4 +1365,28 @@
         assertEquals(firstNameCol, editingCell.getTableColumn());
         assertTrue(cell.isEditing());
     }
+
+    @Test public void test_rt31471() {
+        Person jacobSmith;
+        final TableView<Person> tableView = new TableView<Person>();
+        tableView.setItems(FXCollections.observableArrayList(
+                jacobSmith = new Person("Jacob", "Smith", "jacob.smith@example.com"),
+                new Person("Jim", "Bob", "jim.bob@example.com")
+        ));
+
+        TableColumn firstNameCol = new TableColumn("First Name");
+        firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName"));
+        tableView.getColumns().add(firstNameCol);
+
+        IndexedCell cell = VirtualFlowTestUtils.getCell(tableView, 0);
+        assertEquals(jacobSmith, cell.getItem());
+
+        tableView.setFixedCellSize(50);
+
+        VirtualFlowTestUtils.getVirtualFlow(tableView).requestLayout();
+        Toolkit.getToolkit().firePulse();
+
+        assertEquals(jacobSmith, cell.getItem());
+        assertEquals(50, cell.getHeight(), 0.00);
+    }
 }
--- a/modules/controls/src/test/java/javafx/scene/control/TreeTableViewTest.java	Tue Jul 09 11:02:44 2013 +1200
+++ b/modules/controls/src/test/java/javafx/scene/control/TreeTableViewTest.java	Tue Jul 09 11:59:02 2013 +1200
@@ -2113,4 +2113,28 @@
         treeTableView.setShowRoot(false);
         assertEquals("Child 1", cell.getText());
     }
+
+    @Test public void test_rt31471() {
+        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);
+
+        IndexedCell cell = VirtualFlowTestUtils.getCell(treeTableView, 0);
+        assertEquals("Root", cell.getItem());
+
+        treeTableView.setFixedCellSize(50);
+
+        VirtualFlowTestUtils.getVirtualFlow(treeTableView).requestLayout();
+        Toolkit.getToolkit().firePulse();
+
+        assertEquals("Root", cell.getItem());
+        assertEquals(50, cell.getHeight(), 0.00);
+    }
 }
--- a/modules/controls/src/test/java/javafx/scene/control/TreeViewTest.java	Tue Jul 09 11:02:44 2013 +1200
+++ b/modules/controls/src/test/java/javafx/scene/control/TreeViewTest.java	Tue Jul 09 11:59:02 2013 +1200
@@ -1057,4 +1057,19 @@
         treeView.setShowRoot(false);
         assertEquals("Child 1", cell.getText());
     }
+
+    @Test public void test_rt31471() {
+        installChildren();
+
+        IndexedCell cell = VirtualFlowTestUtils.getCell(treeView, 0);
+        assertEquals("Root", cell.getItem());
+
+        treeView.setFixedCellSize(50);
+
+        VirtualFlowTestUtils.getVirtualFlow(treeView).requestLayout();
+        Toolkit.getToolkit().firePulse();
+
+        assertEquals("Root", cell.getItem());
+        assertEquals(50, cell.getHeight(), 0.00);
+    }
 }