update command dialog

This commit is contained in:
2026-02-18 20:45:32 -05:00
parent a0a456a26b
commit 51c104a4e9
9 changed files with 183 additions and 93 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
+6 -6
View File
@@ -1,13 +1,13 @@
arguments= arguments=--init-script C\:\\Users\\sherw\\AppData\\Roaming\\VSCodium\\User\\globalStorage\\redhat.java\\1.52.0\\config_win\\org.eclipse.osgi\\58\\0\\.cp\\gradle\\init\\init.gradle --init-script C\:\\Users\\sherw\\AppData\\Roaming\\VSCodium\\User\\globalStorage\\redhat.java\\1.52.0\\config_win\\org.eclipse.osgi\\58\\0\\.cp\\gradle\\protobuf\\init.gradle
auto.sync=false auto.sync=true
build.scans.enabled=false build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir= connection.project.dir=
eclipse.preferences.version=1 eclipse.preferences.version=1
gradle.user.home= gradle.user.home=
java.home= java.home=C\:/Program Files/jdk-26
jvm.arguments= jvm.arguments=
offline.mode=false offline.mode=false
override.workspace.settings=false override.workspace.settings=true
show.console.view=false show.console.view=true
show.executions.view=false show.executions.view=true
@@ -12,8 +12,11 @@ import javafx.scene.control.TextField;
import javafx.util.Callback; import javafx.util.Callback;
import edu.bookocontacts.model.Address; import edu.bookocontacts.model.Address;
import edu.bookocontacts.model.Contact;
import edu.bookocontacts.model.EmailAddress;
import edu.bookocontacts.model.PhoneNumber;
public class ControlDDXDialog extends Dialog<Address> { public class ControlDDXDialog extends Dialog<Contact> {
@FXML @FXML
private TextField tfStreet; private TextField tfStreet;
@@ -38,7 +41,7 @@ public class ControlDDXDialog extends Dialog<Address> {
getDialogPane().setContent(fxmlLoader.getRoot()); getDialogPane().setContent(fxmlLoader.getRoot());
getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
setTitle("Contact Address Dialog"); setTitle("Contact Address Dialog");
setHeaderText("Enter Details"); setHeaderText(String.format("Enter Contact Details"));
setPropertyBindings(); setPropertyBindings();
setResultConverter(); setResultConverter();
} }
@@ -49,18 +52,35 @@ public class ControlDDXDialog extends Dialog<Address> {
private void setResultConverter() { private void setResultConverter() {
Logger.getLogger(getClass().getName()).log(Level.INFO, "setResultConverter called."); Logger.getLogger(getClass().getName()).log(Level.INFO, "setResultConverter called.");
Callback<ButtonType, Address> aRC = (buttonType) -> { Callback<ButtonType, Contact> aRC = (buttonType) -> {
if (buttonType == ButtonType.OK) { if (buttonType == ButtonType.OK) {
if (getStreet().isEmpty() || getCity().isEmpty() || getState().isEmpty() || getZip().isEmpty()) { if (getStreet().isEmpty() || getCity().isEmpty() || getState().isEmpty() || getZip().isEmpty()) {
return null; return null;
} }
return new Address(getStreet(), getCity(), getState(), getZip()); return new Contact(getFirstName(), getLastName(), new PhoneNumber(getPhoneNumber()),
new EmailAddress(getEmailAddress()), new Address(getStreet(), getCity(), getState(), getZip()));
} }
return null; return null;
}; };
setResultConverter(aRC); setResultConverter(aRC);
} }
private String getFirstName() {
return "";
}
private String getLastName() {
return "";
}
private String getPhoneNumber() {
return "";
}
private String getEmailAddress() {
return "";
}
private String getZip() { private String getZip() {
return tfZip.getText(); return tfZip.getText();
} }
@@ -105,7 +105,7 @@ public class ViewController implements Initializable {
ControlDDXDialog dialog = new ControlDDXDialog(); ControlDDXDialog dialog = new ControlDDXDialog();
Optional<Address> result = dialog.showAndWait(); Optional<Contact> result = dialog.showAndWait();
if (result.isPresent()) { if (result.isPresent()) {
System.out.println("result is present."); System.out.println("result is present.");
@@ -7,34 +7,61 @@ import java.io.IOException;
* Collects account attributes, and hash instance to enforce uniqueness. * Collects account attributes, and hash instance to enforce uniqueness.
*/ */
public class Contact { public class Contact {
private Integer contact_id = null; private Integer id = 0;
private String phone_number; private String first_name = null;
private Address mailing_address; private String last_name = null;
private PhoneNumber phone_number;
private EmailAddress email_address; private EmailAddress email_address;
private Address mailing_address;
public Contact() { public Contact() {
this("", "");
} }
public Contact( public Contact(String first_name, String last_name) {
String phone_number, this.first_name = first_name;
Address mailing_address, this.last_name = last_name;
EmailAddress email_address) throws IllegalArgumentException { }
public Contact(String first_name, String last_name, PhoneNumber phone_number, EmailAddress email_address,
Address mailing_address)
throws IllegalArgumentException {
this.phone_number = phone_number;
this.mailing_address = mailing_address;
this.email_address = email_address;
this.first_name = first_name;
this.last_name = last_name;
if (phone_number == null) {
throw new IllegalArgumentException(String.format("%s %s", "Contact: requires phone number"));
}
if (mailing_address == null) {
throw new IllegalArgumentException(String.format("%s %s", "Contact: requires mailing address"));
}
if (email_address == null) {
throw new IllegalArgumentException(String.format("%s %s", "Contact: requires email address"));
}
this.phone_number = phone_number;
this.mailing_address = mailing_address;
this.email_address = email_address;
}
public Contact(PhoneNumber phone_number, Address mailing_address, EmailAddress email_address)
throws IllegalArgumentException {
this.phone_number = phone_number; this.phone_number = phone_number;
this.mailing_address = mailing_address; this.mailing_address = mailing_address;
this.email_address = email_address; this.email_address = email_address;
if (phone_number == null) { if (phone_number == null) {
throw new IllegalArgumentException(String.format("%s %s", "Account: requires phone number", throw new IllegalArgumentException(String.format("%s %s", "Contact: requires phone number"));
mailing_address.toString()));
} }
if (mailing_address == null) { if (mailing_address == null) {
throw new IllegalArgumentException(String.format("%s %s", "Account: requires mailing address", throw new IllegalArgumentException(String.format("%s %s", "Contact: requires mailing address"));
phone_number.substring(phone_number.length() - 4)));
} }
if (email_address == null) { if (email_address == null) {
throw new IllegalArgumentException(String.format("%s %s", "Account: requires phone number", throw new IllegalArgumentException(String.format("%s %s", "Contact: requires email address"));
mailing_address.toString()));
} }
this.phone_number = phone_number; this.phone_number = phone_number;
@@ -42,12 +69,21 @@ public class Contact {
this.email_address = email_address; this.email_address = email_address;
} }
public Contact(String first_name, String last_name, PhoneNumber phone_number) {
this.first_name = first_name;
this.last_name = last_name;
this.phone_number = phone_number;
if (email_address == null) {
throw new IllegalArgumentException(String.format("%s %s", "Contact: requires phone number"));
}
}
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("{ \"Account\":{"); sb.append("{ \"Account\":{");
sb.append("\"account_number\": \"").append(contact_id).append("\","); sb.append("\"account_number\": \"").append(id).append("\",");
sb.append("\"phone_number\": \"").append(phone_number).append("\","); sb.append("\"phone_number\": \"").append(phone_number).append("\",");
sb.append("\"mailing_address\": ").append(mailing_address).append(","); sb.append("\"mailing_address\": ").append(mailing_address).append(",");
sb.append("\"email_address\": ").append(email_address).append(","); sb.append("\"email_address\": ").append(email_address).append(",");
@@ -58,11 +94,39 @@ public class Contact {
public static void Write(Contact acct) throws IOException { public static void Write(Contact acct) throws IOException {
} }
public String getPhone_number() { public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return this.first_name + " " + last_name;
}
public String getFirst_name() {
return first_name;
}
public void setFirst_name(String first_name) {
this.first_name = first_name;
}
public String getLast_name() {
return last_name;
}
public void setLast_name(String last_name) {
this.last_name = last_name;
}
public PhoneNumber getPhone_number() {
return phone_number; return phone_number;
} }
public void setPhone_number(String phone_number) { public void setPhone_number(PhoneNumber phone_number) {
this.phone_number = phone_number; this.phone_number = phone_number;
} }
@@ -86,7 +150,7 @@ public class Contact {
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((contact_id == null) ? 0 : contact_id.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode());
return result; return result;
} }
@@ -99,10 +163,10 @@ public class Contact {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
Contact other = (Contact) obj; Contact other = (Contact) obj;
if (contact_id == null) { if (id == null) {
if (other.contact_id != null) if (other.id != null)
return false; return false;
} else if (!contact_id.equals(other.contact_id)) } else if (!id.equals(other.id))
return false; return false;
return true; return true;
} }
@@ -110,22 +174,22 @@ public class Contact {
public boolean checkValid() throws IllegalArgumentException { public boolean checkValid() throws IllegalArgumentException {
if (email_address == null) { if (email_address == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
String.format("not valid, email_address %s", this.contact_id)); String.format("not valid, email_address %s", this.id));
} }
if (phone_number == null) { if (phone_number == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
String.format("not valid, phone_number: %s", this.contact_id)); String.format("not valid, phone_number: %s", this.id));
} }
if (getMailing_address() == null) { if (getMailing_address() == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
String.format("not valid, mailing_address: %s", this.contact_id)); String.format("not valid, mailing_address: %s", this.id));
} }
return true; return true;
} }
public void update(Contact acct) { public void update(Contact ct) {
this.setEmail_address(acct.email_address); this.setEmail_address(ct.email_address);
this.setPhone_number(acct.phone_number); this.setPhone_number(ct.phone_number);
this.setMailing_address(acct.mailing_address); this.setMailing_address(ct.mailing_address);
} }
} }
@@ -1,59 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.ButtonBar?> <?import javafx.scene.control.DialogPane?>
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.TextField?> <?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.ColumnConstraints?> <?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?> <?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?> <?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.text.Font?>
<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/25.0.1"> <DialogPane prefHeight="350.0" prefWidth="250.0" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1">
<content>
<GridPane>
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="294.0" minWidth="-Infinity" prefWidth="168.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="5.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="477.0" minWidth="10.0" prefWidth="432.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="5.0" />
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints maxHeight="128.0" minHeight="10.0" prefHeight="43.0" vgrow="SOMETIMES" /> <RowConstraints vgrow="SOMETIMES" />
<RowConstraints maxHeight="189.0" minHeight="10.0" prefHeight="48.0" vgrow="SOMETIMES" /> <RowConstraints vgrow="SOMETIMES" />
<RowConstraints maxHeight="309.0" minHeight="10.0" prefHeight="180.0" vgrow="SOMETIMES" /> <RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<Label prefHeight="18.0" prefWidth="165.0" text="Email:" /> <Label text="First Name:" />
<TextField promptText="email address" GridPane.columnIndex="1" /> <TextField promptText="First Name" GridPane.columnIndex="1" />
<Label prefHeight="18.0" prefWidth="165.0" text="Phone Number:" GridPane.rowIndex="1" /> <Label text="Last Name:" GridPane.rowIndex="1" />
<Label prefHeight="18.0" prefWidth="165.0" text="Mailing Address:" GridPane.rowIndex="2" /> <TextField promptText="Last Name" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField promptText="phone number" GridPane.columnIndex="1" GridPane.rowIndex="1" /> <Label text="Phone No:" underline="true" GridPane.rowIndex="2" >
<VBox prefHeight="180.0" prefWidth="432.0" GridPane.columnIndex="1" GridPane.rowIndex="2"> <font>
<children> <Font name="System Bold" size="12.0" />
<Label text="Street" /> </font>
<TextField fx:id="tfStreet" promptText="street"/> </Label>
<GridPane prefHeight="90.0" prefWidth="432.0"> <TextField promptText="Phone Number" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<columnConstraints> <Label text="Email:" GridPane.rowIndex="3" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="210.0" minWidth="10.0" prefWidth="151.0" /> <TextField promptText="Email Address" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="295.0" minWidth="10.0" prefWidth="123.0" /> <Label text="Address:" underline="true" GridPane.rowIndex="4">
<ColumnConstraints hgrow="SOMETIMES" maxWidth="295.0" minWidth="10.0" prefWidth="159.0" /> <font>
</columnConstraints> <Font name="System Bold" size="12.0" />
<rowConstraints> </font>
<RowConstraints maxHeight="40.0" minHeight="10.0" prefHeight="33.0" vgrow="SOMETIMES" /> </Label>
<RowConstraints maxHeight="66.0" minHeight="10.0" prefHeight="48.0" vgrow="SOMETIMES" /> <Separator GridPane.columnIndex="1" GridPane.rowIndex="4" />
<RowConstraints maxHeight="66.0" minHeight="10.0" prefHeight="54.0" vgrow="SOMETIMES" /> <TextField promptText="Street" GridPane.columnIndex="1" GridPane.rowIndex="4">
<RowConstraints maxHeight="40.0" minHeight="10.0" prefHeight="17.0" vgrow="SOMETIMES" /> <GridPane.margin>
</rowConstraints> <Insets top="4.0" />
<children> </GridPane.margin></TextField>
<Label text="State" GridPane.columnIndex="1" /> <TextField promptText="City" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<Label text="City" /> <TextField promptText="State" GridPane.columnIndex="1" GridPane.rowIndex="6" />
<Label text="Zip" GridPane.columnIndex="2" /> <TextField promptText="Zip" GridPane.columnIndex="1" GridPane.rowIndex="7" />
<TextField fx:id="tfCity" prefHeight="38.0" prefWidth="150.0" GridPane.rowIndex="1" />
<TextField fx:id="tfState" prefHeight="38.0" prefWidth="120.0" GridPane.columnIndex="1" 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"> </content>
<buttons/>
</ButtonBar> </DialogPane>
</children>
</VBox>
</children>
</GridPane>
+9 -5
View File
@@ -4,29 +4,33 @@
<?import javafx.scene.control.Pagination?> <?import javafx.scene.control.Pagination?>
<?import javafx.scene.control.TableColumn?> <?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?> <?import javafx.scene.control.TableView?>
<?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?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?> <?import javafx.scene.text.Text?>
<AnchorPane id="AnchorPane" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="edu.bookocontacts.ViewController"> <AnchorPane id="AnchorPane" prefHeight="383.0" prefWidth="565.0" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="edu.bookocontacts.ViewController">
<children> <children>
<TableView fx:id="personView" layoutX="1.0" layoutY="76.0" prefHeight="210.0" prefWidth="478.0"> <TableView fx:id="personView" layoutX="1.0" layoutY="76.0" prefHeight="226.0" prefWidth="564.0">
<columns> <columns>
<TableColumn fx:id="personViewIdCol" maxWidth="5000.0" minWidth="10.0" prefWidth="116.0" resizable="true" /> <TableColumn fx:id="personViewIdCol" maxWidth="5000.0" minWidth="10.0" prefWidth="116.0" resizable="true" />
<TableColumn fx:id="personViewNameCol" maxWidth="5000.0" minWidth="10.0" prefWidth="124.0" resizable="true" text="Name" /> <TableColumn fx:id="personViewNameCol" maxWidth="5000.0" minWidth="10.0" prefWidth="124.0" resizable="true" text="Name" />
<TableColumn fx:id="personViewAgeCol" maxWidth="5000.0" minWidth="10.0" prefWidth="93.0" resizable="true" text="Age" /> <TableColumn fx:id="personViewAgeCol" maxWidth="5000.0" minWidth="10.0" prefWidth="93.0" resizable="true" text="Age" />
</columns> </columns>
</TableView> </TableView>
<HBox layoutX="85.0" layoutY="283.0" prefHeight="64.0" prefWidth="377.0"> <HBox layoutX="85.0" layoutY="308.0" prefHeight="64.0" prefWidth="377.0">
<children> <children>
<Pagination fx:id="pagination" prefHeight="65.0" prefWidth="334.0" /> <Pagination fx:id="pagination" prefHeight="65.0" prefWidth="334.0" />
</children></HBox> </children></HBox>
<Button fx:id="save" layoutX="181.0" layoutY="21.0" mnemonicParsing="false" text="Add" textFill="#0052cc" textOverrun="CLIP" /> <Button id="AddBtn" fx:id="save" layoutX="126.0" layoutY="35.0" mnemonicParsing="false" text="Add" textFill="#0052cc" textOverrun="CLIP" />
<Text fill="#1400ff" layoutX="38.0" layoutY="39.0" scaleX="1.393175914330746" scaleY="1.5976504915765308" strokeType="OUTSIDE" strokeWidth="0.0" text="Contacts" wrappingWidth="119.82850646972656"> <Text fill="#1400ff" layoutX="25.0" layoutY="33.0" scaleX="1.393175914330746" scaleY="1.5976504915765308" strokeType="OUTSIDE" strokeWidth="0.0" text="Contacts" wrappingWidth="85.3748550415039">
<font> <font>
<Font name="System Bold" size="16.0" /> <Font name="System Bold" size="16.0" />
</font> </font>
</Text> </Text>
<TextField id="SrchTxt" layoutX="228.0" layoutY="36.0" prefHeight="25.0" prefWidth="187.0" promptText="Search" />
<Button id="DelBtn" fx:id="save1" layoutX="427.0" layoutY="36.0" mnemonicParsing="false" text="Del" textFill="#0052cc" textOverrun="CLIP" />
<Button id="SrchBtn" fx:id="save2" layoutX="174.0" layoutY="35.0" mnemonicParsing="false" text="Search" textFill="#0052cc" textOverrun="CLIP" />
</children> </children>
</AnchorPane> </AnchorPane>