This commit is contained in:
2026-02-18 21:46:39 -05:00
parent 51c104a4e9
commit 41dd1d00ab
2 changed files with 27 additions and 12 deletions
@@ -18,6 +18,15 @@ import edu.bookocontacts.model.PhoneNumber;
public class ControlDDXDialog extends Dialog<Contact> {
@FXML
private TextField tfFirstName;
@FXML
private TextField tfLastName;
@FXML
private TextField tfPhoneNo;
@FXML
private TextField tfEmail;
@FXML
private TextField tfStreet;
@FXML
@@ -54,11 +63,17 @@ public class ControlDDXDialog extends Dialog<Contact> {
Logger.getLogger(getClass().getName()).log(Level.INFO, "setResultConverter called.");
Callback<ButtonType, Contact> aRC = (buttonType) -> {
if (buttonType == ButtonType.OK) {
if (getStreet().isEmpty() || getCity().isEmpty() || getState().isEmpty() || getZip().isEmpty()) {
if (getFirstName().isBlank() && (getEmail().isBlank() || getPhoneNumber().isBlank())) {
return null;
}
if (getFirstName().isBlank() || getStreet().isEmpty() || getCity().isEmpty() || getState().isEmpty()
|| getZip().isEmpty()) {
return null;
}
return new Contact(getFirstName(), getLastName(), new PhoneNumber(getPhoneNumber()),
new EmailAddress(getEmailAddress()), new Address(getStreet(), getCity(), getState(), getZip()));
new EmailAddress(getEmail()), new Address(getStreet(), getCity(), getState(), getZip()));
}
return null;
};
@@ -77,7 +92,7 @@ public class ControlDDXDialog extends Dialog<Contact> {
return "";
}
private String getEmailAddress() {
private String getEmail() {
return "";
}
@@ -29,30 +29,30 @@
</rowConstraints>
<children>
<Label text="First Name:" />
<TextField promptText="First Name" GridPane.columnIndex="1" />
<TextField id="txFirstName" promptText="First Name" GridPane.columnIndex="1" />
<Label text="Last Name:" GridPane.rowIndex="1" />
<TextField promptText="Last Name" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Phone No:" underline="true" GridPane.rowIndex="2" >
<TextField id="tfLastName" promptText="Last Name" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Phone No:" underline="true" GridPane.rowIndex="2">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Label>
<TextField promptText="Phone Number" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<TextField id="tfPhoneNo" promptText="Phone Number" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label text="Email:" GridPane.rowIndex="3" />
<TextField promptText="Email Address" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<TextField id="tfEmail" promptText="Email Address" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Label text="Address:" underline="true" GridPane.rowIndex="4">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Label>
<Separator GridPane.columnIndex="1" GridPane.rowIndex="4" />
<TextField promptText="Street" GridPane.columnIndex="1" GridPane.rowIndex="4">
<TextField id="tfStreet" promptText="Street" GridPane.columnIndex="1" GridPane.rowIndex="4">
<GridPane.margin>
<Insets top="4.0" />
</GridPane.margin></TextField>
<TextField promptText="City" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<TextField promptText="State" GridPane.columnIndex="1" GridPane.rowIndex="6" />
<TextField promptText="Zip" GridPane.columnIndex="1" GridPane.rowIndex="7" />
<TextField id="tfCity" promptText="City" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<TextField id="tfState" promptText="State" GridPane.columnIndex="1" GridPane.rowIndex="6" />
<TextField id="tfZip" promptText="Zip" GridPane.columnIndex="1" GridPane.rowIndex="7" />
</children>
</GridPane>