diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index c98f187845a..cc1354461e3 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -75,7 +75,7 @@ The **API** of this component is specified in [`Ui.java`](https://github.com/se- ![Structure of the UI Component](images/UiClassDiagram.png) -The UI consists of a `MainWindow` that is made up of parts e.g.`CommandBox`, `ResultDisplay`, `PersonListPanel`, `StatusBarFooter` etc. All these, including the `MainWindow`, inherit from the abstract `UiPart` class which captures the commonalities between classes that represent parts of the visible GUI. +The UI consists of a `MainWindow` that is made up of parts e.g.`CommandBox`, `ResultDisplay`, `PersonListPanel`, `LogListPanel`, `StatusBarFooter` etc. All these, including the `MainWindow`, inherit from the abstract `UiPart` class which captures the commonalities between classes that represent parts of the visible GUI. The `UI` component uses the JavaFx UI framework. The layout of these UI parts are defined in matching `.fxml` files that are in the `src/main/resources/view` folder. For example, the layout of the [`MainWindow`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/ui/MainWindow.java) is specified in [`MainWindow.fxml`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/resources/view/MainWindow.fxml) @@ -84,7 +84,7 @@ The `UI` component, * executes user commands using the `Logic` component. * listens for changes to `Model` data so that the UI can be updated with the modified data. * keeps a reference to the `Logic` component, because the `UI` relies on the `Logic` to execute commands. -* depends on some classes in the `Model` component, as it displays `Person` object residing in the `Model`. +* depends on some classes in the `Model` component, as it displays `Person` and `Log` objects that reside in the `Model`. ### Logic component diff --git a/docs/diagrams/UiClassDiagram.puml b/docs/diagrams/UiClassDiagram.puml index 36b53de9ce8..7c7a338d2e0 100644 --- a/docs/diagrams/UiClassDiagram.puml +++ b/docs/diagrams/UiClassDiagram.puml @@ -12,9 +12,12 @@ Class MainWindow Class HelpWindow Class ResultDisplay Class PersonListPanel -Class PersonCard Class StatusBarFooter Class CommandBox +Class LogListPanel +Class VolunteerCard +Class BefriendeeCard +Class LogCard } package Model <> { @@ -33,21 +36,29 @@ UiManager -down-> "1" MainWindow MainWindow *-down-> "1" CommandBox MainWindow *-down-> "1" ResultDisplay MainWindow *-down-> "2" PersonListPanel +MainWindow *-down-> "1" LogListPanel MainWindow *-down-> "1" StatusBarFooter MainWindow --> "0..1" HelpWindow -PersonListPanel -down-> "*" PersonCard +PersonListPanel -down-> "*" VolunteerCard +PersonListPanel -down-> "*" BefriendeeCard +LogListPanel -down-> "*" LogCard MainWindow -left-|> UiPart ResultDisplay --|> UiPart CommandBox --|> UiPart PersonListPanel --|> UiPart -PersonCard --|> UiPart +LogListPanel --|> UiPart +VolunteerCard --|> UiPart +BefriendeeCard --|> UiPart +LogCard --|> UiPart StatusBarFooter --|> UiPart HelpWindow --|> UiPart -PersonCard ..> Model +VolunteerCard -right..> Model +BefriendeeCard -right..> Model +LogCard -right..> Model UiManager -right-> Logic MainWindow -left-> Logic diff --git a/docs/images/UiClassDiagram.png b/docs/images/UiClassDiagram.png index 45832e4cfcb..11a8485c298 100644 Binary files a/docs/images/UiClassDiagram.png and b/docs/images/UiClassDiagram.png differ diff --git a/src/main/java/scrolls/elder/logic/commands/LogDeleteCommand.java b/src/main/java/scrolls/elder/logic/commands/LogDeleteCommand.java index f998ca1b40c..5159c89f7f8 100644 --- a/src/main/java/scrolls/elder/logic/commands/LogDeleteCommand.java +++ b/src/main/java/scrolls/elder/logic/commands/LogDeleteCommand.java @@ -75,8 +75,8 @@ public CommandResult execute(Model model) throws CommandException { int durationToDelete = logToDelete.getDuration(); // Update the timeServed of the volunteer and befriendee - Person volunteer = lastShownPList.get(logToDelete.getVolunteerId()); - Person befriendee = lastShownPList.get(logToDelete.getBefriendeeId()); + Person volunteer = personStore.getPersonFromID(logToDelete.getVolunteerId()); + Person befriendee = personStore.getPersonFromID(logToDelete.getBefriendeeId()); Optional latestLogIdBefriendee = getLatestLogId(befriendee, logToDelete, logStore, logToDelete.getLogId()); diff --git a/src/main/java/scrolls/elder/logic/commands/LogEditCommand.java b/src/main/java/scrolls/elder/logic/commands/LogEditCommand.java index d0556702a5a..07c90851281 100644 --- a/src/main/java/scrolls/elder/logic/commands/LogEditCommand.java +++ b/src/main/java/scrolls/elder/logic/commands/LogEditCommand.java @@ -109,7 +109,6 @@ public CommandResult execute(Model model) throws CommandException { LogStore store = model.getMutableDatastore().getMutableLogStore(); List lastShownList = store.getLogList(); - List lastShownPList = personStore.getPersonList(); if (index.getZeroBased() >= lastShownList.size()) { throw new CommandException(Messages.MESSAGE_INVALID_LOG_DISPLAYED_INDEX); @@ -128,8 +127,8 @@ public CommandResult execute(Model model) throws CommandException { int durationDiff = editedLog.getDuration() - logToEdit.getDuration(); - Person befriendee = lastShownPList.get(logToEdit.getBefriendeeId()); - Person volunteer = lastShownPList.get(logToEdit.getVolunteerId()); + Person befriendee = personStore.getPersonFromID(logToEdit.getBefriendeeId()); + Person volunteer = personStore.getPersonFromID(logToEdit.getVolunteerId()); Integer latestLogIdBefriendee = getLatestLogId(befriendee, editedLog, store, editedLog.getLogId()); Integer latestLogIdVolunteer = getLatestLogId(volunteer, editedLog, store, editedLog.getLogId()); diff --git a/src/main/java/scrolls/elder/model/LogStore.java b/src/main/java/scrolls/elder/model/LogStore.java index e48d43744f7..0f8e02b7c3a 100644 --- a/src/main/java/scrolls/elder/model/LogStore.java +++ b/src/main/java/scrolls/elder/model/LogStore.java @@ -50,7 +50,6 @@ public LogStore() { MapChangeListener listener = change -> { if (change.wasRemoved()) { logList.remove(change.getValueRemoved()); - System.out.println("removed"); deepRemoveId(normalisedLogsByPerson, change.getValueRemoved().getVolunteerId(), change.getValueRemoved().getLogId()); deepRemoveId(normalisedLogsByPerson, change.getValueRemoved().getBefriendeeId(), @@ -58,7 +57,6 @@ public LogStore() { } if (change.wasAdded()) { logList.add(change.getValueAdded()); - System.out.println("added"); deepAddId(normalisedLogsByPerson, change.getValueAdded().getVolunteerId(), change.getValueAdded().getLogId()); deepAddId(normalisedLogsByPerson, change.getValueAdded().getBefriendeeId(),