package be.iminds.ilabt.jfed.experimenter_gui.slice.actions;

import be.iminds.ilabt.jfed.experiment.ExperimentController;
import be.iminds.ilabt.jfed.experimenter_gui.slice.ExperimentViewController;
import be.iminds.ilabt.jfed.experimenter_gui.ui.progressbar.TaskService;
import be.iminds.ilabt.jfed.highlevel.model.Sliver;
import be.iminds.ilabt.jfed.lowlevel.GeniUserProvider;
import be.iminds.ilabt.jfed.lowlevel.TestbedInfoSource;
import be.iminds.ilabt.jfed.lowlevel.authority.AuthorityFinder;
import be.iminds.ilabt.jfed.preferences.JFedGuiPreferences;
import be.iminds.ilabt.jfed.preferences.ProxyPreferencesManager;
import be.iminds.ilabt.jfed.rspec.model.javafx_impl.FXRspecLink;
import be.iminds.ilabt.jfed.rspec.model.javafx_impl.FXRspecNode;
import com.google.common.eventbus.EventBus;
import javafx.stage.Window;

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

/**
 * User: twalcari
 * Date: 2/4/2015
 * Time: 11:04
 */
@Singleton
public class ExperimentActionsFactory {
    private final TestbedInfoSource testbedInfoSource;
    private final AuthorityFinder authorityFinder;
    private final TaskService taskService;
    private final JFedGuiPreferences jFedPreferences;
    private final GeniUserProvider geniUserProvider;
    private final ProxyPreferencesManager proxyPreferencesManager;
    private final EventBus eventBus;

    @Inject
    public ExperimentActionsFactory(TestbedInfoSource testbedInfoSource, AuthorityFinder authorityFinder, TaskService taskService,
                                    JFedGuiPreferences jFedPreferences, GeniUserProvider geniUserProvider,
                                    ProxyPreferencesManager proxyPreferencesManager, EventBus eventBus) {
        this.testbedInfoSource = testbedInfoSource;
        this.authorityFinder = authorityFinder;
        this.taskService = taskService;
        this.jFedPreferences = jFedPreferences;
        this.geniUserProvider = geniUserProvider;
        this.proxyPreferencesManager = proxyPreferencesManager;
        this.eventBus = eventBus;
    }


    public CreateDiskImageAction createCreateDiskImageAction(Window parentWindow, ExperimentController experimentController, FXRspecNode node) {
        return new CreateDiskImageAction(parentWindow, experimentController, node, testbedInfoSource, authorityFinder);

    }

    public ReloadOSAction createReloadOSAction(Window parentWindow, ExperimentController experimentController, Sliver sliver) {
        return new ReloadOSAction(parentWindow, experimentController, sliver);
    }


    public OpenConsoleAction createOpenConsoleAction(Window parentWindow, ExperimentController experimentController, Sliver sliver) {
        return new OpenConsoleAction(parentWindow, experimentController, sliver);
    }

    public SaveManifestAction createSaveManifestAction(ExperimentViewController experimentViewController, boolean saveToCsv) {
        return new SaveManifestAction(experimentViewController, saveToCsv, taskService, jFedPreferences);
    }

    public ShareLanAction createShareLanAction(Window parentWindow, ExperimentController experimentController, FXRspecLink rspecLink) {
        return new ShareLanAction(parentWindow, experimentController, rspecLink);
    }

    public RebootAction createRebootAction(Window parentWindow, ExperimentController experimentController, Sliver selectedSliver) {
        return new RebootAction(parentWindow, experimentController, selectedSliver);

    }

    public SaveExperimentDescriptionAction createSaveExperimentDescriptionAction(Window parentWindow, ExperimentViewController experimentViewController){
        return new SaveExperimentDescriptionAction(parentWindow, experimentViewController, taskService, jFedPreferences);
    }

    public ExportToolsConfigFilesAction createExportToolsConfigFilesAction(Window parentWindow, ExperimentViewController experimentViewController)  {
        return new ExportToolsConfigFilesAction(parentWindow, experimentViewController,taskService, jFedPreferences, geniUserProvider, proxyPreferencesManager);
    }

    public SCPAction createSCPUploadAction(Window parentWindow, ExperimentController experimentController, FXRspecNode node)   {
        return new SCPAction(parentWindow, experimentController, node, eventBus);
    }
}
