<commit_before>package com.metacodestudio.hotsuploader.window;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.metacodestudio.hotsuploader.AccountService;
import com.metacodestudio.hotsuploader.files.FileHandler;
import com.metacodestudio.hotsuploader.models.*;
import com.metacodestudio.hotsuploader.models.stringconverters.HeroConverter;
import com.metacodestudio.hotsuploader.providers.HotSLogs;
import com.metacodestudio.hotsuploader.utils.NetUtils;
import io.datafx.controller.ViewController;
import io.datafx.controller.flow.action.ActionMethod;
import io.datafx.controller.flow.action.ActionTrigger;
import io.datafx.controller.flow.context.FXMLViewFlowContext;
import io.datafx.controller.flow.context.ViewFlowContext;
import javafx.application.Platform;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.concurrent.ScheduledService;
import javafx.concurrent.Task;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.paint.Paint;
import javafx.util.Duration;
import javafx.util.StringConverter;

import javax.annotation.PostConstruct;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;

@ViewController(value = "Home.fxml", title = "HotSLogs UploaderFX")
public class HomeController {

    @FXMLViewFlowContext
    private ViewFlowContext viewFlowContext;

    @FXML
    private Accordion accordion;

    @FXML
    private TitledPane newReplaysTitlePane;
    @FXML
    private TitledPane uploadedReplaysTitlePane;
    @FXML
    private TitledPane exceptionReplaysTitlePane;
    @FXML
    private TitledPane botReplaysTitlePane;

    @FXML
    private ListView<ReplayFile> newReplaysView;

    @FXML
    private ListView<ReplayFile> uploadedReplaysView;

    @FXML
    private ListView<ReplayFile> exceptionReplaysView;

    @FXML
    private ListView<ReplayFile> botReplaysView;

    @FXML
    private Label status;

    @FXML
    private Label qmMmr;

    @FXML
    private Label hlMmr;

    @FXML
    private Label tlMmr;

    @FXML
    private ImageView logo;

    @FXML
    @ActionTrigger("playerSearch")
    private Button playerSearch;

    @FXML
    private TextField playerSearchInput;

    @FXML
    @ActionTrigger("viewProfile")
    private Button viewProfile;

    @FXML
    private ChoiceBox<Account> accountSelect;

    @FXML
    @ActionTrigger("lookupHero")
    private Button lookupHero;

    @FXML
    private ComboBox<Hero> heroName;

    @FXML
    @ActionTrigger("invalidateExceptions")
    private Button invalidateExceptions;

    private FileHandler fileHandler;
    private Desktop desktop;


    @PostConstruct
    public void init() {
        desktop = Desktop.getDesktop();
        fileHandler = viewFlowContext.getRegisteredObject(FileHandler.class);
        logo.setOnMouseClicked(event -> doOpenHotsLogs());
        fetchHeroNames();
        prepareAccordion();
        setPlayerSearchActions();
        bindLists();
        setupFileHandler();
        if (fileHandler.isIdle()) {
            setIdle();
        }

        setupAccounts();
    }

    private void fetchHeroNames() {
        heroName.converterProperty().setValue(new HeroConverter());
        Task<List<Hero>> task = new Task<List<Hero>>() {<commit_msg>autocomplete hero selection when appropriate<commit_after>package com.metacodestudio.hotsuploader.window;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.metacodestudio.hotsuploader.AccountService;
import com.metacodestudio.hotsuploader.files.FileHandler;
import com.metacodestudio.hotsuploader.models.*;
import com.metacodestudio.hotsuploader.models.stringconverters.HeroConverter;
import com.metacodestudio.hotsuploader.providers.HotSLogs;
import com.metacodestudio.hotsuploader.utils.NetUtils;
import io.datafx.controller.ViewController;
import io.datafx.controller.flow.action.ActionMethod;
import io.datafx.controller.flow.action.ActionTrigger;
import io.datafx.controller.flow.context.FXMLViewFlowContext;
import io.datafx.controller.flow.context.ViewFlowContext;
import javafx.application.Platform;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.concurrent.ScheduledService;
import javafx.concurrent.Task;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.paint.Paint;
import javafx.util.Duration;
import javafx.util.StringConverter;

import javax.annotation.PostConstruct;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;

@ViewController(value = "Home.fxml", title = "HotSLogs UploaderFX")
public class HomeController {

    @FXMLViewFlowContext
    private ViewFlowContext viewFlowContext;

    @FXML
    private Accordion accordion;

    @FXML
    private TitledPane newReplaysTitlePane;
    @FXML
    private TitledPane uploadedReplaysTitlePane;
    @FXML
    private TitledPane exceptionReplaysTitlePane;
    @FXML
    private TitledPane botReplaysTitlePane;

    @FXML
    private ListView<ReplayFile> newReplaysView;

    @FXML
    private ListView<ReplayFile> uploadedReplaysView;

    @FXML
    private ListView<ReplayFile> exceptionReplaysView;

    @FXML
    private ListView<ReplayFile> botReplaysView;

    @FXML
    private Label status;

    @FXML
    private Label qmMmr;

    @FXML
    private Label hlMmr;

    @FXML
    private Label tlMmr;

    @FXML
    private ImageView logo;

    @FXML
    @ActionTrigger("playerSearch")
    private Button playerSearch;

    @FXML
    private TextField playerSearchInput;

    @FXML
    @ActionTrigger("viewProfile")
    private Button viewProfile;

    @FXML
    private ChoiceBox<Account> accountSelect;

    @FXML
    @ActionTrigger("lookupHero")
    private Button lookupHero;

    @FXML
    private ComboBox<Hero> heroName;

    @FXML
    @ActionTrigger("invalidateExceptions")
    private Button invalidateExceptions;

    private FileHandler fileHandler;
    private Desktop desktop;


    @PostConstruct
    public void init() {
        desktop = Desktop.getDesktop();
        fileHandler = viewFlowContext.getRegisteredObject(FileHandler.class);
        logo.setOnMouseClicked(event -> doOpenHotsLogs());
        fetchHeroNames();
        prepareAccordion();
        setPlayerSearchActions();
        bindLists();
        setupFileHandler();
        if (fileHandler.isIdle()) {
            setIdle();
        }

        setupAccounts();
    }

    private void fetchHeroNames() {
        new AutoCompleteComboBoxListener<>(heroName);
        heroName.converterProperty().setValue(new HeroConverter());
        Task<List<Hero>> task = new Task<List<Hero>>() {
{'fraction_non_alphanumeric': 0.0884992406461411, 'fraction_numerical': 0.0, 'mean_word_length': 4.141234918381831, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '2771267', 'n_tokens_mistral': 2255, 'n_tokens_neox': 2162, 'n_words': 422}