package be.iminds.ilabt.jfed.experimenter_gui.connectivity_tester;

import be.iminds.ilabt.jfed.ui.javafx.util.StageUtils;
import be.iminds.ilabt.jfed.ui.javafx.GuiceFXMLUtil;
import javafx.scene.Scene;
import javafx.stage.Stage;

import javax.inject.Inject;

/**
 * User: twalcari
 * Date: 8/9/2016
 * Time: 16:18
 */
public class ConnectivityTesterDialog {

    private final GuiceFXMLUtil guiceFXMLUtil;

    private final Stage stage;
    private final ConnectivityTesterController connectivityTesterController;
    @Inject
    public ConnectivityTesterDialog(GuiceFXMLUtil guiceFXMLUtil) {
        this.guiceFXMLUtil = guiceFXMLUtil;

        GuiceFXMLUtil.Result<?, ConnectivityTesterController> result =
                guiceFXMLUtil.createFromFXML(ConnectivityTesterController.class);

        this.stage = new Stage();
        stage.setTitle("jFed Connectivity Tester");
        StageUtils.setJFedStageIcons(stage);
        stage.setScene(new Scene(result.getRoot()));
        stage.setMinWidth(500);

        this.connectivityTesterController = result.getController();
    }

    public synchronized void showDialog() {
        stage.show();

        connectivityTesterController.getConnectivityTester().startTests();
    }

}
