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

import be.iminds.ilabt.jfed.experiment.Experiment;
import be.iminds.ilabt.jfed.experiment.ExperimentController;
import be.iminds.ilabt.jfed.experimenter_gui.call_gui.TasksWindow;
import be.iminds.ilabt.jfed.experimenter_gui.slice.raw.RawSliceView;
import be.iminds.ilabt.jfed.experimenter_gui.timeline.model.TimelineModelFactory;
import be.iminds.ilabt.jfed.experimenter_gui.timeline.view.TimelineView;
import be.iminds.ilabt.jfed.experimenter_gui.util.BrowserUtil;
import be.iminds.ilabt.jfed.experimenter_gui.util.ImageUtil;
import be.iminds.ilabt.jfed.experimenter_gui.util.SSHTerminalUtil;
import be.iminds.ilabt.jfed.log.cache.ApiCallDetailsCache;
import be.iminds.ilabt.jfed.lowlevel.TestbedInfoSource;
import be.iminds.ilabt.jfed.preferences.JFedGuiPreferences;
import be.iminds.ilabt.jfed.rspec.rspec_source.ManifestRspecSource;

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

/**
 * User: twalcari
 * Date: 1/30/2015
 * Time: 11:50
 */
@Singleton
public class ExperimentViewsFactory {

    private final Provider<TasksWindow> tasksWindowProvider;
    private final Provider<ApiCallDetailsCache> apiCallDetailsCacheProvider;
    private final Provider<SSHTerminalUtil> sshTerminalUtilProvider;
    private final Provider<JFedGuiPreferences> jFedPreferencesProvider;
    private final Provider<TestbedInfoSource> authorityListModelProvider;
    private final Provider<SliceExperimentCanvasFactory> sliceExperimentCanvasFactoryProvider;
    private final Provider<NodePropertiesDialogFactory> nodePropertiesDialogFactoryProvider;
    private final Provider<ImageUtil> imageUtilProvider;
    private final Provider<TimelineModelFactory> controllerModelFactoryProvider;
    private final Provider<BrowserUtil> browserUtilProvider;


    @Inject
    public ExperimentViewsFactory(Provider<ApiCallDetailsCache> apiCallDetailsCacheProvider,
                                  Provider<TasksWindow> tasksWindowProvider,
                                  Provider<SSHTerminalUtil> sshTerminalUtilProvider,
                                  Provider<JFedGuiPreferences> jFedPreferencesProvider,
                                  Provider<TestbedInfoSource> authorityListModelProvider,
                                  Provider<SliceExperimentCanvasFactory> sliceExperimentCanvasFactoryProvider,
                                  Provider<NodePropertiesDialogFactory> nodePropertiesDialogFactoryProvider,
                                  Provider<ImageUtil> imageUtilProvider,
                                  Provider<TimelineModelFactory> controllerModelFactoryProvider,
                                  Provider<BrowserUtil> browserUtilProvider) {
        this.apiCallDetailsCacheProvider = apiCallDetailsCacheProvider;
        this.tasksWindowProvider = tasksWindowProvider;
        this.sshTerminalUtilProvider = sshTerminalUtilProvider;
        this.jFedPreferencesProvider = jFedPreferencesProvider;
        this.authorityListModelProvider = authorityListModelProvider;
        this.sliceExperimentCanvasFactoryProvider = sliceExperimentCanvasFactoryProvider;
        this.nodePropertiesDialogFactoryProvider = nodePropertiesDialogFactoryProvider;
        this.imageUtilProvider = imageUtilProvider;
        this.controllerModelFactoryProvider = controllerModelFactoryProvider;
        this.browserUtilProvider = browserUtilProvider;
    }


    public RawSliceView createRawSliceView(Experiment experiment, ManifestRspecSource canvasRspecSource) {
        return new RawSliceView(experiment, canvasRspecSource, sshTerminalUtilProvider.get(), browserUtilProvider.get(),
                jFedPreferencesProvider.get(), authorityListModelProvider.get());
    }

    public ModelSliceView createModelSliceView(ExperimentController experimentController, ManifestRspecSource canvasRspecSource) {
        return new ModelSliceView(experimentController, canvasRspecSource, authorityListModelProvider.get(),
                sliceExperimentCanvasFactoryProvider.get(), browserUtilProvider.get());
    }

    public TimelineView createControllerUi(Experiment experiment, DetailsTabHost detailsTabHost) {
        return new TimelineView(experiment, detailsTabHost, nodePropertiesDialogFactoryProvider.get(),
                imageUtilProvider.get(),controllerModelFactoryProvider.get(), jFedPreferencesProvider.get());
    }
}
