changeset 4945:4690ab589dbe

RT-29902: [TableView, TreeTableView] progress bar in progressBarCell don't resize on column width.
author jgiles
date Thu, 05 Sep 2013 17:25:50 +1200
parents 3a7177158a6c
children f3dcad659452
files modules/controls/src/main/java/javafx/scene/control/cell/ProgressBarTableCell.java modules/controls/src/main/java/javafx/scene/control/cell/ProgressBarTreeTableCell.java modules/controls/src/test/java/javafx/scene/control/cell/ProgressBarTableCellTest.java modules/controls/src/test/java/javafx/scene/control/cell/ProgressBarTreeTableCellTest.java
diffstat 4 files changed, 41 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/javafx/scene/control/cell/ProgressBarTableCell.java	Thu Sep 05 17:14:21 2013 +1200
+++ b/modules/controls/src/main/java/javafx/scene/control/cell/ProgressBarTableCell.java	Thu Sep 05 17:25:50 2013 +1200
@@ -91,6 +91,7 @@
         this.getStyleClass().add("progress-bar-table-cell");
         
         this.progressBar = new ProgressBar();
+        this.progressBar.setMaxWidth(Double.MAX_VALUE);
     }
     
     
@@ -109,8 +110,10 @@
             setGraphic(null);
         } else {
             progressBar.progressProperty().unbind();
-            
-            observable = getTableColumn().getCellObservableValue(getIndex());
+
+            final TableColumn<S,Double> column = getTableColumn();
+            observable = column == null ? null : column.getCellObservableValue(getIndex());
+
             if (observable != null) {
                 progressBar.progressProperty().bind(observable);
             } else if (item != null) {
--- a/modules/controls/src/main/java/javafx/scene/control/cell/ProgressBarTreeTableCell.java	Thu Sep 05 17:14:21 2013 +1200
+++ b/modules/controls/src/main/java/javafx/scene/control/cell/ProgressBarTreeTableCell.java	Thu Sep 05 17:25:50 2013 +1200
@@ -27,6 +27,7 @@
 
 import javafx.beans.value.ObservableValue;
 import javafx.scene.control.ProgressBar;
+import javafx.scene.control.TableColumn;
 import javafx.scene.control.TreeTableCell;
 import javafx.scene.control.TreeTableColumn;
 import javafx.util.Callback;
@@ -91,6 +92,7 @@
         this.getStyleClass().add("progress-bar-tree-table-cell");
         
         this.progressBar = new ProgressBar();
+        this.progressBar.setMaxWidth(Double.MAX_VALUE);
     }
     
     
@@ -110,7 +112,9 @@
         } else {
             progressBar.progressProperty().unbind();
             
-            observable = getTableColumn().getCellObservableValue(getIndex());
+            final TreeTableColumn<S,Double> column = getTableColumn();
+            observable = column == null ? null : column.getCellObservableValue(getIndex());
+
             if (observable != null) {
                 progressBar.progressProperty().bind(observable);
             } else if (item != null) {
--- a/modules/controls/src/test/java/javafx/scene/control/cell/ProgressBarTableCellTest.java	Thu Sep 05 17:14:21 2013 +1200
+++ b/modules/controls/src/test/java/javafx/scene/control/cell/ProgressBarTableCellTest.java	Thu Sep 05 17:25:50 2013 +1200
@@ -140,8 +140,21 @@
         assertNotNull(cell.getGraphic());
         assertTrue(cell.getGraphic() instanceof ProgressBar);
     }
-    
 
+
+
+    /**************************************************************************
+     *
+     * misc tests
+     *
+     **************************************************************************/
+
+    @Test public void test_graphicMaxWidthIsDoubleMaxValue() {
+        ProgressBarTableCell<Object> cell = new ProgressBarTableCell<>();
+        cell.updateItem(0.5, false);
+        assertNotNull(cell.getGraphic());
+        assertEquals(Double.MAX_VALUE, ((ProgressBar)cell.getGraphic()).getMaxWidth(), 0.0);
+    }
     
 //    /**************************************************************************
 //     * 
--- a/modules/controls/src/test/java/javafx/scene/control/cell/ProgressBarTreeTableCellTest.java	Thu Sep 05 17:14:21 2013 +1200
+++ b/modules/controls/src/test/java/javafx/scene/control/cell/ProgressBarTreeTableCellTest.java	Thu Sep 05 17:25:50 2013 +1200
@@ -141,9 +141,24 @@
         assertNotNull(cell.getGraphic());
         assertTrue(cell.getGraphic() instanceof ProgressBar);
     }
-    
 
-    
+
+
+    /**************************************************************************
+     *
+     * misc tests
+     *
+     **************************************************************************/
+
+    @Test public void test_graphicMaxWidthIsDoubleMaxValue() {
+        ProgressBarTreeTableCell<Object> cell = new ProgressBarTreeTableCell<>();
+        cell.updateItem(0.5, false);
+        assertNotNull(cell.getGraphic());
+        assertEquals(Double.MAX_VALUE, ((ProgressBar)cell.getGraphic()).getMaxWidth(), 0.0);
+    }
+
+
+
 //    /**************************************************************************
 //     * 
 //     * test checkbox selection state is bound