Пример #1
2
  /** {@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);
    }
  }
Пример #2
2
  /** {@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);
    }
  }
Пример #3
2
  /** {@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);
    }
  }
Пример #4
0
  @Override
  public void handle(Event e) {
    if (e.getSource() == this.btnModificar) {
      if (this.verificarCampos()) {
        aluno.setBairro(this.txtBairro.getText());
        aluno.setCelular(this.txtCelular.getText());
        aluno.setCep(this.txtCep.getText());
        aluno.setCidade(this.txtCidade.getText());
        aluno.setComplemento(this.txtComplemento.getText());
        aluno.setDataNascimento(this.getDataNascimentoPreenchida());
        aluno.setEmail(this.txtEmail.getText());
        aluno.setNome(this.txtNome.getText());
        aluno.setNomeLogradouro(this.txtEndereco.getText());
        aluno.setNumLogradouro(this.txtNumero.getText());
        aluno.setTelefone(this.txtTelefone.getText());
        aluno.setResponsavel(responsavel);

        if (this.aluno.modificar() == true) {
          Alerta.mostrarMensagemSucesso("O cadastro foi modificado corretamente!", "Sucesso");
        } else {
          Alerta.mostrarMensagemErro("Ocorreu um erro ao modificar o cadastro", "Erro");
        }

        this.close();
      }
    } else if (e.getSource() == this.btnProcurarResponsavel) {
      PesquisarResponsavel telaPesquisaResponsavel = new PesquisarResponsavel();
      telaPesquisaResponsavel.showAndWait();
      this.responsavel = telaPesquisaResponsavel.getResponsavelSelecionado();
      this.txtResponsavel.setText(this.responsavel.getNome());
    }
  }
Пример #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);
      }
    }
  }
Пример #6
0
  /**
   * 处理鼠标移动和退出事件
   *
   * @param event
   */
  protected void preMouseEvent(Event event) {
    if (!(event instanceof MouseEvent)) return;

    MouseEvent me = (MouseEvent) event;
    if (event.getEventType() == MouseEvent.MOUSE_MOVED) {
      mouse = new Point((int) me.getX(), (int) me.getY());
    } else if (event.getEventType() == MouseEvent.MOUSE_EXITED) {
      mouse = null;
    }
  }
Пример #7
0
  /**
   *
   *
   * <ul>
   *   判断方向的基本原则:每当用户按下一个方向键,就把它的keyCode存进数组(数组里不可以有重复);每当一个方向键弹起,则把keyCode从数组里清除。
   *   <li>若数组里只有一个键,那就是轴方向运动;
   *   <li>两个键,两种情况:如果是复合键,就是斜方向运动;如果是一个A一个D这样一组相反键,则只响应先按的那个,物体只做轴方向运动;
   *   <li>三个或四个键只响应数组里最先按的那一组复合键,做斜方向运动.
   * </ul>
   *
   * <p>使用数组的好处在于可以处理复杂的多按键情况(无论是玩家有意乱按还是无意多按的),大大提高手感。
   *
   * <p>例如这样一组输入:先后按下A、W、D再释放A,之后按下S并释放W、D。玩家最可能的意图是,先左上走,然后改为右上,最后改为下。 这样的按键手感方便但是就造成一般的if
   * ...else判断方法很难响应。
   *
   * <p>因为Javafx里始终只不断给出最后一个键按下的消息. 新的按键消息会不断把以前的按键消息“冲”掉。而且同时按3个或4个键在if...else里判断很麻烦,
   * 即使建立了类似Ctrl+Shift这样的变量来追踪以前的按键。 而使用有序且不重复的数组则可以完美解决这些问题。
   */
  protected void preKeyEvent(Event event) {
    if (!(event instanceof KeyEvent)) return;

    KeyEvent ke = (KeyEvent) event;
    if (event.getEventType() == KeyEvent.KEY_PRESSED && keys.size() < 4) {
      keys.add(ke.getCode());
    } else if (event.getEventType() == KeyEvent.KEY_PRESSED) {
      keys.remove(ke);
    }
  }
  @Override
  public void handle(KeyEvent event) {

    if (event.getCode() == KeyCode.ENTER) {
      Event.fireEvent(this.botonNuevoJuego, new ActionEvent());
    }
  }
 public void selectTab(Event evt) {
   Object source = evt.getSource();
   if (source == tabPersoon) {
     clearTabPersoon();
   } else if (source == tabGezin) {
     clearTabGezin();
   } else if (source == tabPersoonInvoer) {
     clearTabPersoonInvoer();
   } else if (source == tabGezinInvoer) {
     clearTabGezinInvoer();
   }
 }
Пример #10
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);
               });
       });
 }
 @FXML
 private void onImageDraggedDropped(Event event) {
   System.out.println("Dragged dropped: " + event.getEventType());
 }
Пример #13
0
  @FXML
  public void clickImagesGridPane(Event event) {
    if (event.getTarget().getClass().equals(ImageView.class)) {

      final ImageView targetImageView;
      String currentOpenedImageId;

      targetImageView = (ImageView) event.getTarget();
      currentOpenedImageId = Singleton.INSTANCE.getCardImagePath(targetImageView);

      if (!Singleton.INSTANCE.rightPairs.contains(currentOpenedImageId)) {
        targetImageView.setImage(new Image(currentOpenedImageId));
      }

      // Testa se é a primeira carta a ser aberta pelo usuário
      if (Singleton.INSTANCE.lastOpenedCard == null) {
        Singleton.INSTANCE.lastOpenedCard = targetImageView;

        Singleton.INSTANCE.sendFlip(
            Singleton.INSTANCE.getGridPaneRowIndexForChildNode(targetImageView),
            Singleton.INSTANCE.getGridPaneColumnIndexForChildNode(targetImageView));

      } else {
        // Caso não seja a primeira carta, testa se usuário não clicou na mesma carta.
        if (!Singleton.INSTANCE.lastOpenedCard.equals(targetImageView)) {
          String lastOpenedCardImageId;
          lastOpenedCardImageId =
              Singleton.INSTANCE.getCardImagePath(Singleton.INSTANCE.lastOpenedCard);

          Singleton.INSTANCE.sendFlip(
              Singleton.INSTANCE.getGridPaneRowIndexForChildNode(targetImageView),
              Singleton.INSTANCE.getGridPaneColumnIndexForChildNode(targetImageView));

          // Testa se as duas cartas possuem a mesma figura
          if (lastOpenedCardImageId.equals(currentOpenedImageId)) {

            if (!Singleton.INSTANCE.rightPairs.contains(currentOpenedImageId)) {
              // Incrementa os pontos do player1 e mostra-os na respectiva label
              Singleton.INSTANCE.rightPairs.add(currentOpenedImageId);
              Singleton.INSTANCE.pontosPlayer1++;
              Singleton.INSTANCE.updatePontosPlayer1();

              targetImageView.setImage(new Image("sample/images/cards/blank.png"));
              targetImageView.getStyleClass().clear();
              targetImageView.getStyleClass().add("correctcard");

              Singleton.INSTANCE.lastOpenedCard.setImage(
                  new Image("sample/images/cards/blank.png"));
              Singleton.INSTANCE.lastOpenedCard.getStyleClass().clear();
              Singleton.INSTANCE.lastOpenedCard.getStyleClass().add("correctcard");
            }

            Singleton.INSTANCE.checkWinner();
            Singleton.INSTANCE.lastOpenedCard = null;

          }
          // Se não possuirem a mesma figura, mostra ambas cartas por 2s e as vira de novo.
          else {

            if (!Singleton.INSTANCE.rightPairs.contains(lastOpenedCardImageId)
                && !Singleton.INSTANCE.rightPairs.contains(currentOpenedImageId)) {
              Timeline timeline;

              this.imagesGridPane.setDisable(true);
              timeline = this.makeTimeline(Singleton.INSTANCE.lastOpenedCard, targetImageView);
              timeline.play();
            }
          }
        }
      }
    }
  }
Пример #14
0
 public void listViewClick(Event event) {
   event.getSource();
   dialog.show();
 }
Пример #15
-1
 @Override
 public Event dispatchEvent(Event event, EventDispatchChain tail) {
   if (event instanceof ScrollEvent) {
     event.consume();
     return null;
   } else {
     return originalDispatcher.dispatchEvent(event, tail);
   }
 }