Exemplo n.º 1
0
  @Override
  protected void activate() {
    FilteredList<Dispute> filteredList =
        new FilteredList<>(disputeManager.getDisputesAsObservableList());
    setFilteredListPredicate(filteredList);
    SortedList<Dispute> sortedList = new SortedList<>(filteredList);
    sortedList.setComparator((o1, o2) -> o2.getOpeningDate().compareTo(o1.getOpeningDate()));
    disputesTable.setItems(sortedList);
    disputesTable.getSelectionModel().selectedItemProperty().addListener(disputeChangeListener);

    Dispute selectedItem = disputesTable.getSelectionModel().getSelectedItem();
    if (selectedItem != null) disputesTable.getSelectionModel().select(selectedItem);

    scrollToBottom();
  }
Exemplo n.º 2
0
  private void onSelectDispute(Dispute dispute) {
    if (dispute == null) {
      if (root.getChildren().size() > 1) root.getChildren().remove(1);

      selectedDispute = null;
    } else if (selectedDispute != dispute) {
      this.selectedDispute = dispute;

      boolean isTrader = disputeManager.isTrader(dispute);

      TableGroupHeadline tableGroupHeadline = new TableGroupHeadline();
      tableGroupHeadline.setText("Messages");
      tableGroupHeadline.prefWidthProperty().bind(root.widthProperty());
      AnchorPane.setTopAnchor(tableGroupHeadline, 10d);
      AnchorPane.setRightAnchor(tableGroupHeadline, 0d);
      AnchorPane.setBottomAnchor(tableGroupHeadline, 0d);
      AnchorPane.setLeftAnchor(tableGroupHeadline, 0d);

      ObservableList<DisputeDirectMessage> list =
          dispute.getDisputeDirectMessagesAsObservableList();
      SortedList<DisputeDirectMessage> sortedList = new SortedList<>(list);
      sortedList.setComparator((o1, o2) -> o1.getDate().compareTo(o2.getDate()));
      list.addListener((ListChangeListener<DisputeDirectMessage>) c -> scrollToBottom());
      messageListView = new ListView<>(sortedList);
      messageListView.setId("message-list-view");
      messageListView.prefWidthProperty().bind(root.widthProperty());
      messageListView.setMinHeight(150);
      AnchorPane.setTopAnchor(messageListView, 30d);
      AnchorPane.setRightAnchor(messageListView, 0d);
      AnchorPane.setLeftAnchor(messageListView, 0d);

      messagesAnchorPane = new AnchorPane();
      messagesAnchorPane.prefWidthProperty().bind(root.widthProperty());
      VBox.setVgrow(messagesAnchorPane, Priority.ALWAYS);

      inputTextArea = new TextArea();
      inputTextArea.setPrefHeight(70);
      inputTextArea.setWrapText(true);

      Button sendButton = new Button("Send");
      sendButton.setDefaultButton(true);
      sendButton.setOnAction(e -> onSendMessage(inputTextArea.getText(), dispute));
      sendButton.setDisable(true);
      inputTextArea
          .textProperty()
          .addListener(
              (observable, oldValue, newValue) -> {
                sendButton.setDisable(
                    newValue.length() == 0
                        && tempAttachments.size() == 0
                        && dispute.disputeResultProperty().get() == null);
              });

      Button uploadButton = new Button("Add attachments");
      uploadButton.setOnAction(e -> onRequestUpload());

      sendMsgInfoLabel = new Label();
      sendMsgInfoLabel.setVisible(false);
      sendMsgInfoLabel.setManaged(false);
      sendMsgInfoLabel.setPadding(new Insets(5, 0, 0, 0));

      sendMsgProgressIndicator = new ProgressIndicator(0);
      sendMsgProgressIndicator.setPrefHeight(24);
      sendMsgProgressIndicator.setPrefWidth(24);
      sendMsgProgressIndicator.setVisible(false);
      sendMsgProgressIndicator.setManaged(false);

      dispute
          .isClosedProperty()
          .addListener(
              (observable, oldValue, newValue) -> {
                messagesInputBox.setVisible(!newValue);
                messagesInputBox.setManaged(!newValue);
                AnchorPane.setBottomAnchor(messageListView, newValue ? 0d : 120d);
              });
      if (!dispute.isClosed()) {
        HBox buttonBox = new HBox();
        buttonBox.setSpacing(10);
        buttonBox
            .getChildren()
            .addAll(sendButton, uploadButton, sendMsgProgressIndicator, sendMsgInfoLabel);

        if (!isTrader) {
          Button closeDisputeButton = new Button("Close ticket");
          closeDisputeButton.setOnAction(e -> onCloseDispute(dispute));
          closeDisputeButton.setDefaultButton(true);
          Pane spacer = new Pane();
          HBox.setHgrow(spacer, Priority.ALWAYS);
          buttonBox.getChildren().addAll(spacer, closeDisputeButton);
        }

        messagesInputBox = new VBox();
        messagesInputBox.setSpacing(10);
        messagesInputBox.getChildren().addAll(inputTextArea, buttonBox);
        VBox.setVgrow(buttonBox, Priority.ALWAYS);

        AnchorPane.setRightAnchor(messagesInputBox, 0d);
        AnchorPane.setBottomAnchor(messagesInputBox, 5d);
        AnchorPane.setLeftAnchor(messagesInputBox, 0d);

        AnchorPane.setBottomAnchor(messageListView, 120d);

        messagesAnchorPane
            .getChildren()
            .addAll(tableGroupHeadline, messageListView, messagesInputBox);
      } else {
        AnchorPane.setBottomAnchor(messageListView, 0d);
        messagesAnchorPane.getChildren().addAll(tableGroupHeadline, messageListView);
      }

      messageListView.setCellFactory(
          new Callback<ListView<DisputeDirectMessage>, ListCell<DisputeDirectMessage>>() {
            @Override
            public ListCell<DisputeDirectMessage> call(ListView<DisputeDirectMessage> list) {
              return new ListCell<DisputeDirectMessage>() {
                final Pane bg = new Pane();
                final ImageView arrow = new ImageView();
                final Label headerLabel = new Label();
                final Label messageLabel = new Label();
                final HBox attachmentsBox = new HBox();
                final AnchorPane messageAnchorPane = new AnchorPane();
                final Label statusIcon = new Label();
                final double arrowWidth = 15d;
                final double attachmentsBoxHeight = 20d;
                final double border = 10d;
                final double bottomBorder = 25d;
                final double padding = border + 10d;

                {
                  bg.setMinHeight(30);
                  messageLabel.setWrapText(true);
                  headerLabel.setTextAlignment(TextAlignment.CENTER);
                  attachmentsBox.setSpacing(5);
                  statusIcon.setStyle("-fx-font-size: 10;");
                  messageAnchorPane
                      .getChildren()
                      .addAll(bg, arrow, headerLabel, messageLabel, attachmentsBox, statusIcon);
                }

                @Override
                public void updateItem(final DisputeDirectMessage item, boolean empty) {
                  super.updateItem(item, empty);

                  if (item != null && !empty) {
                    /* messageAnchorPane.prefWidthProperty().bind(EasyBind.map(messageListView.widthProperty(),
                    w -> (double) w - padding - GUIUtil.getScrollbarWidth(messageListView)));*/
                    if (!messageAnchorPane.prefWidthProperty().isBound())
                      messageAnchorPane
                          .prefWidthProperty()
                          .bind(
                              messageListView
                                  .widthProperty()
                                  .subtract(padding + GUIUtil.getScrollbarWidth(messageListView)));

                    AnchorPane.setTopAnchor(bg, 15d);
                    AnchorPane.setBottomAnchor(bg, bottomBorder);
                    AnchorPane.setTopAnchor(headerLabel, 0d);
                    AnchorPane.setBottomAnchor(arrow, bottomBorder + 5d);
                    AnchorPane.setTopAnchor(messageLabel, 25d);
                    AnchorPane.setBottomAnchor(attachmentsBox, bottomBorder + 10);

                    boolean senderIsTrader = item.isSenderIsTrader();
                    boolean isMyMsg = isTrader ? senderIsTrader : !senderIsTrader;

                    arrow.setVisible(!item.isSystemMessage());
                    arrow.setManaged(!item.isSystemMessage());
                    statusIcon.setVisible(false);
                    if (item.isSystemMessage()) {
                      headerLabel.setStyle("-fx-text-fill: -bs-green; -fx-font-size: 11;");
                      bg.setId("message-bubble-green");
                      messageLabel.setStyle("-fx-text-fill: white;");
                    } else if (isMyMsg) {
                      headerLabel.setStyle("-fx-text-fill: -fx-accent; -fx-font-size: 11;");
                      bg.setId("message-bubble-blue");
                      messageLabel.setStyle("-fx-text-fill: white;");
                      if (isTrader) arrow.setId("bubble_arrow_blue_left");
                      else arrow.setId("bubble_arrow_blue_right");

                      sendMsgProgressIndicator
                          .progressProperty()
                          .addListener(
                              (observable, oldValue, newValue) -> {
                                if ((double) oldValue == -1 && (double) newValue == 0) {
                                  if (item.arrivedProperty().get()) showArrivedIcon();
                                  else if (item.storedInMailboxProperty().get()) showMailboxIcon();
                                }
                              });

                      if (item.arrivedProperty().get()) showArrivedIcon();
                      else if (item.storedInMailboxProperty().get()) showMailboxIcon();
                      // TODO show that icon on error
                      /*else if (sendMsgProgressIndicator.getProgress() == 0)
                      showNotArrivedIcon();*/
                    } else {
                      headerLabel.setStyle("-fx-text-fill: -bs-light-grey; -fx-font-size: 11;");
                      bg.setId("message-bubble-grey");
                      messageLabel.setStyle("-fx-text-fill: black;");
                      if (isTrader) arrow.setId("bubble_arrow_grey_right");
                      else arrow.setId("bubble_arrow_grey_left");
                    }

                    if (item.isSystemMessage()) {
                      AnchorPane.setLeftAnchor(headerLabel, padding);
                      AnchorPane.setRightAnchor(headerLabel, padding);
                      AnchorPane.setLeftAnchor(bg, border);
                      AnchorPane.setRightAnchor(bg, border);
                      AnchorPane.setLeftAnchor(messageLabel, padding);
                      AnchorPane.setRightAnchor(messageLabel, padding);
                      AnchorPane.setLeftAnchor(attachmentsBox, padding);
                      AnchorPane.setRightAnchor(attachmentsBox, padding);
                    } else if (senderIsTrader) {
                      AnchorPane.setLeftAnchor(headerLabel, padding + arrowWidth);
                      AnchorPane.setLeftAnchor(bg, border + arrowWidth);
                      AnchorPane.setRightAnchor(bg, border);
                      AnchorPane.setLeftAnchor(arrow, border);
                      AnchorPane.setLeftAnchor(messageLabel, padding + arrowWidth);
                      AnchorPane.setRightAnchor(messageLabel, padding);
                      AnchorPane.setLeftAnchor(attachmentsBox, padding + arrowWidth);
                      AnchorPane.setRightAnchor(attachmentsBox, padding);
                      AnchorPane.setRightAnchor(statusIcon, padding);
                    } else {
                      AnchorPane.setRightAnchor(headerLabel, padding + arrowWidth);
                      AnchorPane.setLeftAnchor(bg, border);
                      AnchorPane.setRightAnchor(bg, border + arrowWidth);
                      AnchorPane.setRightAnchor(arrow, border);
                      AnchorPane.setLeftAnchor(messageLabel, padding);
                      AnchorPane.setRightAnchor(messageLabel, padding + arrowWidth);
                      AnchorPane.setLeftAnchor(attachmentsBox, padding);
                      AnchorPane.setRightAnchor(attachmentsBox, padding + arrowWidth);
                      AnchorPane.setLeftAnchor(statusIcon, padding);
                    }

                    AnchorPane.setBottomAnchor(statusIcon, 7d);
                    headerLabel.setText(formatter.formatDateTime(item.getDate()));
                    messageLabel.setText(item.getMessage());
                    if (item.getAttachments().size() > 0) {
                      AnchorPane.setBottomAnchor(
                          messageLabel, bottomBorder + attachmentsBoxHeight + 10);
                      attachmentsBox
                          .getChildren()
                          .add(
                              new Label("Attachments: ") {
                                {
                                  setPadding(new Insets(0, 0, 3, 0));
                                  if (isMyMsg) setStyle("-fx-text-fill: white;");
                                  else setStyle("-fx-text-fill: black;");
                                }
                              });

                      item.getAttachments()
                          .stream()
                          .forEach(
                              attachment -> {
                                final Label icon = new Label();
                                setPadding(new Insets(0, 0, 3, 0));
                                if (isMyMsg) icon.getStyleClass().add("attachment-icon");
                                else icon.getStyleClass().add("attachment-icon-black");

                                AwesomeDude.setIcon(icon, AwesomeIcon.FILE_TEXT);
                                icon.setPadding(new Insets(-2, 0, 0, 0));
                                icon.setTooltip(new Tooltip(attachment.getFileName()));
                                icon.setOnMouseClicked(event -> onOpenAttachment(attachment));
                                attachmentsBox.getChildren().add(icon);
                              });
                    } else {
                      attachmentsBox.getChildren().clear();
                      AnchorPane.setBottomAnchor(messageLabel, bottomBorder + 10);
                    }

                    // TODO There are still some cell rendering issues on updates
                    setGraphic(messageAnchorPane);
                  } else {
                    messageAnchorPane.prefWidthProperty().unbind();

                    AnchorPane.clearConstraints(bg);
                    AnchorPane.clearConstraints(headerLabel);
                    AnchorPane.clearConstraints(arrow);
                    AnchorPane.clearConstraints(messageLabel);
                    AnchorPane.clearConstraints(statusIcon);
                    AnchorPane.clearConstraints(attachmentsBox);

                    setGraphic(null);
                  }
                }

                /*  private void showNotArrivedIcon() {
                    statusIcon.setVisible(true);
                    AwesomeDude.setIcon(statusIcon, AwesomeIcon.WARNING_SIGN, "14");
                    Tooltip.install(statusIcon, new Tooltip("Message did not arrive. Please try to send again."));
                    statusIcon.setTextFill(Paint.valueOf("#dd0000"));
                }*/

                private void showMailboxIcon() {
                  statusIcon.setVisible(true);
                  AwesomeDude.setIcon(statusIcon, AwesomeIcon.ENVELOPE_ALT, "14");
                  Tooltip.install(statusIcon, new Tooltip("Message saved in receivers mailbox"));
                  statusIcon.setTextFill(Paint.valueOf("#0f87c3"));
                }

                private void showArrivedIcon() {
                  statusIcon.setVisible(true);
                  AwesomeDude.setIcon(statusIcon, AwesomeIcon.OK, "14");
                  Tooltip.install(statusIcon, new Tooltip("Message arrived at receiver"));
                  statusIcon.setTextFill(Paint.valueOf("#0f87c3"));
                }
              };
            }
          });

      if (root.getChildren().size() > 1) root.getChildren().remove(1);
      root.getChildren().add(1, messagesAnchorPane);

      scrollToBottom();
    }
  }
Exemplo n.º 3
0
  @FXML
  public void initialize() {
    System.out.println("<main_contr>: controller initiation");
    //		observableTeams = FXCollections.observableArrayList(BetterDataGenerator.generateTeams());
    observableTeams = FXCollections.observableArrayList();

    teamsTable.setPlaceholder(new Label("No matching data"));

    FilteredList<Team> filteredTeams = new FilteredList<>(observableTeams, p -> false);
    teamSearcherTextField
        .textProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (newValue != null
                  && newValue.length() == 3
                  && oldValue.length() < newValue.length()) {
                System.out.println("<main_contr>: query to db for '" + newValue + "'");
                observableTeams.clear();
                observableTeams.addAll(dbHandle.loadTeams());
              }

              filteredTeams.setPredicate(
                  team -> {
                    if (newValue == null || newValue.isEmpty() || newValue.length() < 3) {
                      return false;
                    }

                    String lowerCaseFilter = newValue.toLowerCase();
                    if (lowerCaseFilter.equals("all")) {
                      return true;
                    } else if (team.getTeamName().toLowerCase().contains(lowerCaseFilter)) {
                      return true;
                    } else if (team.getSupervisor() != null
                        && team.getSupervisor()
                            .toString()
                            .toLowerCase()
                            .contains(lowerCaseFilter)) {
                      return true;
                    }
                    return false;
                  });
            });

    FilteredList<Team> orphanTeams =
        new FilteredList<>(
            observableTeams,
            team -> {
              if (team.getSupervisor() == null) {
                return true;
              } else {
                return false;
              }
            });

    SortedList<Team> sortedFilteredTeams = new SortedList<>(filteredTeams);
    sortedFilteredTeams.comparatorProperty().bind(teamsTable.comparatorProperty());
    teamsTable.setItems(sortedFilteredTeams);

    SortedList<Team> sortedOrphanTeams = new SortedList<>(orphanTeams);
    sortedOrphanTeams.comparatorProperty().bind(orphanTeamsTable.comparatorProperty());
    orphanTeamsTable.setItems(sortedOrphanTeams);

    teamsTable.setRowFactory(
        p -> {
          TableRow<Team> row = new TableRow<>();
          row.setOnMouseClicked(
              event -> {
                if (event.getClickCount() == 2 && !row.isEmpty()) {
                  Team selectedTeam = row.getItem();
                  handleTeamDoubleClick(selectedTeam);
                }
              });
          return row;
        });
  }
Exemplo n.º 4
0
  /** Starts the Gui applicaiton. */
  public void start(Stage myStage) {

    System.out.println("Inside the start() method.");

    table = new TableView<PersonBean>();
    table.setEditable(true);
    // Give the stage a title.
    myStage.setTitle("Person Spam App");
    filteredData = new FilteredList<>(personData, p -> true);
    sortedData = new SortedList<>(filteredData);
    sortedData.comparatorProperty().bind(table.comparatorProperty());

    table.setItems(sortedData);
    table.setPrefWidth(500);
    table.getStylesheets().add("resource/style.css");

    table.setColumnResizePolicy(TableView.UNCONSTRAINED_RESIZE_POLICY);

    // My edition:
    TableColumn<PersonBean, String> wholeNameCol = new TableColumn<PersonBean, String>("Full name");
    wholeNameCol.setCellValueFactory(new PropertyValueFactory("firstAndLastName"));
    wholeNameCol.setCellFactory(TextFieldTableCell.<PersonBean>forTableColumn());
    wholeNameCol.setOnEditCommit(
        (CellEditEvent<PersonBean, String> t) -> { // Start on line below
          ((PersonBean) t.getTableView().getItems().get(t.getTablePosition().getRow()))
              .setFirstAndLastName(t.getNewValue());
        });

    //		TableColumn<PersonBean, String> firstNameCol = new TableColumn<PersonBean, String>("First
    // Name");
    //		firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
    //		firstNameCol.setCellFactory(TextFieldTableCell.<PersonBean> forTableColumn());
    //		firstNameCol.setOnEditCommit((CellEditEvent<PersonBean, String> t) -> {
    //
    //	((PersonBean)t.getTableView().getItems().get(t.getTablePosition().getRow())).setFirstName(t.getNewValue());
    //		});
    //
    //		TableColumn<PersonBean, String> lastNameCol = new TableColumn<PersonBean, String>("Last
    // Name");
    //		lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
    //		lastNameCol.setCellFactory(TextFieldTableCell.<PersonBean> forTableColumn());
    //		lastNameCol.setOnEditCommit((CellEditEvent<PersonBean, String> t) -> {
    //			((PersonBean)
    // t.getTableView().getItems().get(t.getTablePosition().getRow())).setLastName(t.getNewValue());
    //		});

    TableColumn<PersonBean, String> emailCol = new TableColumn<PersonBean, String>("Email");
    emailCol.setCellValueFactory(new PropertyValueFactory("email"));
    emailCol.setCellFactory(TextFieldTableCell.<PersonBean>forTableColumn());
    emailCol.setOnEditCommit(
        (CellEditEvent<PersonBean, String> t) -> {
          ((PersonBean) t.getTableView().getItems().get(t.getTablePosition().getRow()))
              .setEmail(t.getNewValue());
        });

    TableColumn<PersonBean, String> genderCol = new TableColumn<PersonBean, String>("Gender");
    genderCol.setCellValueFactory(new PropertyValueFactory("gender"));
    genderCol.setCellFactory(TextFieldTableCell.<PersonBean>forTableColumn());
    genderCol.setOnEditCommit(
        (CellEditEvent<PersonBean, String> t) -> {
          ((PersonBean) t.getTableView().getItems().get(t.getTablePosition().getRow()))
              .setGender(t.getNewValue());
        });

    TableColumn<PersonBean, Integer> ageCol = new TableColumn<PersonBean, Integer>("Age");
    ageCol.setCellValueFactory(new PropertyValueFactory("age"));
    ageCol.setCellFactory(
        TextFieldTableCell.<PersonBean, Integer>forTableColumn(new IntegerStringConverter()));
    ageCol.setOnEditCommit(
        (CellEditEvent<PersonBean, Integer> t) -> {
          ((PersonBean) t.getTableView().getItems().get(t.getTablePosition().getRow()))
              .setAge(t.getNewValue());
        });
    table.getColumns().setAll(wholeNameCol, emailCol, genderCol, ageCol);
    ageCol.setId("white");

    Button allButton = new Button("All");
    allButton.setMinSize(100, 10);
    allButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            System.out.println("Show all!");
            filteredData.setPredicate(showAll());
          }
        });

    Button maleButton = new Button("Male");
    maleButton.setMinSize(100, 10);
    maleButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            System.out.println("Show male");
            // printIt();
            filteredData.setPredicate(isMale());
          }
        });
    Button femaleButton = new Button("Female");
    femaleButton.setMinSize(100, 10);
    femaleButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            System.out.println("Show female");
            filteredData.setPredicate(isFemale());
          }
        });

    Button over18Button = new Button("Over 18");
    over18Button.setMinSize(100, 10);
    over18Button.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            System.out.println("Above 18");
            // filteredData.setPredicate(over18());
            filteredData.setPredicate(
                new Predicate<PersonBean>() {
                  public boolean test(PersonBean p) {
                    return p.getAge() > 17;
                  }
                });
          }
        });

    Button addButton = new Button("Add row");
    addButton.setMinSize(100, 10);
    addButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            System.out.println("Add me!");
            filteredData.setPredicate(showAll());
            addRow();
          }
        });

    Button removeButton = new Button("Delete row");
    removeButton.setMinSize(100, 10);
    removeButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            System.out.println("delete me!");
            List items = new ArrayList(table.getSelectionModel().getSelectedItems());
            personData.removeAll(items);
            table.getSelectionModel().clearSelection();
          }
        });

    // Create a root node. In this case, a flow layout
    // is used, but several alternatives exist.
    FlowPane rootNode = new FlowPane();

    rootNode.getStylesheets().add("resource/style.css");

    rootNode
        .getChildren()
        .addAll(table, allButton, maleButton, femaleButton, over18Button, addButton, removeButton);
    // Create a scene.
    Scene myScene = new Scene(rootNode, 800, 800);

    // Set the scene on the stage.
    myStage.setScene(myScene);

    // Show the stage and its scene.
    myStage.show();
  }
  @Override
  public void initialize(URL url, ResourceBundle rb) {

    TableColumnCodigo.setCellValueFactory(cellData -> cellData.getValue().CodigoProperty());
    TableColumnNome.setCellValueFactory(cellData -> cellData.getValue().NomeProperty());
    TableColumnServico.setCellValueFactory(cellData -> cellData.getValue().ServicoProperty());
    // TableColumnVencimento.setCellValueFactory(cellData -> cellData.getValue().StatusProperty());
    TableColumnValor.setCellValueFactory(cellData -> cellData.getValue().ValorProperty());
    TableColumnSituacao.setCellValueFactory(cellData -> cellData.getValue().SituacaoProperty());

    try {
      carregaTabela();
    } catch (ClassNotFoundException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    if (itens.size() > 0) TableViewBuscar.setItems(itens);
    itens.addListener(
        new ListChangeListener<BuscaCadastroContaReceberFiltro>() {
          @Override
          public void onChanged(
              javafx.collections.ListChangeListener.Change<
                      ? extends BuscaCadastroContaReceberFiltro>
                  arg0) {
            TextFieldTotal.setText(Integer.toString(TableViewBuscar.getItems().size()));
          }
        });

    FilteredList<BuscaCadastroContaReceberFiltro> filteredData =
        new FilteredList<>(itens, p -> true);

    TextFieldFiltro.textProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              TextFieldTotal.setText(Integer.toString(TableViewBuscar.getItems().size()));
              filteredData.setPredicate(
                  person -> {
                    if (newValue == null || newValue.isEmpty()) {
                      return true;
                    }

                    String lowerCaseFilter = newValue.toLowerCase();

                    if (person.getNome().toLowerCase().indexOf(lowerCaseFilter) != -1) {
                      return true;
                    }
                    return false;
                  });
            });

    SortedList<BuscaCadastroContaReceberFiltro> sortedData = new SortedList<>(filteredData);

    sortedData.comparatorProperty().bind(TableViewBuscar.comparatorProperty());

    TableViewBuscar.setItems(sortedData);

    ButtonOk.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {

            if (TableViewBuscar.getSelectionModel().getSelectedItems().size() < 1) {

              Alerta alerta = new Alerta("Busca", "Conta não selecionada!");
              alerta.Alertar(BuscaCadastroContaReceberView.myStage);

              return;
            }

            try {

              // if (opt == 0){
              CadastroContasReceberController.setcontareceber(
                  ControllerContaReceber.BuscaContaReceber(
                      TableViewBuscar.getSelectionModel().getSelectedItems().get(0).getCodigo()));
              CadastroContasReceberController.tela.carregaInfo();
              // }else if(opt == 1){
              // CadastroMatriculaController.setaluno(ControllerAluno.BuscaAluno(TableViewBuscar.getSelectionModel().getSelectedItems().get(0).getCodigo()));
              // CadastroMatriculaController.tela.carregaInfoAluno();
              // }

            } catch (ClassNotFoundException | SQLException e1) {

              e1.printStackTrace();
            }
            BuscaCadastroContaReceberView.myStage.close();
          }
        });

    ButtonCancelar.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {

            BuscaCadastroContaReceberView.myStage.close();
          }
        });
  }