Skip to content
Snippets Groups Projects
Commit 299fb72c authored by vincent.steinman's avatar vincent.steinman
Browse files

edit relation/workplace

parent 222e2614
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ public class HelloController {
//Fx functions
/**
* Form start up. Hide and Disable unwanted component
* Form start up. Hide and Disable unwanted component
*/
@FXML
protected void initialize() {
......@@ -66,6 +66,7 @@ public class HelloController {
*/
@FXML
protected void AddCt() {
//enhanced switch, doesn't need break
switch (cbxType.getValue().toString()){ //Use the combo box value
case "Friend" -> AddPal();
case "Family" -> AddFam();
......@@ -240,21 +241,23 @@ public class HelloController {
List<String> social = SplitLine(txtSocial.getText(), " ");
String job = txtJob.getText();
String other = txtOther.getText();
int selected_id = LstCt.getSelectionModel().getSelectedIndex();
contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).setFirstName(firstName);
contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).setLastName(lastName);
contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).setAddr(address);
contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).setPhone(phone);
contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).setEmail(emails);
contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).setSocial(social);
contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).setJob(job);
if(contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).getType().equals("Family")){
// Family fam = (Family)contactArray.get(LstCt.getSelectionModel().getSelectedIndex());
// fam.editRelation(other);
// int tmp = LstCt.getSelectionModel().getSelectedIndex();
// contactArray.get(tmp) = fam;
contactArray.get(selected_id).setFirstName(firstName);
contactArray.get(selected_id).setLastName(lastName);
contactArray.get(selected_id).setAddr(address);
contactArray.get(selected_id).setPhone(phone);
contactArray.get(selected_id).setEmail(emails);
contactArray.get(selected_id).setSocial(social);
contactArray.get(selected_id).setJob(job);
if(contactArray.get(LstCt.getSelectionModel().getSelectedIndex()) instanceof Family){
Family fam = (Family)contactArray.get(selected_id);
fam.setRelation(other);
contactArray.set(selected_id, fam);
} else if(contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).getType().equals("Professional")){
Professional pro = (Professional)contactArray.get(selected_id);
pro.setWork(other);
contactArray.set(selected_id, pro);
}
ShowAll();
}
......@@ -366,7 +369,8 @@ public class HelloController {
List<String> emailList = Arrays.asList(emails.split("/"));
List<String> socialList = Arrays.asList(social.split("/"));
Professional pro = new Professional(first_name_list, lastName, address, phoneList, emailList, socialList, job, wp);
Professional pro = new Professional(first_name_list, lastName, address, phoneList,
emailList, socialList, job, wp);
Add(pro);
}
/**
......@@ -448,11 +452,4 @@ public class HelloController {
public List<String> SplitLine(String str, String splitter){
return Arrays.asList(str.split(splitter));
}
//TODO
/*
Unit Test,
edit relation/job?
*/
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment