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

View File

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

View File

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

View File

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