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

javafx.scene.control.TableCell.commitEdit cannot perform the call to setEditingCell with null

    XMLWordPrintable

Details

    • x86
    • other

    Description

      FULL PRODUCT VERSION :
      java version "9"
      Java(TM) SE Runtime Environment (build 9+180)
      Java HotSpot(TM) 64-Bit Server VM (build 9+180, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [version 10.0.15063]

      A DESCRIPTION OF THE PROBLEM :
      In package javafx.scene.control in the class TableCell
      we found (here /..../ replace not pertinent code for the problem) :

          @Override public void commitEdit(T newValue) {
         /...../
              super.commitEdit(newValue);
         /...../

              if (table != null) {
                  // reset the editing cell on the TableView
                  table.edit(-1, null);
         /...../
              }
          }

      In this method, the line super.commitEdit(newValue) calls in class javafx.scene.control.Cell the following method :

         public void commitEdit(T newValue) {
              if (isEditing()) {
                  setEditing(false);
              }
          }

      Doing so, isEditing is set to false,
      It follows that later, when commitEdit executes table.edit(-1, null) nothing happens as
      the in class javafx.scene.control.TableView the following edit method

          public void edit(int row, TableColumn<S,?> column) {
              if (!isEditable() || (column != null && ! column.isEditable())) {
                  return;
              }

              if (row < 0 && column == null) {
                  setEditingCell(null);
              } else {
                  setEditingCell(new TablePosition<>(this, row, column));
              }
          }

      does !isEditable which is always true, preventing the later call to setEditingCell(null)



      REGRESSION. Last worked in version 8u131

      ADDITIONAL REGRESSION INFORMATION:
      n/a sorry

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      build a table (1 column, 1 field) with setOnKeyPressed such as

            textField.setOnKeyPressed((KeyEvent t) -> {
              if (t.getCode() == KeyCode.ENTER) {
                commitEdit(textField.getText());
              }
            });

      edit that field and hit ENTER


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      edit(-1, null) should do setEditingCell(null)

      changing the cell editing state to not-editing
      ACTUAL -
      edit(-1, null) is not called

      the cell stay in editing mode active...

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
          public void commitEdit(String newValue) {
            super.commitEdit(newValue);

           /* my code here */
          }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
          public void commitEdit(String newValue) {
            super.commitEdit(newValue);

            // the 3 lines are a patch
            getTableView().setEditable(true);
            getTableView().edit(-1, null);
            getTableView().setEditable(false);

            /* my code here */
          }

      Attachments

        Activity

          People

            pmangal Priyanka Mangal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: