package meerkat.voting.gui.managment;

import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import meerkat.voting.gui.configuration.VotingBoothConfiguration;

/**
 * Created by Vladimir Eliezer Tokarev on 8/27/2016.
 * Two Way node gives the ability to set next and previous objects
 */
public abstract class TwoWayNode {

    protected TwoWayNode next;
    protected TwoWayNode previous;
    protected Stage currentStage;
    protected Scene currentScene;
    protected VotingBoothConfiguration config;

    /**
     * Object which contains the voters selections in different panels
     */
    protected VotersBallot votersBallot;

    public void SetVotersBallot(VotersBallot votersBallot){
        this.votersBallot = votersBallot;
    }

    /**
     * Sets which next TwoWayNode
     * @param nextObject the next TwoWayNode to which the flow will eventual arrive
     */
    void SetNext(TwoWayNode nextObject) {
        this.next = nextObject;
    }

    /**
     * Sets which previous TwoWayNode
     * @param previousObject the object that is one twoWayNode before current object
     */
    void SetPrevious(TwoWayNode previousObject) {
        this.previous = previousObject;
    }

    /**
     * Sets the stage of current object
     * @param primaryStage the primary stage on which all the panels displayed
     */
    public void SetStage(Stage primaryStage) {
        this.currentStage = primaryStage;
    }

    /**
     * Sets the current parent node
     * @param parent the object that is the current new scene
     */
    public void SetCurrentScene(Parent parent) {
        this.currentScene = new Scene(parent);
    }

    /**
     * GetCurrentScene return the paren node that represents current object
     * @return Paren object
     */
    public Scene GetCurrentScene() {
        return this.currentScene;
    }

    /**
     * Sets the configuration for the controller
     * @param config VotingBoothConfiguration object that have questions etc...
     */
    public void SetConfig(VotingBoothConfiguration config) {
        this.config = config;
    }

    /**
     * Should updates the visual state of the node baed on pased configuration
     * this method will be called right before we going get this node to be represented
     */
    public abstract void UpdateNode();
}
