-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
8
-
8.0b69
Run the code:
TreeTableView<Data> treeTableView;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
treeTableView = new TreeTableView<Data>();
treeTableView.setMaxHeight(100);
treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
treeTableView.setRoot(new TreeItem<Data>(new Data("Root")));
for (int i = 0; i < 30; i++) {
treeTableView.getRoot().getChildren().add(new TreeItem<Data>(new Data("item" + String.valueOf(i))));
}
treeTableView.getRoot().setExpanded(true);
treeTableView.getColumns().add(new TreeTableColumn<Data, String>("Data"));
((TreeTableColumn<Data, String>) treeTableView.getColumns().get(0)).setCellValueFactory(new Callback<CellDataFeatures<Data, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(CellDataFeatures<Data, String> p) {
return p.getValue().getValue().property;
}
});
treeTableView.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue ov, Object t, Object t1) {
System.out.println("selectedIndexProperty : " + t1);
}
});
treeTableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<Data>>() {
@Override
public void changed(ObservableValue<? extends TreeItem<Data>> ov, TreeItem<Data> t, TreeItem<Data> t1) {
System.out.println("selectedItemProperty : " + t1);
}
});
treeTableView.getSelectionModel().getSelectedItems().addListener(new ListChangeListener<TreeItem<Data>>() {
@Override
public void onChanged(Change<? extends TreeItem<Data>> change) {
System.out.println("SelectedItems : " + treeTableView.getSelectionModel().getSelectedItems());
}
});
treeTableView.getFocusModel().focusedIndexProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
System.out.println("focusedIndexProperty : " + t1);
}
});
treeTableView.getFocusModel().focusedItemProperty().addListener(new ChangeListener<TreeItem<Data>>() {
@Override
public void changed(ObservableValue<? extends TreeItem<Data>> ov, TreeItem<Data> t, TreeItem<Data> t1) {
System.out.println("focusedItemProperty : " + t1);
}
});
VBox vb = new VBox();
vb.getChildren().addAll(treeTableView);
Scene scene = new Scene(vb, 300, 300);
stage.setScene(scene);
stage.show();
}
class Data {
public StringProperty property;
public Data(String data) {
property = new SimpleStringProperty(data);
}
@Override
public String toString() {
return property.get();
}
}
Expand all items.
Select some item, and start selecting down: shift + down.
I see:
SelectedItems : [TreeItem [ value: item1 ]]
selectedItemProperty : TreeItem [ value: item1 ]
selectedIndexProperty : 2
focusedItemProperty : TreeItem [ value: item1 ]
focusedIndexProperty : 2
SelectedItems : [TreeItem [ value: item1 ], TreeItem [ value: item1 ], TreeItem [ value: item2 ]]
selectedItemProperty : TreeItem [ value: item2 ]
selectedIndexProperty : 3
focusedItemProperty : TreeItem [ value: item2 ]
focusedIndexProperty : 3
SelectedItems : [TreeItem [ value: item1 ], TreeItem [ value: item1 ], TreeItem [ value: item2 ], TreeItem [ value: item1 ], TreeItem [ value: item3 ]] // <- the same items, but incrementing set.
selectedItemProperty : TreeItem [ value: item3 ]
selectedIndexProperty : 4
focusedItemProperty : TreeItem [ value: item3 ]
focusedIndexProperty : 4
TreeTableView<Data> treeTableView;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
treeTableView = new TreeTableView<Data>();
treeTableView.setMaxHeight(100);
treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
treeTableView.setRoot(new TreeItem<Data>(new Data("Root")));
for (int i = 0; i < 30; i++) {
treeTableView.getRoot().getChildren().add(new TreeItem<Data>(new Data("item" + String.valueOf(i))));
}
treeTableView.getRoot().setExpanded(true);
treeTableView.getColumns().add(new TreeTableColumn<Data, String>("Data"));
((TreeTableColumn<Data, String>) treeTableView.getColumns().get(0)).setCellValueFactory(new Callback<CellDataFeatures<Data, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(CellDataFeatures<Data, String> p) {
return p.getValue().getValue().property;
}
});
treeTableView.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue ov, Object t, Object t1) {
System.out.println("selectedIndexProperty : " + t1);
}
});
treeTableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<Data>>() {
@Override
public void changed(ObservableValue<? extends TreeItem<Data>> ov, TreeItem<Data> t, TreeItem<Data> t1) {
System.out.println("selectedItemProperty : " + t1);
}
});
treeTableView.getSelectionModel().getSelectedItems().addListener(new ListChangeListener<TreeItem<Data>>() {
@Override
public void onChanged(Change<? extends TreeItem<Data>> change) {
System.out.println("SelectedItems : " + treeTableView.getSelectionModel().getSelectedItems());
}
});
treeTableView.getFocusModel().focusedIndexProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
System.out.println("focusedIndexProperty : " + t1);
}
});
treeTableView.getFocusModel().focusedItemProperty().addListener(new ChangeListener<TreeItem<Data>>() {
@Override
public void changed(ObservableValue<? extends TreeItem<Data>> ov, TreeItem<Data> t, TreeItem<Data> t1) {
System.out.println("focusedItemProperty : " + t1);
}
});
VBox vb = new VBox();
vb.getChildren().addAll(treeTableView);
Scene scene = new Scene(vb, 300, 300);
stage.setScene(scene);
stage.show();
}
class Data {
public StringProperty property;
public Data(String data) {
property = new SimpleStringProperty(data);
}
@Override
public String toString() {
return property.get();
}
}
Expand all items.
Select some item, and start selecting down: shift + down.
I see:
SelectedItems : [TreeItem [ value: item1 ]]
selectedItemProperty : TreeItem [ value: item1 ]
selectedIndexProperty : 2
focusedItemProperty : TreeItem [ value: item1 ]
focusedIndexProperty : 2
SelectedItems : [TreeItem [ value: item1 ], TreeItem [ value: item1 ], TreeItem [ value: item2 ]]
selectedItemProperty : TreeItem [ value: item2 ]
selectedIndexProperty : 3
focusedItemProperty : TreeItem [ value: item2 ]
focusedIndexProperty : 3
SelectedItems : [TreeItem [ value: item1 ], TreeItem [ value: item1 ], TreeItem [ value: item2 ], TreeItem [ value: item1 ], TreeItem [ value: item3 ]] // <- the same items, but incrementing set.
selectedItemProperty : TreeItem [ value: item3 ]
selectedIndexProperty : 4
focusedItemProperty : TreeItem [ value: item3 ]
focusedIndexProperty : 4