// Path: src/main/java/de/idrinth/stellaris/modtools/process/FillerThread.java
// public class FillerThread implements Runnable, Callable {
// 
//     private final ArrayList<ClickableTableView> list;
//     private final LinkedList<ProcessHandlingQueue> tasks = new LinkedList<>();
//     private final PersistenceProvider persistence = new PersistenceProvider();
// 
//     public FillerThread(ArrayList<ClickableTableView> list, ProgressElementGroup progress) {
//         this.list = list;
//         tasks.add(new Queue(new Process1Initializer(), this, progress, "Collecting data", persistence));
//         tasks.add(new Queue(new Process2Initializer(persistence), this, progress, "Removing manually patched", persistence));
//         tasks.add(new Queue(new Process3Initializer(persistence),this, progress, "Creating patches", persistence));
//         tasks.add(new Queue(new Process4Initializer(persistence), this, progress, "Merging patches", persistence));
//         tasks.add(new Queue(new Process5Initializer(), this, progress, "Building Mod", persistence));
//     }
// 
//     @Override
//     public void run() {
//         try {
//             call();
//         } catch (Exception exception) {
//             System.out.println(exception.getLocalizedMessage());
//         }
//     }
// 
//     @Override
//     public synchronized Object call() throws Exception {
//         if (!tasks.isEmpty()) {
//             new Thread(tasks.poll()).start();
//             return null;
//         }
//         EntityManager manager = persistence.get();
//         list.forEach((ctv) -> {
//             ctv.setManager(manager);
//             ctv.addItems();
//         });
//         return null;
//     }
// 
// }


import de.idrinth.stellaris.modtools.process.FillerThread;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.web.WebView;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkEvent.EventType;
import org.codefx.libfx.control.webview.WebViews;
            popup = new Stage();
            popup.getIcons().add(new Image(getClass().getResourceAsStream("/icons/logo.png")));
            FXMLLoader loader = new FXMLLoader();
            loader.setController(this);
            popup.setScene(new Scene(loader.load(getClass().getResource("/fxml/TextPopup.fxml").openStream())));
            popup.initModality(Modality.APPLICATION_MODAL);
            popup.initOwner(mods.getScene().getWindow());
            description.setContextMenuEnabled(false);
            description.getEngine().setJavaScriptEnabled(false);
            description.getEngine().setUserAgent("Idrinth's Stellaris Mod Tools/" + getClass().getPackage().getImplementationVersion() + " (https://github.com/Idrinths-Stellaris-Mods/Mod-Tools)");
            WebViews.addHyperlinkListener(
                    description,
                    (HyperlinkEvent event) -> {
                        if (event.getEventType() == EventType.ACTIVATED) {
                            try {
                                Desktop.getDesktop().browse(new URI(event.getURL().toString()));
                            } catch (URISyntaxException | IOException ex) {
                                Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                        return true;//do NOT navigate
                    },
                    EventType.ACTIVATED
            );
        }
        return popup;
    }

    @FXML
    private void handleButtonAction(ActionEvent event) {
// Path: src/main/java/de/idrinth/stellaris/modtools/process/FillerThread.java
// public class FillerThread implements Runnable, Callable {
// 
//     private final ArrayList<ClickableTableView> list;
//     private final LinkedList<ProcessHandlingQueue> tasks = new LinkedList<>();
//     private final PersistenceProvider persistence = new PersistenceProvider();
// 
//     public FillerThread(ArrayList<ClickableTableView> list, ProgressElementGroup progress) {
//         this.list = list;
//         tasks.add(new Queue(new Process1Initializer(), this, progress, "Collecting data", persistence));
//         tasks.add(new Queue(new Process2Initializer(persistence), this, progress, "Removing manually patched", persistence));
//         tasks.add(new Queue(new Process3Initializer(persistence),this, progress, "Creating patches", persistence));
//         tasks.add(new Queue(new Process4Initializer(persistence), this, progress, "Merging patches", persistence));
//         tasks.add(new Queue(new Process5Initializer(), this, progress, "Building Mod", persistence));
//     }
// 
//     @Override
//     public void run() {
//         try {
//             call();
//         } catch (Exception exception) {
//             System.out.println(exception.getLocalizedMessage());
//         }
//     }
// 
//     @Override
//     public synchronized Object call() throws Exception {
//         if (!tasks.isEmpty()) {
//             new Thread(tasks.poll()).start();
//             return null;
//         }
//         EntityManager manager = persistence.get();
//         list.forEach((ctv) -> {
//             ctv.setManager(manager);
//             ctv.addItems();
//         });
//         return null;
//     }
// 
// }


// Path: src/main/java/de/idrinth/stellaris/modtools/gui/FXMLController.java
import de.idrinth.stellaris.modtools.process.FillerThread;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.web.WebView;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkEvent.EventType;
import org.codefx.libfx.control.webview.WebViews;

            popup = new Stage();
            popup.getIcons().add(new Image(getClass().getResourceAsStream("/icons/logo.png")));
            FXMLLoader loader = new FXMLLoader();
            loader.setController(this);
            popup.setScene(new Scene(loader.load(getClass().getResource("/fxml/TextPopup.fxml").openStream())));
            popup.initModality(Modality.APPLICATION_MODAL);
            popup.initOwner(mods.getScene().getWindow());
            description.setContextMenuEnabled(false);
            description.getEngine().setJavaScriptEnabled(false);
            description.getEngine().setUserAgent("Idrinth's Stellaris Mod Tools/" + getClass().getPackage().getImplementationVersion() + " (https://github.com/Idrinths-Stellaris-Mods/Mod-Tools)");
            WebViews.addHyperlinkListener(
                    description,
                    (HyperlinkEvent event) -> {
                        if (event.getEventType() == EventType.ACTIVATED) {
                            try {
                                Desktop.getDesktop().browse(new URI(event.getURL().toString()));
                            } catch (URISyntaxException | IOException ex) {
                                Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                        return true;//do NOT navigate
                    },
                    EventType.ACTIVATED
            );
        }
        return popup;
    }

    @FXML
    private void handleButtonAction(ActionEvent event) {
        button.disarm();//no more events