Compare commits

..

No commits in common. "b1d1acad2fcc06fb8bb7bf01ab89b0c60e0e0381" and "6ab5e5d1ca524486e679ade41db817090914c01b" have entirely different histories.

4 changed files with 19 additions and 37 deletions

View File

@ -5,23 +5,18 @@ 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 java.util.Optional;
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;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.Event; import javafx.event.Event;
import javafx.fxml.FXML; import javafx.fxml.FXML;
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;
import javafx.scene.control.SpinnerValueFactory; import javafx.scene.control.SpinnerValueFactory;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.control.TextInputDialog;
import javafx.scene.control.ToggleGroup; import javafx.scene.control.ToggleGroup;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.stage.Stage; import javafx.stage.Stage;
@ -73,10 +68,14 @@ public class MainSettingsController {
@FXML @FXML
private TextField passwordField; private TextField passwordField;
@FXML public MainSettingsController() throws IOException {
private ListView<String> prefixListView; // System.out.println("Created settings controller");
// File file = new File("setting-test.xml");
public MainSettingsController() { } // XmlMapper xmlMapper = new XmlMapper();
// settings = xmlMapper.readValue(file, NumbersStationSettings.class);
// settings.setRefreshInterval(settings.getRefreshInterval() + 40);
// settings.getStations().add(new StationSettings());
}
@FXML @FXML
private void initialize() { private void initialize() {
@ -127,15 +126,7 @@ public class MainSettingsController {
@FXML @FXML
private void handleAddPrefixButtonPress() { private void handleAddPrefixButtonPress() {
TextInputDialog dialog = new TextInputDialog(); // TODO
dialog.setTitle("New prefix");
dialog.setHeaderText("Add a new prefix");
dialog.setContentText("Enter a message prefix / identifier:");
Optional<String> result = dialog.showAndWait();
result.ifPresent(prefix -> {
prefixListView.getItems().add(prefix);
});
} }
@FXML @FXML
@ -147,10 +138,7 @@ public class MainSettingsController {
@FXML @FXML
private void handleRemovePrefixButtonPress() { private void handleRemovePrefixButtonPress() {
int selectedIndex = prefixListView.getSelectionModel().getSelectedIndex(); // TODO
if (selectedIndex >= 0) {
prefixListView.getItems().remove(selectedIndex);
}
} }
@FXML @FXML
@ -162,8 +150,6 @@ public class MainSettingsController {
settings.setMessageMethod(messageMethod.get()); settings.setMessageMethod(messageMethod.get());
settings.setName(stationName.get()); settings.setName(stationName.get());
settings.setPassword(password.get()); settings.setPassword(password.get());
settings.getPrefixes().clear();
settings.getPrefixes().addAll(prefixListView.getItems());
settings.setUsername(username.get()); settings.setUsername(username.get());
Node node = (Node) e.getSource(); Node node = (Node) e.getSource();
@ -192,6 +178,5 @@ public class MainSettingsController {
messageMethod.set(settings.getMessageMethod()); messageMethod.set(settings.getMessageMethod());
username.set(settings.getUsername()); username.set(settings.getUsername());
password.set(settings.getPassword()); password.set(settings.getPassword());
prefixListView.getItems().addAll(settings.getPrefixes());
} }
} }

View File

@ -119,7 +119,7 @@
<Insets bottom="10.0" /> <Insets bottom="10.0" />
</VBox.margin> </VBox.margin>
</AnchorPane> </AnchorPane>
<ListView fx:id="prefixListView" prefHeight="103.0" prefWidth="578.0" /> <ListView prefHeight="103.0" prefWidth="578.0" />
<Separator prefWidth="200.0"> <Separator prefWidth="200.0">
<VBox.margin> <VBox.margin>
<Insets bottom="10.0" top="10.0" /> <Insets bottom="10.0" top="10.0" />

View File

@ -1,6 +1,5 @@
package name.nathanmcrae.numbersstation; package name.nathanmcrae.numbersstation;
import java.util.Optional;
import javafx.collections.ListChangeListener; import javafx.collections.ListChangeListener;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
@ -12,6 +11,7 @@ import javafx.event.ActionEvent;
import javafx.event.Event; import javafx.event.Event;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.stage.Stage; import javafx.stage.Stage;
import java.util.Optional;
public class StationSelectionController { public class StationSelectionController {
@ -23,7 +23,9 @@ public class StationSelectionController {
private ObservableList<StationSettings> stationList; private ObservableList<StationSettings> stationList;
public StationSelectionController() { public StationSelectionController() {
// Initialize the list with an empty list
stationList = FXCollections.observableArrayList(); stationList = FXCollections.observableArrayList();
// Add listener to the stationList
stationList.addListener((ListChangeListener<StationSettings>) change -> onStationListChanged(change)); stationList.addListener((ListChangeListener<StationSettings>) change -> onStationListChanged(change));
} }
@ -51,13 +53,16 @@ public class StationSelectionController {
@FXML @FXML
private void handleAddButtonPress(ActionEvent event) { private void handleAddButtonPress(ActionEvent event) {
// Create a TextInputDialog
TextInputDialog dialog = new TextInputDialog(); TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("New Station"); dialog.setTitle("New Station");
dialog.setHeaderText("Add a New Station"); dialog.setHeaderText("Add a New Station");
dialog.setContentText("Please enter the station name:"); dialog.setContentText("Please enter the station name:");
// Show the dialog and capture the result
Optional<String> result = dialog.showAndWait(); Optional<String> result = dialog.showAndWait();
result.ifPresent(stationName -> { result.ifPresent(stationName -> {
// Add the new station to the list
StationSettings newStation = new StationSettings(stationName); StationSettings newStation = new StationSettings(stationName);
stationList.add(newStation); stationList.add(newStation);
}); });
@ -65,6 +70,7 @@ public class StationSelectionController {
@FXML @FXML
private void handleRemoveButtonPress(ActionEvent event) { private void handleRemoveButtonPress(ActionEvent event) {
// Remove the selected item from the list
int selectedIndex = stationListView.getSelectionModel().getSelectedIndex(); int selectedIndex = stationListView.getSelectionModel().getSelectedIndex();
if (selectedIndex >= 0) { if (selectedIndex >= 0) {
stationList.remove(selectedIndex); stationList.remove(selectedIndex);

View File

@ -1,7 +1,5 @@
package name.nathanmcrae.numbersstation; package name.nathanmcrae.numbersstation;
import java.util.ArrayList;
public class StationSettings { public class StationSettings {
private String address; private String address;
private int digitsPerGroup; private int digitsPerGroup;
@ -10,7 +8,6 @@ public class StationSettings {
private MessageMethod messageMethod; private MessageMethod messageMethod;
private String name; private String name;
private String password; private String password;
private ArrayList<String> prefixes;
private String username; private String username;
public enum MessageMethod { public enum MessageMethod {
@ -20,9 +17,7 @@ public class StationSettings {
EXTERNAL_PROGRAM EXTERNAL_PROGRAM
} }
public StationSettings() { public StationSettings() { }
prefixes = new ArrayList<String>();
}
public StationSettings(String newName) { public StationSettings(String newName) {
name = newName; name = newName;
@ -84,10 +79,6 @@ public class StationSettings {
password = newPassword; password = newPassword;
} }
public ArrayList<String> getPrefixes() {
return prefixes;
}
public String getUsername() { public String getUsername() {
return username; return username;
} }