changeset 3983:76a7ba878acd

RT-31016 javafx.scene.control.TableView: column headers shoud appear RT-30363 Region calls requestLayout too aggressively
author Martin Sladecek <martin.sladecek@oracle.com>
date Thu, 13 Jun 2013 10:13:22 +0200
parents eaea57901d09
children 29f85364846e 83a9bfb58e38
files javafx-ui-common/src/javafx/scene/Parent.java javafx-ui-controls/src/com/sun/javafx/scene/control/skin/NestedTableColumnHeader.java javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableColumnHeader.java
diffstat 3 files changed, 13 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/javafx/scene/Parent.java	Wed Jun 12 16:32:53 2013 -0400
+++ b/javafx-ui-common/src/javafx/scene/Parent.java	Thu Jun 13 10:13:22 2013 +0200
@@ -1030,8 +1030,6 @@
 
             // layout the children in this parent.
             layoutChildren();
-            // clear flag before recursing down so requestLayout calls arn't swallowed
-            setNeedsLayout(false);
 
             // Perform layout on each child, hoping it has random access performance!
             for (int i=0, max=children.size(); i<max; i++) {
@@ -1040,6 +1038,8 @@
                     ((Parent) child).layout();
                 }
             }
+            setNeedsLayout(false);
+
             performingLayout = false;
         } else {
             if (PULSE_LOGGING_ENABLED) PULSE_LOGGER.fxIncrementCounter("Parent#layout() on clean Node");
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/NestedTableColumnHeader.java	Wed Jun 12 16:32:53 2013 -0400
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/NestedTableColumnHeader.java	Thu Jun 13 10:13:22 2013 +0200
@@ -75,6 +75,13 @@
             changeListenerHandler.registerChangeListener(getTableColumn().textProperty(), "TABLE_COLUMN_TEXT");
         }
         
+        // watching for changes to the view columns in either table or tableColumn.
+        if (getTableColumn() == null && getTableViewSkin() != null) {
+            setColumns(getTableViewSkin().getColumns());
+        } else if (getTableColumn() != null) {
+            setColumns(getTableColumn().getColumns());
+        }
+
         changeListenerHandler.registerChangeListener(skin.columnResizePolicyProperty(), "TABLE_VIEW_COLUMN_RESIZE_POLICY");
     }
 
@@ -141,18 +148,11 @@
         if (this.columns != null) {
             this.columns.addListener(weakColumnsListener);
         }
+
+        updateTableColumnHeaders();
     }
     
     void updateTableColumnHeaders() {
-        // watching for changes to the view columns in either table or tableColumn.
-        if (getTableColumn() == null && getTableViewSkin() != null) {
-            setColumns(getTableViewSkin().getColumns());
-        } else if (getTableColumn() != null) {
-            setColumns(getTableColumn().getColumns());
-        }
-        
-        // update the column headers....
-        
         // iterate through all current headers, telling them to clean up
         for (int i = 0; i < getColumnHeaders().size(); i++) {
             TableColumnHeader header = getColumnHeaders().get(i);
@@ -399,7 +399,6 @@
     /* **************************/
 
     void setHeadersNeedUpdate() {
-        updateColumns = true;
         // go through children columns - they should update too
         for (int i = 0; i < getColumnHeaders().size(); i++) {
             TableColumnHeader header = getColumnHeaders().get(i);
@@ -407,16 +406,12 @@
                 ((NestedTableColumnHeader)header).setHeadersNeedUpdate();
             }
         }
+        updateTableColumnHeaders();
         requestLayout();
     }
     
-    boolean updateColumns = true;
     @Override protected void layoutChildren() {
-        if (updateColumns) {
-            updateTableColumnHeaders();
-            updateColumns = false;
-            getParent().requestLayout();
-        }
+
         double w = getWidth() - snappedLeftInset() - snappedRightInset();
         double h = getHeight() - snappedTopInset() - snappedBottomInset();
         
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableColumnHeader.java	Wed Jun 12 16:32:53 2013 -0400
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableColumnHeader.java	Thu Jun 13 10:13:22 2013 +0200
@@ -143,11 +143,6 @@
             // visually adjusts its width as necessary.
             isSizeDirty = true;
             requestLayout();
-        } else if ("TABLE_COLUMN_WIDTH".equals(p)) {
-            // It is this that ensures that when a column is resized that the header
-            // visually adjusts its width as necessary.
-            isSizeDirty = true;
-            requestLayout();
         } else if ("TABLE_COLUMN_ID".equals(p)) {
             setId(column.getId());
         } else if ("TABLE_COLUMN_STYLE".equals(p)) {