changeset 1636:e2b8f5cca57b

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/3.0/scrum/controls/jfx/rt
author jgiles
date Fri, 17 Aug 2012 11:55:07 +1200
parents 260c59b8a991 8debd0c0c40b
children 80e8a928ccdc 123ea875cb1a
files javafx-ui-controls/src/com/sun/javafx/scene/control/WeakListChangeListener.java
diffstat 19 files changed, 115 insertions(+), 290 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/preview/javafx/scene/control/TreeTableRow.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/com/preview/javafx/scene/control/TreeTableRow.java	Fri Aug 17 11:55:07 2012 +1200
@@ -25,7 +25,6 @@
 package com.preview.javafx.scene.control;
 
 import com.sun.javafx.css.StyleManager;
-import com.sun.javafx.scene.control.WeakListChangeListener;
 import java.lang.ref.WeakReference;
 import javafx.beans.InvalidationListener;
 import javafx.beans.Observable;
@@ -35,6 +34,7 @@
 import javafx.beans.property.ReadOnlyObjectWrapper;
 import javafx.beans.property.SimpleObjectProperty;
 import javafx.collections.ListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import javafx.scene.Node;
 import javafx.scene.control.*;
 
@@ -94,7 +94,7 @@
         }
     };
     
-    private WeakListChangeListener weakSelectedListener;
+    private final WeakListChangeListener weakSelectedListener = new WeakListChangeListener(selectedListener);
     private final WeakInvalidationListener weakFocusedListener = new WeakInvalidationListener(focusedListener);
     private final WeakInvalidationListener weakEditingListener = new WeakInvalidationListener(editingListener);
     
@@ -159,7 +159,7 @@
                 if (oldTreeTableView != null) {
                     // remove old listeners
                     sm = oldTreeTableView.getSelectionModel();
-                    if (sm != null && weakSelectedListener != null) {
+                    if (sm != null) {
                         sm.getSelectedIndices().removeListener(weakSelectedListener);
                     }
 
@@ -179,7 +179,6 @@
                 if (sm != null) {
                     // listening for changes to treeView.selectedIndex and IndexedCell.index,
                     // to determine if this cell is selected
-                    weakSelectedListener = new WeakListChangeListener(sm.getSelectedIndices(), selectedListener);
                     sm.getSelectedIndices().addListener(weakSelectedListener);
                 }
 
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/WeakListChangeListener.java	Thu Aug 16 14:36:43 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.sun.javafx.scene.control;
-
-import java.lang.ref.Reference;
-import java.lang.ref.ReferenceQueue;
-import java.lang.ref.WeakReference;
-import java.util.WeakHashMap;
-import javafx.collections.ListChangeListener;
-import javafx.collections.ListChangeListener.Change;
-import javafx.collections.ObservableList;
-
-/**
- * A {@code WeakListChangeListener} can be used, if an {@code ObservableList}
- * should only maintain a weak reference to the listener. This helps to avoid
- * memory leaks, that can occur if observers are not unregistered from observed
- * objects after use.
- * <p>
- * {@code WeakListChangeListener} are created by passing in the original
- * {@link ListChangeListener}. The {@code WeakListChangeListener} should
- * then be registered to listen for changes of the observed object.
- * <p>
- * Note: You have to keep a reference to the {@code ListChangeListener}, that
- * was passed in as long as it is in use, otherwise it will be garbage collected
- * too soon.
- * 
- * @see ListChangeListener
- * @see ObservableList
- * 
- * @param T The type of the observed value
- * 
- */
-public class WeakListChangeListener<T> implements ListChangeListener<T> {
-    private static final WeakHashMap<ObservableList, ReferenceQueue<ListChangeListener>> refQueueMap = 
-            new WeakHashMap<ObservableList, ReferenceQueue<ListChangeListener>>();
-    
-    private final ReferenceQueue<ListChangeListener> refQueue;
-    private final WeakReference<ListChangeListener<T>> listenerRef;
-    private final ObservableList<T> list;
-
-    /**
-     * The constructor of {@code WeakListChangeListener}.
-     * 
-     * @param list
-     *          The list on which this listener will be attached. By doing this
-     *          we are able to clean up when the WeakReference becomes null
-     * @param listener
-     *            The original listener that should be notified
-     */
-    public WeakListChangeListener(final ObservableList<T> list, final ListChangeListener<T> listener) {
-        if (listener == null) {
-            throw new NullPointerException("Listener must be specified.");
-        }
-        if (list == null) {
-            throw new NullPointerException("ObservableList must be specified.");
-        }
-        
-        this.list = list;
-        
-        // get, or create a new, reference queue for this list
-        if (refQueueMap.containsKey(list)) {
-            refQueue = refQueueMap.get(list);
-        } else {
-            refQueue = new ReferenceQueue<ListChangeListener>();
-            refQueueMap.put(list, refQueue);
-        }
-        
-        this.listenerRef = new BackReference<ListChangeListener<T>>(listener, refQueue, this);
-        
-        // do a reference queue check now
-        checkReferenceQueue(refQueue, list);
-    }
-
-    @Override public void onChanged(Change<? extends T> c) {
-        ListChangeListener<T> listener = listenerRef.get();
-        if (listener != null) {
-            listener.onChanged(c);
-        } else {
-            // The weakly reference listener has been garbage collected,
-            // so this WeakListener will now unhook itself from the
-            // source bean
-            list.removeListener(this);
-        }
-        
-        // check reference queue for empty references to clean up
-        checkReferenceQueue(refQueue, list);
-    }
-    
-    private static <T> void checkReferenceQueue(final ReferenceQueue<ListChangeListener> refQueue, 
-            final ObservableList list) {
-        BackReference ref;
-        WeakListChangeListener backRef;
-        while ((ref = (BackReference)refQueue.poll()) != null) {
-            backRef = ref.backRef;
-            list.removeListener(backRef);
-        }
-    }
-    
-    private static class BackReference<T> extends WeakReference<T> {
-        
-        private final WeakListChangeListener backRef;
-
-        public BackReference(T referent, ReferenceQueue<? super T> q, WeakListChangeListener backRef) {
-            super(referent, q);
-            this.backRef = backRef;
-        }
-    }
-}
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ChoiceBoxSkin.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ChoiceBoxSkin.java	Fri Aug 17 11:55:07 2012 +1200
@@ -52,7 +52,7 @@
 import javafx.scene.text.Text;
 
 import com.sun.javafx.scene.control.behavior.ChoiceBoxBehavior;
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 
 
 /**
@@ -114,7 +114,8 @@
         }
     };
     
-    private WeakListChangeListener weakChoiceBoxItemsListener;
+    private final WeakListChangeListener weakChoiceBoxItemsListener =
+            new WeakListChangeListener(choiceBoxItemsListener);
 
     private void initialize() {
         updateChoiceBoxItems();
@@ -175,12 +176,11 @@
     }
 
     private void updateChoiceBoxItems() {
-        if (choiceBoxItems != null && weakChoiceBoxItemsListener != null) {
+        if (choiceBoxItems != null) {
             choiceBoxItems.removeListener(weakChoiceBoxItemsListener);
         }
         choiceBoxItems = getSkinnable().getItems();
         if (choiceBoxItems != null) {
-            weakChoiceBoxItemsListener = new WeakListChangeListener(choiceBoxItems, choiceBoxItemsListener);
             choiceBoxItems.addListener(weakChoiceBoxItemsListener);
         }
     }
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java	Fri Aug 17 11:55:07 2012 +1200
@@ -27,7 +27,7 @@
 
 import com.sun.javafx.event.EventDispatchChainImpl;
 import com.sun.javafx.scene.control.FocusableTextField;
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import javafx.scene.control.ComboBox;
 import com.sun.javafx.scene.control.behavior.ComboBoxListViewBehavior;
 import java.util.List;
@@ -95,7 +95,8 @@
         }
     };
     
-    private WeakListChangeListener weakListViewItemsListener;
+    private final WeakListChangeListener weakListViewItemsListener =
+            new WeakListChangeListener(listViewItemsListener);
     
     
     
@@ -241,7 +242,6 @@
         this.listViewItems = comboBox.getItems();
         listView.setItems(null);
         listView.setItems(listViewItems);
-        weakListViewItemsListener = new WeakListChangeListener(listViewItems, listViewItemsListener);
 
         if (listViewItems != null) {
             listViewItems.addListener(weakListViewItemsListener);
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ListViewSkin.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ListViewSkin.java	Fri Aug 17 11:55:07 2012 +1200
@@ -37,7 +37,7 @@
 import javafx.scene.control.SelectionModel;
 import javafx.scene.input.MouseEvent;
 
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import com.sun.javafx.scene.control.behavior.ListViewBehavior;
 import javafx.util.Callback;
 
@@ -146,17 +146,17 @@
         }
     };
     
-    private WeakListChangeListener weakListViewItemsListener;
+    private final WeakListChangeListener weakListViewItemsListener =
+            new WeakListChangeListener(listViewItemsListener);
 
     public void updateListViewItems() {
-        if (listViewItems != null && weakListViewItemsListener != null) {
+        if (listViewItems != null) {
             listViewItems.removeListener(weakListViewItemsListener);
         }
 
         this.listViewItems = getSkinnable().getItems();
-        
+
         if (listViewItems != null) {
-            weakListViewItemsListener = new WeakListChangeListener(listViewItems, listViewItemsListener);
             listViewItems.addListener(weakListViewItemsListener);
         }
 
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/NestedTableColumnHeader.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/NestedTableColumnHeader.java	Fri Aug 17 11:55:07 2012 +1200
@@ -25,13 +25,10 @@
 package com.sun.javafx.scene.control.skin;
 
 import com.sun.javafx.PlatformUtil;
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import java.util.ArrayList;
 import java.util.List;
 
-import javafx.beans.InvalidationListener;
-import javafx.beans.Observable;
-import javafx.beans.WeakInvalidationListener;
 import javafx.collections.FXCollections;
 import javafx.collections.ListChangeListener;
 import javafx.collections.ObservableList;
@@ -103,7 +100,8 @@
         }
     };
     
-    private WeakListChangeListener weakColumnsListener;
+    private final WeakListChangeListener weakColumnsListener =
+            new WeakListChangeListener(columnsListener);
     
     
 
@@ -132,14 +130,13 @@
     private ObservableList<? extends TableColumn> columns;
     ObservableList<? extends TableColumn> getColumns() { return columns; }
     void setColumns(ObservableList<? extends TableColumn> newColumns) {
-        if (this.columns != null && weakColumnsListener != null) {
+        if (this.columns != null) {
             this.columns.removeListener(weakColumnsListener);
         }
         
         this.columns = newColumns;  
         
         if (this.columns != null) {
-            weakColumnsListener = new WeakListChangeListener(columns, columnsListener);
             this.columns.addListener(weakColumnsListener);
         }
     }
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableColumnHeader.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableColumnHeader.java	Fri Aug 17 11:55:07 2012 +1200
@@ -63,7 +63,7 @@
 import com.sun.javafx.css.StyleableProperty;
 import com.sun.javafx.css.converters.SizeConverter;
 import com.sun.javafx.scene.control.MultiplePropertyChangeListenerHandler;
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 
 
 /**
@@ -104,14 +104,8 @@
         
         if (column != null && table != null) {
             setSortPos(! column.isSortable() ? -1 : table.getSortOrder().indexOf(column));
-            
-            ObservableList<TableColumn<?,?>> sortOrderList = table.getSortOrder();
-            weakSortOrderListener = new WeakListChangeListener<TableColumn<?,?>>(sortOrderList, sortOrderListener);
-            sortOrderList.addListener(weakSortOrderListener);
-            
-            ObservableList<TableColumn<?,?>> visibleLeafColumns = table.getVisibleLeafColumns();
-            weakVisibleLeafColumnsListener = new WeakListChangeListener(visibleLeafColumns,visibleLeafColumnsListener);
-            visibleLeafColumns.addListener(weakVisibleLeafColumnsListener);
+            table.getSortOrder().addListener(weakSortOrderListener);
+            table.getVisibleLeafColumns().addListener(weakVisibleLeafColumnsListener);
         }
 
         if (column != null) {
@@ -171,8 +165,10 @@
         }
     };
     
-    private WeakListChangeListener<TableColumn<?,?>> weakSortOrderListener;
-    private WeakListChangeListener weakVisibleLeafColumnsListener;
+    private WeakListChangeListener<TableColumn<?,?>> weakSortOrderListener =
+            new WeakListChangeListener<TableColumn<?,?>>(sortOrderListener);
+    private final WeakListChangeListener weakVisibleLeafColumnsListener =
+            new WeakListChangeListener(visibleLeafColumnsListener);
     
     private static final EventHandler<MouseEvent> mousePressedHandler = new EventHandler<MouseEvent>() {
         @Override public void handle(MouseEvent me) {
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableHeaderRow.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableHeaderRow.java	Fri Aug 17 11:55:07 2012 +1200
@@ -24,7 +24,7 @@
  */
 package com.sun.javafx.scene.control.skin;
 
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -54,19 +54,18 @@
 import com.sun.javafx.scene.control.skin.resources.ControlResources;
 import javafx.beans.WeakInvalidationListener;
 import javafx.beans.property.BooleanPropertyBase;
-import javafx.collections.ObservableList;
 
 /**
  * Region responsible for painting the entire row of column headers.
  */
-public class TableHeaderRow<S> extends StackPane {
+public class TableHeaderRow extends StackPane {
     
     private static final String MENU_SEPARATOR = 
             ControlResources.getString("TableView.nestedColumnControlMenuSeparator");
     
     private final VirtualFlow flow;
     VirtualFlow getVirtualFlow() { return flow; }
-    private final TableView<S> table;
+    private final TableView<?> table;
 
     private Insets tablePadding;
     public void setTablePadding(Insets tablePadding) {
@@ -185,7 +184,7 @@
      *                                                                         *
      **************************************************************************/
     
-    public TableHeaderRow(final TableView<S> table, final VirtualFlow flow) {
+    public TableHeaderRow(final TableView<?> table, final VirtualFlow flow) {
         this.table = table;
         this.flow = flow;
 
@@ -212,18 +211,13 @@
 
         updateTableWidth();
         table.widthProperty().addListener(weakTableWidthListener);
-        
-        ObservableList<TableColumn<S,?>> visibleLeafColumns = table.getVisibleLeafColumns();
-        weakVisibleLeafColumnsListener = new WeakListChangeListener(visibleLeafColumns, visibleLeafColumnsListener);
-        visibleLeafColumns.addListener(weakVisibleLeafColumnsListener);
+        table.getVisibleLeafColumns().addListener(weakVisibleLeafColumnsListener);
 
         // --- popup menu for hiding/showing columns
         columnPopupMenu = new ContextMenu();
 
-        ObservableList<TableColumn<S,?>> columns = table.getColumns();
-        updateTableColumnListeners(columns, Collections.<TableColumn<?,?>>emptyList());
-        weakTableColumnsListener = new WeakListChangeListener(columns, tableColumnsListener);
-        columns.addListener(weakTableColumnsListener);
+        updateTableColumnListeners(table.getColumns(), Collections.<TableColumn<?,?>>emptyList());
+        table.getColumns().addListener(weakTableColumnsListener);
         // --- end of popup menu
 
         // drag header region. Used to indicate the current column being reordered
@@ -321,9 +315,11 @@
     private final WeakInvalidationListener weakTableWidthListener = 
             new WeakInvalidationListener(tableWidthListener);
     
-    private final WeakListChangeListener weakVisibleLeafColumnsListener;
+    private final WeakListChangeListener weakVisibleLeafColumnsListener =
+            new WeakListChangeListener(visibleLeafColumnsListener);
     
-    private final WeakListChangeListener weakTableColumnsListener;
+    private final WeakListChangeListener weakTableColumnsListener =
+            new WeakListChangeListener(tableColumnsListener);
     
 
     private Map<TableColumn, CheckMenuItem> columnMenuItems = new HashMap<TableColumn, CheckMenuItem>();
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkin.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkin.java	Fri Aug 17 11:55:07 2012 +1200
@@ -37,7 +37,7 @@
 import javafx.scene.control.TableView;
 
 import com.sun.javafx.scene.control.behavior.CellBehaviorBase;
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import javafx.collections.ObservableList;
 import javafx.geometry.Insets;
 import javafx.scene.Node;
@@ -140,8 +140,8 @@
             throw new IllegalStateException("TableRow not have the TableView property set");
         }
         
-        ObservableList<TableColumn<T,?>> visibleLeafColumns = getSkinnable().getTableView().getVisibleLeafColumns();
-        visibleLeafColumns.addListener(new WeakListChangeListener(visibleLeafColumns, visibleLeafColumnsListener));
+        getSkinnable().getTableView().getVisibleLeafColumns().addListener(
+                new WeakListChangeListener(visibleLeafColumnsListener));
     }
     
     private void doUpdateCheck() {
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkin.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkin.java	Fri Aug 17 11:55:07 2012 +1200
@@ -49,7 +49,7 @@
 import javafx.util.Callback;
 
 import com.sun.javafx.scene.control.behavior.TableViewBehavior;
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import com.sun.javafx.scene.control.skin.resources.ControlResources;
 import javafx.beans.WeakInvalidationListener;
 import javafx.beans.value.WeakChangeListener;
@@ -125,9 +125,7 @@
             }
         });
 
-        ObservableList<TableColumn<T, ?>> visibleLeafColumns = tableView.getVisibleLeafColumns();
-        weakVisibleLeafColumnsListener = new WeakListChangeListener<TableColumn<T,?>>(visibleLeafColumns, visibleLeafColumnsListener);
-        visibleLeafColumns.addListener(weakVisibleLeafColumnsListener);
+        tableView.getVisibleLeafColumns().addListener(weakVisibleLeafColumnsListener);
         
         updateTableItems(null, tableView.getItems());
         tableView.itemsProperty().addListener(weakItemsChangeListener);
@@ -252,8 +250,10 @@
             }
     };
     
-    private WeakListChangeListener<T> weakRowCountListener;
-    private WeakListChangeListener<TableColumn<T,?>> weakVisibleLeafColumnsListener;
+    private WeakListChangeListener<T> weakRowCountListener =
+            new WeakListChangeListener<T>(rowCountListener);
+    private WeakListChangeListener<TableColumn<T,?>> weakVisibleLeafColumnsListener =
+            new WeakListChangeListener<TableColumn<T,?>>(visibleLeafColumnsListener);
     private WeakInvalidationListener weakWidthListener = 
             new WeakInvalidationListener(widthListener);
     private WeakChangeListener<ObservableList<T>> weakItemsChangeListener = 
@@ -530,12 +530,11 @@
      **************************************************************************/
     
     public void updateTableItems(ObservableList<T> oldList, ObservableList<T> newList) {
-        if (oldList != null && weakRowCountListener != null) {
+        if (oldList != null) {
             oldList.removeListener(weakRowCountListener);
         }
 
         if (newList != null) {
-            weakRowCountListener = new WeakListChangeListener<T>(newList, rowCountListener);
             newList.addListener(weakRowCountListener);
         }
 
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeTableRowSkin.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeTableRowSkin.java	Fri Aug 17 11:55:07 2012 +1200
@@ -43,7 +43,7 @@
 import com.sun.javafx.css.StyleableDoubleProperty;
 import com.sun.javafx.css.StyleableProperty;
 import com.sun.javafx.css.converters.SizeConverter;
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import com.sun.javafx.scene.control.behavior.CellBehaviorBase;
 import com.sun.javafx.scene.control.behavior.TreeTableRowBehavior;
 import javafx.beans.value.WritableValue;
@@ -472,8 +472,8 @@
             throw new IllegalStateException("TableRow not have the TableView property set");
         }
         
-        ObservableList<TableColumn<T,?>> visibleLeafColumns = getSkinnable().getTableView().getVisibleLeafColumns();
-        visibleLeafColumns.addListener(new WeakListChangeListener(visibleLeafColumns, visibleLeafColumnsListener));
+        getSkinnable().getTableView().getVisibleLeafColumns().addListener(
+                new WeakListChangeListener(visibleLeafColumnsListener));
     }
     
     private void doUpdateCheck() {
--- a/javafx-ui-controls/src/javafx/scene/control/ComboBox.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/javafx/scene/control/ComboBox.java	Fri Aug 17 11:55:07 2012 +1200
@@ -27,7 +27,7 @@
 
 import com.sun.javafx.event.EventDispatchChainImpl;
 import com.sun.javafx.scene.control.FocusableTextField;
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import com.sun.javafx.scene.control.skin.ComboBoxListViewSkin;
 import javafx.beans.InvalidationListener;
 import javafx.beans.Observable;
@@ -459,10 +459,8 @@
              */
 
             this.comboBox.itemsProperty().addListener(weakItemsObserver);
-            ObservableList<T> items = this.comboBox.getItems();
-            if (items != null) {
-                weakItemsContentObserver = new WeakListChangeListener(items, itemsContentObserver);
-                items.addListener(weakItemsContentObserver);
+            if (comboBox.getItems() != null) {
+                this.comboBox.getItems().addListener(weakItemsContentObserver);
             }
         }
         
@@ -501,19 +499,18 @@
             }
         };
         
-        private WeakListChangeListener weakItemsContentObserver;
+        private WeakListChangeListener weakItemsContentObserver =
+                new WeakListChangeListener(itemsContentObserver);
         
         private WeakChangeListener weakItemsObserver = 
                 new WeakChangeListener(itemsObserver);
         
         private void updateItemsObserver(ObservableList<T> oldList, ObservableList<T> newList) {
             // update listeners
-            if (oldList != null && weakItemsContentObserver != null) {
+            if (oldList != null) {
                 oldList.removeListener(weakItemsContentObserver);
             }
-            
             if (newList != null) {
-                weakItemsContentObserver = new WeakListChangeListener(newList, itemsContentObserver);
                 newList.addListener(weakItemsContentObserver);
             }
 
@@ -535,4 +532,8 @@
             return items == null ? 0 : items.size();
         }
     }
+    
+    
+    
+    
 }
--- a/javafx-ui-controls/src/javafx/scene/control/ListCell.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/javafx/scene/control/ListCell.java	Fri Aug 17 11:55:07 2012 +1200
@@ -26,16 +26,19 @@
 package javafx.scene.control;
 
 import com.sun.javafx.logging.PlatformLogger;
+import com.sun.javafx.scene.control.Logging;
 import javafx.beans.InvalidationListener;
 import javafx.beans.Observable;
 import javafx.beans.WeakInvalidationListener;
+import javafx.beans.property.ReadOnlyObjectProperty;
+import javafx.beans.property.ReadOnlyObjectWrapper;
 import javafx.beans.value.ChangeListener;
 import javafx.beans.value.ObservableValue;
 import javafx.beans.value.WeakChangeListener;
 import javafx.collections.ListChangeListener;
 import javafx.collections.ObservableList;
 
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import java.lang.ref.WeakReference;
 import java.util.List;
 import javafx.beans.property.ReadOnlyObjectProperty;
@@ -147,11 +150,10 @@
         @Override public void changed(ObservableValue observable,
                                       MultipleSelectionModel oldValue,
                                       MultipleSelectionModel newValue) {
-            if (oldValue != null && weakSelectedListener != null) {
+            if (oldValue != null) {
                 oldValue.getSelectedIndices().removeListener(weakSelectedListener);
             }
             if (newValue != null) {
-                weakSelectedListener = new WeakListChangeListener(newValue.getSelectedIndices(), selectedListener);
                 newValue.getSelectedIndices().addListener(weakSelectedListener);
             }
             updateSelection();
@@ -176,11 +178,10 @@
         @Override public void changed(ObservableValue observable,
                                       ObservableList oldValue,
                                       ObservableList newValue) {
-            if (oldValue != null && weakItemsListener != null) {
+            if (oldValue != null) {
                 oldValue.removeListener(weakItemsListener);
             }
             if (newValue != null) {
-                weakItemsListener = new WeakListChangeListener(newValue, itemsListener);
                 newValue.addListener(weakItemsListener);
             }
             updateItem();
@@ -215,11 +216,11 @@
         }
     };
 
-    private WeakListChangeListener weakSelectedListener;
-    private WeakListChangeListener weakItemsListener;
-    
+
     private final WeakInvalidationListener weakEditingListener = new WeakInvalidationListener(editingListener);
+    private final WeakListChangeListener weakSelectedListener = new WeakListChangeListener(selectedListener);
     private final WeakChangeListener weakSelectionModelPropertyListener = new WeakChangeListener(selectionModelPropertyListener);
+    private final WeakListChangeListener weakItemsListener = new WeakListChangeListener(itemsListener);
     private final WeakChangeListener weakItemsPropertyListener = new WeakChangeListener(itemsPropertyListener);
     private final WeakInvalidationListener weakFocusedListener = new WeakInvalidationListener(focusedListener);
     private final WeakChangeListener weakFocusModelPropertyListener = new WeakChangeListener(focusModelPropertyListener);
@@ -278,7 +279,6 @@
             if (currentListView != null) {
                 final MultipleSelectionModel sm = currentListView.getSelectionModel();
                 if (sm != null) {
-                    weakSelectedListener = new WeakListChangeListener(sm.getSelectedIndices(), selectedListener);
                     sm.getSelectedIndices().addListener(weakSelectedListener);
                 }
 
@@ -289,7 +289,6 @@
 
                 final ObservableList items = currentListView.getItems();
                 if (items != null) {
-                    weakItemsListener = new WeakListChangeListener(items, itemsListener);
                     items.addListener(weakItemsListener);
                 }
 
--- a/javafx-ui-controls/src/javafx/scene/control/ListView.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/javafx/scene/control/ListView.java	Fri Aug 17 11:55:07 2012 +1200
@@ -56,7 +56,7 @@
 import com.sun.javafx.css.StyleableProperty;
 import com.sun.javafx.css.converters.EnumConverter;
 import com.sun.javafx.event.EventTypeUtil;
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import com.sun.javafx.scene.control.skin.ListViewSkin;
 import com.sun.javafx.scene.control.skin.VirtualContainerBase;
 import java.lang.ref.WeakReference;
@@ -914,10 +914,9 @@
              */
 
             this.listView.itemsProperty().addListener(weakItemsObserver);
-            ObservableList<T> items = this.listView.getItems();
-            if (items != null) {
-                weakItemsContentObserver = new WeakListChangeListener(items, itemsContentObserver);
-                items.addListener(weakItemsContentObserver);
+            if (listView.getItems() != null) {
+                this.listView.getItems().addListener(weakItemsContentObserver);
+//                updateItemsObserver(null, this.listView.getItems());
             }
             
             updateItemCount();
@@ -953,19 +952,18 @@
             }
         };
         
-        private WeakListChangeListener weakItemsContentObserver;
+        private WeakListChangeListener weakItemsContentObserver =
+                new WeakListChangeListener(itemsContentObserver);
         
         private WeakChangeListener weakItemsObserver = 
                 new WeakChangeListener(itemsObserver);
         
         private void updateItemsObserver(ObservableList<T> oldList, ObservableList<T> newList) {
             // update listeners
-            if (oldList != null && weakItemsContentObserver != null) {
+            if (oldList != null) {
                 oldList.removeListener(weakItemsContentObserver);
             }
-            
             if (newList != null) {
-                weakItemsContentObserver = new WeakListChangeListener(newList, itemsContentObserver);
                 newList.addListener(weakItemsContentObserver);
             }
             
@@ -1152,10 +1150,9 @@
             }
 
             this.listView = listView;
-            ObservableList<T> items = this.listView.getItems();
-            if (items != null) {
-                weakItemsContentListener = new WeakListChangeListener(items, itemsContentListener);
-                items.addListener(weakItemsContentListener);
+            this.listView.itemsProperty().addListener(weakItemsListener);
+            if (listView.getItems() != null) {
+                this.listView.getItems().addListener(weakItemsContentListener);
             }
             
             updateItemCount();
@@ -1175,14 +1172,8 @@
         private void updateItemsObserver(ObservableList<T> oldList, ObservableList<T> newList) {
             // the listview items list has changed, we need to observe
             // the new list, and remove any observer we had from the old list
-            if (oldList != null && weakItemsContentListener != null) {
-                oldList.removeListener(weakItemsContentListener);
-            }
-            
-            if (newList != null) {
-                weakItemsContentListener = new WeakListChangeListener<T>(newList, itemsContentListener);
-                newList.addListener(weakItemsContentListener);
-            }
+            if (oldList != null) oldList.removeListener(weakItemsContentListener);
+            if (newList != null) newList.addListener(weakItemsContentListener);
             
             updateItemCount();
         }
@@ -1220,7 +1211,8 @@
             }
         };
         
-        private WeakListChangeListener<T> weakItemsContentListener;
+        private WeakListChangeListener<T> weakItemsContentListener 
+                = new WeakListChangeListener<T>(itemsContentListener);
         
         @Override protected int getItemCount() {
             return itemCount;
--- a/javafx-ui-controls/src/javafx/scene/control/TableCell.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/javafx/scene/control/TableCell.java	Fri Aug 17 11:55:07 2012 +1200
@@ -35,11 +35,10 @@
 import javafx.scene.control.TableView.TableViewFocusModel;
 
 import com.sun.javafx.property.PropertyReference;
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import java.lang.ref.WeakReference;
 import javafx.beans.property.ReadOnlyObjectProperty;
 import javafx.beans.property.ReadOnlyObjectWrapper;
-import javafx.collections.ObservableList;
 
 import javafx.scene.control.TableColumn.CellEditEvent;
 
@@ -124,16 +123,16 @@
         }
     };
     
-    private WeakListChangeListener weakSelectedListener;
-    private WeakListChangeListener weakVisibleLeafColumnsListener;
-    
+    private final WeakListChangeListener weakSelectedListener = 
+            new WeakListChangeListener(selectedListener);
     private final WeakInvalidationListener weakFocusedListener = 
             new WeakInvalidationListener(focusedListener);
     private final WeakInvalidationListener weaktableRowUpdateObserver = 
             new WeakInvalidationListener(tableRowUpdateObserver);
     private final WeakInvalidationListener weakEditingListener = 
             new WeakInvalidationListener(editingListener);
-    
+    private final WeakListChangeListener weakVisibleLeafColumnsListener =
+            new WeakListChangeListener(visibleLeafColumnsListener);
 
     
     /***************************************************************************
@@ -192,7 +191,7 @@
                         TableView<S> oldTableView = weakTableViewRef.get();
                         if (oldTableView != null) {
                             sm = oldTableView.getSelectionModel();
-                            if (sm != null && weakSelectedListener != null) {
+                            if (sm != null) {
                                 sm.getSelectedCells().removeListener(weakSelectedListener);
                             }
 
@@ -202,19 +201,14 @@
                             }
 
                             oldTableView.editingCellProperty().removeListener(weakEditingListener);
-                            
-                            if (weakVisibleLeafColumnsListener != null) {
-                                oldTableView.getVisibleLeafColumns().removeListener(weakVisibleLeafColumnsListener);
-                            }
+                            oldTableView.getVisibleLeafColumns().removeListener(weakVisibleLeafColumnsListener);
                         }
                     }
                     
                     if (get() != null) {
                         sm = get().getSelectionModel();
                         if (sm != null) {
-                            ObservableList<TablePosition> selectedCells = sm.getSelectedCells();
-                            weakSelectedListener = new WeakListChangeListener(selectedCells, selectedListener);
-                            selectedCells.addListener(weakSelectedListener);
+                            sm.getSelectedCells().addListener(weakSelectedListener);
                         }
 
                         fm = get().getFocusModel();
@@ -223,10 +217,7 @@
                         }
 
                         get().editingCellProperty().addListener(weakEditingListener);
-                        
-                        ObservableList<TableColumn<S,?>> visibleLeafColumns = get().getVisibleLeafColumns();
-                        weakVisibleLeafColumnsListener = new WeakListChangeListener(visibleLeafColumns, visibleLeafColumnsListener);
-                        visibleLeafColumns.addListener(weakVisibleLeafColumnsListener);
+                        get().getVisibleLeafColumns().addListener(weakVisibleLeafColumnsListener);
                         
                         weakTableViewRef = new WeakReference<TableView<S>>(get());
                     }
--- a/javafx-ui-controls/src/javafx/scene/control/TableColumn.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/javafx/scene/control/TableColumn.java	Fri Aug 17 11:55:07 2012 +1200
@@ -54,7 +54,7 @@
 import com.sun.javafx.scene.control.skin.Utils;
 import com.sun.javafx.event.EventHandlerManager;
 import com.sun.javafx.event.EventTypeUtil;
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import com.sun.javafx.scene.control.skin.*;
 import java.util.Collections;
 import java.util.HashMap;
@@ -281,7 +281,6 @@
         // we listen to the columns list here to ensure that widths are
         // maintained properly, and to also set the column hierarchy such that
         // all children columns know that this TableColumn is their parent.
-        weakColumnsListener = new WeakListChangeListener(getColumns(), columnsListener);
         getColumns().addListener(weakColumnsListener);
 
         tableViewProperty().addListener(new InvalidationListener() {
@@ -380,7 +379,8 @@
         }
     };
     
-    private final WeakListChangeListener weakColumnsListener;
+    private WeakListChangeListener weakColumnsListener = 
+            new WeakListChangeListener(columnsListener);
     
     
     /***************************************************************************
--- a/javafx-ui-controls/src/javafx/scene/control/TableRow.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/javafx/scene/control/TableRow.java	Fri Aug 17 11:55:07 2012 +1200
@@ -30,12 +30,11 @@
 import javafx.collections.ListChangeListener;
 import javafx.scene.control.TableView.TableViewFocusModel;
 
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import java.lang.ref.WeakReference;
 import java.util.List;
 import javafx.beans.property.ReadOnlyObjectProperty;
 import javafx.beans.property.ReadOnlyObjectWrapper;
-import javafx.collections.ObservableList;
 
 /**
  * <p>TableRow is an {@link javafx.scene.control.IndexedCell IndexedCell}, but
@@ -114,7 +113,7 @@
         }
     };
 
-    private WeakListChangeListener weakSelectedListener;
+    private final WeakListChangeListener weakSelectedListener = new WeakListChangeListener(selectedListener);
     private final WeakInvalidationListener weakFocusedListener = new WeakInvalidationListener(focusedListener);
     private final WeakInvalidationListener weakEditingListener = new WeakInvalidationListener(editingListener);
 
@@ -155,7 +154,7 @@
                         TableView oldTableView = weakTableViewRef.get();
                         if (oldTableView != null) {
                             sm = oldTableView.getSelectionModel();
-                            if (sm != null && weakSelectedListener != null) {
+                            if (sm != null) {
                                 sm.getSelectedCells().removeListener(weakSelectedListener);
                             }
 
@@ -173,9 +172,7 @@
                     if (getTableView() != null) {
                         sm = getTableView().getSelectionModel();
                         if (sm != null) {
-                            ObservableList<TablePosition> selectedCells = sm.getSelectedCells();
-                            weakSelectedListener = new WeakListChangeListener(selectedCells, selectedListener);
-                            selectedCells.addListener(weakSelectedListener);
+                            sm.getSelectedCells().addListener(weakSelectedListener);
                         }
 
                         fm = getTableView().getFocusModel();
--- a/javafx-ui-controls/src/javafx/scene/control/TableView.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/javafx/scene/control/TableView.java	Fri Aug 17 11:55:07 2012 +1200
@@ -54,10 +54,9 @@
 
 import com.sun.javafx.collections.annotations.ReturnsUnmodifiableCollection;
 import com.sun.javafx.css.StyleManager;
-import com.sun.javafx.css.StyleableProperty;
 import com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList;
 import com.sun.javafx.scene.control.TableColumnComparator;
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import com.sun.javafx.scene.control.skin.TableViewSkin;
 import com.sun.javafx.scene.control.skin.VirtualContainerBase;
 import java.lang.ref.WeakReference;
@@ -805,7 +804,7 @@
             new WeakInvalidationListener(columnSortTypeObserver);
     
     private final WeakListChangeListener weakColumnsObserver = 
-            new WeakListChangeListener(getColumns(), columnsObserver);
+            new WeakListChangeListener(columnsObserver);
     
     /***************************************************************************
      *                                                                         *
@@ -1771,10 +1770,8 @@
             tableView.itemsProperty().addListener(weakItemsPropertyListener);
             
             // watching for changes to the items list content
-            ObservableList<S> items = this.tableView.getItems();
-            if (items != null) {
-                weakItemsContentListener = new WeakListChangeListener(items, itemsContentListener);
-                items.addListener(weakItemsContentListener);
+            if (tableView.getItems() != null) {
+                tableView.getItems().addListener(weakItemsContentListener);
             }
         }
         
@@ -1805,16 +1802,16 @@
             }
         };
         
-        private WeakListChangeListener weakItemsContentListener;
+        final WeakListChangeListener weakItemsContentListener 
+                = new WeakListChangeListener(itemsContentListener);
         
         private void updateItemsObserver(ObservableList<S> oldList, ObservableList<S> newList) {
             // the listview items list has changed, we need to observe
             // the new list, and remove any observer we had from the old list
-            if (oldList != null && weakItemsContentListener != null) {
+            if (oldList != null) {
                 oldList.removeListener(weakItemsContentListener);
             }
             if (newList != null) {
-                weakItemsContentListener = new WeakListChangeListener(newList, itemsContentListener);
                 newList.addListener(weakItemsContentListener);
             }
 
@@ -2395,10 +2392,8 @@
             this.tableView = tableView;
             
             this.tableView.itemsProperty().addListener(weakItemsPropertyListener);
-            ObservableList<S> items = this.tableView.getItems();
-            if (items != null) {
-                weakItemsContentListener = new WeakListChangeListener(items, itemsContentListener);
-                items.addListener(weakItemsContentListener);
+            if (tableView.getItems() != null) {
+                this.tableView.getItems().addListener(weakItemsContentListener);
             }
 
             TablePosition pos = new TablePosition(tableView, -1, null);
@@ -2442,18 +2437,14 @@
             }
         };
         
-        private WeakListChangeListener<S> weakItemsContentListener;
+        private WeakListChangeListener<S> weakItemsContentListener 
+                = new WeakListChangeListener<S>(itemsContentListener);
         
         private void updateItemsObserver(ObservableList<S> oldList, ObservableList<S> newList) {
             // the tableview items list has changed, we need to observe
             // the new list, and remove any observer we had from the old list
-            if (oldList != null && weakItemsContentListener != null) {
-                oldList.removeListener(weakItemsContentListener);
-            }
-            if (newList != null) {
-                weakItemsContentListener = new WeakListChangeListener<S>(newList, itemsContentListener);
-                newList.addListener(weakItemsContentListener);
-            }
+            if (oldList != null) oldList.removeListener(weakItemsContentListener);
+            if (newList != null) newList.addListener(weakItemsContentListener);
         }
 
         /** {@inheritDoc} */
--- a/javafx-ui-controls/src/javafx/scene/control/TreeCell.java	Thu Aug 16 14:36:43 2012 -0700
+++ b/javafx-ui-controls/src/javafx/scene/control/TreeCell.java	Fri Aug 17 11:55:07 2012 +1200
@@ -32,14 +32,13 @@
 import javafx.collections.ListChangeListener;
 import javafx.scene.Node;
 import com.sun.javafx.css.StyleManager;
-import com.sun.javafx.scene.control.WeakListChangeListener;
+import javafx.collections.WeakListChangeListener;
 import java.lang.ref.WeakReference;
 import javafx.beans.property.ReadOnlyObjectProperty;
 import javafx.beans.property.ReadOnlyObjectWrapper;
 import javafx.beans.value.ChangeListener;
 import javafx.beans.value.ObservableValue;
 import javafx.beans.value.WeakChangeListener;
-import javafx.collections.ObservableList;
 
 /**
  * The {@link Cell} type used with the {@link TreeView} control. In addition to 
@@ -153,7 +152,7 @@
         }
     };
     
-    private WeakListChangeListener weakSelectedListener;
+    private final WeakListChangeListener weakSelectedListener = new WeakListChangeListener(selectedListener);
     private final WeakChangeListener weakSelectionModelPropertyListener = new WeakChangeListener(selectionModelPropertyListener);
     private final WeakInvalidationListener weakFocusedListener = new WeakInvalidationListener(focusedListener);
     private final WeakChangeListener weakFocusModelPropertyListener = new WeakChangeListener(focusModelPropertyListener);
@@ -244,9 +243,7 @@
                 if (sm != null) {
                     // listening for changes to treeView.selectedIndex and IndexedCell.index,
                     // to determine if this cell is selected
-                    ObservableList<Integer> selectedIndices = sm.getSelectedIndices();
-                    weakSelectedListener = new WeakListChangeListener(selectedIndices, selectedListener);
-                    selectedIndices.addListener(weakSelectedListener);
+                    sm.getSelectedIndices().addListener(weakSelectedListener);
                 }
 
                 fm = get().getFocusModel();