From 8a873a4ff0aff781f2462b90a347b8348bd5098b Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Thu, 15 Sep 2016 22:27:25 +0800 Subject: [PATCH 01/22] Added "More User Stories" --- doc/DeveloperGuide.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/DeveloperGuide.md b/doc/DeveloperGuide.md index c82c3afb9..efbdfe1af 100644 --- a/doc/DeveloperGuide.md +++ b/doc/DeveloperGuide.md @@ -45,9 +45,11 @@ Priority | As a ... | I want to ... | So that I can... `* * *` | user | add a new person | `* * *` | user | delete a person | remove entries that I no longer need `* * *` | user | find a person by name | locate details of persons without having to go through the entire list +`* *` | user | edit a person's credentials | changes the contact details of the person if there are any updates `* *` | user | hide [private contact details](#private-contact-detail) by default | minimize chance of someone else seeing them by accident `*` | user with many persons in the address book | sort persons by name | locate a person easily - +`*` | user | indicate a person as a favourite | have easy access to the person's details + `*` | user | undo past addition or edits | recover from mistakes made when adding or editing ## Appendix B : Use Cases From 10e072463555a273325c5a50785ed3e00b75e671 Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Thu, 15 Sep 2016 22:32:03 +0800 Subject: [PATCH 02/22] Added " Rename tag : Use case --- doc/DeveloperGuide.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/DeveloperGuide.md b/doc/DeveloperGuide.md index efbdfe1af..140e4e709 100644 --- a/doc/DeveloperGuide.md +++ b/doc/DeveloperGuide.md @@ -65,6 +65,18 @@ Priority | As a ... | I want to ... | So that I can... 4. AddressBook deletes the person
Use case ends. +#### Use case: Rename tag + + **MSS** + + 1. User requests to list tags + 2. AddressBook shows a list of tags + 3. User requests to edit a specific tag in the list + 4. AddressBook asks to confirms the request + 5. User confirms the request + 6. AddressBook edits the tag + Use case ends. + **Extensions** 2a. The list is empty @@ -75,6 +87,8 @@ Use case ends. > 3a1. AddressBook shows an error message
Use case resumes at step 2 + + ## Appendix C : Non Functional Requirements From f5aeeb9d496f533ca06ad1d369a234eff8f1e58d Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Thu, 15 Sep 2016 22:33:25 +0800 Subject: [PATCH 03/22] Added NFRs --- doc/DeveloperGuide.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/DeveloperGuide.md b/doc/DeveloperGuide.md index 140e4e709..cc4c6cf43 100644 --- a/doc/DeveloperGuide.md +++ b/doc/DeveloperGuide.md @@ -96,6 +96,9 @@ Use case ends. 2. Should be able to hold up to 1000 persons. 3. Should come with automated unit tests and open source code. 4. Should favor DOS style commands over Unix-style commands. +5. Should not require installation +6. Contact list should be exportable +7. Should be system resource-efficient ## Appendix D : Glossary From 62513c730adc6b19c01ee32e7cc87934da414b41 Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Thu, 15 Sep 2016 22:47:41 +0800 Subject: [PATCH 04/22] Add boolean isMutating() --- src/seedu/addressbook/commands/Command.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/seedu/addressbook/commands/Command.java b/src/seedu/addressbook/commands/Command.java index ccd4fcbf4..1dc9b59fc 100644 --- a/src/seedu/addressbook/commands/Command.java +++ b/src/seedu/addressbook/commands/Command.java @@ -41,6 +41,11 @@ public static String getMessageForPersonListShownSummary(List Date: Thu, 15 Sep 2016 22:53:09 +0800 Subject: [PATCH 05/22] Added isMutating() to all relavent classes --- src/seedu/addressbook/commands/AddCommand.java | 6 +++++- src/seedu/addressbook/commands/ClearCommand.java | 5 +++++ src/seedu/addressbook/commands/DeleteCommand.java | 5 +++++ src/seedu/addressbook/commands/ExitCommand.java | 6 +++++- src/seedu/addressbook/commands/FindCommand.java | 5 +++++ src/seedu/addressbook/commands/HelpCommand.java | 5 +++++ src/seedu/addressbook/commands/IncorrectCommand.java | 5 +++++ src/seedu/addressbook/commands/ListCommand.java | 5 +++++ src/seedu/addressbook/commands/ViewAllCommand.java | 5 +++++ src/seedu/addressbook/commands/ViewCommand.java | 5 +++++ 10 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/seedu/addressbook/commands/AddCommand.java b/src/seedu/addressbook/commands/AddCommand.java index b0f202d42..fceb59b4d 100644 --- a/src/seedu/addressbook/commands/AddCommand.java +++ b/src/seedu/addressbook/commands/AddCommand.java @@ -66,5 +66,9 @@ public CommandResult execute() { return new CommandResult(MESSAGE_DUPLICATE_PERSON); } } - + + @Override + public boolean isMutating() { + return true; + } } diff --git a/src/seedu/addressbook/commands/ClearCommand.java b/src/seedu/addressbook/commands/ClearCommand.java index b09706013..bddbe4102 100644 --- a/src/seedu/addressbook/commands/ClearCommand.java +++ b/src/seedu/addressbook/commands/ClearCommand.java @@ -19,4 +19,9 @@ public CommandResult execute() { addressBook.clear(); return new CommandResult(MESSAGE_SUCCESS); } + + @Override + public boolean isMutating() { + return true; + } } diff --git a/src/seedu/addressbook/commands/DeleteCommand.java b/src/seedu/addressbook/commands/DeleteCommand.java index 1dd78f85e..47e8f2ab6 100644 --- a/src/seedu/addressbook/commands/DeleteCommand.java +++ b/src/seedu/addressbook/commands/DeleteCommand.java @@ -38,5 +38,10 @@ public CommandResult execute() { return new CommandResult(Messages.MESSAGE_PERSON_NOT_IN_ADDRESSBOOK); } } + + @Override + public boolean isMutating() { + return true; + } } diff --git a/src/seedu/addressbook/commands/ExitCommand.java b/src/seedu/addressbook/commands/ExitCommand.java index 0585451f1..60643237c 100644 --- a/src/seedu/addressbook/commands/ExitCommand.java +++ b/src/seedu/addressbook/commands/ExitCommand.java @@ -15,5 +15,9 @@ public class ExitCommand extends Command { public CommandResult execute() { return new CommandResult(MESSAGE_EXIT_ACKNOWEDGEMENT); } - + + @Override + public boolean isMutating() { + return false; + } } diff --git a/src/seedu/addressbook/commands/FindCommand.java b/src/seedu/addressbook/commands/FindCommand.java index c8e9a380f..dbee01bc5 100644 --- a/src/seedu/addressbook/commands/FindCommand.java +++ b/src/seedu/addressbook/commands/FindCommand.java @@ -52,5 +52,10 @@ private List getPersonsWithNameContainingAnyKeyword(Set } return matchedPersons; } + + @Override + public boolean isMutating() { + return false; + } } diff --git a/src/seedu/addressbook/commands/HelpCommand.java b/src/seedu/addressbook/commands/HelpCommand.java index 82530440c..6137162f8 100644 --- a/src/seedu/addressbook/commands/HelpCommand.java +++ b/src/seedu/addressbook/commands/HelpCommand.java @@ -27,4 +27,9 @@ public HelpCommand() {} public CommandResult execute() { return new CommandResult(MESSAGE_ALL_USAGES); } + + @Override + public boolean isMutating() { + return false; + } } diff --git a/src/seedu/addressbook/commands/IncorrectCommand.java b/src/seedu/addressbook/commands/IncorrectCommand.java index 81abba7a1..331b30168 100644 --- a/src/seedu/addressbook/commands/IncorrectCommand.java +++ b/src/seedu/addressbook/commands/IncorrectCommand.java @@ -16,5 +16,10 @@ public IncorrectCommand(String feedbackToUser){ public CommandResult execute() { return new CommandResult(feedbackToUser); } + + @Override + public boolean isMutating() { + return false; + } } diff --git a/src/seedu/addressbook/commands/ListCommand.java b/src/seedu/addressbook/commands/ListCommand.java index cb604a8e9..f302766e7 100644 --- a/src/seedu/addressbook/commands/ListCommand.java +++ b/src/seedu/addressbook/commands/ListCommand.java @@ -22,4 +22,9 @@ public CommandResult execute() { List allPersons = addressBook.getAllPersons().immutableListView(); return new CommandResult(getMessageForPersonListShownSummary(allPersons), allPersons); } + + @Override + public boolean isMutating() { + return false; + } } diff --git a/src/seedu/addressbook/commands/ViewAllCommand.java b/src/seedu/addressbook/commands/ViewAllCommand.java index ed2c16e83..2ee64af44 100644 --- a/src/seedu/addressbook/commands/ViewAllCommand.java +++ b/src/seedu/addressbook/commands/ViewAllCommand.java @@ -37,4 +37,9 @@ public CommandResult execute() { return new CommandResult(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } } + + @Override + public boolean isMutating() { + return false; + } } diff --git a/src/seedu/addressbook/commands/ViewCommand.java b/src/seedu/addressbook/commands/ViewCommand.java index 1058c4b52..762aba8e7 100644 --- a/src/seedu/addressbook/commands/ViewCommand.java +++ b/src/seedu/addressbook/commands/ViewCommand.java @@ -37,5 +37,10 @@ public CommandResult execute() { return new CommandResult(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } } + + @Override + public boolean isMutating() { + return false; + } } From e588d51661fdfe50b9454a25ac436c5aa0d9fc3f Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Thu, 15 Sep 2016 22:55:28 +0800 Subject: [PATCH 06/22] Added validation is check isMutating() before saving the file --- src/seedu/addressbook/logic/Logic.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/seedu/addressbook/logic/Logic.java b/src/seedu/addressbook/logic/Logic.java index 17afd61a0..976a1d533 100644 --- a/src/seedu/addressbook/logic/Logic.java +++ b/src/seedu/addressbook/logic/Logic.java @@ -85,7 +85,10 @@ public CommandResult execute(String userCommandText) throws Exception { private CommandResult execute(Command command) throws Exception { command.setData(addressBook, lastShownList); CommandResult result = command.execute(); - storage.save(addressBook); + if (command.isMutating()) { + storage.save(addressBook); + + } return result; } From 2b362eeb3bc85dbc76cfa1032a9ba13fe672e02a Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Thu, 15 Sep 2016 23:09:38 +0800 Subject: [PATCH 07/22] Revert "Added validation is check isMutating() before saving the file" This reverts commit e588d51661fdfe50b9454a25ac436c5aa0d9fc3f. --- src/seedu/addressbook/logic/Logic.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/seedu/addressbook/logic/Logic.java b/src/seedu/addressbook/logic/Logic.java index 976a1d533..17afd61a0 100644 --- a/src/seedu/addressbook/logic/Logic.java +++ b/src/seedu/addressbook/logic/Logic.java @@ -85,10 +85,7 @@ public CommandResult execute(String userCommandText) throws Exception { private CommandResult execute(Command command) throws Exception { command.setData(addressBook, lastShownList); CommandResult result = command.execute(); - if (command.isMutating()) { - storage.save(addressBook); - - } + storage.save(addressBook); return result; } From b02c6813487d11ace90565d7877211b4925ef21c Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Thu, 15 Sep 2016 23:10:07 +0800 Subject: [PATCH 08/22] Revert "Revert "Added validation is check isMutating() before saving the file"" This reverts commit 2b362eeb3bc85dbc76cfa1032a9ba13fe672e02a. --- src/seedu/addressbook/logic/Logic.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/seedu/addressbook/logic/Logic.java b/src/seedu/addressbook/logic/Logic.java index 17afd61a0..976a1d533 100644 --- a/src/seedu/addressbook/logic/Logic.java +++ b/src/seedu/addressbook/logic/Logic.java @@ -85,7 +85,10 @@ public CommandResult execute(String userCommandText) throws Exception { private CommandResult execute(Command command) throws Exception { command.setData(addressBook, lastShownList); CommandResult result = command.execute(); - storage.save(addressBook); + if (command.isMutating()) { + storage.save(addressBook); + + } return result; } From aeeb430d3dd43ad64bed4ffe711c3d480871f824 Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Thu, 15 Sep 2016 23:11:50 +0800 Subject: [PATCH 09/22] Added Exception to overridden method --- src/seedu/addressbook/commands/AddCommand.java | 2 +- src/seedu/addressbook/commands/Command.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/seedu/addressbook/commands/AddCommand.java b/src/seedu/addressbook/commands/AddCommand.java index fceb59b4d..8b9f57fa0 100644 --- a/src/seedu/addressbook/commands/AddCommand.java +++ b/src/seedu/addressbook/commands/AddCommand.java @@ -58,7 +58,7 @@ public ReadOnlyPerson getPerson() { } @Override - public CommandResult execute() { + public CommandResult execute() throws Exception { try { addressBook.addPerson(toAdd); return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd)); diff --git a/src/seedu/addressbook/commands/Command.java b/src/seedu/addressbook/commands/Command.java index 1dc9b59fc..ff384055e 100644 --- a/src/seedu/addressbook/commands/Command.java +++ b/src/seedu/addressbook/commands/Command.java @@ -38,8 +38,9 @@ public static String getMessageForPersonListShownSummary(List Date: Thu, 15 Sep 2016 23:12:28 +0800 Subject: [PATCH 10/22] Revert "Add boolean isMutating()" This reverts commit 62513c730adc6b19c01ee32e7cc87934da414b41. --- src/seedu/addressbook/commands/Command.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/seedu/addressbook/commands/Command.java b/src/seedu/addressbook/commands/Command.java index ff384055e..dd7aaf5d8 100644 --- a/src/seedu/addressbook/commands/Command.java +++ b/src/seedu/addressbook/commands/Command.java @@ -42,11 +42,6 @@ public static String getMessageForPersonListShownSummary(List Date: Thu, 15 Sep 2016 23:27:49 +0800 Subject: [PATCH 11/22] Revert "Added "More User Stories"" This reverts commit 8a873a4ff0aff781f2462b90a347b8348bd5098b. --- doc/DeveloperGuide.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/doc/DeveloperGuide.md b/doc/DeveloperGuide.md index cc4c6cf43..f7337a4f9 100644 --- a/doc/DeveloperGuide.md +++ b/doc/DeveloperGuide.md @@ -45,11 +45,9 @@ Priority | As a ... | I want to ... | So that I can... `* * *` | user | add a new person | `* * *` | user | delete a person | remove entries that I no longer need `* * *` | user | find a person by name | locate details of persons without having to go through the entire list -`* *` | user | edit a person's credentials | changes the contact details of the person if there are any updates `* *` | user | hide [private contact details](#private-contact-detail) by default | minimize chance of someone else seeing them by accident `*` | user with many persons in the address book | sort persons by name | locate a person easily -`*` | user | indicate a person as a favourite | have easy access to the person's details - `*` | user | undo past addition or edits | recover from mistakes made when adding or editing + ## Appendix B : Use Cases From 71cb677b0fda06351ba45943d0803b2e436a9d8c Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Thu, 15 Sep 2016 23:28:00 +0800 Subject: [PATCH 12/22] Revert "Added " Rename tag : Use case" This reverts commit 10e072463555a273325c5a50785ed3e00b75e671. --- doc/DeveloperGuide.md | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/doc/DeveloperGuide.md b/doc/DeveloperGuide.md index f7337a4f9..1b5c58f05 100644 --- a/doc/DeveloperGuide.md +++ b/doc/DeveloperGuide.md @@ -63,18 +63,6 @@ Priority | As a ... | I want to ... | So that I can... 4. AddressBook deletes the person
Use case ends. -#### Use case: Rename tag - - **MSS** - - 1. User requests to list tags - 2. AddressBook shows a list of tags - 3. User requests to edit a specific tag in the list - 4. AddressBook asks to confirms the request - 5. User confirms the request - 6. AddressBook edits the tag - Use case ends. - **Extensions** 2a. The list is empty @@ -85,8 +73,6 @@ Use case ends. > 3a1. AddressBook shows an error message
Use case resumes at step 2 - - ## Appendix C : Non Functional Requirements From 05c0477446b193c79835a4da9a8694efacfb6a8a Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Thu, 15 Sep 2016 23:28:10 +0800 Subject: [PATCH 13/22] Revert "Added NFRs" This reverts commit f5aeeb9d496f533ca06ad1d369a234eff8f1e58d. --- doc/DeveloperGuide.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/DeveloperGuide.md b/doc/DeveloperGuide.md index 1b5c58f05..c82c3afb9 100644 --- a/doc/DeveloperGuide.md +++ b/doc/DeveloperGuide.md @@ -80,9 +80,6 @@ Use case ends. 2. Should be able to hold up to 1000 persons. 3. Should come with automated unit tests and open source code. 4. Should favor DOS style commands over Unix-style commands. -5. Should not require installation -6. Contact list should be exportable -7. Should be system resource-efficient ## Appendix D : Glossary From 70fd62748639222e56906e46c6413a023f482a08 Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Sun, 25 Sep 2016 17:20:48 +0800 Subject: [PATCH 14/22] Updated Use Case --- doc/DeveloperGuide.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/DeveloperGuide.md b/doc/DeveloperGuide.md index c82c3afb9..53d3e880d 100644 --- a/doc/DeveloperGuide.md +++ b/doc/DeveloperGuide.md @@ -74,6 +74,22 @@ Use case ends. > 3a1. AddressBook shows an error message
Use case resumes at step 2 +#### Use case: Change theme + + **MSS** + + 1. User requests to change to a new theme + 2. AddressBook changes the theme + Use case ends. + + **Extensions** + + 1a. The theme to be renamed does not exist + + > 1a1. AddressBook shows an error message
+ Use case ends + + ## Appendix C : Non Functional Requirements 1. Should work on any [mainstream OS](#mainstream-os) as long as it has Java 8 or higher installed. From dedd7bb2c8566e286e97f9b49c282a0730eecb37 Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Sun, 25 Sep 2016 17:21:11 +0800 Subject: [PATCH 15/22] Updated User Guide --- doc/UserGuide.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/UserGuide.md b/doc/UserGuide.md index 3e4baae95..073ca0e1a 100644 --- a/doc/UserGuide.md +++ b/doc/UserGuide.md @@ -99,6 +99,17 @@ Examples: Clears all entries from the address book.
Format: `clear` +## Changing a theme : `theme` + Changes the theme of the app. Irreversible.
+ Format: `theme NEW_THEME` + + > Changes the theme of the app. + + Examples: + * `theme Light`
+ Changes the theme of the app to Light theme. + + ## Exiting the program : `exit` Exits the program.
Format: `exit` From 02c550a934d6c63319a76870c09de7937be8a2b8 Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Sun, 25 Sep 2016 17:23:12 +0800 Subject: [PATCH 16/22] Added ChangeThemeCommand --- .../commands/ChangeThemeCommand.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/seedu/addressbook/commands/ChangeThemeCommand.java diff --git a/src/seedu/addressbook/commands/ChangeThemeCommand.java b/src/seedu/addressbook/commands/ChangeThemeCommand.java new file mode 100644 index 000000000..6a5c5f966 --- /dev/null +++ b/src/seedu/addressbook/commands/ChangeThemeCommand.java @@ -0,0 +1,34 @@ +package seedu.addressbook.commands; + +import seedu.addressbook.data.AddressBook; +import seedu.addressbook.ui.Gui; + +public class ChangeThemeCommand extends Command { + + public static final String COMMAND_WORD = "theme"; + + public static String MESSAGE_USAGE = String.format(COMMAND_WORD + ":\n" + + "Changes theme of the application.\n\t" + + "Parameters: NEW_THEME\n\t" + + "Themes available: %1$s\n\t" + + "Example: " + COMMAND_WORD + " Light", AddressBook.allThemesString()); + + public static final String MESSAGE_SUCCESS = "Theme changed successfully"; + public static final String MESSAGE_FAILED_THEME_DOES_NOT_EXIST = "Theme %1$s does not exist.\n"; + + private final String newThemeName; + + public ChangeThemeCommand(String newThemeName) { + this.newThemeName = newThemeName; + } + + @Override + public CommandResult execute() { + if (!addressBook.containsTheme(newThemeName)) { + return new CommandResult(String.format(MESSAGE_FAILED_THEME_DOES_NOT_EXIST, newThemeName)); + } + Gui.changeTheme(newThemeName); + return new CommandResult(MESSAGE_SUCCESS); + } + +} \ No newline at end of file From 4841708a598a4e355b2d981a9f56b8817bb52bbd Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Sun, 25 Sep 2016 17:23:57 +0800 Subject: [PATCH 17/22] Updated Help Command for ChangeThemeCommand --- src/seedu/addressbook/commands/HelpCommand.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/seedu/addressbook/commands/HelpCommand.java b/src/seedu/addressbook/commands/HelpCommand.java index 6137162f8..6c18bfafc 100644 --- a/src/seedu/addressbook/commands/HelpCommand.java +++ b/src/seedu/addressbook/commands/HelpCommand.java @@ -19,7 +19,8 @@ public class HelpCommand extends Command { + "\n" + ViewCommand.MESSAGE_USAGE + "\n" + ViewAllCommand.MESSAGE_USAGE + "\n" + HelpCommand.MESSAGE_USAGE - + "\n" + ExitCommand.MESSAGE_USAGE; + + "\n" + ExitCommand.MESSAGE_USAGE + + "\n" + ChangeThemeCommand.MESSAGE_USAGE; public HelpCommand() {} From 31e3980b8e1ba5c00fed32d9bd985e9efde9688c Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Sun, 25 Sep 2016 17:25:25 +0800 Subject: [PATCH 18/22] Added ChangeThemeCommand validation --- src/seedu/addressbook/data/AddressBook.java | 23 ++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/seedu/addressbook/data/AddressBook.java b/src/seedu/addressbook/data/AddressBook.java index b3ab0dfeb..6bdb48340 100644 --- a/src/seedu/addressbook/data/AddressBook.java +++ b/src/seedu/addressbook/data/AddressBook.java @@ -19,7 +19,7 @@ public class AddressBook { private final UniquePersonList allPersons; private final UniqueTagList allTags; // can contain tags not attached to any person - + private final static String[] allThemes = {"Dark", "Light", "Mocha", "Grape"}; public static AddressBook empty() { return new AddressBook(); } @@ -106,6 +106,27 @@ public boolean containsTag(Tag key) { } /** + * Checks if provided theme name exists + * */ + + public boolean containsTheme(String theme) { + for (String th : allThemes) { + if (th.equals(theme)) { + return true; + } + } + return false; + } + + /** + * Returns all themes as a string, for use of help command. + * */ + public static String allThemesString() { + return String.join(", ", allThemes); + } + + /** + * Removes the equivalent person from the address book. * * @throws PersonNotFoundException if no such Person could be found. From 13f84b1230b6139b9b4ac842294ccfd50c44d051 Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Sun, 25 Sep 2016 17:31:51 +0800 Subject: [PATCH 19/22] Added Change_Theme_Args_Format , changeTheme(), prepareChangeTheme() --- src/seedu/addressbook/parser/Parser.java | 462 ++++++++++++----------- 1 file changed, 248 insertions(+), 214 deletions(-) diff --git a/src/seedu/addressbook/parser/Parser.java b/src/seedu/addressbook/parser/Parser.java index 3a8305f28..fb4838abd 100644 --- a/src/seedu/addressbook/parser/Parser.java +++ b/src/seedu/addressbook/parser/Parser.java @@ -9,224 +9,258 @@ import static seedu.addressbook.common.Messages.MESSAGE_INVALID_COMMAND_FORMAT; + /** * Parses user input. */ public class Parser { - public static final Pattern PERSON_INDEX_ARGS_FORMAT = Pattern.compile("(?.+)"); - - public static final Pattern KEYWORDS_ARGS_FORMAT = - Pattern.compile("(?\\S+(?:\\s+\\S+)*)"); // one or more keywords separated by whitespace - - public static final Pattern PERSON_DATA_ARGS_FORMAT = // '/' forward slashes are reserved for delimiter prefixes - Pattern.compile("(?[^/]+)" - + " (?p?)p/(?[^/]+)" - + " (?p?)e/(?[^/]+)" - + " (?p?)a/(?
[^/]+)" - + "(?(?: t/[^/]+)*)"); // variable number of tags - - - /** - * Signals that the user input could not be parsed. - */ - public static class ParseException extends Exception { - ParseException(String message) { - super(message); - } - } - - /** - * Used for initial separation of command word and args. - */ - public static final Pattern BASIC_COMMAND_FORMAT = Pattern.compile("(?\\S+)(?.*)"); - - public Parser() {} - - /** - * Parses user input into command for execution. - * - * @param userInput full user input string - * @return the command based on the user input - */ - public Command parseCommand(String userInput) { - final Matcher matcher = BASIC_COMMAND_FORMAT.matcher(userInput.trim()); - if (!matcher.matches()) { - return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE)); - } - - final String commandWord = matcher.group("commandWord"); - final String arguments = matcher.group("arguments"); - switch (commandWord) { - - case AddCommand.COMMAND_WORD: - return prepareAdd(arguments); - - case DeleteCommand.COMMAND_WORD: - return prepareDelete(arguments); - - case ClearCommand.COMMAND_WORD: - return new ClearCommand(); - - case FindCommand.COMMAND_WORD: - return prepareFind(arguments); - - case ListCommand.COMMAND_WORD: - return new ListCommand(); - - case ViewCommand.COMMAND_WORD: - return prepareView(arguments); - - case ViewAllCommand.COMMAND_WORD: - return prepareViewAll(arguments); - - case ExitCommand.COMMAND_WORD: - return new ExitCommand(); - - case HelpCommand.COMMAND_WORD: // Fallthrough - default: - return new HelpCommand(); - } - } - - /** - * Parses arguments in the context of the add person command. - * - * @param args full command args string - * @return the prepared command - */ - private Command prepareAdd(String args){ - final Matcher matcher = PERSON_DATA_ARGS_FORMAT.matcher(args.trim()); - // Validate arg string format - if (!matcher.matches()) { - return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); - } - try { - return new AddCommand( - matcher.group("name"), - - matcher.group("phone"), - isPrivatePrefixPresent(matcher.group("isPhonePrivate")), - - matcher.group("email"), - isPrivatePrefixPresent(matcher.group("isEmailPrivate")), - - matcher.group("address"), - isPrivatePrefixPresent(matcher.group("isAddressPrivate")), - - getTagsFromArgs(matcher.group("tagArguments")) - ); - } catch (IllegalValueException ive) { - return new IncorrectCommand(ive.getMessage()); - } - } - - /** - * Checks whether the private prefix of a contact detail in the add command's arguments string is present. - */ - private static boolean isPrivatePrefixPresent(String matchedPrefix) { - return matchedPrefix.equals("p"); - } - - /** - * Extracts the new person's tags from the add command's tag arguments string. - * Merges duplicate tag strings. - */ - private static Set getTagsFromArgs(String tagArguments) throws IllegalValueException { - // no tags - if (tagArguments.isEmpty()) { - return Collections.emptySet(); - } - // replace first delimiter prefix, then split - final Collection tagStrings = Arrays.asList(tagArguments.replaceFirst(" t/", "").split(" t/")); - return new HashSet<>(tagStrings); - } - - - /** - * Parses arguments in the context of the delete person command. - * - * @param args full command args string - * @return the prepared command - */ - private Command prepareDelete(String args) { - try { - final int targetIndex = parseArgsAsDisplayedIndex(args); - return new DeleteCommand(targetIndex); - } catch (ParseException | NumberFormatException e) { - return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE)); - } - } - - /** - * Parses arguments in the context of the view command. - * - * @param args full command args string - * @return the prepared command - */ - private Command prepareView(String args) { - - try { - final int targetIndex = parseArgsAsDisplayedIndex(args); - return new ViewCommand(targetIndex); - } catch (ParseException | NumberFormatException e) { - return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, - ViewCommand.MESSAGE_USAGE)); - } - } - - /** - * Parses arguments in the context of the view all command. - * - * @param args full command args string - * @return the prepared command - */ - private Command prepareViewAll(String args) { - - try { - final int targetIndex = parseArgsAsDisplayedIndex(args); - return new ViewAllCommand(targetIndex); - } catch (ParseException | NumberFormatException e) { - return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, - ViewAllCommand.MESSAGE_USAGE)); - } - } - - /** - * Parses the given arguments string as a single index number. - * - * @param args arguments string to parse as index number - * @return the parsed index number - * @throws ParseException if no region of the args string could be found for the index - * @throws NumberFormatException the args string region is not a valid number - */ - private int parseArgsAsDisplayedIndex(String args) throws ParseException, NumberFormatException { - final Matcher matcher = PERSON_INDEX_ARGS_FORMAT.matcher(args.trim()); - if (!matcher.matches()) { - throw new ParseException("Could not find index number to parse"); - } - return Integer.parseInt(matcher.group("targetIndex")); - } - - - /** - * Parses arguments in the context of the find person command. - * - * @param args full command args string - * @return the prepared command - */ - private Command prepareFind(String args) { - final Matcher matcher = KEYWORDS_ARGS_FORMAT.matcher(args.trim()); - if (!matcher.matches()) { - return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, - FindCommand.MESSAGE_USAGE)); - } - - // keywords delimited by whitespace - final String[] keywords = matcher.group("keywords").split("\\s+"); - final Set keywordSet = new HashSet<>(Arrays.asList(keywords)); - return new FindCommand(keywordSet); - } - + public static final Pattern PERSON_INDEX_ARGS_FORMAT = Pattern.compile("(?.+)"); + + public static final Pattern KEYWORDS_ARGS_FORMAT = Pattern.compile("(?\\S+(?:\\s+\\S+)*)"); // one + // or + // more + public static final Pattern CHANGE_THEME_ARGS_FORMAT = Pattern.compile("(?.+)"); // keywords + // separated + // by // whitespace + + public static final Pattern PERSON_DATA_ARGS_FORMAT = // '/' forward slashes + // are reserved for + // delimiter + // prefixes + Pattern.compile("(?[^/]+)" + " (?p?)p/(?[^/]+)" + + " (?p?)e/(?[^/]+)" + " (?p?)a/(?
[^/]+)" + + "(?(?: t/[^/]+)*)"); // variable number of + // tags + + /** + * Signals that the user input could not be parsed. + */ + public static class ParseException extends Exception { + ParseException(String message) { + super(message); + } + } + + /** + * Used for initial separation of command word and args. + */ + public static final Pattern BASIC_COMMAND_FORMAT = Pattern.compile("(?\\S+)(?.*)"); + + public Parser() { + } + + /** + * Parses user input into command for execution. + * + * @param userInput + * full user input string + * @return the command based on the user input + */ + public Command parseCommand(String userInput) { + final Matcher matcher = BASIC_COMMAND_FORMAT.matcher(userInput.trim()); + if (!matcher.matches()) { + return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE)); + } + + final String commandWord = matcher.group("commandWord"); + final String arguments = matcher.group("arguments"); + switch (commandWord) { + + case AddCommand.COMMAND_WORD: + return prepareAdd(arguments); + + case DeleteCommand.COMMAND_WORD: + return prepareDelete(arguments); + + case ClearCommand.COMMAND_WORD: + return new ClearCommand(); + + case FindCommand.COMMAND_WORD: + return prepareFind(arguments); + + case ListCommand.COMMAND_WORD: + return new ListCommand(); + + case ViewCommand.COMMAND_WORD: + return prepareView(arguments); + + case ViewAllCommand.COMMAND_WORD: + return prepareViewAll(arguments); + + case ChangeThemeCommand.COMMAND_WORD: + return prepareChangeTheme(arguments); + + case ExitCommand.COMMAND_WORD: + return new ExitCommand(); + + case HelpCommand.COMMAND_WORD: // Fallthrough + default: + return new HelpCommand(); + } + } + + /** + * Parses arguments in the context of the add person command. + * + * @param args + * full command args string + * @return the prepared command + */ + private Command prepareAdd(String args) { + final Matcher matcher = PERSON_DATA_ARGS_FORMAT.matcher(args.trim()); + // Validate arg string format + if (!matcher.matches()) { + return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); + } + try { + return new AddCommand(matcher.group("name"), + + matcher.group("phone"), isPrivatePrefixPresent(matcher.group("isPhonePrivate")), + + matcher.group("email"), isPrivatePrefixPresent(matcher.group("isEmailPrivate")), + + matcher.group("address"), isPrivatePrefixPresent(matcher.group("isAddressPrivate")), + + getTagsFromArgs(matcher.group("tagArguments"))); + } catch (IllegalValueException ive) { + return new IncorrectCommand(ive.getMessage()); + } + } + + private Command changeTheme(String args) { + final Matcher matcher = CHANGE_THEME_ARGS_FORMAT.matcher(args.trim()); + if (!matcher.matches()) { + return new IncorrectCommand( + String.format(MESSAGE_INVALID_COMMAND_FORMAT, ChangeThemeCommand.MESSAGE_USAGE)); + } + return new ChangeThemeCommand(matcher.group("newTheme")); + } + + /** + * + * /** Checks whether the private prefix of a contact detail in the add + * command's arguments string is present. + */ + private static boolean isPrivatePrefixPresent(String matchedPrefix) { + return matchedPrefix.equals("p"); + } + + /** + * Extracts the new person's tags from the add command's tag arguments + * string. Merges duplicate tag strings. + */ + private static Set getTagsFromArgs(String tagArguments) throws IllegalValueException { + // no tags + if (tagArguments.isEmpty()) { + return Collections.emptySet(); + } + // replace first delimiter prefix, then split + final Collection tagStrings = Arrays.asList(tagArguments.replaceFirst(" t/", "").split(" t/")); + return new HashSet<>(tagStrings); + } + + /** + * Parses arguments in the context of the delete person command. + * + * @param args + * full command args string + * @return the prepared command + */ + private Command prepareDelete(String args) { + try { + final int targetIndex = parseArgsAsDisplayedIndex(args); + return new DeleteCommand(targetIndex); + } catch (ParseException | NumberFormatException e) { + return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE)); + } + } + + /** + * Parses arguments in the context of the change theme command. + * + * @param args full command args string + * @return the prepared command + */ + private Command prepareChangeTheme(String args) { + final Matcher matcher = CHANGE_THEME_ARGS_FORMAT.matcher(args.trim()); + if (!matcher.matches()) { + return new IncorrectCommand( + String.format(MESSAGE_INVALID_COMMAND_FORMAT, ChangeThemeCommand.MESSAGE_USAGE)); + } + return new ChangeThemeCommand(matcher.group("newTheme")); + } + + /** + * Parses arguments in the context of the view command. + * + * @param args + * full command args string + * @return the prepared command + */ + private Command prepareView(String args) { + + try { + final int targetIndex = parseArgsAsDisplayedIndex(args); + return new ViewCommand(targetIndex); + } catch (ParseException | NumberFormatException e) { + return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewCommand.MESSAGE_USAGE)); + } + } + + /** + * Parses arguments in the context of the view all command. + * + * @param args + * full command args string + * @return the prepared command + */ + private Command prepareViewAll(String args) { + + try { + final int targetIndex = parseArgsAsDisplayedIndex(args); + return new ViewAllCommand(targetIndex); + } catch (ParseException | NumberFormatException e) { + return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewAllCommand.MESSAGE_USAGE)); + } + } + + /** + * Parses the given arguments string as a single index number. + * + * @param args + * arguments string to parse as index number + * @return the parsed index number + * @throws ParseException + * if no region of the args string could be found for the index + * @throws NumberFormatException + * the args string region is not a valid number + */ + private int parseArgsAsDisplayedIndex(String args) throws ParseException, NumberFormatException { + final Matcher matcher = PERSON_INDEX_ARGS_FORMAT.matcher(args.trim()); + if (!matcher.matches()) { + throw new ParseException("Could not find index number to parse"); + } + return Integer.parseInt(matcher.group("targetIndex")); + } + + /** + * Parses arguments in the context of the find person command. + * + * @param args + * full command args string + * @return the prepared command + */ + private Command prepareFind(String args) { + final Matcher matcher = KEYWORDS_ARGS_FORMAT.matcher(args.trim()); + if (!matcher.matches()) { + return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE)); + } + + // keywords delimited by whitespace + final String[] keywords = matcher.group("keywords").split("\\s+"); + final Set keywordSet = new HashSet<>(Arrays.asList(keywords)); + return new FindCommand(keywordSet); + } } \ No newline at end of file From 606b089be9888e637bdff4cef93ce52acaa9cf21 Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Sun, 25 Sep 2016 17:32:38 +0800 Subject: [PATCH 20/22] Added customised CSS --- src/seedu/addressbook/ui/Grape.css | 15 +++++++++++++++ src/seedu/addressbook/ui/LightTheme.css | 15 +++++++++++++++ src/seedu/addressbook/ui/MochaTheme.css | 15 +++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 src/seedu/addressbook/ui/Grape.css create mode 100644 src/seedu/addressbook/ui/LightTheme.css create mode 100644 src/seedu/addressbook/ui/MochaTheme.css diff --git a/src/seedu/addressbook/ui/Grape.css b/src/seedu/addressbook/ui/Grape.css new file mode 100644 index 000000000..46b8660df --- /dev/null +++ b/src/seedu/addressbook/ui/Grape.css @@ -0,0 +1,15 @@ +.text-field { + -fx-font-size: 12pt; + -fx-font-family: "Consolas"; + -fx-font-weight: bold; + -fx-text-fill: #FFFFFF; + -fx-control-inner-background: derive(#8E1AB2,20%); +} + +.text-area { + -fx-background-color: #8E1AB2; + -fx-control-inner-background: #8E1AB2; + -fx-font-family: "Segoe UI Semibold"; + -fx-font-size: 10pt; + -fx-padding: 5 5 5 5; +} \ No newline at end of file diff --git a/src/seedu/addressbook/ui/LightTheme.css b/src/seedu/addressbook/ui/LightTheme.css new file mode 100644 index 000000000..35fe562aa --- /dev/null +++ b/src/seedu/addressbook/ui/LightTheme.css @@ -0,0 +1,15 @@ +.text-field { + -fx-font-size: 12pt; + -fx-font-family: "Consolas"; + -fx-font-weight: bold; + -fx-text-fill: grey; + -fx-control-inner-background: derive(#eeeeee,20%); +} + +.text-area { + -fx-background-color: white; + -fx-control-inner-background: white; + -fx-font-family: "Segoe UI Semibold"; + -fx-font-size: 10pt; + -fx-padding: 5 5 5 5; +} \ No newline at end of file diff --git a/src/seedu/addressbook/ui/MochaTheme.css b/src/seedu/addressbook/ui/MochaTheme.css new file mode 100644 index 000000000..6bb241543 --- /dev/null +++ b/src/seedu/addressbook/ui/MochaTheme.css @@ -0,0 +1,15 @@ +.text-field { + -fx-font-size: 12pt; + -fx-font-family: "Consolas"; + -fx-font-weight: bold; + -fx-text-fill: #A14200; + -fx-control-inner-background: derive(#46961F,20%); +} + +.text-area { + -fx-background-color: #46961F; + -fx-control-inner-background: #46961F; + -fx-font-family: "Segoe UI Semibold"; + -fx-font-size: 10pt; + -fx-padding: 5 5 5 5; +} \ No newline at end of file From 53e02048dd28791425beed15703042db1d0a01bd Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Sun, 25 Sep 2016 17:33:55 +0800 Subject: [PATCH 21/22] Added commands into GUI --- src/seedu/addressbook/ui/Gui.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/seedu/addressbook/ui/Gui.java b/src/seedu/addressbook/ui/Gui.java index 20a7833c1..278ec5d40 100644 --- a/src/seedu/addressbook/ui/Gui.java +++ b/src/seedu/addressbook/ui/Gui.java @@ -23,27 +23,36 @@ public class Gui { private MainWindow mainWindow; private String version; - + private static Stage stage; + public Gui(Logic logic, String version) { this.logic = logic; this.version = version; } public void start(Stage stage, Stoppable mainApp) throws IOException { - mainWindow = createMainWindow(stage, mainApp); + Gui.stage = stage; + mainWindow = createMainWindow(mainApp); mainWindow.displayWelcomeMessage(version, logic.getStorageFilePath()); } - private MainWindow createMainWindow(Stage stage, Stoppable mainApp) throws IOException{ + private MainWindow createMainWindow(Stoppable mainApp) throws IOException { FXMLLoader loader = new FXMLLoader(); loader.setLocation(Main.class.getResource("ui" + File.separator + "mainwindow.fxml")); stage.setTitle(version); stage.setScene(new Scene(loader.load(), INITIAL_WINDOW_WIDTH, INITIAL_WINDOW_HEIGHT)); + changeTheme("Dark"); stage.show(); MainWindow mainWindow = loader.getController(); mainWindow.setLogic(logic); mainWindow.setMainApp(mainApp); return mainWindow; } + + public static void changeTheme(String newThemeName) { + stage.getScene().getStylesheets().clear(); + stage.getScene().getStylesheets() + .add(Main.class.getResource("ui/" + newThemeName + "Theme.css").toExternalForm()); + } } From 7341c2203e83d2b1be679db75c271d431d487aa3 Mon Sep 17 00:00:00 2001 From: Poh Yee Heng Date: Sun, 25 Sep 2016 17:34:08 +0800 Subject: [PATCH 22/22] no message --- src/seedu/addressbook/ui/mainwindow.fxml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/seedu/addressbook/ui/mainwindow.fxml b/src/seedu/addressbook/ui/mainwindow.fxml index dafeaf6a7..bfc35e955 100644 --- a/src/seedu/addressbook/ui/mainwindow.fxml +++ b/src/seedu/addressbook/ui/mainwindow.fxml @@ -4,7 +4,7 @@ -