meerkat-java/voting-booth-gui/src/main/VotingBoothGUIManager.java

111 lines
4.1 KiB
Java
Raw Normal View History

package main;
import com.google.common.util.concurrent.FutureCallback;
import javafx.application.Application;
import javafx.stage.Stage;
import meerkat.protobuf.Voting;
import meerkat.voting.ui.VotingBoothUI;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Map;
/**
* Created by Vladimir Eliezer Tokarev on 9/17/2016.
* This class managers the gui of the voting booth thruogth external commands
*/
public class VotingBoothGUIManager extends Application implements VotingBoothUI {
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(VotingBoothGUIManager.class);
private Map<String, TwoWayNode> visualPanelsMap;
/**
* Creates new instance of VotingBoothGUIManager
*/
public VotingBoothGUIManager() {
}
@Override
public void start(Stage primaryStage) throws Exception {
visualPanelsMap = ChainBuilder.Build(primaryStage);
}
@Override
public void callShutDown() {
}
/**
* show an error to the voter. let him press a (chosen) button for handling the error.
* @param errorMessage message to show in UI device
* @param buttonLabels labels for buttons to present to voter
* @param callback the number of the selected button
*/
@Override
public void showErrorMessageWithButtons(Voting.UIElement errorMessage, Voting.UIElement[] buttonLabels, FutureCallback<Integer> callback) {
logger.debug("Graphical user interface call to showErrorMessageWithButtons");
}
/**
* show an error to the voter. Halts the system until a technician handles it
* @param errorMessage message to show in UI device
* @param callback returns interrupt
*/
@Override
public void showErrorMessageAndHalt(Voting.UIElement errorMessage, FutureCallback<Boolean> callback) {
logger.debug("Graphical user interface call to showErrorMessageAndHalt");
}
/**
* makes the UI (and voter) wait for something else to happen, by registering a WaitForFinishUICommand in the queue
* @param message a message to show the user on the UI device while waiting
* @param callback a success return value of the wait (cancelling returns false)
*/
@Override
public void notifyVoterToWaitForFinish(Voting.UIElement message, FutureCallback<Void> callback) {
logger.debug("Graphical user interface call to notifyVoterToWaitForFinish");
}
/**
* call for the cast-or-audit phase by registering a CastOrAuditUICommand in the queue
* @param callback the returned choice of how to finalize the ballot
*/
@Override
public void castOrAudit(FutureCallback<VotingBoothUI.FinalizeBallotChoice> callback) {
logger.debug("Graphical user interface call to castOrAudit");
}
/**
* call for the race voting question phase by registering a RaceVotingUICommand in the queue
* @param questions all ballot questions to present to the voter
* @param callback the responses to the questions collected by the UI, to send back to the controller. Responses are null if voter chose to cancel session
*/
@Override
public void askVoterQuestions(List<Voting.BallotQuestion> questions, FutureCallback<List<Voting.BallotAnswer>> callback) {
logger.debug("Graphical user interface call to chooseChannel");
}
/**
* call for the channel choice phase by registering a ChannelChoiceUICommand in the queue
* @param questions questions to determine the right voting channel for this voter
* @param callback that's where we store the answers to decide channel upon for the current voter
*/
@Override
public void chooseChannel(List<Voting.BallotQuestion> questions, FutureCallback<List<Voting.BallotAnswer>> callback) {
logger.debug("Graphical user interface call to chooseChannel");
}
/**
* start a new session by registering a StartSessionUICommand
* @param callback - a boolean future callback to return when done
*/
@Override
public void startNewVoterSession(FutureCallback<Void> callback) {
logger.debug("Graphical user interface call to startNewVoterSession");
}
}