Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8268295

Tree- and TableCell sub implementations should respect the row editability

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: openjfx15, openjfx16
    • Fix Version/s: openjfx18
    • Component/s: javafx
    • Labels:
      None
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      The sub implementations of Tree- and TableCell shipped by JavaFX do not respect the row editability (inside startEdit()).
      This issue persists also in the standard Tree- and TableCell. (see JDK-8252238)

      Affected classes:
      - ComboBoxTableCell
      - ComboBoxTreeTableCell
      - ChoiceBoxTableCell
      - ChoiceBoxTreeTableCell
      - TextFieldTableCell
      - TextFieldTreeTableCell

      There are also 2 special cases: CheckBoxTableCell and CheckBoxTreeTableCell.
      In this cells the corresponding CheckBox should consider the row editability when the disablement is calculated.
      It is also recommended to do a null check before using the row editability.
      There is a follow-up for this here: JDK-8270042

      --- EXAMPLE ---

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableRow;
      import javafx.scene.control.TableView;
      import javafx.scene.control.cell.TextFieldTableCell;
      import javafx.scene.layout.Pane;
      import javafx.stage.Stage;

      public class TableViewBug extends Application {
          public static void main(String[] args) {
              launch(args);
          }

          @Override
          public void start(Stage primaryStage) {
              TableView<Object> table = new TableView<>();
              table.setEditable(true);
              table.getItems().add(new Object());
              TableColumn<Object, Boolean> column = new TableColumn<>("Select Me");
              column.setCellFactory(p -> new TextFieldTableCell<>());
              table.getColumns().add(column);
              table.setRowFactory(p -> {
                  TableRow<Object> row = new TableRow<>();
                  row.setEditable(false);
                  return row;
              });
              Pane root = new Pane();
              root.getChildren().add(table);
              Scene scene = new Scene(root);
              primaryStage.setScene(scene);
              primaryStage.show();
          }
      }
      ---------- END SOURCE ----------

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      TextFieldTableCell should not be editable
      ACTUAL -
      TextFieldTableCell is editable

      ---

      CUSTOMER SUBMITTED WORKAROUND :
      As a temporary workaround, one can use the utility method suggested in https://stackoverflow.com/a/58905149

      FREQUENCY : always

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mhanl Marius Hanl
              Reporter:
              mhanl Marius Hanl
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: