In previous builds, TableCell.commitEdit() called the handler set in ListView.onEditCommit( handler ).
This is no more the case.
Thanks.
--
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.ListView.EditEvent;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.util.Callback;
public class TableCell extends Application {
ListView<String> list = new ListView<String>();
ObservableList<String> data = FXCollections.observableArrayList(
"chocolate", "salmon", "gold", "coral",
"darkorchid", "darkgoldenrod", "lightsalmon",
"black", "rosybrown", "blue", "blueviolet",
"brown");
final Label label = new Label();
@Override
public void start(Stage stage) {
VBox box = new VBox();
Scene scene = new Scene(box, 200, 200);
stage.setScene(scene);
stage.setTitle("ListViewSample");
box.getChildren().addAll(list, label);
box.setVgrow(list, Priority.ALWAYS);
label.setLayoutX(10);
label.setLayoutY(115);
label.setFont(new Font("Verdana", 20));
list.setItems(data);
list.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {
public ListCell<String> call(ListView<String> p) {
return new EditorCell();
}
});
// The handler
list.setOnEditCommit(new EventHandler<ListView.EditEvent<String>>() {
public void handle(EditEvent<String> event) {
throw new UnsupportedOperationException("Is no longer called!");
}
});
list.setPrefHeight(100);
stage.setVisible(true);
}
public static void main(String[] args) {
Application.launch(args);
}
class EditorCell<T> extends ListCell<T> {
final Label label = new Label();
final Text editor = new Text();
@Override
public void updateItem(T item,
boolean empty) {
super.updateItem(item, empty);
setNode(label);
label.setText((String)item);
}
@Override
public void startEdit() {
super.startEdit();
// do something
commitEdit((T)"new value"); // <-- this should call the ListView.onEditCommit() as in builds <#37
}
};
}
This is no more the case.
Thanks.
--
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.ListView.EditEvent;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.util.Callback;
public class TableCell extends Application {
ListView<String> list = new ListView<String>();
ObservableList<String> data = FXCollections.observableArrayList(
"chocolate", "salmon", "gold", "coral",
"darkorchid", "darkgoldenrod", "lightsalmon",
"black", "rosybrown", "blue", "blueviolet",
"brown");
final Label label = new Label();
@Override
public void start(Stage stage) {
VBox box = new VBox();
Scene scene = new Scene(box, 200, 200);
stage.setScene(scene);
stage.setTitle("ListViewSample");
box.getChildren().addAll(list, label);
box.setVgrow(list, Priority.ALWAYS);
label.setLayoutX(10);
label.setLayoutY(115);
label.setFont(new Font("Verdana", 20));
list.setItems(data);
list.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {
public ListCell<String> call(ListView<String> p) {
return new EditorCell();
}
});
// The handler
list.setOnEditCommit(new EventHandler<ListView.EditEvent<String>>() {
public void handle(EditEvent<String> event) {
throw new UnsupportedOperationException("Is no longer called!");
}
});
list.setPrefHeight(100);
stage.setVisible(true);
}
public static void main(String[] args) {
Application.launch(args);
}
class EditorCell<T> extends ListCell<T> {
final Label label = new Label();
final Text editor = new Text();
@Override
public void updateItem(T item,
boolean empty) {
super.updateItem(item, empty);
setNode(label);
label.setText((String)item);
}
@Override
public void startEdit() {
super.startEdit();
// do something
commitEdit((T)"new value"); // <-- this should call the ListView.onEditCommit() as in builds <#37
}
};
}