diff options
author | Tom Schindl | 2017-02-08 22:12:55 +0000 |
---|---|---|
committer | Tom Schindl | 2017-02-08 22:12:55 +0000 |
commit | 18e5434cd5d1710f893558e2e826a97027a3de1a (patch) | |
tree | c3d4866b5c5eab00bf61154d24f376c451e8b23d | |
parent | bc7bd1b7b3a2ce10e5c804e977c5c868d19ce8c5 (diff) | |
download | org.eclipse.efxclipse-18e5434cd5d1710f893558e2e826a97027a3de1a.tar.gz org.eclipse.efxclipse-18e5434cd5d1710f893558e2e826a97027a3de1a.tar.xz org.eclipse.efxclipse-18e5434cd5d1710f893558e2e826a97027a3de1a.zip |
started adding a segmented list
-rw-r--r-- | bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/bindings/FXBindings.java | 113 |
1 files changed, 94 insertions, 19 deletions
diff --git a/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/bindings/FXBindings.java b/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/bindings/FXBindings.java index 2f9ba78bb..937a19554 100644 --- a/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/bindings/FXBindings.java +++ b/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/bindings/FXBindings.java @@ -33,8 +33,25 @@ import java.util.function.ToLongFunction; import java.util.stream.Collectors; import java.util.stream.IntStream; +import org.eclipse.fx.core.Status; +import org.eclipse.fx.core.Subscription; +import org.eclipse.fx.core.ThreadSynchronize; +import org.eclipse.fx.core.Tuple; +import org.eclipse.fx.core.bindings.internal.BaseBidiPropertyBinding; +import org.eclipse.fx.core.bindings.internal.BindingStreamImpl; +import org.eclipse.fx.core.bindings.internal.ConcatListBinding; +import org.eclipse.fx.core.bindings.internal.ConcatStringBinding; +import org.eclipse.fx.core.bindings.internal.FixListBinding; +import org.eclipse.fx.core.bindings.internal.FlatMapListBinding; +import org.eclipse.fx.core.bindings.internal.FlatMapValueListBinding; +import org.eclipse.fx.core.bindings.internal.MapListBinding; +import org.eclipse.fx.core.bindings.internal.MapObjectBinding; +import org.eclipse.fx.core.bindings.internal.MapSimpleObjectBinding; +import org.eclipse.fx.core.bindings.internal.SyncListBinding; +import org.eclipse.fx.core.bindings.internal.SyncObjectBinding; +import org.eclipse.fx.core.bindings.internal.TenaryBinding; + import javafx.beans.binding.Binding; -import javafx.beans.binding.BooleanExpression; import javafx.beans.binding.ListBinding; import javafx.beans.binding.ObjectBinding; import javafx.beans.binding.StringBinding; @@ -53,24 +70,6 @@ import javafx.collections.ListChangeListener; import javafx.collections.ListChangeListener.Change; import javafx.collections.ObservableList; -import org.eclipse.fx.core.Status; -import org.eclipse.fx.core.Subscription; -import org.eclipse.fx.core.ThreadSynchronize; -import org.eclipse.fx.core.Tuple; -import org.eclipse.fx.core.bindings.internal.BaseBidiPropertyBinding; -import org.eclipse.fx.core.bindings.internal.BindingStreamImpl; -import org.eclipse.fx.core.bindings.internal.ConcatListBinding; -import org.eclipse.fx.core.bindings.internal.ConcatStringBinding; -import org.eclipse.fx.core.bindings.internal.FixListBinding; -import org.eclipse.fx.core.bindings.internal.FlatMapListBinding; -import org.eclipse.fx.core.bindings.internal.FlatMapValueListBinding; -import org.eclipse.fx.core.bindings.internal.MapListBinding; -import org.eclipse.fx.core.bindings.internal.MapObjectBinding; -import org.eclipse.fx.core.bindings.internal.MapSimpleObjectBinding; -import org.eclipse.fx.core.bindings.internal.SyncListBinding; -import org.eclipse.fx.core.bindings.internal.SyncObjectBinding; -import org.eclipse.fx.core.bindings.internal.TenaryBinding; - /** * Collection of JavaFX bean bindings. * @@ -112,6 +111,82 @@ public class FXBindings { } } +// public static <E> ObservableList<ObservableList<E>> segmentedList(int segmentSize, ObservableList<E> list) { +// ObservableList<ObservableList<E>> rv = FXCollections.observableArrayList(); +// +// ObservableList<E> v = null; +// for( int i = 0; i < list.size(); i++ ) { +// if( i % segmentSize == 0 ) { +// rv.add(v = FXCollections.observableArrayList()); +// } +// if( v != null ) { +// v.add(list.get(i)); +// } +// } +// +// list.addListener( (Change<? extends E> c) -> { +// while( c.next() ) { +// if( c.wasReplaced() || c.wasRemoved() ) { +// for( int i = 0; i < c.getAddedSize(); i++ ) { +// int ii = i + c.getFrom(); +// int listIndex = ii / segmentSize; +// ObservableList<E> target; +// if( rv.size() == listIndex ) { +// rv.add(target = FXCollections.observableArrayList()); +// } else { +// target = rv.get(listIndex); +// } +// +// if( target.size() == ii % segmentSize ) { +// target.add(c.getAddedSubList().get(i)); +// } else { +// target.set(ii % segmentSize, c.getAddedSubList().get(i)); +// } +// } +// +// if( c.getAddedSize() < c.getRemovedSize() ) { +// int removeIdx = -1; +// for( int i = 0; i < c.getRemovedSize() - c.getAddedSize(); i++ ) { +// int ii = i + c.getFrom() + c.getAddedSize(); +// int listIndex = ii / segmentSize; +// if( removeIdx == -1 ) { +// if( ii % segmentSize == 0 ) { +// removeIdx = listIndex; +// } else { +// rv.get(listIndex).remove(ii % segmentSize); +// } +// } +// } +// +// if( removeIdx != -1 ) { +// List<ObservableList<E>> subList = rv.subList(removeIdx, rv.size()); +// List<ObservableList<E>> tmp = new ArrayList<>(subList); +// subList.clear(); +// tmp.forEach( List::clear ); +// } +// } +// } else if( c.wasAdded() ) { +// for( int i = 0; i < c.getAddedSize(); i++ ) { +// int ii = i + c.getFrom(); +// int listIndex = ii / segmentSize; +// ObservableList<E> target; +// if( rv.size() == listIndex ) { +// rv.add(target = FXCollections.observableArrayList()); +// } else { +// target = rv.get(listIndex); +// } +// +// if( target.size() == ii % segmentSize ) { +// target.add(c.getAddedSubList().get(i)); +// } +// } +// } +// } +// }); +// +// return rv; +// } + /** * Create a concatenated list similar to * {@link FXCollections#concat(ObservableList...)} |