-
Bug
-
Resolution: Fixed
-
P4
-
jfx11
at the end of initialization of all subclasses of VirtualContainerBase, the skin and its flow must be configured completely: in particular, the assertion below must be satisfied:
assertEquals(control.getItems().size(), flow.getCellCount());
TableViewSkin is the only one that fails this test (below are fixtures for all). Reason seems to be a missing updateItemCount in its constructor: comparing to the other, that method is called explicitly in ListViewSkin and implicitly for the tree/table/Skin in their setRoot(..).
/**
* bug in TableViewSkin: virtualFlow's cellCount not initialized.
*/
@Test
public void testTableSkinCellCountInitial() {
TableView<Locale> control = new TableView<>(FXCollections.observableArrayList(Locale.getAvailableLocales()));
control.setSkin(new TableViewSkin<>(control) {
{
assertEquals("flow's cellCount must be initialized", control.getItems().size(),
getVirtualFlow().getCellCount());
}
});
}
@Test
public void testTreeTableSkinCellCountInitial() {
List<TreeItem<Locale>> treeItems = Arrays.stream(Locale.getAvailableLocales())
.map(TreeItem::new)
.collect(Collectors.toList());
TreeItem<Locale> root = new TreeItem<>(new Locale("dummy"));
root.setExpanded(true);
root.getChildren().addAll(treeItems);
TreeTableView<Locale> control = new TreeTableView<>(root);
control.setSkin(new TreeTableViewSkin<>(control) {
{
assertEquals("flow's cellCount must be initialized", treeItems.size() + 1,
getVirtualFlow().getCellCount());
}
});
}
@Test
public void testTreeSkinCellCountInitial() {
List<TreeItem<Locale>> treeItems = Arrays.stream(Locale.getAvailableLocales())
.map(TreeItem::new)
.collect(Collectors.toList());
TreeItem<Locale> root = new TreeItem<>(new Locale("dummy"));
root.setExpanded(true);
root.getChildren().addAll(treeItems);
TreeView<Locale> control = new TreeView<>(root);
control.setSkin(new TreeViewSkin<>(control) {
{
assertEquals("flow's cellCount must be initialized", treeItems.size() +1,
getVirtualFlow().getCellCount());
}
});
}
@Test
public void testListSkinCellCountInitial() {
ListView<Locale> control = new ListView<>(FXCollections.observableArrayList(Locale.getAvailableLocales()));
control.setSkin(new ListViewSkin<>(control) {
{
assertEquals("flow's cellCount must be initialized", control.getItems().size(),
getVirtualFlow().getCellCount());
}
});
}
assertEquals(control.getItems().size(), flow.getCellCount());
TableViewSkin is the only one that fails this test (below are fixtures for all). Reason seems to be a missing updateItemCount in its constructor: comparing to the other, that method is called explicitly in ListViewSkin and implicitly for the tree/table/Skin in their setRoot(..).
/**
* bug in TableViewSkin: virtualFlow's cellCount not initialized.
*/
@Test
public void testTableSkinCellCountInitial() {
TableView<Locale> control = new TableView<>(FXCollections.observableArrayList(Locale.getAvailableLocales()));
control.setSkin(new TableViewSkin<>(control) {
{
assertEquals("flow's cellCount must be initialized", control.getItems().size(),
getVirtualFlow().getCellCount());
}
});
}
@Test
public void testTreeTableSkinCellCountInitial() {
List<TreeItem<Locale>> treeItems = Arrays.stream(Locale.getAvailableLocales())
.map(TreeItem::new)
.collect(Collectors.toList());
TreeItem<Locale> root = new TreeItem<>(new Locale("dummy"));
root.setExpanded(true);
root.getChildren().addAll(treeItems);
TreeTableView<Locale> control = new TreeTableView<>(root);
control.setSkin(new TreeTableViewSkin<>(control) {
{
assertEquals("flow's cellCount must be initialized", treeItems.size() + 1,
getVirtualFlow().getCellCount());
}
});
}
@Test
public void testTreeSkinCellCountInitial() {
List<TreeItem<Locale>> treeItems = Arrays.stream(Locale.getAvailableLocales())
.map(TreeItem::new)
.collect(Collectors.toList());
TreeItem<Locale> root = new TreeItem<>(new Locale("dummy"));
root.setExpanded(true);
root.getChildren().addAll(treeItems);
TreeView<Locale> control = new TreeView<>(root);
control.setSkin(new TreeViewSkin<>(control) {
{
assertEquals("flow's cellCount must be initialized", treeItems.size() +1,
getVirtualFlow().getCellCount());
}
});
}
@Test
public void testListSkinCellCountInitial() {
ListView<Locale> control = new ListView<>(FXCollections.observableArrayList(Locale.getAvailableLocales()));
control.setSkin(new ListViewSkin<>(control) {
{
assertEquals("flow's cellCount must be initialized", control.getItems().size(),
getVirtualFlow().getCellCount());
}
});
}
- relates to
-
JDK-8221335 Virtualized controls: add api to support semantic prefHeight computation
- Open
- links to