Implemented the start new session functionality

When new session needed to be started we call the doStartNewSesison method
which generates all of the gui panels and gives to them the primary
stage.
android-scanner
Vladimir Eliezer Tokarev 2016-09-24 13:26:15 +03:00
parent 0007df38b8
commit f1704ce16e
2 changed files with 20 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import meerkat.protobuf.Voting;
import meerkat.voting.ui.VotingBoothUI;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@ -17,10 +18,23 @@ import java.util.Map;
public class VotingBoothGUIManager extends Application implements VotingBoothUI {
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(VotingBoothGUIManager.class);
private Map<String, TwoWayNode> visualPanelsMap;
private Stage currentStage;
@Override
public void start(Stage primaryStage) throws Exception {
visualPanelsMap = ChainBuilder.Build(primaryStage);
doStartNewSession(primaryStage);
}
/**
* Created new UI panels and sets their primary stage and shows the panels
* @param primaryStage stage object which contains all the panels
* @throws IOException
*/
private void doStartNewSession(Stage primaryStage) throws IOException {
this.visualPanelsMap = ChainBuilder.Build(primaryStage);
this.currentStage = primaryStage;
this.currentStage.setTitle("Voting Booth");
this.currentStage.show();
}
/**
@ -104,6 +118,11 @@ public class VotingBoothGUIManager extends Application implements VotingBoothUI
@Override
public void startNewVoterSession(FutureCallback<Void> callback) {
logger.debug("Graphical user interface call to startNewVoterSession");
try {
this.doStartNewSession(this.currentStage);
} catch (IOException e) {
logger.error(String.format("Couldn't start new session of the voting process :", e));
}
}
}