changeset 5185:5a67a3c94fee

RT-29334 : Split pane doesn't change its rendering after items has changed order, reviewed by David
author mickf
date Tue, 01 Oct 2013 14:38:27 +0100
parents 5475dfc3d98a
children 8319071566e7
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/SplitPaneSkin.java
diffstat 1 files changed, 20 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/SplitPaneSkin.java	Tue Oct 01 13:13:03 2013 +0100
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/SplitPaneSkin.java	Tue Oct 01 14:38:27 2013 +0100
@@ -97,13 +97,27 @@
         getSkinnable().getItems().addListener(new ListChangeListener<Node>() {
             @Override public void onChanged(Change<? extends Node> c) {
                 while (c.next()) {
-                    for (Node n : c.getRemoved()) {
-                        removeContent(n);
-                    }
+                    if (c.wasPermutated() || c.wasUpdated()) {
+                        /**
+                         * the contents were either moved, or updated.
+                         * rebuild the contents to re-sync
+                         */
+                        getChildren().clear();
+                        contentRegions.clear();
+                        int index = 0;
+                        for (Node n : c.getList()) {
+                            addContent(index++, n);
+                        }
 
-                    int index = c.getFrom();
-                    for (Node n : c.getAddedSubList()) {
-                        addContent(index++, n);
+                    } else {
+                        for (Node n : c.getRemoved()) {
+                            removeContent(n);
+                        }
+
+                        int index = c.getFrom();
+                        for (Node n : c.getAddedSubList()) {
+                            addContent(index++, n);
+                        }
                     }
                 }
                 // TODO there may be a more efficient way than rebuilding all the dividers