diff --git a/voting-station-gui/src/polling_station_dashboard/java/EventHandlerMap.java b/voting-station-gui/src/polling_station_dashboard/java/EventHandlerMap.java index c62b47b..f371501 100644 --- a/voting-station-gui/src/polling_station_dashboard/java/EventHandlerMap.java +++ b/voting-station-gui/src/polling_station_dashboard/java/EventHandlerMap.java @@ -2,7 +2,7 @@ package polling_station_dashboard.java; import javafx.event.Event; import javafx.event.EventHandler; -import javafx.scene.control.Control; +import javafx.scene.Parent; import java.util.HashMap; /** @@ -27,6 +27,6 @@ public class EventHandlerMap { public void Handle(Event event) { - this.eventIdToHandler.get(((Control)event.getSource()).getId()).handle(event); + this.eventIdToHandler.get(((Parent)event.getSource()).getId()).handle(event); } } diff --git a/voting-station-gui/src/polling_station_dashboard/java/EventHandlerMapper.java b/voting-station-gui/src/polling_station_dashboard/java/EventHandlerMapper.java index c72bfd4..8efdee0 100644 --- a/voting-station-gui/src/polling_station_dashboard/java/EventHandlerMapper.java +++ b/voting-station-gui/src/polling_station_dashboard/java/EventHandlerMapper.java @@ -25,17 +25,16 @@ public class EventHandlerMapper { settingsLoader settingsLoader = new settingsLoader(primaryStage); SettingsVisualUpdater settingsVisualUpdater = new SettingsVisualUpdater(settingsLoader.GetSettingsInstance(), primaryStage); - map.Add("StatusLogButton", settingsVisualUpdater); - map.Add("StatusLog", settingsVisualUpdater); + map.Add("SettingsButton", settingsVisualUpdater); + map.Add("Settings", settingsVisualUpdater); // map settings objects to status log visual updater StatusLogLoader statusLogLoader = new StatusLogLoader(primaryStage); StatusLogVisualUpdater statusLogVisualUpdater = new StatusLogVisualUpdater(statusLogLoader.GetStatusLogInstance(), primaryStage); - map.Add("SettingsButton", statusLogVisualUpdater); - map.Add("Settings", statusLogVisualUpdater); - - return map + map.Add("StatusLogButton", statusLogVisualUpdater); + map.Add("StatusLog", statusLogVisualUpdater); + return map; } } diff --git a/voting-station-gui/src/polling_station_dashboard/java/PollingStationDashboardController.java b/voting-station-gui/src/polling_station_dashboard/java/PollingStationDashboardController.java index 1e44df4..665274f 100644 --- a/voting-station-gui/src/polling_station_dashboard/java/PollingStationDashboardController.java +++ b/voting-station-gui/src/polling_station_dashboard/java/PollingStationDashboardController.java @@ -2,51 +2,34 @@ package polling_station_dashboard.java; import javafx.fxml.FXML; import javafx.scene.input.MouseEvent; -import javafx.stage.Stage; -import polling_station_dashboard.statusLog.java.StatusLogUpdate; -import polling_station_dashboard.settings.java.SettingsUpdate; /** * Created by Vladimir Eliezer Tokarev on 28/05/2016. * PollingStationDashboardController controls the behavior of the polling station dashboard */ public class PollingStationDashboardController { + private EventHandlerMap eventHandlerMap; - private SettingsUpdate SettingsVisualUpdater; - private StatusLogUpdate StatusLogVisualUpdater; - private Stage currentStage; - - public void SetStage(Stage primaryStage) + public void SetEventHandlerMap(EventHandlerMap map) { - this.currentStage = primaryStage; + this.eventHandlerMap = map; } + @FXML - public void SetSettingsVisualUpdater(SettingsUpdate settingsVisualUpdater) + private void OnStatusLogPressed(MouseEvent mousePressed) { - this.SettingsVisualUpdater = settingsVisualUpdater; - } - - public void SetStatusLogVisualUpdater(StatusLogUpdate statusLogVisualUpdater) - { - this.StatusLogVisualUpdater = statusLogVisualUpdater; + this.eventHandlerMap.Handle(mousePressed); } @FXML - private void OnStatusLogPressed(MouseEvent mousePresed) + private void OnSettingsPressed(MouseEvent mousePressed) { - StatusLogVisualUpdater.UpdateStatusLog(); + this.eventHandlerMap.Handle(mousePressed); } - @FXML - private void OnSettingsPressed() + private void SearchTrigered(MouseEvent mousePressed) { - SettingsVisualUpdater.UpdateSettings(); - } - - - @FXML - private void SearchTrigered(){ - + this.eventHandlerMap.Handle(mousePressed); } } diff --git a/voting-station-gui/src/polling_station_dashboard/java/PollingStationDashboardLoader.java b/voting-station-gui/src/polling_station_dashboard/java/PollingStationDashboardLoader.java index 6fdf3a2..e6a140c 100644 --- a/voting-station-gui/src/polling_station_dashboard/java/PollingStationDashboardLoader.java +++ b/voting-station-gui/src/polling_station_dashboard/java/PollingStationDashboardLoader.java @@ -4,10 +4,6 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; -import polling_station_dashboard.settings.java.SettingsVisualUpdater; -import polling_station_dashboard.statusLog.java.StatusLogLoader; -import polling_station_dashboard.settings.java.settingsLoader; -import polling_station_dashboard.statusLog.java.StatusLogVisualUpdater; import java.io.IOException; @@ -35,25 +31,6 @@ public class PollingStationDashboardLoader { currentStage.setScene(new Scene(root, 850, 615)); currentStage.show(); - controller.SetStage(currentStage); - setSettingsUpdater(controller); - setStatusLogUpdater(controller); - - } - - private void setSettingsUpdater(PollingStationDashboardController controller) throws IOException - { - settingsLoader settingsLoader = new settingsLoader(currentStage); - SettingsVisualUpdater settingsVisualUpdater = - new SettingsVisualUpdater(settingsLoader.GetSettingsInstance(), currentStage); - controller.SetSettingsVisualUpdater(settingsVisualUpdater); - } - - private void setStatusLogUpdater(PollingStationDashboardController controller) throws IOException - { - StatusLogLoader statusLogLoader = new StatusLogLoader(currentStage); - StatusLogVisualUpdater statusLogVisualUpdater = - new StatusLogVisualUpdater(statusLogLoader.GetStatusLogInstance(), currentStage); - controller.SetStatusLogVisualUpdater(statusLogVisualUpdater); + controller.SetEventHandlerMap(EventHandlerMapper.CreateEventHandlerMap(primaryStage)); } }