Removed the lodge appeal managment from event handler map

the lodge appeal object is sub flow of the submit voter flow which means
that polling station dashboard should not know about its existance.
voting-station-gui
Vladimir Eliezer Tokarev 2016-07-02 18:05:29 +03:00
parent c7c6f26db1
commit 1fa38ddb5f
9 changed files with 46 additions and 23 deletions

View File

@ -34,7 +34,7 @@ public class EventHandlerMap {
}
catch (RuntimeException e) {
System.out.println("The event map doesn't have this kind of event handler : " + e);
throw e;
// add logs ...
}
}
}

View File

@ -39,12 +39,6 @@ public class EventHandlerMapper {
map.Add("StatusLogButton", statusLogVisualUpdater);
map.Add("StatusLog", statusLogVisualUpdater);
// maps lodge appeal object to lodge appeal visual updater
LodgeAppealLoader lodgeAppealLoader = new LodgeAppealLoader(primaryStage);
LodgeAppealVisualUpdater lodgeAppealVisualUpdater = new LodgeAppealVisualUpdater(
lodgeAppealLoader.GetSettingsInstance(), primaryStage);
map.Add("LodgeAppealButton", lodgeAppealVisualUpdater);
// map add voter to search button triggered
SearchHandler searchHandler = new SearchHandler(primaryStage, new DummyVotersFetcher());
map.Add("SearchButton", searchHandler);

View File

@ -1,8 +1,10 @@
package polling_station_dashboard.search.submitVoter;
import javafx.fxml.FXML;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import polling_station_dashboard.search.submitVoter.lodgeAppeal.LodgeAppealVisualUpdater;
/**
* Created by Vladimir Eliezer Tokarev on 18/06/2016.
@ -11,12 +13,22 @@ import javafx.stage.Stage;
*/
public class SubmitVoterController {
private Stage currentStage;
private LodgeAppealVisualUpdater lodgeAppealVisualUpdater;
public void SetStage(Stage primaryStage)
{
this.currentStage = primaryStage;
}
public void SetLodgeAppeal(GridPane lodgeAppeal){
this.lodgeAppealVisualUpdater = new LodgeAppealVisualUpdater(lodgeAppeal, currentStage);
}
@FXML
private void AddLodgeAppeal(){
this.lodgeAppealVisualUpdater.UpdateLodgeAppeal();
}
@FXML
private void RemoveSubmitVoterPanel()
{

View File

@ -5,6 +5,7 @@ import javafx.scene.Parent;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import polling_station_dashboard.search.submitVoter.lodgeAppeal.LodgeAppealLoader;
import java.io.IOException;
import java.util.HashMap;
@ -39,9 +40,13 @@ public class SubmitVoterLoader {
Parent root = this.fxmlLoader.load();
ResetVoterParams(voter, root);
LodgeAppealLoader lodgeAppealLoader = new LodgeAppealLoader(currentStage);
SubmitVoterController controller = fxmlLoader.getController();
Pane addEditPane = (Pane)currentStage.getScene().lookup("#AddEditPane");
addEditPane.getChildren().add(root);
controller.SetStage(currentStage);
controller.SetLodgeAppeal(lodgeAppealLoader.GetSettingsInstance());
}
}

View File

@ -1,5 +1,7 @@
package polling_station_dashboard.search.submitVoter.lodgeAppeal;
import javafx.fxml.FXML;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
/**
@ -13,4 +15,12 @@ public class LodgeAppealController {
{
this.currentStage = primaryStage;
}
@FXML
private void HandleCancel(){
Pane addEditPane = (Pane) currentStage.getScene().lookup("#AddEditPane");
// the add edit pane have only one child at a time which mean removing the child in index 0 will
// clean the add edit pane
addEditPane.getChildren().remove(0);
}
}

View File

@ -1,7 +1,5 @@
package polling_station_dashboard.search.submitVoter.lodgeAppeal;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
@ -11,7 +9,7 @@ import javafx.stage.Stage;
* LodgeAppealVisualUpdater is in response of add and remove the lodge appeal panel
* to polling station dashboard
*/
public class LodgeAppealVisualUpdater implements EventHandler {
public class LodgeAppealVisualUpdater {
private Stage currentStage;
private GridPane lodgeAppeal;
@ -23,22 +21,26 @@ public class LodgeAppealVisualUpdater implements EventHandler {
this.currentStage = primalStage;
}
private void UpdateLodgeAppeal() {
public void UpdateLodgeAppeal() {
if (!lodgeAppealOpened) {
addLodgeAppeal();
ClearAddEditPanel();
AddLodgeAppeal();
}
else {
ClearAddEditPanel();
}
lodgeAppealOpened = !lodgeAppealOpened;
}
private void addLodgeAppeal() {
private void ClearAddEditPanel(){
Pane addEditPane = (Pane) currentStage.getScene().lookup("#AddEditPane");
// the add edit pane have only one child at a time which mean removing the child in index 0 will
// clean the add edit pane
addEditPane.getChildren().remove(0);
}
private void AddLodgeAppeal() {
Pane addEditPane = (Pane)currentStage.getScene().lookup("#AddEditPane");
addEditPane.getChildren().add(lodgeAppeal);
}
@Override
public void handle(Event event) {
UpdateLodgeAppeal();
}
}

View File

@ -7,8 +7,7 @@
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="753.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8"
fx:controller="polling_station_dashboard.search.submitVoter.lodgeAppeal.LodgeAppealController">
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="435.0" prefWidth="753.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="polling_station_dashboard.search.submitVoter.lodgeAppeal.LodgeAppealController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
@ -429,7 +428,7 @@
<children>
<BorderPane prefHeight="200.0" prefWidth="200.0">
<right>
<Button mnemonicParsing="false" prefHeight="37.0" prefWidth="111.0" text="cancel" BorderPane.alignment="CENTER" />
<Button mnemonicParsing="false" onMousePressed="#HandleCancel" prefHeight="37.0" prefWidth="111.0" text="cancel" BorderPane.alignment="CENTER" />
</right>
</BorderPane>
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">

View File

@ -2,6 +2,7 @@
<!-- Created By Vladimir Eliezer Tokarev !-->
<?import java.lang.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
@ -37,7 +38,7 @@
</ImageView>
</left>
<center>
<TextField fx:id="SearchValue" prefHeight="56.0" prefWidth="536.0" BorderPane.alignment="CENTER" text="IDNumber: 123123123, FilterName2: value2 ..." />
<TextField fx:id="SearchValue" prefHeight="56.0" prefWidth="536.0" text="IDNumber: 123123123, FilterName2: value2 ..." BorderPane.alignment="CENTER" />
</center>
</BorderPane>
</children>

View File

@ -176,7 +176,7 @@
</GridPane>
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="6">
<top>
<Button mnemonicParsing="false" text="Lodge appeal" BorderPane.alignment="CENTER" />
<Button mnemonicParsing="false" onMousePressed="#AddLodgeAppeal" text="Lodge appeal" BorderPane.alignment="CENTER" />
</top>
</BorderPane>
</children>