Changed the managing of events in PSDController
Now thw evwnts management is in the EventHandlerMapvoting-station-gui
parent
fc21a215d3
commit
61c65594f5
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue