Skip to content

Commit

Permalink
Merge pull request #58 from random689/Update_1.2b
Browse files Browse the repository at this point in the history
Update GUI, UserGuide and bugfix
  • Loading branch information
g4ryy authored Oct 13, 2021
2 parents b1a203a + b1f205c commit 008aa6f
Show file tree
Hide file tree
Showing 20 changed files with 233 additions and 56 deletions.
11 changes: 6 additions & 5 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ NewAddressBook is a **desktop app built for secondary school teachers** handling

* **`list`** : Lists all contacts.

* **`student`**`student n/John Doe p/94629424 e/[email protected] a/George street, block 123, #01-01 f/3A2 g/M i/Math class em/92696977 m/Asthma` : Adds a student named `John Doe` to NewAddressBook.
* **`student`**`
student n/John Doe p/98765432 e/[email protected] g/M a/311, Clementi Ave 2, #02-25 f/3E1 em/999 i/Math class t/naughty ` : Adds a student named `John Doe` to NewAddressBook.

* **`delete`**`3` : Deletes the 3rd contact shown in the current list.

Expand Down Expand Up @@ -116,9 +117,8 @@ A teacher can have any number of tags (including 0), such as whether he/she is a
</div>

Examples:
* `teacher n/Gabe p/91234567 e/[email protected] i/Lunch buddy`
* `teacher n/Lebron p/91234567 e/[email protected] a/George street, block 123, #01-01 i/Math HOD
t/relief`
* `teacher n/Gabe p/91234567 e/[email protected] g/M o/151 i/Lunch buddy`
* `teacher n/Lebron p/91234567 e/[email protected] g/F o/12 i/Math HOD t/relief`

### Adding a medical history to a student: `medical`

Expand Down Expand Up @@ -285,9 +285,10 @@ _Details coming soon ..._
Action | Format, Examples
--------|------------------
**Student** | `student n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS f/FORM_CLASS g/GENDER i/INVOLVEMENT em/EMERGENCY_NUMBER [m/MEDICAL_HISTORY]…​ [t/TAG]…​` <br> e.g., `student n/James p/94629424 e/[email protected] a/George street, block 123, #01-01 f/3A2 g/M i/Math class em/92696977 m/asthma t/representative`
**Teacher** | `teacher n/Name p/PHONE_NUMBER e/EMAIL g/GENDER o/OFFICE_TABLE_NUMBER i/INVOLVEMENT [t/TAG]…​` <br> e.g., `teacher n/Gabe p/91234567 e/[email protected] g/M o/151 i/Lunch buddy`
**Clear** | `clear`
**Delete** | `delete INDEX`<br> e.g., `delete 3`
**Edit** | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [t/TAG]…​`<br> e.g.,`edit 2 n/James Lee e/[email protected]`
**Edit** | `edit<Teacher/Student> INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [t/TAG]…​`<br> e.g.,`editStudent 2 n/James Lee e/[email protected]`
**Find** | `find KEYWORD [MORE_KEYWORDS]`<br> e.g., `find James Jake`
**Copy** | `copy f/FIELD` <br> e.g., `copy f/email`
**List** | `list`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class AddStudentCommand extends Command {
+ PREFIX_EMAIL + "[email protected] "
+ PREFIX_GENDER + "M "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
+ PREFIX_FORM_CLASS + "3E1"
+ PREFIX_FORM_CLASS + "3E1 "
+ PREFIX_EMERGENCY_CONTACT + "999 "
+ PREFIX_INVOLVEMENT + "Math class "
+ PREFIX_TAG + "naughty ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class AddTeacherCommand extends Command {
+ PREFIX_PHONE + "98765432 "
+ PREFIX_EMAIL + "[email protected] "
+ PREFIX_GENDER + "M "
+ PREFIX_OFFICE_TABLE + "7"
+ PREFIX_OFFICE_TABLE + "7 "
+ PREFIX_INVOLVEMENT + "Math HOD "
+ PREFIX_TAG + "Colleague";

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/seedu/address/model/person/Involvement.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Involvement {
*/
public static final String VALIDATION_REGEX = "[^\\s].*";

public final String involvement;
public final String value;

/**
* Constructs a {@code Involvement}.
Expand All @@ -28,7 +28,7 @@ public class Involvement {
public Involvement(String i) {
requireNonNull(i);
checkArgument(isValidInvolvement(i), MESSAGE_CONSTRAINTS);
involvement = i;
value = i;
}

/**
Expand All @@ -40,18 +40,18 @@ public static boolean isValidInvolvement(String test) {

@Override
public String toString() {
return involvement;
return value;
}

@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof Involvement // instanceof handles nulls
&& involvement.equals(((Involvement) other).involvement)); // state check
&& value.equals(((Involvement) other).value)); // state check
}

@Override
public int hashCode() {
return involvement.hashCode();
return value.hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public InvolvementContainsKeywordsPredicate(List<String> keywords) {
@Override
public boolean test(Person person) {
return keywords.stream()
.anyMatch(keyword -> StringUtil.containsWordIgnoreCase(person.getInvolvement().involvement, keyword));
.anyMatch(keyword -> StringUtil.containsWordIgnoreCase(person.getInvolvement().value, keyword));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/person/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Student extends Person {
* @param emergencyContact Emergency contact of student
* @param formClass Form Class of Student
* @param tags Tags associated to student
* @param medicalHistory Medical History of student
* @param medicalHistory Medical History of student
*/
public Student(Name name, Phone phone, Email email, Gender gender, Involvement involvement, Address address,
Phone emergencyContact, FormClass formClass, Set<Tag> tags, MedicalHistory medicalHistory) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/model/person/Teacher.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public boolean equals(Object other) {
return false;
}

Teacher otherStudent = (Teacher) other;
return super.equals(otherStudent)
&& this.getOfficeTable().equals(otherStudent.getOfficeTable());
Teacher otherTeacher = (Teacher) other;
return super.equals(otherTeacher)
&& this.getOfficeTable().equals(otherTeacher.getOfficeTable());
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/storage/JsonAdaptedPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public JsonAdaptedPerson(Person source) {
phone = source.getPhone().value;
email = source.getEmail().value;
gender = source.getGender().value;
involvement = source.getInvolvement().involvement;
involvement = source.getInvolvement().value;
tagged.addAll(source.getTags().stream()
.map(JsonAdaptedTag::new)
.collect(Collectors.toList()));
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class MainWindow extends UiPart<Stage> {
private Logic logic;

// Independent Ui parts residing in this Ui container
private StudentListPanel studentListPanel;
private PersonListPanel personListPanel;
private ResultDisplay resultDisplay;
private HelpWindow helpWindow;

Expand All @@ -42,7 +42,7 @@ public class MainWindow extends UiPart<Stage> {
private MenuItem helpMenuItem;

@FXML
private StackPane personListPanelPlaceholder;
private StackPane studentListPanelPlaceholder;

@FXML
private StackPane resultDisplayPlaceholder;
Expand Down Expand Up @@ -110,8 +110,8 @@ private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) {
* Fills up all the placeholders of this window.
*/
void fillInnerParts() {
studentListPanel = new StudentListPanel(logic.getFilteredPersonList());
personListPanelPlaceholder.getChildren().add(studentListPanel.getRoot());
personListPanel = new PersonListPanel(logic.getFilteredPersonList());
studentListPanelPlaceholder.getChildren().add(personListPanel.getRoot());

resultDisplay = new ResultDisplay();
resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot());
Expand Down Expand Up @@ -163,8 +163,8 @@ private void handleExit() {
primaryStage.hide();
}

public StudentListPanel getPersonListPanel() {
return studentListPanel;
public PersonListPanel getPersonListPanel() {
return personListPanel;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,42 @@
import seedu.address.commons.core.LogsCenter;
import seedu.address.model.person.Person;
import seedu.address.model.person.Student;
import seedu.address.model.person.Teacher;

/**
* Panel containing the list of persons.
*/
public class StudentListPanel extends UiPart<Region> {
public class PersonListPanel extends UiPart<Region> {
private static final String FXML = "PersonListPanel.fxml";
private final Logger logger = LogsCenter.getLogger(StudentListPanel.class);
private final Logger logger = LogsCenter.getLogger(PersonListPanel.class);

@FXML
private ListView<Person> personListView;
private ListView<Person> studentListView;

/**
* Creates a {@code PersonListPanel} with the given {@code ObservableList}.
* Creates a {@code StudentListPanel} with the given {@code ObservableList}.
*/
public StudentListPanel(ObservableList<Person> personList) {
public PersonListPanel(ObservableList<Person> personList) {
super(FXML);
personListView.setItems(personList);
personListView.setCellFactory(listView -> new StudentListViewCell());
studentListView.setItems(personList);
studentListView.setCellFactory(listView -> new PersonListViewCell());
}

/**
* Custom {@code ListCell} that displays the graphics of a {@code Person} using a {@code PersonCard}.
*/
class StudentListViewCell extends ListCell<Person> {
class PersonListViewCell extends ListCell<Person> {
@Override
protected void updateItem(Person person, boolean empty) {
super.updateItem(person, empty);

if (empty || person == null) {
setGraphic(null);
setText(null);
} else {
} else if (person instanceof Student) {
setGraphic(new StudentCard((Student) person, getIndex() + 1).getRoot());
} else if (person instanceof Teacher) {
setGraphic(new TeacherCard((Teacher) person, getIndex() + 1).getRoot());
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/ui/StudentCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
public class StudentCard extends UiPart<Region> {

private static final String FXML = "PersonListCard.fxml";
private static final String FXML = "StudentListCard.fxml";

/**
* Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX.
Expand Down Expand Up @@ -52,7 +52,7 @@ public class StudentCard extends UiPart<Region> {
private Label medicalHistory;

/**
* Creates a {@code PersonCode} with the given {@code Person} and index to display.
* Creates a {@code StudentCode} with the given {@code Student} and index to display.
*/
public StudentCard(Student student, int displayedIndex) {
super(FXML);
Expand All @@ -65,7 +65,7 @@ public StudentCard(Student student, int displayedIndex) {
formClass.setText(student.getFormClass().value);
gender.setText(student.getGender().value);
medicalHistory.setText(student.getMedicalHistory().value);
involvement.setText(student.getInvolvement().involvement);
involvement.setText(student.getInvolvement().value);
emergencyContact.setText(student.getEmergencyContact().value);
student.getTags().stream()
.sorted(Comparator.comparing(tag -> tag.tagName))
Expand Down
83 changes: 83 additions & 0 deletions src/main/java/seedu/address/ui/TeacherCard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package seedu.address.ui;

import java.util.Comparator;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import seedu.address.model.person.Teacher;

/**
* An UI component that displays information of a {@code Teacher}.
*/
public class TeacherCard extends UiPart<Region> {

private static final String FXML = "TeacherListCard.fxml";

/**
* Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX.
* As a consequence, UI elements' variable names cannot be set to such keywords
* or an exception will be thrown by JavaFX during runtime.
*
* @see <a href="https://github.com/se-edu/addressbook-level4/issues/336">The issue on AddressBook level 4</a>
*/

public final Teacher teacher;

@FXML
private HBox cardPane;
@FXML
private Label name;
@FXML
private Label id;
@FXML
private Label phone;
@FXML
private Label email;
@FXML
private Label gender;
@FXML
private Label involvement;
@FXML
private Label officeTable;
@FXML
private FlowPane tags;

/**
* Creates a {@code TeacherCode} with the given {@code Teacher} and index to display.
*/
public TeacherCard(Teacher teacher, int displayedIndex) {
super(FXML);
this.teacher = teacher;
id.setText(displayedIndex + ". ");
name.setText(teacher.getName().fullName);
phone.setText(teacher.getPhone().value);
email.setText(teacher.getEmail().value);
gender.setText(teacher.getGender().value);
officeTable.setText(teacher.getOfficeTable().value);
involvement.setText(teacher.getInvolvement().value);
teacher.getTags().stream()
.sorted(Comparator.comparing(tag -> tag.tagName))
.forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
}

@Override
public boolean equals(Object other) {
// short circuit if same object
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof TeacherCard)) {
return false;
}

// state check
TeacherCard card = (TeacherCard) other;
return id.getText().equals(card.id.getText())
&& teacher.equals(card.teacher);
}
}
Loading

0 comments on commit 008aa6f

Please sign in to comment.