From 87fd64690c966214e67bd3e4d27382910f2669bf Mon Sep 17 00:00:00 2001 From: Chen Lei Yu <128605764+ChenLeiyu@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:01:49 +0800 Subject: [PATCH 1/7] Update command log to store user input --- .../java/seedu/address/logic/CommandLog.java | 28 ++++++++++++++++--- .../seedu/address/logic/commands/Command.java | 1 - src/main/java/seedu/address/model/Model.java | 13 ++++++++- .../seedu/address/model/ModelManager.java | 12 +++++++- 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/main/java/seedu/address/logic/CommandLog.java b/src/main/java/seedu/address/logic/CommandLog.java index adad4869faf..d9f7afbb0ba 100644 --- a/src/main/java/seedu/address/logic/CommandLog.java +++ b/src/main/java/seedu/address/logic/CommandLog.java @@ -5,20 +5,40 @@ import seedu.address.logic.commands.Command; /** - * Keeps track of Commands given by user + * Keeps track of Commands given by user using a stack */ public class CommandLog { private Stack log = new Stack<>(); + private Stack inputLog = new Stack<>(); + /** + * Adds a command to the stack + */ public void add(Command command) { log.push(command); } - public Command undo() { + /** + * Pops most recent command at the top of the stack + * @return null if stack is empty + */ + public Command getPreviousCommand() { return log.isEmpty() ? null : log.pop(); } - public boolean hasLog() { - return !log.isEmpty(); + /** + * Adds a user input to the stack + */ + public void addinput(String input) { + inputLog.push(input); } + + /** + * Returns most recent user input at the top of the stack + * @return empty string if stack is empty + */ + public String getPreviousInput() { + return inputLog.isEmpty() ? "" : inputLog.pop(); + } + } diff --git a/src/main/java/seedu/address/logic/commands/Command.java b/src/main/java/seedu/address/logic/commands/Command.java index 529f93dabbc..021f77ae391 100644 --- a/src/main/java/seedu/address/logic/commands/Command.java +++ b/src/main/java/seedu/address/logic/commands/Command.java @@ -21,5 +21,4 @@ public abstract class Command { * Undoes the command. */ public abstract void undo(Model model); - } diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index 66eea9a0ba2..4b362e97031 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -107,7 +107,18 @@ public interface Model { void addCommandToLog(Command command); /** - * Returns most recent {@code Command} in {@code CommandLog}. + * Returns and removes most recent {@code Command} in {@code CommandLog}. */ Command getPreviousCommand(); + + /** + * Adds the user input string to {@code CommandLog}. + */ + void addInputToLog(String input); + + /** + * Returns and removes most recent user input string in {@code CommandLog}. + * @return + */ + String getPreviousInput(); } diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index d65783c92ed..52f7b049308 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -177,7 +177,17 @@ public void addCommandToLog(Command command) { @Override public Command getPreviousCommand() { - return commandLog.undo(); + return commandLog.getPreviousCommand(); + } + + @Override + public void addInputToLog(String input) { + commandLog.addinput(input); + } + + @Override + public String getPreviousInput() { + return commandLog.getPreviousInput(); } } From 948f0a80cd26a9938b05107c2b20c6b9ec902fdf Mon Sep 17 00:00:00 2001 From: Chen Lei Yu <128605764+ChenLeiyu@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:24:11 +0800 Subject: [PATCH 2/7] Add undo message displaying command undone --- .../java/seedu/address/logic/LogicManager.java | 4 ++++ .../seedu/address/logic/commands/AddCommand.java | 10 +++++++++- .../address/logic/commands/AddGameCommand.java | 10 +++++++++- .../address/logic/commands/ClearCommand.java | 10 +++++++++- .../seedu/address/logic/commands/Command.java | 5 +++++ .../address/logic/commands/DeleteCommand.java | 10 +++++++++- .../logic/commands/DeleteGameCommand.java | 9 ++++++++- .../address/logic/commands/EditCommand.java | 10 +++++++++- .../address/logic/commands/EditGameCommand.java | 10 +++++++++- .../address/logic/commands/ExitCommand.java | 8 ++++++++ .../logic/commands/FavouriteGameCommand.java | 10 +++++++++- .../address/logic/commands/FindCommand.java | 10 +++++++++- .../address/logic/commands/FindTimeCommand.java | 10 +++++++++- .../address/logic/commands/HelpCommand.java | 9 +++++++++ .../address/logic/commands/ListCommand.java | 10 +++++++++- .../address/logic/commands/LoadCommand.java | 11 +++++++++++ .../address/logic/commands/SaveCommand.java | 11 +++++++++++ .../address/logic/commands/UndoCommand.java | 14 ++++++++++++-- .../logic/commands/UnfavouriteGameCommand.java | 10 +++++++++- .../java/seedu/address/model/ModelManager.java | 1 - .../address/logic/commands/AddCommandTest.java | 16 +++++++++++++++- 21 files changed, 182 insertions(+), 16 deletions(-) diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index bb01951a735..732a45c94a7 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -50,6 +50,10 @@ public CommandResult execute(String commandText) throws CommandException, ParseE CommandResult commandResult; Command command = addressBookParser.parseCommand(commandText); commandResult = command.execute(model); + if (command.canBeUndone()) { + model.addInputToLog(commandText); + } + if (commandResult.isLoad()) { try { Optional loadedAddressBookOpt = storage.loadAddressBookManually(); diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 75c0818a551..fc11154d8d8 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -46,6 +46,7 @@ public class AddCommand extends Command { public static final String MESSAGE_SUCCESS = "New person added: %1$s"; public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book"; + private static final boolean IS_UNDOABLE = true; private final Person toAdd; private Predicate previousPredicate; @@ -68,7 +69,9 @@ public CommandResult execute(Model model) throws CommandException { previousPredicate = model.getCurrentPredicate(); model.addPerson(toAdd); - model.addCommandToLog(this); + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(toAdd))); } @@ -82,6 +85,11 @@ public void undo(Model model) { model.updateFilteredPersonList(previousPredicate); } + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } + @Override public boolean equals(Object other) { if (other == this) { diff --git a/src/main/java/seedu/address/logic/commands/AddGameCommand.java b/src/main/java/seedu/address/logic/commands/AddGameCommand.java index 554e87a299e..3fd0a5218e3 100644 --- a/src/main/java/seedu/address/logic/commands/AddGameCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddGameCommand.java @@ -44,6 +44,7 @@ public class AddGameCommand extends Command { public static final String MESSAGE_ADD_GAME_SUCCESS = "Added Game to Person: %1$s"; public static final String MESSAGE_GAME_EXISTS = "The game provided already exists for that person."; + private static final boolean IS_UNDOABLE = true; private final Index index; private final GameDescriptor addGameDescriptor; @@ -85,7 +86,9 @@ public CommandResult execute(Model model) throws CommandException { Game editedGame = createNewGame(gameName, addGameDescriptor); gameMap.put(gameName, editedGame); model.setPerson(personToEdit, personToEdit); - model.addCommandToLog(this); + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult(String.format(MESSAGE_ADD_GAME_SUCCESS, Messages.format(editedGame))); } @@ -99,6 +102,11 @@ public void undo(Model model) { model.setPerson(personToEdit, personToEdit); } + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } + /** * Creates and returns a {@code Game} with the details of {@code addGameDescriptor} */ diff --git a/src/main/java/seedu/address/logic/commands/ClearCommand.java b/src/main/java/seedu/address/logic/commands/ClearCommand.java index b4aea30098b..dfbb97a3ac0 100644 --- a/src/main/java/seedu/address/logic/commands/ClearCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClearCommand.java @@ -13,6 +13,7 @@ public class ClearCommand extends Command { public static final String COMMAND_WORD = "clear"; public static final String MESSAGE_SUCCESS = "Address book has been cleared!"; + private static final boolean IS_UNDOABLE = true; private ReadOnlyAddressBook previousAddressBook; @@ -22,7 +23,9 @@ public CommandResult execute(Model model) { requireNonNull(model); previousAddressBook = new AddressBook(model.getAddressBook()); model.setAddressBook(new AddressBook()); - model.addCommandToLog(this); + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult(MESSAGE_SUCCESS); } @@ -30,4 +33,9 @@ public CommandResult execute(Model model) { public void undo(Model model) { model.setAddressBook(previousAddressBook); } + + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } } diff --git a/src/main/java/seedu/address/logic/commands/Command.java b/src/main/java/seedu/address/logic/commands/Command.java index 021f77ae391..3b89b0df340 100644 --- a/src/main/java/seedu/address/logic/commands/Command.java +++ b/src/main/java/seedu/address/logic/commands/Command.java @@ -21,4 +21,9 @@ public abstract class Command { * Undoes the command. */ public abstract void undo(Model model); + + /** + * Returns whether the command can be undone. + */ + public abstract boolean canBeUndone(); } diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index ecc2bffe85a..58be3a664d4 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -24,6 +24,7 @@ public class DeleteCommand extends Command { + "Example: " + COMMAND_WORD + " 1"; public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s"; + private static final boolean IS_UNDOABLE = true; private final Index targetIndex; @@ -48,7 +49,9 @@ public CommandResult execute(Model model) throws CommandException { model.getAddressBookIndex(targetIndex.getZeroBased())); model.deletePerson(personToDelete); deletedPerson = personToDelete; - model.addCommandToLog(this); + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete))); } @@ -60,6 +63,11 @@ public void undo(Model model) { model.insertPerson(deletedPerson, deletedPersonIndex.getZeroBased()); } + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } + @Override public boolean equals(Object other) { if (other == this) { diff --git a/src/main/java/seedu/address/logic/commands/DeleteGameCommand.java b/src/main/java/seedu/address/logic/commands/DeleteGameCommand.java index a7c71b3169d..c26b425f43c 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteGameCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteGameCommand.java @@ -31,6 +31,7 @@ public class DeleteGameCommand extends Command { public static final String MESSAGE_DELETE_GAME_SUCCESS = "Deleted Game from Person: %1$s"; public static final String MESSAGE_NOT_DELETED = "The game provided does not exist for that person."; + private static final boolean IS_UNDOABLE = true; private final Index index; private final String gameName; @@ -69,7 +70,9 @@ public CommandResult execute(Model model) throws CommandException { deletedGame = gameMap.remove(gameName); model.setPerson(personToEdit, personToEdit); - model.addCommandToLog(this); + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult(String.format(MESSAGE_DELETE_GAME_SUCCESS, Messages.format(deletedGame))); } @@ -83,6 +86,10 @@ public void undo(Model model) { model.setPerson(personToEdit, personToEdit); } + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } @Override public boolean equals(Object other) { diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index b31e6fcb1ed..d00de05cc58 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -59,6 +59,7 @@ public class EditCommand extends Command { public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Person: %1$s"; public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book."; + private static final boolean IS_UNDOABLE = true; private final Index index; private final EditPersonDescriptor editPersonDescriptor; @@ -95,7 +96,9 @@ public CommandResult execute(Model model) throws CommandException { model.setPerson(personToEdit, editedPerson); model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); - model.addCommandToLog(this); + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson))); } @@ -107,6 +110,11 @@ public void undo(Model model) { model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); } + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } + /** * Creates and returns a {@code Person} with the details of {@code personToEdit} * edited with {@code editPersonDescriptor}. diff --git a/src/main/java/seedu/address/logic/commands/EditGameCommand.java b/src/main/java/seedu/address/logic/commands/EditGameCommand.java index c6de5e9f636..821c98ab826 100644 --- a/src/main/java/seedu/address/logic/commands/EditGameCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditGameCommand.java @@ -44,6 +44,7 @@ public class EditGameCommand extends Command { public static final String MESSAGE_EDIT_GAME_SUCCESS = "Edited Game: %1$s"; public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; + private static final boolean IS_UNDOABLE = true; private final Index index; private final String gameName; @@ -86,7 +87,9 @@ public CommandResult execute(Model model) throws CommandException { Game editedGame = createEditedGame(gameToEdit, editGameDescriptor); gameMap.put(gameName, editedGame); model.setPerson(personToEdit, personToEdit); - model.addCommandToLog(this); + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult(String.format(MESSAGE_EDIT_GAME_SUCCESS, Messages.format(editedGame))); } @@ -98,6 +101,11 @@ public void undo(Model model) { model.setPerson(personToEdit, personToEdit); } + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } + /** * Creates and returns a {@code Game} with the details of {@code gameToEdit} * edited with {@code editGameDescriptor}. diff --git a/src/main/java/seedu/address/logic/commands/ExitCommand.java b/src/main/java/seedu/address/logic/commands/ExitCommand.java index 981bf332e21..3aaf2763df1 100644 --- a/src/main/java/seedu/address/logic/commands/ExitCommand.java +++ b/src/main/java/seedu/address/logic/commands/ExitCommand.java @@ -10,9 +10,13 @@ public class ExitCommand extends Command { public static final String COMMAND_WORD = "exit"; public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting Address Book as requested ..."; + private static final boolean IS_UNDOABLE = false; @Override public CommandResult execute(Model model) { + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true, false, false); } @@ -21,4 +25,8 @@ public void undo(Model model) { } + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } } diff --git a/src/main/java/seedu/address/logic/commands/FavouriteGameCommand.java b/src/main/java/seedu/address/logic/commands/FavouriteGameCommand.java index e440e9a21f5..ede35fc32e1 100644 --- a/src/main/java/seedu/address/logic/commands/FavouriteGameCommand.java +++ b/src/main/java/seedu/address/logic/commands/FavouriteGameCommand.java @@ -30,6 +30,7 @@ public class FavouriteGameCommand extends Command { public static final String MESSAGE_FAVOURITE_GAME_SUCCESS = "Favourited Game: %1$s"; public static final String MESSAGE_GAME_NOT_SPECIFIED = "Please specify a game!"; public static final String MESSAGE_GAME_NOT_FOUND = "Game not found!"; + private static final boolean IS_UNDOABLE = true; private Index index; private String gameName; @@ -66,7 +67,9 @@ public CommandResult execute(Model model) throws CommandException { prevGameIsFavourite = targetGame.getFavouriteStatus(); targetGame.setAsFavourite(); model.setPerson(targetPerson, targetPerson); - model.addCommandToLog(this); + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult(String.format(MESSAGE_FAVOURITE_GAME_SUCCESS, gameName)); } @@ -90,6 +93,11 @@ public void undo(Model model) { model.setPerson(targetPerson, targetPerson); } + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } + @Override public boolean equals(Object other) { if (other == this) { diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index ec185ec6f9f..6807236d85d 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -22,6 +22,7 @@ public class FindCommand extends Command { + "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n" + "Parameters: KEYWORD [MORE_KEYWORDS]...\n" + "Example: " + COMMAND_WORD + " alice bob charlie"; + private static final boolean IS_UNDOABLE = true; private final NameContainsKeywordsPredicate predicate; private Predicate previousPredicate; @@ -35,7 +36,9 @@ public CommandResult execute(Model model) { requireNonNull(model); previousPredicate = model.getCurrentPredicate(); model.updateFilteredPersonList(predicate); - model.addCommandToLog(this); + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult( String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredPersonList().size())); } @@ -46,6 +49,11 @@ public void undo(Model model) { model.updateFilteredPersonList(previousPredicate); } + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } + @Override public boolean equals(Object other) { if (other == this) { diff --git a/src/main/java/seedu/address/logic/commands/FindTimeCommand.java b/src/main/java/seedu/address/logic/commands/FindTimeCommand.java index b58528bf72c..d847bc42e4a 100644 --- a/src/main/java/seedu/address/logic/commands/FindTimeCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindTimeCommand.java @@ -24,6 +24,7 @@ public class FindTimeCommand extends Command { + "Tips: RANGE has format HHmm, same ending time as starting time is allowed.\n" + "Parameters: RANGE [MORE_RANGES]...\n" + "Example: " + COMMAND_WORD + " 1100-1230 2130-2245"; + private static final boolean IS_UNDOABLE = true; private final PreferredTimeOverlapsRangesPredicate predicate; private Predicate previousPredicate; @@ -37,7 +38,9 @@ public CommandResult execute(Model model) { requireNonNull(model); previousPredicate = model.getCurrentPredicate(); model.updateFilteredPersonList(predicate); - model.addCommandToLog(this); + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult( String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredPersonList().size())); } @@ -48,6 +51,11 @@ public void undo(Model model) { model.updateFilteredPersonList(previousPredicate); } + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } + @Override public boolean equals(Object other) { if (other == this) { diff --git a/src/main/java/seedu/address/logic/commands/HelpCommand.java b/src/main/java/seedu/address/logic/commands/HelpCommand.java index 139f70dba28..416dded83c8 100644 --- a/src/main/java/seedu/address/logic/commands/HelpCommand.java +++ b/src/main/java/seedu/address/logic/commands/HelpCommand.java @@ -13,9 +13,13 @@ public class HelpCommand extends Command { + "Example: " + COMMAND_WORD; public static final String SHOWING_HELP_MESSAGE = "Opened help window."; + private static final boolean IS_UNDOABLE = false; @Override public CommandResult execute(Model model) { + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult(SHOWING_HELP_MESSAGE, true, false, false, false); } @@ -23,4 +27,9 @@ public CommandResult execute(Model model) { public void undo(Model model) { } + + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } } diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index be8cdc5d591..b075b5733f2 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -16,6 +16,7 @@ public class ListCommand extends Command { public static final String COMMAND_WORD = "list"; public static final String MESSAGE_SUCCESS = "Listed all persons"; + private static final boolean IS_UNDOABLE = true; private Predicate previousPredicate; @@ -24,7 +25,9 @@ public CommandResult execute(Model model) { requireNonNull(model); previousPredicate = model.getCurrentPredicate(); model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); - model.addCommandToLog(this); + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult(MESSAGE_SUCCESS); } @@ -33,4 +36,9 @@ public void undo(Model model) { requireNonNull(model); model.updateFilteredPersonList(previousPredicate); } + + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } } diff --git a/src/main/java/seedu/address/logic/commands/LoadCommand.java b/src/main/java/seedu/address/logic/commands/LoadCommand.java index ed9d3a953f5..8ff7ecffa48 100644 --- a/src/main/java/seedu/address/logic/commands/LoadCommand.java +++ b/src/main/java/seedu/address/logic/commands/LoadCommand.java @@ -8,7 +8,13 @@ public class LoadCommand extends Command { public static final String COMMAND_WORD = "load"; public static final String MESSAGE_SUCCESS = "The saved address book has been loaded!"; + private static final boolean IS_UNDOABLE = false; + + @Override public CommandResult execute(Model model) throws CommandException { + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult(MESSAGE_SUCCESS, false, false, false, true); } @@ -16,4 +22,9 @@ public CommandResult execute(Model model) throws CommandException { public void undo(Model model) { } + + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } } diff --git a/src/main/java/seedu/address/logic/commands/SaveCommand.java b/src/main/java/seedu/address/logic/commands/SaveCommand.java index 60febbe2698..80b3fa87e87 100644 --- a/src/main/java/seedu/address/logic/commands/SaveCommand.java +++ b/src/main/java/seedu/address/logic/commands/SaveCommand.java @@ -9,7 +9,13 @@ public class SaveCommand extends Command { public static final String COMMAND_WORD = "save"; public static final String MESSAGE_SUCCESS = "Address book has been saved!"; + private static final boolean IS_UNDOABLE = false; + + @Override public CommandResult execute(Model model) throws CommandException { + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult(MESSAGE_SUCCESS, false, false, true, false); } @@ -17,4 +23,9 @@ public CommandResult execute(Model model) throws CommandException { public void undo(Model model) { } + + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } } diff --git a/src/main/java/seedu/address/logic/commands/UndoCommand.java b/src/main/java/seedu/address/logic/commands/UndoCommand.java index 8e326c47e34..fc234548dbd 100644 --- a/src/main/java/seedu/address/logic/commands/UndoCommand.java +++ b/src/main/java/seedu/address/logic/commands/UndoCommand.java @@ -13,8 +13,10 @@ public class UndoCommand extends Command { public static final String MESSAGE_USAGE = COMMAND_WORD + ": Undoes previous user command.\n" + "Example: " + COMMAND_WORD; - public static final String MESSAGE_SUCCESS = "Undid previous command."; + //public static final String MESSAGE_SUCCESS = "Undid previous command."; + public static final String MESSAGE_SUCCESS = "Undid previous command: %1$s"; public static final String MESSAGE_INVALID_PREVIOUS_COMMAND = "No Command found to undo"; + private static final boolean IS_UNDOABLE = false; @Override public CommandResult execute(Model model) throws CommandException { @@ -23,11 +25,19 @@ public CommandResult execute(Model model) throws CommandException { throw new CommandException(MESSAGE_INVALID_PREVIOUS_COMMAND); } previousCommand.undo(model); - return new CommandResult(MESSAGE_SUCCESS); + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } + return new CommandResult(String.format(MESSAGE_SUCCESS, model.getPreviousInput())); } @Override public void undo(Model model) { } + + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } } diff --git a/src/main/java/seedu/address/logic/commands/UnfavouriteGameCommand.java b/src/main/java/seedu/address/logic/commands/UnfavouriteGameCommand.java index f5baa5859c0..1ece786c28a 100644 --- a/src/main/java/seedu/address/logic/commands/UnfavouriteGameCommand.java +++ b/src/main/java/seedu/address/logic/commands/UnfavouriteGameCommand.java @@ -31,6 +31,7 @@ public class UnfavouriteGameCommand extends Command { public static final String MESSAGE_UNFAVOURITE_GAME_SUCCESS = "Un-favourited Game: %1$s"; public static final String MESSAGE_GAME_NOT_SPECIFIED = "Please specify a game!"; public static final String MESSAGE_GAME_NOT_FOUND = "Game not found!"; + private static final boolean IS_UNDOABLE = true; private Index index; private String gameName; @@ -67,7 +68,9 @@ public CommandResult execute(Model model) throws CommandException { prevGameIsFavourite = targetGame.getFavouriteStatus(); targetGame.removeFavourite(); model.setPerson(targetPerson, targetPerson); - model.addCommandToLog(this); + if (IS_UNDOABLE) { + model.addCommandToLog(this); + } return new CommandResult(String.format(MESSAGE_UNFAVOURITE_GAME_SUCCESS, gameName)); } @@ -91,6 +94,11 @@ public void undo(Model model) { model.setPerson(targetPerson, targetPerson); } + @Override + public boolean canBeUndone() { + return IS_UNDOABLE; + } + @Override public boolean equals(Object other) { if (other == this) { diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 52f7b049308..cf7ee155741 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -189,5 +189,4 @@ public void addInputToLog(String input) { public String getPreviousInput() { return commandLog.getPreviousInput(); } - } diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index 8dd7722ab75..6227d15a01c 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -182,6 +182,16 @@ public void addCommandToLog(Command command) { public Command getPreviousCommand() { throw new AssertionError("This method should not be called."); } + + @Override + public void addInputToLog(String input) { + throw new AssertionError("This method should not be called."); + } + + @Override + public String getPreviousInput() { + throw new AssertionError("This method should not be called."); + } } /** @@ -234,6 +244,10 @@ public Predicate getCurrentPredicate() { public ReadOnlyAddressBook getAddressBook() { return new AddressBook(); } - } + @Override + public void addInputToLog(String input) { + + } + } } From 6b4b93c3c5d75e1707fcd2b7c32f00ce55d9b109 Mon Sep 17 00:00:00 2001 From: Chen Lei Yu <128605764+ChenLeiyu@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:38:24 +0800 Subject: [PATCH 3/7] Refactor redundant code for undoing --- src/main/java/seedu/address/logic/LogicManager.java | 1 + src/main/java/seedu/address/logic/commands/AddCommand.java | 3 --- src/main/java/seedu/address/logic/commands/AddGameCommand.java | 3 --- src/main/java/seedu/address/logic/commands/ClearCommand.java | 3 --- src/main/java/seedu/address/logic/commands/DeleteCommand.java | 3 --- .../java/seedu/address/logic/commands/DeleteGameCommand.java | 3 --- src/main/java/seedu/address/logic/commands/EditCommand.java | 3 --- .../java/seedu/address/logic/commands/EditGameCommand.java | 3 --- src/main/java/seedu/address/logic/commands/ExitCommand.java | 3 --- .../seedu/address/logic/commands/FavouriteGameCommand.java | 3 --- src/main/java/seedu/address/logic/commands/FindCommand.java | 3 --- .../java/seedu/address/logic/commands/FindTimeCommand.java | 3 --- src/main/java/seedu/address/logic/commands/HelpCommand.java | 3 --- src/main/java/seedu/address/logic/commands/ListCommand.java | 3 --- src/main/java/seedu/address/logic/commands/LoadCommand.java | 3 --- src/main/java/seedu/address/logic/commands/SaveCommand.java | 3 --- src/main/java/seedu/address/logic/commands/UndoCommand.java | 3 --- .../seedu/address/logic/commands/UnfavouriteGameCommand.java | 3 --- 18 files changed, 1 insertion(+), 51 deletions(-) diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index 732a45c94a7..59cc5ad3548 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -52,6 +52,7 @@ public CommandResult execute(String commandText) throws CommandException, ParseE commandResult = command.execute(model); if (command.canBeUndone()) { model.addInputToLog(commandText); + model.addCommandToLog(command); } if (commandResult.isLoad()) { diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index fc11154d8d8..4abac2a25a6 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -69,9 +69,6 @@ public CommandResult execute(Model model) throws CommandException { previousPredicate = model.getCurrentPredicate(); model.addPerson(toAdd); - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(toAdd))); } diff --git a/src/main/java/seedu/address/logic/commands/AddGameCommand.java b/src/main/java/seedu/address/logic/commands/AddGameCommand.java index 3fd0a5218e3..81f99b99e81 100644 --- a/src/main/java/seedu/address/logic/commands/AddGameCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddGameCommand.java @@ -86,9 +86,6 @@ public CommandResult execute(Model model) throws CommandException { Game editedGame = createNewGame(gameName, addGameDescriptor); gameMap.put(gameName, editedGame); model.setPerson(personToEdit, personToEdit); - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(String.format(MESSAGE_ADD_GAME_SUCCESS, Messages.format(editedGame))); } diff --git a/src/main/java/seedu/address/logic/commands/ClearCommand.java b/src/main/java/seedu/address/logic/commands/ClearCommand.java index dfbb97a3ac0..0302f3cf8df 100644 --- a/src/main/java/seedu/address/logic/commands/ClearCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClearCommand.java @@ -23,9 +23,6 @@ public CommandResult execute(Model model) { requireNonNull(model); previousAddressBook = new AddressBook(model.getAddressBook()); model.setAddressBook(new AddressBook()); - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(MESSAGE_SUCCESS); } diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 58be3a664d4..d0efb3ebbb4 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -49,9 +49,6 @@ public CommandResult execute(Model model) throws CommandException { model.getAddressBookIndex(targetIndex.getZeroBased())); model.deletePerson(personToDelete); deletedPerson = personToDelete; - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete))); } diff --git a/src/main/java/seedu/address/logic/commands/DeleteGameCommand.java b/src/main/java/seedu/address/logic/commands/DeleteGameCommand.java index c26b425f43c..22b048bf51f 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteGameCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteGameCommand.java @@ -70,9 +70,6 @@ public CommandResult execute(Model model) throws CommandException { deletedGame = gameMap.remove(gameName); model.setPerson(personToEdit, personToEdit); - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(String.format(MESSAGE_DELETE_GAME_SUCCESS, Messages.format(deletedGame))); } diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index d00de05cc58..cf5a912d86d 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -96,9 +96,6 @@ public CommandResult execute(Model model) throws CommandException { model.setPerson(personToEdit, editedPerson); model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson))); } diff --git a/src/main/java/seedu/address/logic/commands/EditGameCommand.java b/src/main/java/seedu/address/logic/commands/EditGameCommand.java index 821c98ab826..c1e531e7ad5 100644 --- a/src/main/java/seedu/address/logic/commands/EditGameCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditGameCommand.java @@ -87,9 +87,6 @@ public CommandResult execute(Model model) throws CommandException { Game editedGame = createEditedGame(gameToEdit, editGameDescriptor); gameMap.put(gameName, editedGame); model.setPerson(personToEdit, personToEdit); - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(String.format(MESSAGE_EDIT_GAME_SUCCESS, Messages.format(editedGame))); } diff --git a/src/main/java/seedu/address/logic/commands/ExitCommand.java b/src/main/java/seedu/address/logic/commands/ExitCommand.java index 3aaf2763df1..cc353e09bf7 100644 --- a/src/main/java/seedu/address/logic/commands/ExitCommand.java +++ b/src/main/java/seedu/address/logic/commands/ExitCommand.java @@ -14,9 +14,6 @@ public class ExitCommand extends Command { @Override public CommandResult execute(Model model) { - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true, false, false); } diff --git a/src/main/java/seedu/address/logic/commands/FavouriteGameCommand.java b/src/main/java/seedu/address/logic/commands/FavouriteGameCommand.java index ede35fc32e1..a2eec17e942 100644 --- a/src/main/java/seedu/address/logic/commands/FavouriteGameCommand.java +++ b/src/main/java/seedu/address/logic/commands/FavouriteGameCommand.java @@ -67,9 +67,6 @@ public CommandResult execute(Model model) throws CommandException { prevGameIsFavourite = targetGame.getFavouriteStatus(); targetGame.setAsFavourite(); model.setPerson(targetPerson, targetPerson); - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(String.format(MESSAGE_FAVOURITE_GAME_SUCCESS, gameName)); } diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index 6807236d85d..7acba5e4456 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -36,9 +36,6 @@ public CommandResult execute(Model model) { requireNonNull(model); previousPredicate = model.getCurrentPredicate(); model.updateFilteredPersonList(predicate); - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult( String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredPersonList().size())); } diff --git a/src/main/java/seedu/address/logic/commands/FindTimeCommand.java b/src/main/java/seedu/address/logic/commands/FindTimeCommand.java index d847bc42e4a..899628cfe17 100644 --- a/src/main/java/seedu/address/logic/commands/FindTimeCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindTimeCommand.java @@ -38,9 +38,6 @@ public CommandResult execute(Model model) { requireNonNull(model); previousPredicate = model.getCurrentPredicate(); model.updateFilteredPersonList(predicate); - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult( String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredPersonList().size())); } diff --git a/src/main/java/seedu/address/logic/commands/HelpCommand.java b/src/main/java/seedu/address/logic/commands/HelpCommand.java index 416dded83c8..18c7743a4e2 100644 --- a/src/main/java/seedu/address/logic/commands/HelpCommand.java +++ b/src/main/java/seedu/address/logic/commands/HelpCommand.java @@ -17,9 +17,6 @@ public class HelpCommand extends Command { @Override public CommandResult execute(Model model) { - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(SHOWING_HELP_MESSAGE, true, false, false, false); } diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index b075b5733f2..a33ed6befab 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -25,9 +25,6 @@ public CommandResult execute(Model model) { requireNonNull(model); previousPredicate = model.getCurrentPredicate(); model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(MESSAGE_SUCCESS); } diff --git a/src/main/java/seedu/address/logic/commands/LoadCommand.java b/src/main/java/seedu/address/logic/commands/LoadCommand.java index 8ff7ecffa48..1da542e3ee2 100644 --- a/src/main/java/seedu/address/logic/commands/LoadCommand.java +++ b/src/main/java/seedu/address/logic/commands/LoadCommand.java @@ -12,9 +12,6 @@ public class LoadCommand extends Command { @Override public CommandResult execute(Model model) throws CommandException { - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(MESSAGE_SUCCESS, false, false, false, true); } diff --git a/src/main/java/seedu/address/logic/commands/SaveCommand.java b/src/main/java/seedu/address/logic/commands/SaveCommand.java index 80b3fa87e87..a541c09cab6 100644 --- a/src/main/java/seedu/address/logic/commands/SaveCommand.java +++ b/src/main/java/seedu/address/logic/commands/SaveCommand.java @@ -13,9 +13,6 @@ public class SaveCommand extends Command { @Override public CommandResult execute(Model model) throws CommandException { - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(MESSAGE_SUCCESS, false, false, true, false); } diff --git a/src/main/java/seedu/address/logic/commands/UndoCommand.java b/src/main/java/seedu/address/logic/commands/UndoCommand.java index fc234548dbd..ce445e03589 100644 --- a/src/main/java/seedu/address/logic/commands/UndoCommand.java +++ b/src/main/java/seedu/address/logic/commands/UndoCommand.java @@ -25,9 +25,6 @@ public CommandResult execute(Model model) throws CommandException { throw new CommandException(MESSAGE_INVALID_PREVIOUS_COMMAND); } previousCommand.undo(model); - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(String.format(MESSAGE_SUCCESS, model.getPreviousInput())); } diff --git a/src/main/java/seedu/address/logic/commands/UnfavouriteGameCommand.java b/src/main/java/seedu/address/logic/commands/UnfavouriteGameCommand.java index 1ece786c28a..b02f3d8d0cf 100644 --- a/src/main/java/seedu/address/logic/commands/UnfavouriteGameCommand.java +++ b/src/main/java/seedu/address/logic/commands/UnfavouriteGameCommand.java @@ -68,9 +68,6 @@ public CommandResult execute(Model model) throws CommandException { prevGameIsFavourite = targetGame.getFavouriteStatus(); targetGame.removeFavourite(); model.setPerson(targetPerson, targetPerson); - if (IS_UNDOABLE) { - model.addCommandToLog(this); - } return new CommandResult(String.format(MESSAGE_UNFAVOURITE_GAME_SUCCESS, gameName)); } From b30f1d3f04347c1693b486281f09d95393ad0473 Mon Sep 17 00:00:00 2001 From: Chen Lei Yu <128605764+ChenLeiyu@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:42:31 +0800 Subject: [PATCH 4/7] Fix "edit" command showing whole list --- src/main/java/seedu/address/logic/commands/EditCommand.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index cf5a912d86d..45f1d7669e9 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -95,7 +95,6 @@ public CommandResult execute(Model model) throws CommandException { } model.setPerson(personToEdit, editedPerson); - model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson))); } @@ -104,7 +103,6 @@ public void undo(Model model) { requireNonNull(model); model.setPerson(editedPerson, personToEdit); - model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); } @Override From 530be661f9991dbe87d83948e2a7d09cfdb63e0c Mon Sep 17 00:00:00 2001 From: Chen Lei Yu <128605764+ChenLeiyu@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:44:22 +0800 Subject: [PATCH 5/7] Remove unused import --- src/main/java/seedu/address/logic/commands/EditCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 45f1d7669e9..f8546675e13 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -8,7 +8,6 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_PREFERREDTIME; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; -import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; import java.util.Collections; import java.util.HashMap; From 39aff2de0d489c9fedd5095e8485e5e343a3d84f Mon Sep 17 00:00:00 2001 From: Chen Lei Yu <128605764+ChenLeiyu@users.noreply.github.com> Date: Thu, 7 Nov 2024 17:35:26 +0800 Subject: [PATCH 6/7] Fix edit testing for filtered lists --- .../logic/commands/CommandTestUtil.java | 18 ++++++++++++++++++ .../logic/commands/EditCommandTest.java | 4 ++-- .../logic/commands/EditGameCommandTest.java | 4 ++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 82b1816bfc4..ca2f8a93426 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -108,6 +108,24 @@ public static void assertCommandSuccess(Command command, Model actualModel, Stri assertCommandSuccess(command, actualModel, expectedCommandResult, expectedModel); } + /** + * Executes the given {@code command} while unfiltering the {@code actualModel}, confirms that
+ * - the returned {@link CommandResult} matches {@code expectedMessage}
+ * - the {@code actualModel} matches {@code expectedModel} + */ + public static void assertCommandSuccessUnfilter(Command command, Model actualModel, String expectedMessage, + Model expectedModel) { + CommandResult expectedCommandResult = new CommandResult(expectedMessage); + try { + CommandResult result = command.execute(actualModel); + actualModel.updateFilteredPersonList(unused -> true); + assertEquals(expectedCommandResult, result); + assertEquals(expectedModel, actualModel); + } catch (CommandException ce) { + throw new AssertionError("Execution of command should not fail.", ce); + } + } + /** * Executes the given {@code command}, confirms that
* - a {@code CommandException} is thrown
diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index 469dd97daa7..d2629ca2741 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -10,6 +10,7 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccessUnfilter; import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; @@ -95,8 +96,7 @@ public void execute_filteredList_success() { Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); - - assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); + assertCommandSuccessUnfilter(editCommand, model, expectedMessage, expectedModel); } @Test diff --git a/src/test/java/seedu/address/logic/commands/EditGameCommandTest.java b/src/test/java/seedu/address/logic/commands/EditGameCommandTest.java index 7a41d18ad10..14fd6b5e413 100644 --- a/src/test/java/seedu/address/logic/commands/EditGameCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditGameCommandTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccessUnfilter; import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; @@ -112,8 +113,7 @@ public void execute_filteredList_success() { Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); - showPersonAtIndex(expectedModel, INDEX_FIRST_PERSON); - assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); + assertCommandSuccessUnfilter(editCommand, model, expectedMessage, expectedModel); } @Test From 8a246c83013c61c67697d0e4f472cb2d665642ea Mon Sep 17 00:00:00 2001 From: flyingsalsa <107453007+flyingsalsa@users.noreply.github.com> Date: Thu, 7 Nov 2024 22:28:19 +0800 Subject: [PATCH 7/7] Update HelpWindow.java --- src/main/java/seedu/address/ui/HelpWindow.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/seedu/address/ui/HelpWindow.java b/src/main/java/seedu/address/ui/HelpWindow.java index 8165596d46b..82bba826958 100644 --- a/src/main/java/seedu/address/ui/HelpWindow.java +++ b/src/main/java/seedu/address/ui/HelpWindow.java @@ -74,8 +74,6 @@ public String getDescription() { */ public HelpWindow(Stage root) { super(FXML, root); - - this.getRoot().setResizable(true); this.getRoot().setMinHeight(500); this.getRoot().setMinWidth(600);