diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_name/StringsAnswersUpdater.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_name/StringsAnswersUpdater.java index c5cff66..cb8ba57 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_name/StringsAnswersUpdater.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_name/StringsAnswersUpdater.java @@ -119,7 +119,6 @@ class StringsAnswersUpdater implements javafx.event.EventHandler{ if (target.isSelected()) { String answer = target.getId().split("-")[0]; this.answer = answer; - System.out.println(answer); this.uncheckBoxes(target); } } diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/straight_channel_section/StraightChannelSectionController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/straight_channel_section/StraightChannelSectionController.java index 84ffdc6..ac8c33a 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/straight_channel_section/StraightChannelSectionController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/straight_channel_section/StraightChannelSectionController.java @@ -1,14 +1,22 @@ package meerkat.voting.gui.straight_channel_section; import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.TextField; import javafx.scene.input.MouseEvent; import meerkat.voting.gui.TwoWayNode; +import java.util.ArrayList; +import java.util.List; + /** * Created by Vladimir Eliezer Tokarev on 8/27/2016. * StraightChannelSectionController handle the behavior of select channel section screen */ public class StraightChannelSectionController extends TwoWayNode { + private List chanelValue; + private int pointer; + private boolean lock; @FXML private void ProceedToNameSelection(MouseEvent boutonPressed) { @@ -19,7 +27,55 @@ public class StraightChannelSectionController extends TwoWayNode { } @Override + /** + * Creates the array of the canel value + */ public void UpdateNode() { - // Does it suppose to show the channel ? + this.pointer = 0; + this.lock = false; + this.chanelValue = new ArrayList<>(); + this.chanelValue.add(0); + this.chanelValue.add(0); + this.chanelValue.add(0); + this.chanelValue.add(0); + this.updateVisualChanel(); } + + /** + * Updates the visual channel value + */ + private void updateVisualChanel(){ + for (int i = 0 ; i < 4 ; i ++ ){ + String id = "#textarea_"+i; + TextField textField = ((TextField)this.currentStage.getScene().lookup(id)); + textField.setText(String.valueOf(this.chanelValue.get(i))); + } + } + + @FXML + private void numberPressed(MouseEvent mousePressed){ + if (!this.lock) { + String value = ((Button) mousePressed.getSource()).getId().split("_")[1]; + this.chanelValue.set(this.pointer, Integer.parseInt(value)); + this.pointer++; + this.updateVisualChanel(); + if (this.pointer == 4) { + this.lock = true; + } + } + } + + @FXML + private void clearLastNumber(MouseEvent mousePressed){ + if (this.pointer >= 1) { + int lastValueLocation = this.pointer - 1; + this.chanelValue.set(lastValueLocation, 0); + this.currentStage.show(); + this.pointer--; + this.updateVisualChanel(); + this.lock = false; + } + } + + } diff --git a/voting-booth-gui/src/main/resources/view/straight_channel_section.fxml b/voting-booth-gui/src/main/resources/view/straight_channel_section.fxml index 8959884..b497086 100644 --- a/voting-booth-gui/src/main/resources/view/straight_channel_section.fxml +++ b/voting-booth-gui/src/main/resources/view/straight_channel_section.fxml @@ -118,7 +118,7 @@
- + @@ -127,7 +127,7 @@
- + @@ -136,7 +136,7 @@
- + @@ -145,7 +145,7 @@
- + @@ -167,7 +167,7 @@
-
- -