From feeecd0c894f84cc6549576eb386c522e1b198ba Mon Sep 17 00:00:00 2001 From: ArgVampir Date: Sat, 9 Nov 2019 14:37:59 +0800 Subject: [PATCH] Use higher level check has customer/driver and fix UI display scroll bar missing --- .../commands/ViewCustomerTaskCommand.java | 4 +--- .../logic/commands/ViewDriverTaskCommand.java | 4 +--- .../address/logic/parser/GoCommandParser.java | 4 ++-- src/main/resources/view/MainWindow.fxml | 18 +++++++++--------- .../logic/commands/CommandResultTest.java | 2 +- .../logic/commands/ExitCommandTest.java | 2 +- .../logic/commands/HelpCommandTest.java | 2 +- 7 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/ViewCustomerTaskCommand.java b/src/main/java/seedu/address/logic/commands/ViewCustomerTaskCommand.java index 5475b769afb..540e0234728 100644 --- a/src/main/java/seedu/address/logic/commands/ViewCustomerTaskCommand.java +++ b/src/main/java/seedu/address/logic/commands/ViewCustomerTaskCommand.java @@ -36,9 +36,7 @@ public ViewCustomerTaskCommand(int customerId) { public CommandResult execute(Model model) throws CommandException { requireNonNull(model); - List currentCustomerList = model.getFilteredCustomerList(); - - if (customerId > currentCustomerList.size()) { + if (!model.hasCustomer(customerId)) { throw new CommandException(Messages.MESSAGE_INVALID_CUSTOMER_DISPLAYED_INDEX); } diff --git a/src/main/java/seedu/address/logic/commands/ViewDriverTaskCommand.java b/src/main/java/seedu/address/logic/commands/ViewDriverTaskCommand.java index d9bf21e2dab..e4bd93e7679 100644 --- a/src/main/java/seedu/address/logic/commands/ViewDriverTaskCommand.java +++ b/src/main/java/seedu/address/logic/commands/ViewDriverTaskCommand.java @@ -36,9 +36,7 @@ public ViewDriverTaskCommand(int driverId) { public CommandResult execute(Model model) throws CommandException { requireNonNull(model); - List currentDriverList = model.getFilteredDriverList(); - - if (driverId > currentDriverList.size()) { + if (!model.hasDriver(driverId)) { throw new CommandException(Messages.MESSAGE_INVALID_DRIVER_DISPLAYED_INDEX); } diff --git a/src/main/java/seedu/address/logic/parser/GoCommandParser.java b/src/main/java/seedu/address/logic/parser/GoCommandParser.java index f3a92081e29..44baeea200b 100644 --- a/src/main/java/seedu/address/logic/parser/GoCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/GoCommandParser.java @@ -22,9 +22,9 @@ public class GoCommandParser implements Parser { public GoCommand parse(String args) throws ParseException { String tabName = args.trim().toLowerCase(); - if (tabName.equalsIgnoreCase(HOME_TAB)) { + if (tabName.equals(HOME_TAB)) { return new GoCommand(HOME_TAB); - } else if (tabName.equalsIgnoreCase(HISTORY_TAB)) { + } else if (tabName.equals(HISTORY_TAB)) { return new GoCommand(HISTORY_TAB); } else { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, GoCommand.MESSAGE_USAGE)); diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 88e0eab3be4..8d4fed78290 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -35,25 +35,25 @@ - + + - + - + @@ -64,7 +64,7 @@ - + @@ -95,18 +95,18 @@ - + - + - + - + diff --git a/src/test/java/seedu/address/logic/commands/CommandResultTest.java b/src/test/java/seedu/address/logic/commands/CommandResultTest.java index 89f261d6ef8..750689b26a1 100644 --- a/src/test/java/seedu/address/logic/commands/CommandResultTest.java +++ b/src/test/java/seedu/address/logic/commands/CommandResultTest.java @@ -46,7 +46,7 @@ public void hashcode() { // different showHelp value -> returns different hashcode assertNotEquals(commandResult.hashCode(), new CommandResult("feedback", true, - false, "default").hashCode()); + false).hashCode()); // different exit value -> returns different hashcode assertNotEquals(commandResult.hashCode(), new CommandResult("feedback", false, true).hashCode()); diff --git a/src/test/java/seedu/address/logic/commands/ExitCommandTest.java b/src/test/java/seedu/address/logic/commands/ExitCommandTest.java index 86f18afe236..61a673f8091 100644 --- a/src/test/java/seedu/address/logic/commands/ExitCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ExitCommandTest.java @@ -15,7 +15,7 @@ public class ExitCommandTest { @Test public void execute_exit_success() { CommandResult expectedCommandResult = new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, - true, "default"); + true); assertCommandSuccess(new ExitCommand(), model, expectedCommandResult, expectedModel); } } diff --git a/src/test/java/seedu/address/logic/commands/HelpCommandTest.java b/src/test/java/seedu/address/logic/commands/HelpCommandTest.java index 2054132a756..814d8a0926b 100644 --- a/src/test/java/seedu/address/logic/commands/HelpCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/HelpCommandTest.java @@ -15,7 +15,7 @@ public class HelpCommandTest { @Test public void execute_help_success() { CommandResult expectedCommandResult = new CommandResult(SHOWING_HELP_MESSAGE, - true, false, "default"); + true, false); assertCommandSuccess(new HelpCommand(), model, expectedCommandResult, expectedModel); } }