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.
Binary file not shown.
@@ -1,13 +1,13 @@
|
|||||||
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
|
arguments=
|
||||||
auto.sync=true
|
auto.sync=false
|
||||||
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=C\:/Program Files/jdk-26
|
java.home=
|
||||||
jvm.arguments=
|
jvm.arguments=
|
||||||
offline.mode=false
|
offline.mode=false
|
||||||
override.workspace.settings=true
|
override.workspace.settings=false
|
||||||
show.console.view=true
|
show.console.view=false
|
||||||
show.executions.view=true
|
show.executions.view=false
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class ControlDDXDialog extends Dialog<Contact> {
|
|||||||
Callback<ButtonType, Contact> aRC = (buttonType) -> {
|
Callback<ButtonType, Contact> aRC = (buttonType) -> {
|
||||||
if (buttonType == ButtonType.OK) {
|
if (buttonType == ButtonType.OK) {
|
||||||
|
|
||||||
if (getFirstName().isBlank() && (getEmail().isBlank() || getPhoneNumber().isBlank())) {
|
if (getFirstName().isBlank() && (getEmail().isBlank() || getPhoneNo().isBlank())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (getFirstName().isBlank() || getStreet().isEmpty() || getCity().isEmpty() || getState().isEmpty()
|
if (getFirstName().isBlank() || getStreet().isEmpty() || getCity().isEmpty() || getState().isEmpty()
|
||||||
@@ -72,8 +72,8 @@ public class ControlDDXDialog extends Dialog<Contact> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Contact(getFirstName(), getLastName(), new PhoneNumber(getPhoneNumber()),
|
return new Contact(getFirstName(), getLastName(), new EmailAddress(getEmail()),
|
||||||
new EmailAddress(getEmail()), new Address(getStreet(), getCity(), getState(), getZip()));
|
new PhoneNumber(getPhoneNo()), new Address(getStreet(), getCity(), getState(), getZip()));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
@@ -88,7 +88,7 @@ public class ControlDDXDialog extends Dialog<Contact> {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPhoneNumber() {
|
private String getPhoneNo() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import java.util.logging.Logger;
|
|||||||
import edu.bookocontacts.model.Factory;
|
import edu.bookocontacts.model.Factory;
|
||||||
import edu.bookocontacts.model.Person;
|
import edu.bookocontacts.model.Person;
|
||||||
import edu.bookocontacts.model.Address;
|
import edu.bookocontacts.model.Address;
|
||||||
|
import edu.bookocontacts.model.PhoneNumber;
|
||||||
import edu.bookocontacts.model.Contact;
|
import edu.bookocontacts.model.Contact;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -42,29 +43,24 @@ public class ViewController implements Initializable {
|
|||||||
Logger logger = Logger.getLogger(getClass().getName());
|
Logger logger = Logger.getLogger(getClass().getName());
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private TableView<Person> personView = new TableView<>();
|
private TableView<Contact> personView = new TableView<>();
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Person, String> personViewIdCol;
|
private TableColumn<Contact, String> personViewIdCol;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Person, String> personViewNameCol;
|
private TableColumn<Contact, String> personViewNameCol;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Person, Integer> personViewAgeCol;
|
private TableColumn<Contact, PhoneNumber> personViewPhoneNoCol;
|
||||||
@FXML
|
@FXML
|
||||||
Pagination pagination;
|
Pagination pagination;
|
||||||
@FXML
|
@FXML
|
||||||
private Button save;
|
private Button save;
|
||||||
@FXML
|
|
||||||
private TextField idTxt;
|
|
||||||
@FXML
|
|
||||||
private TextField nameTxt;
|
|
||||||
@FXML
|
|
||||||
private TextField ageTxt;
|
|
||||||
private Button id = new Button("ID");
|
private Button id = new Button("ID");
|
||||||
|
|
||||||
private ImageView upImg = new ImageView(new Image("/media/up.png"));
|
private ImageView upImg = new ImageView(new Image("/media/up.png"));
|
||||||
private ImageView downImg = new ImageView(new Image("/media/down.png"));
|
private ImageView downImg = new ImageView(new Image("/media/down.png"));
|
||||||
|
|
||||||
private ObservableList<Person> persons = null;
|
private ObservableList<Contact> contacts = null;
|
||||||
|
|
||||||
private int pageCount = 5;
|
private int pageCount = 5;
|
||||||
private int itemsPerPage = 4;
|
private int itemsPerPage = 4;
|
||||||
@@ -72,7 +68,7 @@ public class ViewController implements Initializable {
|
|||||||
private boolean order = true;
|
private boolean order = true;
|
||||||
|
|
||||||
private void log(String message) {
|
private void log(String message) {
|
||||||
logger.log(Level.FINE, message);
|
logger.log(Level.INFO, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,12 +76,12 @@ public class ViewController implements Initializable {
|
|||||||
*/
|
*/
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
log("initialize");
|
log("initialize");
|
||||||
persons = FXCollections.observableArrayList(Factory.getAll(new Person()));
|
contacts = FXCollections.observableArrayList(Factory.getAll(new Contact()));
|
||||||
log(String.format("Person size: %d", persons.size()));
|
log(String.format("Person size: %d", contacts.size()));
|
||||||
|
|
||||||
sort();
|
sort();
|
||||||
initializeTable();
|
initializeTable();
|
||||||
pageCount = getPageCount(persons.size(), itemsPerPage);
|
pageCount = getPageCount(contacts.size(), itemsPerPage);
|
||||||
|
|
||||||
log("pageCount=" + pageCount);
|
log("pageCount=" + pageCount);
|
||||||
pagination.setPageCount(pageCount);
|
pagination.setPageCount(pageCount);
|
||||||
@@ -108,9 +104,9 @@ public class ViewController implements Initializable {
|
|||||||
Optional<Contact> result = dialog.showAndWait();
|
Optional<Contact> result = dialog.showAndWait();
|
||||||
|
|
||||||
if (result.isPresent()) {
|
if (result.isPresent()) {
|
||||||
System.out.println("result is present.");
|
log("result is present.");
|
||||||
// add to storage
|
// add to storage
|
||||||
// persons.add((Address) result.get());
|
// contacts.add((Address) result.get());
|
||||||
// bind to model
|
// bind to model
|
||||||
// tvInventory.refresh();
|
// tvInventory.refresh();
|
||||||
//
|
//
|
||||||
@@ -126,9 +122,9 @@ public class ViewController implements Initializable {
|
|||||||
public void handle(javafx.event.ActionEvent t) {
|
public void handle(javafx.event.ActionEvent t) {
|
||||||
sort();
|
sort();
|
||||||
if (order) {
|
if (order) {
|
||||||
Collections.reverse(persons);
|
Collections.reverse(contacts);
|
||||||
}
|
}
|
||||||
log(" order = " + order + "; data = " + persons);
|
log(" order = " + order + "; data = " + contacts);
|
||||||
order = !order;
|
order = !order;
|
||||||
id.setGraphic((order) ? upImg : downImg);
|
id.setGraphic((order) ? upImg : downImg);
|
||||||
updatePersonView();
|
updatePersonView();
|
||||||
@@ -138,9 +134,9 @@ public class ViewController implements Initializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sort() {
|
private void sort() {
|
||||||
Collections.sort(persons, new Comparator<Person>() {
|
Collections.sort(contacts, new Comparator<Contact>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Person t, Person t1) {
|
public int compare(Contact t, Contact t1) {
|
||||||
log(" comparator called");
|
log(" comparator called");
|
||||||
return t.getId().compareTo(t1.getId());
|
return t.getId().compareTo(t1.getId());
|
||||||
}
|
}
|
||||||
@@ -148,20 +144,20 @@ public class ViewController implements Initializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updatePersonView() {
|
public void updatePersonView() {
|
||||||
log("updatePersonView");
|
log("update View");
|
||||||
personView.getItems()
|
personView.getItems()
|
||||||
.setAll(persons.subList(currentPageIndex * itemsPerPage,
|
.setAll(contacts.subList(currentPageIndex * itemsPerPage,
|
||||||
((currentPageIndex * itemsPerPage + itemsPerPage <= persons.size())
|
((currentPageIndex * itemsPerPage + itemsPerPage <= contacts.size())
|
||||||
? currentPageIndex * itemsPerPage + itemsPerPage
|
? currentPageIndex * itemsPerPage + itemsPerPage
|
||||||
: persons.size())));
|
: contacts.size())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeTable() {
|
private void initializeTable() {
|
||||||
personViewIdCol.setCellValueFactory(new PropertyValueFactory<Person, String>("Id"));
|
personViewIdCol.setCellValueFactory(new PropertyValueFactory<Contact, String>("Id"));
|
||||||
id.setGraphic(upImg);
|
id.setGraphic(upImg);
|
||||||
personViewIdCol.setGraphic(id);
|
personViewIdCol.setGraphic(id);
|
||||||
personViewIdCol.setSortable(false);
|
personViewIdCol.setSortable(false);
|
||||||
personViewNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("Name"));
|
personViewNameCol.setCellValueFactory(new PropertyValueFactory<Contact, String>("Name"));
|
||||||
personViewNameCol.sortTypeProperty().addListener(new ChangeListener<SortType>() {
|
personViewNameCol.sortTypeProperty().addListener(new ChangeListener<SortType>() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<? extends SortType> paramObservableValue, SortType paramT1,
|
public void changed(ObservableValue<? extends SortType> paramObservableValue, SortType paramT1,
|
||||||
@@ -170,10 +166,10 @@ public class ViewController implements Initializable {
|
|||||||
id.setGraphic(null);
|
id.setGraphic(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
personViewAgeCol.setCellValueFactory(new PropertyValueFactory<Person, Integer>("Age"));
|
personViewPhoneNoCol.setCellValueFactory(new PropertyValueFactory<Contact, PhoneNumber>("PhoneNo"));
|
||||||
personViewAgeCol.setText("AGE");
|
personViewPhoneNoCol.setText("PhoneNo");
|
||||||
personViewAgeCol.setSortable(false);
|
personViewPhoneNoCol.setSortable(false);
|
||||||
personView.getItems().setAll(persons.subList(0, itemsPerPage));
|
personView.getItems().setAll(contacts.subList(0, itemsPerPage));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getItemsPerPage() {
|
public int getItemsPerPage() {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class Contact {
|
|||||||
this.last_name = last_name;
|
this.last_name = last_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Contact(String first_name, String last_name, PhoneNumber phone_number, EmailAddress email_address,
|
public Contact(String first_name, String last_name, EmailAddress email_address, PhoneNumber phone_number,
|
||||||
Address mailing_address)
|
Address mailing_address)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
this.phone_number = phone_number;
|
this.phone_number = phone_number;
|
||||||
@@ -33,14 +33,8 @@ public class Contact {
|
|||||||
this.first_name = first_name;
|
this.first_name = first_name;
|
||||||
this.last_name = last_name;
|
this.last_name = last_name;
|
||||||
|
|
||||||
if (phone_number == null) {
|
if (this.first_name==null && (email_address.isBlank() || phone_number.isBlank())){
|
||||||
throw new IllegalArgumentException(String.format("%s %s", "Contact: requires phone number"));
|
throw new IllegalArgumentException(String.format("%s %s", "Contact: requires Phone Number or Email Address"));
|
||||||
}
|
|
||||||
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.phone_number = phone_number;
|
||||||
@@ -122,7 +116,7 @@ public class Contact {
|
|||||||
this.last_name = last_name;
|
this.last_name = last_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PhoneNumber getPhone_number() {
|
public PhoneNumber getPhoneNo() {
|
||||||
return phone_number;
|
return phone_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,11 +132,11 @@ public class Contact {
|
|||||||
this.mailing_address = mailing_address;
|
this.mailing_address = mailing_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmailAddress getEmail_address() {
|
public EmailAddress getEmail() {
|
||||||
return email_address;
|
return email_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEmail_address(EmailAddress email_address) {
|
public void setEmail(EmailAddress email_address) {
|
||||||
this.email_address = email_address;
|
this.email_address = email_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +182,7 @@ public class Contact {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void update(Contact ct) {
|
public void update(Contact ct) {
|
||||||
this.setEmail_address(ct.email_address);
|
this.setEmail(ct.email_address);
|
||||||
this.setPhone_number(ct.phone_number);
|
this.setPhone_number(ct.phone_number);
|
||||||
this.setMailing_address(ct.mailing_address);
|
this.setMailing_address(ct.mailing_address);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,5 +48,10 @@ public class EmailAddress{
|
|||||||
sb.append("}}");
|
sb.append("}}");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBlank() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'isBlank'");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,11 +46,20 @@ public class Factory {
|
|||||||
|
|
||||||
public static List<Contact> getAllContacts() {
|
public static List<Contact> getAllContacts() {
|
||||||
ArrayList<Contact> list = new ArrayList<>();
|
ArrayList<Contact> list = new ArrayList<>();
|
||||||
|
list.add(createContact(1, "Jose", "Cezone", "cezon50@yahoo.com", "410-456-9876"));
|
||||||
|
list.add(createContact(2,"Jack", "Bolt", "jbolt100@hotmail.com", "443-266-9776"));
|
||||||
|
list.add(createContact(3,"David", "Rossi", null, "210-356-9876"));
|
||||||
|
list.add(createContact(4, "Sheila", "Philster", null, "410-356-5876"));
|
||||||
|
list.add(createContact(5, "Adam", "Zhaine", null, "410-456-1876"));
|
||||||
|
list.add(createContact(6, "Amanda", "Kelstone", null, "410-456-2876"));
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Person createContact(String _name, int _age) {
|
static Contact createContact(Integer id, String first_name, String last_name, String email, String phone_number) {
|
||||||
return new Person(Integer.toString(id++),_name, _age);
|
Contact c = new Contact(first_name, last_name, new EmailAddress(email), new PhoneNumber(phone_number), (Address)null);
|
||||||
|
c.setId(id);
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ public class PhoneNumber {
|
|||||||
|
|
||||||
public PhoneNumber(String phone_number) {
|
public PhoneNumber(String phone_number) {
|
||||||
this.phone_number = phone_number;
|
this.phone_number = phone_number;
|
||||||
|
if( phone_number == null ){
|
||||||
|
phone_number = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getphone_number() {
|
public String getphone_number() {
|
||||||
@@ -42,10 +45,10 @@ public class PhoneNumber {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
return String.format("%s", phone_number);
|
||||||
sb.append("{ \"PhoneNumber\":{");
|
}
|
||||||
sb.append("\"phone\": \"" + phone_number + "\"");
|
|
||||||
sb.append("}}");
|
public boolean isBlank() {
|
||||||
return sb.toString();
|
return this.phone_number == null || this.phone_number.isBlank();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<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="personViewPhoneNoCol" maxWidth="5000.0" minWidth="10.0" prefWidth="93.0" resizable="true" text="Phone" />
|
||||||
</columns>
|
</columns>
|
||||||
</TableView>
|
</TableView>
|
||||||
<HBox layoutX="85.0" layoutY="308.0" prefHeight="64.0" prefWidth="377.0">
|
<HBox layoutX="85.0" layoutY="308.0" prefHeight="64.0" prefWidth="377.0">
|
||||||
|
|||||||
Reference in New Issue
Block a user