Add prefixes to settings
This commit is contained in:
parent
6ab5e5d1ca
commit
3b725e3f29
@ -5,18 +5,23 @@ 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;
|
||||||
@ -68,14 +73,10 @@ public class MainSettingsController {
|
|||||||
@FXML
|
@FXML
|
||||||
private TextField passwordField;
|
private TextField passwordField;
|
||||||
|
|
||||||
public MainSettingsController() throws IOException {
|
@FXML
|
||||||
// System.out.println("Created settings controller");
|
private ListView<String> prefixListView;
|
||||||
// File file = new File("setting-test.xml");
|
|
||||||
// XmlMapper xmlMapper = new XmlMapper();
|
public MainSettingsController() { }
|
||||||
// settings = xmlMapper.readValue(file, NumbersStationSettings.class);
|
|
||||||
// settings.setRefreshInterval(settings.getRefreshInterval() + 40);
|
|
||||||
// settings.getStations().add(new StationSettings());
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
@ -126,7 +127,15 @@ public class MainSettingsController {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void handleAddPrefixButtonPress() {
|
private void handleAddPrefixButtonPress() {
|
||||||
// TODO
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@ -138,7 +147,10 @@ public class MainSettingsController {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void handleRemovePrefixButtonPress() {
|
private void handleRemovePrefixButtonPress() {
|
||||||
// TODO
|
int selectedIndex = prefixListView.getSelectionModel().getSelectedIndex();
|
||||||
|
if (selectedIndex >= 0) {
|
||||||
|
prefixListView.getItems().remove(selectedIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@ -150,6 +162,8 @@ 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();
|
||||||
@ -178,5 +192,6 @@ 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@
|
|||||||
<Insets bottom="10.0" />
|
<Insets bottom="10.0" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
<ListView prefHeight="103.0" prefWidth="578.0" />
|
<ListView fx:id="prefixListView" 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" />
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
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;
|
||||||
@ -8,6 +10,7 @@ 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 {
|
||||||
@ -17,7 +20,9 @@ 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;
|
||||||
@ -79,6 +84,10 @@ public class StationSettings {
|
|||||||
password = newPassword;
|
password = newPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getPrefixes() {
|
||||||
|
return prefixes;
|
||||||
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user