Added the changes of two way node to number of clases

android-scanner
VladimirEliTokarev 2016-10-02 19:11:34 +03:00
parent 5267c7026f
commit c410fc6693
10 changed files with 41 additions and 63 deletions

View File

@ -10,8 +10,8 @@ import javafx.stage.Stage;
*/
public abstract class TwoWayNode {
protected Scene next;
protected Scene previous;
protected TwoWayNode next;
protected TwoWayNode previous;
protected Stage currentStage;
protected Scene currentScene;
protected VotingBoothConfiguration config;
@ -21,7 +21,7 @@ public abstract class TwoWayNode {
* @param nextObject the next TwoWayNode to which the flow will eventual arrive
*/
void SetNext(TwoWayNode nextObject) {
this.next = nextObject.GetCurrentScene();
this.next = nextObject;
}
/**
@ -29,7 +29,7 @@ public abstract class TwoWayNode {
* @param previousObject the object that is one twoWayNode before current object
*/
void SetPrevious(TwoWayNode previousObject) {
this.previous = previousObject.GetCurrentScene();
this.previous = previousObject;
}
/**
@ -52,7 +52,7 @@ public abstract class TwoWayNode {
* GetCurrentScene return the paren node that represents current object
* @return Paren object
*/
private Scene GetCurrentScene() {
public Scene GetCurrentScene() {
return this.currentScene;
}

View File

@ -12,14 +12,21 @@ public class BallotSummaryController extends TwoWayNode {
@FXML
private void GetToSelectByPicture(MouseEvent mousePressed){
this.currentStage.close();
this.currentStage.setScene(this.previous);
this.next.UpdateNode();
this.currentStage.setScene(this.next.GetCurrentScene());
this.currentStage.show();
}
@FXML
private void GetToCastOrAudit(MouseEvent mousePressed){
this.currentStage.close();
this.currentStage.setScene(this.next);
this.previous.UpdateNode();
this.currentStage.setScene(this.previous.GetCurrentScene());
this.currentStage.show();
}
@Override
public void UpdateNode() {
// Nothing relevant to do
}
}

View File

@ -36,7 +36,7 @@ public class BallotSummaryLoader {
BallotSummaryController controller = fxmlLoader.getController();
// set the controller to be functional TwoWayNode
controller.SetParent(ballotSummary);
controller.SetCurrentScene(ballotSummary);
controller.SetStage(currentStage);
// set the controller to have the configuration file

View File

@ -13,7 +13,13 @@ public class CastOrAuditController extends TwoWayNode {
@FXML
private void GetToVoteHaveBeenCast(MouseEvent mousePressed) {
this.currentStage.close();
this.currentStage.setScene(this.next);
this.next.UpdateNode();
this.currentStage.setScene(this.next.GetCurrentScene());
this.currentStage.show();
}
@Override
public void UpdateNode() {
// Maybe one of the buttons should be disabled ?
}
}

View File

@ -36,7 +36,7 @@ public class CastOrAuditLoader {
CastOrAuditController controller = fxmlLoader.getController();
// set the controller to be functional TwoWayNode
controller.SetParent(castOrAudit);
controller.SetCurrentScene(castOrAudit);
controller.SetStage(currentStage);
// set the controller to have the configuration file

View File

@ -22,64 +22,25 @@ public class SelectCandidateByPictureController extends TwoWayNode {
private List<Voting.BallotQuestion> questions;
private List<Voting.BallotAnswer> answers;
public void SetQuestions(List<Voting.BallotQuestion> questions) throws InterruptedException {
this.questions = questions;
this.GetAnswers();
}
public List<Voting.BallotAnswer> GetAnswers() throws InterruptedException {
return null;
}
@FXML
private void submitTheSelection(MouseEvent mousePressed){
BorderPane b = (BorderPane) mousePressed.getSource();
int id = Integer.parseInt(b.getId().split("_")[1]);
unColorAllOthers(id);
b.setBackground(new Background(new BackgroundFill(Color.RED, CornerRadii.EMPTY, Insets.EMPTY)));
}
private List<Voting.BallotAnswer> getAnswers(String id){
String name = getCandidateName(id);
return null;
}
/**
* Gets the name of the candidate
* @param id
* @return
*/
private String getCandidateName(String id){
return ((Label)this.currentStage.getScene().lookup("#name"+id)).getText();
}
/**
* Uncolors all the not selected picttures of candidates
* @param id the id of the selected candidate
*/
private void unColorAllOthers(int id){
for (int i = 0 ; i < 3 ; i++ ){
BorderPane b = (BorderPane)currentStage.getScene().lookup("#picture_"+i);
if (i != id) {
b.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
}
}
}
@FXML
private void GetToSelectByName(MouseEvent mousePressed){
this.currentStage.close();
this.currentStage.setScene(this.previous);
this.next.UpdateNode();
this.currentStage.setScene(this.next.GetCurrentScene());
this.currentStage.show();
}
@FXML
private void GetToBallotSummary(MouseEvent mousePressed){
this.currentStage.close();
this.currentStage.setScene(this.next);
this.previous.UpdateNode();
this.currentStage.setScene(this.previous.GetCurrentScene());
this.currentStage.show();
}
@Override
public void UpdateNode() {
// Update the visual representations of the voters options
}
}

View File

@ -36,7 +36,7 @@ public class SelectCandidateByPictureLoader {
meerkat.voting.gui.select_candidate_by_picture.SelectCandidateByPictureController controller = fxmlLoader.getController();
// set the controller to be functional TwoWayNode
controller.SetParent(selectByPicture);
controller.SetCurrentScene(selectByPicture);
controller.SetStage(currentStage);
// set the controller to have the configuration file

View File

@ -13,14 +13,16 @@ public class SelectCandidateNameController extends TwoWayNode {
@FXML
private void GetToSelectChannel(MouseEvent mousePressed){
this.currentStage.close();
this.currentStage.setScene(this.previous);
this.next.UpdateNode();
this.currentStage.setScene(this.next.GetCurrentScene());
this.currentStage.show();
}
@FXML
private void SelectCandidateByName(MouseEvent mousePressed) {
this.currentStage.close();
this.currentStage.setScene(this.next);
this.previous.UpdateNode();
this.currentStage.setScene(this.previous.GetCurrentScene());
this.currentStage.show();
}

View File

@ -16,7 +16,8 @@ public class StraightChannelSectionController extends TwoWayNode {
@FXML
private void ProceedToNameSelection(MouseEvent boutonPressed) {
this.currentStage.close();
this.currentStage.setScene(this.next);
this.next.UpdateNode();
this.currentStage.setScene(this.next.GetCurrentScene());
this.currentStage.show();
}

View File

@ -14,7 +14,8 @@ public class WelcomeSplashController extends TwoWayNode {
@FXML
private void StartVotingProcess(MouseEvent mousePressed) {
this.currentStage.close();
this.currentStage.setScene(this.next);
this.next.UpdateNode();
this.currentStage.setScene(this.next.GetCurrentScene());
this.currentStage.show();
}