Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2016-06-22 01:07:24 +0000
committerTom Schindl2016-06-22 01:07:24 +0000
commit5ad219b28badc0a70170c64478e206af7d726297 (patch)
tree80be335fab927ec273ac1c6ed7b6e62b8a3c64ec /bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding
parentc5c5f2db2f1eddb354c4501cc13edea5d3176d1a (diff)
downloadorg.eclipse.efxclipse-5ad219b28badc0a70170c64478e206af7d726297.tar.gz
org.eclipse.efxclipse-5ad219b28badc0a70170c64478e206af7d726297.tar.xz
org.eclipse.efxclipse-5ad219b28badc0a70170c64478e206af7d726297.zip
Bug 496516 - TreeUtil#createModel is buggy
Diffstat (limited to 'bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding')
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/TreeUtil.java25
1 files changed, 16 insertions, 9 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/TreeUtil.java b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/TreeUtil.java
index f1f4ccbed..d14f6cd0a 100755
--- a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/TreeUtil.java
+++ b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/TreeUtil.java
@@ -20,7 +20,6 @@ import org.eclipse.core.databinding.observable.list.ListChangeEvent;
import org.eclipse.core.databinding.observable.list.ListDiffVisitor;
import org.eclipse.jdt.annotation.NonNull;
-import javafx.beans.value.ChangeListener;
import javafx.collections.ObservableList;
import javafx.scene.control.TreeItem;
@@ -30,7 +29,7 @@ import javafx.scene.control.TreeItem;
public class TreeUtil {
/**
* Create a tree model backed by the given {@link ObservableFactory}
- *
+ *
* @param root
* the root of the model
* @param factory
@@ -46,14 +45,14 @@ public class TreeUtil {
/**
* Factory to create child observables
- *
+ *
* @param <T>
* the type
*/
public interface ObservableFactory<T> {
/**
* Create an observable list for the parent element
- *
+ *
* @param parent
* the parent
* @return the list
@@ -72,7 +71,7 @@ public class TreeUtil {
this.factory = factory;
this.list = factory.createObservable(element);
getChildren().add(new TreeItem<>());
-
+
expandedProperty().addListener((o) -> {
if( isExpanded() ) {
if( ! this.hasLoadedChildren ) {
@@ -81,7 +80,7 @@ public class TreeUtil {
}
});
}
-
+
// @Override
// public ObservableList<TreeItem<T>> getChildren() {
// if (this.hasLoadedChildren == false) {
@@ -89,7 +88,7 @@ public class TreeUtil {
// }
// return super.getChildren();
// }
-
+
// @Override
// public boolean isLeaf() {
// if( this.hasLoadedChildren ) {
@@ -143,18 +142,26 @@ public class TreeUtil {
itemList.add(new TreeItemImpl<@NonNull T>((T) element, TreeItemImpl.this.factory));
}
}
+
+ @Override
+ public void handleMove(int oldIndex, int newIndex, Object element) {
+ TreeItem<T> item = getChildren().remove(oldIndex);
+ getChildren().add(newIndex,item);
+ }
});
}
});
List<TreeItemImpl<@NonNull T>> l = new ArrayList<>(this.list.size());
-
+
for (Object o : this.list) {
@SuppressWarnings("unchecked")
T t = (T) o;
l.add(new TreeItemImpl<@NonNull T>(t, this.factory));
}
-
+
itemList.setAll(l);
+ } else {
+ getChildren().clear();
}
}

Back to the top