@FXML
 void loadSelectedPlaylist() {
   Playlist p = (Playlist) playlistsView.getSelectionModel().getSelectedItem();
   if (p == null) return;
   tracksView.setPlaceholder(offlinePlaceHolder);
   Platform.runLater(
       () -> {
         List<Track> tracks = p.getTracks();
         tracksView.getItems().clear();
         for (int i = tracks.size() - 1; i >= 0; i--) {
           tracksView.getItems().add(tracks.get(i));
         }
         if (findTrack) {
           Platform.runLater(
               () -> {
                 tracksView.getSelectionModel().select(currentTrack);
                 tracksView.scrollTo(currentTrack);
                 tracksView.requestFocus();
                 findTrack = false;
               });
         } else {
           if (tracksView.getItems().size() > 0) {
             tracksView.scrollTo(0);
           }
         }
       });
 }
  @Override
  public void initialize() {
    disputesTable = new TableView<>();
    VBox.setVgrow(disputesTable, Priority.SOMETIMES);
    disputesTable.setMinHeight(150);
    root.getChildren().add(disputesTable);

    TableColumn<Dispute, Dispute> tradeIdColumn = getTradeIdColumn();
    disputesTable.getColumns().add(tradeIdColumn);
    TableColumn<Dispute, Dispute> roleColumn = getRoleColumn();
    disputesTable.getColumns().add(roleColumn);
    TableColumn<Dispute, Dispute> dateColumn = getDateColumn();
    disputesTable.getColumns().add(dateColumn);
    TableColumn<Dispute, Dispute> contractColumn = getContractColumn();
    disputesTable.getColumns().add(contractColumn);
    TableColumn<Dispute, Dispute> stateColumn = getStateColumn();
    disputesTable.getColumns().add(stateColumn);

    disputesTable.getSortOrder().add(dateColumn);
    disputesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Label placeholder = new Label("There are no open tickets");
    placeholder.setWrapText(true);
    disputesTable.setPlaceholder(placeholder);
    disputesTable.getSelectionModel().clearSelection();

    disputeChangeListener = (observableValue, oldValue, newValue) -> onSelectDispute(newValue);
  }
 @FXML
 void search() {
   searching = true;
   new Thread(
           () -> {
             List<Track> tracks = Cache.search(searchText.getText());
             tracksView.setPlaceholder(searchPlaceholder);
             Platform.runLater(
                 () -> {
                   if (tracksView.getItems().size() > 0) {
                     tracksView.scrollTo(0);
                   }
                   tracksView.getItems().clear();
                   tracksView.getItems().addAll(tracks.toArray());
                 });
           })
       .start();
 }
  private void setupPlaylistsView() {
    TableColumn titleColumn = new TableColumn("Title");
    titleColumn.setMinWidth(USE_COMPUTED_SIZE);
    titleColumn.setSortable(false);
    titleColumn.setCellValueFactory(new PropertyValueFactory<>("title"));

    TableColumn countColumn = new TableColumn("Tracks");
    countColumn.setMinWidth(60);
    countColumn.setMaxWidth(60);
    countColumn.setSortable(false);
    countColumn.setCellValueFactory(new PropertyValueFactory<>("count"));
    countColumn.getStyleClass().add("text-layout-right");

    playlistsView.getColumns().clear();
    playlistsView.getColumns().addAll(titleColumn, countColumn);
    playlistsView.setContextMenu(playlistsContextMenu);
    playlistsView.setPlaceholder(playlistPlaceholder);
    playlistsView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
  }
  /** @return Top-level {@link Node} */
  public Node create() {
    // Layout:
    //
    // | table |  [Add]
    // | table |  [Remove]
    // | table |
    // | table |

    // Create table with editable columns for type Double (supported as Number)
    final TableColumn<Point, Number> x_col = new TableColumn<>(Messages.PointsTable_X);
    x_col.setCellValueFactory(
        new Callback<TableColumn.CellDataFeatures<Point, Number>, ObservableValue<Number>>() {
          @Override
          public ObservableValue<Number> call(CellDataFeatures<Point, Number> param) {
            return new SimpleDoubleProperty(param.getValue().getX());
          }
        });
    x_col.setCellFactory(
        TextFieldTableCell.<Point, Number>forTableColumn(new NumberStringConverter()));
    x_col.setOnEditCommit(
        event -> {
          final int row = event.getTablePosition().getRow();
          points.setX(row, event.getNewValue().doubleValue());
        });

    final TableColumn<Point, Number> y_col = new TableColumn<>(Messages.PointsTable_Y);
    y_col.setCellValueFactory(
        new Callback<TableColumn.CellDataFeatures<Point, Number>, ObservableValue<Number>>() {
          @Override
          public ObservableValue<Number> call(CellDataFeatures<Point, Number> param) {
            return new SimpleDoubleProperty(param.getValue().getY());
          }
        });
    y_col.setCellFactory(
        TextFieldTableCell.<Point, Number>forTableColumn(new NumberStringConverter()));
    y_col.setOnEditCommit(
        event -> {
          final int row = event.getTablePosition().getRow();
          points.setY(row, event.getNewValue().doubleValue());
        });

    final ObservableList<Point> data = new PointsAdapter(points);
    final TableView<Point> table = new TableView<>(data);
    table.getColumns().add(x_col);
    table.getColumns().add(y_col);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    table.setPlaceholder(new Label(Messages.PointsTable_Empty));
    table.setEditable(true);

    // Buttons
    final Button add = new Button(Messages.Add, JFXUtil.getIcon("add.png"));
    add.setMaxWidth(Double.MAX_VALUE);
    add.setOnAction(event -> data.add(new Point(0, 0)));

    final Button remove = new Button(Messages.Remove, JFXUtil.getIcon("delete.png"));
    remove.setMaxWidth(Double.MAX_VALUE);
    remove.setOnAction(
        event -> {
          final int sel = table.getSelectionModel().getSelectedIndex();
          if (sel >= 0) data.remove(sel);
        });

    final VBox buttons = new VBox(10, add, remove);
    final HBox content = new HBox(10, table, buttons);
    HBox.setHgrow(table, Priority.ALWAYS);
    return content;
  }
 /** Set text to put "No Tasks" if there are no contents in the table. */
 private void setTablePlaceHolder() {
   taskTable.setPlaceholder(new Label("No tasks"));
   eventTable.setPlaceholder(new Label("No tasks"));
   floatingTable.setPlaceholder(new Label("No tasks"));
 }
  private Tuple2<TableView<Offer>, VBox> getOfferTable(Offer.Direction direction) {
    TableView<Offer> tableView = new TableView();

    // price
    TableColumn<Offer, Offer> priceColumn = new TableColumn<>();
    priceColumn.textProperty().bind(priceColumnLabel);
    priceColumn.setMinWidth(120);
    priceColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    priceColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatFiat(item.getPrice()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(priceColumn);

    // amount
    TableColumn<Offer, Offer> amountColumn = new TableColumn<>("Amount (BTC)");
    amountColumn.setText("Amount (BTC)");
    amountColumn.setMinWidth(120);
    amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    amountColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatCoin(item.getAmount()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(amountColumn);

    // volume
    TableColumn<Offer, Offer> volumeColumn = new TableColumn<>("Amount (BTC)");
    volumeColumn.setMinWidth(120);
    volumeColumn.textProperty().bind(volumeColumnLabel);
    volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    volumeColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatFiat(item.getOfferVolume()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(volumeColumn);

    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Label placeholder = new Label("Currently there are no offers available");
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);

    Label titleLabel =
        new Label(
            direction.equals(Offer.Direction.BUY)
                ? "Offers for buy bitcoin (bid)"
                : "Offers for sell bitcoin (ask)");
    titleLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 16; -fx-alignment: center");
    UserThread.execute(() -> titleLabel.prefWidthProperty().bind(tableView.widthProperty()));

    VBox vBox = new VBox();
    vBox.setSpacing(10);
    vBox.setFillWidth(true);
    vBox.setMinHeight(150);
    vBox.getChildren().addAll(titleLabel, tableView);
    return new Tuple2<>(tableView, vBox);
  }
  @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;
        });
  }