Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Ui: Show total persons in status bar #596

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ void fillInnerParts() {
ResultDisplay resultDisplay = new ResultDisplay();
resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot());

StatusBarFooter statusBarFooter = new StatusBarFooter(prefs.getAddressBookFilePath());
StatusBarFooter statusBarFooter = new StatusBarFooter(prefs.getAddressBookFilePath(),
logic.getFilteredPersonList().size());
statusbarPlaceholder.getChildren().add(statusBarFooter.getRoot());

CommandBox commandBox = new CommandBox(logic);
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/seedu/address/ui/StatusBarFooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ public class StatusBarFooter extends UiPart<Region> {
@FXML
private StatusBar syncStatus;
@FXML
private StatusBar totalPersons;
@FXML
private StatusBar saveLocationStatus;


public StatusBarFooter(String saveLocation) {
public StatusBarFooter(String saveLocation, int totalPersons) {
super(FXML);
setSyncStatus(SYNC_STATUS_INITIAL);
setSaveLocation("./" + saveLocation);
setTotalPersons(totalPersons);
registerAsAnEventHandler(this);
}

Expand All @@ -70,11 +72,16 @@ private void setSyncStatus(String status) {
this.syncStatus.setText(status);
}

private void setTotalPersons(int totalPersons) {
this.totalPersons.setText(totalPersons + " person(s) total");
}

@Subscribe
public void handleAddressBookChangedEvent(AddressBookChangedEvent abce) {
long now = clock.millis();
String lastUpdated = new Date(now).toString();
logger.info(LogsCenter.getEventHandlingLogMessage(abce, "Setting last updated status to " + lastUpdated));
setSyncStatus(String.format(SYNC_STATUS_UPDATED, lastUpdated));
setTotalPersons(abce.data.getPersonList().size());
}
}
3 changes: 2 additions & 1 deletion src/main/resources/view/StatusBarFooter.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
<ColumnConstraints hgrow="SOMETIMES" minWidth="10" prefWidth="100" />
</columnConstraints>
<StatusBar styleClass="anchor-pane" fx:id="syncStatus" />
<StatusBar styleClass="anchor-pane" fx:id="saveLocationStatus" GridPane.columnIndex="1" nodeOrientation="RIGHT_TO_LEFT" />
<StatusBar styleClass="anchor-pane" fx:id="totalPersons" GridPane.columnIndex="1" />
<StatusBar styleClass="anchor-pane" fx:id="saveLocationStatus" GridPane.columnIndex="2" nodeOrientation="RIGHT_TO_LEFT" />
</GridPane>