Bind spinners to settings
and save settings values
This commit is contained in:
parent
9a49ea572a
commit
e21c078e4c
@ -5,10 +5,14 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import javafx.beans.property.IntegerProperty;
|
||||||
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.beans.property.StringProperty;
|
import javafx.beans.property.StringProperty;
|
||||||
import javafx.event.Event;
|
import javafx.event.Event;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Spinner;
|
||||||
|
import javafx.scene.control.SpinnerValueFactory;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
@ -17,6 +21,8 @@ public class MainSettingsController {
|
|||||||
private StationSettings settings;
|
private StationSettings settings;
|
||||||
private StringProperty stationAddress = new SimpleStringProperty();
|
private StringProperty stationAddress = new SimpleStringProperty();
|
||||||
private StringProperty stationName = new SimpleStringProperty();
|
private StringProperty stationName = new SimpleStringProperty();
|
||||||
|
private IntegerProperty digitsPerGroup = new SimpleIntegerProperty();
|
||||||
|
private IntegerProperty messageLength = new SimpleIntegerProperty();
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private TextField stationNameField;
|
private TextField stationNameField;
|
||||||
@ -24,6 +30,12 @@ public class MainSettingsController {
|
|||||||
@FXML
|
@FXML
|
||||||
private TextField stationAddressField;
|
private TextField stationAddressField;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Spinner<Integer> digitsPerGroupSpinner;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Spinner<Integer> messageLengthSpinner;
|
||||||
|
|
||||||
public MainSettingsController() throws IOException {
|
public MainSettingsController() throws IOException {
|
||||||
// System.out.println("Created settings controller");
|
// System.out.println("Created settings controller");
|
||||||
// File file = new File("setting-test.xml");
|
// File file = new File("setting-test.xml");
|
||||||
@ -37,6 +49,12 @@ public class MainSettingsController {
|
|||||||
private void initialize() {
|
private void initialize() {
|
||||||
stationNameField.textProperty().bindBidirectional(stationName);
|
stationNameField.textProperty().bindBidirectional(stationName);
|
||||||
stationAddressField.textProperty().bindBidirectional(stationAddress);
|
stationAddressField.textProperty().bindBidirectional(stationAddress);
|
||||||
|
|
||||||
|
digitsPerGroupSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 100, 1));
|
||||||
|
messageLengthSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 100, 1));
|
||||||
|
|
||||||
|
digitsPerGroupSpinner.getValueFactory().valueProperty().bindBidirectional(digitsPerGroup.asObject());
|
||||||
|
messageLengthSpinner.getValueFactory().valueProperty().bindBidirectional(messageLength.asObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@ -61,6 +79,9 @@ public class MainSettingsController {
|
|||||||
private void handleSaveButtonPress(Event e) {
|
private void handleSaveButtonPress(Event e) {
|
||||||
settings.setAddress(stationAddress.get());
|
settings.setAddress(stationAddress.get());
|
||||||
|
|
||||||
|
settings.setDigitsPerGroup(digitsPerGroup.get());
|
||||||
|
settings.setMessageLength(messageLength.get());
|
||||||
|
|
||||||
Node node = (Node) e.getSource();
|
Node node = (Node) e.getSource();
|
||||||
Stage stage = (Stage) node.getScene().getWindow();
|
Stage stage = (Stage) node.getScene().getWindow();
|
||||||
stage.setUserData(true);
|
stage.setUserData(true);
|
||||||
@ -74,5 +95,7 @@ public class MainSettingsController {
|
|||||||
public void setStationSettings(StationSettings newSettings) {
|
public void setStationSettings(StationSettings newSettings) {
|
||||||
settings = newSettings;
|
settings = newSettings;
|
||||||
stationName.set(settings.getName());
|
stationName.set(settings.getName());
|
||||||
|
digitsPerGroup.set(settings.getDigitsPerGroup());
|
||||||
|
messageLength.set(settings.getMessageLength());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
</FlowPane>
|
</FlowPane>
|
||||||
<Separator prefWidth="200.0" />
|
<Separator prefWidth="200.0" />
|
||||||
<AnchorPane prefHeight="120.0" prefWidth="578.0">
|
<AnchorPane prefHeight="77.0" prefWidth="578.0">
|
||||||
<children>
|
<children>
|
||||||
<FlowPane alignment="CENTER_LEFT" layoutX="8.0" layoutY="7.0" prefHeight="63.0" prefWidth="216.0">
|
<FlowPane alignment="CENTER_LEFT" layoutX="8.0" layoutY="7.0" prefHeight="63.0" prefWidth="216.0">
|
||||||
<children>
|
<children>
|
||||||
@ -47,17 +47,7 @@
|
|||||||
<Insets right="10.0" />
|
<Insets right="10.0" />
|
||||||
</FlowPane.margin>
|
</FlowPane.margin>
|
||||||
</Label>
|
</Label>
|
||||||
<Spinner editable="true" prefHeight="25.0" prefWidth="96.0" />
|
<Spinner fx:id="digitsPerGroupSpinner" editable="true" prefHeight="25.0" prefWidth="96.0" />
|
||||||
</children>
|
|
||||||
</FlowPane>
|
|
||||||
<FlowPane alignment="CENTER_LEFT" layoutX="7.0" layoutY="69.0" prefHeight="63.0" prefWidth="219.0">
|
|
||||||
<children>
|
|
||||||
<Label prefHeight="38.0" prefWidth="103.0" text="Groups in line: (only for display)" textAlignment="RIGHT" textOverrun="CLIP" wrapText="true">
|
|
||||||
<FlowPane.margin>
|
|
||||||
<Insets right="10.0" />
|
|
||||||
</FlowPane.margin>
|
|
||||||
</Label>
|
|
||||||
<Spinner editable="true" prefHeight="25.0" prefWidth="96.0" />
|
|
||||||
</children>
|
</children>
|
||||||
</FlowPane>
|
</FlowPane>
|
||||||
<FlowPane alignment="CENTER_LEFT" layoutX="233.0" layoutY="7.0" prefHeight="63.0" prefWidth="216.0">
|
<FlowPane alignment="CENTER_LEFT" layoutX="233.0" layoutY="7.0" prefHeight="63.0" prefWidth="216.0">
|
||||||
@ -67,13 +57,13 @@
|
|||||||
<Insets right="10.0" />
|
<Insets right="10.0" />
|
||||||
</FlowPane.margin>
|
</FlowPane.margin>
|
||||||
</Label>
|
</Label>
|
||||||
<Spinner editable="true" prefHeight="25.0" prefWidth="96.0" />
|
<Spinner fx:id="messageLengthSpinner" editable="true" prefHeight="25.0" prefWidth="96.0" />
|
||||||
</children>
|
</children>
|
||||||
</FlowPane>
|
</FlowPane>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
<Separator prefWidth="200.0" />
|
<Separator prefWidth="200.0" />
|
||||||
<AnchorPane prefHeight="192.0" prefWidth="578.0">
|
<AnchorPane prefHeight="170.0" prefWidth="578.0">
|
||||||
<children>
|
<children>
|
||||||
<Label layoutY="6.0" text="Send messages via:">
|
<Label layoutY="6.0" text="Send messages via:">
|
||||||
<font>
|
<font>
|
||||||
@ -93,7 +83,7 @@
|
|||||||
<Label layoutX="380.0" layoutY="69.0" text="Username:" AnchorPane.rightAnchor="142.0" />
|
<Label layoutX="380.0" layoutY="69.0" text="Username:" AnchorPane.rightAnchor="142.0" />
|
||||||
<Label layoutX="380.0" layoutY="99.0" text="Password:" AnchorPane.rightAnchor="142.0" />
|
<Label layoutX="380.0" layoutY="99.0" text="Password:" AnchorPane.rightAnchor="142.0" />
|
||||||
<TextField fx:id="usernameField" layoutX="444.0" layoutY="65.0" prefHeight="25.0" prefWidth="135.0" AnchorPane.rightAnchor="0.0" />
|
<TextField fx:id="usernameField" layoutX="444.0" layoutY="65.0" prefHeight="25.0" prefWidth="135.0" AnchorPane.rightAnchor="0.0" />
|
||||||
<PasswordField fx:id="passwordField" layoutX="444.0" layoutY="95.0" prefHeight="25.0" prefWidth="134.0" AnchorPane.rightAnchor="0.0" />
|
<PasswordField fx:id="passwordField" layoutX="444.0" layoutY="95.0" prefHeight="25.0" prefWidth="135.0" AnchorPane.rightAnchor="0.0" />
|
||||||
<TextField fx:id="externalProgramField" layoutX="140.0" layoutY="131.0" prefHeight="25.0" prefWidth="438.0" AnchorPane.leftAnchor="140.0" AnchorPane.rightAnchor="0.0" />
|
<TextField fx:id="externalProgramField" layoutX="140.0" layoutY="131.0" prefHeight="25.0" prefWidth="438.0" AnchorPane.leftAnchor="140.0" AnchorPane.rightAnchor="0.0" />
|
||||||
</children>
|
</children>
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
|
Loading…
Reference in New Issue
Block a user