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

import be.iminds.ilabt.jfed.experimenter_gui.config.JFedGuiConfig;
import be.iminds.ilabt.jfed.experimenter_gui.canvas.rspec.CanvasNodeFactory;
import be.iminds.ilabt.jfed.experimenter_gui.timeline.view.TimelineViewFactory;
import be.iminds.ilabt.jfed.experimenter_gui.editor.ModelRspecEditor;
import be.iminds.ilabt.jfed.experimenter_gui.editor.addresspool_properties.AddressPoolPropertiesDialogFactory;
import be.iminds.ilabt.jfed.experimenter_gui.editor.channel_properties.ChannelPropertiesDialogFactory;

import be.iminds.ilabt.jfed.lowlevel.TestbedInfoSource;
import be.iminds.ilabt.jfed.lowlevel.authority.AuthorityFinder;
import be.iminds.ilabt.jfed.rspec.model.StringRspec;
import com.google.common.eventbus.EventBus;

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

/**
 * User: twalcari
 * Date: 5/20/2015
 * Time: 09:06
 */
@Singleton
public class EditorViewsFactory {
    private final JFedGuiConfig conf;
    private final TimelineViewFactory timelineViewFactory;

    private final CanvasNodeFactory canvasNodeFactory;

    private final TestbedInfoSource testbedInfoSource;
    private final AuthorityFinder authorityFinder;
    private final ChannelPropertiesDialogFactory channelPropertiesDialogFactory;
    private final AddressPoolPropertiesDialogFactory addressPoolPropertiesDialogFactory;
    private final EventBus eventBus;

    @Inject
    public EditorViewsFactory(JFedGuiConfig conf, TimelineViewFactory timelineViewFactory,
                              CanvasNodeFactory canvasNodeFactory, TestbedInfoSource testbedInfoSource, AuthorityFinder authorityFinder,
                              ChannelPropertiesDialogFactory channelPropertiesDialogFactory,
                              AddressPoolPropertiesDialogFactory addressPoolPropertiesDialogFactory, EventBus eventBus) {
        this.conf = conf;
        this.timelineViewFactory = timelineViewFactory;
        this.canvasNodeFactory = canvasNodeFactory;
        this.testbedInfoSource = testbedInfoSource;
        this.authorityFinder = authorityFinder;
        this.channelPropertiesDialogFactory = channelPropertiesDialogFactory;
        this.addressPoolPropertiesDialogFactory = addressPoolPropertiesDialogFactory;
        this.eventBus = eventBus;
    }


    public EditableCanvasEditorView createEditableCanvasEditorView(ModelRspecEditor modelRspecEditor) {
        return new EditableCanvasEditorView(modelRspecEditor, conf, canvasNodeFactory, testbedInfoSource, authorityFinder,
                channelPropertiesDialogFactory, addressPoolPropertiesDialogFactory, eventBus);
    }

    public RawRspecEditor createRawRspecEditor(StringRspec stringRspec) {
        return new RawRspecEditor(stringRspec);
    }

    public EditableControllerView createControllerUI(ModelRspecEditor modelRspecEditor) {
        return new EditableControllerView(modelRspecEditor, timelineViewFactory);
    }

}
