update project.
This commit is contained in:
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.
@@ -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
@@ -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 {
|
||||
|
||||
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,5 +1,7 @@
|
||||
package edu.bookocontacts.model;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public final class MailAddress {
|
||||
|
||||
String street;
|
||||
@@ -11,6 +13,26 @@ public final class MailAddress{
|
||||
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) {
|
||||
this.street = street;
|
||||
this.city = city;
|
||||
|
||||
Reference in New Issue
Block a user