<commit_before>package logbook.internal.gui;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.apache.logging.log4j.LogManager;

import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.stage.Stage;
import javafx.util.Duration;
import logbook.bean.DeckPort;
import logbook.bean.DeckPortCollection;
import logbook.bean.Ship;
import logbook.bean.ShipCollection;

/**
 * 所有艦娘一覧のコントローラ
 *
 */
public class ShipController extends WindowController {

    @FXML
    private TabPane tab;

    private List<ShipTablePane> tablePanes = new ArrayList<>();

    private Timeline timeline;

    @FXML
    void initialize() {
        try {
            ShipTablePane allPane = new ShipTablePane(() -> {
                Map<Integer, Ship> shipMap = ShipCollection.get()
                        .getShipMap();
                return shipMap.values().stream()
                        .sorted(Comparator.comparing(Ship::getShipId))
                        .sorted(Comparator.comparing(Ship::getLv).reversed())
                        .collect(Collectors.toList());
            });

            this.tablePanes.add(allPane);
            this.tab.getTabs().add(new Tab("全員", allPane));

            for (DeckPort deck : DeckPortCollection.get().getDeckPortMap().values()) {
                ShipTablePane deckPane = new ShipTablePane(deck);
                this.tab.getTabs().add(new Tab(deck.getName(), deckPane));
            }

            this.timeline = new Timeline();
            this.timeline.setCycleCount(Timeline.INDEFINITE);
            this.timeline.getKeyFrames().add(new KeyFrame(
                    Duration.seconds(1),
                    this::update));
            this.timeline.play();

        } catch (Exception e) {
            LogManager.getLogger(ShipController.class)
                    .error("FXMLの初期化に失敗しました", e);
        }
    }

    @Override
    public void setWindow(Stage window) {
        super.setWindow(window);
        window.setOnCloseRequest(e -> this.timeline.stop());
    }

    /**
     * 画面の更新
     *
     * @param e ActionEvent
     */
    void update(ActionEvent e) {
        for (ShipTablePane pane : this.tablePanes) {
            pane.update();<commit_msg>今見ているタブのみを再読込するようにする<commit_after>package logbook.internal.gui;

import java.util.Comparator;
import java.util.Map;
import java.util.stream.Collectors;

import org.apache.logging.log4j.LogManager;

import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.stage.Stage;
import javafx.util.Duration;
import logbook.bean.DeckPort;
import logbook.bean.DeckPortCollection;
import logbook.bean.Ship;
import logbook.bean.ShipCollection;

/**
 * 所有艦娘一覧のコントローラ
 *
 */
public class ShipController extends WindowController {

    @FXML
    private TabPane tab;

    private Timeline timeline;

    @FXML
    void initialize() {
        try {
            ShipTablePane allPane = new ShipTablePane(() -> {
                Map<Integer, Ship> shipMap = ShipCollection.get()
                        .getShipMap();
                return shipMap.values().stream()
                        .sorted(Comparator.comparing(Ship::getShipId))
                        .sorted(Comparator.comparing(Ship::getLv).reversed())
                        .collect(Collectors.toList());
            });

            this.tab.getTabs().add(new Tab("全員", allPane));

            for (DeckPort deck : DeckPortCollection.get().getDeckPortMap().values()) {
                ShipTablePane deckPane = new ShipTablePane(deck);
                this.tab.getTabs().add(new Tab(deck.getName(), deckPane));
            }

            this.timeline = new Timeline();
            this.timeline.setCycleCount(Timeline.INDEFINITE);
            this.timeline.getKeyFrames().add(new KeyFrame(
                    Duration.seconds(1),
                    this::update));
            this.timeline.play();

        } catch (Exception e) {
            LogManager.getLogger(ShipController.class)
                    .error("FXMLの初期化に失敗しました", e);
        }
    }

    @Override
    public void setWindow(Stage window) {
        super.setWindow(window);
        window.setOnCloseRequest(e -> this.timeline.stop());
    }

    /**
     * 画面の更新
     *
     * @param e ActionEvent
     */
    void update(ActionEvent e) {
        Tab selectedTab = this.tab.getSelectionModel()
                .getSelectedItem();
        if (selectedTab != null) {
            Node content = selectedTab.getContent();
            if (content instanceof ShipTablePane) {
                ((ShipTablePane) content).update();
            }
{'fraction_non_alphanumeric': 0.11428571428571428, 'fraction_numerical': 0.0008048289738430583, 'mean_word_length': 2.225827384815055, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5559462', 'n_tokens_mistral': 1496, 'n_tokens_neox': 1467, 'n_words': 250}