missing support:
- changes with subchanged (f.i. discontinous removes/adds)
- permutations
Without, there's no way interested client code can keep state related to current locations of items. Examples of how internal code suffers from the omissing is selectedIndices/selectedItems of TreeView. (Which currently might not be claringly obvious because all internal implementations of selection models are incorrect in respect to multiple subchanges, tree selection bugs show the same symptoms). While the list-based models can be implemented correctly (see f.i. IndicesList/IndexedItems in my git), the tree-based can't.
Some pseudo-code snippets:
// expect a single notification because ...
@Test
public void testChildEventDiscontinousRemoved() {
IntegerProperty p = new SimpleIntegerProperty(0);
EventHandler<TreeModificationEvent> l = e -> {
assertTrue(e.wasRemoved());
p.set(p.get() + 1);
};
treeItem.addEventHandler(TreeItem.childrenModificationEvent(), l);
children.removeAll(children.get(2), children.get(5));
assertEquals("received singe removed", 1, p.get());
}
// without single notification can't safely update stored indices
@Test
public void testChildEventSubChanges() {
// simulate external storage of last index
IntegerProperty p = new SimpleIntegerProperty(children.size()-1);
EventHandler<TreeModificationEvent> l = e -> {
assertTrue("sanity: got a removed", e.wasRemoved());
// adjust index: fine for single subChange
p.set(p.get() - e.getRemovedSize());
// this must be valid but isn't because it's the first
// of a sequence of separate notifications
children.get(p.get());
};
treeItem.addEventHandler(TreeItem.childrenModificationEvent(), l);
children.removeAll(children.get(2), children.get(5));
}
// no way to update index-based state after sorting
@Test
public void testChildEventPermutated() {
EventHandler<TreeModificationEvent> l = e -> {
assertTrue("sanity: got a permutated", e.wasPermutated());
// now how to get the permutation indices?
};
treeItem.addEventHandler(TreeItem.childrenModificationEvent(), l);
Comparator<TreeItem<String>> c = (TreeItem<String> o1, TreeItem<String> o2)
-> o1.getValue().compareTo(o2.getValue());
children.sort((Comparator<? super TreeItem>) c);
}
- changes with subchanged (f.i. discontinous removes/adds)
- permutations
Without, there's no way interested client code can keep state related to current locations of items. Examples of how internal code suffers from the omissing is selectedIndices/selectedItems of TreeView. (Which currently might not be claringly obvious because all internal implementations of selection models are incorrect in respect to multiple subchanges, tree selection bugs show the same symptoms). While the list-based models can be implemented correctly (see f.i. IndicesList/IndexedItems in my git), the tree-based can't.
Some pseudo-code snippets:
// expect a single notification because ...
@Test
public void testChildEventDiscontinousRemoved() {
IntegerProperty p = new SimpleIntegerProperty(0);
EventHandler<TreeModificationEvent> l = e -> {
assertTrue(e.wasRemoved());
p.set(p.get() + 1);
};
treeItem.addEventHandler(TreeItem.childrenModificationEvent(), l);
children.removeAll(children.get(2), children.get(5));
assertEquals("received singe removed", 1, p.get());
}
// without single notification can't safely update stored indices
@Test
public void testChildEventSubChanges() {
// simulate external storage of last index
IntegerProperty p = new SimpleIntegerProperty(children.size()-1);
EventHandler<TreeModificationEvent> l = e -> {
assertTrue("sanity: got a removed", e.wasRemoved());
// adjust index: fine for single subChange
p.set(p.get() - e.getRemovedSize());
// this must be valid but isn't because it's the first
// of a sequence of separate notifications
children.get(p.get());
};
treeItem.addEventHandler(TreeItem.childrenModificationEvent(), l);
children.removeAll(children.get(2), children.get(5));
}
// no way to update index-based state after sorting
@Test
public void testChildEventPermutated() {
EventHandler<TreeModificationEvent> l = e -> {
assertTrue("sanity: got a permutated", e.wasPermutated());
// now how to get the permutation indices?
};
treeItem.addEventHandler(TreeItem.childrenModificationEvent(), l);
Comparator<TreeItem<String>> c = (TreeItem<String> o1, TreeItem<String> o2)
-> o1.getValue().compareTo(o2.getValue());
children.sort((Comparator<? super TreeItem>) c);
}
- relates to
-
JDK-8094602 [TreeItem] Incompatible API change to TreeItem$TreeModificationEvent constructor
- Resolved
-
JDK-8096243 [ListView] Removing multiple items including the selected item leads to inconsistent and wrong selection state
- Resolved
-
JDK-8248217 ☂ TreeTableView selection issues
- Open
-
JDK-8199324 IllegalStateException: Not a permutation change in TreeTableView when selection is active
- Open
-
JDK-8193800 TreeTableView selection changes on sorting
- Resolved