update command dialog
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,13 +1,13 @@
|
||||
arguments=
|
||||
auto.sync=false
|
||||
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=true
|
||||
build.scans.enabled=false
|
||||
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
||||
connection.project.dir=
|
||||
eclipse.preferences.version=1
|
||||
gradle.user.home=
|
||||
java.home=
|
||||
java.home=C\:/Program Files/jdk-26
|
||||
jvm.arguments=
|
||||
offline.mode=false
|
||||
override.workspace.settings=false
|
||||
show.console.view=false
|
||||
show.executions.view=false
|
||||
override.workspace.settings=true
|
||||
show.console.view=true
|
||||
show.executions.view=true
|
||||
|
||||
@@ -12,8 +12,11 @@ import javafx.scene.control.TextField;
|
||||
import javafx.util.Callback;
|
||||
|
||||
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
|
||||
private TextField tfStreet;
|
||||
@@ -38,7 +41,7 @@ public class ControlDDXDialog extends Dialog<Address> {
|
||||
getDialogPane().setContent(fxmlLoader.getRoot());
|
||||
getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
|
||||
setTitle("Contact Address Dialog");
|
||||
setHeaderText("Enter Details");
|
||||
setHeaderText(String.format("Enter Contact Details"));
|
||||
setPropertyBindings();
|
||||
setResultConverter();
|
||||
}
|
||||
@@ -49,18 +52,35 @@ public class ControlDDXDialog extends Dialog<Address> {
|
||||
|
||||
private void setResultConverter() {
|
||||
Logger.getLogger(getClass().getName()).log(Level.INFO, "setResultConverter called.");
|
||||
Callback<ButtonType, Address> aRC = (buttonType) -> {
|
||||
Callback<ButtonType, Contact> 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 new Contact(getFirstName(), getLastName(), new PhoneNumber(getPhoneNumber()),
|
||||
new EmailAddress(getEmailAddress()), new Address(getStreet(), getCity(), getState(), getZip()));
|
||||
}
|
||||
return null;
|
||||
};
|
||||
setResultConverter(aRC);
|
||||
}
|
||||
|
||||
private String getFirstName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getLastName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getPhoneNumber() {
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getEmailAddress() {
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getZip() {
|
||||
return tfZip.getText();
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class ViewController implements Initializable {
|
||||
|
||||
ControlDDXDialog dialog = new ControlDDXDialog();
|
||||
|
||||
Optional<Address> result = dialog.showAndWait();
|
||||
Optional<Contact> result = dialog.showAndWait();
|
||||
|
||||
if (result.isPresent()) {
|
||||
System.out.println("result is present.");
|
||||
|
||||
@@ -7,34 +7,61 @@ import java.io.IOException;
|
||||
* Collects account attributes, and hash instance to enforce uniqueness.
|
||||
*/
|
||||
public class Contact {
|
||||
private Integer contact_id = null;
|
||||
private String phone_number;
|
||||
private Address mailing_address;
|
||||
private Integer id = 0;
|
||||
private String first_name = null;
|
||||
private String last_name = null;
|
||||
private PhoneNumber phone_number;
|
||||
private EmailAddress email_address;
|
||||
private Address mailing_address;
|
||||
|
||||
public Contact() {
|
||||
|
||||
this("", "");
|
||||
}
|
||||
|
||||
public Contact(
|
||||
String phone_number,
|
||||
Address mailing_address,
|
||||
EmailAddress email_address) throws IllegalArgumentException {
|
||||
public Contact(String first_name, String last_name) {
|
||||
this.first_name = first_name;
|
||||
this.last_name = last_name;
|
||||
}
|
||||
|
||||
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.mailing_address = mailing_address;
|
||||
this.email_address = email_address;
|
||||
|
||||
if (phone_number == null) {
|
||||
throw new IllegalArgumentException(String.format("%s %s", "Account: requires phone number",
|
||||
mailing_address.toString()));
|
||||
throw new IllegalArgumentException(String.format("%s %s", "Contact: requires phone number"));
|
||||
}
|
||||
if (mailing_address == null) {
|
||||
throw new IllegalArgumentException(String.format("%s %s", "Account: requires mailing address",
|
||||
phone_number.substring(phone_number.length() - 4)));
|
||||
throw new IllegalArgumentException(String.format("%s %s", "Contact: requires mailing address"));
|
||||
}
|
||||
if (email_address == null) {
|
||||
throw new IllegalArgumentException(String.format("%s %s", "Account: requires phone number",
|
||||
mailing_address.toString()));
|
||||
throw new IllegalArgumentException(String.format("%s %s", "Contact: requires email address"));
|
||||
}
|
||||
|
||||
this.phone_number = phone_number;
|
||||
@@ -42,12 +69,21 @@ public class Contact {
|
||||
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
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
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("\"mailing_address\": ").append(mailing_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 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;
|
||||
}
|
||||
|
||||
public void setPhone_number(String phone_number) {
|
||||
public void setPhone_number(PhoneNumber phone_number) {
|
||||
this.phone_number = phone_number;
|
||||
}
|
||||
|
||||
@@ -86,7 +150,7 @@ public class Contact {
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((contact_id == null) ? 0 : contact_id.hashCode());
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -99,10 +163,10 @@ public class Contact {
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Contact other = (Contact) obj;
|
||||
if (contact_id == null) {
|
||||
if (other.contact_id != null)
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!contact_id.equals(other.contact_id))
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -110,22 +174,22 @@ public class Contact {
|
||||
public boolean checkValid() throws IllegalArgumentException {
|
||||
if (email_address == null) {
|
||||
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) {
|
||||
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) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("not valid, mailing_address: %s", this.contact_id));
|
||||
String.format("not valid, mailing_address: %s", this.id));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void update(Contact acct) {
|
||||
this.setEmail_address(acct.email_address);
|
||||
this.setPhone_number(acct.phone_number);
|
||||
this.setMailing_address(acct.mailing_address);
|
||||
public void update(Contact ct) {
|
||||
this.setEmail_address(ct.email_address);
|
||||
this.setPhone_number(ct.phone_number);
|
||||
this.setMailing_address(ct.mailing_address);
|
||||
}
|
||||
}
|
||||
@@ -1,59 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ButtonBar?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.DialogPane?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.Separator?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?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">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="294.0" minWidth="-Infinity" prefWidth="168.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="477.0" minWidth="10.0" prefWidth="432.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<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="309.0" minHeight="10.0" prefHeight="180.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label prefHeight="18.0" prefWidth="165.0" text="Email:" />
|
||||
<TextField promptText="email address" GridPane.columnIndex="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" />
|
||||
<TextField promptText="phone number" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
<VBox prefHeight="180.0" prefWidth="432.0" GridPane.columnIndex="1" GridPane.rowIndex="2">
|
||||
<DialogPane prefHeight="350.0" prefWidth="250.0" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<content>
|
||||
<GridPane>
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="5.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="5.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints vgrow="SOMETIMES" />
|
||||
<RowConstraints vgrow="SOMETIMES" />
|
||||
<RowConstraints vgrow="SOMETIMES" />
|
||||
<RowConstraints vgrow="SOMETIMES" />
|
||||
<RowConstraints vgrow="SOMETIMES" />
|
||||
<RowConstraints vgrow="SOMETIMES" />
|
||||
<RowConstraints vgrow="SOMETIMES" />
|
||||
<RowConstraints vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label text="Street" />
|
||||
<TextField fx:id="tfStreet" promptText="street"/>
|
||||
<GridPane prefHeight="90.0" prefWidth="432.0">
|
||||
<columnConstraints>
|
||||
<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="159.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<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="54.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="40.0" minHeight="10.0" prefHeight="17.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label text="State" GridPane.columnIndex="1" />
|
||||
<Label text="City" />
|
||||
<Label text="Zip" GridPane.columnIndex="2" />
|
||||
<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>
|
||||
</GridPane>
|
||||
<ButtonBar prefHeight="38.0" prefWidth="429.0">
|
||||
<buttons/>
|
||||
</ButtonBar>
|
||||
<Label text="First Name:" />
|
||||
<TextField 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" >
|
||||
<font>
|
||||
<Font name="System Bold" size="12.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<TextField 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" />
|
||||
<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">
|
||||
<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" />
|
||||
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
</GridPane>
|
||||
</GridPane>
|
||||
</content>
|
||||
|
||||
</DialogPane>
|
||||
|
||||
@@ -4,29 +4,33 @@
|
||||
<?import javafx.scene.control.Pagination?>
|
||||
<?import javafx.scene.control.TableColumn?>
|
||||
<?import javafx.scene.control.TableView?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?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>
|
||||
<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>
|
||||
<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="personViewAgeCol" maxWidth="5000.0" minWidth="10.0" prefWidth="93.0" resizable="true" text="Age" />
|
||||
</columns>
|
||||
</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>
|
||||
<Pagination fx:id="pagination" prefHeight="65.0" prefWidth="334.0" />
|
||||
</children></HBox>
|
||||
<Button fx:id="save" layoutX="181.0" layoutY="21.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">
|
||||
<Button id="AddBtn" fx:id="save" layoutX="126.0" layoutY="35.0" mnemonicParsing="false" text="Add" textFill="#0052cc" textOverrun="CLIP" />
|
||||
<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 name="System Bold" size="16.0" />
|
||||
</font>
|
||||
</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>
|
||||
</AnchorPane>
|
||||
|
||||
Reference in New Issue
Block a user