69 lines
2.1 KiB
Java
69 lines
2.1 KiB
Java
package polling_station_dashboard.statusLog;
|
|
|
|
import javafx.event.Event;
|
|
import javafx.event.EventHandler;
|
|
import javafx.scene.control.Button;
|
|
import javafx.scene.layout.GridPane;
|
|
import javafx.scene.layout.Pane;
|
|
import javafx.stage.Stage;
|
|
|
|
/**
|
|
* Created by Vladimir Eliezer Tokarev on 12/06/2016.
|
|
* This object manages the visual changes of the status log panel
|
|
* which means that he opens and closes status log panel)
|
|
*/
|
|
public class StatusLogVisualUpdater implements EventHandler {
|
|
|
|
private static final int STATUS_LOG_WIDTH_EXPANSION_VALUE = 400;
|
|
private boolean statusLogOpened = false;
|
|
private Stage currentStage;
|
|
private GridPane statusLog;
|
|
|
|
|
|
public StatusLogVisualUpdater(GridPane statusLog, Stage primalStage)
|
|
{
|
|
this.statusLog = statusLog;
|
|
this.currentStage = primalStage;
|
|
}
|
|
|
|
public void UpdateStatusLog(){
|
|
showStatusLogButton(statusLogOpened);
|
|
if (!statusLogOpened) {
|
|
SetStatusLogSize(STATUS_LOG_WIDTH_EXPANSION_VALUE);
|
|
addStatusLog();
|
|
}
|
|
else {
|
|
SetStatusLogSize(-STATUS_LOG_WIDTH_EXPANSION_VALUE);
|
|
removeStatusLog();
|
|
}
|
|
statusLogOpened = !statusLogOpened;
|
|
}
|
|
|
|
private void showStatusLogButton(boolean showOrNot){
|
|
Button statusLogButton = (Button) currentStage.getScene().lookup("#StatusLogButton");
|
|
statusLogButton.setVisible(showOrNot);
|
|
}
|
|
|
|
private void addStatusLog() {
|
|
Pane statusLog = (Pane) currentStage.getScene().lookup("#statusLog");
|
|
statusLog.getChildren().add(this.statusLog);
|
|
}
|
|
|
|
private void removeStatusLog(){
|
|
Pane statusLog = (Pane) currentStage.getScene().lookup("#statusLog");
|
|
statusLog.getChildren().remove(this.statusLog);
|
|
}
|
|
|
|
private void SetStatusLogSize(int expansionWidth) {
|
|
currentStage.setWidth(currentStage.getWidth() + expansionWidth);
|
|
Pane statusLog = (Pane) currentStage.getScene().lookup("#statusLog");
|
|
statusLog.setPrefWidth(expansionWidth);
|
|
}
|
|
|
|
|
|
@Override
|
|
public void handle(Event event) {
|
|
UpdateStatusLog();
|
|
}
|
|
}
|