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

changed a bit some comments

parent 299fb72c
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ import java.util.regex.Pattern; ...@@ -12,7 +12,7 @@ import java.util.regex.Pattern;
public class HelloController { public class HelloController {
static ArrayList<Contact> contactArray = new ArrayList<>(); static ArrayList<Contact> contactArray = new ArrayList<>();
int selectedID = 0; int selectedID = 0; //Save the id of the selected item in the list view
boolean imported = false; //Used to know whenever we should enable or disable button save/edit boolean imported = false; //Used to know whenever we should enable or disable button save/edit
ObservableList<String> ctType = FXCollections.observableArrayList("Friend", "Family", "Professional"); ObservableList<String> ctType = FXCollections.observableArrayList("Friend", "Family", "Professional");
//Fx fields //Fx fields
...@@ -194,12 +194,13 @@ public class HelloController { ...@@ -194,12 +194,13 @@ public class HelloController {
txtEmail.setText(data.get(5)); txtEmail.setText(data.get(5));
txtSocial.setText(data.get(6)); txtSocial.setText(data.get(6));
txtJob.setText(data.get(7)); txtJob.setText(data.get(7));
//Family and professional have one more arguments
if(data.size() > 8){ if(data.size() > 8){
txtOther.setVisible(true); txtOther.setVisible(true);
lblOther.setVisible(true); lblOther.setVisible(true);
txtOther.setText(data.get(8)); txtOther.setText(data.get(8));
if(contactArray.get(LstCt.getSelectionModel().getSelectedIndex()) instanceof Family){ if(contactArray.get(LstCt.getSelectionModel().getSelectedIndex()) instanceof Family){
//contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).EditRelation(other);
lblOther.setVisible(true); lblOther.setVisible(true);
lblOther.setText("Relation"); lblOther.setText("Relation");
txtOther.setVisible(true); txtOther.setVisible(true);
...@@ -210,7 +211,7 @@ public class HelloController { ...@@ -210,7 +211,7 @@ public class HelloController {
txtOther.setVisible(true); txtOther.setVisible(true);
cbxType.setValue("Professional"); cbxType.setValue("Professional");
} }
} else { } else { //Reset when it comes back to friends
txtOther.setVisible(false); txtOther.setVisible(false);
lblOther.setVisible(false); lblOther.setVisible(false);
cbxType.setValue("Friend"); cbxType.setValue("Friend");
...@@ -288,18 +289,20 @@ public class HelloController { ...@@ -288,18 +289,20 @@ public class HelloController {
*/ */
@FXML @FXML
protected void ShowAll() { protected void ShowAll() {
int cpt = 0; int cpt_id = 0;
imported = false; imported = false;
btnEdit.setDisable(true); btnEdit.setDisable(true);
btnAdd.setDisable(true); btnAdd.setDisable(true);
for(Contact cont: contactArray){
cont.setId(cpt); for(Contact cont: contactArray){ //Give the correct id to the contact (based on their place in the list
cpt++; cont.setId(cpt_id);
cpt_id++;
} }
LstCt.getItems().clear(); LstCt.getItems().clear();
for(Contact c: contactArray){ for(Contact c: contactArray){
LstCt.getItems().add(c.toString()); LstCt.getItems().add(c.toString());
} }
txtFirst.setText(""); txtFirst.setText("");
txtLast.setText(""); txtLast.setText("");
txtAdd.setText(""); txtAdd.setText("");
...@@ -384,6 +387,7 @@ public class HelloController { ...@@ -384,6 +387,7 @@ public class HelloController {
} }
/** /**
* Import a Friend * Import a Friend
* @param str_array Friends informations
*/ */
public void ImportFriend(List<String> str_array){ public void ImportFriend(List<String> str_array){
Friend f = new Friend( Friend f = new Friend(
...@@ -400,6 +404,7 @@ public class HelloController { ...@@ -400,6 +404,7 @@ public class HelloController {
} }
/** /**
* Import a Family Member * Import a Family Member
* @param str_array Family member informations
*/ */
public void ImportFamily(List<String> str_array){ public void ImportFamily(List<String> str_array){
Family f = new Family( Family f = new Family(
...@@ -418,6 +423,7 @@ public class HelloController { ...@@ -418,6 +423,7 @@ public class HelloController {
/** /**
* Import a Professional * Import a Professional
* @param str_array Professional informations
*/ */
public void ImportProfessional(List<String> str_array){ public void ImportProfessional(List<String> str_array){
Professional f = new Professional( Professional f = new Professional(
...@@ -435,13 +441,14 @@ public class HelloController { ...@@ -435,13 +441,14 @@ public class HelloController {
} }
/** /**
* Add a contact (any type) to the list * Add a contact (any type) to the list
* @param str_array contact info
* @param checker checker to verify contact type
*/ */
public void AddContactToList(List<String> str_array, int checker){ public void AddContactToList(List<String> str_array, int checker){
switch (checker){ switch (checker){
case 1 -> ImportFriend(str_array); case 1 -> ImportFriend(str_array);
case 2 -> ImportFamily(str_array); case 2 -> ImportFamily(str_array);
case 3 -> ImportProfessional(str_array); case 3 -> ImportProfessional(str_array);
default -> System.out.println("Error contact type");
} }
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment