<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package calendarioSeries.vistas;

import calendarioSeries.MainApp;
import calendarioSeries.modelos.Serie;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Cursor;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.cell.CheckBoxListCell;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

/**
 * FXML Controller class
 *
 * @author Cotel
 */
public class DetailsSerieController {
    
    @FXML
    private Button back;
    @FXML
    private Label title;
    @FXML
    private Label description;
    @FXML
    private ImageView poster;
    @FXML
    private ListView temporadas;
    @FXML
    private ListView capitulos;
    
    private Serie serie;
    private Scene anterior;
    private MainApp mainApp;
    
    public DetailsSerieController() {
        this.serie = MainViewController.serieToPass;
        this.anterior = MainViewController.sceneToPass;
    }
    
    /**
     * Initializes the controller class.
     */
    @FXML
    public void initialize() {
        this.title.setText(serie.getTitulo());
        this.description.setText(serie.getDescription());
        Image image = new Image(serie.getUrlImagen());
        this.poster.setImage(image);
        this.poster.getStyleClass().clear();
        populateLists();
    }
    
    public void setSerie(Serie serie) {
        this.serie = serie;
    }
    
    public void setAnteriorScene(Scene scene) {
        this.anterior = scene;
    }
    
    public void setMainApp(MainApp mainApp) {
        this.mainApp = mainApp;
    }
    
    private void populateLists() {
        List<String> temps = new ArrayList<String>();
        for(int i=0; i<serie.getTemporadas(); i++) {
            temps.add("Temporada " + (i+1));
        }
        ObservableList<String> observableList = FXCollections.observableArrayList(temps);
        temporadas.setItems(observableList);
        temporadas.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
            @Override
            public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                List<String> caps = new ArrayList<>();
                for(int i=0; i<serie.getCapitulos()[newValue.intValue()].length; i++) {
                    String aux = serie.getCapitulos()[newValue.intValue()][i];
                    int numCap = i+1;
                    String nomCap = aux.substring(0, aux.lastIndexOf(' '));
                    String fecCap = aux.substring(aux.lastIndexOf(' '), aux.length());
                    String res = "%02d\t\t %-50s %s";
                    List<Object> args = new ArrayList<>();
                    args.add(numCap);
                    args.add(nomCap);
                    args.add(fecCap);
                    res = String.format(res, args.toArray());
                    caps.add(res);
                }
                ObservableList<String> thisCaps = FXCollections.observableArrayList(caps);
                capitulos.setItems(thisCaps);
            }
            
        });
    }<commit_msg>Hay que añadir los checkboxes al listView<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package calendarioSeries.vistas;

import calendarioSeries.MainApp;
import calendarioSeries.modelos.Serie;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Cursor;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.cell.CheckBoxListCell;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

/**
 * FXML Controller class
 *
 * @author Cotel
 */
public class DetailsSerieController {
    
    @FXML
    private Button back;
    @FXML
    private Label title;
    @FXML
    private Label description;
    @FXML
    private ImageView poster;
    @FXML
    private ListView temporadas;
    @FXML
    private ListView capitulos;
    
    private Serie serie;
    private Scene anterior;
    private MainApp mainApp;
    
    public DetailsSerieController() {
        this.serie = MainViewController.serieToPass;
        this.anterior = MainViewController.sceneToPass;
    }
    
    /**
     * Initializes the controller class.
     */
    @FXML
    public void initialize() {
        this.title.setText(serie.getTitulo());
        this.description.setText(serie.getDescription());
        Image image = new Image(serie.getUrlImagen());
        this.poster.setImage(image);
        this.poster.getStyleClass().clear();
        populateLists();
    }
    
    public void setSerie(Serie serie) {
        this.serie = serie;
    }
    
    public void setAnteriorScene(Scene scene) {
        this.anterior = scene;
    }
    
    public void setMainApp(MainApp mainApp) {
        this.mainApp = mainApp;
    }
    
    private void populateLists() {
        List<String> temps = new ArrayList<String>();
        for(int i=0; i<serie.getTemporadas(); i++) {
            temps.add("Temporada " + (i+1));
        }
        ObservableList<String> observableList = FXCollections.observableArrayList(temps);
        temporadas.setItems(observableList);
        temporadas.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
            @Override
            public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                List<String> caps = new ArrayList<>();
                for(int i=0; i<serie.getCapitulos()[newValue.intValue()].length; i++) {
                    String aux = serie.getCapitulos()[newValue.intValue()][i];
                    int numCap = i+1;
                    String nomCap = aux.substring(0, aux.lastIndexOf(' '));
                    //String fecCap = aux.substring(aux.lastIndexOf(' '), aux.length());
                    String res = "%02d\t\t %-50s";
                    List<Object> args = new ArrayList<>();
                    args.add(numCap);
                    args.add(nomCap);
                    res = String.format(res, args.toArray());
                    caps.add(res);
                }
                ObservableList<String> thisCaps = FXCollections.observableArrayList(caps);
                capitulos.setItems(thisCaps);
                capitulos.setCellFactory(CheckBoxListCell.forListView(getSelectedProperty));
            }
            
        });
    }
{'fraction_non_alphanumeric': 0.10492059359541786, 'fraction_numerical': 0.002343139807341838, 'mean_word_length': 2.5454545454545454, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5709412', 'n_tokens_mistral': 2194, 'n_tokens_neox': 2173, 'n_words': 467}