Created the status log update interface
in order to reduce coupling between polling station dashboard and all other elements it produces and uses i have created status log update interface, which expose the functuality of update the state of status log panel. the idea behind this is status log does not have to know polling station dashboard. all other objects that polling station dashboard will use will have their own interfaces (for the same reason too).voting-station-gui
parent
b0c4fff11a
commit
f2a26b7145
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 371 B |
|
@ -2,17 +2,27 @@
|
||||||
|
|
||||||
<!-- Created By Vladimir Eliezer Tokarev !-->
|
<!-- Created By Vladimir Eliezer Tokarev !-->
|
||||||
|
|
||||||
<?import java.lang.*?>
|
<?import javafx.geometry.*?>
|
||||||
<?import javafx.scene.image.*?>
|
<?import javafx.scene.image.*?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
<GridPane prefHeight="615.0" prefWidth="400.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
|
<GridPane fx:id="StatusLogGridPane" prefHeight="615.0" prefWidth="400.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="polling_station_dashboard.StatusLog.java.StatusLogController">
|
||||||
<children>
|
<children>
|
||||||
<BorderPane prefHeight="200.0" prefWidth="200.0">
|
<BorderPane onMousePressed="#CloseStatusLog" prefHeight="200.0" prefWidth="200.0">
|
||||||
<center>
|
<center>
|
||||||
<Label text="Status Log" BorderPane.alignment="CENTER" />
|
<Label text="Status Log" BorderPane.alignment="CENTER" />
|
||||||
</center>
|
</center>
|
||||||
|
<left>
|
||||||
|
<ImageView BorderPane.alignment="CENTER">
|
||||||
|
<image>
|
||||||
|
<Image url="@../../../pictures/blacktriangle.png" />
|
||||||
|
</image>
|
||||||
|
<BorderPane.margin>
|
||||||
|
<Insets left="10.0" />
|
||||||
|
</BorderPane.margin>
|
||||||
|
</ImageView>
|
||||||
|
</left>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
<Accordion GridPane.rowIndex="1">
|
<Accordion GridPane.rowIndex="1">
|
||||||
<panes>
|
<panes>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package polling_station_dashboard.StatusLog.java;
|
package polling_station_dashboard.StatusLog.java;
|
||||||
|
|
||||||
|
import javafx.fxml.FXML;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,10 +10,21 @@ import javafx.stage.Stage;
|
||||||
public class StatusLogController {
|
public class StatusLogController {
|
||||||
|
|
||||||
private Stage primaryStage;
|
private Stage primaryStage;
|
||||||
|
private StatusLogUpdate statusLogUpdater;
|
||||||
|
|
||||||
|
public void SetStatusLogUpdater(StatusLogUpdate updater){
|
||||||
|
statusLogUpdater = updater;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetStage(Stage stage){
|
public void SetStage(Stage stage){
|
||||||
primaryStage = stage;
|
primaryStage = stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private void CloseStatusLog(){
|
||||||
|
// UpdateStatusLog is called from open status log object which means that
|
||||||
|
// the current UpdateStatusLog will close it
|
||||||
|
statusLogUpdater.UpdateStatusLog();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,17 +16,20 @@ public class StatusLogLoader {
|
||||||
|
|
||||||
private Stage currentStage;
|
private Stage currentStage;
|
||||||
private FXMLLoader fxmlLoader;
|
private FXMLLoader fxmlLoader;
|
||||||
|
private StatusLogUpdate statusLogUpdater;
|
||||||
|
|
||||||
public StatusLogLoader (Stage primaryStage) throws IOException
|
public StatusLogLoader (Stage primaryStage, StatusLogUpdate updater) throws IOException
|
||||||
{
|
{
|
||||||
currentStage = primaryStage;
|
currentStage = primaryStage;
|
||||||
|
statusLogUpdater = updater;
|
||||||
fxmlLoader = new FXMLLoader(getClass().getResource(POLLING_STATION_DASHBOARD_FXML_PATH));
|
fxmlLoader = new FXMLLoader(getClass().getResource(POLLING_STATION_DASHBOARD_FXML_PATH));
|
||||||
}
|
}
|
||||||
|
|
||||||
private GridPane GetStatusLogInstance() throws IOException {
|
public GridPane GetStatusLogInstance() throws IOException {
|
||||||
GridPane StatusLog = (GridPane) fxmlLoader.load();
|
GridPane StatusLog = fxmlLoader.load();
|
||||||
StatusLogController controller = fxmlLoader.getController();
|
StatusLogController controller = fxmlLoader.getController();
|
||||||
controller.SetStage(currentStage);
|
controller.SetStage(currentStage);
|
||||||
|
controller.SetStatusLogUpdater(statusLogUpdater);
|
||||||
|
|
||||||
return StatusLog;
|
return StatusLog;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package polling_station_dashboard.StatusLog.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Vladimir Eliezer Tokarev on 04/06/2016.
|
||||||
|
* StatusLogUpdate gives the ability to update the status log object
|
||||||
|
* decouple status log from polling station dashboard
|
||||||
|
*/
|
||||||
|
public interface StatusLogUpdate {
|
||||||
|
|
||||||
|
void UpdateStatusLog();
|
||||||
|
}
|
|
@ -69,7 +69,7 @@
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
<Pane fx:id="StatusLog" layoutX="788.0" layoutY="12.0" prefHeight="544.0" prefWidth="42.0">
|
<Pane fx:id="StatusLog" layoutX="788.0" layoutY="12.0" prefHeight="544.0" prefWidth="42.0">
|
||||||
<children>
|
<children>
|
||||||
<Button layoutX="-251.0" layoutY="250.0" mnemonicParsing="false" onMousePressed="#OnStatusLogPressed" prefHeight="43.0" prefWidth="545.0" rotate="-90.0" text="Status Log" />
|
<Button fx:id="StatusLogButton" layoutX="-251.0" layoutY="250.0" mnemonicParsing="false" onMousePressed="#OnStatusLogPressed" prefHeight="43.0" prefWidth="545.0" rotate="-90.0" text="Status Log" />
|
||||||
</children>
|
</children>
|
||||||
</Pane>
|
</Pane>
|
||||||
<Pane layoutY="557.0" prefHeight="34.0" prefWidth="830.0">
|
<Pane layoutY="557.0" prefHeight="34.0" prefWidth="830.0">
|
||||||
|
|
|
@ -1,42 +1,69 @@
|
||||||
package polling_station_dashboard.java;
|
package polling_station_dashboard.java;
|
||||||
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import polling_station_dashboard.StatusLog.java.StatusLogUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Vladimir Eliezer Tokarev on 28/05/2016.
|
* Created by Vladimir Eliezer Tokarev on 28/05/2016.
|
||||||
|
* PollingStationDashboardController controls the behavior of the polling station dashboard
|
||||||
*/
|
*/
|
||||||
public class PollingStationDashboardController {
|
public class PollingStationDashboardController implements StatusLogUpdate {
|
||||||
|
|
||||||
private Stage currentStage;
|
private Stage currentStage;
|
||||||
|
private GridPane statusLog;
|
||||||
|
|
||||||
private boolean statusLogOpened = false;
|
private boolean statusLogOpened = false;
|
||||||
|
|
||||||
public void SetStage(Stage primaryStage)
|
public void SetStage(Stage primaryStage) {
|
||||||
{
|
|
||||||
this.currentStage = primaryStage;
|
this.currentStage = primaryStage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setStatusLog(){
|
public void SetStatusLog(GridPane statusLog){
|
||||||
|
this.statusLog = statusLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void UpdateStatusLog(){
|
||||||
|
showStatusLogButton(statusLogOpened);
|
||||||
if (!statusLogOpened) {
|
if (!statusLogOpened) {
|
||||||
SetStatusLogSize(400);
|
SetStatusLogSize(400);
|
||||||
|
addStatusLog();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SetStatusLogSize(-400);
|
SetStatusLogSize(-400);
|
||||||
|
removeStatusLog();
|
||||||
}
|
}
|
||||||
statusLogOpened = !statusLogOpened;
|
statusLogOpened = !statusLogOpened;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
private void SetStatusLogSize(int expansionWidth) {
|
private void SetStatusLogSize(int expansionWidth) {
|
||||||
currentStage.setWidth(currentStage.getWidth() + expansionWidth);
|
currentStage.setWidth(currentStage.getWidth() + expansionWidth);
|
||||||
Pane statusLogGrid = (Pane) currentStage.getScene().lookup("#StatusLog");
|
Pane statusLogPane = (Pane) currentStage.getScene().lookup("#StatusLog");
|
||||||
statusLogGrid.setPrefWidth(expansionWidth);
|
statusLogPane.setPrefWidth(expansionWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void OnStatusLogPressed() {
|
private void OnStatusLogPressed() {
|
||||||
setStatusLog();
|
UpdateStatusLog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import polling_station_dashboard.StatusLog.java.StatusLogLoader;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public class PollingStationDashboardLoader {
|
public class PollingStationDashboardLoader {
|
||||||
|
|
||||||
private static final String POLLING_STATION_DASHBOARD_FXML_PATH = "../fxml/status_log.fxml";
|
private static final String POLLING_STATION_DASHBOARD_FXML_PATH = "../fxml/polling_station_dashboard.fxml";
|
||||||
|
|
||||||
private Stage currentStage;
|
private Stage currentStage;
|
||||||
|
|
||||||
|
@ -28,6 +29,9 @@ public class PollingStationDashboardLoader {
|
||||||
currentStage.setScene(new Scene(root, 850, 615));
|
currentStage.setScene(new Scene(root, 850, 615));
|
||||||
currentStage.show();
|
currentStage.show();
|
||||||
|
|
||||||
|
StatusLogLoader statusLogLoader = new StatusLogLoader(currentStage, controller);
|
||||||
controller.SetStage(currentStage);
|
controller.SetStage(currentStage);
|
||||||
|
controller.SetStatusLog(statusLogLoader.GetStatusLogInstance());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue