From ff4ad81cca24e2e07a7dbbdf639e07e23f4ada83 Mon Sep 17 00:00:00 2001 From: Vladimir Eliezer Tokarev Date: Sat, 2 Jul 2016 17:35:47 +0300 Subject: [PATCH] Created lodge appeal visual updater Lodge Appeal Visual Updter adds and removes lodge appeal pannel from and to the polling station dashboard. --- .../EventHandlerMapper.java | 12 ++++- .../lodgeAppeal/LodgeAppealVisualUpdater.java | 44 +++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 polling-station-gui/src/main/java/polling_station_dashboard/search/submitVoter/lodgeAppeal/LodgeAppealVisualUpdater.java diff --git a/polling-station-gui/src/main/java/polling_station_dashboard/EventHandlerMapper.java b/polling-station-gui/src/main/java/polling_station_dashboard/EventHandlerMapper.java index 0dd245f..b758ca3 100644 --- a/polling-station-gui/src/main/java/polling_station_dashboard/EventHandlerMapper.java +++ b/polling-station-gui/src/main/java/polling_station_dashboard/EventHandlerMapper.java @@ -2,6 +2,8 @@ package polling_station_dashboard; import javafx.stage.Stage; import polling_station_dashboard.search.SearchHandler; +import polling_station_dashboard.search.submitVoter.lodgeAppeal.LodgeAppealLoader; +import polling_station_dashboard.search.submitVoter.lodgeAppeal.LodgeAppealVisualUpdater; import polling_station_dashboard.search.votersFetcher.DummyVotersFetcher; import polling_station_dashboard.settings.SettingsVisualUpdater; import polling_station_dashboard.settings.settingsLoader; @@ -23,20 +25,26 @@ public class EventHandlerMapper { { EventHandlerMap map = new EventHandlerMap(); - // Map status log objects to settings visual updater + // maps status log object to settings visual updater settingsLoader settingsLoader = new settingsLoader(primaryStage); SettingsVisualUpdater settingsVisualUpdater = new SettingsVisualUpdater(settingsLoader.GetSettingsInstance(), primaryStage); map.Add("SettingsButton", settingsVisualUpdater); map.Add("Settings", settingsVisualUpdater); - // map settings objects to status log visual updater + // maps settings object to status log visual updater StatusLogLoader statusLogLoader = new StatusLogLoader(primaryStage); StatusLogVisualUpdater statusLogVisualUpdater = new StatusLogVisualUpdater(statusLogLoader.GetStatusLogInstance(), primaryStage); 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); diff --git a/polling-station-gui/src/main/java/polling_station_dashboard/search/submitVoter/lodgeAppeal/LodgeAppealVisualUpdater.java b/polling-station-gui/src/main/java/polling_station_dashboard/search/submitVoter/lodgeAppeal/LodgeAppealVisualUpdater.java new file mode 100644 index 0000000..59f3dcc --- /dev/null +++ b/polling-station-gui/src/main/java/polling_station_dashboard/search/submitVoter/lodgeAppeal/LodgeAppealVisualUpdater.java @@ -0,0 +1,44 @@ +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; + +/** + * Created by dasha on 7/2/2016. + * LodgeAppealVisualUpdater is in response of add and remove the lodge appeal panel + * to polling station dashboard + */ +public class LodgeAppealVisualUpdater implements EventHandler { + + private Stage currentStage; + private GridPane lodgeAppeal; + private boolean lodgeAppealOpened = false; + + public LodgeAppealVisualUpdater(GridPane lodgeAppeal, Stage primalStage) + { + this.lodgeAppeal = lodgeAppeal; + this.currentStage = primalStage; + } + + private void UpdateLodgeAppeal() { + if (!lodgeAppealOpened) { + addLodgeAppeal(); + } + else { + } + lodgeAppealOpened = !lodgeAppealOpened; + } + + private void addLodgeAppeal() { + Pane addEditPane = (Pane)currentStage.getScene().lookup("#AddEditPane"); + addEditPane.getChildren().add(lodgeAppeal); + } + + @Override + public void handle(Event event) { + UpdateLodgeAppeal(); + } +}