package com.bookmarking.desktop.util;

import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.stage.*;

public class Util
{
    public static Stage getModalStage(AbstractController controller, String winTitle)
    {
        // Create the dialog Stage.
        Stage dialogStage = new Stage();
        dialogStage.setTitle(winTitle);
        dialogStage.initModality(Modality.APPLICATION_MODAL);
        dialogStage.initOwner(null);
        controller.setStage(dialogStage);
        return dialogStage;
    }

    public static <T> T initDialog(Stage stage, Pane pane, AbstractController<T> controller)
    {
        Scene scene = new Scene(pane);
        stage.setScene(scene);

        stage.showAndWait();

        if (controller.isOkayClicked())
        {
            return controller.getObj();
        }
        return null;
    }
}
