package be.iminds.ilabt.jfed.experimenter_gui.editor.addresspool_properties;

import be.iminds.ilabt.jfed.experimenter_gui.config.JFedGuiConfig;
import be.iminds.ilabt.jfed.experimenter_gui.util.ui.FXUtils;
import be.iminds.ilabt.jfed.ui.javafx.util.StageUtils;
import be.iminds.ilabt.jfed.lowlevel.TestbedInfoSource;
import be.iminds.ilabt.jfed.rspec.model.javafx_impl.FXAddressPool;
import be.iminds.ilabt.jfed.rspec.model.javafx_impl.FXModelRspec;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.Window;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * User: twalcari
 * Date: 12/2/2014
 * Time: 14:45
 */
@Singleton
public class AddressPoolPropertiesDialogFactory {

    private final JFedGuiConfig config;
    private final TestbedInfoSource testbedInfoSource;

    @Inject
    public AddressPoolPropertiesDialogFactory(TestbedInfoSource testbedInfoSource, JFedGuiConfig config) {
        this.testbedInfoSource = testbedInfoSource;
        this.config = config;
    }

    private AddressPoolPropertiesDialog createAddressPoolPropertiesDialog(FXAddressPool addressPool) {
        return new AddressPoolPropertiesDialog(addressPool, config, testbedInfoSource);
    }

    public boolean showAddressPoolPropertiesDialog(Window parent, FXAddressPool addressPool,
                                                   @SuppressWarnings("UnusedParameters") FXModelRspec modelRspec) {
        final AddressPoolPropertiesDialog addressPoolPropertiesDialog = createAddressPoolPropertiesDialog(addressPool);
        Scene scene = new Scene(addressPoolPropertiesDialog);

        Stage dialogStage = new Stage();
        StageUtils.setJFedStageIcons(dialogStage);
        dialogStage.setScene(scene);


        dialogStage.setTitle("Address Pool properties");
        FXUtils.centerToOwner(parent, dialogStage);

        dialogStage.showAndWait();

        return addressPoolPropertiesDialog.isSuccess();

    }
}
