-
Bug
-
Resolution: Fixed
-
P3
-
9
-
9-ea-104
To reproduce, run the example below,
- start editing such that the popup is open (notice that the current cell value is selected)
- type some char
- press enter
- expected: the edited value is committed (that is same in first column)
- actual: the edit is canceled (that is value unchanged)
Additional observation:
- start editing such that the popup is not open
- type some char and press enter (not committing at this point is yet another misbehavior;)
- open popup: notice that nothing is selected
- press enter
- expected and actual: edited value is committed
Worked as expected in both scenarios in release 8u60, could be introduced by https://bugs.openjdk.java.net/browse/JDK-8138683 - using the showing property of the popup is not a good trigger for committing ..
The example, slightly changed version of the older issue, to allow editable combo cells
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.ComboBoxTableCell;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.BorderPane;
import javafx.scene.shape.Arc;
import javafx.scene.shape.Line;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Shape;
import javafx.stage.Stage;
import java.util.List;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class ComboCellIssuesContinued extends Application {
private Parent getContent() {
ObservableList<Shape> items = FXCollections.observableArrayList(
new Line(), new Rectangle(), new Arc());
items.forEach(p -> p.setId(p.getClass().getSimpleName()));
List<String> names = items.stream().map(Node::getId).collect(Collectors.toList());
TableView<Shape> table = new TableView<>(items);
table.setEditable(true);
TableColumn<Shape, String> plain = new TableColumn<>("Plain");
plain.setCellValueFactory(new PropertyValueFactory("id"));
plain.setCellFactory(TextFieldTableCell.forTableColumn());
table.getColumns().addAll(plain);
TableColumn<Shape, String> combo = new TableColumn<>("Combo");
combo.setCellValueFactory(new PropertyValueFactory("id"));
combo.setCellFactory(p -> {
ComboBoxTableCell tc = new ComboBoxTableCell(names.toArray()); //"someId", "other", "orNothing");
tc.setComboBoxEditable(true);
return tc;
});
table.getColumns().addAll(combo);
Parent content = new BorderPane(table);
return content;
}
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setScene(new Scene(getContent()));
primaryStage.setTitle(FXUtils.version());
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
@SuppressWarnings("unused")
private static final Logger LOG = Logger
.getLogger(ComboCellIssuesContinued.class.getName());
}
- start editing such that the popup is open (notice that the current cell value is selected)
- type some char
- press enter
- expected: the edited value is committed (that is same in first column)
- actual: the edit is canceled (that is value unchanged)
Additional observation:
- start editing such that the popup is not open
- type some char and press enter (not committing at this point is yet another misbehavior;)
- open popup: notice that nothing is selected
- press enter
- expected and actual: edited value is committed
Worked as expected in both scenarios in release 8u60, could be introduced by https://bugs.openjdk.java.net/browse/JDK-8138683 - using the showing property of the popup is not a good trigger for committing ..
The example, slightly changed version of the older issue, to allow editable combo cells
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.ComboBoxTableCell;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.BorderPane;
import javafx.scene.shape.Arc;
import javafx.scene.shape.Line;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Shape;
import javafx.stage.Stage;
import java.util.List;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class ComboCellIssuesContinued extends Application {
private Parent getContent() {
ObservableList<Shape> items = FXCollections.observableArrayList(
new Line(), new Rectangle(), new Arc());
items.forEach(p -> p.setId(p.getClass().getSimpleName()));
List<String> names = items.stream().map(Node::getId).collect(Collectors.toList());
TableView<Shape> table = new TableView<>(items);
table.setEditable(true);
TableColumn<Shape, String> plain = new TableColumn<>("Plain");
plain.setCellValueFactory(new PropertyValueFactory("id"));
plain.setCellFactory(TextFieldTableCell.forTableColumn());
table.getColumns().addAll(plain);
TableColumn<Shape, String> combo = new TableColumn<>("Combo");
combo.setCellValueFactory(new PropertyValueFactory("id"));
combo.setCellFactory(p -> {
ComboBoxTableCell tc = new ComboBoxTableCell(names.toArray()); //"someId", "other", "orNothing");
tc.setComboBoxEditable(true);
return tc;
});
table.getColumns().addAll(combo);
Parent content = new BorderPane(table);
return content;
}
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setScene(new Scene(getContent()));
primaryStage.setTitle(FXUtils.version());
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
@SuppressWarnings("unused")
private static final Logger LOG = Logger
.getLogger(ComboCellIssuesContinued.class.getName());
}