From 7012aaf83865b31897f1ad11477afb09396da494 Mon Sep 17 00:00:00 2001 From: khooroko Date: Thu, 2 Nov 2017 13:59:28 +0800 Subject: [PATCH 1/5] Update author tags --- src/main/java/seedu/address/logic/LogicManager.java | 2 ++ src/main/java/seedu/address/model/ModelManager.java | 4 +++- src/main/java/seedu/address/model/person/Handphone.java | 1 + src/main/java/seedu/address/model/person/HomePhone.java | 1 + src/main/java/seedu/address/model/person/OfficePhone.java | 1 + src/main/java/seedu/address/ui/InfoPanel.java | 2 +- src/main/java/seedu/address/ui/MainWindow.java | 2 +- src/main/java/seedu/address/ui/UiManager.java | 1 + src/main/resources/view/InfoPanel.fxml | 3 +-- 9 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index c8304fff2013..208a093c7a99 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -48,6 +48,7 @@ public CommandResult execute(String commandText) throws CommandException, ParseE } } + //@@author khooroko /** * Updates the selected person. * @param person the person that has been selected. @@ -70,6 +71,7 @@ public ObservableList getAllPersons() { return model.getAllPersons(); } + //@@author @Override public ObservableList getFilteredPersonList() { return model.getFilteredPersonList(); diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index a598155297c8..cc2b6d923ad8 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -319,8 +319,8 @@ public ReadOnlyPerson deductDebtFromPerson(ReadOnlyPerson target, Debt amount) t indicateAddressBookChanged(); return repayingPerson; } - //@@author + //@@author @Override public void changeListTo(String listName) { raise(new ChangeInternalListEvent(listName)); @@ -409,6 +409,7 @@ public int updateFilteredWhitelistedPersonList(Predicate predica return filteredWhitelistedPersons.size(); } + //@@author khooroko /** * Obtains and updates the list of persons that share the same cluster as {@param selectedPerson}. */ @@ -452,6 +453,7 @@ public void sortBy(String order) throws IllegalArgumentException { indicateAddressBookChanged(); } + //@@author @Override public boolean equals(Object obj) { // short circuit if same object diff --git a/src/main/java/seedu/address/model/person/Handphone.java b/src/main/java/seedu/address/model/person/Handphone.java index 43de0e03fe38..028238553900 100644 --- a/src/main/java/seedu/address/model/person/Handphone.java +++ b/src/main/java/seedu/address/model/person/Handphone.java @@ -2,6 +2,7 @@ import seedu.address.commons.exceptions.IllegalValueException; +//@@author khooroko /** * Represents a Person's handphone number in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} diff --git a/src/main/java/seedu/address/model/person/HomePhone.java b/src/main/java/seedu/address/model/person/HomePhone.java index 199fb42a3298..f5d04ace4853 100644 --- a/src/main/java/seedu/address/model/person/HomePhone.java +++ b/src/main/java/seedu/address/model/person/HomePhone.java @@ -2,6 +2,7 @@ import seedu.address.commons.exceptions.IllegalValueException; +//@@author khooroko /** * Represents a Person's home number in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} diff --git a/src/main/java/seedu/address/model/person/OfficePhone.java b/src/main/java/seedu/address/model/person/OfficePhone.java index 19c373cd9b73..2f72b606db5c 100644 --- a/src/main/java/seedu/address/model/person/OfficePhone.java +++ b/src/main/java/seedu/address/model/person/OfficePhone.java @@ -2,6 +2,7 @@ import seedu.address.commons.exceptions.IllegalValueException; +//@@author khooroko /** * Represents a Person's office phone number in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} diff --git a/src/main/java/seedu/address/ui/InfoPanel.java b/src/main/java/seedu/address/ui/InfoPanel.java index 2ff06875f53d..b241f59e196c 100644 --- a/src/main/java/seedu/address/ui/InfoPanel.java +++ b/src/main/java/seedu/address/ui/InfoPanel.java @@ -167,8 +167,8 @@ private void resetDebtRepaymentProgressBar(ReadOnlyPerson person) { debtRepaymentProgressBar = new DebtRepaymentProgressBar(person); progressBarPlaceholder.getChildren().add(debtRepaymentProgressBar.getRoot()); } - //@@author + //@@author khooroko /** * Binds the individual UI elements to observe their respective {@code Person} properties * so that they will be notified of any changes. diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 6fbb66bd4e5a..8478fecfc631 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -167,8 +167,8 @@ void fillInnerPartsForStartUp() { commandBoxPlaceholder.getChildren().add(commandBox.getRoot()); }); } - //@@author + //@@author jaivigneshvenugopal /** * Fills up the placeholders of PersonListPanel with the given list name. * Should only display welcome page without contacts. diff --git a/src/main/java/seedu/address/ui/UiManager.java b/src/main/java/seedu/address/ui/UiManager.java index 59f4bef4d9a2..cdff28cf14b7 100644 --- a/src/main/java/seedu/address/ui/UiManager.java +++ b/src/main/java/seedu/address/ui/UiManager.java @@ -154,6 +154,7 @@ public void handleLogoutAppRequestEvent(LogoutAppRequestEvent event) { } } + //@@author jaivigneshvenugopal /** * Handles change internal list event. * Displays the list that user requested(e.g masterlist, blacklist etc) diff --git a/src/main/resources/view/InfoPanel.fxml b/src/main/resources/view/InfoPanel.fxml index 4e98e1c68b3a..1439975e2497 100644 --- a/src/main/resources/view/InfoPanel.fxml +++ b/src/main/resources/view/InfoPanel.fxml @@ -1,7 +1,5 @@ - - @@ -11,6 +9,7 @@ + From 78f4d204743f77f63246c83a910a94b90c2799af Mon Sep 17 00:00:00 2001 From: khooroko Date: Thu, 2 Nov 2017 14:01:42 +0800 Subject: [PATCH 2/5] weiping.adoc: update with more implementations --- docs/team/weiping.adoc | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/docs/team/weiping.adoc b/docs/team/weiping.adoc index 2f1f8ab6ac41..5dfac3e81f97 100644 --- a/docs/team/weiping.adoc +++ b/docs/team/weiping.adoc @@ -4,9 +4,13 @@ ifdef::env-github,env-browser[:outfilesuffix: .adoc] :stylesDir: ../stylesheets == Project: Codii -[https://github.com/CS2103AUG2017-T17-B1/main[Codii]] is a desktop address book application targeted at debt collectors. The user interacts with it using a CLI, and it has a GUI created with JavaFX. It is written in Java, and has about 6kLoC. +[https://github.com/CS2103AUG2017-T17-B1/main[Codii]] is a desktop address book application specially designed for debt collectors to manage debtors in a simple manner. It has a GUI but most of the user interactions happen using a CLI (Command Line Interface). -Codii is enhanced from [https://github.com/nus-cs2103-AY1718S1/addressbook-level4[AddressBook - Level 4]] which is a desktop address book application used for teaching Software Engineering principles. +Debt collectors can store information such as the amount owed, debt borrow date and debt cleared date in addition to debtor’s personal information. + +Unique features such as an interest calculator help debt collectors manage debts more efficiently. + +Codii is evolved from [https://github.com/nus-cs2103-AY1718S1/addressbook-level4[AddressBook - Level 4]] which is a desktop address book application used for teaching Software Engineering principles. *Code contributed*: [https://github.com/CS2103AUG2017-T17-B1/main/tree/master/collated/main/khooroko.md[Functional code]] [https://github.com/CS2103AUG2017-T17-B1/main/tree/master/collated/test/khooroko.md[Test code]] @@ -55,6 +59,27 @@ include::../UserGuide.adoc[tag=sort] Debt collectors would want to sort their contacts in various ways for easier viewing. +=== Enhancement Added: Cluster field + +==== External behaviour + +`Clusters` are generated based on postal districts. + +==== Justification + +An easy way to group contacts is needed for a debt collector to better plan his/her trips. + +==== Implementation + +--- +#Start of Extract [from: Developer Guide]# + +include::../DeveloperGuide.adoc[tag=cluster] + +#End of Extract# + +--- + === Enhancement Added: Nearby command ==== External behavior @@ -79,6 +104,10 @@ Debt collectors may want to see details of nearby contacts to plan a more effect * Replacing the browser with full information panel * Creating the nearby persons panel inside the full information panel +==== Miscellaneous +* Assist teammates with debugging tests + + == Project: Dog Mario [https://github.com/DogMario/Dog-Mario[Dog Mario]] is a game developed with [https://github.com/tbhbhbh[Tan Bing Hwang]] as an independent project for Orbital 2017. From 90707ac4cfa2efcd37d4bbe04a41806cd38299e0 Mon Sep 17 00:00:00 2001 From: khooroko Date: Thu, 2 Nov 2017 14:04:53 +0800 Subject: [PATCH 3/5] Update collated code --- collated/main/khooroko.md | 368 +++++++++++++++++++++++++++++++++++--- collated/test/khooroko.md | 252 +++++++++++++++++++++++--- 2 files changed, 565 insertions(+), 55 deletions(-) diff --git a/collated/main/khooroko.md b/collated/main/khooroko.md index ffec088ae701..9eb102053bfb 100644 --- a/collated/main/khooroko.md +++ b/collated/main/khooroko.md @@ -2,7 +2,7 @@ ###### \java\seedu\address\commons\events\ui\JumpToNearbyListRequestEvent.java ``` java /** - * Indicates a request to jump to the nearby list of persons + * Indicates a request to jump to the list of nearby persons */ public class JumpToNearbyListRequestEvent extends BaseEvent { @@ -19,6 +19,31 @@ public class JumpToNearbyListRequestEvent extends BaseEvent { } ``` +###### \java\seedu\address\commons\events\ui\NearbyPersonNotInCurrentListEvent.java +``` java +/** + * Represents a selection change in the Nearby Person List Panel to a person that is not in the current Person List + * Panel. + */ +public class NearbyPersonNotInCurrentListEvent extends BaseEvent { + + + private final PersonCard newSelection; + + public NearbyPersonNotInCurrentListEvent(PersonCard newSelection) { + this.newSelection = newSelection; + } + + @Override + public String toString() { + return this.getClass().getSimpleName(); + } + + public PersonCard getNewSelection() { + return newSelection; + } +} +``` ###### \java\seedu\address\commons\events\ui\NearbyPersonPanelSelectionChangedEvent.java ``` java /** @@ -26,6 +51,7 @@ public class JumpToNearbyListRequestEvent extends BaseEvent { */ public class NearbyPersonPanelSelectionChangedEvent extends BaseEvent { + private final PersonCard newSelection; public NearbyPersonPanelSelectionChangedEvent(PersonCard newSelection) { @@ -50,6 +76,7 @@ public class NearbyPersonPanelSelectionChangedEvent extends BaseEvent { public class NearbyCommand extends Command { public static final String COMMAND_WORD = "nearby"; + public static final String COMMAND_WORD_ALIAS = "n"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Selects the person identified by the index number used in the currently selected person's " @@ -80,7 +107,10 @@ public class NearbyCommand extends Command { model.updateSelectedPerson(nearbyList.get(targetIndex.getZeroBased())); EventsCenter.getInstance().post(new JumpToNearbyListRequestEvent(targetIndex)); - return new CommandResult(String.format(MESSAGE_NEARBY_PERSON_SUCCESS, targetIndex.getOneBased())); + + String currentList = listObserver.getCurrentListName(); + + return new CommandResult(currentList + String.format(MESSAGE_NEARBY_PERSON_SUCCESS, targetIndex.getOneBased())); } @@ -100,7 +130,7 @@ public class NearbyCommand extends Command { public class SortCommand extends UndoableCommand { public static final String COMMAND_WORD = "sort"; - public static final String MESSAGE_SUCCESS = "Address book has been sorted by %1$s!"; + public static final String MESSAGE_SUCCESS = "List has been sorted by %1$s!"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Sorts the addressbook by specified ordering in " + "intuitive order. If no ordering is specified, the addressbook is sorted by name.\n" + "Parameters: ORDERING (i.e. \"name\", \"debt\", \"deadline\" or \"cluster\")\n" @@ -125,7 +155,12 @@ public class SortCommand extends UndoableCommand { } catch (IllegalArgumentException ive) { throw new CommandException(ive.getMessage()); } - return new CommandResult(String.format(MESSAGE_SUCCESS, order)); + + listObserver.updateCurrentFilteredList(PREDICATE_SHOW_ALL_PERSONS); + + String currentList = listObserver.getCurrentListName(); + + return new CommandResult(currentList + String.format(MESSAGE_SUCCESS, order)); } @Override @@ -145,6 +180,31 @@ public class SortCommand extends UndoableCommand { return order.equals(s.order); } } +``` +###### \java\seedu\address\logic\LogicManager.java +``` java + /** + * Updates the selected person. + * @param person the person that has been selected. + */ + @Override + public void updateSelectedPerson(ReadOnlyPerson person) { + model.updateSelectedPerson(person); + } + + /** + * Resets the filteredPersonList to be a list of all persons. + */ + @Override + public void resetFilteredPersonList() { + model.updateFilteredPersonList(Model.PREDICATE_SHOW_ALL_PERSONS); + } + + @Override + public ObservableList getAllPersons() { + return model.getAllPersons(); + } + ``` ###### \java\seedu\address\logic\parser\NearbyCommandParser.java ``` java @@ -208,6 +268,52 @@ public class SortCommandParser implements Parser { } } } +``` +###### \java\seedu\address\model\ModelManager.java +``` java + /** + * Obtains and updates the list of persons that share the same cluster as {@param selectedPerson}. + */ + @Override + public void updateSelectedPerson(ReadOnlyPerson selectedPerson) { + this.selectedPerson = selectedPerson; + nearbyPersons = allPersons.stream().filter(person -> person.isSameCluster(selectedPerson)) + .collect(toCollection(FXCollections::observableArrayList)); + } + + /** + * Retrieves the full list of persons nearby a particular person. + */ + @Override + public ObservableList getNearbyPersons() { + return nearbyPersons; + } + + /** + * Retrieves the current selected person. + */ + @Override + public ReadOnlyPerson getSelectedPerson() { + return selectedPerson; + } + + /** + * Retrieves the full list of persons in addressbook. + */ + @Override + public ObservableList getAllPersons() { + return allPersons; + } + + /** + * Sorts the {@code internal list} in addressbook according to {@param order} + */ + @Override + public void sortBy(String order) throws IllegalArgumentException { + addressBook.sortBy(order); + indicateAddressBookChanged(); + } + ``` ###### \java\seedu\address\model\person\Cluster.java ``` java @@ -255,6 +361,48 @@ public class Cluster { return value.hashCode(); } +} +``` +###### \java\seedu\address\model\person\Handphone.java +``` java +/** + * Represents a Person's handphone number in the address book. + * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} + */ +public class Handphone extends Phone { + + public Handphone(String phone) throws IllegalValueException { + super(phone); + } + +} +``` +###### \java\seedu\address\model\person\HomePhone.java +``` java +/** + * Represents a Person's home number in the address book. + * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} + */ +public class HomePhone extends Phone { + + public HomePhone (String phone) throws IllegalValueException { + super(phone); + } + +} +``` +###### \java\seedu\address\model\person\OfficePhone.java +``` java +/** + * Represents a Person's office phone number in the address book. + * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} + */ +public class OfficePhone extends Phone { + + public OfficePhone (String phone) throws IllegalValueException { + super(phone); + } + } ``` ###### \java\seedu\address\model\person\Person.java @@ -614,30 +762,43 @@ public class InfoPanel extends UiPart { private static final String FXML = "InfoPanel.fxml"; private static final String MESSAGE_INFO_ADDRESS_FIELD = "Address: "; - private static final String MESSAGE_INFO_PHONE_FIELD = "HP: "; + private static final String MESSAGE_INFO_HANDPHONE_FIELD = "HP: "; + private static final String MESSAGE_INFO_HOME_PHONE_FIELD = "Home: "; + private static final String MESSAGE_INFO_OFFICE_PHONE_FIELD = "Office: "; private static final String MESSAGE_INFO_EMAIL_FIELD = "Email: "; private static final String MESSAGE_INFO_POSTAL_CODE_FIELD = "S"; private static final String MESSAGE_INFO_CLUSTER_FIELD = "General Location: "; - private static final String MESSAGE_INFO_DEBT_FIELD = "Debt: $"; + private static final String MESSAGE_INFO_DEBT_FIELD = "Current Debt: $"; + private static final String MESSAGE_INFO_TOTAL_DEBT_FIELD = "Total Debt: $"; private static final String MESSAGE_INFO_INTEREST_FIELD = "Interest: "; private static final String MESSAGE_INFO_DATE_BORROW_FIELD = "Date Borrowed: "; private static final String MESSAGE_INFO_DEADLINE_FIELD = "Deadline: "; private static final String MESSAGE_INFO_DATE_REPAID_FIELD = "Date Repaid: "; private static final String MESSAGE_INFO_NEARBY_PERSON_FIELD = "All contacts in this area: "; + private static final String MESSAGE_INFO_DEBT_REPAYMENT_FIELD = "Debt repayment progress: "; private Logic logic; private final Logger logger = LogsCenter.getLogger(this.getClass()); private NearbyPersonListPanel nearbyPersonListPanel; + private DebtRepaymentProgressBar debtRepaymentProgressBar; @FXML private Pane pane; @FXML private Label name; @FXML - private Text phoneField; + private Text handphoneField; @FXML - private Label phone; + private Label handphone; + @FXML + private Text homePhoneField; + @FXML + private Label homePhone; + @FXML + private Text officePhoneField; + @FXML + private Label officePhone; @FXML private Text addressField; @FXML @@ -659,6 +820,10 @@ public class InfoPanel extends UiPart { @FXML private Label debt; @FXML + private Text totalDebtField; + @FXML + private Label totalDebt; + @FXML private Text interestField; @FXML private Label interest; @@ -680,6 +845,10 @@ public class InfoPanel extends UiPart { private FlowPane tags; @FXML private StackPane nearbyPersonListPanelPlaceholder; + @FXML + private StackPane progressBarPlaceholder; + @FXML + private Text debtRepaymentField; public InfoPanel(Logic logic) { super(FXML); @@ -694,17 +863,21 @@ public class InfoPanel extends UiPart { * @param person the selected person to display the full info of. */ public void loadPersonInfo(ReadOnlyPerson person) { - phoneField.setText(MESSAGE_INFO_PHONE_FIELD); + handphoneField.setText(MESSAGE_INFO_HANDPHONE_FIELD); + homePhoneField.setText(MESSAGE_INFO_HOME_PHONE_FIELD); + officePhoneField.setText(MESSAGE_INFO_OFFICE_PHONE_FIELD); addressField.setText(MESSAGE_INFO_ADDRESS_FIELD); emailField.setText(MESSAGE_INFO_EMAIL_FIELD); postalCodeField.setText(MESSAGE_INFO_POSTAL_CODE_FIELD); clusterField.setText(MESSAGE_INFO_CLUSTER_FIELD); debtField.setText(MESSAGE_INFO_DEBT_FIELD); + totalDebtField.setText(MESSAGE_INFO_TOTAL_DEBT_FIELD); interestField.setText(MESSAGE_INFO_INTEREST_FIELD); dateBorrowField.setText(MESSAGE_INFO_DATE_BORROW_FIELD); deadlineField.setText(MESSAGE_INFO_DEADLINE_FIELD); dateRepaidField.setText(MESSAGE_INFO_DATE_REPAID_FIELD); nearbyPersonField.setText(MESSAGE_INFO_NEARBY_PERSON_FIELD); + debtRepaymentField.setText(MESSAGE_INFO_DEBT_REPAYMENT_FIELD); bindListeners(person); } @@ -714,21 +887,28 @@ public class InfoPanel extends UiPart { */ public void resetNearbyPersonListPanel(ReadOnlyPerson person) { nearbyPersonListPanel = new NearbyPersonListPanel(logic.getAllPersons(), person); + nearbyPersonListPanelPlaceholder.getChildren().clear(); nearbyPersonListPanelPlaceholder.getChildren().add(nearbyPersonListPanel.getRoot()); } +``` +###### \java\seedu\address\ui\InfoPanel.java +``` java /** * Binds the individual UI elements to observe their respective {@code Person} properties * so that they will be notified of any changes. */ private void bindListeners(ReadOnlyPerson person) { name.textProperty().bind(Bindings.convert(person.nameProperty())); - phone.textProperty().bind(Bindings.convert(person.phoneProperty())); + handphone.textProperty().bind(Bindings.convert(person.handphoneProperty())); + homePhone.textProperty().bind(Bindings.convert(person.homePhoneProperty())); + officePhone.textProperty().bind(Bindings.convert(person.officePhoneProperty())); address.textProperty().bind(Bindings.convert(person.addressProperty())); postalCode.textProperty().bind(Bindings.convert(person.postalCodeProperty())); cluster.textProperty().bind(Bindings.convert(person.clusterProperty())); email.textProperty().bind(Bindings.convert(person.emailProperty())); debt.textProperty().bind(Bindings.convert(person.debtProperty())); + totalDebt.textProperty().bind(Bindings.convert(person.totalDebtProperty())); interest.textProperty().bind(Bindings.convert(person.interestProperty())); dateBorrow.textProperty().bind(Bindings.convert(person.dateBorrowProperty())); deadline.textProperty().bind(Bindings.convert(person.deadlineProperty())); @@ -793,11 +973,14 @@ public class InfoPanel extends UiPart { InfoPanel infoPanel = (InfoPanel) other; return name.getText().equals(infoPanel.name.getText()) - && phone.getText().equals(infoPanel.phone.getText()) + && handphone.getText().equals(infoPanel.handphone.getText()) + && homePhone.getText().equals(infoPanel.homePhone.getText()) + && officePhone.getText().equals(infoPanel.officePhone.getText()) && address.getText().equals(infoPanel.address.getText()) && postalCode.getText().equals(infoPanel.postalCode.getText()) && cluster.getText().equals(infoPanel.cluster.getText()) && debt.getText().equals(infoPanel.debt.getText()) + && totalDebt.getText().equals(infoPanel.totalDebt.getText()) && interest.getText().equals(infoPanel.interest.getText()) && email.getText().equals(infoPanel.email.getText()) && deadline.getText().equals(infoPanel.deadline.getText()) @@ -821,14 +1004,31 @@ public class InfoPanel extends UiPart { loadPersonInfo(event.getNewSelection().person); logic.updateSelectedPerson(event.getNewSelection().person); resetNearbyPersonListPanel(event.getNewSelection().person); + resetDebtRepaymentProgressBar(event.getNewSelection().person); } @Subscribe - private void handleNearbyPersonPanelSelectionChangedEvent(NearbyPersonPanelSelectionChangedEvent event) { - logger.info(LogsCenter.getEventHandlingLogMessage(event)); - logic.updateSelectedPerson(event.getNewSelection().person); - loadPersonInfo(event.getNewSelection().person); + private void handleChangeInternalListEvent(ChangeInternalListEvent event) { + unregisterAsAnEventHandler(this); + } +} +``` +###### \java\seedu\address\ui\MainWindow.java +``` java + /** + * Sets the person panel to display the unfiltered masterlist and raises a {@code JumpToListRequestEvent}. + * @param event + */ + @Subscribe + private void handleNearbyPersonNotInCurrentListEvent(NearbyPersonNotInCurrentListEvent event) { + logger.info(LogsCenter.getEventHandlingLogMessage(event)); + logic.resetFilteredPersonList(); + personListPanel = new PersonListPanel(logic.getFilteredPersonList()); + personListPanelPlaceholder.getChildren().removeAll(); + personListPanelPlaceholder.getChildren().add(personListPanel.getRoot()); + raise(new JumpToListRequestEvent(Index.fromZeroBased(logic.getFilteredPersonList() + .indexOf(event.getNewSelection().person)))); } } ``` @@ -855,6 +1055,7 @@ public class NearbyPersonListPanel extends UiPart { .collect(toCollection(FXCollections::observableArrayList)); setConnections(nearbyList); registerAsAnEventHandler(this); + scrollTo(nearbyList.indexOf(currentPerson)); } private void setConnections(ObservableList personList) { @@ -868,8 +1069,8 @@ public class NearbyPersonListPanel extends UiPart { private void setEventHandlerForSelectionChangeEvent() { nearbyPersonListView.getSelectionModel().selectedItemProperty() .addListener((observable, oldValue, newValue) -> { - if (newValue != null) { - logger.fine("Selection in person list panel changed to : '" + newValue + "'"); + if (oldValue != null && newValue != null) { + logger.fine("Selection in nearby person list panel changed to : '" + newValue + "'"); raise(new NearbyPersonPanelSelectionChangedEvent(newValue)); } }); @@ -886,11 +1087,16 @@ public class NearbyPersonListPanel extends UiPart { } @Subscribe - private void handleJumpToNearbyListRequestEvent(JumpToNearbyListRequestEvent event) { + private void handleJumpToListRequestEvent(JumpToNearbyListRequestEvent event) { logger.info(LogsCenter.getEventHandlingLogMessage(event)); scrollTo(event.targetIndex); } + @Subscribe + private void handleChangeInternalListEvent(ChangeInternalListEvent event) { + unregisterAsAnEventHandler(this); + } + /** * Custom {@code ListCell} that displays the graphics of a {@code PersonCard}. */ @@ -910,80 +1116,190 @@ public class NearbyPersonListPanel extends UiPart { } } +``` +###### \java\seedu\address\ui\PersonListPanel.java +``` java + /** + * When there is a change in selection in nearby panel, scroll to the selected person in this person list panel, + * if it exists. If it does not exist, a {@code NearbyPersonNotInCurrentListEvent} is raised and this panel is + * unregistered as an event handler as it will be replaced by a new {@code PersonListPanel} in the + * {@code MainWindow}. + */ + @Subscribe + private void handleNearbyPersonPanelSelectionChangedEvent(NearbyPersonPanelSelectionChangedEvent event) { + logger.info(LogsCenter.getEventHandlingLogMessage(event)); + boolean currentListContainsPerson = false; + for (PersonCard pc : personListView.getItems()) { + if (pc.person.equals(event.getNewSelection().person)) { + scrollTo(personListView.getItems().indexOf(pc)); + currentListContainsPerson = true; + } + } + if (!currentListContainsPerson) { + raise(new NearbyPersonNotInCurrentListEvent(event.getNewSelection())); + unregisterAsAnEventHandler(this); + } + } + + @Subscribe + private void handleChangeInternalListEvent(ChangeInternalListEvent event) { + unregisterAsAnEventHandler(this); + } + +``` +###### \java\seedu\address\ui\UiPart.java +``` java + /** + * Unregisters the object as an event handler at the {@link EventsCenter} + * @param handler usually {@code this} + */ + protected void unregisterAsAnEventHandler(Object handler) { + EventsCenter.getInstance().unregisterHandler(handler); + } + ``` ###### \resources\view\InfoPanel.fxml ``` fxml + + + - diff --git a/collated/test/khooroko.md b/collated/test/khooroko.md index 164c7297a144..de58ad5b1e42 100644 --- a/collated/test/khooroko.md +++ b/collated/test/khooroko.md @@ -9,22 +9,28 @@ public class InfoPanelHandle extends NodeHandle { private static final String NAME_FIELD_ID = "#name"; private static final String ADDRESS_FIELD_ID = "#address"; - private static final String PHONE_FIELD_ID = "#phone"; + private static final String HANDPHONE_FIELD_ID = "#handphone"; + private static final String HOME_PHONE_FIELD_ID = "#homePhone"; + private static final String OFFICE_PHONE_FIELD_ID = "#officePhone"; private static final String EMAIL_FIELD_ID = "#email"; private static final String POSTAL_CODE_FIELD_ID = "#postalCode"; private static final String CLUSTER_FIELD_ID = "#cluster"; private static final String DEBT_FIELD_ID = "#debt"; + private static final String TOTAL_DEBT_FIELD_ID = "#totalDebt"; private static final String INTEREST_FIELD_ID = "#interest"; private static final String DATE_BORROW_FIELD_ID = "#dateBorrow"; private static final String DEADLINE_FIELD_ID = "#deadline"; private static final String DATE_REPAID_FIELD_ID = "#dateRepaid"; private static final String TAGS_FIELD_ID = "#tags"; private static final String ADDRESS_FIELD_FIELD_ID = "#addressField"; - private static final String PHONE_FIELD_FIELD_ID = "#phoneField"; + private static final String HANDPHONE_FIELD_FIELD_ID = "#handphoneField"; + private static final String HOME_PHONE_FIELD_FIELD_ID = "#homePhoneField"; + private static final String OFFICE_PHONE_FIELD_FIELD_ID = "#officePhoneField"; private static final String EMAIL_FIELD_FIELD_ID = "#emailField"; private static final String POSTAL_CODE_FIELD_FIELD_ID = "#postalCodeField"; private static final String CLUSTER_FIELD_FIELD_ID = "#clusterField"; private static final String DEBT_FIELD_FIELD_ID = "#debtField"; + private static final String TOTAL_DEBT_FIELD_FIELD_ID = "#totalDebtField"; private static final String INTEREST_FIELD_FIELD_ID = "#interestField"; private static final String DATE_BORROW_FIELD_FIELD_ID = "#dateBorrowField"; private static final String DEADLINE_FIELD_FIELD_ID = "#deadlineField"; @@ -32,22 +38,28 @@ public class InfoPanelHandle extends NodeHandle { private final Label nameLabel; private final Label addressLabel; - private final Label phoneLabel; + private final Label handphoneLabel; + private final Label homePhoneLabel; + private final Label officePhoneLabel; private final Label emailLabel; private final Label postalCodeLabel; private final Label clusterLabel; private final Label debtLabel; + private final Label totalDebtLabel; private final Label interestLabel; private final Label dateBorrowLabel; private final Label deadlineLabel; private final Label dateRepaidLabel; private final List