2016-05-28 10:50:22 -04:00
|
|
|
package polling_station_dashboard.java;
|
|
|
|
|
2016-06-04 06:01:06 -04:00
|
|
|
import javafx.fxml.FXML;
|
2016-06-04 08:11:18 -04:00
|
|
|
import javafx.scene.control.Button;
|
|
|
|
import javafx.scene.layout.GridPane;
|
2016-06-04 06:01:06 -04:00
|
|
|
import javafx.scene.layout.Pane;
|
2016-05-28 11:00:40 -04:00
|
|
|
import javafx.stage.Stage;
|
2016-06-04 08:11:18 -04:00
|
|
|
import polling_station_dashboard.StatusLog.java.StatusLogUpdate;
|
2016-06-04 09:05:12 -04:00
|
|
|
import polling_station_dashboard.settings.java.SettingsUpdate;
|
2016-05-28 11:00:40 -04:00
|
|
|
|
2016-05-28 10:50:22 -04:00
|
|
|
/**
|
|
|
|
* Created by Vladimir Eliezer Tokarev on 28/05/2016.
|
2016-06-04 08:11:18 -04:00
|
|
|
* PollingStationDashboardController controls the behavior of the polling station dashboard
|
2016-05-28 10:50:22 -04:00
|
|
|
*/
|
2016-06-04 09:05:12 -04:00
|
|
|
public class PollingStationDashboardController implements StatusLogUpdate, SettingsUpdate {
|
2016-05-28 11:00:40 -04:00
|
|
|
|
|
|
|
private Stage currentStage;
|
2016-06-04 08:11:18 -04:00
|
|
|
private GridPane statusLog;
|
2016-05-28 11:00:40 -04:00
|
|
|
|
2016-06-04 06:01:06 -04:00
|
|
|
private boolean statusLogOpened = false;
|
|
|
|
|
2016-06-04 08:11:18 -04:00
|
|
|
public void SetStage(Stage primaryStage) {
|
2016-05-28 11:00:40 -04:00
|
|
|
this.currentStage = primaryStage;
|
|
|
|
}
|
2016-06-04 06:01:06 -04:00
|
|
|
|
2016-06-04 08:11:18 -04:00
|
|
|
public void SetStatusLog(GridPane statusLog){
|
|
|
|
this.statusLog = statusLog;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void UpdateStatusLog(){
|
|
|
|
showStatusLogButton(statusLogOpened);
|
2016-06-04 06:01:06 -04:00
|
|
|
if (!statusLogOpened) {
|
|
|
|
SetStatusLogSize(400);
|
2016-06-04 08:11:18 -04:00
|
|
|
addStatusLog();
|
2016-06-04 06:01:06 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
SetStatusLogSize(-400);
|
2016-06-04 08:11:18 -04:00
|
|
|
removeStatusLog();
|
2016-06-04 06:01:06 -04:00
|
|
|
}
|
|
|
|
statusLogOpened = !statusLogOpened;
|
|
|
|
}
|
|
|
|
|
2016-06-04 09:05:12 -04:00
|
|
|
@Override
|
|
|
|
public void UpdateSettings() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-04 08:11:18 -04:00
|
|
|
private void showStatusLogButton(boolean showOrNot){
|
|
|
|
Button statusLogButton = (Button) currentStage.getScene().lookup("#StatusLogButton");
|
|
|
|
statusLogButton.setVisible(showOrNot);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addStatusLog() {
|
|
|
|
Pane statusLogPane = (Pane) currentStage.getScene().lookup("#StatusLog");
|
|
|
|
statusLogPane.getChildren().add(statusLog);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void removeStatusLog(){
|
|
|
|
Pane statusLogPane = (Pane) currentStage.getScene().lookup("#StatusLog");
|
|
|
|
statusLogPane.getChildren().remove(statusLog);
|
|
|
|
}
|
|
|
|
|
2016-06-04 06:01:06 -04:00
|
|
|
private void SetStatusLogSize(int expansionWidth) {
|
|
|
|
currentStage.setWidth(currentStage.getWidth() + expansionWidth);
|
2016-06-04 08:11:18 -04:00
|
|
|
Pane statusLogPane = (Pane) currentStage.getScene().lookup("#StatusLog");
|
|
|
|
statusLogPane.setPrefWidth(expansionWidth);
|
2016-06-04 06:01:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
private void OnStatusLogPressed() {
|
2016-06-04 08:11:18 -04:00
|
|
|
UpdateStatusLog();
|
2016-06-04 06:01:06 -04:00
|
|
|
}
|
2016-05-28 10:50:22 -04:00
|
|
|
}
|