/** {@inheritDoc} */
  @Override
  public void cancelEdit() {
    if (!isEditing()) return;

    final TableView table = getTableView();

    super.cancelEdit();

    // reset the editing index on the TableView
    if (table != null) {
      TablePosition editingCell = table.getEditingCell();
      if (updateEditingIndex) table.edit(-1, null);

      // request focus back onto the table, only if the current focus
      // owner has the table as a parent (otherwise the user might have
      // clicked out of the table entirely and given focus to something else.
      // It would be rude of us to request it back again.
      ControlUtils.requestFocusOnControlOnlyIfCurrentFocusOwnerIsChild(table);

      CellEditEvent editEvent =
          new CellEditEvent(table, editingCell, TableColumn.editCancelEvent(), null);

      Event.fireEvent(getTableColumn(), editEvent);
    }
  }
  /** {@inheritDoc} */
  @Override
  public void commitEdit(T newValue) {
    if (!isEditing()) return;

    final TableView table = getTableView();
    if (table != null) {
      // Inform the TableView of the edit being ready to be committed.
      CellEditEvent editEvent =
          new CellEditEvent(table, table.getEditingCell(), TableColumn.editCommitEvent(), newValue);

      Event.fireEvent(getTableColumn(), editEvent);
    }

    // inform parent classes of the commit, so that they can switch us
    // out of the editing state.
    // This MUST come before the updateItem call below, otherwise it will
    // call cancelEdit(), resulting in both commit and cancel events being
    // fired (as identified in RT-29650)
    super.commitEdit(newValue);

    // update the item within this cell, so that it represents the new value
    updateItem(newValue, false);

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

      // request focus back onto the table, only if the current focus
      // owner has the table as a parent (otherwise the user might have
      // clicked out of the table entirely and given focus to something else.
      // It would be rude of us to request it back again.
      ControlUtils.requestFocusOnControlOnlyIfCurrentFocusOwnerIsChild(table);
    }
  }
  /** {@inheritDoc} */
  @Override
  public void startEdit() {
    final TableView table = getTableView();
    final TableColumn column = getTableColumn();
    if (!isEditable()
        || (table != null && !table.isEditable())
        || (column != null && !getTableColumn().isEditable())) {
      return;
    }

    // We check the boolean lockItemOnEdit field here, as whilst we want to
    // updateItem normally, when it comes to unit tests we can't have the
    // item change in all circumstances.
    if (!lockItemOnEdit) {
      updateItem();
    }

    // it makes sense to get the cell into its editing state before firing
    // the event to listeners below, so that's what we're doing here
    // by calling super.startEdit().
    super.startEdit();

    if (column != null) {
      CellEditEvent editEvent =
          new CellEditEvent(table, table.getEditingCell(), TableColumn.editStartEvent(), null);

      Event.fireEvent(column, editEvent);
    }
  }
  @Override
  public void handle(KeyEvent event) {

    if (event.getCode() == KeyCode.ENTER) {
      Event.fireEvent(this.botonNuevoJuego, new ActionEvent());
    }
  }
Exemple #5
0
  /**
   * Traverse the scene graph for all open stages and pick an event target for a dock event based on
   * the location. Once the event target is chosen run the event task with the target and the
   * previous target of the last dock event if one is cached. If an event target is not found fire
   * the explicit dock event on the stage root if one is provided.
   *
   * @param location The location of the dock event in screen coordinates.
   * @param eventTask The event task to be run when the event target is found.
   * @param explicit The explicit event to be fired on the stage root when no event target is found.
   */
  private void pickEventTarget(Point2D location, EventTask eventTask, Event explicit) {
    // RFE for public scene graph traversal API filed but closed:
    // https://bugs.openjdk.java.net/browse/JDK-8133331

    ObservableList<Stage> stages =
        FXCollections.unmodifiableObservableList(StageHelper.getStages());
    // fire the dock over event for the active stages
    for (Stage targetStage : stages) {
      // obviously this title bar does not need to receive its own events
      // though users of this library may want to know when their
      // dock node is being dragged by subclassing it or attaching
      // an event listener in which case a new event can be defined or
      // this continue behavior can be removed
      if (targetStage == this.dockNode.getStage()) continue;

      eventTask.reset();

      Node dragNode = dragNodes.get(targetStage);

      Parent root = targetStage.getScene().getRoot();
      Stack<Parent> stack = new Stack<Parent>();
      if (root.contains(root.screenToLocal(location.getX(), location.getY()))
          && !root.isMouseTransparent()) {
        stack.push(root);
      }
      // depth first traversal to find the deepest node or parent with no children
      // that intersects the point of interest
      while (!stack.isEmpty()) {
        Parent parent = stack.pop();
        // if this parent contains the mouse click in screen coordinates in its local bounds
        // then traverse its children
        boolean notFired = true;
        for (Node node : parent.getChildrenUnmodifiable()) {
          if (node.contains(node.screenToLocal(location.getX(), location.getY()))
              && !node.isMouseTransparent()) {
            if (node instanceof Parent) {
              stack.push((Parent) node);
            } else {
              eventTask.run(node, dragNode);
            }
            notFired = false;
            break;
          }
        }
        // if none of the children fired the event or there were no children
        // fire it with the parent as the target to receive the event
        if (notFired) {
          eventTask.run(parent, dragNode);
        }
      }

      if (explicit != null && dragNode != null && eventTask.getExecutions() < 1) {
        Event.fireEvent(dragNode, explicit.copyFor(this, dragNode));
        dragNodes.put(targetStage, null);
      }
    }
  }
Exemple #6
0
 /** {@inheritDoc} */
 @Override
 public void setCellValue(int row, int column, Object value) {
   if (row < rowCount && column < columnCount && !isLocked()) {
     SpreadsheetCell cell = getRows().get(row).get(column);
     Object previousItem = cell.getItem();
     Object convertedValue = cell.getCellType().convertValue(value);
     cell.setItem(convertedValue);
     if (!java.util.Objects.equals(previousItem, cell.getItem())) {
       GridChange cellChange = new GridChange(row, column, previousItem, convertedValue);
       Event.fireEvent(this, cellChange);
     }
   }
 }
 public AutocompleteMenu() {
   // The drop-down menu which lists suggestions happens
   // to capture ENTER keys.
   //
   // When user types PV name into current_field and presses ENTER,
   // the menu captures that ENTER key and uses it to hide the menu.
   // --> Need to send ENTER down to current_field.
   //
   // If user selects one of the suggested menu items
   // and presses enter, menu item will update the current_field
   // --> Need to send ENTER down to current_field _after_
   //     the menu item updated current_field.
   menu.addEventFilter(
       KeyEvent.KEY_PRESSED,
       event -> {
         if (event.getCode() == KeyCode.ENTER && current_field != null)
           Platform.runLater(
               () -> {
                 if (current_field != null) Event.fireEvent(current_field, event);
               });
       });
 }