Skip to content

Commit

Permalink
Merge pull request #129 from CJerrong/updateDG-UI
Browse files Browse the repository at this point in the history
Update Ui Class Diagram in DG and fix bug in logEdit and logDelete
  • Loading branch information
CJerrong authored Apr 4, 2024
2 parents b62ebb5 + 7c3d327 commit 9acf452
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

Expand Down
19 changes: 15 additions & 4 deletions docs/diagrams/UiClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<Rectangle>> {
Expand All @@ -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

Expand Down
Binary file modified docs/images/UiClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer> latestLogIdBefriendee =
getLatestLogId(befriendee, logToDelete, logStore, logToDelete.getLogId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public CommandResult execute(Model model) throws CommandException {
LogStore store = model.getMutableDatastore().getMutableLogStore();

List<Log> lastShownList = store.getLogList();
List<Person> lastShownPList = personStore.getPersonList();

if (index.getZeroBased() >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_LOG_DISPLAYED_INDEX);
Expand All @@ -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());
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/scrolls/elder/model/LogStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,13 @@ public LogStore() {
MapChangeListener<? super Integer, ? super Log> 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(),
change.getValueRemoved().getLogId());
}
if (change.wasAdded()) {
logList.add(change.getValueAdded());
System.out.println("added");
deepAddId(normalisedLogsByPerson, change.getValueAdded().getVolunteerId(),
change.getValueAdded().getLogId());
deepAddId(normalisedLogsByPerson, change.getValueAdded().getBefriendeeId(),
Expand Down

0 comments on commit 9acf452

Please sign in to comment.