<commit_before>package ph.kana.b64image.dialog;


import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.stage.*;

import static javafx.stage.FileChooser.ExtensionFilter;

import javafx.stage.Window;
import ph.kana.b64image.MetadataDialogController;
import ph.kana.b64image.file.FileMetadata;

import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;

public final class DialogService {
	private static DialogService instance = new DialogService();
	private static final String DIALOG_TITLE = "ImageViewer-B64";

	public static DialogService getInstance() {
		return instance;
	}

	private DialogService() { }

	public Optional<File> showOpenRegularFileDialog(Window parent) {
		FileChooser fileChooser = new FileChooser();
		fileChooser.setTitle("Open File to Convert");
		fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));

		return Optional
			.ofNullable(fileChooser.showOpenDialog(parent));
	}

	public Optional<File> showOpenBase64FileDialog(Window parent) {
		FileChooser fileChooser = new FileChooser();
		fileChooser.setTitle("Open Base64 Text File");
		fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));

		ExtensionFilter textFileFilter = new ExtensionFilter("Base64 Text Files (*.txt, *.b64, *.base64)", "*.txt", "*.b64", "*.base64");
		fileChooser
			.getExtensionFilters()
			.add(textFileFilter);
		fileChooser.setSelectedExtensionFilter(textFileFilter);

		return Optional
			.ofNullable(fileChooser.showOpenDialog(parent));
	}

	public void showAboutDialog(Window parent) {
		String fxmlFile = "about-dialog";
		String title = "About: " + DIALOG_TITLE;

		Stage aboutDialog = createDialog(fxmlFile, title, parent, c -> {});
		aboutDialog.showAndWait();
	}

	public void showErrorDialog(Window parent, Exception e) {
		e.printStackTrace(System.err);

		Alert warningDialog = new Alert(Alert.AlertType.ERROR, e.getMessage(), ButtonType.CLOSE);
		warningDialog.initOwner(parent);
		warningDialog.initModality(Modality.APPLICATION_MODAL);
		warningDialog.setTitle(DIALOG_TITLE + " - Error!");
		warningDialog
			.getDialogPane()
			.getButtonTypes();
		warningDialog.showAndWait();
	}

	public void showFileInfo(Window parent, List<FileMetadata> fileInfo) {<commit_msg>CLeanup dead code<commit_after>package ph.kana.b64image.dialog;


import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.stage.*;

import static javafx.stage.FileChooser.ExtensionFilter;

import javafx.stage.Window;
import ph.kana.b64image.MetadataDialogController;
import ph.kana.b64image.file.FileMetadata;

import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;

public final class DialogService {
	private static DialogService instance = new DialogService();
	private static final String DIALOG_TITLE = "ImageViewer-B64";

	public static DialogService getInstance() {
		return instance;
	}

	private DialogService() { }

	public Optional<File> showOpenRegularFileDialog(Window parent) {
		FileChooser fileChooser = new FileChooser();
		fileChooser.setTitle("Open File to Convert");
		fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));

		return Optional
			.ofNullable(fileChooser.showOpenDialog(parent));
	}

	public Optional<File> showOpenBase64FileDialog(Window parent) {
		FileChooser fileChooser = new FileChooser();
		fileChooser.setTitle("Open Base64 Text File");
		fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));

		ExtensionFilter textFileFilter = new ExtensionFilter("Base64 Text Files (*.txt, *.b64, *.base64)", "*.txt", "*.b64", "*.base64");
		fileChooser
			.getExtensionFilters()
			.add(textFileFilter);
		fileChooser.setSelectedExtensionFilter(textFileFilter);

		return Optional
			.ofNullable(fileChooser.showOpenDialog(parent));
	}

	public void showAboutDialog(Window parent) {
		String fxmlFile = "about-dialog";
		String title = "About: " + DIALOG_TITLE;

		Stage aboutDialog = createDialog(fxmlFile, title, parent, c -> {});
		aboutDialog.showAndWait();
	}

	public void showErrorDialog(Window parent, Exception e) {
		e.printStackTrace(System.err);

		Alert warningDialog = new Alert(Alert.AlertType.ERROR, e.getMessage(), ButtonType.CLOSE);
		warningDialog.initOwner(parent);
		warningDialog.initModality(Modality.APPLICATION_MODAL);
		warningDialog.setTitle(DIALOG_TITLE + " - Error!");
		warningDialog.showAndWait();
	}

	public void showFileInfo(Window parent, List<FileMetadata> fileInfo) {
{'fraction_non_alphanumeric': 0.11471273291925466, 'fraction_numerical': 0.008540372670807454, 'mean_word_length': 5.834217506631299, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '5518340', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1570, 'n_words': 327}