Ended the settings panel

for now we have all the main flow vor the voter voting process (without
all the logic for example the logic of fetching from server who else is
voting right now is not existing, etc'...)
voting-station-gui
Vladimir ELazar Tokarev 2016-06-04 16:48:47 +03:00
parent 725589ddfc
commit b7d8c887ec
8 changed files with 209 additions and 24 deletions

View File

@ -12,7 +12,7 @@ import java.io.IOException;
*/ */
public class StatusLogLoader { public class StatusLogLoader {
private static final String POLLING_STATION_DASHBOARD_FXML_PATH = "../fxml/settings.fxml"; private static final String STATUS_LOG_FXML_PATH = "../fxml/status_log.fxml";
private Stage currentStage; private Stage currentStage;
private FXMLLoader fxmlLoader; private FXMLLoader fxmlLoader;
@ -22,7 +22,7 @@ public class StatusLogLoader {
{ {
currentStage = primaryStage; currentStage = primaryStage;
statusLogUpdater = updater; statusLogUpdater = updater;
fxmlLoader = new FXMLLoader(getClass().getResource(POLLING_STATION_DASHBOARD_FXML_PATH)); fxmlLoader = new FXMLLoader(getClass().getResource(STATUS_LOG_FXML_PATH));
} }
public GridPane GetStatusLogInstance() throws IOException { public GridPane GetStatusLogInstance() throws IOException {

View File

@ -72,9 +72,9 @@
<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" /> <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 fx:id="Settings" layoutX="20" layoutY="557.0" prefHeight="34.0" prefWidth="830.0">
<children> <children>
<Button mnemonicParsing="false" prefHeight="34.0" prefWidth="790.0" text="Settings" /> <Button fx:id="SettingsButton" onMousePressed="#OnSettingsPressed" mnemonicParsing="false" prefHeight="34.0" prefWidth="790.0" text="Settings" />
</children> </children>
</Pane> </Pane>
</children> </children>

View File

@ -14,10 +14,15 @@ import polling_station_dashboard.settings.java.SettingsUpdate;
*/ */
public class PollingStationDashboardController implements StatusLogUpdate, SettingsUpdate { public class PollingStationDashboardController implements StatusLogUpdate, SettingsUpdate {
private static final int STATUS_LOG_WIDTH_EXPANSION_VALUE = 400;
private static final int SETTINGS_HEIGHT_EXPANSION_VALUE = 60;
private Stage currentStage; private Stage currentStage;
private GridPane statusLog; private GridPane statusLog;
private GridPane settings;
private boolean statusLogOpened = false; private boolean statusLogOpened = false;
private boolean settingsOpened = false;
public void SetStage(Stage primaryStage) { public void SetStage(Stage primaryStage) {
this.currentStage = primaryStage; this.currentStage = primaryStage;
@ -27,49 +32,89 @@ public class PollingStationDashboardController implements StatusLogUpdate, Setti
this.statusLog = statusLog; this.statusLog = statusLog;
} }
@FXML
private void OnStatusLogPressed() {
UpdateStatusLog();
}
@Override @Override
public void UpdateStatusLog(){ public void UpdateStatusLog(){
showStatusLogButton(statusLogOpened); showStatusLogButton(statusLogOpened);
if (!statusLogOpened) { if (!statusLogOpened) {
SetStatusLogSize(400); SetStatusLogSize(STATUS_LOG_WIDTH_EXPANSION_VALUE);
addStatusLog(); addStatusLog();
} }
else { else {
SetStatusLogSize(-400); SetStatusLogSize(-STATUS_LOG_WIDTH_EXPANSION_VALUE);
removeStatusLog(); removeStatusLog();
} }
statusLogOpened = !statusLogOpened; statusLogOpened = !statusLogOpened;
} }
@Override
public void UpdateSettings() {
}
private void showStatusLogButton(boolean showOrNot){ private void showStatusLogButton(boolean showOrNot){
Button statusLogButton = (Button) currentStage.getScene().lookup("#StatusLogButton"); Button statusLogButton = (Button) currentStage.getScene().lookup("#StatusLogButton");
statusLogButton.setVisible(showOrNot); statusLogButton.setVisible(showOrNot);
} }
private void addStatusLog() { private void addStatusLog() {
Pane statusLogPane = (Pane) currentStage.getScene().lookup("#StatusLog"); Pane statusLog = (Pane) currentStage.getScene().lookup("#StatusLog");
statusLogPane.getChildren().add(statusLog); statusLog.getChildren().add(this.statusLog);
} }
private void removeStatusLog(){ private void removeStatusLog(){
Pane statusLogPane = (Pane) currentStage.getScene().lookup("#StatusLog"); Pane statusLog = (Pane) currentStage.getScene().lookup("#StatusLog");
statusLogPane.getChildren().remove(statusLog); statusLog.getChildren().remove(this.statusLog);
} }
private void SetStatusLogSize(int expansionWidth) { private void SetStatusLogSize(int expansionWidth) {
currentStage.setWidth(currentStage.getWidth() + expansionWidth); currentStage.setWidth(currentStage.getWidth() + expansionWidth);
Pane statusLogPane = (Pane) currentStage.getScene().lookup("#StatusLog"); Pane statusLog = (Pane) currentStage.getScene().lookup("#StatusLog");
statusLogPane.setPrefWidth(expansionWidth); statusLog.setPrefWidth(expansionWidth);
} }
@FXML @FXML
private void OnStatusLogPressed() { private void OnSettingsPressed() {
UpdateStatusLog(); UpdateSettings();
}
public void SetSettings(GridPane settings){
this.settings = settings;
}
@Override
public void UpdateSettings() {
showSettingsButton(settingsOpened);
System.out.println(settingsOpened);
if (!settingsOpened) {
SetSettingsSize(SETTINGS_HEIGHT_EXPANSION_VALUE);
addSettings();
}
else {
SetSettingsSize(-SETTINGS_HEIGHT_EXPANSION_VALUE);
removeSettings();
}
settingsOpened = !settingsOpened;
}
private void SetSettingsSize(int expansionHeight) {
currentStage.setHeight(currentStage.getHeight() + expansionHeight);
Pane statusLog = (Pane) currentStage.getScene().lookup("#Settings");
statusLog.setPrefHeight(expansionHeight);
}
private void showSettingsButton(boolean showOrNot){
Button settings = (Button) currentStage.getScene().lookup("#SettingsButton");
settings.setVisible(showOrNot);
}
private void addSettings() {
Pane settingsPane = (Pane) currentStage.getScene().lookup("#Settings");
settingsPane.getChildren().add(settings);
}
private void removeSettings(){
Pane settingsPane = (Pane) currentStage.getScene().lookup("#Settings");
settingsPane.getChildren().remove(settings);
} }
} }

View File

@ -5,6 +5,7 @@ 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 polling_station_dashboard.StatusLog.java.StatusLogLoader;
import polling_station_dashboard.settings.java.settingsLoader;
import java.io.IOException; import java.io.IOException;
@ -20,6 +21,9 @@ public class PollingStationDashboardLoader {
public PollingStationDashboardLoader (Stage primaryStage) throws IOException public PollingStationDashboardLoader (Stage primaryStage) throws IOException
{ {
primaryStage.setX(100);
primaryStage.setY(100);
currentStage = primaryStage; currentStage = primaryStage;
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(POLLING_STATION_DASHBOARD_FXML_PATH)); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(POLLING_STATION_DASHBOARD_FXML_PATH));
Parent root = fxmlLoader.load(); Parent root = fxmlLoader.load();
@ -29,9 +33,14 @@ public class PollingStationDashboardLoader {
currentStage.setScene(new Scene(root, 850, 615)); currentStage.setScene(new Scene(root, 850, 615));
currentStage.show(); currentStage.show();
// create the status log object
StatusLogLoader statusLogLoader = new StatusLogLoader(currentStage, controller); StatusLogLoader statusLogLoader = new StatusLogLoader(currentStage, controller);
controller.SetStage(currentStage); controller.SetStage(currentStage);
controller.SetStatusLog(statusLogLoader.GetStatusLogInstance()); controller.SetStatusLog(statusLogLoader.GetStatusLogInstance());
// create the settings object
settingsLoader settingsLoader = new settingsLoader(currentStage, controller);
controller.SetSettings(settingsLoader.GetSettingsInstance());
} }
} }

View File

@ -6,7 +6,7 @@
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<GridPane fx:id="SettingsGridPane" prefHeight="70.0" prefWidth="850.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="polling_station_dashboard.StatusLog.java.StatusLogController"> <GridPane fx:id="SettingsGridPane" prefHeight="70.0" prefWidth="850.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="polling_station_dashboard.settings.java.settingsController">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="177.0" minWidth="10.0" prefWidth="177.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="177.0" minWidth="10.0" prefWidth="177.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="172.0" minWidth="10.0" prefWidth="144.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="172.0" minWidth="10.0" prefWidth="144.0" />
@ -19,7 +19,7 @@
<RowConstraints maxHeight="561.0" minHeight="10.0" prefHeight="561.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="561.0" minHeight="10.0" prefHeight="561.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<GridPane GridPane.rowIndex="1"> <GridPane onMousePressed="#CloseSettings" GridPane.rowIndex="1">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="80.0" minWidth="10.0" prefWidth="53.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="80.0" minWidth="10.0" prefWidth="53.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="125.0" minWidth="10.0" prefWidth="117.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="125.0" minWidth="10.0" prefWidth="117.0" />

View File

@ -1,5 +1,6 @@
package polling_station_dashboard.settings.java; package polling_station_dashboard.settings.java;
import javafx.fxml.FXML;
import javafx.stage.Stage; import javafx.stage.Stage;
/** /**
@ -19,4 +20,10 @@ public class settingsController {
this.settingsUpdater = updater; this.settingsUpdater = updater;
} }
@FXML
private void CloseSettings(){
// UpdateStatusLog is called from open status log object which means that
// the current UpdateStatusLog will close it
this.settingsUpdater.UpdateSettings();
}
} }

View File

@ -14,7 +14,7 @@ import java.io.IOException;
*/ */
public class settingsLoader { public class settingsLoader {
private static final String POLLING_STATION_DASHBOARD_FXML_PATH = "../fxml/settings.fxml"; private static final String SETTINGS_FXML_PATH = "../fxml/settings.fxml";
private Stage currentStage; private Stage currentStage;
private FXMLLoader fxmlLoader; private FXMLLoader fxmlLoader;
@ -24,7 +24,7 @@ public class settingsLoader {
{ {
currentStage = primaryStage; currentStage = primaryStage;
settingsUpdater = updater; settingsUpdater = updater;
fxmlLoader = new FXMLLoader(getClass().getResource(POLLING_STATION_DASHBOARD_FXML_PATH)); fxmlLoader = new FXMLLoader(getClass().getResource(SETTINGS_FXML_PATH));
} }
public GridPane GetSettingsInstance() throws IOException { public GridPane GetSettingsInstance() throws IOException {

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created By Vladimir Eliezer Tokarev !-->
<?import java.lang.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<GridPane fx:id="StatusLogGridPane" prefHeight="70.0" prefWidth="850.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="polling_station_dashboard.StatusLog.java.StatusLogController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="177.0" minWidth="10.0" prefWidth="177.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="172.0" minWidth="10.0" prefWidth="144.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="216.0" minWidth="10.0" prefWidth="200.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="165.0" minWidth="10.0" prefWidth="136.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="202.0" minHeight="0.0" prefHeight="54.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="561.0" minHeight="10.0" prefHeight="561.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<GridPane GridPane.rowIndex="1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="80.0" minWidth="10.0" prefWidth="53.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="125.0" minWidth="10.0" prefWidth="117.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<BorderPane prefHeight="200.0" prefWidth="200.0">
<right>
<ImageView BorderPane.alignment="CENTER">
<image>
<Image url="@../../pictures/bullets.png" />
</image>
</ImageView>
</right>
</BorderPane>
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
<left>
<Label text="Manage voting booths" BorderPane.alignment="CENTER" />
</left>
</BorderPane>
</children>
</GridPane>
<GridPane GridPane.columnIndex="1" GridPane.rowIndex="1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="80.0" minWidth="10.0" prefWidth="57.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="128.0" minWidth="10.0" prefWidth="113.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
<left>
<Label text="Manage Polls workers" BorderPane.alignment="CENTER" />
</left>
</BorderPane>
<BorderPane prefHeight="200.0" prefWidth="200.0">
<right>
<ImageView BorderPane.alignment="CENTER">
<image>
<Image url="@../../pictures/women.png" />
</image>
</ImageView>
</right>
</BorderPane>
</children>
</GridPane>
<GridPane GridPane.columnIndex="2" GridPane.rowIndex="1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="79.0" minWidth="10.0" prefWidth="60.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="120.0" minWidth="10.0" prefWidth="110.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
<left>
<Label text="Manage provisional votes" BorderPane.alignment="CENTER" />
</left>
</BorderPane>
<BorderPane prefHeight="200.0" prefWidth="200.0">
<right>
<ImageView BorderPane.alignment="CENTER">
<image>
<Image url="@../../pictures/settings.png" />
</image>
</ImageView>
</right>
</BorderPane>
</children>
</GridPane>
<GridPane GridPane.columnIndex="3" GridPane.rowIndex="1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="76.0" minWidth="10.0" prefWidth="54.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="108.0" minWidth="10.0" prefWidth="108.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
<left>
<Label text="Close polling station" BorderPane.alignment="CENTER" />
</left>
</BorderPane>
<BorderPane prefHeight="200.0" prefWidth="200.0">
<right>
<ImageView BorderPane.alignment="CENTER">
<image>
<Image url="@../../pictures/exit.png" />
</image>
</ImageView>
</right>
</BorderPane>
</children>
</GridPane>
</children>
</GridPane>