Restructure under numbersstation package

This keeps naming a little less verbose
This commit is contained in:
Nathan McRae 2025-01-11 12:03:56 -08:00
parent 7a6e250804
commit 9a49ea572a
12 changed files with 54 additions and 43 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\*.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 .\name\nathanmcrae\numbersstation\*.java -d out
cp name/nathanmcrae/*.fxml out/name/nathanmcrae 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 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

View File

@ -1,4 +1,4 @@
package name.nathanmcrae; package name.nathanmcrae.numbersstation;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
@ -6,10 +6,10 @@ import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.stage.Stage; import javafx.stage.Stage;
public class NumbersStation extends Application { public class Main extends Application {
@Override @Override
public void start(Stage primaryStage) throws Exception { public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("NumbersStation.fxml")); Parent root = FXMLLoader.load(getClass().getResource("MainView.fxml"));
primaryStage.setTitle("Numbers Station"); primaryStage.setTitle("Numbers Station");
primaryStage.setScene(new Scene(root)); primaryStage.setScene(new Scene(root));
primaryStage.show(); primaryStage.show();

View File

@ -1,4 +1,4 @@
package name.nathanmcrae; package name.nathanmcrae.numbersstation;
import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import java.io.File; import java.io.File;
@ -23,10 +23,10 @@ import javafx.scene.Scene;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
public class NumbersStationController implements Initializable { public class MainController implements Initializable {
private Stage settingsStage; private Stage settingsStage;
private Stage selectStationStage; private Stage selectStationStage;
private NumbersStationSettings settings; private MainSettings settings;
private StationSettings selectedStation; private StationSettings selectedStation;
private StringProperty selectedStationName = new SimpleStringProperty(); private StringProperty selectedStationName = new SimpleStringProperty();
@ -47,10 +47,10 @@ public class NumbersStationController implements Initializable {
if (settingsStage == null || !settingsStage.isShowing()) { if (settingsStage == null || !settingsStage.isShowing()) {
try { try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("NumbersStationSettings.fxml")); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MainSettingsView.fxml"));
Parent root = fxmlLoader.load(); Parent root = fxmlLoader.load();
NumbersStationSettingsController controller = fxmlLoader.getController(); MainSettingsController controller = fxmlLoader.getController();
controller.setStationSettings(selectedStation); controller.setStationSettings(selectedStation);
settingsStage = new Stage(); settingsStage = new Stage();
@ -73,11 +73,11 @@ public class NumbersStationController implements Initializable {
private void handleSelectStationButtonPress() { private void handleSelectStationButtonPress() {
if (selectStationStage == null || !selectStationStage.isShowing()) { if (selectStationStage == null || !selectStationStage.isShowing()) {
try { try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("NumbersStationSelection.fxml")); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("StationSelectionView.fxml"));
Parent root = fxmlLoader.load(); Parent root = fxmlLoader.load();
// Pass settings to the controller // Pass settings to the controller
NumbersStationSelectionController controller = fxmlLoader.getController(); StationSelectionController controller = fxmlLoader.getController();
controller.setSettings(settings); controller.setSettings(settings);
selectStationStage = new Stage(); selectStationStage = new Stage();
@ -121,11 +121,11 @@ public class NumbersStationController implements Initializable {
} }
if (!Files.exists(filePath)) { if (!Files.exists(filePath)) {
settings = new NumbersStationSettings(); settings = new MainSettings();
xmlMapper.writeValue(new File(filePath.toString()), settings); xmlMapper.writeValue(new File(filePath.toString()), settings);
} else { } else {
settings = xmlMapper.readValue(new File(filePath.toString()), NumbersStationSettings.class); settings = xmlMapper.readValue(new File(filePath.toString()), MainSettings.class);
} }
} catch (IOException e) { } catch (IOException e) {
// Print the contents of filePath // Print the contents of filePath

View File

@ -1,4 +1,4 @@
package name.nathanmcrae; package name.nathanmcrae.numbersstation;
import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import java.io.File; import java.io.File;
@ -8,7 +8,7 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
public class NumbersStationSettings { public class MainSettings {
private int digitsPerGroup; private int digitsPerGroup;
private String username; private String username;
private int refreshInterval; private int refreshInterval;
@ -16,7 +16,7 @@ public class NumbersStationSettings {
private ArrayList<StationSettings> stations; private ArrayList<StationSettings> stations;
public NumbersStationSettings() { public MainSettings() {
stations = new ArrayList<>(); stations = new ArrayList<>();
stations.add(new StationSettings("Station 1")); stations.add(new StationSettings("Station 1"));
} }

View File

@ -1,4 +1,4 @@
package name.nathanmcrae; package name.nathanmcrae.numbersstation;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
@ -13,7 +13,7 @@ import javafx.scene.control.TextField;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.stage.Stage; import javafx.stage.Stage;
public class NumbersStationSettingsController { 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();
@ -24,7 +24,7 @@ public class NumbersStationSettingsController {
@FXML @FXML
private TextField stationAddressField; private TextField stationAddressField;
public NumbersStationSettingsController() throws IOException { public MainSettingsController() throws IOException {
// System.out.println("Created settings controller"); // System.out.println("Created settings controller");
// File file = new File("setting-test.xml"); // File file = new File("setting-test.xml");
// XmlMapper xmlMapper = new XmlMapper(); // XmlMapper xmlMapper = new XmlMapper();
@ -40,13 +40,8 @@ public class NumbersStationSettingsController {
} }
@FXML @FXML
private void handleSaveButtonPress(Event e) { private void handleAddPrefixButtonPress() {
settings.setAddress(stationAddress.get()); // TODO
Node node = (Node) e.getSource();
Stage stage = (Stage) node.getScene().getWindow();
stage.setUserData(true);
stage.close();
} }
@FXML @FXML
@ -57,6 +52,21 @@ public class NumbersStationSettingsController {
stage.close(); stage.close();
} }
@FXML
private void handleRemovePrefixButtonPress() {
// TODO
}
@FXML
private void handleSaveButtonPress(Event e) {
settings.setAddress(stationAddress.get());
Node node = (Node) e.getSource();
Stage stage = (Stage) node.getScene().getWindow();
stage.setUserData(true);
stage.close();
}
public StringProperty stationAddressProperty() { public StringProperty stationAddressProperty() {
return stationAddress; return stationAddress;
} }

View File

@ -18,11 +18,11 @@
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<AnchorPane prefHeight="700.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.NumbersStationSettingsController"> <AnchorPane prefHeight="700.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.MainSettingsController">
<children> <children>
<ScrollPane fitToWidth="true" hbarPolicy="NEVER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="297.0" prefWidth="600.0" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <ScrollPane fitToWidth="true" hbarPolicy="NEVER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0" prefWidth="600.0" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content> <content>
<VBox prefHeight="631.0" prefWidth="598.0"> <VBox prefHeight="679.0" prefWidth="598.0">
<children> <children>
<FlowPane alignment="CENTER_LEFT" prefHeight="41.0" prefWidth="640.0"> <FlowPane alignment="CENTER_LEFT" prefHeight="41.0" prefWidth="640.0">
<children> <children>
@ -108,8 +108,8 @@
<Font size="14.0" /> <Font size="14.0" />
</font> </font>
</Label> </Label>
<Button layoutX="520.5" layoutY="4.0" mnemonicParsing="false" onAction="#handleAddButtonPress" text="+" AnchorPane.rightAnchor="33.0" /> <Button layoutX="520.5" layoutY="4.0" mnemonicParsing="false" onMousePressed="#handleAddPrefixButtonPress" text="+" AnchorPane.rightAnchor="33.0" />
<Button layoutX="552.0" layoutY="4.0" mnemonicParsing="false" onAction="#handleRemoveButtonPress" prefHeight="25.0" prefWidth="25.0" text="-" AnchorPane.rightAnchor="1.0" /> <Button layoutX="552.0" layoutY="4.0" mnemonicParsing="false" onMousePressed="#handleRemovePrefixButtonPress" prefHeight="25.0" prefWidth="25.0" text="-" AnchorPane.rightAnchor="1.0" />
</children> </children>
<VBox.margin> <VBox.margin>
<Insets bottom="10.0" /> <Insets bottom="10.0" />
@ -126,7 +126,7 @@
<Font size="14.0" /> <Font size="14.0" />
</font> </font>
</Label> </Label>
<AnchorPane prefHeight="132.0" prefWidth="578.0"> <AnchorPane prefHeight="152.0" prefWidth="578.0">
<children> <children>
<CheckBox layoutX="395.0" mnemonicParsing="false" text="Manage schedule externally" AnchorPane.rightAnchor="14.5" /> <CheckBox layoutX="395.0" mnemonicParsing="false" text="Manage schedule externally" AnchorPane.rightAnchor="14.5" />
<RadioButton layoutX="14.0" layoutY="8.0" mnemonicParsing="false" text="Daily"> <RadioButton layoutX="14.0" layoutY="8.0" mnemonicParsing="false" text="Daily">
@ -138,7 +138,8 @@
<RadioButton layoutX="14.0" layoutY="68.0" mnemonicParsing="false" text="Monthly" toggleGroup="$scheduleFrequency" /> <RadioButton layoutX="14.0" layoutY="68.0" mnemonicParsing="false" text="Monthly" toggleGroup="$scheduleFrequency" />
<DatePicker layoutX="115.0" layoutY="34.0" /> <DatePicker 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="2025-01-10T23:24:49" /> <TextField layoutX="115.0" layoutY="64.0" text="23:24:49" />
<Label layoutX="48.0" layoutY="102.0" text="TODO: Jitter" />
</children> </children>
</AnchorPane> </AnchorPane>
</children> </children>

View File

@ -43,7 +43,7 @@
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<AnchorPane xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.NumbersStationController"> <AnchorPane xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.MainController">
<children> <children>
<VBox maxHeight="1.7976931348623157E308" minWidth="400.0" prefHeight="400.0" prefWidth="640.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <VBox maxHeight="1.7976931348623157E308" minWidth="400.0" prefHeight="400.0" prefWidth="640.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children> <children>

View File

@ -1,4 +1,4 @@
package name.nathanmcrae; package name.nathanmcrae.numbersstation;
import javafx.collections.ListChangeListener; import javafx.collections.ListChangeListener;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
@ -13,16 +13,16 @@ import javafx.scene.Node;
import javafx.stage.Stage; import javafx.stage.Stage;
import java.util.Optional; import java.util.Optional;
public class NumbersStationSelectionController { public class StationSelectionController {
private NumbersStationSettings settings; private MainSettings settings;
@FXML @FXML
private ListView<StationSettings> stationListView; private ListView<StationSettings> stationListView;
private ObservableList<StationSettings> stationList; private ObservableList<StationSettings> stationList;
public NumbersStationSelectionController() { public StationSelectionController() {
// Initialize the list with an empty list // Initialize the list with an empty list
stationList = FXCollections.observableArrayList(); stationList = FXCollections.observableArrayList();
// Add listener to the stationList // Add listener to the stationList
@ -45,7 +45,7 @@ public class NumbersStationSelectionController {
}); });
} }
public void setSettings(NumbersStationSettings newSettings) { public void setSettings(MainSettings newSettings) {
settings = newSettings; settings = newSettings;
stationList.addAll(settings.getStations()); stationList.addAll(settings.getStations());
stationListView.setItems(stationList); stationListView.setItems(stationList);

View File

@ -6,7 +6,7 @@
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="437.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.NumbersStationSelectionController"> <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="437.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.StationSelectionController">
<children> <children>
<Label layoutX="14.0" layoutY="14.0" text="Numbers Stations"> <Label layoutX="14.0" layoutY="14.0" text="Numbers Stations">
<font> <font>

View File

@ -1,4 +1,4 @@
package name.nathanmcrae; package name.nathanmcrae.numbersstation;
public class StationSettings { public class StationSettings {
private String name; private String name;