update project.

This commit is contained in:
2026-02-19 21:12:03 -05:00
parent 21f792685c
commit 24112322b9
17 changed files with 100 additions and 24 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+6
View File
@@ -15,8 +15,14 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ajdt.core.ajbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.ajdt.ui.ajnature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
+2 -1
View File
@@ -5,6 +5,7 @@
plugins {
id 'application'
id("io.freefair.aspectj") version "9.2.0"
id("org.openjfx.javafxplugin") version "0.1.0"
}
@@ -36,7 +37,7 @@ sourceSets {
javafx {
version = "25.0.2"
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.graphics' ]
modules = [ 'javafx.controls', 'javafx.fxml']
}
dependencies {
BIN
View File
Binary file not shown.
@@ -40,12 +40,13 @@ public class ControlDDXDialog extends Dialog<Contact> {
@FXML
private TextField tfZip;
public ControlDDXDialog() {
public ControlDDXDialog(Contact ct) {
super();
String fxml = "/media/ControlAddressDDXDialog.fxml";
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource(fxml));
fxmlLoader.setController(this);
fxmlLoader.setLocation(getClass().getResource(fxml));
try {
fxmlLoader.load();
} catch (IOException exception) {
@@ -55,12 +56,25 @@ public class ControlDDXDialog extends Dialog<Contact> {
getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
setTitle("Contact Address Dialog");
setHeaderText(String.format("Enter Contact Details"));
setPropertyBindings();
setPropertyBindings(ct);
setResultConverter();
}
private void setPropertyBindings() {
private void setPropertyBindings(Contact ct) {
Logger.getLogger(getClass().getName()).log(Level.INFO, "setPropertyBindings called.");
if (ct == null) {
return;
}
tfFirstName.setText(ct.getFirst_name());
tfLastName.setText(ct.getLast_name());
tfPhoneNo.setText(ct.getPhoneNo().getphone_number());
tfEmail.setText(ct.getEmail().getEmail_address());
tfStreet.setText(ct.getMailing_address().getStreet());
tfCity.setText(ct.getMailing_address().getStreet());
tfState.setText(ct.getMailing_address().getState());
tfZip.setText(ct.getMailing_address().getZip());
}
private void setResultConverter() {
@@ -0,0 +1,10 @@
package edu.bookocontacts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public aspect StorageMonitor {
pointcut save(): execution(public * edu.bookocontacts.model.Factory.*(..));
}
@@ -27,6 +27,8 @@ import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.PickResult;
/**
* FXML Controller class
@@ -100,7 +102,7 @@ public class ViewController implements Initializable {
@Override
public void handle(javafx.event.ActionEvent t) {
ControlDDXDialog dialog = new ControlDDXDialog();
ControlDDXDialog dialog = new ControlDDXDialog(contactView.getSelectionModel().getSelectedItem());
Optional<Contact> result = dialog.showAndWait();
@@ -137,6 +139,26 @@ public class ViewController implements Initializable {
updatecontactView();
}
});
contactView.setOnMouseClicked(e -> {
PickResult p = e.getPickResult();
ControlDDXDialog dialog = new ControlDDXDialog(contactView.getSelectionModel().getSelectedItem());
Optional<Contact> result = dialog.showAndWait();
if (result.isPresent()) {
log("result is present.");
// add to storage
Contact ct = (Contact) result.get();
try {
ct.save();
} catch (Exception ex) {
log(ex.getMessage());
}
updatecontactView();
}
});
}
private void initializeTable() {
@@ -35,7 +35,8 @@ public interface DATASET {
rs.getString("FIRST_NAME"),
rs.getString("LAST_NAME"),
new EmailAddress(rs.getString("EMAIL_ADDRESS")),
new PhoneNumber(rs.getString("PHONE_NUMBER")));
new PhoneNumber(rs.getString("PHONE_NUMBER")),
new MailAddress(rs.getString("MAIL_ADDRESS")));
ct.status = EnumStatus.STORED;
list.add(ct);
}
@@ -10,14 +10,14 @@ import java.util.List;
/**
*
*/
public interface Factory {
public final class Factory {
public static List<Contact> getAll(Contact clazz) {
return DATASET.FINDDATA();
}
static Contact createContact(Integer id, String first_name, String last_name, EmailAddress email,
PhoneNumber phone_number) {
Contact c = new Contact(first_name, last_name, email, phone_number, new MailAddress());
PhoneNumber phone_number, MailAddress mail) {
Contact c = new Contact(first_name, last_name, email, phone_number, mail);
c.setId(id);
return c;
@@ -1,6 +1,8 @@
package edu.bookocontacts.model;
public final class MailAddress{
import java.util.Scanner;
public final class MailAddress {
String street;
String city;
@@ -8,7 +10,27 @@ public final class MailAddress{
String zip;
public MailAddress() {
this("", "", "", "");
this("", "", "", "");
}
public MailAddress(String addressline) {
this("", "", "", "");
if (addressline != null) {
try (Scanner scanner = new Scanner(addressline)) {
try {
scanner.useDelimiter(",\\s*");
street = scanner.next();
city = scanner.next();
state = scanner.next();
zip = scanner.next();
} catch (java.util.NoSuchElementException e) {
scanner.close();
}
}
}
}
public MailAddress(String street, String city, String state, String zip) {
@@ -17,7 +39,7 @@ public final class MailAddress{
this.state = state;
this.zip = zip;
}
public String getStreet() {
return street;
}
@@ -50,12 +72,12 @@ public final class MailAddress{
this.zip = zip;
}
public String getMailingAddress(){
return String.format( "%s %s %s %s", formatField(this.street), formatField(this.city), this.state, this.zip );
public String getMailingAddress() {
return String.format("%s %s %s %s", formatField(this.street), formatField(this.city), this.state, this.zip);
}
private String formatField(String field){
return field == null || field.isBlank()? "": field.trim() + ",";
private String formatField(String field) {
return field == null || field.isBlank() ? "" : field.trim() + ",";
}
@Override
@@ -112,15 +134,15 @@ public final class MailAddress{
sb.append("}}");
return sb.toString();
}
public Boolean isBlank() {
if(street.isBlank() && city.isBlank() && state.isBlank()) {
return true;
}
if( zip == null || zip.isBlank() ) {
return true;
}
return false;
if (street.isBlank() && city.isBlank() && state.isBlank()) {
return true;
}
if (zip == null || zip.isBlank()) {
return true;
}
return false;
}
}