package be.iminds.ilabt.jfed.ui.javafx.probe_gui;

import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;

import javax.inject.Inject;
import javax.inject.Singleton;
import java.net.URL;

/**
 * User: twalcari
 * Date: 12/1/2014
 * Time: 15:06
 */
@Singleton
public class ProbeFactory {

    @Inject
    private FXMLLoader loader;

    public ProbeController showProbe() {
        return showProbe(null);
    }

    public ProbeController showProbe(Stage probeStage) {

        if (probeStage == null) {
            probeStage = new Stage();
        }

        try {
            URL location = ProbeController.class.getResource("Probe.fxml");
            loader.setLocation(location);
            probeStage.setScene(new Scene(loader.load()));
            probeStage.sizeToScene();
            probeStage.show();

            return loader.getController();
        } catch (Exception e) {
            throw new RuntimeException("Something went wrong showing the Probe: " + e.getMessage(), e);
        }


    }

}
