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: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"
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
cp name/nathanmcrae/*.fxml out/name/nathanmcrae
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
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/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.Main

View File

@ -1,4 +1,4 @@
package name.nathanmcrae;
package name.nathanmcrae.numbersstation;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
@ -6,10 +6,10 @@ import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class NumbersStation extends Application {
public class Main extends Application {
@Override
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.setScene(new Scene(root));
primaryStage.show();

View File

@ -1,4 +1,4 @@
package name.nathanmcrae;
package name.nathanmcrae.numbersstation;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import java.io.File;
@ -23,10 +23,10 @@ import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
public class NumbersStationController implements Initializable {
public class MainController implements Initializable {
private Stage settingsStage;
private Stage selectStationStage;
private NumbersStationSettings settings;
private MainSettings settings;
private StationSettings selectedStation;
private StringProperty selectedStationName = new SimpleStringProperty();
@ -47,10 +47,10 @@ public class NumbersStationController implements Initializable {
if (settingsStage == null || !settingsStage.isShowing()) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("NumbersStationSettings.fxml"));
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MainSettingsView.fxml"));
Parent root = fxmlLoader.load();
NumbersStationSettingsController controller = fxmlLoader.getController();
MainSettingsController controller = fxmlLoader.getController();
controller.setStationSettings(selectedStation);
settingsStage = new Stage();
@ -73,11 +73,11 @@ public class NumbersStationController implements Initializable {
private void handleSelectStationButtonPress() {
if (selectStationStage == null || !selectStationStage.isShowing()) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("NumbersStationSelection.fxml"));
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("StationSelectionView.fxml"));
Parent root = fxmlLoader.load();
// Pass settings to the controller
NumbersStationSelectionController controller = fxmlLoader.getController();
StationSelectionController controller = fxmlLoader.getController();
controller.setSettings(settings);
selectStationStage = new Stage();
@ -121,11 +121,11 @@ public class NumbersStationController implements Initializable {
}
if (!Files.exists(filePath)) {
settings = new NumbersStationSettings();
settings = new MainSettings();
xmlMapper.writeValue(new File(filePath.toString()), settings);
} else {
settings = xmlMapper.readValue(new File(filePath.toString()), NumbersStationSettings.class);
settings = xmlMapper.readValue(new File(filePath.toString()), MainSettings.class);
}
} catch (IOException e) {
// 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 java.io.File;
@ -8,7 +8,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
public class NumbersStationSettings {
public class MainSettings {
private int digitsPerGroup;
private String username;
private int refreshInterval;
@ -16,7 +16,7 @@ public class NumbersStationSettings {
private ArrayList<StationSettings> stations;
public NumbersStationSettings() {
public MainSettings() {
stations = new ArrayList<>();
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.core.JsonProcessingException;
@ -13,7 +13,7 @@ import javafx.scene.control.TextField;
import javafx.scene.Node;
import javafx.stage.Stage;
public class NumbersStationSettingsController {
public class MainSettingsController {
private StationSettings settings;
private StringProperty stationAddress = new SimpleStringProperty();
private StringProperty stationName = new SimpleStringProperty();
@ -24,7 +24,7 @@ public class NumbersStationSettingsController {
@FXML
private TextField stationAddressField;
public NumbersStationSettingsController() throws IOException {
public MainSettingsController() throws IOException {
// System.out.println("Created settings controller");
// File file = new File("setting-test.xml");
// XmlMapper xmlMapper = new XmlMapper();
@ -40,13 +40,8 @@ public class NumbersStationSettingsController {
}
@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();
private void handleAddPrefixButtonPress() {
// TODO
}
@FXML
@ -57,6 +52,21 @@ public class NumbersStationSettingsController {
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() {
return stationAddress;
}

View File

@ -18,11 +18,11 @@
<?import javafx.scene.layout.VBox?>
<?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>
<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>
<VBox prefHeight="631.0" prefWidth="598.0">
<VBox prefHeight="679.0" prefWidth="598.0">
<children>
<FlowPane alignment="CENTER_LEFT" prefHeight="41.0" prefWidth="640.0">
<children>
@ -108,8 +108,8 @@
<Font size="14.0" />
</font>
</Label>
<Button layoutX="520.5" layoutY="4.0" mnemonicParsing="false" onAction="#handleAddButtonPress" 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="520.5" layoutY="4.0" mnemonicParsing="false" onMousePressed="#handleAddPrefixButtonPress" text="+" AnchorPane.rightAnchor="33.0" />
<Button layoutX="552.0" layoutY="4.0" mnemonicParsing="false" onMousePressed="#handleRemovePrefixButtonPress" prefHeight="25.0" prefWidth="25.0" text="-" AnchorPane.rightAnchor="1.0" />
</children>
<VBox.margin>
<Insets bottom="10.0" />
@ -126,7 +126,7 @@
<Font size="14.0" />
</font>
</Label>
<AnchorPane prefHeight="132.0" prefWidth="578.0">
<AnchorPane prefHeight="152.0" prefWidth="578.0">
<children>
<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">
@ -138,7 +138,8 @@
<RadioButton layoutX="14.0" layoutY="68.0" mnemonicParsing="false" text="Monthly" toggleGroup="$scheduleFrequency" />
<DatePicker layoutX="115.0" layoutY="34.0" />
<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>
</AnchorPane>
</children>

View File

@ -43,7 +43,7 @@
<?import javafx.scene.layout.VBox?>
<?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>
<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>

View File

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

View File

@ -6,7 +6,7 @@
<?import javafx.scene.layout.AnchorPane?>
<?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>
<Label layoutX="14.0" layoutY="14.0" text="Numbers Stations">
<font>

View File

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