<commit_before>package ui.issuecolumn;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import model.Model;
import storage.DataManager;
import ui.UI;
import ui.components.StatusBar;
import ui.issuepanel.IssuePanel;
import util.events.ColumnChangeEvent;
import util.events.IssueSelectedEvent;
import util.events.IssueSelectedEventHandler;
import util.events.ModelChangedEvent;
import util.events.ModelChangedEventHandler;
import util.events.RefreshDoneEvent;
import util.events.RefreshDoneEventHandler;

import command.TurboCommandExecutor;


public class ColumnControl extends HBox {

	private final UI ui;
	private final Stage stage;
	private final Model model;
	
	@SuppressWarnings("unused")
	private final UIBrowserBridge uiBrowserBridge;

	private TurboCommandExecutor dragAndDropExecutor;
	private Optional<Integer> currentlySelectedColumn = Optional.empty();
	
	public ColumnControl(UI ui, Stage stage, Model model) {
		this.ui = ui;
		this.stage = stage;
		this.model = model;
		this.dragAndDropExecutor = new TurboCommandExecutor();
		this.uiBrowserBridge = new UIBrowserBridge(ui);
		setSpacing(10);
		setPadding(new Insets(0,10,0,10));
		setupModelChangeResponse();
		
		ui.registerEvent(new RefreshDoneEventHandler() {
			@Override
			public void handle(RefreshDoneEvent e) {
				// We need this because this is triggered from a Timer thread
				Platform.runLater(()-> {
					refresh();
				});	
			}
		});
		
		ui.registerEvent(new IssueSelectedEventHandler() {
			@Override
			public void handle(IssueSelectedEvent e) {
				currentlySelectedColumn = Optional.of(e.columnIndex);
			}
		});
	}
	
	private void setupModelChangeResponse(){
		ui.registerEvent(new ModelChangedEventHandler() {
			@Override
			public void handle(ModelChangedEvent e) {
				refresh();
			}
		});
	}
	
	public void restoreColumns() {
		getChildren().clear();
		
		List<String> filters = DataManager.getInstance().getFiltersFromPreviousSession(model.getRepoId());
		if (filters != null && !filters.isEmpty()) {<commit_msg>Ensured that model changes run on JavaFX thread<commit_after>package ui.issuecolumn;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import model.Model;
import storage.DataManager;
import ui.UI;
import ui.components.StatusBar;
import ui.issuepanel.IssuePanel;
import util.events.ColumnChangeEvent;
import util.events.IssueSelectedEvent;
import util.events.IssueSelectedEventHandler;
import util.events.ModelChangedEvent;
import util.events.ModelChangedEventHandler;
import util.events.RefreshDoneEvent;
import util.events.RefreshDoneEventHandler;

import command.TurboCommandExecutor;


public class ColumnControl extends HBox {

	private final UI ui;
	private final Stage stage;
	private final Model model;
	
	@SuppressWarnings("unused")
	private final UIBrowserBridge uiBrowserBridge;

	private TurboCommandExecutor dragAndDropExecutor;
	private Optional<Integer> currentlySelectedColumn = Optional.empty();
	
	public ColumnControl(UI ui, Stage stage, Model model) {
		this.ui = ui;
		this.stage = stage;
		this.model = model;
		this.dragAndDropExecutor = new TurboCommandExecutor();
		this.uiBrowserBridge = new UIBrowserBridge(ui);
		setSpacing(10);
		setPadding(new Insets(0,10,0,10));
		setupModelChangeResponse();
		
		ui.registerEvent(new RefreshDoneEventHandler() {
			@Override
			public void handle(RefreshDoneEvent e) {
				// We need this because this is triggered from a Timer thread
				Platform.runLater(()-> {
					refresh();
				});	
			}
		});
		
		ui.registerEvent(new IssueSelectedEventHandler() {
			@Override
			public void handle(IssueSelectedEvent e) {
				currentlySelectedColumn = Optional.of(e.columnIndex);
			}
		});
	}
	
	private void setupModelChangeResponse(){
		ui.registerEvent(new ModelChangedEventHandler() {
			@Override
			public void handle(ModelChangedEvent e) {
				Platform.runLater(() -> refresh());
			}
		});
	}
	
	public void restoreColumns() {
		getChildren().clear();
		
		List<String> filters = DataManager.getInstance().getFiltersFromPreviousSession(model.getRepoId());
		if (filters != null && !filters.isEmpty()) {
{'fraction_non_alphanumeric': 0.10146231721034871, 'fraction_numerical': 0.0035995500562429695, 'mean_word_length': 5.073770491803279, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7375701', 'n_tokens_mistral': 1420, 'n_tokens_neox': 1264, 'n_words': 302}