Add schedule start date setting

This commit is contained in:
Nathan McRae 2025-01-14 22:52:23 -08:00
parent 008d1e2d6b
commit 5e362673d4
6 changed files with 36 additions and 3 deletions

View File

@ -1,6 +1,6 @@
$Env:JAVA_HOME = "C:\Users\nathanm\Downloads\openjdk-23.0.1_windows-x64_bin\jdk-23.0.1" $Env:JAVA_HOME = "C:\Users\nathanm\Downloads\openjdk-23.0.1_windows-x64_bin\jdk-23.0.1"
$Env:PATH = "C:\Users\nathanm\Downloads\openjdk-23.0.1_windows-x64_bin\jdk-23.0.1\bin;$($Env:PATH)" $Env:PATH = "C:\Users\nathanm\Downloads\openjdk-23.0.1_windows-x64_bin\jdk-23.0.1\bin;$($Env:PATH)"
$Env:PATH_TO_FX="C:\Users\nathanm\Downloads\openjfx-23.0.1_windows-x64_bin-sdk\javafx-sdk-23.0.1\lib" $Env:PATH_TO_FX="C:\Users\nathanm\Downloads\openjfx-23.0.1_windows-x64_bin-sdk\javafx-sdk-23.0.1\lib"
javac --module-path "$Env:PATH_TO_FX;P:\personal_root\projects\number-station\lib" --add-modules javafx.controls,javafx.fxml,com.fasterxml.jackson.annotation,com.fasterxml.jackson.core,com.fasterxml.jackson.dataformat.xml .\name\nathanmcrae\numbersstation\*.java -d out javac --module-path "$Env:PATH_TO_FX;P:\personal_root\projects\number-station\lib" --add-modules javafx.controls,javafx.fxml,com.fasterxml.jackson.annotation,com.fasterxml.jackson.core,com.fasterxml.jackson.dataformat.xml,com.fasterxml.jackson.datatype.jsr310 .\name\nathanmcrae\numbersstation\*.java -d out
cp name/nathanmcrae/numbersstation/*.fxml out/name/nathanmcrae/numbersstation cp name/nathanmcrae/numbersstation/*.fxml out/name/nathanmcrae/numbersstation
java --module-path "$Env:PATH_TO_FX;P:\personal_root\projects\number-station\lib" --add-modules javafx.controls,javafx.fxml,com.fasterxml.jackson.annotation,com.fasterxml.jackson.core,com.fasterxml.jackson.dataformat.xml -cp out name.nathanmcrae.numbersstation.Main java --module-path "$Env:PATH_TO_FX;P:\personal_root\projects\number-station\lib" --add-modules javafx.controls,javafx.fxml,com.fasterxml.jackson.annotation,com.fasterxml.jackson.core,com.fasterxml.jackson.dataformat.xml,com.fasterxml.jackson.datatype.jsr310 -cp out name.nathanmcrae.numbersstation.Main

View File

@ -1,6 +1,9 @@
package name.nathanmcrae.numbersstation; package name.nathanmcrae.numbersstation;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
@ -113,6 +116,7 @@ public class MainController implements Initializable {
private void loadSettings() throws IOException { private void loadSettings() throws IOException {
XmlMapper xmlMapper = new XmlMapper(); XmlMapper xmlMapper = new XmlMapper();
xmlMapper.registerModule(new JavaTimeModule());
String userHome = System.getProperty("user.home"); String userHome = System.getProperty("user.home");
// TODO: XDG // TODO: XDG
Path directoryPath = Paths.get(userHome, ".numbers-station"); Path directoryPath = Paths.get(userHome, ".numbers-station");

View File

@ -1,6 +1,10 @@
package name.nathanmcrae.numbersstation; package name.nathanmcrae.numbersstation;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@ -51,6 +55,8 @@ public class MainSettings {
public void save() { public void save() {
XmlMapper xmlMapper = new XmlMapper(); XmlMapper xmlMapper = new XmlMapper();
xmlMapper.registerModule(new JavaTimeModule());
xmlMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
try { try {
String userHome = System.getProperty("user.home"); String userHome = System.getProperty("user.home");
Path directoryPath = Paths.get(userHome, ".numbers-station"); Path directoryPath = Paths.get(userHome, ".numbers-station");

View File

@ -6,6 +6,7 @@ import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Optional; import java.util.Optional;
import java.time.LocalDate;
import javafx.beans.property.IntegerProperty; import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty; import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleIntegerProperty;
@ -16,6 +17,7 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.Event; import javafx.event.Event;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.DatePicker;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
import javafx.scene.control.RadioButton; import javafx.scene.control.RadioButton;
import javafx.scene.control.Spinner; import javafx.scene.control.Spinner;
@ -36,6 +38,7 @@ 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 ObjectProperty<LocalDate> scheduleStartDate = new SimpleObjectProperty<>();
private StringProperty username = new SimpleStringProperty(); private StringProperty username = new SimpleStringProperty();
@FXML @FXML
@ -86,6 +89,9 @@ public class MainSettingsController {
@FXML @FXML
private ListView<String> prefixListView; private ListView<String> prefixListView;
@FXML
private DatePicker scheduleStartDatePicker;
@FXML @FXML
private RadioButton weeklyRadioButton; private RadioButton weeklyRadioButton;
@ -97,6 +103,7 @@ public class MainSettingsController {
stationNameField.textProperty().bindBidirectional(stationName); stationNameField.textProperty().bindBidirectional(stationName);
stationAddressField.textProperty().bindBidirectional(stationAddress); stationAddressField.textProperty().bindBidirectional(stationAddress);
passwordField.textProperty().bindBidirectional(password); passwordField.textProperty().bindBidirectional(password);
scheduleStartDatePicker.valueProperty().bindBidirectional(scheduleStartDate);
usernameField.textProperty().bindBidirectional(username); usernameField.textProperty().bindBidirectional(username);
digitsPerGroupSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 100, 1)); digitsPerGroupSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 100, 1));
@ -198,6 +205,7 @@ public class MainSettingsController {
settings.setPassword(password.get()); settings.setPassword(password.get());
settings.getPrefixes().clear(); settings.getPrefixes().clear();
settings.getPrefixes().addAll(prefixListView.getItems()); settings.getPrefixes().addAll(prefixListView.getItems());
settings.setScheduleStartDate(scheduleStartDatePicker.getValue());
settings.setUsername(username.get()); settings.setUsername(username.get());
Node node = (Node) e.getSource(); Node node = (Node) e.getSource();
@ -227,6 +235,8 @@ public class MainSettingsController {
messagePeriod.set(settings.getMessagePeriod()); messagePeriod.set(settings.getMessagePeriod());
username.set(settings.getUsername()); username.set(settings.getUsername());
password.set(settings.getPassword()); password.set(settings.getPassword());
System.out.println(settings.getPrefixes());
prefixListView.getItems().addAll(settings.getPrefixes()); prefixListView.getItems().addAll(settings.getPrefixes());
scheduleStartDate.set(settings.getScheduleStartDate());
} }
} }

View File

@ -148,7 +148,7 @@
<fx:reference source="messagePeriodGroup" /> <fx:reference source="messagePeriodGroup" />
</toggleGroup> </toggleGroup>
</RadioButton> </RadioButton>
<DatePicker layoutX="115.0" layoutY="34.0" /> <DatePicker fx:id="scheduleStartDatePicker" layoutX="115.0" layoutY="34.0" />
<Label layoutX="115.0" layoutY="8.0" text="Starting from:" /> <Label layoutX="115.0" layoutY="8.0" text="Starting from:" />
<TextField layoutX="115.0" layoutY="64.0" text="23:24:49" /> <TextField layoutX="115.0" layoutY="64.0" text="23:24:49" />
<Label layoutX="48.0" layoutY="102.0" text="TODO: Jitter" /> <Label layoutX="48.0" layoutY="102.0" text="TODO: Jitter" />

View File

@ -1,5 +1,6 @@
package name.nathanmcrae.numbersstation; package name.nathanmcrae.numbersstation;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
public class StationSettings { public class StationSettings {
@ -12,6 +13,7 @@ public class StationSettings {
private String name; private String name;
private String password; private String password;
private ArrayList<String> prefixes; private ArrayList<String> prefixes;
private LocalDate scheduleStartDate;
private String username; private String username;
public enum MessageMethod { public enum MessageMethod {
@ -100,9 +102,20 @@ public class StationSettings {
} }
public ArrayList<String> getPrefixes() { public ArrayList<String> getPrefixes() {
if (prefixes == null) {
prefixes = new ArrayList<String>();
}
return prefixes; return prefixes;
} }
public LocalDate getScheduleStartDate() {
return scheduleStartDate;
}
public void setScheduleStartDate(LocalDate newScheduleStartDate) {
scheduleStartDate = newScheduleStartDate;
}
public String getUsername() { public String getUsername() {
return username; return username;
} }