diff --git a/src/main/java/name/nathanmcrae/numbersstation/MainSettingsController.java b/src/main/java/name/nathanmcrae/numbersstation/MainSettingsController.java index f1d201a..fd9a59f 100644 --- a/src/main/java/name/nathanmcrae/numbersstation/MainSettingsController.java +++ b/src/main/java/name/nathanmcrae/numbersstation/MainSettingsController.java @@ -31,6 +31,7 @@ public class MainSettingsController { private StringProperty externalProgramCommand = new SimpleStringProperty(); private IntegerProperty messageLength = new SimpleIntegerProperty(); private ObjectProperty messageMethod = new SimpleObjectProperty<>(); + private ObjectProperty messagePeriod = new SimpleObjectProperty<>(); private StringProperty password = new SimpleStringProperty(); private StationSettings settings; private StringProperty stationAddress = new SimpleStringProperty(); @@ -43,6 +44,9 @@ public class MainSettingsController { @FXML private TextField stationAddressField; + @FXML + private RadioButton dailyRadioButton; + @FXML private Spinner digitsPerGroupSpinner; @@ -55,6 +59,12 @@ public class MainSettingsController { @FXML private ToggleGroup messageMethodGroup; + @FXML + private ToggleGroup messagePeriodGroup; + + @FXML + private RadioButton monthlyRadioButton; + @FXML private RadioButton ftpRadioButton; @@ -76,6 +86,9 @@ public class MainSettingsController { @FXML private ListView prefixListView; + @FXML + private RadioButton weeklyRadioButton; + public MainSettingsController() { } @FXML @@ -116,6 +129,26 @@ public class MainSettingsController { } }); + messagePeriodGroup.selectedToggleProperty().addListener((observable, oldValue, newValue) -> { + if (newValue == dailyRadioButton) { + messagePeriod.set(StationSettings.MessagePeriod.DAILY); + } else if (newValue == monthlyRadioButton) { + messagePeriod.set(StationSettings.MessagePeriod.MONTHLY); + } else if (newValue == weeklyRadioButton) { + messagePeriod.set(StationSettings.MessagePeriod.WEEKLY); + } + }); + + messagePeriod.addListener((observable, oldValue, newValue) -> { + if (newValue == StationSettings.MessagePeriod.DAILY) { + messagePeriodGroup.selectToggle(dailyRadioButton); + } else if (newValue == StationSettings.MessagePeriod.MONTHLY) { + messagePeriodGroup.selectToggle(monthlyRadioButton); + } else if (newValue == StationSettings.MessagePeriod.WEEKLY) { + messagePeriodGroup.selectToggle(weeklyRadioButton); + } + }); + // Set user data. Default result is no update. stationNameField.sceneProperty().addListener((observable, oldScene, newScene) -> { if (newScene != null) { @@ -160,6 +193,7 @@ public class MainSettingsController { settings.setExternalProgramCommand(externalProgramCommand.get()); settings.setMessageLength(messageLength.get()); settings.setMessageMethod(messageMethod.get()); + settings.setMessagePeriod(messagePeriod.get()); settings.setName(stationName.get()); settings.setPassword(password.get()); settings.getPrefixes().clear(); @@ -190,6 +224,7 @@ public class MainSettingsController { externalProgramCommand.set(settings.getExternalProgramCommand()); messageLength.set(settings.getMessageLength()); messageMethod.set(settings.getMessageMethod()); + messagePeriod.set(settings.getMessagePeriod()); username.set(settings.getUsername()); password.set(settings.getPassword()); prefixListView.getItems().addAll(settings.getPrefixes()); diff --git a/src/main/java/name/nathanmcrae/numbersstation/MainSettingsView.fxml b/src/main/java/name/nathanmcrae/numbersstation/MainSettingsView.fxml index e10fcac..48b3e86 100644 --- a/src/main/java/name/nathanmcrae/numbersstation/MainSettingsView.fxml +++ b/src/main/java/name/nathanmcrae/numbersstation/MainSettingsView.fxml @@ -133,18 +133,27 @@ - + - + - - + + + + + + + + + + + + diff --git a/src/main/java/name/nathanmcrae/numbersstation/StationSettings.java b/src/main/java/name/nathanmcrae/numbersstation/StationSettings.java index 348e23c..112ed96 100644 --- a/src/main/java/name/nathanmcrae/numbersstation/StationSettings.java +++ b/src/main/java/name/nathanmcrae/numbersstation/StationSettings.java @@ -8,6 +8,7 @@ public class StationSettings { private String externalProgramCommand; private int messageLength; private MessageMethod messageMethod; + private MessagePeriod messagePeriod; private String name; private String password; private ArrayList prefixes; @@ -20,6 +21,12 @@ public class StationSettings { EXTERNAL_PROGRAM } + public enum MessagePeriod { + DAILY, + WEEKLY, + MONTHLY + } + public StationSettings() { prefixes = new ArrayList(); } @@ -68,6 +75,14 @@ public class StationSettings { messageMethod = newMessageMethod; } + public MessagePeriod getMessagePeriod() { + return messagePeriod; + } + + public void setMessagePeriod(MessagePeriod newMessagePeriod) { + messagePeriod = newMessagePeriod; + } + public String getName() { return name; }