This commit is contained in:
2025-10-03 15:00:27 -04:00
parent d18e1acc24
commit 9bebe024b5
7 changed files with 114 additions and 98 deletions

View File

@@ -28,3 +28,7 @@ Install Graphviz in your OS
dot -Tsvg classdiagram.dot -o classdiagram.svg dot -Tsvg classdiagram.dot -o classdiagram.svg
### build a list of accomodations
https://earth.google.com/web : to find building address
https://www.unitedstateszipcodes.org/ : to check zipcodes

View File

@@ -11,7 +11,7 @@ public class TestMainFx extends Application {
public void start(Stage primaryStage) { public void start(Stage primaryStage) {
try { try {
primaryStage.setTitle("Lodge ReservationSystem"); primaryStage.setTitle("Lodge ReservationSystem");
Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("main.fxml")); Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("mainViewModel.fxml"));
Scene scene = new Scene(root, 800, 600); Scene scene = new Scene(root, 800, 600);
primaryStage.setScene(scene); primaryStage.setScene(scene);
primaryStage.show(); primaryStage.show();

View File

@@ -1,76 +0,0 @@
package lodge;
import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.util.Callback;
import lodge.datamodel.Account;
import lodge.datamodel.Address;
import lodge.datamodel.EmailAddress;
public class TestMainFxAccountDialog extends Dialog<Account> {
private Address mailingAddress;
private EmailAddress emailAddress;
private String phoneNumber;
public Address getMailingAddress() {
return mailingAddress;
}
public void setMailingAddress(Address mailingAddress) {
this.mailingAddress = mailingAddress;
}
public EmailAddress getEmailAddress() {
return emailAddress;
}
public void setEmailAddress(EmailAddress emailAddress) {
this.emailAddress = emailAddress;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public TestMainFxAccountDialog() {
super();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource("accountdialog.fxml"));
fxmlLoader.setController(this);
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
getDialogPane().setContent(fxmlLoader.getRoot());
getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
setTitle("Account Dialog");
setHeaderText("Enter Account Details");
setPropertyBindings();
setResultConverter();
}
private void setPropertyBindings() {
System.out.println("setPropertyBindings called.");
}
private void setResultConverter() {
System.out.println("setResultConverter called.");
Callback<ButtonType, Account> aRC = (buttonType) -> {
if (buttonType == ButtonType.OK && mailingAddress != null && getEmailAddress().getEmail_address().trim().length() > 0 && getPhoneNumber().trim().length() > 0) {
return new Account(phoneNumber, mailingAddress, emailAddress);
}
return null;
};
setResultConverter(aRC);
}
}

View File

@@ -0,0 +1,75 @@
package lodge;
import java.io.IOException;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.TextField;
import javafx.util.Callback;
import lodge.datamodel.Address;
public class TestMainFxCommandDialog extends Dialog<Address> {
@FXML
private TextField tfStreet;
@FXML
private TextField tfCity;
@FXML
private TextField tfState;
@FXML
private TextField tfZip;
public TestMainFxCommandDialog() {
super();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource("dialogCommandAddress.fxml"));
fxmlLoader.setController(this);
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
getDialogPane().setContent(fxmlLoader.getRoot());
getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
setTitle("AccomodationAddress Dialog");
setHeaderText("Enter Inventory Details");
setPropertyBindings();
setResultConverter();
}
private void setPropertyBindings() {
System.out.println("setPropertyBindings called.");
}
private void setResultConverter() {
System.out.println("setResultConverter called.");
Callback<ButtonType, Address> aRC = (buttonType) -> {
if (buttonType == ButtonType.OK) {
if(getStreet().isEmpty() || getCity().isEmpty() || getState().isEmpty() || getZip().isEmpty()) {
return null;
}
return new Address(getStreet(), getCity(), getState(), getZip());
}
return null;
};
setResultConverter(aRC);
}
private String getZip() {
return tfZip.getText();
}
private String getState() {
return tfState.getText();
}
private String getCity() {
return tfCity.getText();
}
private String getStreet() {
return tfStreet.getText();
}
}

View File

@@ -14,15 +14,15 @@ import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.PropertyValueFactory;
import lodge.datamodel.Address; import lodge.datamodel.Address;
public class TestMainFxCommandButtonEventController { public class TestMainFxView {
@FXML @FXML
private Button btnAdd; private Button btnAdd;
@FXML @FXML
private TableView tvInventory; private TableView<Address> tvInventory;
private final ObservableList<Address> rows = FXCollections.observableArrayList(); private final ObservableList<Address> rows = FXCollections.observableArrayList();
@FXML @FXML
private void initialize() { private void initialize() {
@@ -30,12 +30,16 @@ public class TestMainFxCommandButtonEventController {
rows.add(new Address("10 wilco ave", "wilco", "WY", "82801")); rows.add(new Address("10 wilco ave", "wilco", "WY", "82801"));
rows.add(new Address("30 Amstadam ave", "New York", "NY", "12010")); rows.add(new Address("30 Amstadam ave", "New York", "NY", "12010"));
rows.add(new Address("400 hotel ave", "Maryland City", "MD", "20723")); rows.add(new Address("400 hotel ave", "Maryland City", "MD", "20723"));
rows.add(new Address("160 Canal Road", "South Bethany", "Delaware", "19930"));
TableColumn<Address, String> tcStreet = new TableColumn<>("Street"); TableColumn<Address, String> tcStreet = new TableColumn<>("Street");
TableColumn<Address, String> tcCity = new TableColumn<>("City"); TableColumn<Address, String> tcCity = new TableColumn<>("City");
TableColumn<Address, String> tcState = new TableColumn<>("State"); TableColumn<Address, String> tcState = new TableColumn<>("State");
TableColumn<Address, String> tcZip = new TableColumn<>("Zip"); TableColumn<Address, String> tcZip = new TableColumn<>("Zip");
List<TableColumn<Address, String>> columns = new ArrayList<>();
tcStreet.setPrefWidth( 100.0d ); tcStreet.setPrefWidth( 100.0d );
tcStreet.setMinWidth(100.0d); tcStreet.setMinWidth(100.0d);
tcCity.setPrefWidth( 100.0d ); tcCity.setPrefWidth( 100.0d );
@@ -47,21 +51,28 @@ public class TestMainFxCommandButtonEventController {
tcState.setCellValueFactory(new PropertyValueFactory<Address, String>("state")); tcState.setCellValueFactory(new PropertyValueFactory<Address, String>("state"));
tcZip.setCellValueFactory(new PropertyValueFactory<Address, String>("zip")); tcZip.setCellValueFactory(new PropertyValueFactory<Address, String>("zip"));
tvInventory.itemsProperty().bind( new SimpleObjectProperty<>(rows) );
tvInventory.getColumns().clear(); tvInventory.getColumns().clear();
tvInventory.getColumns().addAll(tcStreet, tcCity, tcState, tcZip);
columns.add(tcStreet);
columns.add(tcCity);
columns.add(tcState);
columns.add(tcZip);
tvInventory.getColumns().addAll(columns);
tvInventory.itemsProperty().bind( new SimpleObjectProperty<>(rows) );
btnAdd.setOnAction((ev) -> { btnAdd.setOnAction((ev) -> {
TestMainFxAccountDialog accomodationDialog = new TestMainFxAccountDialog(); TestMainFxCommandDialog accomodationDialog = new TestMainFxCommandDialog();
Optional result = accomodationDialog.showAndWait(); Optional result = accomodationDialog.showAndWait();
if (result.isPresent()) { if (result.isPresent()) {
System.out.println("result is present."); System.out.println("result is present.");
// add to storage // add to storage
rows.add((Address) result.get());
// bind to model // bind to model
tvInventory.refresh();
} }
}); });

View File

@@ -9,7 +9,7 @@
<?import javafx.scene.layout.RowConstraints?> <?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="361.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/24.0.1"> <GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="364.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/24.0.1">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="294.0" minWidth="-Infinity" prefWidth="168.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="294.0" minWidth="-Infinity" prefWidth="168.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="477.0" minWidth="10.0" prefWidth="432.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="477.0" minWidth="10.0" prefWidth="432.0" />
@@ -17,7 +17,7 @@
<rowConstraints> <rowConstraints>
<RowConstraints maxHeight="128.0" minHeight="10.0" prefHeight="43.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="128.0" minHeight="10.0" prefHeight="43.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="189.0" minHeight="10.0" prefHeight="48.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="189.0" minHeight="10.0" prefHeight="48.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="309.0" minHeight="10.0" prefHeight="309.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="309.0" minHeight="10.0" prefHeight="180.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<Label prefHeight="18.0" prefWidth="165.0" text="Email:" /> <Label prefHeight="18.0" prefWidth="165.0" text="Email:" />
@@ -25,29 +25,29 @@
<Label prefHeight="18.0" prefWidth="165.0" text="Phone Number:" GridPane.rowIndex="1" /> <Label prefHeight="18.0" prefWidth="165.0" text="Phone Number:" GridPane.rowIndex="1" />
<Label prefHeight="18.0" prefWidth="165.0" text="Mailing Address:" GridPane.rowIndex="2" /> <Label prefHeight="18.0" prefWidth="165.0" text="Mailing Address:" GridPane.rowIndex="2" />
<TextField promptText="phone number" GridPane.columnIndex="1" GridPane.rowIndex="1" /> <TextField promptText="phone number" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<VBox prefHeight="262.0" prefWidth="432.0" GridPane.columnIndex="1" GridPane.rowIndex="2"> <VBox prefHeight="180.0" prefWidth="432.0" GridPane.columnIndex="1" GridPane.rowIndex="2">
<children> <children>
<Label text="Street" /> <Label text="Street" />
<TextField /> <TextField fx:id="tfStreet" promptText="street"/>
<GridPane prefHeight="152.0" prefWidth="432.0"> <GridPane prefHeight="90.0" prefWidth="432.0">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="210.0" minWidth="10.0" prefWidth="151.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="210.0" minWidth="10.0" prefWidth="151.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="295.0" minWidth="10.0" prefWidth="123.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="295.0" minWidth="10.0" prefWidth="123.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="295.0" minWidth="10.0" prefWidth="159.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="295.0" minWidth="10.0" prefWidth="159.0" />
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints maxHeight="40.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="40.0" minHeight="10.0" prefHeight="33.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="66.0" minHeight="10.0" prefHeight="48.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="66.0" minHeight="10.0" prefHeight="48.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="66.0" minHeight="10.0" prefHeight="54.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="66.0" minHeight="10.0" prefHeight="54.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="24.0" minHeight="10.0" prefHeight="17.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="40.0" minHeight="10.0" prefHeight="17.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<Label text="State" GridPane.columnIndex="1" /> <Label text="State" GridPane.columnIndex="1" />
<Label text="City" /> <Label text="City" />
<Label text="Zip" GridPane.columnIndex="2" /> <Label text="Zip" GridPane.columnIndex="2" />
<TextField prefHeight="33.0" prefWidth="150.0" GridPane.rowIndex="1" /> <TextField fx:id="tfCity" prefHeight="38.0" prefWidth="150.0" GridPane.rowIndex="1" />
<TextField prefHeight="33.0" prefWidth="120.0" GridPane.columnIndex="1" GridPane.rowIndex="1" /> <TextField fx:id="tfState" prefHeight="38.0" prefWidth="120.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField prefHeight="33.0" prefWidth="159.0" GridPane.columnIndex="2" GridPane.rowIndex="1" /> <TextField fx:id="tfZip" prefHeight="38.0" prefWidth="159.0" GridPane.columnIndex="2" GridPane.rowIndex="1" />
</children> </children>
</GridPane> </GridPane>
<ButtonBar prefHeight="38.0" prefWidth="429.0"> <ButtonBar prefHeight="38.0" prefWidth="429.0">

View File

@@ -47,7 +47,7 @@
<?import javafx.scene.paint.Color?> <?import javafx.scene.paint.Color?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<VBox prefHeight="600.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/24.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="lodge.TestMainFxCommandButtonEventController"> <VBox prefHeight="600.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/24.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="lodge.TestMainFxView">
<children> <children>
<SplitPane dividerPositions="0.11469933184855234" focusTraversable="true" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS"> <SplitPane dividerPositions="0.11469933184855234" focusTraversable="true" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
<items> <items>
@@ -64,13 +64,15 @@
<SplitPane dividerPositions="0.2979094076655052, 0.6480836236933798" layoutY="88.0" orientation="VERTICAL" prefHeight="576.0" prefWidth="140.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <SplitPane dividerPositions="0.2979094076655052, 0.6480836236933798" layoutY="88.0" orientation="VERTICAL" prefHeight="576.0" prefWidth="140.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items> <items>
<AnchorPane prefHeight="291.0" prefWidth="98.0"> <AnchorPane prefHeight="291.0" prefWidth="98.0">
<VBox>
<children> <children>
<ButtonBar layoutY="71.0" prefHeight="40.0" prefWidth="129.0"> <ButtonBar layoutY="71.0" prefHeight="40.0" prefWidth="129.0">
<buttons> <buttons>
<Button fx:id="btnAdd" mnemonicParsing="false" prefHeight="30.0" text="Add" /> <Button fx:id="btnAdd" mnemonicParsing="false" prefHeight="30.0" text="Add" />
<Button mnemonicParsing="false" prefHeight="30.0" text="Reserve" />
</buttons> </buttons>
</ButtonBar> </ButtonBar>
</children></AnchorPane> </children></VBox></AnchorPane>
<AnchorPane prefHeight="78.0" prefWidth="98.0" /> <AnchorPane prefHeight="78.0" prefWidth="98.0" />
<AnchorPane prefHeight="223.0" prefWidth="98.0" /> <AnchorPane prefHeight="223.0" prefWidth="98.0" />
</items> </items>
@@ -79,12 +81,12 @@
</AnchorPane> </AnchorPane>
<AnchorPane prefHeight="459.0" prefWidth="574.0"> <AnchorPane prefHeight="459.0" prefWidth="574.0">
<children> <children>
<Label alignment="CENTER" font="$x1" layoutX="14.0" layoutY="14.0" style="&#10;" text="Details" textAlignment="CENTER" textFill="$x2" wrapText="false" /> <Label alignment="CENTER" font="$x1" layoutX="14.0" layoutY="14.0" style="&#10;" text="Accomodations" textAlignment="CENTER" textFill="$x2" wrapText="false" />
<VBox layoutX="34.0" layoutY="54.0" prefHeight="576.0" prefWidth="761.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <VBox layoutX="34.0" layoutY="54.0" prefHeight="576.0" prefWidth="761.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children> <children>
<HBox prefHeight="36.0" prefWidth="483.0"> <HBox prefHeight="36.0" prefWidth="483.0">
<children> <children>
<Label prefHeight="30.0" prefWidth="66.0" text="Label" /> <Label prefHeight="30.0" prefWidth="66.0" text="" />
<Label prefHeight="28.0" prefWidth="115.0" /> <Label prefHeight="28.0" prefWidth="115.0" />
<TextField prefHeight="31.0" prefWidth="314.0" promptText="search" /> <TextField prefHeight="31.0" prefWidth="314.0" promptText="search" />
</children> </children>