package controllers;

import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ResourceBundle;

import data.GuiMysql;
import dev.failsafe.internal.util.Lists;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import objects.League;

public class AnalyzerController implements Initializable {

    @FXML
    VBox leagueList;

    @FXML
    Label bankLabel;
    @FXML
    TextField bankTextField;
    @FXML
    Label percentLabel;
    @FXML
    TextField percentTextField;
    @FXML
    HBox topPanelBox;

    @Override
    public void initialize(URL arg0, ResourceBundle arg1) {
        HBox.setHgrow(leagueList, Priority.ALWAYS);
        populateLeagueList();

    }

    private void populateLeagueList() {
        List<League> leagues = GuiMysql.getInstance().getLeagues(GuiMysql.getInstance().getSportId("Soccer"));

        for (League league : leagues) {
            CheckBox c = new CheckBox(league.getLeagueName() + " (" + league.getCountryName() + ")");
            c.selectedProperty().set(league.isPrio());
            leagueList.getChildren().add(c);
        }
    }

    @FXML
    private void runTest() {

    }
}