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 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 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 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 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 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 questions, FutureCallback> 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 questions, FutureCallback> 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 callback) { logger.debug("Graphical user interface call to startNewVoterSession"); } }