package sbu.javafx;

import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;


public class PlaylistController {

    @FXML public TableView<Song> playListTable;
    @FXML public TableColumn<Song, String> titleCol;
    @FXML public TableColumn<Song, String> artistCol;
    @FXML public TableColumn<Song, String> durationCol;

    private ObservableList<Song> playlist;

    @FXML
    public void initialize() {

        titleCol.setCellValueFactory(new PropertyValueFactory<>("title"));
        artistCol.setCellValueFactory(new PropertyValueFactory<>("artistName"));
        durationCol.setCellValueFactory(new PropertyValueFactory<>("duration"));
    }

    public void setPlaylist(ObservableList<Song> playlist) {
        this.playlist = playlist;
        playListTable.setItems(this.playlist);
    }
}
