Esempio n. 1
1
 @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);
           }
         }
       });
 }
Esempio n. 2
0
 @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();
 }
Esempio n. 3
0
  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);
  }