updates
This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -21,7 +21,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"mainClass": "lodge.TestMainFx",
|
"mainClass": "lodge.TestMainFx",
|
||||||
"projectName": "reservationsystem",
|
"projectName": "reservationsystem",
|
||||||
"vmArgs": " --module-path .;${workspaceFolder}/libs;${workspaceFolder}/libs/win32 --add-modules ALL-MODULE-PATH --enable-native-access=javafx.web,javafx.controls,javafx.graphics -Dcom.sun.management.jmxremote=false -Djava.awt.headless=true -XX:+DisableAttachMechanism",
|
"vmArgs": " --module-path .:${workspaceFolder}/libs:${workspaceFolder}/libs/linux --add-modules ALL-MODULE-PATH --enable-native-access=javafx.web,javafx.controls,javafx.graphics -Dcom.sun.management.jmxremote=false -Djava.awt.headless=true -XX:+DisableAttachMechanism",
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"console": "integratedTerminal"
|
"console": "integratedTerminal"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class TestMainFx extends Application {
|
|||||||
Scene scene = new Scene(root, 800, 600);
|
Scene scene = new Scene(root, 800, 600);
|
||||||
primaryStage.setScene(scene);
|
primaryStage.setScene(scene);
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import lodge.datamodel.Account;
|
|||||||
import lodge.datamodel.Address;
|
import lodge.datamodel.Address;
|
||||||
import lodge.datamodel.EmailAddress;
|
import lodge.datamodel.EmailAddress;
|
||||||
|
|
||||||
public class AccountDialog extends Dialog<Account> {
|
public class TestMainFxAccountDialog extends Dialog<Account> {
|
||||||
|
|
||||||
private Address mailingAddress;
|
private Address mailingAddress;
|
||||||
private EmailAddress emailAddress;
|
private EmailAddress emailAddress;
|
||||||
@@ -41,7 +41,7 @@ public class AccountDialog extends Dialog<Account> {
|
|||||||
this.phoneNumber = phoneNumber;
|
this.phoneNumber = phoneNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountDialog() {
|
public TestMainFxAccountDialog() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource("accountdialog.fxml"));
|
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource("accountdialog.fxml"));
|
||||||
@@ -65,12 +65,12 @@ public class AccountDialog extends Dialog<Account> {
|
|||||||
|
|
||||||
private void setResultConverter() {
|
private void setResultConverter() {
|
||||||
System.out.println("setResultConverter called.");
|
System.out.println("setResultConverter called.");
|
||||||
Callback<ButtonType, Account> accountResultConverter = (buttonType) -> {
|
Callback<ButtonType, Account> aRC = (buttonType) -> {
|
||||||
if (buttonType == ButtonType.OK) {
|
if (buttonType == ButtonType.OK && mailingAddress != null && getEmailAddress().getEmail_address().trim().length() > 0 && getPhoneNumber().trim().length() > 0) {
|
||||||
return new Account(phoneNumber, mailingAddress, emailAddress);
|
return new Account(phoneNumber, mailingAddress, emailAddress);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
setResultConverter(accountResultConverter);
|
setResultConverter(aRC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,29 +1,65 @@
|
|||||||
package lodge;
|
package lodge;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import lodge.datamodel.Account;
|
import javafx.scene.control.TableColumn;
|
||||||
|
import javafx.scene.control.TableView;
|
||||||
|
import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
|
import lodge.datamodel.Address;
|
||||||
|
|
||||||
public class TestMainFxCommandButtonEventController {
|
public class TestMainFxCommandButtonEventController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Button btnAdd;
|
private Button btnAdd;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TableView tvInventory;
|
||||||
|
|
||||||
|
private final ObservableList<Address> rows = FXCollections.observableArrayList();
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
|
|
||||||
|
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("400 hotel ave", "Maryland City", "MD", "20723"));
|
||||||
|
|
||||||
|
TableColumn<Address, String> tcStreet = new TableColumn<>("Street");
|
||||||
|
TableColumn<Address, String> tcCity = new TableColumn<>("City");
|
||||||
|
TableColumn<Address, String> tcState = new TableColumn<>("State");
|
||||||
|
TableColumn<Address, String> tcZip = new TableColumn<>("Zip");
|
||||||
|
|
||||||
|
tcStreet.setPrefWidth( 100.0d );
|
||||||
|
tcStreet.setMinWidth(100.0d);
|
||||||
|
tcCity.setPrefWidth( 100.0d );
|
||||||
|
tcState.setPrefWidth( 100.0d );
|
||||||
|
tcZip.setPrefWidth( 100.0d );
|
||||||
|
|
||||||
|
tcStreet.setCellValueFactory(new PropertyValueFactory<Address, String>("street"));
|
||||||
|
tcCity.setCellValueFactory(new PropertyValueFactory<Address, String>("city"));
|
||||||
|
tcState.setCellValueFactory(new PropertyValueFactory<Address, String>("state"));
|
||||||
|
tcZip.setCellValueFactory(new PropertyValueFactory<Address, String>("zip"));
|
||||||
|
|
||||||
|
tvInventory.itemsProperty().bind( new SimpleObjectProperty<>(rows) );
|
||||||
|
tvInventory.getColumns().clear();
|
||||||
|
tvInventory.getColumns().addAll(tcStreet, tcCity, tcState, tcZip);
|
||||||
|
|
||||||
|
|
||||||
btnAdd.setOnAction((ev) -> {
|
btnAdd.setOnAction((ev) -> {
|
||||||
|
|
||||||
AccountDialog accomodationDialog= new AccountDialog();
|
TestMainFxAccountDialog accomodationDialog = new TestMainFxAccountDialog();
|
||||||
|
|
||||||
Optional result = accomodationDialog.showAndWait();
|
Optional result = accomodationDialog.showAndWait();
|
||||||
|
|
||||||
if( result.isPresent()){
|
if (result.isPresent()) {
|
||||||
|
System.out.println("result is present.");
|
||||||
// add to storage
|
// add to storage
|
||||||
// bind to model
|
// bind to model
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ public final class Address{
|
|||||||
/** not used
|
/** not used
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private Address() {
|
public Address() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Address(String street, String city, String state, String zip) {
|
public Address(String street, String city, String state, String zip) {
|
||||||
|
|||||||
@@ -36,8 +36,9 @@
|
|||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.control.ButtonBar?>
|
<?import javafx.scene.control.ButtonBar?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.ListView?>
|
|
||||||
<?import javafx.scene.control.SplitPane?>
|
<?import javafx.scene.control.SplitPane?>
|
||||||
|
<?import javafx.scene.control.TableColumn?>
|
||||||
|
<?import javafx.scene.control.TableView?>
|
||||||
<?import javafx.scene.control.TextField?>
|
<?import javafx.scene.control.TextField?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?import javafx.scene.layout.HBox?>
|
<?import javafx.scene.layout.HBox?>
|
||||||
@@ -46,7 +47,7 @@
|
|||||||
<?import javafx.scene.paint.Color?>
|
<?import javafx.scene.paint.Color?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<VBox fx:controller="lodge.TestMainFxCommandButtonEventController" prefHeight="600.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/24.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
<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">
|
||||||
<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>
|
||||||
@@ -88,7 +89,14 @@
|
|||||||
<TextField prefHeight="31.0" prefWidth="314.0" promptText="search" />
|
<TextField prefHeight="31.0" prefWidth="314.0" promptText="search" />
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<ListView prefHeight="536.0" prefWidth="761.0" />
|
<TableView fx:id="tvInventory" prefHeight="501.0" prefWidth="761.0">
|
||||||
|
<columns>
|
||||||
|
<TableColumn prefWidth="75.0" text="Street" />
|
||||||
|
<TableColumn prefWidth="75.0" text="City" />
|
||||||
|
<TableColumn prefWidth="75.0" text="State" />
|
||||||
|
<TableColumn prefWidth="75.0" text="Zip" />
|
||||||
|
</columns>
|
||||||
|
</TableView>
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</VBox>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
Reference in New Issue
Block a user