changeset 4138:4ae1706251da

RT-31234: 8.0-controls-scrum-624: 84% footprint regression in TableColumn
author jgiles
date Wed, 03 Jul 2013 09:08:37 +1200
parents f0c5b8c75c94
children 35d3fe04f57e
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/NestedTableColumnHeader.java
diffstat 1 files changed, 25 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/NestedTableColumnHeader.java	Wed Jul 03 08:58:37 2013 +1200
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/NestedTableColumnHeader.java	Wed Jul 03 09:08:37 2013 +1200
@@ -74,13 +74,6 @@
         if (getTableColumn() != null) {
             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");
     }
@@ -148,11 +141,18 @@
         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);
@@ -398,7 +398,11 @@
     /* END OF COLUMN RESIZING   */
     /* **************************/
 
+    boolean updateColumns = true;
+
     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);
@@ -406,9 +410,16 @@
                 ((NestedTableColumnHeader)header).setHeadersNeedUpdate();
             }
         }
-        updateTableColumnHeaders();
         requestLayout();
     }
+
+    private void checkState() {
+        if (updateColumns) {
+            updateTableColumnHeaders();
+            updateColumns = false;
+            getParent().requestLayout();
+        }
+    }
     
     @Override protected void layoutChildren() {
 
@@ -459,6 +470,8 @@
 
     // sum up all children columns
     @Override protected double computePrefWidth(double height) {
+        checkState();
+
         double width = 0.0F;
 
         if (getColumns() != null) {
@@ -473,6 +486,8 @@
     }
 
     @Override protected double computePrefHeight(double width) {
+        checkState();
+
         double height = 0.0F;
 
         if (getColumnHeaders() != null) {