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>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.ajdt.core.ajbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.ajdt.ui.ajnature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures> </natures>
+2 -1
View File
@@ -5,6 +5,7 @@
plugins { plugins {
id 'application' id 'application'
id("io.freefair.aspectj") version "9.2.0"
id("org.openjfx.javafxplugin") version "0.1.0" id("org.openjfx.javafxplugin") version "0.1.0"
} }
@@ -36,7 +37,7 @@ sourceSets {
javafx { javafx {
version = "25.0.2" version = "25.0.2"
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.graphics' ] modules = [ 'javafx.controls', 'javafx.fxml']
} }
dependencies { dependencies {
BIN
View File
Binary file not shown.
@@ -40,12 +40,13 @@ public class ControlDDXDialog extends Dialog<Contact> {
@FXML @FXML
private TextField tfZip; private TextField tfZip;
public ControlDDXDialog() { public ControlDDXDialog(Contact ct) {
super(); super();
String fxml = "/media/ControlAddressDDXDialog.fxml"; String fxml = "/media/ControlAddressDDXDialog.fxml";
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource(fxml)); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource(fxml));
fxmlLoader.setController(this); fxmlLoader.setController(this);
fxmlLoader.setLocation(getClass().getResource(fxml)); fxmlLoader.setLocation(getClass().getResource(fxml));
try { try {
fxmlLoader.load(); fxmlLoader.load();
} catch (IOException exception) { } catch (IOException exception) {
@@ -55,12 +56,25 @@ public class ControlDDXDialog extends Dialog<Contact> {
getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
setTitle("Contact Address Dialog"); setTitle("Contact Address Dialog");
setHeaderText(String.format("Enter Contact Details")); setHeaderText(String.format("Enter Contact Details"));
setPropertyBindings();
setPropertyBindings(ct);
setResultConverter(); setResultConverter();
} }
private void setPropertyBindings() { private void setPropertyBindings(Contact ct) {
Logger.getLogger(getClass().getName()).log(Level.INFO, "setPropertyBindings called."); 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() { 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.TableView;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.PickResult;
/** /**
* FXML Controller class * FXML Controller class
@@ -100,7 +102,7 @@ public class ViewController implements Initializable {
@Override @Override
public void handle(javafx.event.ActionEvent t) { public void handle(javafx.event.ActionEvent t) {
ControlDDXDialog dialog = new ControlDDXDialog(); ControlDDXDialog dialog = new ControlDDXDialog(contactView.getSelectionModel().getSelectedItem());
Optional<Contact> result = dialog.showAndWait(); Optional<Contact> result = dialog.showAndWait();
@@ -137,6 +139,26 @@ public class ViewController implements Initializable {
updatecontactView(); 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() { private void initializeTable() {
@@ -35,7 +35,8 @@ public interface DATASET {
rs.getString("FIRST_NAME"), rs.getString("FIRST_NAME"),
rs.getString("LAST_NAME"), rs.getString("LAST_NAME"),
new EmailAddress(rs.getString("EMAIL_ADDRESS")), 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; ct.status = EnumStatus.STORED;
list.add(ct); 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) { public static List<Contact> getAll(Contact clazz) {
return DATASET.FINDDATA(); return DATASET.FINDDATA();
} }
static Contact createContact(Integer id, String first_name, String last_name, EmailAddress email, static Contact createContact(Integer id, String first_name, String last_name, EmailAddress email,
PhoneNumber phone_number) { PhoneNumber phone_number, MailAddress mail) {
Contact c = new Contact(first_name, last_name, email, phone_number, new MailAddress()); Contact c = new Contact(first_name, last_name, email, phone_number, mail);
c.setId(id); c.setId(id);
return c; return c;
@@ -1,6 +1,8 @@
package edu.bookocontacts.model; package edu.bookocontacts.model;
public final class MailAddress{ import java.util.Scanner;
public final class MailAddress {
String street; String street;
String city; String city;
@@ -8,7 +10,27 @@ public final class MailAddress{
String zip; String zip;
public MailAddress() { 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) { public MailAddress(String street, String city, String state, String zip) {
@@ -50,12 +72,12 @@ public final class MailAddress{
this.zip = zip; this.zip = zip;
} }
public String getMailingAddress(){ public String getMailingAddress() {
return String.format( "%s %s %s %s", formatField(this.street), formatField(this.city), this.state, this.zip ); return String.format("%s %s %s %s", formatField(this.street), formatField(this.city), this.state, this.zip);
} }
private String formatField(String field){ private String formatField(String field) {
return field == null || field.isBlank()? "": field.trim() + ","; return field == null || field.isBlank() ? "" : field.trim() + ",";
} }
@Override @Override
@@ -115,12 +137,12 @@ public final class MailAddress{
public Boolean isBlank() { public Boolean isBlank() {
if(street.isBlank() && city.isBlank() && state.isBlank()) { if (street.isBlank() && city.isBlank() && state.isBlank()) {
return true; return true;
} }
if( zip == null || zip.isBlank() ) { if (zip == null || zip.isBlank()) {
return true; return true;
} }
return false; return false;
} }
} }