Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine searchmode #179

Merged
Merged
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
9 changes: 9 additions & 0 deletions src/main/java/seedu/address/logic/commands/ExitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ public CommandResult execute(Model model, EventManager eventManager) {
return new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true);
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

return other instanceof ExitCommand;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public CommandResult execute(Model model, EventManager eventManager) throws Comm
Event eventToView = events.get(targetIndex.getZeroBased());

model.updateFilteredPersonList(eventManager.getPersonInEventPredicate(eventToView));

return new CommandResult(String.format(MESSAGE_SUCCESS, eventToView.getName()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Exits search mode.
*/
public class ExitSearchModeCommand extends Command {
public static final String COMMAND_WORD = "exitsearchmode";
public static final String COMMAND_WORD = "exitsearch";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Exits search mode.\n"
+ "Example: " + COMMAND_WORD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ public Command parseSearchCommand(String userInput) throws ParseException {
return new ExitSearchModeCommand();
case SearchModeSearchCommand.COMMAND_WORD:
return new SearchModeSearchCommandParser().parse(arguments);
case ExitCommand.COMMAND_WORD:
return new ExitCommand();
default:
throw new ParseException(MESSAGE_UNKNOWN_COMMAND);
throw new ParseException(
MESSAGE_UNKNOWN_COMMAND + "\nYou are in searchmode.\nUse only search, exitsearch or exit");
}
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,4 @@ public boolean equals(Object other) {
public ObservableList<Person> getAllPersons() {
return addressBook.getPersonList();
}

}
3 changes: 0 additions & 3 deletions src/main/java/seedu/address/model/event/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
import seedu.address.model.role.exceptions.InvalidRoleException;





/**
* Represents an Event in the address book.
*/
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/seedu/address/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ public static Event[] getSampleEvents() {

return new Event[] {
new Event("NUS Student Life Fair 2024",
getPersonSet(samplePersons[0], samplePersons[1]),
getPersonSet(samplePersons[0]),
getPersonSet(samplePersons[1]),
getPersonSet(samplePersons[2]),
getPersonSet(samplePersons[3]),
getPersonSet(samplePersons[4])
getPersonSet(samplePersons[1])
),
new Event("NUS Open House 2024",
getPersonSet(samplePersons[1]),
getPersonSet(samplePersons[0], samplePersons[2]),
getPersonSet(samplePersons[3], samplePersons[4]),
getPersonSet(samplePersons[3]),
getPersonSet(samplePersons[4], samplePersons[5])
getPersonSet(samplePersons[5]),
getPersonSet(samplePersons[1])
)
};
}
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,6 @@ private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) {
*/
void fillInnerParts() {
updateUiBasedOnSearchMode(logic.getSearchMode().get());
// personListPanel = new PersonListPanel(logic.getFilteredPersonList());
// personListPanelPlaceholder.getChildren().add(personListPanel.getRoot());
// if (logic.getSearchMode()) {
// allPersonListPanel = new PersonListPanel(logic.getAllPersons());
// personListPanelPlaceholder.getChildren().add(allPersonListPanel.getRoot());
// }

eventListPanel = new EventListPanel(logic.getFilteredEventList());
eventListPanelPlaceholder.getChildren().add(eventListPanel.getRoot());
Expand Down
29 changes: 29 additions & 0 deletions src/test/java/seedu/address/logic/commands/ExitCommandTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package seedu.address.logic.commands;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.logic.commands.ExitCommand.MESSAGE_EXIT_ACKNOWLEDGEMENT;

Expand All @@ -17,4 +19,31 @@ public void execute_exit_success() {
CommandResult expectedCommandResult = new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true);
assertCommandSuccess(new ExitCommand(), model, expectedCommandResult, expectedModel);
}

@Test
public void equals_sameObject_returnsTrue() {
ExitCommand exitCommand = new ExitCommand();
assertTrue(exitCommand.equals(exitCommand));
}

@Test
public void equals_differentInstanceSameType_returnsTrue() {
ExitCommand exitCommand1 = new ExitCommand();
ExitCommand exitCommand2 = new ExitCommand();
assertTrue(exitCommand1.equals(exitCommand2));
}

@Test
public void equals_differentType_returnsFalse() {
ExitCommand exitCommand = new ExitCommand();
Object notExitCommand = new Object();
assertFalse(exitCommand.equals(notExitCommand));
}

@Test
public void equals_null_returnsFalse() {
ExitCommand exitCommand = new ExitCommand();
assertFalse(exitCommand.equals(null));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ public void parseSearchCommand_exitSearchModeCommand() throws ParseException {
assertEquals(expected, new AddressBookParser()
.parseSearchCommand(ExitSearchModeCommand.COMMAND_WORD));
}
@Test
public void parseSearchCommand_exitCommand() throws ParseException {
Command expected = new ExitCommand();
assertEquals(expected, new AddressBookParser()
.parseSearchCommand(ExitCommand.COMMAND_WORD));
}

@Test
public void parseSearchCommand_unrecognisedInput_throwsParseException() {
Expand Down