From 8519bf4da185f2ec70a1d15a4270498d652b06e4 Mon Sep 17 00:00:00 2001 From: Ray-97 Date: Tue, 25 Feb 2020 13:58:39 +0800 Subject: [PATCH 1/2] assisted refactoring to remove address --- .gitattributes | 2 +- .gitignore | 42 +- .travis.yml | 48 +- LICENSE | 42 +- README.adoc | 72 +- _config.yml | 2 +- appveyor.yml | 36 +- build.gradle | 310 +++---- config/checkstyle/checkstyle.xml | 848 ++++++++--------- config/checkstyle/suppressions.xml | 18 +- config/travis/check-eof-newline.sh | 36 +- config/travis/check-line-endings.sh | 38 +- config/travis/check-trailing-whitespace.sh | 52 +- config/travis/deploy_github_pages.sh | 84 +- config/travis/run-checks.sh | 22 +- copyright.txt | 18 +- docs/AboutUs.adoc | 112 +-- docs/ContactUs.adoc | 14 +- docs/DevOps.adoc | 96 +- docs/DeveloperGuide.adoc | 850 +++++++++--------- docs/Documentation.adoc | 246 ++--- docs/LearningOutcomes.adoc | 432 ++++----- docs/SettingUp.adoc | 168 ++-- docs/Testing.adoc | 104 +-- docs/UserGuide.adoc | 354 ++++---- docs/UsingAppVeyor.adoc | 188 ++-- docs/UsingCheckstyle.adoc | 96 +- docs/UsingCoveralls.adoc | 126 +-- docs/UsingGradle.adoc | 198 ++-- docs/UsingNetlify.adoc | 118 +-- docs/UsingPlantUml.adoc | 422 ++++----- docs/UsingTravis.adoc | 280 +++--- docs/diagrams/ArchitectureDiagram.puml | 84 +- .../diagrams/ArchitectureSequenceDiagram.puml | 74 +- docs/diagrams/BetterModelClassDiagram.puml | 42 +- docs/diagrams/CommitActivityDiagram.puml | 30 +- docs/diagrams/DeleteSequenceDiagram.puml | 138 +-- docs/diagrams/LogicClassDiagram.puml | 124 +-- docs/diagrams/ModelClassDiagram.puml | 112 +-- docs/diagrams/StorageClassDiagram.puml | 48 +- docs/diagrams/UiClassDiagram.puml | 120 +-- docs/diagrams/UndoRedoState0.puml | 40 +- docs/diagrams/UndoRedoState1.puml | 44 +- docs/diagrams/UndoRedoState2.puml | 40 +- docs/diagrams/UndoRedoState3.puml | 40 +- docs/diagrams/UndoRedoState4.puml | 40 +- docs/diagrams/UndoRedoState5.puml | 42 +- docs/diagrams/UndoSequenceDiagram.puml | 106 +-- .../diagrams/add-remark/CommandInterface.puml | 68 +- docs/diagrams/add-remark/ParserInterface.puml | 38 +- docs/diagrams/plantuml/AbeforeC.puml | 22 +- docs/diagrams/plantuml/AllDown.puml | 50 +- docs/diagrams/plantuml/ArrowLength.puml | 54 +- docs/diagrams/plantuml/CbeforeA.puml | 22 +- docs/diagrams/plantuml/HiddenArrows.puml | 60 +- .../plantuml/PackagesAndConsistency.puml | 28 +- docs/diagrams/plantuml/UpAndDown.puml | 58 +- docs/diagrams/style.puml | 150 ++-- .../tracing/LogicSequenceDiagram.puml | 42 +- docs/index.adoc | 4 +- docs/stylesheets/asciidoctor.css | 814 ++++++++--------- docs/stylesheets/gh-pages.css | 428 ++++----- docs/team/johndoe.adoc | 144 +-- docs/templates/LICENSE | 48 +- docs/templates/_footer.html.slim | 24 +- docs/templates/_footnotes.html.slim | 14 +- docs/templates/_header.html.slim | 152 ++-- docs/templates/_toc.html.slim | 10 +- docs/templates/document.html.slim | 58 +- docs/templates/helpers.rb | 600 ++++++------- docs/tutorials/AddRemark.adoc | 850 +++++++++--------- docs/tutorials/RemovingFields.adoc | 234 ++--- docs/tutorials/TracingCode.adoc | 516 +++++------ gradle.properties | 12 +- gradle/wrapper/gradle-wrapper.properties | 10 +- gradlew.bak | 172 ++++ gradlew.bat | 168 ++-- .../java/seedu/address/AppParameters.java | 128 +-- src/main/java/seedu/address/Main.java | 50 +- src/main/java/seedu/address/MainApp.java | 366 ++++---- .../seedu/address/commons/core/Config.java | 126 +-- .../address/commons/core/GuiSettings.java | 146 +-- .../address/commons/core/LogsCenter.java | 224 ++--- .../seedu/address/commons/core/Messages.java | 26 +- .../seedu/address/commons/core/Version.java | 226 ++--- .../address/commons/core/index/Index.java | 108 +-- .../exceptions/DataConversionException.java | 22 +- .../exceptions/IllegalValueException.java | 42 +- .../seedu/address/commons/util/AppUtil.java | 78 +- .../address/commons/util/CollectionUtil.java | 70 +- .../address/commons/util/ConfigUtil.java | 46 +- .../seedu/address/commons/util/FileUtil.java | 166 ++-- .../seedu/address/commons/util/JsonUtil.java | 286 +++--- .../address/commons/util/StringUtil.java | 136 +-- src/main/java/seedu/address/logic/Logic.java | 100 +-- .../seedu/address/logic/LogicManager.java | 156 ++-- .../address/logic/commands/AddCommand.java | 134 +-- .../address/logic/commands/ClearCommand.java | 46 +- .../seedu/address/logic/commands/Command.java | 40 +- .../address/logic/commands/CommandResult.java | 142 +-- .../address/logic/commands/DeleteCommand.java | 106 +-- .../address/logic/commands/EditCommand.java | 439 +++++---- .../address/logic/commands/ExitCommand.java | 38 +- .../address/logic/commands/FindCommand.java | 84 +- .../address/logic/commands/HelpCommand.java | 42 +- .../address/logic/commands/ListCommand.java | 48 +- .../commands/exceptions/CommandException.java | 34 +- .../logic/parser/AddCommandParser.java | 117 ++- .../logic/parser/AddressBookParser.java | 152 ++-- .../logic/parser/ArgumentMultimap.java | 120 +-- .../logic/parser/ArgumentTokenizer.java | 296 +++--- .../seedu/address/logic/parser/CliSyntax.java | 30 +- .../logic/parser/DeleteCommandParser.java | 58 +- .../logic/parser/EditCommandParser.java | 160 ++-- .../logic/parser/FindCommandParser.java | 66 +- .../seedu/address/logic/parser/Parser.java | 32 +- .../address/logic/parser/ParserUtil.java | 232 +++-- .../seedu/address/logic/parser/Prefix.java | 78 +- .../parser/exceptions/ParseException.java | 34 +- .../java/seedu/address/model/AddressBook.java | 240 ++--- src/main/java/seedu/address/model/Model.java | 174 ++-- .../seedu/address/model/ModelManager.java | 302 +++---- .../address/model/ReadOnlyAddressBook.java | 34 +- .../address/model/ReadOnlyUserPrefs.java | 32 +- .../java/seedu/address/model/UserPrefs.java | 174 ++-- .../seedu/address/model/person/Address.java | 57 -- .../seedu/address/model/person/Email.java | 134 +-- .../java/seedu/address/model/person/Name.java | 118 +-- .../person/NameContainsKeywordsPredicate.java | 62 +- .../seedu/address/model/person/Person.java | 232 +++-- .../seedu/address/model/person/Phone.java | 106 +-- .../model/person/UniquePersonList.java | 274 +++--- .../exceptions/DuplicatePersonException.java | 22 +- .../exceptions/PersonNotFoundException.java | 12 +- .../java/seedu/address/model/tag/Tag.java | 108 +-- .../address/model/util/SampleDataUtil.java | 113 ++- .../address/storage/AddressBookStorage.java | 90 +- .../address/storage/JsonAdaptedPerson.java | 206 ++--- .../seedu/address/storage/JsonAdaptedTag.java | 96 +- .../storage/JsonAddressBookStorage.java | 160 ++-- .../storage/JsonSerializableAddressBook.java | 120 +-- .../address/storage/JsonUserPrefsStorage.java | 94 +- .../java/seedu/address/storage/Storage.java | 64 +- .../seedu/address/storage/StorageManager.java | 154 ++-- .../address/storage/UserPrefsStorage.java | 72 +- .../java/seedu/address/ui/CommandBox.java | 154 ++-- .../java/seedu/address/ui/HelpWindow.java | 204 ++--- .../java/seedu/address/ui/MainWindow.java | 386 ++++---- .../java/seedu/address/ui/PersonCard.java | 145 ++- .../seedu/address/ui/PersonListPanel.java | 92 +- .../java/seedu/address/ui/ResultDisplay.java | 56 +- .../seedu/address/ui/StatusBarFooter.java | 52 +- src/main/java/seedu/address/ui/Ui.java | 26 +- src/main/java/seedu/address/ui/UiManager.java | 172 ++-- src/main/java/seedu/address/ui/UiPart.java | 176 ++-- src/main/resources/view/CommandBox.fxml | 18 +- src/main/resources/view/DarkTheme.css | 704 +++++++-------- src/main/resources/view/Extensions.css | 40 +- src/main/resources/view/HelpWindow.fxml | 78 +- src/main/resources/view/MainWindow.fxml | 120 +-- src/main/resources/view/PersonListCard.fxml | 72 +- src/main/resources/view/PersonListPanel.fxml | 16 +- src/main/resources/view/ResultDisplay.fxml | 18 +- src/main/resources/view/StatusBarFooter.fxml | 24 +- src/test/data/ConfigUtilTest/EmptyConfig.json | 6 +- .../ConfigUtilTest/ExtraValuesConfig.json | 10 +- .../ConfigUtilTest/NotJsonFormatConfig.json | 2 +- .../data/ConfigUtilTest/TypicalConfig.json | 8 +- .../invalidAndValidPersonAddressBook.json | 26 +- .../invalidPersonAddressBook.json | 16 +- .../notJsonFormatAddressBook.json | 2 +- .../duplicatePersonAddressBook.json | 28 +- .../invalidPersonAddressBook.json | 16 +- .../typicalPersonsAddressBook.json | 92 +- .../EmptyUserPrefs.json | 6 +- .../ExtraValuesUserPref.json | 26 +- .../NotJsonFormatUserPrefs.json | 2 +- .../TypicalUserPref.json | 22 +- .../java/seedu/address/AppParametersTest.java | 116 +-- .../address/commons/core/ConfigTest.java | 54 +- .../address/commons/core/VersionTest.java | 270 +++--- .../address/commons/core/index/IndexTest.java | 120 +-- .../address/commons/util/AppUtilTest.java | 72 +- .../commons/util/CollectionUtilTest.java | 216 ++--- .../address/commons/util/ConfigUtilTest.java | 232 ++--- .../address/commons/util/FileUtilTest.java | 46 +- .../address/commons/util/JsonUtilTest.java | 90 +- .../address/commons/util/StringUtilTest.java | 286 +++--- .../seedu/address/logic/LogicManagerTest.java | 324 +++---- .../commands/AddCommandIntegrationTest.java | 90 +- .../logic/commands/AddCommandTest.java | 388 ++++---- .../logic/commands/ClearCommandTest.java | 64 +- .../logic/commands/CommandResultTest.java | 108 +-- .../logic/commands/CommandTestUtil.java | 256 +++--- .../logic/commands/DeleteCommandTest.java | 218 ++--- .../logic/commands/EditCommandTest.java | 346 +++---- .../commands/EditPersonDescriptorTest.java | 116 +-- .../logic/commands/ExitCommandTest.java | 40 +- .../logic/commands/FindCommandTest.java | 166 ++-- .../logic/commands/HelpCommandTest.java | 40 +- .../logic/commands/ListCommandTest.java | 78 +- .../logic/parser/AddCommandParserTest.java | 273 +++--- .../logic/parser/AddressBookParserTest.java | 202 ++--- .../logic/parser/ArgumentTokenizerTest.java | 300 +++---- .../logic/parser/CommandParserTestUtil.java | 76 +- .../logic/parser/DeleteCommandParserTest.java | 64 +- .../logic/parser/EditCommandParserTest.java | 409 ++++----- .../logic/parser/FindCommandParserTest.java | 68 +- .../address/logic/parser/ParserUtilTest.java | 366 ++++---- .../seedu/address/model/AddressBookTest.java | 204 ++--- .../seedu/address/model/ModelManagerTest.java | 264 +++--- .../seedu/address/model/UserPrefsTest.java | 42 +- .../address/model/person/AddressTest.java | 36 - .../seedu/address/model/person/EmailTest.java | 122 +-- .../NameContainsKeywordsPredicateTest.java | 150 ++-- .../seedu/address/model/person/NameTest.java | 80 +- .../address/model/person/PersonTest.java | 190 ++-- .../seedu/address/model/person/PhoneTest.java | 80 +- .../model/person/UniquePersonListTest.java | 340 +++---- .../java/seedu/address/model/tag/TagTest.java | 52 +- .../storage/JsonAdaptedPersonTest.java | 202 ++--- .../storage/JsonAddressBookStorageTest.java | 220 ++--- .../JsonSerializableAddressBookTest.java | 94 +- .../storage/JsonUserPrefsStorageTest.java | 246 ++--- .../address/storage/StorageManagerTest.java | 136 +-- .../address/testutil/AddressBookBuilder.java | 68 +- .../java/seedu/address/testutil/Assert.java | 68 +- .../testutil/EditPersonDescriptorBuilder.java | 171 ++-- .../seedu/address/testutil/PersonBuilder.java | 173 ++-- .../seedu/address/testutil/PersonUtil.java | 124 +-- .../testutil/SerializableTestClass.java | 144 +-- .../java/seedu/address/testutil/TestUtil.java | 110 +-- .../address/testutil/TypicalIndexes.java | 24 +- .../address/testutil/TypicalPersons.java | 152 ++-- .../java/seedu/address/ui/TestFxmlObject.java | 70 +- .../java/seedu/address/ui/UiPartTest.java | 228 ++--- .../view/UiPartTest/invalidFile.fxml | 2 +- .../resources/view/UiPartTest/validFile.fxml | 8 +- .../view/UiPartTest/validFileWithFxRoot.fxml | 12 +- 239 files changed, 15890 insertions(+), 15959 deletions(-) create mode 100644 gradlew.bak delete mode 100644 src/main/java/seedu/address/model/person/Address.java delete mode 100644 src/test/java/seedu/address/model/person/AddressTest.java diff --git a/.gitattributes b/.gitattributes index d72fd520b1c..a5bfe29a443 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -*.pdf binary +*.pdf binary diff --git a/.gitignore b/.gitignore index 5e59b862ba4..bcd26804024 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,21 @@ -# Gradle build files -/.gradle/ -/build/ -src/main/resources/docs/ - -# IDEA files -/.idea/ -/out/ -/*.iml - -# Storage/log files -/data/ -/config.json -/preferences.json -/*.log.* - -# Test sandbox files -src/test/data/sandbox/ - -# MacOS custom attributes files created by Finder -.DS_Store +# Gradle build files +/.gradle/ +/build/ +src/main/resources/docs/ + +# IDEA files +/.idea/ +/out/ +/*.iml + +# Storage/log files +/data/ +/config.json +/preferences.json +/*.log.* + +# Test sandbox files +src/test/data/sandbox/ + +# MacOS custom attributes files created by Finder +.DS_Store diff --git a/.travis.yml b/.travis.yml index 924a42eb8da..5fcca075990 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,24 @@ -language: java -matrix: - include: - - jdk: openjdk11 - -script: >- - ./config/travis/run-checks.sh && - ./gradlew clean checkstyleMain checkstyleTest test coverage coveralls asciidoctor - -deploy: - skip_cleanup: true - provider: script - script: ./config/travis/deploy_github_pages.sh - on: - branch: master - -before_cache: - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ - -cache: - directories: - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ +language: java +matrix: + include: + - jdk: openjdk11 + +script: >- + ./config/travis/run-checks.sh && + ./gradlew clean checkstyleMain checkstyleTest test coverage coveralls asciidoctor + +deploy: + skip_cleanup: true + provider: script + script: ./config/travis/deploy_github_pages.sh + on: + branch: master + +before_cache: + - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock + - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ + +cache: + directories: + - $HOME/.gradle/caches/ + - $HOME/.gradle/wrapper/ diff --git a/LICENSE b/LICENSE index 39b3478982c..bd32a13e5e5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2016 Software Engineering Education - FOSS Resources - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT License + +Copyright (c) 2016 Software Engineering Education - FOSS Resources + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.adoc b/README.adoc index 68942b0c92a..25b76d787ed 100644 --- a/README.adoc +++ b/README.adoc @@ -1,36 +1,36 @@ -= Address Book (Level 3) -ifdef::env-github,env-browser[:relfileprefix: docs/] - -https://travis-ci.org/se-edu/addressbook-level3[image:https://travis-ci.org/se-edu/addressbook-level3.svg?branch=master[Build Status]] -https://ci.appveyor.com/project/damithc/addressbook-level3[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]] -https://coveralls.io/github/se-edu/addressbook-level3?branch=master[image:https://coveralls.io/repos/github/se-edu/addressbook-level3/badge.svg?branch=master[Coverage Status]] -https://www.codacy.com/app/damith/addressbook-level3?utm_source=github.com&utm_medium=referral&utm_content=se-edu/addressbook-level3&utm_campaign=Badge_Grade[image:https://api.codacy.com/project/badge/Grade/fc0b7775cf7f4fdeaf08776f3d8e364a[Codacy Badge]] - - -ifdef::env-github[] -image::docs/images/Ui.png[width="600"] -endif::[] - -ifndef::env-github[] -image::images/Ui.png[width="600"] -endif::[] - -* This is a desktop Address Book application. It has a GUI but most of the user interactions happen using a CLI (Command Line Interface). -* It is a Java sample application intended for students learning Software Engineering while using Java as the main programming language. -* It is *written in OOP fashion*. It provides a *reasonably well-written* code example that is *significantly bigger* (around 6 KLoC)than what students usually write in beginner-level SE modules. - -== Site Map - -* <> -* <> -* <> -* <> -* <> - -== Acknowledgements - -* Some parts of this sample application were inspired by the excellent http://code.makery.ch/library/javafx-8-tutorial/[Java FX tutorial] by -_Marco Jakob_. -* Libraries used: https://openjfx.io/[JavaFX], https://github.com/FasterXML/jackson[Jackson], https://github.com/junit-team/junit5[JUnit5] - -== Licence : link:LICENSE[MIT] += Address Book (Level 3) +ifdef::env-github,env-browser[:relfileprefix: docs/] + +https://travis-ci.org/se-edu/addressbook-level3[image:https://travis-ci.org/se-edu/addressbook-level3.svg?branch=master[Build Status]] +https://ci.appveyor.com/project/damithc/addressbook-level3[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]] +https://coveralls.io/github/se-edu/addressbook-level3?branch=master[image:https://coveralls.io/repos/github/se-edu/addressbook-level3/badge.svg?branch=master[Coverage Status]] +https://www.codacy.com/app/damith/addressbook-level3?utm_source=github.com&utm_medium=referral&utm_content=se-edu/addressbook-level3&utm_campaign=Badge_Grade[image:https://api.codacy.com/project/badge/Grade/fc0b7775cf7f4fdeaf08776f3d8e364a[Codacy Badge]] + + +ifdef::env-github[] +image::docs/images/Ui.png[width="600"] +endif::[] + +ifndef::env-github[] +image::images/Ui.png[width="600"] +endif::[] + +* This is a desktop Address Book application. It has a GUI but most of the user interactions happen using a CLI (Command Line Interface). +* It is a Java sample application intended for students learning Software Engineering while using Java as the main programming language. +* It is *written in OOP fashion*. It provides a *reasonably well-written* code example that is *significantly bigger* (around 6 KLoC)than what students usually write in beginner-level SE modules. + +== Site Map + +* <> +* <> +* <> +* <> +* <> + +== Acknowledgements + +* Some parts of this sample application were inspired by the excellent http://code.makery.ch/library/javafx-8-tutorial/[Java FX tutorial] by +_Marco Jakob_. +* Libraries used: https://openjfx.io/[JavaFX], https://github.com/FasterXML/jackson[Jackson], https://github.com/junit-team/junit5[JUnit5] + +== Licence : link:LICENSE[MIT] diff --git a/_config.yml b/_config.yml index 277f1f2c510..76c8a8c1ccd 100644 --- a/_config.yml +++ b/_config.yml @@ -1 +1 @@ -theme: jekyll-theme-cayman +theme: jekyll-theme-cayman diff --git a/appveyor.yml b/appveyor.yml index 6f53e7cd2d6..229ccae4b7d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,18 +1,18 @@ -# AppVeyor configuration file -# For more details see https://www.appveyor.com/docs/build-configuration/ - -# Call on gradle to build and run tests -# --no-daemon: Prevent the daemon from launching to prevent file-in-use errors -# when we cache the ~/.gradle directory -build_script: - - gradlew.bat --no-daemon assemble checkstyleMain checkstyleTest - -test_script: - - gradlew.bat --no-daemon test - -environment: - JAVA_HOME: C:\Program Files\Java\jdk11 # Use 64-bit Java - -# Files/folders to preserve between builds to speed them up -cache: - - C:\Users\appveyor\.gradle +# AppVeyor configuration file +# For more details see https://www.appveyor.com/docs/build-configuration/ + +# Call on gradle to build and run tests +# --no-daemon: Prevent the daemon from launching to prevent file-in-use errors +# when we cache the ~/.gradle directory +build_script: + - gradlew.bat --no-daemon assemble checkstyleMain checkstyleTest + +test_script: + - gradlew.bat --no-daemon test + +environment: + JAVA_HOME: C:\Program Files\Java\jdk11 # Use 64-bit Java + +# Files/folders to preserve between builds to speed them up +cache: + - C:\Users\appveyor\.gradle diff --git a/build.gradle b/build.gradle index 93029ef8262..d63e2744873 100644 --- a/build.gradle +++ b/build.gradle @@ -1,155 +1,155 @@ -// Gradle Configuration File -// For more details take a look at the Java Quickstart chapter in the Gradle -// user guide available at http://gradle.org/docs/5.2.1/userguide/tutorial_java_projects.html - -import org.gradle.api.tasks.testing.logging.TestLogEvent - -plugins { - id 'java' - id 'jacoco' - id 'checkstyle' - id 'com.github.kt3k.coveralls' version '2.4.0' - id 'com.github.johnrengelman.shadow' version '4.0.4' - id 'org.asciidoctor.convert' version '1.5.6' - id 'application' -} - -// Specifies the entry point of the application -mainClassName = 'seedu.address.Main' - -sourceCompatibility = JavaVersion.VERSION_11 -targetCompatibility = JavaVersion.VERSION_11 - -repositories { - mavenCentral() - maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } -} - -checkstyle { - toolVersion = '8.1' -} - -jacocoTestReport { - reports { - xml.enabled false - csv.enabled false - html.destination file("${buildDir}/jacocoHtml") - } -} - -test { - useJUnitPlatform() -} - -dependencies { - String jUnitVersion = '5.4.0' - String javaFxVersion = '11' - - implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win' - implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac' - implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux' - implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win' - implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac' - implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux' - implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win' - implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac' - implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux' - implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win' - implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac' - implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux' - - implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.0' - implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.7.4' - - testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: jUnitVersion - - testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: jUnitVersion -} - -shadowJar { - archiveName = 'addressbook.jar' - - destinationDir = file("${buildDir}/jar/") -} - -task coverage(type: JacocoReport) { - sourceDirectories.from files(sourceSets.main.allSource.srcDirs) - classDirectories.from files(sourceSets.main.output) - executionData.from files(jacocoTestReport.executionData) - afterEvaluate { - classDirectories.from files(classDirectories.files.collect { - fileTree(dir: it, exclude: ['**/*.jar']) - }) - } - reports { - html.enabled = true - xml.enabled = true - } -} - -coveralls { - sourceDirs = sourceSets.main.allSource.srcDirs.absolutePath - jacocoReportPath = "${buildDir}/reports/jacoco/coverage/coverage.xml" -} - -tasks.coveralls { - dependsOn coverage - onlyIf { System.env.'CI' } -} - -test { - testLogging { - events TestLogEvent.FAILED, TestLogEvent.SKIPPED - - // Prints the currently running test's name in the CI's build log, - // so that we can check if tests are being silently skipped or - // stalling the build. - if (System.env.'CI') { - events << TestLogEvent.STARTED - } - } - - jacoco { - destinationFile = new File("${buildDir}/jacoco/test.exec") - } -} - -asciidoctor { - backends 'html5' - sourceDir 'docs' - outputDir "${buildDir}/docs" - - options = [ - template_dirs: [file("${sourceDir}/templates")], - ] - - attributes = [ - linkcss: true, - stylesheet: 'gh-pages.css', - 'source-highlighter': 'coderay', - icons: 'font', - experimental: true, - sectlinks: true, - idprefix: '', // for compatibility with GitHub preview - idseparator: '-', - 'site-root': "${sourceDir}", // must be the same as sourceDir, do not modify - 'site-name': 'AddressBook-Level3', - 'site-githuburl': 'https://github.com/se-edu/addressbook-level3', - 'site-seedu': true, // delete this line if your project is not a fork (not a SE-EDU project) - ] - - options['template_dirs'].each { - inputs.files fileTree(it) - } -} - -// Copies stylesheets into the directory containing generated HTML files as -// Asciidoctor does not copy linked CSS files to the output directory when rendering. -// This is needed for linked stylesheets and embedded stylesheets which import other files. -task copyStylesheets(type: Copy) { - from "${asciidoctor.sourceDir}/stylesheets" - into "${asciidoctor.outputDir}/html5/stylesheets" -} -asciidoctor.dependsOn copyStylesheets - -defaultTasks 'clean', 'test', 'coverage', 'asciidoctor' +// Gradle Configuration File +// For more details take a look at the Java Quickstart chapter in the Gradle +// user guide available at http://gradle.org/docs/5.2.1/userguide/tutorial_java_projects.html + +import org.gradle.api.tasks.testing.logging.TestLogEvent + +plugins { + id 'java' + id 'jacoco' + id 'checkstyle' + id 'com.github.kt3k.coveralls' version '2.4.0' + id 'com.github.johnrengelman.shadow' version '4.0.4' + id 'org.asciidoctor.convert' version '1.5.6' + id 'application' +} + +// Specifies the entry point of the application +mainClassName = 'seedu.address.Main' + +sourceCompatibility = JavaVersion.VERSION_11 +targetCompatibility = JavaVersion.VERSION_11 + +repositories { + mavenCentral() + maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } +} + +checkstyle { + toolVersion = '8.1' +} + +jacocoTestReport { + reports { + xml.enabled false + csv.enabled false + html.destination file("${buildDir}/jacocoHtml") + } +} + +test { + useJUnitPlatform() +} + +dependencies { + String jUnitVersion = '5.4.0' + String javaFxVersion = '11' + + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux' + implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux' + + implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.0' + implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.7.4' + + testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: jUnitVersion + + testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: jUnitVersion +} + +shadowJar { + archiveName = 'addressbook.jar' + + destinationDir = file("${buildDir}/jar/") +} + +task coverage(type: JacocoReport) { + sourceDirectories.from files(sourceSets.main.allSource.srcDirs) + classDirectories.from files(sourceSets.main.output) + executionData.from files(jacocoTestReport.executionData) + afterEvaluate { + classDirectories.from files(classDirectories.files.collect { + fileTree(dir: it, exclude: ['**/*.jar']) + }) + } + reports { + html.enabled = true + xml.enabled = true + } +} + +coveralls { + sourceDirs = sourceSets.main.allSource.srcDirs.absolutePath + jacocoReportPath = "${buildDir}/reports/jacoco/coverage/coverage.xml" +} + +tasks.coveralls { + dependsOn coverage + onlyIf { System.env.'CI' } +} + +test { + testLogging { + events TestLogEvent.FAILED, TestLogEvent.SKIPPED + + // Prints the currently running test's name in the CI's build log, + // so that we can check if tests are being silently skipped or + // stalling the build. + if (System.env.'CI') { + events << TestLogEvent.STARTED + } + } + + jacoco { + destinationFile = new File("${buildDir}/jacoco/test.exec") + } +} + +asciidoctor { + backends 'html5' + sourceDir 'docs' + outputDir "${buildDir}/docs" + + options = [ + template_dirs: [file("${sourceDir}/templates")], + ] + + attributes = [ + linkcss: true, + stylesheet: 'gh-pages.css', + 'source-highlighter': 'coderay', + icons: 'font', + experimental: true, + sectlinks: true, + idprefix: '', // for compatibility with GitHub preview + idseparator: '-', + 'site-root': "${sourceDir}", // must be the same as sourceDir, do not modify + 'site-name': 'AddressBook-Level3', + 'site-githuburl': 'https://github.com/se-edu/addressbook-level3', + 'site-seedu': true, // delete this line if your project is not a fork (not a SE-EDU project) + ] + + options['template_dirs'].each { + inputs.files fileTree(it) + } +} + +// Copies stylesheets into the directory containing generated HTML files as +// Asciidoctor does not copy linked CSS files to the output directory when rendering. +// This is needed for linked stylesheets and embedded stylesheets which import other files. +task copyStylesheets(type: Copy) { + from "${asciidoctor.sourceDir}/stylesheets" + into "${asciidoctor.outputDir}/html5/stylesheets" +} +asciidoctor.dependsOn copyStylesheets + +defaultTasks 'clean', 'test', 'coverage', 'asciidoctor' diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 24eaeb44965..3402ea95d8f 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -1,424 +1,424 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml index dabcd1ff4e3..2b6bcbca8a8 100644 --- a/config/checkstyle/suppressions.xml +++ b/config/checkstyle/suppressions.xml @@ -1,9 +1,9 @@ - - - - - - - + + + + + + + diff --git a/config/travis/check-eof-newline.sh b/config/travis/check-eof-newline.sh index b771f3988dd..a62238ae053 100755 --- a/config/travis/check-eof-newline.sh +++ b/config/travis/check-eof-newline.sh @@ -1,18 +1,18 @@ -#!/bin/sh -# Checks that all text files end with a newline. - -ret=0 - -# Preserve filename with spaces by only splitting on newlines. -IFS=' -' - -for filename in $(git grep --cached -I -l -e '' -- ':/'); do - if [ "$(tail -c 1 "./$filename")" != '' ]; then - line="$(wc -l "./$filename" | cut -d' ' -f1)" - echo "ERROR:$filename:$line: no newline at EOF." - ret=1 - fi -done - -exit $ret +#!/bin/sh +# Checks that all text files end with a newline. + +ret=0 + +# Preserve filename with spaces by only splitting on newlines. +IFS=' +' + +for filename in $(git grep --cached -I -l -e '' -- ':/'); do + if [ "$(tail -c 1 "./$filename")" != '' ]; then + line="$(wc -l "./$filename" | cut -d' ' -f1)" + echo "ERROR:$filename:$line: no newline at EOF." + ret=1 + fi +done + +exit $ret diff --git a/config/travis/check-line-endings.sh b/config/travis/check-line-endings.sh index 3de67ea87f6..e75394a601e 100755 --- a/config/travis/check-line-endings.sh +++ b/config/travis/check-line-endings.sh @@ -1,19 +1,19 @@ -#!/bin/sh -# Checks for prohibited line endings. -# Prohibited line endings: \r\n - -git grep --cached -I -n --no-color -P '\r$' -- ':/' | -awk ' - BEGIN { - FS = ":" - OFS = ":" - ret = 0 - } - { - ret = 1 - print "ERROR", $1, $2, " prohibited \\r\\n line ending, use \\n instead." - } - END { - exit ret - } -' +#!/bin/sh +# Checks for prohibited line endings. +# Prohibited line endings: \r\n + +git grep --cached -I -n --no-color -P '\r$' -- ':/' | +awk ' + BEGIN { + FS = ":" + OFS = ":" + ret = 0 + } + { + ret = 1 + print "ERROR", $1, $2, " prohibited \\r\\n line ending, use \\n instead." + } + END { + exit ret + } +' diff --git a/config/travis/check-trailing-whitespace.sh b/config/travis/check-trailing-whitespace.sh index 33841caa81f..a2f9ae4b4c4 100755 --- a/config/travis/check-trailing-whitespace.sh +++ b/config/travis/check-trailing-whitespace.sh @@ -1,26 +1,26 @@ -#!/bin/sh -# Checks for trailing whitespace - -git grep --cached -I -n --no-color -P '[ \t]+$' -- ':/' | -awk ' - BEGIN { - FS = ":" - OFS = ":" - ret = 0 - } - { - # Only warn for markdown files (*.md) to accomodate text editors - # which do not properly handle trailing whitespace. - # (e.g. GitHub web editor) - if ($1 ~ /\.md$/) { - severity = "WARN" - } else { - severity = "ERROR" - ret = 1 - } - print severity, $1, $2, " trailing whitespace." - } - END { - exit ret - } -' +#!/bin/sh +# Checks for trailing whitespace + +git grep --cached -I -n --no-color -P '[ \t]+$' -- ':/' | +awk ' + BEGIN { + FS = ":" + OFS = ":" + ret = 0 + } + { + # Only warn for markdown files (*.md) to accomodate text editors + # which do not properly handle trailing whitespace. + # (e.g. GitHub web editor) + if ($1 ~ /\.md$/) { + severity = "WARN" + } else { + severity = "ERROR" + ret = 1 + } + print severity, $1, $2, " trailing whitespace." + } + END { + exit ret + } +' diff --git a/config/travis/deploy_github_pages.sh b/config/travis/deploy_github_pages.sh index 2d8909741ab..9c24e131d33 100755 --- a/config/travis/deploy_github_pages.sh +++ b/config/travis/deploy_github_pages.sh @@ -1,42 +1,42 @@ -#!/bin/sh -# Pushes files generated by Asciidoctor and associated files to gh-pages branch for commits to master branch. - -set -o errexit # exit with nonzero exit code if any line fails - -if [ -z "$GITHUB_TOKEN" ]; then - echo 'GITHUB_TOKEN is not set up in Travis. Skipping deploy.' - exit 0 -fi; - -set -o nounset # exit if variable is unset - -cd build/docs/html5 - -git init -git config user.name 'Deployment Bot (Travis)' -git config user.email 'deploy@travis-ci.org' - -git config credential.helper 'store --file=.git/credentials' -echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials - -git remote add upstream "https://github.com/${TRAVIS_REPO_SLUG}.git" - -# Reset to gh-pages branch, or create orphan branch if gh-pages does not exist in remote. -if git ls-remote --exit-code --heads upstream gh-pages; then - git fetch --depth=1 upstream gh-pages - git reset upstream/gh-pages -elif [ $? -eq 2 ]; then # exit code of git ls-remote is 2 if branch does not exist - git checkout --orphan gh-pages -else # error occurred - exit $? -fi - -# Exit if there are no changes to gh-pages files. -if changes=$(git status --porcelain) && [ -z "$changes" ]; then - echo 'No changes to GitHub Pages files; exiting.' - exit 0 -fi - -git add -A . -git commit -m "Rebuild pages at ${TRAVIS_COMMIT}" -git push --quiet upstream HEAD:gh-pages +#!/bin/sh +# Pushes files generated by Asciidoctor and associated files to gh-pages branch for commits to master branch. + +set -o errexit # exit with nonzero exit code if any line fails + +if [ -z "$GITHUB_TOKEN" ]; then + echo 'GITHUB_TOKEN is not set up in Travis. Skipping deploy.' + exit 0 +fi; + +set -o nounset # exit if variable is unset + +cd build/docs/html5 + +git init +git config user.name 'Deployment Bot (Travis)' +git config user.email 'deploy@travis-ci.org' + +git config credential.helper 'store --file=.git/credentials' +echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials + +git remote add upstream "https://github.com/${TRAVIS_REPO_SLUG}.git" + +# Reset to gh-pages branch, or create orphan branch if gh-pages does not exist in remote. +if git ls-remote --exit-code --heads upstream gh-pages; then + git fetch --depth=1 upstream gh-pages + git reset upstream/gh-pages +elif [ $? -eq 2 ]; then # exit code of git ls-remote is 2 if branch does not exist + git checkout --orphan gh-pages +else # error occurred + exit $? +fi + +# Exit if there are no changes to gh-pages files. +if changes=$(git status --porcelain) && [ -z "$changes" ]; then + echo 'No changes to GitHub Pages files; exiting.' + exit 0 +fi + +git add -A . +git commit -m "Rebuild pages at ${TRAVIS_COMMIT}" +git push --quiet upstream HEAD:gh-pages diff --git a/config/travis/run-checks.sh b/config/travis/run-checks.sh index 7aad1e96220..3c31784e92e 100755 --- a/config/travis/run-checks.sh +++ b/config/travis/run-checks.sh @@ -1,11 +1,11 @@ -#!/bin/sh -# Runs all check-* scripts, and returns a non-zero exit code if any of them fail. - -dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) && -ret=0 && -for checkscript in "$dir"/check-*; do - if ! "$checkscript"; then - ret=1 - fi -done -exit $ret +#!/bin/sh +# Runs all check-* scripts, and returns a non-zero exit code if any of them fail. + +dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) && +ret=0 && +for checkscript in "$dir"/check-*; do + if ! "$checkscript"; then + ret=1 + fi +done +exit $ret diff --git a/copyright.txt b/copyright.txt index 93aa2a39ce2..96d5376a8e1 100644 --- a/copyright.txt +++ b/copyright.txt @@ -1,9 +1,9 @@ -Some code adapted from http://code.makery.ch/library/javafx-8-tutorial/ by Marco Jakob - -Copyright by Susumu Yoshida - http://www.mcdodesign.com/ -- address_book_32.png -- AddressApp.ico - -Copyright by Jan Jan Kovařík - http://glyphicons.com/ -- calendar.png -- edit.png +Some code adapted from http://code.makery.ch/library/javafx-8-tutorial/ by Marco Jakob + +Copyright by Susumu Yoshida - http://www.mcdodesign.com/ +- address_book_32.png +- AddressApp.ico + +Copyright by Jan Jan Kovařík - http://glyphicons.com/ +- calendar.png +- edit.png diff --git a/docs/AboutUs.adoc b/docs/AboutUs.adoc index 458e6134f45..ffa99689f7e 100644 --- a/docs/AboutUs.adoc +++ b/docs/AboutUs.adoc @@ -1,56 +1,56 @@ -= About Us -:site-section: AboutUs -:relfileprefix: team/ -:imagesDir: images -:stylesDir: stylesheets - -AddressBook - Level 3 was developed by the https://se-edu.github.io/docs/Team.html[se-edu] team. + -_{The dummy content given below serves as a placeholder to be used by future forks of the project.}_ + -{empty} + -We are a team based in the http://www.comp.nus.edu.sg[School of Computing, National University of Singapore]. - -== Project Team - -=== John Doe -image::damithc.jpg[width="150", align="left"] -{empty}[http://www.comp.nus.edu.sg/~damithch[homepage]] [https://github.com/damithc[github]] [<>] - -Role: Project Advisor - -''' - -=== John Roe -image::lejolly.jpg[width="150", align="left"] -{empty}[http://github.com/lejolly[github]] [<>] - -Role: Team Lead + -Responsibilities: UI - -''' - -=== Johnny Doe -image::yijinl.jpg[width="150", align="left"] -{empty}[http://github.com/yijinl[github]] [<>] - -Role: Developer + -Responsibilities: Data - -''' - -=== Johnny Roe -image::m133225.jpg[width="150", align="left"] -{empty}[http://github.com/m133225[github]] [<>] - -Role: Developer + -Responsibilities: Dev Ops + Threading - -''' - -=== Benson Meier -image::yl_coder.jpg[width="150", align="left"] -{empty}[http://github.com/yl-coder[github]] [<>] - -Role: Developer + -Responsibilities: UI - -''' += About Us +:site-section: AboutUs +:relfileprefix: team/ +:imagesDir: images +:stylesDir: stylesheets + +AddressBook - Level 3 was developed by the https://se-edu.github.io/docs/Team.html[se-edu] team. + +_{The dummy content given below serves as a placeholder to be used by future forks of the project.}_ + +{empty} + +We are a team based in the http://www.comp.nus.edu.sg[School of Computing, National University of Singapore]. + +== Project Team + +=== John Doe +image::damithc.jpg[width="150", align="left"] +{empty}[http://www.comp.nus.edu.sg/~damithch[homepage]] [https://github.com/damithc[github]] [<>] + +Role: Project Advisor + +''' + +=== John Roe +image::lejolly.jpg[width="150", align="left"] +{empty}[http://github.com/lejolly[github]] [<>] + +Role: Team Lead + +Responsibilities: UI + +''' + +=== Johnny Doe +image::yijinl.jpg[width="150", align="left"] +{empty}[http://github.com/yijinl[github]] [<>] + +Role: Developer + +Responsibilities: Data + +''' + +=== Johnny Roe +image::m133225.jpg[width="150", align="left"] +{empty}[http://github.com/m133225[github]] [<>] + +Role: Developer + +Responsibilities: Dev Ops + Threading + +''' + +=== Benson Meier +image::yl_coder.jpg[width="150", align="left"] +{empty}[http://github.com/yl-coder[github]] [<>] + +Role: Developer + +Responsibilities: UI + +''' diff --git a/docs/ContactUs.adoc b/docs/ContactUs.adoc index 81be279ef6d..17bb22a3a7e 100644 --- a/docs/ContactUs.adoc +++ b/docs/ContactUs.adoc @@ -1,7 +1,7 @@ -= Contact Us -:site-section: ContactUs -:stylesDir: stylesheets - -* *Bug reports, Suggestions* : Post in our https://github.com/se-edu/addressbook-level3/issues[issue tracker] if you noticed bugs or have suggestions on how to improve. -* *Contributing* : We welcome pull requests. Follow the process described https://github.com/oss-generic/process[here] -* *Email us* : You can also reach us at `damith [at] comp.nus.edu.sg` += Contact Us +:site-section: ContactUs +:stylesDir: stylesheets + +* *Bug reports, Suggestions* : Post in our https://github.com/se-edu/addressbook-level3/issues[issue tracker] if you noticed bugs or have suggestions on how to improve. +* *Contributing* : We welcome pull requests. Follow the process described https://github.com/oss-generic/process[here] +* *Email us* : You can also reach us at `damith [at] comp.nus.edu.sg` diff --git a/docs/DevOps.adoc b/docs/DevOps.adoc index 2aa5a6bc0c1..165e79d2505 100644 --- a/docs/DevOps.adoc +++ b/docs/DevOps.adoc @@ -1,48 +1,48 @@ -= AddressBook Level 3 - Dev Ops -:site-section: DeveloperGuide -:toc: -:toc-title: -:toc-placement: preamble -:sectnums: -:imagesDir: images -:stylesDir: stylesheets -:xrefstyle: full -ifdef::env-github[] -:tip-caption: :bulb: -:note-caption: :information_source: -:warning-caption: :warning: -endif::[] -:repoURL: https://github.com/se-edu/addressbook-level3/tree/master - -== Build Automation - -See <> to learn how to use Gradle for build automation. - -== Continuous Integration - -We use https://travis-ci.org/[Travis CI] and https://www.appveyor.com/[AppVeyor] to perform _Continuous Integration_ on our projects. See <> and <> for more details. - -== Coverage Reporting - -We use https://coveralls.io/[Coveralls] to track the code coverage of our projects. See <> for more details. - -== Documentation Previews - -When a pull request has changes to asciidoc files, you can use https://www.netlify.com/[Netlify] to see a preview of how the HTML version of those asciidoc files will look like when the pull request is merged. See <> for more details. - -== Making a Release - -Here are the steps to create a new release. - -. Update the version number in link:{repoURL}/src/main/java/seedu/address/MainApp.java[`MainApp.java`]. -. Generate a JAR file <>. -. Tag the repo with the version number. e.g. `v0.1` -. https://help.github.com/articles/creating-releases/[Create a new release using GitHub] and upload the JAR file you created. - -== Managing Dependencies - -A project often depends on third-party libraries. For example, Address Book depends on the https://github.com/FasterXML/jackson[Jackson library] for JSON parsing. Managing these _dependencies_ can be automated using Gradle. For example, Gradle can download the dependencies automatically, which is better than these alternatives: - -[loweralpha] -. Include those libraries in the repo (this bloats the repo size) -. Require developers to download those libraries manually (this creates extra work for developers) += AddressBook Level 3 - Dev Ops +:site-section: DeveloperGuide +:toc: +:toc-title: +:toc-placement: preamble +:sectnums: +:imagesDir: images +:stylesDir: stylesheets +:xrefstyle: full +ifdef::env-github[] +:tip-caption: :bulb: +:note-caption: :information_source: +:warning-caption: :warning: +endif::[] +:repoURL: https://github.com/se-edu/addressbook-level3/tree/master + +== Build Automation + +See <> to learn how to use Gradle for build automation. + +== Continuous Integration + +We use https://travis-ci.org/[Travis CI] and https://www.appveyor.com/[AppVeyor] to perform _Continuous Integration_ on our projects. See <> and <> for more details. + +== Coverage Reporting + +We use https://coveralls.io/[Coveralls] to track the code coverage of our projects. See <> for more details. + +== Documentation Previews + +When a pull request has changes to asciidoc files, you can use https://www.netlify.com/[Netlify] to see a preview of how the HTML version of those asciidoc files will look like when the pull request is merged. See <> for more details. + +== Making a Release + +Here are the steps to create a new release. + +. Update the version number in link:{repoURL}/src/main/java/seedu/address/MainApp.java[`MainApp.java`]. +. Generate a JAR file <>. +. Tag the repo with the version number. e.g. `v0.1` +. https://help.github.com/articles/creating-releases/[Create a new release using GitHub] and upload the JAR file you created. + +== Managing Dependencies + +A project often depends on third-party libraries. For example, Address Book depends on the https://github.com/FasterXML/jackson[Jackson library] for JSON parsing. Managing these _dependencies_ can be automated using Gradle. For example, Gradle can download the dependencies automatically, which is better than these alternatives: + +[loweralpha] +. Include those libraries in the repo (this bloats the repo size) +. Require developers to download those libraries manually (this creates extra work for developers) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 3d65905a853..eca95db6e9c 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -1,425 +1,425 @@ -= AddressBook Level 3 - Developer Guide -:site-section: DeveloperGuide -:toc: -:toc-title: -:toc-placement: preamble -:sectnums: -:imagesDir: images -:stylesDir: stylesheets -:xrefstyle: full -ifdef::env-github[] -:tip-caption: :bulb: -:note-caption: :information_source: -:warning-caption: :warning: -endif::[] -:repoURL: https://github.com/se-edu/addressbook-level3/tree/master - -By: `Team SE-EDU`      Since: `Jun 2016`      Licence: `MIT` - -== Setting up - -Refer to the guide <>. - -== Design - -[[Design-Architecture]] -=== Architecture - -.Architecture Diagram -image::ArchitectureDiagram.png[] - -The *_Architecture Diagram_* given above explains the high-level design of the App. Given below is a quick overview of each component. - -[TIP] -The `.puml` files used to create diagrams in this document can be found in the link:{repoURL}/docs/diagrams/[diagrams] folder. -Refer to the <> to learn how to create and edit diagrams. - -`Main` has two classes called link:{repoURL}/src/main/java/seedu/address/Main.java[`Main`] and link:{repoURL}/src/main/java/seedu/address/MainApp.java[`MainApp`]. It is responsible for, - -* At app launch: Initializes the components in the correct sequence, and connects them up with each other. -* At shut down: Shuts down the components and invokes cleanup method where necessary. - -<> represents a collection of classes used by multiple other components. -The following class plays an important role at the architecture level: - -* `LogsCenter` : Used by many classes to write log messages to the App's log file. - -The rest of the App consists of four components. - -* <>: The UI of the App. -* <>: The command executor. -* <>: Holds the data of the App in-memory. -* <>: Reads data from, and writes data to, the hard disk. - -Each of the four components - -* Defines its _API_ in an `interface` with the same name as the Component. -* Exposes its functionality using a `{Component Name}Manager` class. - -For example, the `Logic` component (see the class diagram given below) defines it's API in the `Logic.java` interface and exposes its functionality using the `LogicManager.java` class. - -.Class Diagram of the Logic Component -image::LogicClassDiagram.png[] - -[discrete] -==== How the architecture components interact with each other - -The _Sequence Diagram_ below shows how the components interact with each other for the scenario where the user issues the command `delete 1`. - -.Component interactions for `delete 1` command -image::ArchitectureSequenceDiagram.png[] - -The sections below give more details of each component. - -[[Design-Ui]] -=== UI component - -.Structure of the UI Component -image::UiClassDiagram.png[] - -*API* : link:{repoURL}/src/main/java/seedu/address/ui/Ui.java[`Ui.java`] - -The UI consists of a `MainWindow` that is made up of parts e.g.`CommandBox`, `ResultDisplay`, `PersonListPanel`, `StatusBarFooter` etc. All these, including the `MainWindow`, inherit from the abstract `UiPart` class. - -The `UI` component uses JavaFx UI framework. The layout of these UI parts are defined in matching `.fxml` files that are in the `src/main/resources/view` folder. For example, the layout of the link:{repoURL}/src/main/java/seedu/address/ui/MainWindow.java[`MainWindow`] is specified in link:{repoURL}/src/main/resources/view/MainWindow.fxml[`MainWindow.fxml`] - -The `UI` component, - -* Executes user commands using the `Logic` component. -* Listens for changes to `Model` data so that the UI can be updated with the modified data. - -[[Design-Logic]] -=== Logic component - -[[fig-LogicClassDiagram]] -.Structure of the Logic Component -image::LogicClassDiagram.png[] - -*API* : -link:{repoURL}/src/main/java/seedu/address/logic/Logic.java[`Logic.java`] - -. `Logic` uses the `AddressBookParser` class to parse the user command. -. This results in a `Command` object which is executed by the `LogicManager`. -. The command execution can affect the `Model` (e.g. adding a person). -. The result of the command execution is encapsulated as a `CommandResult` object which is passed back to the `Ui`. -. In addition, the `CommandResult` object can also instruct the `Ui` to perform certain actions, such as displaying help to the user. - -Given below is the Sequence Diagram for interactions within the `Logic` component for the `execute("delete 1")` API call. - -.Interactions Inside the Logic Component for the `delete 1` Command -image::DeleteSequenceDiagram.png[] - -NOTE: The lifeline for `DeleteCommandParser` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. - -[[Design-Model]] -=== Model component - -.Structure of the Model Component -image::ModelClassDiagram.png[] - -*API* : link:{repoURL}/src/main/java/seedu/address/model/Model.java[`Model.java`] - -The `Model`, - -* stores a `UserPref` object that represents the user's preferences. -* stores the Address Book data. -* exposes an unmodifiable `ObservableList` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change. -* does not depend on any of the other three components. - -[NOTE] -As a more OOP model, we can store a `Tag` list in `Address Book`, which `Person` can reference. This would allow `Address Book` to only require one `Tag` object per unique `Tag`, instead of each `Person` needing their own `Tag` object. An example of how such a model may look like is given below. + - + -image:BetterModelClassDiagram.png[] - -[[Design-Storage]] -=== Storage component - -.Structure of the Storage Component -image::StorageClassDiagram.png[] - -*API* : link:{repoURL}/src/main/java/seedu/address/storage/Storage.java[`Storage.java`] - -The `Storage` component, - -* can save `UserPref` objects in json format and read it back. -* can save the Address Book data in json format and read it back. - -[[Design-Commons]] -=== Common classes - -Classes used by multiple components are in the `seedu.addressbook.commons` package. - -== Implementation - -This section describes some noteworthy details on how certain features are implemented. - -// tag::undoredo[] -=== [Proposed] Undo/Redo feature -==== Proposed Implementation - -The undo/redo mechanism is facilitated by `VersionedAddressBook`. -It extends `AddressBook` with an undo/redo history, stored internally as an `addressBookStateList` and `currentStatePointer`. -Additionally, it implements the following operations: - -* `VersionedAddressBook#commit()` -- Saves the current address book state in its history. -* `VersionedAddressBook#undo()` -- Restores the previous address book state from its history. -* `VersionedAddressBook#redo()` -- Restores a previously undone address book state from its history. - -These operations are exposed in the `Model` interface as `Model#commitAddressBook()`, `Model#undoAddressBook()` and `Model#redoAddressBook()` respectively. - -Given below is an example usage scenario and how the undo/redo mechanism behaves at each step. - -Step 1. The user launches the application for the first time. The `VersionedAddressBook` will be initialized with the initial address book state, and the `currentStatePointer` pointing to that single address book state. - -image::UndoRedoState0.png[] - -Step 2. The user executes `delete 5` command to delete the 5th person in the address book. The `delete` command calls `Model#commitAddressBook()`, causing the modified state of the address book after the `delete 5` command executes to be saved in the `addressBookStateList`, and the `currentStatePointer` is shifted to the newly inserted address book state. - -image::UndoRedoState1.png[] - -Step 3. The user executes `add n/David ...` to add a new person. The `add` command also calls `Model#commitAddressBook()`, causing another modified address book state to be saved into the `addressBookStateList`. - -image::UndoRedoState2.png[] - -[NOTE] -If a command fails its execution, it will not call `Model#commitAddressBook()`, so the address book state will not be saved into the `addressBookStateList`. - -Step 4. The user now decides that adding the person was a mistake, and decides to undo that action by executing the `undo` command. The `undo` command will call `Model#undoAddressBook()`, which will shift the `currentStatePointer` once to the left, pointing it to the previous address book state, and restores the address book to that state. - -image::UndoRedoState3.png[] - -[NOTE] -If the `currentStatePointer` is at index 0, pointing to the initial address book state, then there are no previous address book states to restore. The `undo` command uses `Model#canUndoAddressBook()` to check if this is the case. If so, it will return an error to the user rather than attempting to perform the undo. - -The following sequence diagram shows how the undo operation works: - -image::UndoSequenceDiagram.png[] - -NOTE: The lifeline for `UndoCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. - -The `redo` command does the opposite -- it calls `Model#redoAddressBook()`, which shifts the `currentStatePointer` once to the right, pointing to the previously undone state, and restores the address book to that state. - -[NOTE] -If the `currentStatePointer` is at index `addressBookStateList.size() - 1`, pointing to the latest address book state, then there are no undone address book states to restore. The `redo` command uses `Model#canRedoAddressBook()` to check if this is the case. If so, it will return an error to the user rather than attempting to perform the redo. - -Step 5. The user then decides to execute the command `list`. Commands that do not modify the address book, such as `list`, will usually not call `Model#commitAddressBook()`, `Model#undoAddressBook()` or `Model#redoAddressBook()`. Thus, the `addressBookStateList` remains unchanged. - -image::UndoRedoState4.png[] - -Step 6. The user executes `clear`, which calls `Model#commitAddressBook()`. Since the `currentStatePointer` is not pointing at the end of the `addressBookStateList`, all address book states after the `currentStatePointer` will be purged. We designed it this way because it no longer makes sense to redo the `add n/David ...` command. This is the behavior that most modern desktop applications follow. - -image::UndoRedoState5.png[] - -The following activity diagram summarizes what happens when a user executes a new command: - -image::CommitActivityDiagram.png[] - -==== Design Considerations - -===== Aspect: How undo & redo executes - -* **Alternative 1 (current choice):** Saves the entire address book. -** Pros: Easy to implement. -** Cons: May have performance issues in terms of memory usage. -* **Alternative 2:** Individual command knows how to undo/redo by itself. -** Pros: Will use less memory (e.g. for `delete`, just save the person being deleted). -** Cons: We must ensure that the implementation of each individual command are correct. - -===== Aspect: Data structure to support the undo/redo commands - -* **Alternative 1 (current choice):** Use a list to store the history of address book states. -** Pros: Easy for new Computer Science student undergraduates to understand, who are likely to be the new incoming developers of our project. -** Cons: Logic is duplicated twice. For example, when a new command is executed, we must remember to update both `HistoryManager` and `VersionedAddressBook`. -* **Alternative 2:** Use `HistoryManager` for undo/redo -** Pros: We do not need to maintain a separate list, and just reuse what is already in the codebase. -** Cons: Requires dealing with commands that have already been undone: We must remember to skip these commands. Violates Single Responsibility Principle and Separation of Concerns as `HistoryManager` now needs to do two different things. -// end::undoredo[] - -// tag::dataencryption[] -=== [Proposed] Data Encryption - -_{Explain here how the data encryption feature will be implemented}_ - -// end::dataencryption[] - -=== Logging - -We are using `java.util.logging` package for logging. The `LogsCenter` class is used to manage the logging levels and logging destinations. - -* The logging level can be controlled using the `logLevel` setting in the configuration file (See <>) -* The `Logger` for a class can be obtained using `LogsCenter.getLogger(Class)` which will log messages according to the specified logging level -* Currently log messages are output through: `Console` and to a `.log` file. - -*Logging Levels* - -* `SEVERE` : Critical problem detected which may possibly cause the termination of the application -* `WARNING` : Can continue, but with caution -* `INFO` : Information showing the noteworthy actions by the App -* `FINE` : Details that is not usually noteworthy but may be useful in debugging e.g. print the actual list instead of just its size - -[[Implementation-Configuration]] -=== Configuration - -Certain properties of the application can be controlled (e.g user prefs file location, logging level) through the configuration file (default: `config.json`). - -== Documentation - -Refer to the guide <>. - -== Testing - -Refer to the guide <>. - -== Dev Ops - -Refer to the guide <>. - -[appendix] -== Product Scope - -*Target user profile*: - -* has a need to manage a significant number of contacts -* prefer desktop apps over other types -* can type fast -* prefers typing over mouse input -* is reasonably comfortable using CLI apps - -*Value proposition*: manage contacts faster than a typical mouse/GUI driven app - -[appendix] -== User Stories - -Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (unlikely to have) - `*` - -[width="59%",cols="22%,<23%,<25%,<30%",options="header",] -|======================================================================= -|Priority |As a ... |I want to ... |So that I can... -|`* * *` |new user |see usage instructions |refer to instructions when I forget how to use the App - -|`* * *` |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 |hide <> 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 -|======================================================================= - -_{More to be added}_ - -[appendix] -== Use Cases - -(For all use cases below, the *System* is the `AddressBook` and the *Actor* is the `user`, unless specified otherwise) - -[discrete] -=== Use case: Delete person - -*MSS* - -1. User requests to list persons -2. AddressBook shows a list of persons -3. User requests to delete a specific person in the list -4. AddressBook deletes the person -+ -Use case ends. - -*Extensions* - -[none] -* 2a. The list is empty. -+ -Use case ends. - -* 3a. The given index is invalid. -+ -[none] -** 3a1. AddressBook shows an error message. -+ -Use case resumes at step 2. - -_{More to be added}_ - -[appendix] -== Non Functional Requirements - -. Should work on any <> as long as it has Java `11` or above installed. -. Should be able to hold up to 1000 persons without a noticeable sluggishness in performance for typical usage. -. A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse. - -_{More to be added}_ - -[appendix] -== Glossary - -[[mainstream-os]] Mainstream OS:: -Windows, Linux, Unix, OS-X - -[[private-contact-detail]] Private contact detail:: -A contact detail that is not meant to be shared with others - -[appendix] -== Product Survey - -*Product Name* - -Author: ... - -Pros: - -* ... -* ... - -Cons: - -* ... -* ... - -[appendix] -== Instructions for Manual Testing - -Given below are instructions to test the app manually. - -[NOTE] -These instructions only provide a starting point for testers to work on; testers are expected to do more _exploratory_ testing. - -=== Launch and Shutdown - -. Initial launch - -.. Download the jar file and copy into an empty folder -.. Double-click the jar file + - Expected: Shows the GUI with a set of sample contacts. The window size may not be optimum. - -. Saving window preferences - -.. Resize the window to an optimum size. Move the window to a different location. Close the window. -.. Re-launch the app by double-clicking the jar file. + - Expected: The most recent window size and location is retained. - -_{ more test cases ... }_ - -=== Deleting a person - -. Deleting a person while all persons are listed - -.. Prerequisites: List all persons using the `list` command. Multiple persons in the list. -.. Test case: `delete 1` + - Expected: First contact is deleted from the list. Details of the deleted contact shown in the status message. Timestamp in the status bar is updated. -.. Test case: `delete 0` + - Expected: No person is deleted. Error details shown in the status message. Status bar remains the same. -.. Other incorrect delete commands to try: `delete`, `delete x` (where x is larger than the list size) _{give more}_ + - Expected: Similar to previous. - -_{ more test cases ... }_ - -=== Saving data - -. Dealing with missing/corrupted data files - -.. _{explain how to simulate a missing/corrupted file and the expected behavior}_ - -_{ more test cases ... }_ += AddressBook Level 3 - Developer Guide +:site-section: DeveloperGuide +:toc: +:toc-title: +:toc-placement: preamble +:sectnums: +:imagesDir: images +:stylesDir: stylesheets +:xrefstyle: full +ifdef::env-github[] +:tip-caption: :bulb: +:note-caption: :information_source: +:warning-caption: :warning: +endif::[] +:repoURL: https://github.com/se-edu/addressbook-level3/tree/master + +By: `Team SE-EDU`      Since: `Jun 2016`      Licence: `MIT` + +== Setting up + +Refer to the guide <>. + +== Design + +[[Design-Architecture]] +=== Architecture + +.Architecture Diagram +image::ArchitectureDiagram.png[] + +The *_Architecture Diagram_* given above explains the high-level design of the App. Given below is a quick overview of each component. + +[TIP] +The `.puml` files used to create diagrams in this document can be found in the link:{repoURL}/docs/diagrams/[diagrams] folder. +Refer to the <> to learn how to create and edit diagrams. + +`Main` has two classes called link:{repoURL}/src/main/java/seedu/address/Main.java[`Main`] and link:{repoURL}/src/main/java/seedu/address/MainApp.java[`MainApp`]. It is responsible for, + +* At app launch: Initializes the components in the correct sequence, and connects them up with each other. +* At shut down: Shuts down the components and invokes cleanup method where necessary. + +<> represents a collection of classes used by multiple other components. +The following class plays an important role at the architecture level: + +* `LogsCenter` : Used by many classes to write log messages to the App's log file. + +The rest of the App consists of four components. + +* <>: The UI of the App. +* <>: The command executor. +* <>: Holds the data of the App in-memory. +* <>: Reads data from, and writes data to, the hard disk. + +Each of the four components + +* Defines its _API_ in an `interface` with the same name as the Component. +* Exposes its functionality using a `{Component Name}Manager` class. + +For example, the `Logic` component (see the class diagram given below) defines it's API in the `Logic.java` interface and exposes its functionality using the `LogicManager.java` class. + +.Class Diagram of the Logic Component +image::LogicClassDiagram.png[] + +[discrete] +==== How the architecture components interact with each other + +The _Sequence Diagram_ below shows how the components interact with each other for the scenario where the user issues the command `delete 1`. + +.Component interactions for `delete 1` command +image::ArchitectureSequenceDiagram.png[] + +The sections below give more details of each component. + +[[Design-Ui]] +=== UI component + +.Structure of the UI Component +image::UiClassDiagram.png[] + +*API* : link:{repoURL}/src/main/java/seedu/address/ui/Ui.java[`Ui.java`] + +The UI consists of a `MainWindow` that is made up of parts e.g.`CommandBox`, `ResultDisplay`, `PersonListPanel`, `StatusBarFooter` etc. All these, including the `MainWindow`, inherit from the abstract `UiPart` class. + +The `UI` component uses JavaFx UI framework. The layout of these UI parts are defined in matching `.fxml` files that are in the `src/main/resources/view` folder. For example, the layout of the link:{repoURL}/src/main/java/seedu/address/ui/MainWindow.java[`MainWindow`] is specified in link:{repoURL}/src/main/resources/view/MainWindow.fxml[`MainWindow.fxml`] + +The `UI` component, + +* Executes user commands using the `Logic` component. +* Listens for changes to `Model` data so that the UI can be updated with the modified data. + +[[Design-Logic]] +=== Logic component + +[[fig-LogicClassDiagram]] +.Structure of the Logic Component +image::LogicClassDiagram.png[] + +*API* : +link:{repoURL}/src/main/java/seedu/address/logic/Logic.java[`Logic.java`] + +. `Logic` uses the `AddressBookParser` class to parse the user command. +. This results in a `Command` object which is executed by the `LogicManager`. +. The command execution can affect the `Model` (e.g. adding a person). +. The result of the command execution is encapsulated as a `CommandResult` object which is passed back to the `Ui`. +. In addition, the `CommandResult` object can also instruct the `Ui` to perform certain actions, such as displaying help to the user. + +Given below is the Sequence Diagram for interactions within the `Logic` component for the `execute("delete 1")` API call. + +.Interactions Inside the Logic Component for the `delete 1` Command +image::DeleteSequenceDiagram.png[] + +NOTE: The lifeline for `DeleteCommandParser` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. + +[[Design-Model]] +=== Model component + +.Structure of the Model Component +image::ModelClassDiagram.png[] + +*API* : link:{repoURL}/src/main/java/seedu/address/model/Model.java[`Model.java`] + +The `Model`, + +* stores a `UserPref` object that represents the user's preferences. +* stores the Address Book data. +* exposes an unmodifiable `ObservableList` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change. +* does not depend on any of the other three components. + +[NOTE] +As a more OOP model, we can store a `Tag` list in `Address Book`, which `Person` can reference. This would allow `Address Book` to only require one `Tag` object per unique `Tag`, instead of each `Person` needing their own `Tag` object. An example of how such a model may look like is given below. + + + +image:BetterModelClassDiagram.png[] + +[[Design-Storage]] +=== Storage component + +.Structure of the Storage Component +image::StorageClassDiagram.png[] + +*API* : link:{repoURL}/src/main/java/seedu/address/storage/Storage.java[`Storage.java`] + +The `Storage` component, + +* can save `UserPref` objects in json format and read it back. +* can save the Address Book data in json format and read it back. + +[[Design-Commons]] +=== Common classes + +Classes used by multiple components are in the `seedu.addressbook.commons` package. + +== Implementation + +This section describes some noteworthy details on how certain features are implemented. + +// tag::undoredo[] +=== [Proposed] Undo/Redo feature +==== Proposed Implementation + +The undo/redo mechanism is facilitated by `VersionedAddressBook`. +It extends `AddressBook` with an undo/redo history, stored internally as an `addressBookStateList` and `currentStatePointer`. +Additionally, it implements the following operations: + +* `VersionedAddressBook#commit()` -- Saves the current address book state in its history. +* `VersionedAddressBook#undo()` -- Restores the previous address book state from its history. +* `VersionedAddressBook#redo()` -- Restores a previously undone address book state from its history. + +These operations are exposed in the `Model` interface as `Model#commitAddressBook()`, `Model#undoAddressBook()` and `Model#redoAddressBook()` respectively. + +Given below is an example usage scenario and how the undo/redo mechanism behaves at each step. + +Step 1. The user launches the application for the first time. The `VersionedAddressBook` will be initialized with the initial address book state, and the `currentStatePointer` pointing to that single address book state. + +image::UndoRedoState0.png[] + +Step 2. The user executes `delete 5` command to delete the 5th person in the address book. The `delete` command calls `Model#commitAddressBook()`, causing the modified state of the address book after the `delete 5` command executes to be saved in the `addressBookStateList`, and the `currentStatePointer` is shifted to the newly inserted address book state. + +image::UndoRedoState1.png[] + +Step 3. The user executes `add n/David ...` to add a new person. The `add` command also calls `Model#commitAddressBook()`, causing another modified address book state to be saved into the `addressBookStateList`. + +image::UndoRedoState2.png[] + +[NOTE] +If a command fails its execution, it will not call `Model#commitAddressBook()`, so the address book state will not be saved into the `addressBookStateList`. + +Step 4. The user now decides that adding the person was a mistake, and decides to undo that action by executing the `undo` command. The `undo` command will call `Model#undoAddressBook()`, which will shift the `currentStatePointer` once to the left, pointing it to the previous address book state, and restores the address book to that state. + +image::UndoRedoState3.png[] + +[NOTE] +If the `currentStatePointer` is at index 0, pointing to the initial address book state, then there are no previous address book states to restore. The `undo` command uses `Model#canUndoAddressBook()` to check if this is the case. If so, it will return an error to the user rather than attempting to perform the undo. + +The following sequence diagram shows how the undo operation works: + +image::UndoSequenceDiagram.png[] + +NOTE: The lifeline for `UndoCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. + +The `redo` command does the opposite -- it calls `Model#redoAddressBook()`, which shifts the `currentStatePointer` once to the right, pointing to the previously undone state, and restores the address book to that state. + +[NOTE] +If the `currentStatePointer` is at index `addressBookStateList.size() - 1`, pointing to the latest address book state, then there are no undone address book states to restore. The `redo` command uses `Model#canRedoAddressBook()` to check if this is the case. If so, it will return an error to the user rather than attempting to perform the redo. + +Step 5. The user then decides to execute the command `list`. Commands that do not modify the address book, such as `list`, will usually not call `Model#commitAddressBook()`, `Model#undoAddressBook()` or `Model#redoAddressBook()`. Thus, the `addressBookStateList` remains unchanged. + +image::UndoRedoState4.png[] + +Step 6. The user executes `clear`, which calls `Model#commitAddressBook()`. Since the `currentStatePointer` is not pointing at the end of the `addressBookStateList`, all address book states after the `currentStatePointer` will be purged. We designed it this way because it no longer makes sense to redo the `add n/David ...` command. This is the behavior that most modern desktop applications follow. + +image::UndoRedoState5.png[] + +The following activity diagram summarizes what happens when a user executes a new command: + +image::CommitActivityDiagram.png[] + +==== Design Considerations + +===== Aspect: How undo & redo executes + +* **Alternative 1 (current choice):** Saves the entire address book. +** Pros: Easy to implement. +** Cons: May have performance issues in terms of memory usage. +* **Alternative 2:** Individual command knows how to undo/redo by itself. +** Pros: Will use less memory (e.g. for `delete`, just save the person being deleted). +** Cons: We must ensure that the implementation of each individual command are correct. + +===== Aspect: Data structure to support the undo/redo commands + +* **Alternative 1 (current choice):** Use a list to store the history of address book states. +** Pros: Easy for new Computer Science student undergraduates to understand, who are likely to be the new incoming developers of our project. +** Cons: Logic is duplicated twice. For example, when a new command is executed, we must remember to update both `HistoryManager` and `VersionedAddressBook`. +* **Alternative 2:** Use `HistoryManager` for undo/redo +** Pros: We do not need to maintain a separate list, and just reuse what is already in the codebase. +** Cons: Requires dealing with commands that have already been undone: We must remember to skip these commands. Violates Single Responsibility Principle and Separation of Concerns as `HistoryManager` now needs to do two different things. +// end::undoredo[] + +// tag::dataencryption[] +=== [Proposed] Data Encryption + +_{Explain here how the data encryption feature will be implemented}_ + +// end::dataencryption[] + +=== Logging + +We are using `java.util.logging` package for logging. The `LogsCenter` class is used to manage the logging levels and logging destinations. + +* The logging level can be controlled using the `logLevel` setting in the configuration file (See <>) +* The `Logger` for a class can be obtained using `LogsCenter.getLogger(Class)` which will log messages according to the specified logging level +* Currently log messages are output through: `Console` and to a `.log` file. + +*Logging Levels* + +* `SEVERE` : Critical problem detected which may possibly cause the termination of the application +* `WARNING` : Can continue, but with caution +* `INFO` : Information showing the noteworthy actions by the App +* `FINE` : Details that is not usually noteworthy but may be useful in debugging e.g. print the actual list instead of just its size + +[[Implementation-Configuration]] +=== Configuration + +Certain properties of the application can be controlled (e.g user prefs file location, logging level) through the configuration file (default: `config.json`). + +== Documentation + +Refer to the guide <>. + +== Testing + +Refer to the guide <>. + +== Dev Ops + +Refer to the guide <>. + +[appendix] +== Product Scope + +*Target user profile*: + +* has a need to manage a significant number of contacts +* prefer desktop apps over other types +* can type fast +* prefers typing over mouse input +* is reasonably comfortable using CLI apps + +*Value proposition*: manage contacts faster than a typical mouse/GUI driven app + +[appendix] +== User Stories + +Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (unlikely to have) - `*` + +[width="59%",cols="22%,<23%,<25%,<30%",options="header",] +|======================================================================= +|Priority |As a ... |I want to ... |So that I can... +|`* * *` |new user |see usage instructions |refer to instructions when I forget how to use the App + +|`* * *` |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 |hide <> 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 +|======================================================================= + +_{More to be added}_ + +[appendix] +== Use Cases + +(For all use cases below, the *System* is the `AddressBook` and the *Actor* is the `user`, unless specified otherwise) + +[discrete] +=== Use case: Delete person + +*MSS* + +1. User requests to list persons +2. AddressBook shows a list of persons +3. User requests to delete a specific person in the list +4. AddressBook deletes the person ++ +Use case ends. + +*Extensions* + +[none] +* 2a. The list is empty. ++ +Use case ends. + +* 3a. The given index is invalid. ++ +[none] +** 3a1. AddressBook shows an error message. ++ +Use case resumes at step 2. + +_{More to be added}_ + +[appendix] +== Non Functional Requirements + +. Should work on any <> as long as it has Java `11` or above installed. +. Should be able to hold up to 1000 persons without a noticeable sluggishness in performance for typical usage. +. A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse. + +_{More to be added}_ + +[appendix] +== Glossary + +[[mainstream-os]] Mainstream OS:: +Windows, Linux, Unix, OS-X + +[[private-contact-detail]] Private contact detail:: +A contact detail that is not meant to be shared with others + +[appendix] +== Product Survey + +*Product Name* + +Author: ... + +Pros: + +* ... +* ... + +Cons: + +* ... +* ... + +[appendix] +== Instructions for Manual Testing + +Given below are instructions to test the app manually. + +[NOTE] +These instructions only provide a starting point for testers to work on; testers are expected to do more _exploratory_ testing. + +=== Launch and Shutdown + +. Initial launch + +.. Download the jar file and copy into an empty folder +.. Double-click the jar file + + Expected: Shows the GUI with a set of sample contacts. The window size may not be optimum. + +. Saving window preferences + +.. Resize the window to an optimum size. Move the window to a different location. Close the window. +.. Re-launch the app by double-clicking the jar file. + + Expected: The most recent window size and location is retained. + +_{ more test cases ... }_ + +=== Deleting a person + +. Deleting a person while all persons are listed + +.. Prerequisites: List all persons using the `list` command. Multiple persons in the list. +.. Test case: `delete 1` + + Expected: First contact is deleted from the list. Details of the deleted contact shown in the status message. Timestamp in the status bar is updated. +.. Test case: `delete 0` + + Expected: No person is deleted. Error details shown in the status message. Status bar remains the same. +.. Other incorrect delete commands to try: `delete`, `delete x` (where x is larger than the list size) _{give more}_ + + Expected: Similar to previous. + +_{ more test cases ... }_ + +=== Saving data + +. Dealing with missing/corrupted data files + +.. _{explain how to simulate a missing/corrupted file and the expected behavior}_ + +_{ more test cases ... }_ diff --git a/docs/Documentation.adoc b/docs/Documentation.adoc index ad90ac87bda..6ecce99c2c6 100644 --- a/docs/Documentation.adoc +++ b/docs/Documentation.adoc @@ -1,123 +1,123 @@ -= AddressBook Level 3 - Documentation -:site-section: DeveloperGuide -:toc: -:toc-title: -:toc-placement: preamble -:sectnums: -:imagesDir: images -:stylesDir: stylesheets -:xrefstyle: full -ifdef::env-github[] -:tip-caption: :bulb: -:note-caption: :information_source: -:warning-caption: :warning: -endif::[] -:repoURL: https://github.com/se-edu/addressbook-level3/tree/master - -== Introduction - -We use asciidoc for writing documentation. - -[NOTE] -We chose asciidoc over Markdown because asciidoc, although a bit more complex than Markdown, provides more flexibility in formatting. - -== Editing Documentation - -See <> to learn how to render `.adoc` files locally to preview the end result of your edits. -Alternatively, you can download the AsciiDoc plugin for IntelliJ, which allows you to preview the changes you have made to your `.adoc` files in real-time. - -== Editing Diagrams - -See <> to find out how to create and update the UML diagrams in the developer guide. - -== Publishing Documentation - -See <> to learn how to deploy GitHub Pages using Travis. - -== Converting Documentation to PDF format - -We use https://www.google.com/chrome/browser/desktop/[Google Chrome] for converting documentation to PDF format, as Chrome's PDF engine preserves hyperlinks used in webpages. - -Here are the steps to convert the project documentation files to PDF format. - -. Follow the instructions in <> to convert the AsciiDoc files in the `docs/` directory to HTML format. -. Go to your generated HTML files in the `build/docs` folder, right click on them and select `Open with` -> `Google Chrome`. -. Within Chrome, click on the `Print` option in Chrome's menu. -. Set the destination to `Save as PDF`, then click `Save` to save a copy of the file in PDF format. For best results, use the settings indicated in the screenshot below. - -.Saving documentation as PDF files in Chrome -image::chrome_save_as_pdf.png[width="300"] - -[[Docs-SiteWideDocSettings]] -== Site-wide Documentation Settings - -The link:{repoURL}/build.gradle[`build.gradle`] file specifies some project-specific https://asciidoctor.org/docs/user-manual/#attributes[asciidoc attributes] which affects how all documentation files within this project are rendered. - -[TIP] -Attributes left unset in the `build.gradle` file will use their *default value*, if any. - -[cols="1,2a,1", options="header"] -.List of site-wide attributes -|=== -|Attribute name |Description |Default value - -|`site-name` -|The name of the website. -If set, the name will be displayed near the top of the page. -|_not set_ - -|`site-githuburl` -|URL to the site's repository on https://github.com[GitHub]. -Setting this will add a "View on GitHub" link in the navigation bar. -|_not set_ - -|`site-seedu` -|Define this attribute if the project is an official SE-EDU project. -This will render the SE-EDU navigation bar at the top of the page, and add some SE-EDU-specific navigation items. -|_not set_ - -|=== - -[[Docs-PerFileDocSettings]] -== Per-file Documentation Settings - -Each `.adoc` file may also specify some file-specific https://asciidoctor.org/docs/user-manual/#attributes[asciidoc attributes] which affects how the file is rendered. - -Asciidoctor's https://asciidoctor.org/docs/user-manual/#builtin-attributes[built-in attributes] may be specified and used as well. - -[TIP] -Attributes left unset in `.adoc` files will use their *default value*, if any. - -[cols="1,2a,1", options="header"] -.List of per-file attributes, excluding Asciidoctor's built-in attributes -|=== -|Attribute name |Description |Default value - -|`site-section` -|Site section that the document belongs to. -This will cause the associated item in the navigation bar to be highlighted. -One of: `UserGuide`, `DeveloperGuide`, ``LearningOutcomes``{asterisk}, `AboutUs`, `ContactUs` - -_{asterisk} Official SE-EDU projects only_ -|_not set_ - -|`no-site-header` -|Set this attribute to remove the site navigation bar. -|_not set_ - -|=== - -== Site Template - -The files in link:{repoURL}/docs/stylesheets[`docs/stylesheets`] are the https://developer.mozilla.org/en-US/docs/Web/CSS[CSS stylesheets] of the site. -You can modify them to change some properties of the site's design. - -The files in link:{repoURL}/docs/templates[`docs/templates`] controls the rendering of `.adoc` files into HTML5. -These template files are written in a mixture of https://www.ruby-lang.org[Ruby] and http://slim-lang.com[Slim]. - -[WARNING] -==== -Modifying the template files in link:{repoURL}/docs/templates[`docs/templates`] requires some knowledge and experience with Ruby and Asciidoctor's API. -You should only modify them if you need greater control over the site's layout than what stylesheets can provide. -The SE-EDU team does not provide support for modified template files. -==== += AddressBook Level 3 - Documentation +:site-section: DeveloperGuide +:toc: +:toc-title: +:toc-placement: preamble +:sectnums: +:imagesDir: images +:stylesDir: stylesheets +:xrefstyle: full +ifdef::env-github[] +:tip-caption: :bulb: +:note-caption: :information_source: +:warning-caption: :warning: +endif::[] +:repoURL: https://github.com/se-edu/addressbook-level3/tree/master + +== Introduction + +We use asciidoc for writing documentation. + +[NOTE] +We chose asciidoc over Markdown because asciidoc, although a bit more complex than Markdown, provides more flexibility in formatting. + +== Editing Documentation + +See <> to learn how to render `.adoc` files locally to preview the end result of your edits. +Alternatively, you can download the AsciiDoc plugin for IntelliJ, which allows you to preview the changes you have made to your `.adoc` files in real-time. + +== Editing Diagrams + +See <> to find out how to create and update the UML diagrams in the developer guide. + +== Publishing Documentation + +See <> to learn how to deploy GitHub Pages using Travis. + +== Converting Documentation to PDF format + +We use https://www.google.com/chrome/browser/desktop/[Google Chrome] for converting documentation to PDF format, as Chrome's PDF engine preserves hyperlinks used in webpages. + +Here are the steps to convert the project documentation files to PDF format. + +. Follow the instructions in <> to convert the AsciiDoc files in the `docs/` directory to HTML format. +. Go to your generated HTML files in the `build/docs` folder, right click on them and select `Open with` -> `Google Chrome`. +. Within Chrome, click on the `Print` option in Chrome's menu. +. Set the destination to `Save as PDF`, then click `Save` to save a copy of the file in PDF format. For best results, use the settings indicated in the screenshot below. + +.Saving documentation as PDF files in Chrome +image::chrome_save_as_pdf.png[width="300"] + +[[Docs-SiteWideDocSettings]] +== Site-wide Documentation Settings + +The link:{repoURL}/build.gradle[`build.gradle`] file specifies some project-specific https://asciidoctor.org/docs/user-manual/#attributes[asciidoc attributes] which affects how all documentation files within this project are rendered. + +[TIP] +Attributes left unset in the `build.gradle` file will use their *default value*, if any. + +[cols="1,2a,1", options="header"] +.List of site-wide attributes +|=== +|Attribute name |Description |Default value + +|`site-name` +|The name of the website. +If set, the name will be displayed near the top of the page. +|_not set_ + +|`site-githuburl` +|URL to the site's repository on https://github.com[GitHub]. +Setting this will add a "View on GitHub" link in the navigation bar. +|_not set_ + +|`site-seedu` +|Define this attribute if the project is an official SE-EDU project. +This will render the SE-EDU navigation bar at the top of the page, and add some SE-EDU-specific navigation items. +|_not set_ + +|=== + +[[Docs-PerFileDocSettings]] +== Per-file Documentation Settings + +Each `.adoc` file may also specify some file-specific https://asciidoctor.org/docs/user-manual/#attributes[asciidoc attributes] which affects how the file is rendered. + +Asciidoctor's https://asciidoctor.org/docs/user-manual/#builtin-attributes[built-in attributes] may be specified and used as well. + +[TIP] +Attributes left unset in `.adoc` files will use their *default value*, if any. + +[cols="1,2a,1", options="header"] +.List of per-file attributes, excluding Asciidoctor's built-in attributes +|=== +|Attribute name |Description |Default value + +|`site-section` +|Site section that the document belongs to. +This will cause the associated item in the navigation bar to be highlighted. +One of: `UserGuide`, `DeveloperGuide`, ``LearningOutcomes``{asterisk}, `AboutUs`, `ContactUs` + +_{asterisk} Official SE-EDU projects only_ +|_not set_ + +|`no-site-header` +|Set this attribute to remove the site navigation bar. +|_not set_ + +|=== + +== Site Template + +The files in link:{repoURL}/docs/stylesheets[`docs/stylesheets`] are the https://developer.mozilla.org/en-US/docs/Web/CSS[CSS stylesheets] of the site. +You can modify them to change some properties of the site's design. + +The files in link:{repoURL}/docs/templates[`docs/templates`] controls the rendering of `.adoc` files into HTML5. +These template files are written in a mixture of https://www.ruby-lang.org[Ruby] and http://slim-lang.com[Slim]. + +[WARNING] +==== +Modifying the template files in link:{repoURL}/docs/templates[`docs/templates`] requires some knowledge and experience with Ruby and Asciidoctor's API. +You should only modify them if you need greater control over the site's layout than what stylesheets can provide. +The SE-EDU team does not provide support for modified template files. +==== diff --git a/docs/LearningOutcomes.adoc b/docs/LearningOutcomes.adoc index 436c1777617..35ce811232c 100644 --- a/docs/LearningOutcomes.adoc +++ b/docs/LearningOutcomes.adoc @@ -1,216 +1,216 @@ -= Learning Outcomes -:site-section: LearningOutcomes -:toc: macro -:toc-title: -:toclevels: 1 -:imagesDir: images -:stylesDir: stylesheets -ifdef::env-github[] -:note-caption: :information_source: -endif::[] - -After studying this code and completing the corresponding exercises, you should be able to, - -toc::[] - -== Utilize User Stories `[LO-UserStories]` - -=== References - -* https://se-edu.github.io/se-book/specifyingRequirements/userStories/[se-edu/se-book: Requirements: Specifying Requirements: User Stories] - -=== Exercise: Add more user stories - -* Assume you are planing to expand the functionality of the AddressBook (but keep it as a CLI application). -What other user stories do you think AddressBook should support? Add those user stories to the `DeveloperGuide.adoc`. - -== Utilize use cases `[LO-UseCases]` - -=== References - -* https://se-edu.github.io/se-book/specifyingRequirements/useCases/[se-edu/se-book: Requirements: Specifying Requirements: Use Cases] - -=== Exercise: Add a 'Rename tag' use case - -* Add a use case to the `DeveloperGuide.adoc` to cover the case of _renaming of an existing tag_. -e.g. rename the tag `friends` to `buddies` (i.e. all persons who had the `friends` tag will now have -a `buddies` tag instead) -Assume that AddressBook confirms the change with the user before carrying out the operation. - -== Use Non Functional Requirements `[LO-NFR]` - -=== References - -* https://se-edu.github.io/se-book/requirements/nonFunctionalRequirements/[se-edu/se-book: Requirements: Non-Functional Requirements] - -=== Exercise: Add more NFRs - -* Add some more NFRs to the `DeveloperGuide.adoc` - -== Use Polymorphism `[LO-Polymorphism]` - -Note how the `Command::execute()` method shows polymorphic behavior. - -=== References - -* https://se-edu.github.io/se-book/oop/polymorphism/[se-edu/se-book: Paradigms: OOP: Polymorphism] -* https://se-edu.github.io/se-book/cppToJava/inheritance/polymorphism/[se-edu/se-book: C++ to Java: OOP: Polymorphism] - -=== Exercise: Add a polymorphic `isMutating` method - -* Add a method `boolean isMutating()` to the `Command` class. This method will return `true` for -command types that mutate the data. e.g. `AddCommand` -* Currently, AddressBook data are saved to the file after every command. -Take advantage of the the new method you added to limit file saving to only for command types that mutate data. -i.e. `add` command should always save the data while `list` command should never save data to the file. - -[NOTE] -==== -There may be better ways to limit file saving to commands that mutate data. The above approach, while not -optimal, will give you chance to implement a polymorphic behavior. -==== - -== Use abstract classes/methods `[LO-Abstract]` - -=== References - -* https://se-edu.github.io/se-book/oop/inheritance/abstractClasses/[se-edu/se-book: Paradigms: OOP: Abstract Classes] -* https://se-edu.github.io/se-book/cppToJava/inheritance/abstractClassesAndMethods/[se-edu/se-book: C++ to Java: OOP: Abstract Classes] - -=== Exercise: Make `Command#execute()` method abstract - -* Make the `Command#execute()` method abstract (hint: refer to the comment given below the method) - -== Use interfaces `[LO-Interfaces]` - -Note how the `AddressBook` class implements the `ReadOnlyAddressBook` interface so that clients who don't need write access to the `AddressBook` can access the `AddressBook` through the `ReadOnlyAddressBook` interface instead. - -image::ReadOnlyAddressBookUsage.png[width=500] - -=== References - -* https://se-edu.github.io/se-book/oop/inheritance/interfaces/[se-edu/se-book: Paradigms: OOP: Abstract Interfaces] -* https://se-edu.github.io/se-book/cppToJava/inheritance/interfaces/[se-edu/se-book: C++ to Java: OOP: Abstract Interfaces] - -=== Exercise: Add a `Printable` interface - -* Add a `Printable` interface as follows. -+ -image::PrintableInterface.png[width=400] -* `Override` the `getPrintableString` in classes `Name`, `Phone`, `Email`, and `Address` so that each produces a printable string representation of the object. e.g. `Name: John Smith`, `Phone: 12349862` -* Add the following method in a suitable place of some other class. Note how the method depends on the Interface. -+ -[source,java] ----- -/** - * Returns a concatenated version of the printable strings of each object. - */ -String getPrintableString(Printable... printables) { ----- -+ -The above method can be used to get a printable string representing a bunch of person details. -For example, you should be able to call that method like this: -+ -[source,java] ----- -// p is a Person object -return getPrintableString(p.getPhone(), p.getEmail(), p.getAddress()); ----- - -== Follow Liskov Substitution Principle `[LO-LSP]` - -=== References - -* https://se-edu.github.io/se-book/principles/liskovSubstitutionPrinciple/[se-edu/se-book: Principles: Liskov Substitution Principle] - -=== Exercise: Add an exception to an overridden method - -* Add a `throws Exception` clause to the `AddCommand::execute` method. Notice how Java compiler will not allow it, -unless you add the same `throws` clause to the parent class method. This is because if a child class throws -an exception that is not specified by the Parent's contract, the child class is no longer substitutable in place of -the parent class. -* Also note that while in the above example the compiler enforces LSP, there are other situations where it is up to -the programmer to enforce it. For example, if the method in the parent class works for `null` input, the overridden -method in the child class should not reject `null` inputs. This will not be enforced by the compiler. - -== Use Java-FX for GUI programming `[LO-JavaFx]` - -=== References - -* https://se-edu.github.io/se-book/javaTools/javaFXBasic/[se-edu/se-book: Tools: Java: JavaFX: Basic] - -=== Exercise: Enhance GUI - -* Do some enhancements to the AddressBook GUI. e.g. add an application icon, change font size/style - -== Analyze Coupling and Cohesion of designs `[LO-CouplingCohesion]` - -* Notice how having a separate `ParserUtil` class to handle user input validation, space trimming etc. of model data (an application of the Single Responsibility Principle) improves the _cohesion_ of the model component (since it does not need to be concerned with handling user input) as well as the `ParserUtil` class. - -=== References - -* https://se-edu.github.io/se-book/designFundamentals/coupling/[se-edu/se-book: Design: Design Principles: Coupling] -* https://se-edu.github.io/se-book/designFundamentals/cohesion/[se-edu/se-book: Design: Design Principles: Cohesion] - -=== Exercise: Identify places to reduce coupling and increase cohesion - -* Where else in the design coupling can be reduced further, or cohesion can be increased further? - -[[apply-dependency-inversion-principle-lo-dip]] -== Apply Dependency Inversion Principle `[LO-DIP]` - -* Note how the `LogicManager` class doesn't depend on `StorageManager` directly, but rather the interface `Storage`. -This is an application of the Dependency Inversion Principle. -+ -image::LogicStorageDIP.png[width=300] -* Where else in the code do you notice the application of DIP? - -=== References - -* https://se-edu.github.io/se-book/principles/dependencyInversionPrinciple/[se-edu/se-book: Principles: Dependency Inversion Principle] - -== Use Dependency Injection `[LO-DI]` - -Notice how the `LogicManager` class does not depend on the `StorageManager` class, but depends on the `Storage` interface. -This allows us to use _Dependency Injection_ to test the `LogicManager` class without getting the `StorageManager` class involved. - -=== References - -* https://se-edu.github.io/se-book/testing/dependencyInjection/[se-edu/se-book: Quality Assurance: Testing: Dependency Injection] - -=== Exercise: Facilitate injecting a StorageStub - -* Notice how `LogicManagerTest` tests `LogicManager` by constructing a `StorageManager` object. -* Implement `StorageStub` such that calls to its `save*` methods do nothing (i.e. empty method body). -* Update `LogicManagerTest` to work with the `StorageStub` instead of the actual `StorageManager` object. -i.e. `LogicManagerTest` injects a `StorageStub` object when constructing a `LogicManager` before testing it. -+ -image::DependencyInjection.png[width=600] -* The example above uses <> as a means to achieve DI. -Note that there is another way to inject a `StorageStub` object, as shown below. -In this case we do not apply the DIP but we still achieve DI. -+ -image::DependencyInjectionWithoutDIP.png[width=250] - -== Apply Open-Closed Principle `[LO-OCP]` - -=== References - -* https://se-edu.github.io/se-book/principles/openClosedPrinciple/[se-edu/se-book: Principles: Open-Closed Principle] - -=== Exercise: Analyze OCP-compliance of the `LogicManager` class - -* Consider adding a new command to the Address Book. e.g. an `edit` command. Notice how little you need to change in the `LogicManager` class to extend its behavior so that it can execute the new command. -That is because `LogicManager` follows the OCP i.e. `LogicManager` is _open to be extended_ with more commands but _closed for modifications_. -* Is it possible to make the `AddressBookParser` class more OCP-compliant in terms of extending it to handle more -command types? -* In terms of how it saves data, is `LogicManager` more OCP-compliant -due to the application of DIP as given in <>? -How can you improve ``LogicManager``'s OCP-compliance further so that it can not only work with different types -of storages, but different number of storages (e.g. save to both a text file and a database). - -== Work in a 3KLoC code base `[LO-3KLoC]` - -=== Exercise: Enhance AddressBook - -* Enhance AddressBook in some way. e.g. add a new command += Learning Outcomes +:site-section: LearningOutcomes +:toc: macro +:toc-title: +:toclevels: 1 +:imagesDir: images +:stylesDir: stylesheets +ifdef::env-github[] +:note-caption: :information_source: +endif::[] + +After studying this code and completing the corresponding exercises, you should be able to, + +toc::[] + +== Utilize User Stories `[LO-UserStories]` + +=== References + +* https://se-edu.github.io/se-book/specifyingRequirements/userStories/[se-edu/se-book: Requirements: Specifying Requirements: User Stories] + +=== Exercise: Add more user stories + +* Assume you are planing to expand the functionality of the AddressBook (but keep it as a CLI application). +What other user stories do you think AddressBook should support? Add those user stories to the `DeveloperGuide.adoc`. + +== Utilize use cases `[LO-UseCases]` + +=== References + +* https://se-edu.github.io/se-book/specifyingRequirements/useCases/[se-edu/se-book: Requirements: Specifying Requirements: Use Cases] + +=== Exercise: Add a 'Rename tag' use case + +* Add a use case to the `DeveloperGuide.adoc` to cover the case of _renaming of an existing tag_. +e.g. rename the tag `friends` to `buddies` (i.e. all persons who had the `friends` tag will now have +a `buddies` tag instead) +Assume that AddressBook confirms the change with the user before carrying out the operation. + +== Use Non Functional Requirements `[LO-NFR]` + +=== References + +* https://se-edu.github.io/se-book/requirements/nonFunctionalRequirements/[se-edu/se-book: Requirements: Non-Functional Requirements] + +=== Exercise: Add more NFRs + +* Add some more NFRs to the `DeveloperGuide.adoc` + +== Use Polymorphism `[LO-Polymorphism]` + +Note how the `Command::execute()` method shows polymorphic behavior. + +=== References + +* https://se-edu.github.io/se-book/oop/polymorphism/[se-edu/se-book: Paradigms: OOP: Polymorphism] +* https://se-edu.github.io/se-book/cppToJava/inheritance/polymorphism/[se-edu/se-book: C++ to Java: OOP: Polymorphism] + +=== Exercise: Add a polymorphic `isMutating` method + +* Add a method `boolean isMutating()` to the `Command` class. This method will return `true` for +command types that mutate the data. e.g. `AddCommand` +* Currently, AddressBook data are saved to the file after every command. +Take advantage of the the new method you added to limit file saving to only for command types that mutate data. +i.e. `add` command should always save the data while `list` command should never save data to the file. + +[NOTE] +==== +There may be better ways to limit file saving to commands that mutate data. The above approach, while not +optimal, will give you chance to implement a polymorphic behavior. +==== + +== Use abstract classes/methods `[LO-Abstract]` + +=== References + +* https://se-edu.github.io/se-book/oop/inheritance/abstractClasses/[se-edu/se-book: Paradigms: OOP: Abstract Classes] +* https://se-edu.github.io/se-book/cppToJava/inheritance/abstractClassesAndMethods/[se-edu/se-book: C++ to Java: OOP: Abstract Classes] + +=== Exercise: Make `Command#execute()` method abstract + +* Make the `Command#execute()` method abstract (hint: refer to the comment given below the method) + +== Use interfaces `[LO-Interfaces]` + +Note how the `AddressBook` class implements the `ReadOnlyAddressBook` interface so that clients who don't need write access to the `AddressBook` can access the `AddressBook` through the `ReadOnlyAddressBook` interface instead. + +image::ReadOnlyAddressBookUsage.png[width=500] + +=== References + +* https://se-edu.github.io/se-book/oop/inheritance/interfaces/[se-edu/se-book: Paradigms: OOP: Abstract Interfaces] +* https://se-edu.github.io/se-book/cppToJava/inheritance/interfaces/[se-edu/se-book: C++ to Java: OOP: Abstract Interfaces] + +=== Exercise: Add a `Printable` interface + +* Add a `Printable` interface as follows. ++ +image::PrintableInterface.png[width=400] +* `Override` the `getPrintableString` in classes `Name`, `Phone`, `Email`, and `Address` so that each produces a printable string representation of the object. e.g. `Name: John Smith`, `Phone: 12349862` +* Add the following method in a suitable place of some other class. Note how the method depends on the Interface. ++ +[source,java] +---- +/** + * Returns a concatenated version of the printable strings of each object. + */ +String getPrintableString(Printable... printables) { +---- ++ +The above method can be used to get a printable string representing a bunch of person details. +For example, you should be able to call that method like this: ++ +[source,java] +---- +// p is a Person object +return getPrintableString(p.getPhone(), p.getEmail(), p.getAddress()); +---- + +== Follow Liskov Substitution Principle `[LO-LSP]` + +=== References + +* https://se-edu.github.io/se-book/principles/liskovSubstitutionPrinciple/[se-edu/se-book: Principles: Liskov Substitution Principle] + +=== Exercise: Add an exception to an overridden method + +* Add a `throws Exception` clause to the `AddCommand::execute` method. Notice how Java compiler will not allow it, +unless you add the same `throws` clause to the parent class method. This is because if a child class throws +an exception that is not specified by the Parent's contract, the child class is no longer substitutable in place of +the parent class. +* Also note that while in the above example the compiler enforces LSP, there are other situations where it is up to +the programmer to enforce it. For example, if the method in the parent class works for `null` input, the overridden +method in the child class should not reject `null` inputs. This will not be enforced by the compiler. + +== Use Java-FX for GUI programming `[LO-JavaFx]` + +=== References + +* https://se-edu.github.io/se-book/javaTools/javaFXBasic/[se-edu/se-book: Tools: Java: JavaFX: Basic] + +=== Exercise: Enhance GUI + +* Do some enhancements to the AddressBook GUI. e.g. add an application icon, change font size/style + +== Analyze Coupling and Cohesion of designs `[LO-CouplingCohesion]` + +* Notice how having a separate `ParserUtil` class to handle user input validation, space trimming etc. of model data (an application of the Single Responsibility Principle) improves the _cohesion_ of the model component (since it does not need to be concerned with handling user input) as well as the `ParserUtil` class. + +=== References + +* https://se-edu.github.io/se-book/designFundamentals/coupling/[se-edu/se-book: Design: Design Principles: Coupling] +* https://se-edu.github.io/se-book/designFundamentals/cohesion/[se-edu/se-book: Design: Design Principles: Cohesion] + +=== Exercise: Identify places to reduce coupling and increase cohesion + +* Where else in the design coupling can be reduced further, or cohesion can be increased further? + +[[apply-dependency-inversion-principle-lo-dip]] +== Apply Dependency Inversion Principle `[LO-DIP]` + +* Note how the `LogicManager` class doesn't depend on `StorageManager` directly, but rather the interface `Storage`. +This is an application of the Dependency Inversion Principle. ++ +image::LogicStorageDIP.png[width=300] +* Where else in the code do you notice the application of DIP? + +=== References + +* https://se-edu.github.io/se-book/principles/dependencyInversionPrinciple/[se-edu/se-book: Principles: Dependency Inversion Principle] + +== Use Dependency Injection `[LO-DI]` + +Notice how the `LogicManager` class does not depend on the `StorageManager` class, but depends on the `Storage` interface. +This allows us to use _Dependency Injection_ to test the `LogicManager` class without getting the `StorageManager` class involved. + +=== References + +* https://se-edu.github.io/se-book/testing/dependencyInjection/[se-edu/se-book: Quality Assurance: Testing: Dependency Injection] + +=== Exercise: Facilitate injecting a StorageStub + +* Notice how `LogicManagerTest` tests `LogicManager` by constructing a `StorageManager` object. +* Implement `StorageStub` such that calls to its `save*` methods do nothing (i.e. empty method body). +* Update `LogicManagerTest` to work with the `StorageStub` instead of the actual `StorageManager` object. +i.e. `LogicManagerTest` injects a `StorageStub` object when constructing a `LogicManager` before testing it. ++ +image::DependencyInjection.png[width=600] +* The example above uses <> as a means to achieve DI. +Note that there is another way to inject a `StorageStub` object, as shown below. +In this case we do not apply the DIP but we still achieve DI. ++ +image::DependencyInjectionWithoutDIP.png[width=250] + +== Apply Open-Closed Principle `[LO-OCP]` + +=== References + +* https://se-edu.github.io/se-book/principles/openClosedPrinciple/[se-edu/se-book: Principles: Open-Closed Principle] + +=== Exercise: Analyze OCP-compliance of the `LogicManager` class + +* Consider adding a new command to the Address Book. e.g. an `edit` command. Notice how little you need to change in the `LogicManager` class to extend its behavior so that it can execute the new command. +That is because `LogicManager` follows the OCP i.e. `LogicManager` is _open to be extended_ with more commands but _closed for modifications_. +* Is it possible to make the `AddressBookParser` class more OCP-compliant in terms of extending it to handle more +command types? +* In terms of how it saves data, is `LogicManager` more OCP-compliant +due to the application of DIP as given in <>? +How can you improve ``LogicManager``'s OCP-compliance further so that it can not only work with different types +of storages, but different number of storages (e.g. save to both a text file and a database). + +== Work in a 3KLoC code base `[LO-3KLoC]` + +=== Exercise: Enhance AddressBook + +* Enhance AddressBook in some way. e.g. add a new command diff --git a/docs/SettingUp.adoc b/docs/SettingUp.adoc index c0659782fab..33ddf38babe 100644 --- a/docs/SettingUp.adoc +++ b/docs/SettingUp.adoc @@ -1,84 +1,84 @@ -= AddressBook Level 3 - Setting Up -:site-section: DeveloperGuide -:toc: -:toc-title: -:toc-placement: preamble -:sectnums: -:imagesDir: images -:stylesDir: stylesheets -:xrefstyle: full -ifdef::env-github[] -:tip-caption: :bulb: -:note-caption: :information_source: -:warning-caption: :warning: -endif::[] -:repoURL: https://github.com/se-edu/addressbook-level3/tree/master - -== Prerequisites - -. *JDK `11`* or above -. *IntelliJ* IDE -+ -[NOTE] -IntelliJ by default has Gradle and JavaFx plugins installed. + -Do not disable them. If you have disabled them, go to `File` > `Settings` > `Plugins` to re-enable them. - -== Setting up the project in your computer - -. Fork this repo, and clone the fork to your computer -. Open IntelliJ (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project dialog first) -. Set up the correct JDK version for Gradle -.. Click `Configure` > `Project Defaults` > `Project Structure` -.. Click `New...` and find the directory of the JDK -. Click `Import Project` -. Locate the `build.gradle` file and select it. Click `OK` -. Click `Open as Project` -. Click `OK` to accept the default settings. - -== Verifying the setup - -. Run the `seedu.address.Main` and try a few commands -. <> to ensure they all pass. - -== Configurations to do before writing code - -=== Configuring the coding style - -This project follows https://github.com/oss-generic/process/blob/master/docs/CodingStandards.adoc[oss-generic coding standards]. IntelliJ's default style is mostly compliant with ours but it uses a different import order from ours. To rectify, - -. Go to `File` > `Settings...` (Windows/Linux), or `IntelliJ IDEA` > `Preferences...` (macOS) -. Select `Editor` > `Code Style` > `Java` -. Click on the `Imports` tab to set the order - -* For `Class count to use import with '\*'` and `Names count to use static import with '*'`: Set to `999` to prevent IntelliJ from contracting the import statements -* For `Import Layout`: The order is `import static all other imports`, `import java.\*`, `import javax.*`, `import org.\*`, `import com.*`, `import all other imports`. Add a `` between each `import` - -Optionally, you can follow the <> document to configure Intellij to check style-compliance as you write code. - -=== Updating documentation to match your fork - -After forking the repo, the documentation will still have the SE-EDU branding and refer to the `se-edu/addressbook-level3` repo. - -If you plan to develop this fork as a separate product (i.e. instead of contributing to `se-edu/addressbook-level3`), you should do the following: - -. Configure the <> in link:{repoURL}/build.gradle[`build.gradle`], such as the `site-name`, to suit your own project. - -. Replace the URL in the attribute `repoURL` in link:{repoURL}/docs/DeveloperGuide.adoc[`DeveloperGuide.adoc`] and link:{repoURL}/docs/UserGuide.adoc[`UserGuide.adoc`] with the URL of your fork. - -=== Setting up CI - -Set up Travis to perform Continuous Integration (CI) for your fork. See <> to learn how to set it up. - -After setting up Travis, you can optionally set up coverage reporting for your team fork (see <>). - -[NOTE] -Coverage reporting could be useful for a team repository that hosts the final version but it is not that useful for your personal fork. - -Optionally, you can set up AppVeyor as a second CI (see <>). - -[NOTE] -Having both Travis and AppVeyor ensures your App works on both Unix-based platforms and Windows-based platforms (Travis is Unix-based and AppVeyor is Windows-based) - -=== Getting started with coding - -When you are ready to start coding, we recommend that you get some sense of the overall design by reading about <>. += AddressBook Level 3 - Setting Up +:site-section: DeveloperGuide +:toc: +:toc-title: +:toc-placement: preamble +:sectnums: +:imagesDir: images +:stylesDir: stylesheets +:xrefstyle: full +ifdef::env-github[] +:tip-caption: :bulb: +:note-caption: :information_source: +:warning-caption: :warning: +endif::[] +:repoURL: https://github.com/se-edu/addressbook-level3/tree/master + +== Prerequisites + +. *JDK `11`* or above +. *IntelliJ* IDE ++ +[NOTE] +IntelliJ by default has Gradle and JavaFx plugins installed. + +Do not disable them. If you have disabled them, go to `File` > `Settings` > `Plugins` to re-enable them. + +== Setting up the project in your computer + +. Fork this repo, and clone the fork to your computer +. Open IntelliJ (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project dialog first) +. Set up the correct JDK version for Gradle +.. Click `Configure` > `Project Defaults` > `Project Structure` +.. Click `New...` and find the directory of the JDK +. Click `Import Project` +. Locate the `build.gradle` file and select it. Click `OK` +. Click `Open as Project` +. Click `OK` to accept the default settings. + +== Verifying the setup + +. Run the `seedu.address.Main` and try a few commands +. <> to ensure they all pass. + +== Configurations to do before writing code + +=== Configuring the coding style + +This project follows https://github.com/oss-generic/process/blob/master/docs/CodingStandards.adoc[oss-generic coding standards]. IntelliJ's default style is mostly compliant with ours but it uses a different import order from ours. To rectify, + +. Go to `File` > `Settings...` (Windows/Linux), or `IntelliJ IDEA` > `Preferences...` (macOS) +. Select `Editor` > `Code Style` > `Java` +. Click on the `Imports` tab to set the order + +* For `Class count to use import with '\*'` and `Names count to use static import with '*'`: Set to `999` to prevent IntelliJ from contracting the import statements +* For `Import Layout`: The order is `import static all other imports`, `import java.\*`, `import javax.*`, `import org.\*`, `import com.*`, `import all other imports`. Add a `` between each `import` + +Optionally, you can follow the <> document to configure Intellij to check style-compliance as you write code. + +=== Updating documentation to match your fork + +After forking the repo, the documentation will still have the SE-EDU branding and refer to the `se-edu/addressbook-level3` repo. + +If you plan to develop this fork as a separate product (i.e. instead of contributing to `se-edu/addressbook-level3`), you should do the following: + +. Configure the <> in link:{repoURL}/build.gradle[`build.gradle`], such as the `site-name`, to suit your own project. + +. Replace the URL in the attribute `repoURL` in link:{repoURL}/docs/DeveloperGuide.adoc[`DeveloperGuide.adoc`] and link:{repoURL}/docs/UserGuide.adoc[`UserGuide.adoc`] with the URL of your fork. + +=== Setting up CI + +Set up Travis to perform Continuous Integration (CI) for your fork. See <> to learn how to set it up. + +After setting up Travis, you can optionally set up coverage reporting for your team fork (see <>). + +[NOTE] +Coverage reporting could be useful for a team repository that hosts the final version but it is not that useful for your personal fork. + +Optionally, you can set up AppVeyor as a second CI (see <>). + +[NOTE] +Having both Travis and AppVeyor ensures your App works on both Unix-based platforms and Windows-based platforms (Travis is Unix-based and AppVeyor is Windows-based) + +=== Getting started with coding + +When you are ready to start coding, we recommend that you get some sense of the overall design by reading about <>. diff --git a/docs/Testing.adoc b/docs/Testing.adoc index 5767b92912c..978f26e84db 100644 --- a/docs/Testing.adoc +++ b/docs/Testing.adoc @@ -1,52 +1,52 @@ -= AddressBook Level 3 - Testing -:site-section: DeveloperGuide -:toc: -:toc-title: -:toc-placement: preamble -:sectnums: -:imagesDir: images -:stylesDir: stylesheets -:xrefstyle: full -ifdef::env-github[] -:tip-caption: :bulb: -:note-caption: :information_source: -:warning-caption: :warning: -endif::[] -:repoURL: https://github.com/se-edu/addressbook-level3/tree/master - -== Running Tests - -There are two ways to run tests. - -*Method 1: Using IntelliJ JUnit test runner* - -* To run all tests, right-click on the `src/test/java` folder and choose `Run 'All Tests'` -* To run a subset of tests, you can right-click on a test package, test class, or a test and choose `Run 'ABC'` - -*Method 2: Using Gradle* - -* Open a console and run the command `gradlew clean test` (Mac/Linux: `./gradlew clean test`) - -[NOTE] -See <> for more info on how to run tests using Gradle. - -== Types of tests - -We have three types of tests: - -. _Unit tests_ targeting the lowest level methods/classes. + -e.g. `seedu.address.commons.StringUtilTest` -. _Integration tests_ that are checking the integration of multiple code units (those code units are assumed to be working). + -e.g. `seedu.address.storage.StorageManagerTest` -. Hybrids of unit and integration tests. These test are checking multiple code units as well as how the are connected together. + -e.g. `seedu.address.logic.LogicManagerTest` - - -== Troubleshooting Testing -**Problem: Keyboard and mouse movements are not simulated on macOS Mojave, resulting in GUI Tests failure.** - -* Reason: From macOS Mojave onwards, applications without `Accessibility` permission cannot simulate certain keyboard and mouse movements. -* Solution: Open `System Preferences`, click `Security and Privacy` -> `Privacy` -> `Accessibility`, and check the box beside `Intellij IDEA`. - -.`Accessibility` permission is granted to `IntelliJ IDEA` -image::testfx-idea-accessibility-permissions.png[width="600"] += AddressBook Level 3 - Testing +:site-section: DeveloperGuide +:toc: +:toc-title: +:toc-placement: preamble +:sectnums: +:imagesDir: images +:stylesDir: stylesheets +:xrefstyle: full +ifdef::env-github[] +:tip-caption: :bulb: +:note-caption: :information_source: +:warning-caption: :warning: +endif::[] +:repoURL: https://github.com/se-edu/addressbook-level3/tree/master + +== Running Tests + +There are two ways to run tests. + +*Method 1: Using IntelliJ JUnit test runner* + +* To run all tests, right-click on the `src/test/java` folder and choose `Run 'All Tests'` +* To run a subset of tests, you can right-click on a test package, test class, or a test and choose `Run 'ABC'` + +*Method 2: Using Gradle* + +* Open a console and run the command `gradlew clean test` (Mac/Linux: `./gradlew clean test`) + +[NOTE] +See <> for more info on how to run tests using Gradle. + +== Types of tests + +We have three types of tests: + +. _Unit tests_ targeting the lowest level methods/classes. + +e.g. `seedu.address.commons.StringUtilTest` +. _Integration tests_ that are checking the integration of multiple code units (those code units are assumed to be working). + +e.g. `seedu.address.storage.StorageManagerTest` +. Hybrids of unit and integration tests. These test are checking multiple code units as well as how the are connected together. + +e.g. `seedu.address.logic.LogicManagerTest` + + +== Troubleshooting Testing +**Problem: Keyboard and mouse movements are not simulated on macOS Mojave, resulting in GUI Tests failure.** + +* Reason: From macOS Mojave onwards, applications without `Accessibility` permission cannot simulate certain keyboard and mouse movements. +* Solution: Open `System Preferences`, click `Security and Privacy` -> `Privacy` -> `Accessibility`, and check the box beside `Intellij IDEA`. + +.`Accessibility` permission is granted to `IntelliJ IDEA` +image::testfx-idea-accessibility-permissions.png[width="600"] diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index 4e5d297a19f..6123c6cd62d 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -1,177 +1,177 @@ -= AddressBook Level 3 - User Guide -:site-section: UserGuide -:toc: -:toc-title: -:toc-placement: preamble -:sectnums: -:imagesDir: images -:stylesDir: stylesheets -:xrefstyle: full -:experimental: -ifdef::env-github[] -:tip-caption: :bulb: -:note-caption: :information_source: -endif::[] -:repoURL: https://github.com/se-edu/addressbook-level3 - -By: `Team SE-EDU` Since: `Jun 2016` Licence: `MIT` - -== Introduction - -AddressBook Level 3 (AB3) is for those who *prefer to use a desktop app for managing contacts*. More importantly, AB3 is *optimized for those who prefer to work with a Command Line Interface* (CLI) while still having the benefits of a Graphical User Interface (GUI). If you can type fast, AB3 can get your contact management tasks done faster than traditional GUI apps. Interested? Jump to the <> to get started. Enjoy! - -== Quick Start - -. Ensure you have Java `11` or above installed in your Computer. -. Download the latest `addressbook.jar` link:{repoURL}/releases[here]. -. Copy the file to the folder you want to use as the home folder for your Address Book. -. Double-click the file to start the app. The GUI should appear in a few seconds. -+ -image::Ui.png[width="790"] -+ -. Type the command in the command box and press kbd:[Enter] to execute it. + -e.g. typing *`help`* and pressing kbd:[Enter] will open the help window. -. Some example commands you can try: - -* *`list`* : lists all contacts -* **`add`**`n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` : adds a contact named `John Doe` to the Address Book. -* **`delete`**`3` : deletes the 3rd contact shown in the current list -* *`exit`* : exits the app - -. Refer to <> for details of each command. - -[[Features]] -== Features - -==== -*Command Format* - -* Words in `UPPER_CASE` are the parameters to be supplied by the user e.g. in `add n/NAME`, `NAME` is a parameter which can be used as `add n/John Doe`. -* Items in square brackets are optional e.g `n/NAME [t/TAG]` can be used as `n/John Doe t/friend` or as `n/John Doe`. -* Items with `…`​ after them can be used multiple times including zero times e.g. `[t/TAG]...` can be used as `{nbsp}` (i.e. 0 times), `t/friend`, `t/friend t/family` etc. -* Parameters can be in any order e.g. if the command specifies `n/NAME p/PHONE_NUMBER`, `p/PHONE_NUMBER n/NAME` is also acceptable. -==== - -=== Viewing help : `help` - -Format: `help` - -=== Adding a person: `add` - -Adds a person to the address book + -Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]...` - -[TIP] -A person can have any number of tags (including 0) - -Examples: - -* `add n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` -* `add n/Betsy Crowe t/friend e/betsycrowe@example.com a/Newgate Prison p/1234567 t/criminal` - -=== Listing all persons : `list` - -Shows a list of all persons in the address book. + -Format: `list` - -=== Editing a person : `edit` - -Edits an existing person in the address book. + -Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [t/TAG]...` - -**** -* Edits the person at the specified `INDEX`. The index refers to the index number shown in the displayed person list. The index *must be a positive integer* 1, 2, 3, ... -* At least one of the optional fields must be provided. -* Existing values will be updated to the input values. -* When editing tags, the existing tags of the person will be removed i.e adding of tags is not cumulative. -* You can remove all the person's tags by typing `t/` without specifying any tags after it. -**** - -Examples: - -* `edit 1 p/91234567 e/johndoe@example.com` + -Edits the phone number and email address of the 1st person to be `91234567` and `johndoe@example.com` respectively. -* `edit 2 n/Betsy Crower t/` + -Edits the name of the 2nd person to be `Betsy Crower` and clears all existing tags. - -=== Locating persons by name: `find` - -Finds persons whose names contain any of the given keywords. + -Format: `find KEYWORD [MORE_KEYWORDS]` - -**** -* The search is case insensitive. e.g `hans` will match `Hans` -* The order of the keywords does not matter. e.g. `Hans Bo` will match `Bo Hans` -* Only the name is searched. -* Only full words will be matched e.g. `Han` will not match `Hans` -* Persons matching at least one keyword will be returned (i.e. `OR` search). e.g. `Hans Bo` will return `Hans Gruber`, `Bo Yang` -**** - -Examples: - -* `find John` + -Returns `john` and `John Doe` -* `find Betsy Tim John` + -Returns any person having names `Betsy`, `Tim`, or `John` - -// tag::delete[] -=== Deleting a person : `delete` - -Deletes the specified person from the address book. + -Format: `delete INDEX` - -**** -* Deletes the person at the specified `INDEX`. -* The index refers to the index number shown in the displayed person list. -* The index *must be a positive integer* 1, 2, 3, ... -**** - -Examples: - -* `list` + -`delete 2` + -Deletes the 2nd person in the address book. -* `find Betsy` + -`delete 1` + -Deletes the 1st person in the results of the `find` command. - -// end::delete[] -=== Clearing all entries : `clear` - -Clears all entries from the address book. + -Format: `clear` - -=== Exiting the program : `exit` - -Exits the program. + -Format: `exit` - -=== Saving the data - -Address book data are saved in the hard disk automatically after any command that changes the data. + -There is no need to save manually. - -// tag::dataencryption[] -=== Encrypting data files `[coming in v2.0]` - -_{explain how the user can enable/disable data encryption}_ -// end::dataencryption[] - -== FAQ - -*Q*: How do I transfer my data to another Computer? + -*A*: Install the app in the other computer and overwrite the empty data file it creates with the file that contains the data of your previous Address Book folder. - -== Command Summary - -* *Add* `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]...` + -e.g. `add n/James Ho p/22224444 e/jamesho@example.com a/123, Clementi Rd, 1234665 t/friend t/colleague` -* *Clear* : `clear` -* *Delete* : `delete INDEX` + -e.g. `delete 3` -* *Edit* : `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [t/TAG]...` + -e.g. `edit 2 n/James Lee e/jameslee@example.com` -* *Find* : `find KEYWORD [MORE_KEYWORDS]` + -e.g. `find James Jake` -* *List* : `list` -* *Help* : `help` += AddressBook Level 3 - User Guide +:site-section: UserGuide +:toc: +:toc-title: +:toc-placement: preamble +:sectnums: +:imagesDir: images +:stylesDir: stylesheets +:xrefstyle: full +:experimental: +ifdef::env-github[] +:tip-caption: :bulb: +:note-caption: :information_source: +endif::[] +:repoURL: https://github.com/se-edu/addressbook-level3 + +By: `Team SE-EDU` Since: `Jun 2016` Licence: `MIT` + +== Introduction + +AddressBook Level 3 (AB3) is for those who *prefer to use a desktop app for managing contacts*. More importantly, AB3 is *optimized for those who prefer to work with a Command Line Interface* (CLI) while still having the benefits of a Graphical User Interface (GUI). If you can type fast, AB3 can get your contact management tasks done faster than traditional GUI apps. Interested? Jump to the <> to get started. Enjoy! + +== Quick Start + +. Ensure you have Java `11` or above installed in your Computer. +. Download the latest `addressbook.jar` link:{repoURL}/releases[here]. +. Copy the file to the folder you want to use as the home folder for your Address Book. +. Double-click the file to start the app. The GUI should appear in a few seconds. ++ +image::Ui.png[width="790"] ++ +. Type the command in the command box and press kbd:[Enter] to execute it. + +e.g. typing *`help`* and pressing kbd:[Enter] will open the help window. +. Some example commands you can try: + +* *`list`* : lists all contacts +* **`add`**`n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` : adds a contact named `John Doe` to the Address Book. +* **`delete`**`3` : deletes the 3rd contact shown in the current list +* *`exit`* : exits the app + +. Refer to <> for details of each command. + +[[Features]] +== Features + +==== +*Command Format* + +* Words in `UPPER_CASE` are the parameters to be supplied by the user e.g. in `add n/NAME`, `NAME` is a parameter which can be used as `add n/John Doe`. +* Items in square brackets are optional e.g `n/NAME [t/TAG]` can be used as `n/John Doe t/friend` or as `n/John Doe`. +* Items with `…`​ after them can be used multiple times including zero times e.g. `[t/TAG]...` can be used as `{nbsp}` (i.e. 0 times), `t/friend`, `t/friend t/family` etc. +* Parameters can be in any order e.g. if the command specifies `n/NAME p/PHONE_NUMBER`, `p/PHONE_NUMBER n/NAME` is also acceptable. +==== + +=== Viewing help : `help` + +Format: `help` + +=== Adding a person: `add` + +Adds a person to the address book + +Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]...` + +[TIP] +A person can have any number of tags (including 0) + +Examples: + +* `add n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` +* `add n/Betsy Crowe t/friend e/betsycrowe@example.com a/Newgate Prison p/1234567 t/criminal` + +=== Listing all persons : `list` + +Shows a list of all persons in the address book. + +Format: `list` + +=== Editing a person : `edit` + +Edits an existing person in the address book. + +Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [t/TAG]...` + +**** +* Edits the person at the specified `INDEX`. The index refers to the index number shown in the displayed person list. The index *must be a positive integer* 1, 2, 3, ... +* At least one of the optional fields must be provided. +* Existing values will be updated to the input values. +* When editing tags, the existing tags of the person will be removed i.e adding of tags is not cumulative. +* You can remove all the person's tags by typing `t/` without specifying any tags after it. +**** + +Examples: + +* `edit 1 p/91234567 e/johndoe@example.com` + +Edits the phone number and email address of the 1st person to be `91234567` and `johndoe@example.com` respectively. +* `edit 2 n/Betsy Crower t/` + +Edits the name of the 2nd person to be `Betsy Crower` and clears all existing tags. + +=== Locating persons by name: `find` + +Finds persons whose names contain any of the given keywords. + +Format: `find KEYWORD [MORE_KEYWORDS]` + +**** +* The search is case insensitive. e.g `hans` will match `Hans` +* The order of the keywords does not matter. e.g. `Hans Bo` will match `Bo Hans` +* Only the name is searched. +* Only full words will be matched e.g. `Han` will not match `Hans` +* Persons matching at least one keyword will be returned (i.e. `OR` search). e.g. `Hans Bo` will return `Hans Gruber`, `Bo Yang` +**** + +Examples: + +* `find John` + +Returns `john` and `John Doe` +* `find Betsy Tim John` + +Returns any person having names `Betsy`, `Tim`, or `John` + +// tag::delete[] +=== Deleting a person : `delete` + +Deletes the specified person from the address book. + +Format: `delete INDEX` + +**** +* Deletes the person at the specified `INDEX`. +* The index refers to the index number shown in the displayed person list. +* The index *must be a positive integer* 1, 2, 3, ... +**** + +Examples: + +* `list` + +`delete 2` + +Deletes the 2nd person in the address book. +* `find Betsy` + +`delete 1` + +Deletes the 1st person in the results of the `find` command. + +// end::delete[] +=== Clearing all entries : `clear` + +Clears all entries from the address book. + +Format: `clear` + +=== Exiting the program : `exit` + +Exits the program. + +Format: `exit` + +=== Saving the data + +Address book data are saved in the hard disk automatically after any command that changes the data. + +There is no need to save manually. + +// tag::dataencryption[] +=== Encrypting data files `[coming in v2.0]` + +_{explain how the user can enable/disable data encryption}_ +// end::dataencryption[] + +== FAQ + +*Q*: How do I transfer my data to another Computer? + +*A*: Install the app in the other computer and overwrite the empty data file it creates with the file that contains the data of your previous Address Book folder. + +== Command Summary + +* *Add* `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]...` + +e.g. `add n/James Ho p/22224444 e/jamesho@example.com a/123, Clementi Rd, 1234665 t/friend t/colleague` +* *Clear* : `clear` +* *Delete* : `delete INDEX` + +e.g. `delete 3` +* *Edit* : `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [t/TAG]...` + +e.g. `edit 2 n/James Lee e/jameslee@example.com` +* *Find* : `find KEYWORD [MORE_KEYWORDS]` + +e.g. `find James Jake` +* *List* : `list` +* *Help* : `help` diff --git a/docs/UsingAppVeyor.adoc b/docs/UsingAppVeyor.adoc index 12a7a89ac68..d726b1f62ff 100644 --- a/docs/UsingAppVeyor.adoc +++ b/docs/UsingAppVeyor.adoc @@ -1,94 +1,94 @@ -= AppVeyor -:site-section: DeveloperGuide -:imagesDir: images -:stylesDir: stylesheets -ifdef::env-github[] -:note-caption: :information_source: -endif::[] - -[NOTE] -==== -This document was originally written for _AddressBook Level 4_ and hence its screenshots refer to `addressbook-level4`. -For use with _AddressBook Level 3_, wherever `addressbook-level4` is used in the screenshots, you should use *`addressbook-level3`*. -==== - -https://www.appveyor.com/[AppVeyor] is a _Continuous Integration_ platform for GitHub projects. It runs its builds on Windows virtual machines. - -AppVeyor can run the project's tests automatically whenever new code is pushed to the repo. This ensures that existing functionality and features have not been broken on Windows by the changes. - -The current AppVeyor setup runs `gradlew.bat test` whenever someone pushes code to the repo. - -If you would like to customize your AppVeyor build further, you can learn more about AppVeyor from the https://www.appveyor.com/docs/[AppVeyor Documentation]. - -== Setting up AppVeyor - -. Fork the repo to your own organization. -. Go to https://ci.appveyor.com/, and under `Login`, click on `GitHub` to login with your GitHub account. Enter your GitHub account details if needed. -+ -image:appveyor/login.png[Click on GitHub in the login page] -+ -. After logging in, you will be brought to your projects dashboard. Click on `NEW PROJECT`. -+ -image:appveyor/add-project-1.png[Click on "NEW PROJECT" in the projects dashboard] -+ -. You will be brought to the `Select repository` page. Select `GitHub`. -* On your first usage of AppVeyor, you will need to give AppVeyor authorization to your GitHub account. Click on `Authorize GitHub`. -+ -image:appveyor/add-project-2.png[Click on Authorize GitHub] -+ -* This will bring you to a GitHub page that manages the access of third-party applications to your repositories. -+ -Depending on whether you are the owner of the repository, you can either -grant access: -+ -image:grant_access.png[Grant Access] -+ -Or request access: -+ -image:request_access.png[Request Access] -+ -. AppVeyor will then list the repositories you have access to in your GitHub account. Find the repository you want to set AppVeyor up on, and then click `ADD`. -+ -image:appveyor/add-project-3.png[Click "Add" on the repository you want to set AppVeyor up on] -+ -. AppVeyor will then be activated on that repository. To see the CI in action, push a commit to any branch! -* Go to the repository and see the pushed commit. There should be an icon which will link you to the AppVeyor build: -+ -image:appveyor/ci-pending.png[Commit build] -+ -* As the build is run on a remote machine, we can only examine the logs it produces: -+ -image:appveyor/ci-log.png[AppVeyor build] -+ -. Update the link to the "build status" badge at the top of `README.adoc` to point to the AppVeyor build status of your own repo. -* To find your build status badge URL, first go to your project settings by clicking on the "Settings" icon: -+ -image:appveyor/project-settings-1.png[Click on project settings] -+ -* Then go to the `Badges` section of your project settings by clicking on it: -+ -image:appveyor/project-settings-2.png[Click on "Badges"] -+ -* As AppVeyor does not provide asciidoc code for the badge, we will have to create our own. Start by copying the markdown code provided: -+ -image:appveyor/project-settings-3.png[Copy the markdown code] -+ -The markdown code should be in this format: -+ ----- -[![Build status]()]() ----- -+ -Convert it to the asciidoc format as follows: -+ ----- -[image:[Build status]] ----- -+ -The asciidoc code should look similar to: -+ ----- -https://ci.appveyor.com/project/damithc/addressbook-level3[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]] ----- -+ -Copy and paste the asciidoc code to your `README.adoc` file. += AppVeyor +:site-section: DeveloperGuide +:imagesDir: images +:stylesDir: stylesheets +ifdef::env-github[] +:note-caption: :information_source: +endif::[] + +[NOTE] +==== +This document was originally written for _AddressBook Level 4_ and hence its screenshots refer to `addressbook-level4`. +For use with _AddressBook Level 3_, wherever `addressbook-level4` is used in the screenshots, you should use *`addressbook-level3`*. +==== + +https://www.appveyor.com/[AppVeyor] is a _Continuous Integration_ platform for GitHub projects. It runs its builds on Windows virtual machines. + +AppVeyor can run the project's tests automatically whenever new code is pushed to the repo. This ensures that existing functionality and features have not been broken on Windows by the changes. + +The current AppVeyor setup runs `gradlew.bat test` whenever someone pushes code to the repo. + +If you would like to customize your AppVeyor build further, you can learn more about AppVeyor from the https://www.appveyor.com/docs/[AppVeyor Documentation]. + +== Setting up AppVeyor + +. Fork the repo to your own organization. +. Go to https://ci.appveyor.com/, and under `Login`, click on `GitHub` to login with your GitHub account. Enter your GitHub account details if needed. ++ +image:appveyor/login.png[Click on GitHub in the login page] ++ +. After logging in, you will be brought to your projects dashboard. Click on `NEW PROJECT`. ++ +image:appveyor/add-project-1.png[Click on "NEW PROJECT" in the projects dashboard] ++ +. You will be brought to the `Select repository` page. Select `GitHub`. +* On your first usage of AppVeyor, you will need to give AppVeyor authorization to your GitHub account. Click on `Authorize GitHub`. ++ +image:appveyor/add-project-2.png[Click on Authorize GitHub] ++ +* This will bring you to a GitHub page that manages the access of third-party applications to your repositories. ++ +Depending on whether you are the owner of the repository, you can either +grant access: ++ +image:grant_access.png[Grant Access] ++ +Or request access: ++ +image:request_access.png[Request Access] ++ +. AppVeyor will then list the repositories you have access to in your GitHub account. Find the repository you want to set AppVeyor up on, and then click `ADD`. ++ +image:appveyor/add-project-3.png[Click "Add" on the repository you want to set AppVeyor up on] ++ +. AppVeyor will then be activated on that repository. To see the CI in action, push a commit to any branch! +* Go to the repository and see the pushed commit. There should be an icon which will link you to the AppVeyor build: ++ +image:appveyor/ci-pending.png[Commit build] ++ +* As the build is run on a remote machine, we can only examine the logs it produces: ++ +image:appveyor/ci-log.png[AppVeyor build] ++ +. Update the link to the "build status" badge at the top of `README.adoc` to point to the AppVeyor build status of your own repo. +* To find your build status badge URL, first go to your project settings by clicking on the "Settings" icon: ++ +image:appveyor/project-settings-1.png[Click on project settings] ++ +* Then go to the `Badges` section of your project settings by clicking on it: ++ +image:appveyor/project-settings-2.png[Click on "Badges"] ++ +* As AppVeyor does not provide asciidoc code for the badge, we will have to create our own. Start by copying the markdown code provided: ++ +image:appveyor/project-settings-3.png[Copy the markdown code] ++ +The markdown code should be in this format: ++ +---- +[![Build status]()]() +---- ++ +Convert it to the asciidoc format as follows: ++ +---- +[image:[Build status]] +---- ++ +The asciidoc code should look similar to: ++ +---- +https://ci.appveyor.com/project/damithc/addressbook-level3[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]] +---- ++ +Copy and paste the asciidoc code to your `README.adoc` file. diff --git a/docs/UsingCheckstyle.adoc b/docs/UsingCheckstyle.adoc index a12ab09cc9c..326b56dc424 100644 --- a/docs/UsingCheckstyle.adoc +++ b/docs/UsingCheckstyle.adoc @@ -1,48 +1,48 @@ -= Using Checkstyle-IDEA -:site-section: DeveloperGuide -:imagesDir: images -:stylesDir: stylesheets -:experimental: -ifdef::env-github[] -:tip-caption: :bulb: -:note-caption: :information_source: -endif::[] - -[NOTE] -==== -This document was originally written for _AddressBook Level 4_ and hence its screenshots refer to `addressbook-level4`. -For use with _AddressBook Level 3_, wherever `addressbook-level4` is used in the screenshots, you should use *`addressbook-level3`*. -==== - -== Configuring Checkstyle-IDEA - -. Install the Checkstyle-IDEA plugin by going to `File` > `Settings` (Windows/Linux), or `IntelliJ IDEA` > `Preferences...` (macOS). + -Select `Plugins`, press `Browse Repository`, and find the plugin. + -Restart the IDE to complete the installation. -. Click `File` > `Settings...` > `Other Settings` > `Checkstyle` -. Set `Scan Scope` to `Only Java sources (including tests)`, so that the plugin will run checkstyle for our test source codes as well -. Ensure that the `Checkstyle version` is set to `8.1`. This is the same version that we are using inside Gradle, so that you won't get any errors due to version incompatibility - * If `Checkstyle version` is not set to `8.1`, set it to version `8.1` and click `Apply` -+ -image::checkstyle-idea-scan-scope.png[width="500"] -. Click the plus sign under `Configuration File` -. Enter an arbitrary description e.g. addressbook -. Select `Use a local Checkstyle file` -. Use the checkstyle configuration file found at `config/checkstyle/checkstyle.xml` -. Click `Next` > `Finish` -. Mark `Active` for the newly imported check configuration -+ -image::checkstyle-idea-configuration.png[width="700"] -. Click `OK` - -== Troubleshooting Checkstyle-IDEA - -**Problem: When importing `checkstyle.xml`, Checkstyle-IDEA plugin complains that `The Checkstyle rules file could not be parsed. ... The file has been blacklisted for 60s.`** - -* Reason: `checkstyle.xml` is written for a particular version, but the plugin was not configured to the correct version. -* Solution: Ensure that you have selected the correct `Checkstyle version` that matches the version in `build.gradle` and have clicked `Apply`, as `checkstyle.xml` is written for Gradle's checkstyle. - -**Problem: After setting up `checkstyle.xml`, Checkstyle-IDEA plugin does not seem to highlight the errors / real-time scanning seems broken.** - -* Reason: The plugin may not immediately run after setting it up. -* Solution: Restart the IDE. += Using Checkstyle-IDEA +:site-section: DeveloperGuide +:imagesDir: images +:stylesDir: stylesheets +:experimental: +ifdef::env-github[] +:tip-caption: :bulb: +:note-caption: :information_source: +endif::[] + +[NOTE] +==== +This document was originally written for _AddressBook Level 4_ and hence its screenshots refer to `addressbook-level4`. +For use with _AddressBook Level 3_, wherever `addressbook-level4` is used in the screenshots, you should use *`addressbook-level3`*. +==== + +== Configuring Checkstyle-IDEA + +. Install the Checkstyle-IDEA plugin by going to `File` > `Settings` (Windows/Linux), or `IntelliJ IDEA` > `Preferences...` (macOS). + +Select `Plugins`, press `Browse Repository`, and find the plugin. + +Restart the IDE to complete the installation. +. Click `File` > `Settings...` > `Other Settings` > `Checkstyle` +. Set `Scan Scope` to `Only Java sources (including tests)`, so that the plugin will run checkstyle for our test source codes as well +. Ensure that the `Checkstyle version` is set to `8.1`. This is the same version that we are using inside Gradle, so that you won't get any errors due to version incompatibility + * If `Checkstyle version` is not set to `8.1`, set it to version `8.1` and click `Apply` ++ +image::checkstyle-idea-scan-scope.png[width="500"] +. Click the plus sign under `Configuration File` +. Enter an arbitrary description e.g. addressbook +. Select `Use a local Checkstyle file` +. Use the checkstyle configuration file found at `config/checkstyle/checkstyle.xml` +. Click `Next` > `Finish` +. Mark `Active` for the newly imported check configuration ++ +image::checkstyle-idea-configuration.png[width="700"] +. Click `OK` + +== Troubleshooting Checkstyle-IDEA + +**Problem: When importing `checkstyle.xml`, Checkstyle-IDEA plugin complains that `The Checkstyle rules file could not be parsed. ... The file has been blacklisted for 60s.`** + +* Reason: `checkstyle.xml` is written for a particular version, but the plugin was not configured to the correct version. +* Solution: Ensure that you have selected the correct `Checkstyle version` that matches the version in `build.gradle` and have clicked `Apply`, as `checkstyle.xml` is written for Gradle's checkstyle. + +**Problem: After setting up `checkstyle.xml`, Checkstyle-IDEA plugin does not seem to highlight the errors / real-time scanning seems broken.** + +* Reason: The plugin may not immediately run after setting it up. +* Solution: Restart the IDE. diff --git a/docs/UsingCoveralls.adoc b/docs/UsingCoveralls.adoc index 5191e47316c..72548dc2f6a 100644 --- a/docs/UsingCoveralls.adoc +++ b/docs/UsingCoveralls.adoc @@ -1,63 +1,63 @@ -= Using Coveralls -:site-section: DeveloperGuide -:imagesDir: images -:stylesDir: stylesheets -ifdef::env-github[] -:note-caption: :information_source: -endif::[] - -[NOTE] -==== -This document was originally written for _AddressBook Level 4_ and hence its screenshots refer to `addressbook-level4`. -For use with _AddressBook Level 3_, wherever `addressbook-level4` is used in the screenshots, you should use *`addressbook-level3`*. -==== - -https://coveralls.io/[Coveralls] is a web service that tracks code coverage over time for GitHub projects. -Coveralls requires Travis CI to be set up beforehand as Travis sends the coverage report from the latest build to Coveralls. -If you have not set up Travis CI, see <>. Currently, Coveralls supports Travis CI but not AppVeyor. - -== Setting up Coveralls - -. Go to https://coveralls.io/ and click `SIGN IN`. Then click `GITHUB SIGN IN` and enter your GitHub account details if needed. -+ -. After logging in, you will be brought to the `Your Repositories` page. On the site's navigation bar, click https://coveralls.io/repos/new[ADD REPOS]. -+ -. Find the switch for the forked repository. -* If the organization is not shown, click `GITHUB SETTINGS` as shown below: -+ -image:coveralls/github_settings.png[GitHub settings] -+ -This should bring you to a GitHub page that manages the access of third-party applications. Depending on whether you are the owner of the repository, you can either grant access -+ -image:grant_access.png[Grant Access] -+ -or request access -+ -image:request_access.png[Request Access] -+ -to Coveralls so that it can access your repository. -* If your repository cannot be found, click `SYNC REPOS`. -+ -image:coveralls/sync_repos.png[Sync repos] -+ -. Activate the switch. -+ -image:coveralls/flick_repository_switch.png[Activate the switch] -+ -. Update the link of the `Coverage Status` badge at the top of your <> to point to that of your own repo by replacing the outlined areas with `your-org-name/your-repo-name`. -+ -image:coveralls/coverage_asciidoc_code.png[Coverage Status Badge] -+ -. You can now see the coverage report for your project after each Travis build by clicking on the `Coverage Status` badge. -+ -image:coveralls/coverage_report.png[Coverage Report Summary] - -== Disabling Coveralls Automatic Comments on Pull Requests - -Coveralls automatically comments on the coverage status of the pull requests in GitHub. If it's a hindrance, you can disable it in the settings of your project in Coveralls: - -. Click `Settings`. -+ -. Uncheck the `LEAVE COMMENTS?` checkbox. Then click `SAVE CHANGES`. -+ -image:coveralls/disable_comments.png[Disable comments, width = 942] += Using Coveralls +:site-section: DeveloperGuide +:imagesDir: images +:stylesDir: stylesheets +ifdef::env-github[] +:note-caption: :information_source: +endif::[] + +[NOTE] +==== +This document was originally written for _AddressBook Level 4_ and hence its screenshots refer to `addressbook-level4`. +For use with _AddressBook Level 3_, wherever `addressbook-level4` is used in the screenshots, you should use *`addressbook-level3`*. +==== + +https://coveralls.io/[Coveralls] is a web service that tracks code coverage over time for GitHub projects. +Coveralls requires Travis CI to be set up beforehand as Travis sends the coverage report from the latest build to Coveralls. +If you have not set up Travis CI, see <>. Currently, Coveralls supports Travis CI but not AppVeyor. + +== Setting up Coveralls + +. Go to https://coveralls.io/ and click `SIGN IN`. Then click `GITHUB SIGN IN` and enter your GitHub account details if needed. ++ +. After logging in, you will be brought to the `Your Repositories` page. On the site's navigation bar, click https://coveralls.io/repos/new[ADD REPOS]. ++ +. Find the switch for the forked repository. +* If the organization is not shown, click `GITHUB SETTINGS` as shown below: ++ +image:coveralls/github_settings.png[GitHub settings] ++ +This should bring you to a GitHub page that manages the access of third-party applications. Depending on whether you are the owner of the repository, you can either grant access ++ +image:grant_access.png[Grant Access] ++ +or request access ++ +image:request_access.png[Request Access] ++ +to Coveralls so that it can access your repository. +* If your repository cannot be found, click `SYNC REPOS`. ++ +image:coveralls/sync_repos.png[Sync repos] ++ +. Activate the switch. ++ +image:coveralls/flick_repository_switch.png[Activate the switch] ++ +. Update the link of the `Coverage Status` badge at the top of your <> to point to that of your own repo by replacing the outlined areas with `your-org-name/your-repo-name`. ++ +image:coveralls/coverage_asciidoc_code.png[Coverage Status Badge] ++ +. You can now see the coverage report for your project after each Travis build by clicking on the `Coverage Status` badge. ++ +image:coveralls/coverage_report.png[Coverage Report Summary] + +== Disabling Coveralls Automatic Comments on Pull Requests + +Coveralls automatically comments on the coverage status of the pull requests in GitHub. If it's a hindrance, you can disable it in the settings of your project in Coveralls: + +. Click `Settings`. ++ +. Uncheck the `LEAVE COMMENTS?` checkbox. Then click `SAVE CHANGES`. ++ +image:coveralls/disable_comments.png[Disable comments, width = 942] diff --git a/docs/UsingGradle.adoc b/docs/UsingGradle.adoc index cca9c6d1d12..d139247fa2c 100644 --- a/docs/UsingGradle.adoc +++ b/docs/UsingGradle.adoc @@ -1,99 +1,99 @@ -= Using Gradle -:site-section: DeveloperGuide -:imagesDir: images -:stylesDir: stylesheets -:experimental: -ifdef::env-github[] -:tip-caption: :bulb: -:note-caption: :information_source: -endif::[] - -https://gradle.org/[Gradle] is a build automation tool. It can automate build-related tasks such as - -* Running tests -* Managing library dependencies -* Analyzing code for style compliance - -The gradle configuration for this project is defined in the _build script_ link:../build.gradle[`build.gradle`]. - -[NOTE] -To learn more about gradle build scripts, refer https://docs.gradle.org/current/userguide/tutorial_using_tasks.html[Build Scripts Basics]. - -== Running Gradle Commands - -To run a Gradle command, open a command window on the project folder and enter the Gradle command. Gradle commands look like this: - -* On Windows: `gradlew ...` e.g. `gradlew clean test` -* On Mac/Linux: `./gradlew ...` e.g. -`./gradlew clean test` - -[NOTE] -If you do not specify any tasks, Gradlew will run the default tasks `clean` `test` `coverage` - -== Cleaning the Project - -* *`clean`* + -Deletes the files created during the previous build tasks (e.g. files in the `build` folder). e.g. `./gradlew clean` - -[TIP] -*`clean` to force Gradle to execute a task*: + -When running a Gradle task, Gradle will try to figure out if the task needs running at all. If Gradle determines that the output of the task will be same as the previous time, it will not run the task. For example, it will not build the JAR file again if the relevant source files have not changed since the last time the JAR file was built. If we want to force Gradle to run a task, we can combine that task with `clean`. Once the build files have been `clean` ed, Gradle has no way to determine if the output will be same as before, so it will be forced to execute the task. - -== Creating the JAR file - -* *`shadowJar`* + -Creates the `addressbook.jar` file in the `build/jar` folder, _if the current file is outdated_. + -e.g. `./gradlew shadowJar` - -**** -To force Gradle to create the JAR file even if the current one is up-to-date, you can '`clean`' first. + -e.g. `./gradlew clean shadowJar` -**** - -[NOTE] -*Why do we create a fat JAR?* If we package only our own class files into the JAR file, it will not work properly unless the user has all the other JAR files (i.e. third party libraries) our classes depend on, which is rather inconvenient. Therefore, we package all dependencies into a single JAR files, creating what is also known as a _fat_ JAR file. To create a fat JAR file, we use the Gradle plugin https://github.com/johnrengelman/shadow[shadow jar]. - -== Rendering AsciiDoc files - -* **`asciidoctor`** + -Converts AsciiDoc files in `docs` to HTML format. Generated HTML files can be found in `build/docs`. -* **`deployOfflineDocs`** + -Updates the offline user guide, and its associated files, used by the Help window in the application. Deployed HTML files and images can be found in `src/main/resources/docs`. - -== Running the application - -* *`run`* + -Builds and runs the application. -* *`runShadow`* + -Builds the application as a fat JAR, and then runs it. - -== Running code style checks - -* **`checkstyleMain`** + -Runs the code style check for the main code base -* **`checkstyleTest`** + -Runs the code style check for the test code base - -The set of code style rules implemented can be found in `config/checkstyle/checkstyle.xml`. To enable _exceptions_ to code styles, add in the comment `//CODESTYLE.OFF: RuleName` at the start of the section and `//CODESTYLE.ON: RuleName` at the end of the section. - -== Running Tests - -* **`test`** + -Runs all tests. - -Here are some examples: - -* `./gradlew test` -- Runs all tests -* `./gradlew clean test` -- Cleans the project and runs tests - -== Updating Dependencies - -There is no need to run these Gradle tasks manually as they are called automatically by other relevant Gradle tasks. - -* **`compileJava`** + -Checks whether the project has the required dependencies to compile and run the main program, and download any missing dependencies before compiling the classes. + -See `build.gradle` -> -`allprojects` -> `dependencies` -> `compile` for the list of dependencies required. -* **`compileTestJava`** + -Checks whether the project has the required dependencies to perform testing, and download any missing dependencies before compiling the test classes. + -See `build.gradle` -> `allprojects` -> `dependencies` -> `testCompile` for the list of dependencies required. += Using Gradle +:site-section: DeveloperGuide +:imagesDir: images +:stylesDir: stylesheets +:experimental: +ifdef::env-github[] +:tip-caption: :bulb: +:note-caption: :information_source: +endif::[] + +https://gradle.org/[Gradle] is a build automation tool. It can automate build-related tasks such as + +* Running tests +* Managing library dependencies +* Analyzing code for style compliance + +The gradle configuration for this project is defined in the _build script_ link:../build.gradle[`build.gradle`]. + +[NOTE] +To learn more about gradle build scripts, refer https://docs.gradle.org/current/userguide/tutorial_using_tasks.html[Build Scripts Basics]. + +== Running Gradle Commands + +To run a Gradle command, open a command window on the project folder and enter the Gradle command. Gradle commands look like this: + +* On Windows: `gradlew ...` e.g. `gradlew clean test` +* On Mac/Linux: `./gradlew ...` e.g. +`./gradlew clean test` + +[NOTE] +If you do not specify any tasks, Gradlew will run the default tasks `clean` `test` `coverage` + +== Cleaning the Project + +* *`clean`* + +Deletes the files created during the previous build tasks (e.g. files in the `build` folder). e.g. `./gradlew clean` + +[TIP] +*`clean` to force Gradle to execute a task*: + +When running a Gradle task, Gradle will try to figure out if the task needs running at all. If Gradle determines that the output of the task will be same as the previous time, it will not run the task. For example, it will not build the JAR file again if the relevant source files have not changed since the last time the JAR file was built. If we want to force Gradle to run a task, we can combine that task with `clean`. Once the build files have been `clean` ed, Gradle has no way to determine if the output will be same as before, so it will be forced to execute the task. + +== Creating the JAR file + +* *`shadowJar`* + +Creates the `addressbook.jar` file in the `build/jar` folder, _if the current file is outdated_. + +e.g. `./gradlew shadowJar` + +**** +To force Gradle to create the JAR file even if the current one is up-to-date, you can '`clean`' first. + +e.g. `./gradlew clean shadowJar` +**** + +[NOTE] +*Why do we create a fat JAR?* If we package only our own class files into the JAR file, it will not work properly unless the user has all the other JAR files (i.e. third party libraries) our classes depend on, which is rather inconvenient. Therefore, we package all dependencies into a single JAR files, creating what is also known as a _fat_ JAR file. To create a fat JAR file, we use the Gradle plugin https://github.com/johnrengelman/shadow[shadow jar]. + +== Rendering AsciiDoc files + +* **`asciidoctor`** + +Converts AsciiDoc files in `docs` to HTML format. Generated HTML files can be found in `build/docs`. +* **`deployOfflineDocs`** + +Updates the offline user guide, and its associated files, used by the Help window in the application. Deployed HTML files and images can be found in `src/main/resources/docs`. + +== Running the application + +* *`run`* + +Builds and runs the application. +* *`runShadow`* + +Builds the application as a fat JAR, and then runs it. + +== Running code style checks + +* **`checkstyleMain`** + +Runs the code style check for the main code base +* **`checkstyleTest`** + +Runs the code style check for the test code base + +The set of code style rules implemented can be found in `config/checkstyle/checkstyle.xml`. To enable _exceptions_ to code styles, add in the comment `//CODESTYLE.OFF: RuleName` at the start of the section and `//CODESTYLE.ON: RuleName` at the end of the section. + +== Running Tests + +* **`test`** + +Runs all tests. + +Here are some examples: + +* `./gradlew test` -- Runs all tests +* `./gradlew clean test` -- Cleans the project and runs tests + +== Updating Dependencies + +There is no need to run these Gradle tasks manually as they are called automatically by other relevant Gradle tasks. + +* **`compileJava`** + +Checks whether the project has the required dependencies to compile and run the main program, and download any missing dependencies before compiling the classes. + +See `build.gradle` -> +`allprojects` -> `dependencies` -> `compile` for the list of dependencies required. +* **`compileTestJava`** + +Checks whether the project has the required dependencies to perform testing, and download any missing dependencies before compiling the test classes. + +See `build.gradle` -> `allprojects` -> `dependencies` -> `testCompile` for the list of dependencies required. diff --git a/docs/UsingNetlify.adoc b/docs/UsingNetlify.adoc index 2e108c936a3..b3c3bee8401 100644 --- a/docs/UsingNetlify.adoc +++ b/docs/UsingNetlify.adoc @@ -1,59 +1,59 @@ -= Using Netlify -:site-section: DeveloperGuide -:imagesDir: images -:stylesDir: stylesheets -ifdef::env-github[] -:note-caption: :information_source: -endif::[] - -[NOTE] -==== -This document was originally written for _AddressBook Level 4_ and hence its screenshots refer to `addressbook-level4`. -For use with _AddressBook Level 3_, wherever `addressbook-level4` is used in the screenshots, you should use *`addressbook-level3`*. -==== - -https://www.netlify.com/[Netlify] is an automated hosting platform for deploying static websites. With the aid of build tools such as Gradle, Netlify provides a smoother experience for previewing documentation. This can be done by using Netlify's https://www.netlify.com/blog/2016/07/20/introducing-deploy-previews-in-netlify/[Deploy Previews] feature, which shows a preview of the updated documentation whenever a pull request is made. - -== Setting up Netlify -. Fork the repository to your own organization. -+ -. Go to https://www.netlify.com/ and click `Sign Up`. Next, click `GITHUB SIGN IN`, enter your GitHub account details and authorize netlify. -+ -. After logging in, click `New site from Git`. -+ -. You will then be brought to the setup page. Click `GitHub` to link your repository to Netlify. -* Depending on whether you are the owner of the repository, you can either grant or request access to Netlify so that it can access your repository and build your documentation. -+ -image:netlify/grant_or_request_access.png[Grant or request access, width = 630] -* After granting or requesting access to your repository, click `Authorize netlify`. -+ -. Pick your repository from the list. -+ -. Fill out the details as follows and then click `Deploy site`. -* Branch to deploy: select `master` branch -* Build command: `./gradlew asciidoctor` -+ -[NOTE] -The build command is the command that builds the documentation into HTML format. -+ -* Publish directory: `build/docs/html5` -[NOTE] -The publish directory is the directory in which the built HTML documentation resides. -+ -. Once Netlify has completed building your project, you can now: -* View your main branch's deployed documentation on the site name given by Netlify (customizable as shown <>). -+ -image:netlify/temp_site_name.png[Temporary site name, width = 630] -+ -* Preview the updated documentation whenever a pull request is made by clicking the `Details` hyperlink next to the Netlify test status. -+ -image:netlify/netlify_details.png[Netlify details link, width = 630] - -== Changing the site name of your project -If you don't like the site name given by Netlify, you can change it as follows: - -. Click on `Settings`. -+ -. Then click `Change site name` and fill in your desired site name. -+ -image:netlify/change_site_name.png[Change site name, width = 630] += Using Netlify +:site-section: DeveloperGuide +:imagesDir: images +:stylesDir: stylesheets +ifdef::env-github[] +:note-caption: :information_source: +endif::[] + +[NOTE] +==== +This document was originally written for _AddressBook Level 4_ and hence its screenshots refer to `addressbook-level4`. +For use with _AddressBook Level 3_, wherever `addressbook-level4` is used in the screenshots, you should use *`addressbook-level3`*. +==== + +https://www.netlify.com/[Netlify] is an automated hosting platform for deploying static websites. With the aid of build tools such as Gradle, Netlify provides a smoother experience for previewing documentation. This can be done by using Netlify's https://www.netlify.com/blog/2016/07/20/introducing-deploy-previews-in-netlify/[Deploy Previews] feature, which shows a preview of the updated documentation whenever a pull request is made. + +== Setting up Netlify +. Fork the repository to your own organization. ++ +. Go to https://www.netlify.com/ and click `Sign Up`. Next, click `GITHUB SIGN IN`, enter your GitHub account details and authorize netlify. ++ +. After logging in, click `New site from Git`. ++ +. You will then be brought to the setup page. Click `GitHub` to link your repository to Netlify. +* Depending on whether you are the owner of the repository, you can either grant or request access to Netlify so that it can access your repository and build your documentation. ++ +image:netlify/grant_or_request_access.png[Grant or request access, width = 630] +* After granting or requesting access to your repository, click `Authorize netlify`. ++ +. Pick your repository from the list. ++ +. Fill out the details as follows and then click `Deploy site`. +* Branch to deploy: select `master` branch +* Build command: `./gradlew asciidoctor` ++ +[NOTE] +The build command is the command that builds the documentation into HTML format. ++ +* Publish directory: `build/docs/html5` +[NOTE] +The publish directory is the directory in which the built HTML documentation resides. ++ +. Once Netlify has completed building your project, you can now: +* View your main branch's deployed documentation on the site name given by Netlify (customizable as shown <>). ++ +image:netlify/temp_site_name.png[Temporary site name, width = 630] ++ +* Preview the updated documentation whenever a pull request is made by clicking the `Details` hyperlink next to the Netlify test status. ++ +image:netlify/netlify_details.png[Netlify details link, width = 630] + +== Changing the site name of your project +If you don't like the site name given by Netlify, you can change it as follows: + +. Click on `Settings`. ++ +. Then click `Change site name` and fill in your desired site name. ++ +image:netlify/change_site_name.png[Change site name, width = 630] diff --git a/docs/UsingPlantUml.adoc b/docs/UsingPlantUml.adoc index cfe2533ea84..1c24cf16c8a 100644 --- a/docs/UsingPlantUml.adoc +++ b/docs/UsingPlantUml.adoc @@ -1,211 +1,211 @@ -= Using PlantUML -:site-section: DeveloperGuide -:imagesDir: images/plantuml -:stylesDir: stylesheets -:experimental: -ifdef::env-github[] -:tip-caption: :bulb: -:note-caption: :information_source: -endif::[] - -== Introduction to PlantUML - -PlantUML is a tool used in this project to create UML diagrams. -For more information about the basics of PlantUML, head over to http://plantuml.com/[its official website]. - -== Set up PlantUML - -=== Installing Graphviz - -Graphviz is a dependency that PlantUML requires to generate more advanced diagrams. -Head over to the https://www.graphviz.org/download/[downloads page] on the official Graphviz website and follow instructions to install Graphviz. - -=== Installing the `PlantUML integration` plugin for IntelliJ IDEA - -Go to `Settings` > `Plugins` > `Marketplace` and install the plugin `PlantUML integration`. - -Then go to `Settings` > `Other Settings` > `PlantUML` or search for PlantUML. -Configure the path to the `dot` executable. -This executable can be found in the `/bin` directory where you installed GraphViz. - -.Settings - Other Settings - PlantUML: input the path to your dot executable -image::ConfiguringGraphviz.png[] - -== Create/Edit PlantUML diagrams - -After installing the `PlantUML integration` plugin, simply create or open any `.puml` file to start editing it. - -.Editing `DeleteSequenceDiagram.puml` -image::EditingDeleteSequenceDiagram.png[] -Any changes you make in editor pane on the left will be reflected in the preview pane on the right. -However, do take note that these changes _will not_ be reflected in the developers guide until you export the diagram. -//TODO: Discussion about why we're not using asciidoctor-diagram - -== Export PlantUML diagrams - -The `PlantUML integration` plugin allows you to export individual diagrams to a location of your choosing. -Click the `Save Current Diagram Only` button and choose the location to export the image file. - -NOTE: You will have to `git add` any new diagrams generated! - -== Common tasks - -=== Applying consistent formatting to PlantUML diagrams - -It is highly recommended to consistently color your UML diagrams as an visual aid. -You can achieve this by creating a dictionary of colors and import it like CSS. - -For example, you can create a `Style.puml` with the contents: - -.Style.puml -[source] ----- -... -!define LOGIC_COLOR #3333C4 -!define LOGIC_COLOR_T1 #7777DB -!define LOGIC_COLOR_T2 #5252CE -!define LOGIC_COLOR_T3 #1616B0 -!define LOGIC_COLOR_T4 #101086 -... ----- - -Then you can use it in another PlantUML file like this: - -.UndoSequenceDiagram.puml -[source] ----- -!include Style.puml - -box Logic LOGIC_COLOR_T2 -participant ":LogicManager" as LogicManager LOGIC_COLOR -participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR -participant ":UndoCommand" as UndoCommand LOGIC_COLOR -end box ----- - -You can fine-tune the formatting of PlantUML diagrams with the `skinparam` command. -For example, `skinparam backgroundColor transparent` turns the background of the diagram transparent. - -For a comprehensive list of ``skinparam``s head over to the https://plantuml-documentation.readthedocs.io/en/latest/[unofficial PlantUML skinparam documentation]. - -*** - -=== Repositioning elements in PlantUML diagrams - -While PlantUML's automatic layout engine usually produces satisfactory results, at times the result can be less than ideal, especially on larger diagrams. -Here is an example where the default layout generated by PlantUML has a lot of overlapping lines that are hard to decipher: - -.The UI class diagram without additional formatting -image::RawUiDiagram.png[] - -NOTE: In most cases, you should consider decomposing the diagram into smaller ones or focusing on a more specific portion of the diagram. - -Here are some of the techniques we used in this project to obtain a more palatable diagram. - -==== Link lengths -By default, a short link (`\->`) points to right and a long link (`-\->`) -points downwards. you can extend any link to make it longer (```--\->```). - -.Length of arrows and its effects -image::ArrowLength.png[] - -==== Link directions -Clever usage of arrow directions will resolve most layout issues. -For example, the table below shows how the way in which you specify arrows can results in drastically different layouts for the same diagram. - -.Link directions -[cols="40a,60a"] -|=== -|Source |Result - -|[source, puml] ----- -A --> Z -B --> Z -C --> Z -D --> Z - -A --> 1 -B --> 2 -C --> 3 -D --> 4 ----- -|image::AllDown.png[] - -|[source, puml] ----- -'default is down -A --> Z -'specify down -B -down-> Z -'shorthand for down -C -d-> Z -'arrow lengths take priority -D -down> Z - -A -up-> 1 -B -up-> 2 -C -up-> 3 -D -up-> 4 - ----- -|image::UpAndDown.png[] - -|[source, puml] ----- -A -up-> Z -B -up-> Z -C -up-> Z -D -up-> Z - -A --> 1 -B --> 2 -C --> 3 -D --> 4 - -'Force A B C D -A -right[hidden]- B -B -right[hidden]- C -C -right[hidden]- D ----- -|image::HiddenArrows.png[] -|=== - -==== Reordering definitions -As a general rule of thumb, the layout engine will attempt to order objects in the order in which they are defined. -If there is no formal definition, the objects is taken to be declared upon its first usage. - -.Definition ordering and outcomes -[cols="70a,30a"] -|=== -|Source |Result - -|[source, puml] ----- -A --> B -C --> D ----- -|image::ABeforeC.png[] - -|[source, puml] ----- -'Class C is defined before A -Class C - -A --> B -C --> D ----- -|image::CBeforeA.png[] - -|[source, puml] ----- -package "Rule Of Thumb"{ - Class C - A --> B - C --> D -} ----- -|image::PackagesAndConsistency.png[] -|=== - -TIP: Explicitly define all symbols to avoid any potential layout mishaps. += Using PlantUML +:site-section: DeveloperGuide +:imagesDir: images/plantuml +:stylesDir: stylesheets +:experimental: +ifdef::env-github[] +:tip-caption: :bulb: +:note-caption: :information_source: +endif::[] + +== Introduction to PlantUML + +PlantUML is a tool used in this project to create UML diagrams. +For more information about the basics of PlantUML, head over to http://plantuml.com/[its official website]. + +== Set up PlantUML + +=== Installing Graphviz + +Graphviz is a dependency that PlantUML requires to generate more advanced diagrams. +Head over to the https://www.graphviz.org/download/[downloads page] on the official Graphviz website and follow instructions to install Graphviz. + +=== Installing the `PlantUML integration` plugin for IntelliJ IDEA + +Go to `Settings` > `Plugins` > `Marketplace` and install the plugin `PlantUML integration`. + +Then go to `Settings` > `Other Settings` > `PlantUML` or search for PlantUML. +Configure the path to the `dot` executable. +This executable can be found in the `/bin` directory where you installed GraphViz. + +.Settings - Other Settings - PlantUML: input the path to your dot executable +image::ConfiguringGraphviz.png[] + +== Create/Edit PlantUML diagrams + +After installing the `PlantUML integration` plugin, simply create or open any `.puml` file to start editing it. + +.Editing `DeleteSequenceDiagram.puml` +image::EditingDeleteSequenceDiagram.png[] +Any changes you make in editor pane on the left will be reflected in the preview pane on the right. +However, do take note that these changes _will not_ be reflected in the developers guide until you export the diagram. +//TODO: Discussion about why we're not using asciidoctor-diagram + +== Export PlantUML diagrams + +The `PlantUML integration` plugin allows you to export individual diagrams to a location of your choosing. +Click the `Save Current Diagram Only` button and choose the location to export the image file. + +NOTE: You will have to `git add` any new diagrams generated! + +== Common tasks + +=== Applying consistent formatting to PlantUML diagrams + +It is highly recommended to consistently color your UML diagrams as an visual aid. +You can achieve this by creating a dictionary of colors and import it like CSS. + +For example, you can create a `Style.puml` with the contents: + +.Style.puml +[source] +---- +... +!define LOGIC_COLOR #3333C4 +!define LOGIC_COLOR_T1 #7777DB +!define LOGIC_COLOR_T2 #5252CE +!define LOGIC_COLOR_T3 #1616B0 +!define LOGIC_COLOR_T4 #101086 +... +---- + +Then you can use it in another PlantUML file like this: + +.UndoSequenceDiagram.puml +[source] +---- +!include Style.puml + +box Logic LOGIC_COLOR_T2 +participant ":LogicManager" as LogicManager LOGIC_COLOR +participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR +participant ":UndoCommand" as UndoCommand LOGIC_COLOR +end box +---- + +You can fine-tune the formatting of PlantUML diagrams with the `skinparam` command. +For example, `skinparam backgroundColor transparent` turns the background of the diagram transparent. + +For a comprehensive list of ``skinparam``s head over to the https://plantuml-documentation.readthedocs.io/en/latest/[unofficial PlantUML skinparam documentation]. + +*** + +=== Repositioning elements in PlantUML diagrams + +While PlantUML's automatic layout engine usually produces satisfactory results, at times the result can be less than ideal, especially on larger diagrams. +Here is an example where the default layout generated by PlantUML has a lot of overlapping lines that are hard to decipher: + +.The UI class diagram without additional formatting +image::RawUiDiagram.png[] + +NOTE: In most cases, you should consider decomposing the diagram into smaller ones or focusing on a more specific portion of the diagram. + +Here are some of the techniques we used in this project to obtain a more palatable diagram. + +==== Link lengths +By default, a short link (`\->`) points to right and a long link (`-\->`) +points downwards. you can extend any link to make it longer (```--\->```). + +.Length of arrows and its effects +image::ArrowLength.png[] + +==== Link directions +Clever usage of arrow directions will resolve most layout issues. +For example, the table below shows how the way in which you specify arrows can results in drastically different layouts for the same diagram. + +.Link directions +[cols="40a,60a"] +|=== +|Source |Result + +|[source, puml] +---- +A --> Z +B --> Z +C --> Z +D --> Z + +A --> 1 +B --> 2 +C --> 3 +D --> 4 +---- +|image::AllDown.png[] + +|[source, puml] +---- +'default is down +A --> Z +'specify down +B -down-> Z +'shorthand for down +C -d-> Z +'arrow lengths take priority +D -down> Z + +A -up-> 1 +B -up-> 2 +C -up-> 3 +D -up-> 4 + +---- +|image::UpAndDown.png[] + +|[source, puml] +---- +A -up-> Z +B -up-> Z +C -up-> Z +D -up-> Z + +A --> 1 +B --> 2 +C --> 3 +D --> 4 + +'Force A B C D +A -right[hidden]- B +B -right[hidden]- C +C -right[hidden]- D +---- +|image::HiddenArrows.png[] +|=== + +==== Reordering definitions +As a general rule of thumb, the layout engine will attempt to order objects in the order in which they are defined. +If there is no formal definition, the objects is taken to be declared upon its first usage. + +.Definition ordering and outcomes +[cols="70a,30a"] +|=== +|Source |Result + +|[source, puml] +---- +A --> B +C --> D +---- +|image::ABeforeC.png[] + +|[source, puml] +---- +'Class C is defined before A +Class C + +A --> B +C --> D +---- +|image::CBeforeA.png[] + +|[source, puml] +---- +package "Rule Of Thumb"{ + Class C + A --> B + C --> D +} +---- +|image::PackagesAndConsistency.png[] +|=== + +TIP: Explicitly define all symbols to avoid any potential layout mishaps. diff --git a/docs/UsingTravis.adoc b/docs/UsingTravis.adoc index 887c0b09068..a71ab2d5807 100644 --- a/docs/UsingTravis.adoc +++ b/docs/UsingTravis.adoc @@ -1,140 +1,140 @@ -= Travis CI -:site-section: DeveloperGuide -:imagesDir: images -:stylesDir: stylesheets -ifdef::env-github[] -:note-caption: :information_source: -endif::[] - -[NOTE] -==== -This document was originally written for _AddressBook Level 4_ and hence its screenshots refer to `addressbook-level4`. -For use with _AddressBook Level 3_, wherever `addressbook-level4` is used in the screenshots, you should use *`addressbook-level3`*. -==== - -https://travis-ci.org/[Travis CI] is a _Continuous Integration_ platform for GitHub projects. - -Travis CI can run the projects' tests automatically whenever new code is pushed to the repo. This ensures that existing functionality and features have not been broken by the changes. - -The current Travis CI set up performs the following things whenever someone push code to the repo: - -* Runs the `./gradlew clean test coverage coveralls -i` command (see <> for more details on what this command means). -* Renders documentation from asciidoc to html and automatically publishes them using GitHub Pages. -* Runs additional link:#repository-wide-checks[repository-wide checks]. - -If you would like to customise your travis build further, you can learn more about Travis from https://docs.travis-ci.com/[Travis CI Documentation]. - -== Setting up Travis CI - -. Fork the repo to your own organization. -. Go to https://travis-ci.org/ and click `Sign in with GitHub`, then enter your GitHub account details if needed. -+ -image:signing_in.png[Signing into Travis CI] -+ -. Head to the https://travis-ci.org/profile[Accounts] page, and find the switch for the forked repository. -* If the organization is not shown, click `Review and add` as shown below: -+ -image:review_and_add.png[Review and add] -+ -This should bring you to a GitHub page that manages the access of third-party applications. Depending on whether you are the owner of the repository, you can either grant access -+ -image:grant_access.png[Grant Access] -+ -or request access -+ -image:request_access.png[Request Access] -+ -to Travis CI so that it can access your commits and build your code. -* If repository cannot be found, click `Sync account` -. Activate the switch. -+ -image:flick_repository_switch.png[Activate the switch] -+ -. This repo comes with a link:../.travis.yml[`.travis.yml`] that tells Travis what to do. So there is no need for you to create one yourself. -. To see the CI in action, push a commit to the master branch! -* Go to the repository and see the pushed commit. There should be an icon which will link you to the Travis build. -+ -image:build_pending.png[Commit build] -+ -* As the build is run on a provided remote machine, we can only examine the logs it produces: -+ -image:travis_build.png[Travis build] -+ -. If the build is successful, you should be able to check the coverage details of the tests at http://coveralls.io/[Coveralls] -. Update the link to the 'build status' badge at the top of the `README.adoc` to point to the build status of your own repo. - -== Enabling auto-publishing of documentation - -. Ensure that you have followed the steps above to set up Travis CI. -. On GitHub, create a new user account and give this account collaborator and admin access to the repo. + - Using this account, generate a personal access token https://github.com/settings/tokens/new[here]. -+ -[NOTE] -Personal access tokens are like passwords so make sure you keep them secret! If the personal access token is leaked, please delete it and generate a new one. -+ -[NOTE] -We use a new user account to generate the token for team projects to prevent team members from gaining access to other team members' repos. + -If you are the only one with write access to the repo, you can use your own account to generate the token. -+ --- -* Add a description for the token. (e.g. `Travis CI - deploy docs to gh-pages`) -* Check the `public_repo` checkbox. -* Click `Generate Token` and copy your new personal access token. --- -We will use this token to grant Travis access to the repo. -+ -image:generate_token.png[Generate token] - -. Head to the https://travis-ci.org/profile[Accounts] page, and find the switch for the forked repository. -+ -image:flick_repository_switch.png[Activate the switch] -+ -. Click on the settings button next to the switch. In the Environment Variables section, add a new environment variable with -+ --- -* name: `GITHUB_TOKEN` -* value: personal access token copied in step 1 -* Display value in build log: `OFF` --- -image:travis_add_token.png[Travis add token] -+ -[NOTE] -*Make sure you set `Display value in build log` to `OFF`.* + -Otherwise, other people will be able to see the personal access token and thus have access this repo. + -Similarly, make sure you *do not print `$GITHUB_TOKEN` to the logs* in Travis scripts as the logs are viewable by the public. - -. Now, whenever there's a new commit to master branch, Travis will push the latest documentation to gh-pages branch. - -**To verify that it works,** - -. Trigger Travis to regenerate documentation. To do so, you need to push a new commit to the master branch of the fork. + - Suggested change: Remove the codacy badge from `README`. -. Wait for Travis CI to finish running the build on your new commit. -. Go to the URL `\https://.github.io/addressbook-level3/index.html`. You should see your `README` file displayed. - -== Repository-wide checks - -In addition to running Gradle checks, we also configure Travis CI to run some repository-wide checks. Unlike the Gradle checks which only cover files used in the build process, these repository-wide checks cover _all_ files in the repository. They check for repository rules which are hard to enforce on development machines such as line ending requirements. - -These checks are implemented as POSIX shell scripts, and thus can only be run on POSIX-compliant operating systems such as macOS and Linux. To run all checks locally on these operating systems, execute the following in the repository root directory: - -[source,shell] ----- -./config/travis/run-checks.sh ----- - -Any warnings or errors will be printed out to the console. - -=== Implementing new checks - -Checks are implemented as executable `check-*` scripts within the `config/travis/` directory. The `run-checks.sh` script will automatically pick up and run files named as such. - -Check scripts should print out errors in the following format: - -.... -SEVERITY:FILENAME:LINE: MESSAGE -.... - -where `SEVERITY` is either `ERROR` or `WARN`, `FILENAME` is the path to the file relative to the current directory, `LINE` is the line of the file where the error occurred and `MESSAGE` is the message explaining the error. - -Check scripts must exit with a non-zero exit code if any errors occur. += Travis CI +:site-section: DeveloperGuide +:imagesDir: images +:stylesDir: stylesheets +ifdef::env-github[] +:note-caption: :information_source: +endif::[] + +[NOTE] +==== +This document was originally written for _AddressBook Level 4_ and hence its screenshots refer to `addressbook-level4`. +For use with _AddressBook Level 3_, wherever `addressbook-level4` is used in the screenshots, you should use *`addressbook-level3`*. +==== + +https://travis-ci.org/[Travis CI] is a _Continuous Integration_ platform for GitHub projects. + +Travis CI can run the projects' tests automatically whenever new code is pushed to the repo. This ensures that existing functionality and features have not been broken by the changes. + +The current Travis CI set up performs the following things whenever someone push code to the repo: + +* Runs the `./gradlew clean test coverage coveralls -i` command (see <> for more details on what this command means). +* Renders documentation from asciidoc to html and automatically publishes them using GitHub Pages. +* Runs additional link:#repository-wide-checks[repository-wide checks]. + +If you would like to customise your travis build further, you can learn more about Travis from https://docs.travis-ci.com/[Travis CI Documentation]. + +== Setting up Travis CI + +. Fork the repo to your own organization. +. Go to https://travis-ci.org/ and click `Sign in with GitHub`, then enter your GitHub account details if needed. ++ +image:signing_in.png[Signing into Travis CI] ++ +. Head to the https://travis-ci.org/profile[Accounts] page, and find the switch for the forked repository. +* If the organization is not shown, click `Review and add` as shown below: ++ +image:review_and_add.png[Review and add] ++ +This should bring you to a GitHub page that manages the access of third-party applications. Depending on whether you are the owner of the repository, you can either grant access ++ +image:grant_access.png[Grant Access] ++ +or request access ++ +image:request_access.png[Request Access] ++ +to Travis CI so that it can access your commits and build your code. +* If repository cannot be found, click `Sync account` +. Activate the switch. ++ +image:flick_repository_switch.png[Activate the switch] ++ +. This repo comes with a link:../.travis.yml[`.travis.yml`] that tells Travis what to do. So there is no need for you to create one yourself. +. To see the CI in action, push a commit to the master branch! +* Go to the repository and see the pushed commit. There should be an icon which will link you to the Travis build. ++ +image:build_pending.png[Commit build] ++ +* As the build is run on a provided remote machine, we can only examine the logs it produces: ++ +image:travis_build.png[Travis build] ++ +. If the build is successful, you should be able to check the coverage details of the tests at http://coveralls.io/[Coveralls] +. Update the link to the 'build status' badge at the top of the `README.adoc` to point to the build status of your own repo. + +== Enabling auto-publishing of documentation + +. Ensure that you have followed the steps above to set up Travis CI. +. On GitHub, create a new user account and give this account collaborator and admin access to the repo. + + Using this account, generate a personal access token https://github.com/settings/tokens/new[here]. ++ +[NOTE] +Personal access tokens are like passwords so make sure you keep them secret! If the personal access token is leaked, please delete it and generate a new one. ++ +[NOTE] +We use a new user account to generate the token for team projects to prevent team members from gaining access to other team members' repos. + +If you are the only one with write access to the repo, you can use your own account to generate the token. ++ +-- +* Add a description for the token. (e.g. `Travis CI - deploy docs to gh-pages`) +* Check the `public_repo` checkbox. +* Click `Generate Token` and copy your new personal access token. +-- +We will use this token to grant Travis access to the repo. ++ +image:generate_token.png[Generate token] + +. Head to the https://travis-ci.org/profile[Accounts] page, and find the switch for the forked repository. ++ +image:flick_repository_switch.png[Activate the switch] ++ +. Click on the settings button next to the switch. In the Environment Variables section, add a new environment variable with ++ +-- +* name: `GITHUB_TOKEN` +* value: personal access token copied in step 1 +* Display value in build log: `OFF` +-- +image:travis_add_token.png[Travis add token] ++ +[NOTE] +*Make sure you set `Display value in build log` to `OFF`.* + +Otherwise, other people will be able to see the personal access token and thus have access this repo. + +Similarly, make sure you *do not print `$GITHUB_TOKEN` to the logs* in Travis scripts as the logs are viewable by the public. + +. Now, whenever there's a new commit to master branch, Travis will push the latest documentation to gh-pages branch. + +**To verify that it works,** + +. Trigger Travis to regenerate documentation. To do so, you need to push a new commit to the master branch of the fork. + + Suggested change: Remove the codacy badge from `README`. +. Wait for Travis CI to finish running the build on your new commit. +. Go to the URL `\https://.github.io/addressbook-level3/index.html`. You should see your `README` file displayed. + +== Repository-wide checks + +In addition to running Gradle checks, we also configure Travis CI to run some repository-wide checks. Unlike the Gradle checks which only cover files used in the build process, these repository-wide checks cover _all_ files in the repository. They check for repository rules which are hard to enforce on development machines such as line ending requirements. + +These checks are implemented as POSIX shell scripts, and thus can only be run on POSIX-compliant operating systems such as macOS and Linux. To run all checks locally on these operating systems, execute the following in the repository root directory: + +[source,shell] +---- +./config/travis/run-checks.sh +---- + +Any warnings or errors will be printed out to the console. + +=== Implementing new checks + +Checks are implemented as executable `check-*` scripts within the `config/travis/` directory. The `run-checks.sh` script will automatically pick up and run files named as such. + +Check scripts should print out errors in the following format: + +.... +SEVERITY:FILENAME:LINE: MESSAGE +.... + +where `SEVERITY` is either `ERROR` or `WARN`, `FILENAME` is the path to the file relative to the current directory, `LINE` is the line of the file where the error occurred and `MESSAGE` is the message explaining the error. + +Check scripts must exit with a non-zero exit code if any errors occur. diff --git a/docs/diagrams/ArchitectureDiagram.puml b/docs/diagrams/ArchitectureDiagram.puml index d021b3992ed..237ac38249f 100644 --- a/docs/diagrams/ArchitectureDiagram.puml +++ b/docs/diagrams/ArchitectureDiagram.puml @@ -1,42 +1,42 @@ -@startuml -!include -!include -!include -!include style.puml - -Package " "<>{ - Class UI UI_COLOR - Class Logic LOGIC_COLOR - Class Storage STORAGE_COLOR - Class Model MODEL_COLOR - Class Main MODEL_COLOR_T1 - Class Commons LOGIC_COLOR_T2 - Class "Log Center" as Logs UI_COLOR_T2 - Class Hidden #FFFFFF - Class HiddenUI #FFFFFF - Class HiddenModel #FFFFFF - - -} -Class "<$user>" as User MODEL_COLOR_T2 -Class "<$documents>" as File UI_COLOR_T1 - - -HiddenUI -up[hidden]-> UI -HiddenModel -left[hidden]-> Model -Main -up-> HiddenUI -Main -left-> HiddenModel -UI -> Logic -UI -right-> Model -Logic -> Storage -Logic -down-> Model - -Logs -right- Commons -Hidden .down.> Commons -Hidden .down.> Commons -Hidden .down.> Commons - -Storage .right.>File -User --> UI -Main --> Hidden -@enduml +@startuml +!include +!include +!include +!include style.puml + +Package " "<>{ + Class UI UI_COLOR + Class Logic LOGIC_COLOR + Class Storage STORAGE_COLOR + Class Model MODEL_COLOR + Class Main MODEL_COLOR_T1 + Class Commons LOGIC_COLOR_T2 + Class "Log Center" as Logs UI_COLOR_T2 + Class Hidden #FFFFFF + Class HiddenUI #FFFFFF + Class HiddenModel #FFFFFF + + +} +Class "<$user>" as User MODEL_COLOR_T2 +Class "<$documents>" as File UI_COLOR_T1 + + +HiddenUI -up[hidden]-> UI +HiddenModel -left[hidden]-> Model +Main -up-> HiddenUI +Main -left-> HiddenModel +UI -> Logic +UI -right-> Model +Logic -> Storage +Logic -down-> Model + +Logs -right- Commons +Hidden .down.> Commons +Hidden .down.> Commons +Hidden .down.> Commons + +Storage .right.>File +User --> UI +Main --> Hidden +@enduml diff --git a/docs/diagrams/ArchitectureSequenceDiagram.puml b/docs/diagrams/ArchitectureSequenceDiagram.puml index d1e2ae93675..555d078d9c8 100644 --- a/docs/diagrams/ArchitectureSequenceDiagram.puml +++ b/docs/diagrams/ArchitectureSequenceDiagram.puml @@ -1,37 +1,37 @@ -@startuml -!include style.puml - -Actor User as user USER_COLOR -Participant ":UI" as ui UI_COLOR -Participant ":Logic" as logic LOGIC_COLOR -Participant ":Model" as model MODEL_COLOR -Participant ":Storage" as storage STORAGE_COLOR - -user -[USER_COLOR]> ui : "delete 1" -activate ui UI_COLOR - -ui -[UI_COLOR]> logic : execute("delete 1") -activate logic LOGIC_COLOR - -logic -[LOGIC_COLOR]> model : deletePerson(p) -activate model MODEL_COLOR - -model -[MODEL_COLOR]-> logic -deactivate model - -logic -[LOGIC_COLOR]> storage : saveAddressBook(addressBook) -activate storage STORAGE_COLOR - -storage -[STORAGE_COLOR]> storage : Save to file -activate storage STORAGE_COLOR_T1 -deactivate storage - -storage --[STORAGE_COLOR]> logic -deactivate storage - -logic --[LOGIC_COLOR]> ui -deactivate logic - -ui--[UI_COLOR]> user -deactivate ui -@enduml +@startuml +!include style.puml + +Actor User as user USER_COLOR +Participant ":UI" as ui UI_COLOR +Participant ":Logic" as logic LOGIC_COLOR +Participant ":Model" as model MODEL_COLOR +Participant ":Storage" as storage STORAGE_COLOR + +user -[USER_COLOR]> ui : "delete 1" +activate ui UI_COLOR + +ui -[UI_COLOR]> logic : execute("delete 1") +activate logic LOGIC_COLOR + +logic -[LOGIC_COLOR]> model : deletePerson(p) +activate model MODEL_COLOR + +model -[MODEL_COLOR]-> logic +deactivate model + +logic -[LOGIC_COLOR]> storage : saveAddressBook(addressBook) +activate storage STORAGE_COLOR + +storage -[STORAGE_COLOR]> storage : Save to file +activate storage STORAGE_COLOR_T1 +deactivate storage + +storage --[STORAGE_COLOR]> logic +deactivate storage + +logic --[LOGIC_COLOR]> ui +deactivate logic + +ui--[UI_COLOR]> user +deactivate ui +@enduml diff --git a/docs/diagrams/BetterModelClassDiagram.puml b/docs/diagrams/BetterModelClassDiagram.puml index 7790472da52..66bf66e0c37 100644 --- a/docs/diagrams/BetterModelClassDiagram.puml +++ b/docs/diagrams/BetterModelClassDiagram.puml @@ -1,21 +1,21 @@ -@startuml -!include style.puml -skinparam arrowThickness 1.1 -skinparam arrowColor MODEL_COLOR -skinparam classBackgroundColor MODEL_COLOR - -AddressBook *-right-> "1" UniquePersonList -AddressBook *-right-> "1" UniqueTagList -UniqueTagList -[hidden]down- UniquePersonList -UniqueTagList -[hidden]down- UniquePersonList - -UniqueTagList *-right-> "*" Tag -UniquePersonList o-right-> Person - -Person o-up-> "*" Tag - -Person *--> Name -Person *--> Phone -Person *--> Email -Person *--> Address -@enduml +@startuml +!include style.puml +skinparam arrowThickness 1.1 +skinparam arrowColor MODEL_COLOR +skinparam classBackgroundColor MODEL_COLOR + +AddressBook *-right-> "1" UniquePersonList +AddressBook *-right-> "1" UniqueTagList +UniqueTagList -[hidden]down- UniquePersonList +UniqueTagList -[hidden]down- UniquePersonList + +UniqueTagList *-right-> "*" Tag +UniquePersonList o-right-> Person + +Person o-up-> "*" Tag + +Person *--> Name +Person *--> Phone +Person *--> Email +Person *--> Address +@enduml diff --git a/docs/diagrams/CommitActivityDiagram.puml b/docs/diagrams/CommitActivityDiagram.puml index 7f8fe407f89..ad5a7144dcb 100644 --- a/docs/diagrams/CommitActivityDiagram.puml +++ b/docs/diagrams/CommitActivityDiagram.puml @@ -1,15 +1,15 @@ -@startuml -start -:User executes command; - -'Since the beta syntax does not support placing the condition outside the -'diamond we place it as the true branch instead. - -if () then ([command commits AddressBook]) - :Purge redunant states; - :Save AddressBook to - addressBookStateList; -else ([else]) -endif -stop -@enduml +@startuml +start +:User executes command; + +'Since the beta syntax does not support placing the condition outside the +'diamond we place it as the true branch instead. + +if () then ([command commits AddressBook]) + :Purge redunant states; + :Save AddressBook to + addressBookStateList; +else ([else]) +endif +stop +@enduml diff --git a/docs/diagrams/DeleteSequenceDiagram.puml b/docs/diagrams/DeleteSequenceDiagram.puml index 1dc2311b245..920cf8a2bc0 100644 --- a/docs/diagrams/DeleteSequenceDiagram.puml +++ b/docs/diagrams/DeleteSequenceDiagram.puml @@ -1,69 +1,69 @@ -@startuml -!include style.puml - -box Logic LOGIC_COLOR_T1 -participant ":LogicManager" as LogicManager LOGIC_COLOR -participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR -participant ":DeleteCommandParser" as DeleteCommandParser LOGIC_COLOR -participant "d:DeleteCommand" as DeleteCommand LOGIC_COLOR -participant ":CommandResult" as CommandResult LOGIC_COLOR -end box - -box Model MODEL_COLOR_T1 -participant ":Model" as Model MODEL_COLOR -end box - -[-> LogicManager : execute("delete 1") -activate LogicManager - -LogicManager -> AddressBookParser : parseCommand("delete 1") -activate AddressBookParser - -create DeleteCommandParser -AddressBookParser -> DeleteCommandParser -activate DeleteCommandParser - -DeleteCommandParser --> AddressBookParser -deactivate DeleteCommandParser - -AddressBookParser -> DeleteCommandParser : parse("1") -activate DeleteCommandParser - -create DeleteCommand -DeleteCommandParser -> DeleteCommand -activate DeleteCommand - -DeleteCommand --> DeleteCommandParser : d -deactivate DeleteCommand - -DeleteCommandParser --> AddressBookParser : d -deactivate DeleteCommandParser -'Hidden arrow to position the destroy marker below the end of the activation bar. -DeleteCommandParser -[hidden]-> AddressBookParser -destroy DeleteCommandParser - -AddressBookParser --> LogicManager : d -deactivate AddressBookParser - -LogicManager -> DeleteCommand : execute() -activate DeleteCommand - -DeleteCommand -> Model : deletePerson(1) -activate Model - -Model --> DeleteCommand -deactivate Model - -create CommandResult -DeleteCommand -> CommandResult -activate CommandResult - -CommandResult --> DeleteCommand -deactivate CommandResult - -DeleteCommand --> LogicManager : result -deactivate DeleteCommand - -[<--LogicManager -deactivate LogicManager -@enduml +@startuml +!include style.puml + +box Logic LOGIC_COLOR_T1 +participant ":LogicManager" as LogicManager LOGIC_COLOR +participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR +participant ":DeleteCommandParser" as DeleteCommandParser LOGIC_COLOR +participant "d:DeleteCommand" as DeleteCommand LOGIC_COLOR +participant ":CommandResult" as CommandResult LOGIC_COLOR +end box + +box Model MODEL_COLOR_T1 +participant ":Model" as Model MODEL_COLOR +end box + +[-> LogicManager : execute("delete 1") +activate LogicManager + +LogicManager -> AddressBookParser : parseCommand("delete 1") +activate AddressBookParser + +create DeleteCommandParser +AddressBookParser -> DeleteCommandParser +activate DeleteCommandParser + +DeleteCommandParser --> AddressBookParser +deactivate DeleteCommandParser + +AddressBookParser -> DeleteCommandParser : parse("1") +activate DeleteCommandParser + +create DeleteCommand +DeleteCommandParser -> DeleteCommand +activate DeleteCommand + +DeleteCommand --> DeleteCommandParser : d +deactivate DeleteCommand + +DeleteCommandParser --> AddressBookParser : d +deactivate DeleteCommandParser +'Hidden arrow to position the destroy marker below the end of the activation bar. +DeleteCommandParser -[hidden]-> AddressBookParser +destroy DeleteCommandParser + +AddressBookParser --> LogicManager : d +deactivate AddressBookParser + +LogicManager -> DeleteCommand : execute() +activate DeleteCommand + +DeleteCommand -> Model : deletePerson(1) +activate Model + +Model --> DeleteCommand +deactivate Model + +create CommandResult +DeleteCommand -> CommandResult +activate CommandResult + +CommandResult --> DeleteCommand +deactivate CommandResult + +DeleteCommand --> LogicManager : result +deactivate DeleteCommand + +[<--LogicManager +deactivate LogicManager +@enduml diff --git a/docs/diagrams/LogicClassDiagram.puml b/docs/diagrams/LogicClassDiagram.puml index 016ef33e2e2..310ba657255 100644 --- a/docs/diagrams/LogicClassDiagram.puml +++ b/docs/diagrams/LogicClassDiagram.puml @@ -1,62 +1,62 @@ -@startuml -!include style.puml -skinparam arrowThickness 1.1 -skinparam arrowColor LOGIC_COLOR_T4 -skinparam classBackgroundColor LOGIC_COLOR - -package Logic { - -package Parser { -Interface Parser <> -Class AddressBookParser -Class XYZCommandParser -Class CliSyntax -Class ParserUtil -Class ArgumentMultimap -Class ArgumentTokenizer -Class Prefix -} - -package Command { -Class XYZCommand -Class CommandResult -Class "{abstract}\nCommand" as Command -} - -Interface Logic <> -Class LogicManager -} - -package Model{ -Class HiddenModel #FFFFFF -} - -Class HiddenOutside #FFFFFF -HiddenOutside ..> Logic - -LogicManager .up.|> Logic -LogicManager -->"1" AddressBookParser -AddressBookParser .left.> XYZCommandParser: creates > - -XYZCommandParser ..> XYZCommand : creates > -XYZCommandParser ..|> Parser -XYZCommandParser ..> ArgumentMultimap -XYZCommandParser ..> ArgumentTokenizer -ArgumentTokenizer .left.> ArgumentMultimap -XYZCommandParser ..> CliSyntax -CliSyntax ..> Prefix -XYZCommandParser ..> ParserUtil -ParserUtil .down.> Prefix -ArgumentTokenizer .down.> Prefix -XYZCommand -up-|> Command -LogicManager .left.> Command : executes > - -LogicManager --> Model -Command .right.> Model -note right of XYZCommand: XYZCommand = AddCommand, \nFindCommand, etc - -Logic ..> CommandResult -LogicManager .down.> CommandResult -Command .up.> CommandResult -CommandResult -[hidden]-> Parser -@enduml +@startuml +!include style.puml +skinparam arrowThickness 1.1 +skinparam arrowColor LOGIC_COLOR_T4 +skinparam classBackgroundColor LOGIC_COLOR + +package Logic { + +package Parser { +Interface Parser <> +Class AddressBookParser +Class XYZCommandParser +Class CliSyntax +Class ParserUtil +Class ArgumentMultimap +Class ArgumentTokenizer +Class Prefix +} + +package Command { +Class XYZCommand +Class CommandResult +Class "{abstract}\nCommand" as Command +} + +Interface Logic <> +Class LogicManager +} + +package Model{ +Class HiddenModel #FFFFFF +} + +Class HiddenOutside #FFFFFF +HiddenOutside ..> Logic + +LogicManager .up.|> Logic +LogicManager -->"1" AddressBookParser +AddressBookParser .left.> XYZCommandParser: creates > + +XYZCommandParser ..> XYZCommand : creates > +XYZCommandParser ..|> Parser +XYZCommandParser ..> ArgumentMultimap +XYZCommandParser ..> ArgumentTokenizer +ArgumentTokenizer .left.> ArgumentMultimap +XYZCommandParser ..> CliSyntax +CliSyntax ..> Prefix +XYZCommandParser ..> ParserUtil +ParserUtil .down.> Prefix +ArgumentTokenizer .down.> Prefix +XYZCommand -up-|> Command +LogicManager .left.> Command : executes > + +LogicManager --> Model +Command .right.> Model +note right of XYZCommand: XYZCommand = AddCommand, \nFindCommand, etc + +Logic ..> CommandResult +LogicManager .down.> CommandResult +Command .up.> CommandResult +CommandResult -[hidden]-> Parser +@enduml diff --git a/docs/diagrams/ModelClassDiagram.puml b/docs/diagrams/ModelClassDiagram.puml index e85a00d4107..77e7aee4820 100644 --- a/docs/diagrams/ModelClassDiagram.puml +++ b/docs/diagrams/ModelClassDiagram.puml @@ -1,56 +1,56 @@ -@startuml -!include style.puml -skinparam arrowThickness 1.1 -skinparam arrowColor MODEL_COLOR -skinparam classBackgroundColor MODEL_COLOR - -Package Model <>{ -Interface ReadOnlyAddressBook <> -Interface Model <> -Interface ObservableList <> -Class AddressBook -Class ReadOnlyAddressBook -Class Model -Class ModelManager -Class UserPrefs -Class ReadOnlyUserPrefs - -Package Person { -Class Person -Class Address -Class Email -Class Name -Class Phone -Class UniquePersonList -} - -Package Tag { -Class Tag -} -} - -Class HiddenOutside #FFFFFF -HiddenOutside ..> Model - -AddressBook .up.|> ReadOnlyAddressBook - -ModelManager .up.|> Model -Model .right.> ObservableList -ModelManager o--> "1" AddressBook -ModelManager o-left-> "1" UserPrefs -UserPrefs .up.|> ReadOnlyUserPrefs - -AddressBook *--> "1" UniquePersonList -UniquePersonList o--> "*" Person -Person *--> Name -Person *--> Phone -Person *--> Email -Person *--> Address -Person *--> "*" Tag - -Name -[hidden]right-> Phone -Phone -[hidden]right-> Address -Address -[hidden]right-> Email - -ModelManager -->"1" Person : filtered list -@enduml +@startuml +!include style.puml +skinparam arrowThickness 1.1 +skinparam arrowColor MODEL_COLOR +skinparam classBackgroundColor MODEL_COLOR + +Package Model <>{ +Interface ReadOnlyAddressBook <> +Interface Model <> +Interface ObservableList <> +Class AddressBook +Class ReadOnlyAddressBook +Class Model +Class ModelManager +Class UserPrefs +Class ReadOnlyUserPrefs + +Package Person { +Class Person +Class Address +Class Email +Class Name +Class Phone +Class UniquePersonList +} + +Package Tag { +Class Tag +} +} + +Class HiddenOutside #FFFFFF +HiddenOutside ..> Model + +AddressBook .up.|> ReadOnlyAddressBook + +ModelManager .up.|> Model +Model .right.> ObservableList +ModelManager o--> "1" AddressBook +ModelManager o-left-> "1" UserPrefs +UserPrefs .up.|> ReadOnlyUserPrefs + +AddressBook *--> "1" UniquePersonList +UniquePersonList o--> "*" Person +Person *--> Name +Person *--> Phone +Person *--> Email +Person *--> Address +Person *--> "*" Tag + +Name -[hidden]right-> Phone +Phone -[hidden]right-> Address +Address -[hidden]right-> Email + +ModelManager -->"1" Person : filtered list +@enduml diff --git a/docs/diagrams/StorageClassDiagram.puml b/docs/diagrams/StorageClassDiagram.puml index 6adb2e156bf..fce9eb30048 100644 --- a/docs/diagrams/StorageClassDiagram.puml +++ b/docs/diagrams/StorageClassDiagram.puml @@ -1,24 +1,24 @@ -@startuml -!include style.puml -skinparam arrowThickness 1.1 -skinparam arrowColor STORAGE_COLOR -skinparam classBackgroundColor STORAGE_COLOR - -Interface Storage <> -Interface UserPrefsStorage <> -Interface AddressBookStorage <> - -Class StorageManager -Class JsonUserPrefsStorage -Class JsonAddressBookStorage - -StorageManager .left.|> Storage -StorageManager o-right-> UserPrefsStorage -StorageManager o--> AddressBookStorage - -JsonUserPrefsStorage .left.|> UserPrefsStorage -JsonAddressBookStorage .left.|> AddressBookStorage -JsonAddressBookStorage .down.> JsonSerializableAddressBookStorage -JsonSerializableAddressBookStorage .right.> JsonSerializablePerson -JsonSerializablePerson .right.> JsonAdaptedTag -@enduml +@startuml +!include style.puml +skinparam arrowThickness 1.1 +skinparam arrowColor STORAGE_COLOR +skinparam classBackgroundColor STORAGE_COLOR + +Interface Storage <> +Interface UserPrefsStorage <> +Interface AddressBookStorage <> + +Class StorageManager +Class JsonUserPrefsStorage +Class JsonAddressBookStorage + +StorageManager .left.|> Storage +StorageManager o-right-> UserPrefsStorage +StorageManager o--> AddressBookStorage + +JsonUserPrefsStorage .left.|> UserPrefsStorage +JsonAddressBookStorage .left.|> AddressBookStorage +JsonAddressBookStorage .down.> JsonSerializableAddressBookStorage +JsonSerializableAddressBookStorage .right.> JsonSerializablePerson +JsonSerializablePerson .right.> JsonAdaptedTag +@enduml diff --git a/docs/diagrams/UiClassDiagram.puml b/docs/diagrams/UiClassDiagram.puml index 92746f9fcf7..9ee55b0c41a 100644 --- a/docs/diagrams/UiClassDiagram.puml +++ b/docs/diagrams/UiClassDiagram.puml @@ -1,60 +1,60 @@ -@startuml -!include style.puml -skinparam arrowThickness 1.1 -skinparam arrowColor UI_COLOR_T4 -skinparam classBackgroundColor UI_COLOR - -package UI <>{ -Interface Ui <> -Class "{abstract}\nUiPart" as UiPart -Class UiManager -Class MainWindow -Class HelpWindow -Class ResultDisplay -Class PersonListPanel -Class PersonCard -Class StatusBarFooter -Class CommandBox -} - -package Model <> { -Class HiddenModel #FFFFFF -} - -package Logic <> { -Class HiddenLogic #FFFFFF -} - -Class HiddenOutside #FFFFFF -HiddenOutside ..> Ui - -UiManager .left.|> Ui -UiManager -down-> MainWindow -MainWindow --> HelpWindow -MainWindow *-down-> CommandBox -MainWindow *-down-> ResultDisplay -MainWindow *-down-> PersonListPanel -MainWindow *-down-> StatusBarFooter - -PersonListPanel -down-> PersonCard - -MainWindow -left-|> UiPart - -ResultDisplay --|> UiPart -CommandBox --|> UiPart -PersonListPanel --|> UiPart -PersonCard --|> UiPart -StatusBarFooter --|> UiPart -HelpWindow -down-|> UiPart - -PersonCard ..> Model -UiManager -right-> Logic -MainWindow -left-> Logic - -PersonListPanel -[hidden]left- HelpWindow -HelpWindow -[hidden]left- CommandBox -CommandBox -[hidden]left- ResultDisplay -ResultDisplay -[hidden]left- StatusBarFooter - -MainWindow -[hidden]-|> UiPart -@enduml +@startuml +!include style.puml +skinparam arrowThickness 1.1 +skinparam arrowColor UI_COLOR_T4 +skinparam classBackgroundColor UI_COLOR + +package UI <>{ +Interface Ui <> +Class "{abstract}\nUiPart" as UiPart +Class UiManager +Class MainWindow +Class HelpWindow +Class ResultDisplay +Class PersonListPanel +Class PersonCard +Class StatusBarFooter +Class CommandBox +} + +package Model <> { +Class HiddenModel #FFFFFF +} + +package Logic <> { +Class HiddenLogic #FFFFFF +} + +Class HiddenOutside #FFFFFF +HiddenOutside ..> Ui + +UiManager .left.|> Ui +UiManager -down-> MainWindow +MainWindow --> HelpWindow +MainWindow *-down-> CommandBox +MainWindow *-down-> ResultDisplay +MainWindow *-down-> PersonListPanel +MainWindow *-down-> StatusBarFooter + +PersonListPanel -down-> PersonCard + +MainWindow -left-|> UiPart + +ResultDisplay --|> UiPart +CommandBox --|> UiPart +PersonListPanel --|> UiPart +PersonCard --|> UiPart +StatusBarFooter --|> UiPart +HelpWindow -down-|> UiPart + +PersonCard ..> Model +UiManager -right-> Logic +MainWindow -left-> Logic + +PersonListPanel -[hidden]left- HelpWindow +HelpWindow -[hidden]left- CommandBox +CommandBox -[hidden]left- ResultDisplay +ResultDisplay -[hidden]left- StatusBarFooter + +MainWindow -[hidden]-|> UiPart +@enduml diff --git a/docs/diagrams/UndoRedoState0.puml b/docs/diagrams/UndoRedoState0.puml index 96e30744d24..9066fdeffad 100644 --- a/docs/diagrams/UndoRedoState0.puml +++ b/docs/diagrams/UndoRedoState0.puml @@ -1,20 +1,20 @@ -@startuml -!include style.puml -skinparam ClassFontColor #000000 -skinparam ClassBorderColor #000000 - -title Initial state - -package States { - class State1 as "__ab0:AddressBook__" - class State2 as "__ab1:AddressBook__" - class State3 as "__ab2:AddressBook__" -} -State1 -[hidden]right-> State2 -State2 -[hidden]right-> State3 -hide State2 -hide State3 - -class Pointer as "Current State" #FFFFF -Pointer -up-> State1 -@end +@startuml +!include style.puml +skinparam ClassFontColor #000000 +skinparam ClassBorderColor #000000 + +title Initial state + +package States { + class State1 as "__ab0:AddressBook__" + class State2 as "__ab1:AddressBook__" + class State3 as "__ab2:AddressBook__" +} +State1 -[hidden]right-> State2 +State2 -[hidden]right-> State3 +hide State2 +hide State3 + +class Pointer as "Current State" #FFFFF +Pointer -up-> State1 +@end diff --git a/docs/diagrams/UndoRedoState1.puml b/docs/diagrams/UndoRedoState1.puml index 01fcb9b2b96..3bbeb133de0 100644 --- a/docs/diagrams/UndoRedoState1.puml +++ b/docs/diagrams/UndoRedoState1.puml @@ -1,22 +1,22 @@ -@startuml -!include style.puml -skinparam ClassFontColor #000000 -skinparam ClassBorderColor #000000 - -title After command "delete 5" - -package States <> { - class State1 as "__ab0:AddressBook__" - class State2 as "__ab1:AddressBook__" - class State3 as "__ab2:AddressBook__" -} - -State1 -[hidden]right-> State2 -State2 -[hidden]right-> State3 - -hide State3 - -class Pointer as "Current State" #FFFFF - -Pointer -up-> State2 -@end +@startuml +!include style.puml +skinparam ClassFontColor #000000 +skinparam ClassBorderColor #000000 + +title After command "delete 5" + +package States <> { + class State1 as "__ab0:AddressBook__" + class State2 as "__ab1:AddressBook__" + class State3 as "__ab2:AddressBook__" +} + +State1 -[hidden]right-> State2 +State2 -[hidden]right-> State3 + +hide State3 + +class Pointer as "Current State" #FFFFF + +Pointer -up-> State2 +@end diff --git a/docs/diagrams/UndoRedoState2.puml b/docs/diagrams/UndoRedoState2.puml index bccc230a5d1..61a1054b7c5 100644 --- a/docs/diagrams/UndoRedoState2.puml +++ b/docs/diagrams/UndoRedoState2.puml @@ -1,20 +1,20 @@ -@startuml -!include style.puml -skinparam ClassFontColor #000000 -skinparam ClassBorderColor #000000 - -title After command "add n/David" - -package States <> { - class State1 as "__ab0:AddressBook__" - class State2 as "__ab1:AddressBook__" - class State3 as "__ab2:AddressBook__" -} - -State1 -[hidden]right-> State2 -State2 -[hidden]right-> State3 - -class Pointer as "Current State" #FFFFF - -Pointer -up-> State3 -@end +@startuml +!include style.puml +skinparam ClassFontColor #000000 +skinparam ClassBorderColor #000000 + +title After command "add n/David" + +package States <> { + class State1 as "__ab0:AddressBook__" + class State2 as "__ab1:AddressBook__" + class State3 as "__ab2:AddressBook__" +} + +State1 -[hidden]right-> State2 +State2 -[hidden]right-> State3 + +class Pointer as "Current State" #FFFFF + +Pointer -up-> State3 +@end diff --git a/docs/diagrams/UndoRedoState3.puml b/docs/diagrams/UndoRedoState3.puml index ea29c9483e4..159557714c6 100644 --- a/docs/diagrams/UndoRedoState3.puml +++ b/docs/diagrams/UndoRedoState3.puml @@ -1,20 +1,20 @@ -@startuml -!include style.puml -skinparam ClassFontColor #000000 -skinparam ClassBorderColor #000000 - -title After command "undo" - -package States <> { - class State1 as "__ab0:AddressBook__" - class State2 as "__ab1:AddressBook__" - class State3 as "__ab2:AddressBook__" -} - -State1 -[hidden]right-> State2 -State2 -[hidden]right-> State3 - -class Pointer as "Current State" #FFFFF - -Pointer -up-> State2 -@end +@startuml +!include style.puml +skinparam ClassFontColor #000000 +skinparam ClassBorderColor #000000 + +title After command "undo" + +package States <> { + class State1 as "__ab0:AddressBook__" + class State2 as "__ab1:AddressBook__" + class State3 as "__ab2:AddressBook__" +} + +State1 -[hidden]right-> State2 +State2 -[hidden]right-> State3 + +class Pointer as "Current State" #FFFFF + +Pointer -up-> State2 +@end diff --git a/docs/diagrams/UndoRedoState4.puml b/docs/diagrams/UndoRedoState4.puml index 1b784cece80..80dc5dc29d6 100644 --- a/docs/diagrams/UndoRedoState4.puml +++ b/docs/diagrams/UndoRedoState4.puml @@ -1,20 +1,20 @@ -@startuml -!include style.puml -skinparam ClassFontColor #000000 -skinparam ClassBorderColor #000000 - -title After command "list" - -package States <> { - class State1 as "__ab0:AddressBook__" - class State2 as "__ab1:AddressBook__" - class State3 as "__ab2:AddressBook__" -} - -State1 -[hidden]right-> State2 -State2 -[hidden]right-> State3 - -class Pointer as "Current State" #FFFFF - -Pointer -up-> State2 -@end +@startuml +!include style.puml +skinparam ClassFontColor #000000 +skinparam ClassBorderColor #000000 + +title After command "list" + +package States <> { + class State1 as "__ab0:AddressBook__" + class State2 as "__ab1:AddressBook__" + class State3 as "__ab2:AddressBook__" +} + +State1 -[hidden]right-> State2 +State2 -[hidden]right-> State3 + +class Pointer as "Current State" #FFFFF + +Pointer -up-> State2 +@end diff --git a/docs/diagrams/UndoRedoState5.puml b/docs/diagrams/UndoRedoState5.puml index 88927be32bc..14f1e7c8273 100644 --- a/docs/diagrams/UndoRedoState5.puml +++ b/docs/diagrams/UndoRedoState5.puml @@ -1,21 +1,21 @@ -@startuml -!include style.puml -skinparam ClassFontColor #000000 -skinparam ClassBorderColor #000000 - -title After command "clear" - -package States <> { - class State1 as "__ab0:AddressBook__" - class State2 as "__ab1:AddressBook__" - class State3 as "__ab3:AddressBook__" -} - -State1 -[hidden]right-> State2 -State2 -[hidden]right-> State3 - -class Pointer as "Current State" #FFFFF - -Pointer -up-> State3 -note right on link: State ab2 deleted. -@end +@startuml +!include style.puml +skinparam ClassFontColor #000000 +skinparam ClassBorderColor #000000 + +title After command "clear" + +package States <> { + class State1 as "__ab0:AddressBook__" + class State2 as "__ab1:AddressBook__" + class State3 as "__ab3:AddressBook__" +} + +State1 -[hidden]right-> State2 +State2 -[hidden]right-> State3 + +class Pointer as "Current State" #FFFFF + +Pointer -up-> State3 +note right on link: State ab2 deleted. +@end diff --git a/docs/diagrams/UndoSequenceDiagram.puml b/docs/diagrams/UndoSequenceDiagram.puml index 410aab4e412..2d68a73b6b4 100644 --- a/docs/diagrams/UndoSequenceDiagram.puml +++ b/docs/diagrams/UndoSequenceDiagram.puml @@ -1,53 +1,53 @@ -@startuml -!include style.puml - -box Logic LOGIC_COLOR_T1 -participant ":LogicManager" as LogicManager LOGIC_COLOR -participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR -participant "u:UndoCommand" as UndoCommand LOGIC_COLOR -end box - -box Model MODEL_COLOR_T1 -participant ":Model" as Model MODEL_COLOR -participant ":VersionedAddressBook" as VersionedAddressBook MODEL_COLOR -end box -[-> LogicManager : execute(undo) -activate LogicManager - -LogicManager -> AddressBookParser : parseCommand(undo) -activate AddressBookParser - -create UndoCommand -AddressBookParser -> UndoCommand -activate UndoCommand - -UndoCommand --> AddressBookParser -deactivate UndoCommand - -AddressBookParser --> LogicManager : u -deactivate AddressBookParser - -LogicManager -> UndoCommand : execute() -activate UndoCommand - -UndoCommand -> Model : undoAddressBook() -activate Model - -Model -> VersionedAddressBook : undo() -activate VersionedAddressBook - -VersionedAddressBook -> VersionedAddressBook :resetData(ReadOnlyAddressBook) -VersionedAddressBook --> Model : -deactivate VersionedAddressBook - -Model --> UndoCommand -deactivate Model - -UndoCommand --> LogicManager : result -deactivate UndoCommand -UndoCommand -[hidden]-> LogicManager : result -destroy UndoCommand - -[<--LogicManager -deactivate LogicManager -@enduml +@startuml +!include style.puml + +box Logic LOGIC_COLOR_T1 +participant ":LogicManager" as LogicManager LOGIC_COLOR +participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR +participant "u:UndoCommand" as UndoCommand LOGIC_COLOR +end box + +box Model MODEL_COLOR_T1 +participant ":Model" as Model MODEL_COLOR +participant ":VersionedAddressBook" as VersionedAddressBook MODEL_COLOR +end box +[-> LogicManager : execute(undo) +activate LogicManager + +LogicManager -> AddressBookParser : parseCommand(undo) +activate AddressBookParser + +create UndoCommand +AddressBookParser -> UndoCommand +activate UndoCommand + +UndoCommand --> AddressBookParser +deactivate UndoCommand + +AddressBookParser --> LogicManager : u +deactivate AddressBookParser + +LogicManager -> UndoCommand : execute() +activate UndoCommand + +UndoCommand -> Model : undoAddressBook() +activate Model + +Model -> VersionedAddressBook : undo() +activate VersionedAddressBook + +VersionedAddressBook -> VersionedAddressBook :resetData(ReadOnlyAddressBook) +VersionedAddressBook --> Model : +deactivate VersionedAddressBook + +Model --> UndoCommand +deactivate Model + +UndoCommand --> LogicManager : result +deactivate UndoCommand +UndoCommand -[hidden]-> LogicManager : result +destroy UndoCommand + +[<--LogicManager +deactivate LogicManager +@enduml diff --git a/docs/diagrams/add-remark/CommandInterface.puml b/docs/diagrams/add-remark/CommandInterface.puml index 2c67afa598c..f206028b787 100644 --- a/docs/diagrams/add-remark/CommandInterface.puml +++ b/docs/diagrams/add-remark/CommandInterface.puml @@ -1,34 +1,34 @@ -@startuml -!include ../style.puml - -Class "{abstract}\nCommand" as Command LOGIC_COLOR_T1{ ---- -+ {abstract} execute(Model) : CommandResult -} - -Class CommandException LOGIC_COLOR_T1 - -Class RemarkCommand LOGIC_COLOR_T1{ -+ COMMAND_WORD : String -+ MESSAGE_USAGE : String -+ MESSAGE_NOT_IMPLEMENTED_YET: String -'Empty spaces to ensure that box resizes to fit text -                         -'Do _not_ change the previous line ---- -+ execute(Model) : CommandResult -} - -RemarkCommand -up-|> Command -RemarkCommand -up[hidden]-|> Command -RemarkCommand .right.> CommandException : > throws -Command .right.> CommandException : > throws - - -skinparam classAttributeIconSize 0 -skinparam classFontColor #000000 -hide circle -show members -hide CommandException members -@enduml - +@startuml +!include ../style.puml + +Class "{abstract}\nCommand" as Command LOGIC_COLOR_T1{ +--- ++ {abstract} execute(Model) : CommandResult +} + +Class CommandException LOGIC_COLOR_T1 + +Class RemarkCommand LOGIC_COLOR_T1{ ++ COMMAND_WORD : String ++ MESSAGE_USAGE : String ++ MESSAGE_NOT_IMPLEMENTED_YET: String +'Empty spaces to ensure that box resizes to fit text +                         +'Do _not_ change the previous line +--- ++ execute(Model) : CommandResult +} + +RemarkCommand -up-|> Command +RemarkCommand -up[hidden]-|> Command +RemarkCommand .right.> CommandException : > throws +Command .right.> CommandException : > throws + + +skinparam classAttributeIconSize 0 +skinparam classFontColor #000000 +hide circle +show members +hide CommandException members +@enduml + diff --git a/docs/diagrams/add-remark/ParserInterface.puml b/docs/diagrams/add-remark/ParserInterface.puml index ff84b0881e4..d3686793d49 100644 --- a/docs/diagrams/add-remark/ParserInterface.puml +++ b/docs/diagrams/add-remark/ParserInterface.puml @@ -1,19 +1,19 @@ -@startuml -!include ../style.puml -Interface Parser LOGIC_COLOR_T1 - -Class RemarkCommandParser LOGIC_COLOR_T1{ -+parse : RemarkCommand -} - -Class ParserException LOGIC_COLOR_T1 - -RemarkCommandParser -up-|> Parser -Parser .right.> ParserException : throws - -show members - -skinparam classFontColor #000000 -skinparam classAttributeIconSize 0 -@enduml - +@startuml +!include ../style.puml +Interface Parser LOGIC_COLOR_T1 + +Class RemarkCommandParser LOGIC_COLOR_T1{ ++parse : RemarkCommand +} + +Class ParserException LOGIC_COLOR_T1 + +RemarkCommandParser -up-|> Parser +Parser .right.> ParserException : throws + +show members + +skinparam classFontColor #000000 +skinparam classAttributeIconSize 0 +@enduml + diff --git a/docs/diagrams/plantuml/AbeforeC.puml b/docs/diagrams/plantuml/AbeforeC.puml index b4c86d69e08..be6a1a0761b 100644 --- a/docs/diagrams/plantuml/AbeforeC.puml +++ b/docs/diagrams/plantuml/AbeforeC.puml @@ -1,11 +1,11 @@ -@startuml -!include ../style.puml - -Class A LOGIC_COLOR_T3 -Class B LOGIC_COLOR_T3 -Class C UI_COLOR_T3 -Class D UI_COLOR_T3 - -A --> B -C --> D -@enduml +@startuml +!include ../style.puml + +Class A LOGIC_COLOR_T3 +Class B LOGIC_COLOR_T3 +Class C UI_COLOR_T3 +Class D UI_COLOR_T3 + +A --> B +C --> D +@enduml diff --git a/docs/diagrams/plantuml/AllDown.puml b/docs/diagrams/plantuml/AllDown.puml index 6eaf1c8bb00..158abd7a1cb 100644 --- a/docs/diagrams/plantuml/AllDown.puml +++ b/docs/diagrams/plantuml/AllDown.puml @@ -1,25 +1,25 @@ -@startuml -!include ../style.puml - -Class A LOGIC_COLOR_T3 -Class B LOGIC_COLOR_T3 -Class C LOGIC_COLOR_T3 -Class D LOGIC_COLOR_T3 - -Class 1 MODEL_COLOR_T3 -Class 2 MODEL_COLOR_T3 -Class 3 MODEL_COLOR_T3 -Class 4 MODEL_COLOR_T3 - -Class Z UI_COLOR_T3 - -A --> Z -B --> Z -C --> Z -D --> Z - -A --> 1 -B --> 2 -C --> 3 -D --> 4 -@enduml +@startuml +!include ../style.puml + +Class A LOGIC_COLOR_T3 +Class B LOGIC_COLOR_T3 +Class C LOGIC_COLOR_T3 +Class D LOGIC_COLOR_T3 + +Class 1 MODEL_COLOR_T3 +Class 2 MODEL_COLOR_T3 +Class 3 MODEL_COLOR_T3 +Class 4 MODEL_COLOR_T3 + +Class Z UI_COLOR_T3 + +A --> Z +B --> Z +C --> Z +D --> Z + +A --> 1 +B --> 2 +C --> 3 +D --> 4 +@enduml diff --git a/docs/diagrams/plantuml/ArrowLength.puml b/docs/diagrams/plantuml/ArrowLength.puml index 99c5abfe062..a2a6c95ca75 100644 --- a/docs/diagrams/plantuml/ArrowLength.puml +++ b/docs/diagrams/plantuml/ArrowLength.puml @@ -1,27 +1,27 @@ -@startuml -!include ../style.puml - -Package "Short\n->" { -Class A LOGIC_COLOR_T1 -Class B LOGIC_COLOR_T1 -A -> B -} - -Package "Long\n-->" { -Class C LOGIC_COLOR_T2 -Class D LOGIC_COLOR_T2 -C --> D -} - -Package "Longer\n--->" { -Class E LOGIC_COLOR_T3 -Class F LOGIC_COLOR_T3 -E ---> F -} - -Package "Even Longer\n---->" { -Class G LOGIC_COLOR_T4 -Class H LOGIC_COLOR_T4 -G ----> H -} -@enduml +@startuml +!include ../style.puml + +Package "Short\n->" { +Class A LOGIC_COLOR_T1 +Class B LOGIC_COLOR_T1 +A -> B +} + +Package "Long\n-->" { +Class C LOGIC_COLOR_T2 +Class D LOGIC_COLOR_T2 +C --> D +} + +Package "Longer\n--->" { +Class E LOGIC_COLOR_T3 +Class F LOGIC_COLOR_T3 +E ---> F +} + +Package "Even Longer\n---->" { +Class G LOGIC_COLOR_T4 +Class H LOGIC_COLOR_T4 +G ----> H +} +@enduml diff --git a/docs/diagrams/plantuml/CbeforeA.puml b/docs/diagrams/plantuml/CbeforeA.puml index 87dbca3f199..37160361b2b 100644 --- a/docs/diagrams/plantuml/CbeforeA.puml +++ b/docs/diagrams/plantuml/CbeforeA.puml @@ -1,11 +1,11 @@ -@startuml -!include ../style.puml - -Class C UI_COLOR_T3 -Class A LOGIC_COLOR_T3 -Class B LOGIC_COLOR_T3 -Class D UI_COLOR_T3 - -A --> B -C --> D -@enduml +@startuml +!include ../style.puml + +Class C UI_COLOR_T3 +Class A LOGIC_COLOR_T3 +Class B LOGIC_COLOR_T3 +Class D UI_COLOR_T3 + +A --> B +C --> D +@enduml diff --git a/docs/diagrams/plantuml/HiddenArrows.puml b/docs/diagrams/plantuml/HiddenArrows.puml index c17ef6e4f13..53c7ef0ae94 100644 --- a/docs/diagrams/plantuml/HiddenArrows.puml +++ b/docs/diagrams/plantuml/HiddenArrows.puml @@ -1,30 +1,30 @@ -@startuml -!include ../style.puml - -Class A LOGIC_COLOR_T3 -Class B LOGIC_COLOR_T3 -Class C LOGIC_COLOR_T3 -Class D LOGIC_COLOR_T3 - -Class 1 MODEL_COLOR_T3 -Class 2 MODEL_COLOR_T3 -Class 3 MODEL_COLOR_T3 -Class 4 MODEL_COLOR_T3 - -Class Z UI_COLOR_T3 - -A -up-> Z -B -up-> Z -C -up-> Z -D -up-> Z - -A --> 1 -B --> 2 -C --> 3 -D --> 4 - -'Force A B C D -A -right[hidden]- B -B -right[hidden]- C -C -right[hidden]- D -@enduml +@startuml +!include ../style.puml + +Class A LOGIC_COLOR_T3 +Class B LOGIC_COLOR_T3 +Class C LOGIC_COLOR_T3 +Class D LOGIC_COLOR_T3 + +Class 1 MODEL_COLOR_T3 +Class 2 MODEL_COLOR_T3 +Class 3 MODEL_COLOR_T3 +Class 4 MODEL_COLOR_T3 + +Class Z UI_COLOR_T3 + +A -up-> Z +B -up-> Z +C -up-> Z +D -up-> Z + +A --> 1 +B --> 2 +C --> 3 +D --> 4 + +'Force A B C D +A -right[hidden]- B +B -right[hidden]- C +C -right[hidden]- D +@enduml diff --git a/docs/diagrams/plantuml/PackagesAndConsistency.puml b/docs/diagrams/plantuml/PackagesAndConsistency.puml index 6364eb5de03..5f684f1fbae 100644 --- a/docs/diagrams/plantuml/PackagesAndConsistency.puml +++ b/docs/diagrams/plantuml/PackagesAndConsistency.puml @@ -1,14 +1,14 @@ -@startuml -!include ../style.puml - -package "Rule Of Thumb"{ - Class C UI_COLOR_T3 - Class D UI_COLOR_T3 - Class A LOGIC_COLOR_T3 - Class B LOGIC_COLOR_T3 - - A --> B - C --> D -} - -@enduml +@startuml +!include ../style.puml + +package "Rule Of Thumb"{ + Class C UI_COLOR_T3 + Class D UI_COLOR_T3 + Class A LOGIC_COLOR_T3 + Class B LOGIC_COLOR_T3 + + A --> B + C --> D +} + +@enduml diff --git a/docs/diagrams/plantuml/UpAndDown.puml b/docs/diagrams/plantuml/UpAndDown.puml index e7a0313ad01..865d14b3031 100644 --- a/docs/diagrams/plantuml/UpAndDown.puml +++ b/docs/diagrams/plantuml/UpAndDown.puml @@ -1,29 +1,29 @@ -@startuml -!include ../style.puml - -Class A LOGIC_COLOR_T3 -Class B LOGIC_COLOR_T3 -Class C LOGIC_COLOR_T3 -Class D LOGIC_COLOR_T3 - -Class 1 MODEL_COLOR_T3 -Class 2 MODEL_COLOR_T3 -Class 3 MODEL_COLOR_T3 -Class 4 MODEL_COLOR_T3 - -Class Z UI_COLOR_T3 - -'default is down -A --> Z -'specify down -B -down-> Z -'shorthand for down -C -d-> Z -'arrow lengths take priority -D -down> Z - -A -up-> 1 -B -up-> 2 -C -up-> 3 -D -up-> 4 -@enduml +@startuml +!include ../style.puml + +Class A LOGIC_COLOR_T3 +Class B LOGIC_COLOR_T3 +Class C LOGIC_COLOR_T3 +Class D LOGIC_COLOR_T3 + +Class 1 MODEL_COLOR_T3 +Class 2 MODEL_COLOR_T3 +Class 3 MODEL_COLOR_T3 +Class 4 MODEL_COLOR_T3 + +Class Z UI_COLOR_T3 + +'default is down +A --> Z +'specify down +B -down-> Z +'shorthand for down +C -d-> Z +'arrow lengths take priority +D -down> Z + +A -up-> 1 +B -up-> 2 +C -up-> 3 +D -up-> 4 +@enduml diff --git a/docs/diagrams/style.puml b/docs/diagrams/style.puml index fad8b0adeaa..9898e03beb3 100644 --- a/docs/diagrams/style.puml +++ b/docs/diagrams/style.puml @@ -1,75 +1,75 @@ -/' - 'Commonly used styles and colors across diagrams. - 'Refer to https://plantuml-documentation.readthedocs.io/en/latest for a more - 'comprehensive list of skinparams. - '/ - - -'T1 through T4 are shades of the original color from lightest to darkest - -!define UI_COLOR #1D8900 -!define UI_COLOR_T1 #83E769 -!define UI_COLOR_T2 #3FC71B -!define UI_COLOR_T3 #166800 -!define UI_COLOR_T4 #0E4100 - -!define LOGIC_COLOR #3333C4 -!define LOGIC_COLOR_T1 #C8C8FA -!define LOGIC_COLOR_T2 #6A6ADC -!define LOGIC_COLOR_T3 #1616B0 -!define LOGIC_COLOR_T4 #101086 - -!define MODEL_COLOR #9D0012 -!define MODEL_COLOR_T1 #F97181 -!define MODEL_COLOR_T2 #E41F36 -!define MODEL_COLOR_T3 #7B000E -!define MODEL_COLOR_T4 #51000A - -!define STORAGE_COLOR #A38300 -!define STORAGE_COLOR_T1 #FFE374 -!define STORAGE_COLOR_T2 #EDC520 -!define STORAGE_COLOR_T3 #806600 -!define STORAGE_COLOR_T2 #544400 - -!define USER_COLOR #000000 - -skinparam BackgroundColor #FFFFFFF - -skinparam Shadowing false - -skinparam Class { - FontColor #FFFFFF - BorderThickness 1 - BorderColor #FFFFFF - StereotypeFontColor #FFFFFF - FontName Arial -} - -skinparam Actor { - BorderColor USER_COLOR - Color USER_COLOR - FontName Arial -} - -skinparam Sequence { - MessageAlign center - BoxFontSize 15 - BoxPadding 0 - BoxFontColor #FFFFFF - FontName Arial -} - -skinparam Participant { - FontColor #FFFFFFF - Padding 20 -} - -skinparam MinClassWidth 50 -skinparam ParticipantPadding 10 -skinparam Shadowing false -skinparam DefaultTextAlignment center -skinparam packageStyle Rectangle - -hide footbox -hide members -hide circle +/' + 'Commonly used styles and colors across diagrams. + 'Refer to https://plantuml-documentation.readthedocs.io/en/latest for a more + 'comprehensive list of skinparams. + '/ + + +'T1 through T4 are shades of the original color from lightest to darkest + +!define UI_COLOR #1D8900 +!define UI_COLOR_T1 #83E769 +!define UI_COLOR_T2 #3FC71B +!define UI_COLOR_T3 #166800 +!define UI_COLOR_T4 #0E4100 + +!define LOGIC_COLOR #3333C4 +!define LOGIC_COLOR_T1 #C8C8FA +!define LOGIC_COLOR_T2 #6A6ADC +!define LOGIC_COLOR_T3 #1616B0 +!define LOGIC_COLOR_T4 #101086 + +!define MODEL_COLOR #9D0012 +!define MODEL_COLOR_T1 #F97181 +!define MODEL_COLOR_T2 #E41F36 +!define MODEL_COLOR_T3 #7B000E +!define MODEL_COLOR_T4 #51000A + +!define STORAGE_COLOR #A38300 +!define STORAGE_COLOR_T1 #FFE374 +!define STORAGE_COLOR_T2 #EDC520 +!define STORAGE_COLOR_T3 #806600 +!define STORAGE_COLOR_T2 #544400 + +!define USER_COLOR #000000 + +skinparam BackgroundColor #FFFFFFF + +skinparam Shadowing false + +skinparam Class { + FontColor #FFFFFF + BorderThickness 1 + BorderColor #FFFFFF + StereotypeFontColor #FFFFFF + FontName Arial +} + +skinparam Actor { + BorderColor USER_COLOR + Color USER_COLOR + FontName Arial +} + +skinparam Sequence { + MessageAlign center + BoxFontSize 15 + BoxPadding 0 + BoxFontColor #FFFFFF + FontName Arial +} + +skinparam Participant { + FontColor #FFFFFFF + Padding 20 +} + +skinparam MinClassWidth 50 +skinparam ParticipantPadding 10 +skinparam Shadowing false +skinparam DefaultTextAlignment center +skinparam packageStyle Rectangle + +hide footbox +hide members +hide circle diff --git a/docs/diagrams/tracing/LogicSequenceDiagram.puml b/docs/diagrams/tracing/LogicSequenceDiagram.puml index fdcbe1c0ccc..19bb98670e5 100644 --- a/docs/diagrams/tracing/LogicSequenceDiagram.puml +++ b/docs/diagrams/tracing/LogicSequenceDiagram.puml @@ -1,21 +1,21 @@ -@startuml -!include ../style.puml - -Participant ":LogicManager" as logic LOGIC_COLOR -Participant ":AddressBookParser" as abp LOGIC_COLOR -Participant ":EditCommandParser" as ecp LOGIC_COLOR -Participant "command:EditCommand" as ec LOGIC_COLOR - -[-> logic : execute -activate logic -logic -> abp ++: parseCommand(commandText) -create ecp -abp -> ecp -abp -> ecp ++: parse(arguments) -create ec -ecp -> ec ++: index, editPersonDescriptor -ec --> ecp -- -ecp --> abp --: command -abp --> logic --: command - -@enduml +@startuml +!include ../style.puml + +Participant ":LogicManager" as logic LOGIC_COLOR +Participant ":AddressBookParser" as abp LOGIC_COLOR +Participant ":EditCommandParser" as ecp LOGIC_COLOR +Participant "command:EditCommand" as ec LOGIC_COLOR + +[-> logic : execute +activate logic +logic -> abp ++: parseCommand(commandText) +create ecp +abp -> ecp +abp -> ecp ++: parse(arguments) +create ec +ecp -> ec ++: index, editPersonDescriptor +ec --> ecp -- +ecp --> abp --: command +abp --> logic --: command + +@enduml diff --git a/docs/index.adoc b/docs/index.adoc index a65ae663288..8ca3a5fca97 100644 --- a/docs/index.adoc +++ b/docs/index.adoc @@ -1,2 +1,2 @@ -:stylesDir: stylesheets -include::../README.adoc[] +:stylesDir: stylesheets +include::../README.adoc[] diff --git a/docs/stylesheets/asciidoctor.css b/docs/stylesheets/asciidoctor.css index 36590bf346c..8c3ecc3fbd7 100644 --- a/docs/stylesheets/asciidoctor.css +++ b/docs/stylesheets/asciidoctor.css @@ -1,407 +1,407 @@ -/* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */ -/* Remove comment around @import statement below when using as a custom stylesheet */ -/*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700";*/ -article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block} -audio,canvas,video{display:inline-block} -audio:not([controls]){display:none;height:0} -[hidden],template{display:none} -script{display:none!important} -html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%} -body{margin:0} -a{background:transparent} -a:focus{outline:thin dotted} -a:active,a:hover{outline:0} -h1{font-size:2em;margin:.67em 0} -abbr[title]{border-bottom:1px dotted} -b,strong{font-weight:bold} -dfn{font-style:italic} -hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0} -mark{background:#ff0;color:#000} -code,kbd,pre,samp{font-family:monospace;font-size:1em} -pre{white-space:pre-wrap} -q{quotes:"\201C" "\201D" "\2018" "\2019"} -small{font-size:80%} -sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline} -sup{top:-.5em} -sub{bottom:-.25em} -img{border:0} -svg:not(:root){overflow:hidden} -figure{margin:0} -fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em} -legend{border:0;padding:0} -button,input,select,textarea{font-family:inherit;font-size:100%;margin:0} -button,input{line-height:normal} -button,select{text-transform:none} -button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer} -button[disabled],html input[disabled]{cursor:default} -input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0} -input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box} -input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none} -button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0} -textarea{overflow:auto;vertical-align:top} -table{border-collapse:collapse;border-spacing:0} -*,*:before,*:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box} -html,body{font-size:100%} -body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto} -a:hover{cursor:pointer} -img,object,embed{max-width:100%;height:auto} -object,embed{height:100%} -img{-ms-interpolation-mode:bicubic} -.left{float:left!important} -.right{float:right!important} -.text-left{text-align:left!important} -.text-right{text-align:right!important} -.text-center{text-align:center!important} -.text-justify{text-align:justify!important} -.hide{display:none} -body{-webkit-font-smoothing:antialiased} -img,object,svg{display:inline-block;vertical-align:middle} -textarea{height:auto;min-height:50px} -select{width:100%} -.center{margin-left:auto;margin-right:auto} -.spread{width:100%} -p.lead,.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{font-size:1.21875em;line-height:1.6} -.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em} -div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr} -a{color:#2156a5;text-decoration:underline;line-height:inherit} -a:hover,a:focus{color:#1d4b8f} -a img{border:none} -p{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility} -p aside{font-size:.875em;line-height:1.35;font-style:italic} -h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em} -h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0} -h1{font-size:2.125em} -h2{font-size:1.6875em} -h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em} -h4,h5{font-size:1.125em} -h6{font-size:1em} -hr{border:solid #ddddd8;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0} -em,i{font-style:italic;line-height:inherit} -strong,b{font-weight:bold;line-height:inherit} -small{font-size:60%;line-height:inherit} -code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)} -ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit} -ul,ol,ul.no-bullet,ol.no-bullet{margin-left:1.5em} -ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em} -ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit} -ul.square{list-style-type:square} -ul.circle{list-style-type:circle} -ul.disc{list-style-type:disc} -ul.no-bullet{list-style:none} -ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0} -dl dt{margin-bottom:.3125em;font-weight:bold} -dl dd{margin-bottom:1.25em} -abbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help} -abbr{text-transform:none} -blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd} -blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)} -blockquote cite:before{content:"\2014 \0020"} -blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)} -blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)} -@media only screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2} -h1{font-size:2.75em} -h2{font-size:2.3125em} -h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em} -h4{font-size:1.4375em}} -table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede} -table thead,table tfoot{background:#f7f8f7;font-weight:bold} -table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left} -table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)} -table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7} -table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6} -body{tab-size:4} -h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em} -h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400} -.clearfix:before,.clearfix:after,.float-group:before,.float-group:after{content:" ";display:table} -.clearfix:after,.float-group:after{clear:both} -*:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed} -pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed} -.keyseq{color:rgba(51,51,51,.8)} -kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap} -.keyseq kbd:first-child{margin-left:0} -.keyseq kbd:last-child{margin-right:0} -.menuseq,.menu{color:rgba(0,0,0,.8)} -b.button:before,b.button:after{position:relative;top:-1px;font-weight:400} -b.button:before{content:"[";padding:0 3px 0 2px} -b.button:after{content:"]";padding:0 2px 0 3px} -p a>code:hover{color:rgba(0,0,0,.9)} -#header,#content,#footnotes,#footer{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em} -#header:before,#header:after,#content:before,#content:after,#footnotes:before,#footnotes:after,#footer:before,#footer:after{content:" ";display:table} -#header:after,#content:after,#footnotes:after,#footer:after{clear:both} -#content{margin-top:1.25em} -#content:before{content:none} -#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0} -#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #ddddd8} -#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #ddddd8;padding-bottom:8px} -#header .details{border-bottom:1px solid #ddddd8;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap} -#header .details span:first-child{margin-left:-.125em} -#header .details span.email a{color:rgba(0,0,0,.85)} -#header .details br{display:none} -#header .details br+span:before{content:"\00a0\2013\00a0"} -#header .details br+span.author:before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)} -#header .details br+span#revremark:before{content:"\00a0|\00a0"} -#header #revnumber{text-transform:capitalize} -#header #revnumber:after{content:"\00a0"} -#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #ddddd8;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem} -#toc{border-bottom:1px solid #efefed;padding-bottom:.5em} -#toc>ul{margin-left:.125em} -#toc ul.sectlevel0>li>a{font-style:italic} -#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0} -#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none} -#toc li{line-height:1.3334;margin-top:.3334em} -#toc a{text-decoration:none} -#toc a:active{text-decoration:underline} -#toctitle{color:#7a2518;font-size:1.2em} -@media only screen and (min-width:768px){#toctitle{font-size:1.375em} -body.toc2{padding-left:15em;padding-right:0} -#toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #efefed;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto} -#toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em} -#toc.toc2>ul{font-size:.9em;margin-bottom:0} -#toc.toc2 ul ul{margin-left:0;padding-left:1em} -#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em} -body.toc2.toc-right{padding-left:0;padding-right:15em} -body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #efefed;left:auto;right:0}} -@media only screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0} -#toc.toc2{width:20em} -#toc.toc2 #toctitle{font-size:1.375em} -#toc.toc2>ul{font-size:.95em} -#toc.toc2 ul ul{padding-left:1.25em} -body.toc2.toc-right{padding-left:0;padding-right:20em}} -#content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px} -#content #toc>:first-child{margin-top:0} -#content #toc>:last-child{margin-bottom:0} -#footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em} -#footer-text{color:rgba(255,255,255,.8);line-height:1.44} -.sect1{padding-bottom:.625em} -@media only screen and (min-width:768px){.sect1{padding-bottom:1.25em}} -.sect1+.sect1{border-top:1px solid #efefed} -#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400} -#content h1>a.anchor:before,h2>a.anchor:before,h3>a.anchor:before,#toctitle>a.anchor:before,.sidebarblock>.content>.title>a.anchor:before,h4>a.anchor:before,h5>a.anchor:before,h6>a.anchor:before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em} -#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible} -#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none} -#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221} -.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em} -.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic} -table.tableblock>caption.title{white-space:nowrap;overflow:visible;max-width:0} -.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{color:rgba(0,0,0,.85)} -table.tableblock #preamble>.sectionbody>.paragraph:first-of-type p{font-size:inherit} -.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%} -.admonitionblock>table td.icon{text-align:center;width:80px} -.admonitionblock>table td.icon img{max-width:none} -.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase} -.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #ddddd8;color:rgba(0,0,0,.6)} -.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0} -.exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px} -.exampleblock>.content>:first-child{margin-top:0} -.exampleblock>.content>:last-child{margin-bottom:0} -.sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px} -.sidebarblock>:first-child{margin-top:0} -.sidebarblock>:last-child{margin-bottom:0} -.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center} -.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0} -.literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8} -.sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1} -.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;padding:1em;font-size:.8125em} -.literalblock pre.nowrap,.literalblock pre[class].nowrap,.listingblock pre.nowrap,.listingblock pre[class].nowrap{overflow-x:auto;white-space:pre;word-wrap:normal} -@media only screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}} -@media only screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}} -.literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)} -.listingblock pre.highlightjs{padding:0} -.listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px} -.listingblock pre.prettyprint{border-width:0} -.listingblock>.content{position:relative} -.listingblock code[data-lang]:before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999} -.listingblock:hover code[data-lang]:before{display:block} -.listingblock.terminal pre .command:before{content:attr(data-prompt);padding-right:.5em;color:#999} -.listingblock.terminal pre .command:not([data-prompt]):before{content:"$"} -table.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none} -table.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0;line-height:1.45} -table.pyhltable td.code{padding-left:.75em;padding-right:0} -pre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #ddddd8} -pre.pygments .lineno{display:inline-block;margin-right:.25em} -table.pyhltable .linenodiv{background:none!important;padding-right:0!important} -.quoteblock{margin:0 1em 1.25em 1.5em;display:table} -.quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em} -.quoteblock blockquote,.quoteblock blockquote p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify} -.quoteblock blockquote{margin:0;padding:0;border:0} -.quoteblock blockquote:before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)} -.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0} -.quoteblock .attribution{margin-top:.5em;margin-right:.5ex;text-align:right} -.quoteblock .quoteblock{margin-left:0;margin-right:0;padding:.5em 0;border-left:3px solid rgba(0,0,0,.6)} -.quoteblock .quoteblock blockquote{padding:0 0 0 .75em} -.quoteblock .quoteblock blockquote:before{display:none} -.verseblock{margin:0 1em 1.25em 1em} -.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility} -.verseblock pre strong{font-weight:400} -.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex} -.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic} -.quoteblock .attribution br,.verseblock .attribution br{display:none} -.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)} -.quoteblock.abstract{margin:0 0 1.25em 0;display:block} -.quoteblock.abstract blockquote,.quoteblock.abstract blockquote p{text-align:left;word-spacing:0} -.quoteblock.abstract blockquote:before,.quoteblock.abstract blockquote p:first-of-type:before{display:none} -table.tableblock{max-width:100%;border-collapse:separate} -table.tableblock td>.paragraph:last-child p>p:last-child,table.tableblock th>p:last-child,table.tableblock td>p:last-child{margin-bottom:0} -table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede} -table.grid-all th.tableblock,table.grid-all td.tableblock{border-width:0 1px 1px 0} -table.grid-all tfoot>tr>th.tableblock,table.grid-all tfoot>tr>td.tableblock{border-width:1px 1px 0 0} -table.grid-cols th.tableblock,table.grid-cols td.tableblock{border-width:0 1px 0 0} -table.grid-all *>tr>.tableblock:last-child,table.grid-cols *>tr>.tableblock:last-child{border-right-width:0} -table.grid-rows th.tableblock,table.grid-rows td.tableblock{border-width:0 0 1px 0} -table.grid-all tbody>tr:last-child>th.tableblock,table.grid-all tbody>tr:last-child>td.tableblock,table.grid-all thead:last-child>tr>th.tableblock,table.grid-rows tbody>tr:last-child>th.tableblock,table.grid-rows tbody>tr:last-child>td.tableblock,table.grid-rows thead:last-child>tr>th.tableblock{border-bottom-width:0} -table.grid-rows tfoot>tr>th.tableblock,table.grid-rows tfoot>tr>td.tableblock{border-width:1px 0 0 0} -table.frame-all{border-width:1px} -table.frame-sides{border-width:0 1px} -table.frame-topbot{border-width:1px 0} -th.halign-left,td.halign-left{text-align:left} -th.halign-right,td.halign-right{text-align:right} -th.halign-center,td.halign-center{text-align:center} -th.valign-top,td.valign-top{vertical-align:top} -th.valign-bottom,td.valign-bottom{vertical-align:bottom} -th.valign-middle,td.valign-middle{vertical-align:middle} -table thead th,table tfoot th{font-weight:bold} -tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7} -tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold} -p.tableblock>code:only-child{background:none;padding:0} -p.tableblock{font-size:1em} -td>div.verse{white-space:pre} -ol{margin-left:1.75em} -ul li ol{margin-left:1.5em} -dl dd{margin-left:1.125em} -dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0} -ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em} -ul.unstyled,ol.unnumbered,ul.checklist,ul.none{list-style-type:none} -ul.unstyled,ol.unnumbered,ul.checklist{margin-left:.625em} -ul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1em;font-size:.85em} -ul.checklist li>p:first-child>input[type="checkbox"]:first-child{width:1em;position:relative;top:1px} -ul.inline{margin:0 auto .625em auto;margin-left:-1.375em;margin-right:0;padding:0;list-style:none;overflow:hidden} -ul.inline>li{list-style:none;float:left;margin-left:1.375em;display:block} -ul.inline>li>*{display:block} -.unstyled dl dt{font-weight:400;font-style:normal} -ol.arabic{list-style-type:decimal} -ol.decimal{list-style-type:decimal-leading-zero} -ol.loweralpha{list-style-type:lower-alpha} -ol.upperalpha{list-style-type:upper-alpha} -ol.lowerroman{list-style-type:lower-roman} -ol.upperroman{list-style-type:upper-roman} -ol.lowergreek{list-style-type:lower-greek} -.hdlist>table,.colist>table{border:0;background:none} -.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none} -td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em} -td.hdlist1{font-weight:bold;padding-bottom:1.25em} -.literalblock+.colist,.listingblock+.colist{margin-top:-.5em} -.colist>table tr>td:first-of-type{padding:0 .75em;line-height:1} -.colist>table tr>td:last-of-type{padding:.25em 0} -.thumb,.th{line-height:0;display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px #ddd;box-shadow:0 0 0 1px #ddd} -.imageblock.left,.imageblock[style*="float: left"]{margin:.25em .625em 1.25em 0} -.imageblock.right,.imageblock[style*="float: right"]{margin:.25em 0 1.25em .625em} -.imageblock>.title{margin-bottom:0} -.imageblock.thumb,.imageblock.th{border-width:6px} -.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em} -.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0} -.image.left{margin-right:.625em} -.image.right{margin-left:.625em} -a.image{text-decoration:none;display:inline-block} -a.image object{pointer-events:none} -sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super} -sup.footnote a,sup.footnoteref a{text-decoration:none} -sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline} -#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em} -#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em 0;border-width:1px 0 0 0} -#footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;text-indent:-1.05em;margin-bottom:.2em} -#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none} -#footnotes .footnote:last-of-type{margin-bottom:0} -#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0} -.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0} -.gist .file-data>table td.line-data{width:99%} -div.unbreakable{page-break-inside:avoid} -.big{font-size:larger} -.small{font-size:smaller} -.underline{text-decoration:underline} -.overline{text-decoration:overline} -.line-through{text-decoration:line-through} -.aqua{color:#00bfbf} -.aqua-background{background-color:#00fafa} -.black{color:#000} -.black-background{background-color:#000} -.blue{color:#0000bf} -.blue-background{background-color:#0000fa} -.fuchsia{color:#bf00bf} -.fuchsia-background{background-color:#fa00fa} -.gray{color:#606060} -.gray-background{background-color:#7d7d7d} -.green{color:#006000} -.green-background{background-color:#007d00} -.lime{color:#00bf00} -.lime-background{background-color:#00fa00} -.maroon{color:#600000} -.maroon-background{background-color:#7d0000} -.navy{color:#000060} -.navy-background{background-color:#00007d} -.olive{color:#606000} -.olive-background{background-color:#7d7d00} -.purple{color:#600060} -.purple-background{background-color:#7d007d} -.red{color:#bf0000} -.red-background{background-color:#fa0000} -.silver{color:#909090} -.silver-background{background-color:#bcbcbc} -.teal{color:#006060} -.teal-background{background-color:#007d7d} -.white{color:#bfbfbf} -.white-background{background-color:#fafafa} -.yellow{color:#bfbf00} -.yellow-background{background-color:#fafa00} -span.icon>.fa{cursor:default} -.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default} -.admonitionblock td.icon .icon-note:before{content:"\f05a";color:#19407c} -.admonitionblock td.icon .icon-tip:before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111} -.admonitionblock td.icon .icon-warning:before{content:"\f071";color:#bf6900} -.admonitionblock td.icon .icon-caution:before{content:"\f06d";color:#bf3400} -.admonitionblock td.icon .icon-important:before{content:"\f06a";color:#bf0000} -.conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold} -.conum[data-value] *{color:#fff!important} -.conum[data-value]+b{display:none} -.conum[data-value]:after{content:attr(data-value)} -pre .conum[data-value]{position:relative;top:-.125em} -b.conum *{color:inherit!important} -.conum:not([data-value]):empty{display:none} -dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility} -h1,h2,p,td.content,span.alt{letter-spacing:-.01em} -p strong,td.content strong,div.footnote strong{letter-spacing:-.005em} -p,blockquote,dt,td.content,span.alt{font-size:1.0625rem} -p{margin-bottom:1.25rem} -.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em} -.exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc} -.print-only{display:none!important} -@media print{@page{margin:1.25cm .75cm} -*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important} -a{color:inherit!important;text-decoration:underline!important} -a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important} -a[href^="http:"]:not(.bare):after,a[href^="https:"]:not(.bare):after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em} -abbr[title]:after{content:" (" attr(title) ")"} -pre,blockquote,tr,img,object,svg{page-break-inside:avoid} -thead{display:table-header-group} -svg{max-width:100%} -p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3} -h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid} -#toc,.sidebarblock,.exampleblock>.content{background:none!important} -#toc{border-bottom:1px solid #ddddd8!important;padding-bottom:0!important} -.sect1{padding-bottom:0!important} -.sect1+.sect1{border:0!important} -#header>h1:first-child{margin-top:1.25rem} -body.book #header{text-align:center} -body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em 0} -body.book #header .details{border:0!important;display:block;padding:0!important} -body.book #header .details span:first-child{margin-left:0!important} -body.book #header .details br{display:block} -body.book #header .details br+span:before{content:none!important} -body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important} -body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always} -.listingblock code[data-lang]:before{display:block} -#footer{background:none!important;padding:0 .9375em} -#footer-text{color:rgba(0,0,0,.6)!important;font-size:.9em} -.hide-on-print{display:none!important} -.print-only{display:block!important} -.hide-for-print{display:none!important} -.show-for-print{display:inherit!important}} +/* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */ +/* Remove comment around @import statement below when using as a custom stylesheet */ +/*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700";*/ +article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block} +audio,canvas,video{display:inline-block} +audio:not([controls]){display:none;height:0} +[hidden],template{display:none} +script{display:none!important} +html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%} +body{margin:0} +a{background:transparent} +a:focus{outline:thin dotted} +a:active,a:hover{outline:0} +h1{font-size:2em;margin:.67em 0} +abbr[title]{border-bottom:1px dotted} +b,strong{font-weight:bold} +dfn{font-style:italic} +hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0} +mark{background:#ff0;color:#000} +code,kbd,pre,samp{font-family:monospace;font-size:1em} +pre{white-space:pre-wrap} +q{quotes:"\201C" "\201D" "\2018" "\2019"} +small{font-size:80%} +sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline} +sup{top:-.5em} +sub{bottom:-.25em} +img{border:0} +svg:not(:root){overflow:hidden} +figure{margin:0} +fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em} +legend{border:0;padding:0} +button,input,select,textarea{font-family:inherit;font-size:100%;margin:0} +button,input{line-height:normal} +button,select{text-transform:none} +button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer} +button[disabled],html input[disabled]{cursor:default} +input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0} +input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box} +input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none} +button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0} +textarea{overflow:auto;vertical-align:top} +table{border-collapse:collapse;border-spacing:0} +*,*:before,*:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box} +html,body{font-size:100%} +body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto} +a:hover{cursor:pointer} +img,object,embed{max-width:100%;height:auto} +object,embed{height:100%} +img{-ms-interpolation-mode:bicubic} +.left{float:left!important} +.right{float:right!important} +.text-left{text-align:left!important} +.text-right{text-align:right!important} +.text-center{text-align:center!important} +.text-justify{text-align:justify!important} +.hide{display:none} +body{-webkit-font-smoothing:antialiased} +img,object,svg{display:inline-block;vertical-align:middle} +textarea{height:auto;min-height:50px} +select{width:100%} +.center{margin-left:auto;margin-right:auto} +.spread{width:100%} +p.lead,.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{font-size:1.21875em;line-height:1.6} +.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em} +div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr} +a{color:#2156a5;text-decoration:underline;line-height:inherit} +a:hover,a:focus{color:#1d4b8f} +a img{border:none} +p{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility} +p aside{font-size:.875em;line-height:1.35;font-style:italic} +h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em} +h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0} +h1{font-size:2.125em} +h2{font-size:1.6875em} +h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em} +h4,h5{font-size:1.125em} +h6{font-size:1em} +hr{border:solid #ddddd8;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0} +em,i{font-style:italic;line-height:inherit} +strong,b{font-weight:bold;line-height:inherit} +small{font-size:60%;line-height:inherit} +code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)} +ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit} +ul,ol,ul.no-bullet,ol.no-bullet{margin-left:1.5em} +ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em} +ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit} +ul.square{list-style-type:square} +ul.circle{list-style-type:circle} +ul.disc{list-style-type:disc} +ul.no-bullet{list-style:none} +ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0} +dl dt{margin-bottom:.3125em;font-weight:bold} +dl dd{margin-bottom:1.25em} +abbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help} +abbr{text-transform:none} +blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd} +blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)} +blockquote cite:before{content:"\2014 \0020"} +blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)} +blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)} +@media only screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2} +h1{font-size:2.75em} +h2{font-size:2.3125em} +h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em} +h4{font-size:1.4375em}} +table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede} +table thead,table tfoot{background:#f7f8f7;font-weight:bold} +table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left} +table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)} +table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7} +table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6} +body{tab-size:4} +h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em} +h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400} +.clearfix:before,.clearfix:after,.float-group:before,.float-group:after{content:" ";display:table} +.clearfix:after,.float-group:after{clear:both} +*:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed} +pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed} +.keyseq{color:rgba(51,51,51,.8)} +kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap} +.keyseq kbd:first-child{margin-left:0} +.keyseq kbd:last-child{margin-right:0} +.menuseq,.menu{color:rgba(0,0,0,.8)} +b.button:before,b.button:after{position:relative;top:-1px;font-weight:400} +b.button:before{content:"[";padding:0 3px 0 2px} +b.button:after{content:"]";padding:0 2px 0 3px} +p a>code:hover{color:rgba(0,0,0,.9)} +#header,#content,#footnotes,#footer{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em} +#header:before,#header:after,#content:before,#content:after,#footnotes:before,#footnotes:after,#footer:before,#footer:after{content:" ";display:table} +#header:after,#content:after,#footnotes:after,#footer:after{clear:both} +#content{margin-top:1.25em} +#content:before{content:none} +#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0} +#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #ddddd8} +#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #ddddd8;padding-bottom:8px} +#header .details{border-bottom:1px solid #ddddd8;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap} +#header .details span:first-child{margin-left:-.125em} +#header .details span.email a{color:rgba(0,0,0,.85)} +#header .details br{display:none} +#header .details br+span:before{content:"\00a0\2013\00a0"} +#header .details br+span.author:before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)} +#header .details br+span#revremark:before{content:"\00a0|\00a0"} +#header #revnumber{text-transform:capitalize} +#header #revnumber:after{content:"\00a0"} +#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #ddddd8;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem} +#toc{border-bottom:1px solid #efefed;padding-bottom:.5em} +#toc>ul{margin-left:.125em} +#toc ul.sectlevel0>li>a{font-style:italic} +#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0} +#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none} +#toc li{line-height:1.3334;margin-top:.3334em} +#toc a{text-decoration:none} +#toc a:active{text-decoration:underline} +#toctitle{color:#7a2518;font-size:1.2em} +@media only screen and (min-width:768px){#toctitle{font-size:1.375em} +body.toc2{padding-left:15em;padding-right:0} +#toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #efefed;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto} +#toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em} +#toc.toc2>ul{font-size:.9em;margin-bottom:0} +#toc.toc2 ul ul{margin-left:0;padding-left:1em} +#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em} +body.toc2.toc-right{padding-left:0;padding-right:15em} +body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #efefed;left:auto;right:0}} +@media only screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0} +#toc.toc2{width:20em} +#toc.toc2 #toctitle{font-size:1.375em} +#toc.toc2>ul{font-size:.95em} +#toc.toc2 ul ul{padding-left:1.25em} +body.toc2.toc-right{padding-left:0;padding-right:20em}} +#content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px} +#content #toc>:first-child{margin-top:0} +#content #toc>:last-child{margin-bottom:0} +#footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em} +#footer-text{color:rgba(255,255,255,.8);line-height:1.44} +.sect1{padding-bottom:.625em} +@media only screen and (min-width:768px){.sect1{padding-bottom:1.25em}} +.sect1+.sect1{border-top:1px solid #efefed} +#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400} +#content h1>a.anchor:before,h2>a.anchor:before,h3>a.anchor:before,#toctitle>a.anchor:before,.sidebarblock>.content>.title>a.anchor:before,h4>a.anchor:before,h5>a.anchor:before,h6>a.anchor:before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em} +#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible} +#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none} +#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221} +.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em} +.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic} +table.tableblock>caption.title{white-space:nowrap;overflow:visible;max-width:0} +.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{color:rgba(0,0,0,.85)} +table.tableblock #preamble>.sectionbody>.paragraph:first-of-type p{font-size:inherit} +.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%} +.admonitionblock>table td.icon{text-align:center;width:80px} +.admonitionblock>table td.icon img{max-width:none} +.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase} +.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #ddddd8;color:rgba(0,0,0,.6)} +.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0} +.exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px} +.exampleblock>.content>:first-child{margin-top:0} +.exampleblock>.content>:last-child{margin-bottom:0} +.sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px} +.sidebarblock>:first-child{margin-top:0} +.sidebarblock>:last-child{margin-bottom:0} +.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center} +.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0} +.literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8} +.sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1} +.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;padding:1em;font-size:.8125em} +.literalblock pre.nowrap,.literalblock pre[class].nowrap,.listingblock pre.nowrap,.listingblock pre[class].nowrap{overflow-x:auto;white-space:pre;word-wrap:normal} +@media only screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}} +@media only screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}} +.literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)} +.listingblock pre.highlightjs{padding:0} +.listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px} +.listingblock pre.prettyprint{border-width:0} +.listingblock>.content{position:relative} +.listingblock code[data-lang]:before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999} +.listingblock:hover code[data-lang]:before{display:block} +.listingblock.terminal pre .command:before{content:attr(data-prompt);padding-right:.5em;color:#999} +.listingblock.terminal pre .command:not([data-prompt]):before{content:"$"} +table.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none} +table.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0;line-height:1.45} +table.pyhltable td.code{padding-left:.75em;padding-right:0} +pre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #ddddd8} +pre.pygments .lineno{display:inline-block;margin-right:.25em} +table.pyhltable .linenodiv{background:none!important;padding-right:0!important} +.quoteblock{margin:0 1em 1.25em 1.5em;display:table} +.quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em} +.quoteblock blockquote,.quoteblock blockquote p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify} +.quoteblock blockquote{margin:0;padding:0;border:0} +.quoteblock blockquote:before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)} +.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0} +.quoteblock .attribution{margin-top:.5em;margin-right:.5ex;text-align:right} +.quoteblock .quoteblock{margin-left:0;margin-right:0;padding:.5em 0;border-left:3px solid rgba(0,0,0,.6)} +.quoteblock .quoteblock blockquote{padding:0 0 0 .75em} +.quoteblock .quoteblock blockquote:before{display:none} +.verseblock{margin:0 1em 1.25em 1em} +.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility} +.verseblock pre strong{font-weight:400} +.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex} +.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic} +.quoteblock .attribution br,.verseblock .attribution br{display:none} +.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)} +.quoteblock.abstract{margin:0 0 1.25em 0;display:block} +.quoteblock.abstract blockquote,.quoteblock.abstract blockquote p{text-align:left;word-spacing:0} +.quoteblock.abstract blockquote:before,.quoteblock.abstract blockquote p:first-of-type:before{display:none} +table.tableblock{max-width:100%;border-collapse:separate} +table.tableblock td>.paragraph:last-child p>p:last-child,table.tableblock th>p:last-child,table.tableblock td>p:last-child{margin-bottom:0} +table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede} +table.grid-all th.tableblock,table.grid-all td.tableblock{border-width:0 1px 1px 0} +table.grid-all tfoot>tr>th.tableblock,table.grid-all tfoot>tr>td.tableblock{border-width:1px 1px 0 0} +table.grid-cols th.tableblock,table.grid-cols td.tableblock{border-width:0 1px 0 0} +table.grid-all *>tr>.tableblock:last-child,table.grid-cols *>tr>.tableblock:last-child{border-right-width:0} +table.grid-rows th.tableblock,table.grid-rows td.tableblock{border-width:0 0 1px 0} +table.grid-all tbody>tr:last-child>th.tableblock,table.grid-all tbody>tr:last-child>td.tableblock,table.grid-all thead:last-child>tr>th.tableblock,table.grid-rows tbody>tr:last-child>th.tableblock,table.grid-rows tbody>tr:last-child>td.tableblock,table.grid-rows thead:last-child>tr>th.tableblock{border-bottom-width:0} +table.grid-rows tfoot>tr>th.tableblock,table.grid-rows tfoot>tr>td.tableblock{border-width:1px 0 0 0} +table.frame-all{border-width:1px} +table.frame-sides{border-width:0 1px} +table.frame-topbot{border-width:1px 0} +th.halign-left,td.halign-left{text-align:left} +th.halign-right,td.halign-right{text-align:right} +th.halign-center,td.halign-center{text-align:center} +th.valign-top,td.valign-top{vertical-align:top} +th.valign-bottom,td.valign-bottom{vertical-align:bottom} +th.valign-middle,td.valign-middle{vertical-align:middle} +table thead th,table tfoot th{font-weight:bold} +tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7} +tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold} +p.tableblock>code:only-child{background:none;padding:0} +p.tableblock{font-size:1em} +td>div.verse{white-space:pre} +ol{margin-left:1.75em} +ul li ol{margin-left:1.5em} +dl dd{margin-left:1.125em} +dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0} +ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em} +ul.unstyled,ol.unnumbered,ul.checklist,ul.none{list-style-type:none} +ul.unstyled,ol.unnumbered,ul.checklist{margin-left:.625em} +ul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1em;font-size:.85em} +ul.checklist li>p:first-child>input[type="checkbox"]:first-child{width:1em;position:relative;top:1px} +ul.inline{margin:0 auto .625em auto;margin-left:-1.375em;margin-right:0;padding:0;list-style:none;overflow:hidden} +ul.inline>li{list-style:none;float:left;margin-left:1.375em;display:block} +ul.inline>li>*{display:block} +.unstyled dl dt{font-weight:400;font-style:normal} +ol.arabic{list-style-type:decimal} +ol.decimal{list-style-type:decimal-leading-zero} +ol.loweralpha{list-style-type:lower-alpha} +ol.upperalpha{list-style-type:upper-alpha} +ol.lowerroman{list-style-type:lower-roman} +ol.upperroman{list-style-type:upper-roman} +ol.lowergreek{list-style-type:lower-greek} +.hdlist>table,.colist>table{border:0;background:none} +.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none} +td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em} +td.hdlist1{font-weight:bold;padding-bottom:1.25em} +.literalblock+.colist,.listingblock+.colist{margin-top:-.5em} +.colist>table tr>td:first-of-type{padding:0 .75em;line-height:1} +.colist>table tr>td:last-of-type{padding:.25em 0} +.thumb,.th{line-height:0;display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px #ddd;box-shadow:0 0 0 1px #ddd} +.imageblock.left,.imageblock[style*="float: left"]{margin:.25em .625em 1.25em 0} +.imageblock.right,.imageblock[style*="float: right"]{margin:.25em 0 1.25em .625em} +.imageblock>.title{margin-bottom:0} +.imageblock.thumb,.imageblock.th{border-width:6px} +.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em} +.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0} +.image.left{margin-right:.625em} +.image.right{margin-left:.625em} +a.image{text-decoration:none;display:inline-block} +a.image object{pointer-events:none} +sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super} +sup.footnote a,sup.footnoteref a{text-decoration:none} +sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline} +#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em} +#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em 0;border-width:1px 0 0 0} +#footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;text-indent:-1.05em;margin-bottom:.2em} +#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none} +#footnotes .footnote:last-of-type{margin-bottom:0} +#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0} +.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0} +.gist .file-data>table td.line-data{width:99%} +div.unbreakable{page-break-inside:avoid} +.big{font-size:larger} +.small{font-size:smaller} +.underline{text-decoration:underline} +.overline{text-decoration:overline} +.line-through{text-decoration:line-through} +.aqua{color:#00bfbf} +.aqua-background{background-color:#00fafa} +.black{color:#000} +.black-background{background-color:#000} +.blue{color:#0000bf} +.blue-background{background-color:#0000fa} +.fuchsia{color:#bf00bf} +.fuchsia-background{background-color:#fa00fa} +.gray{color:#606060} +.gray-background{background-color:#7d7d7d} +.green{color:#006000} +.green-background{background-color:#007d00} +.lime{color:#00bf00} +.lime-background{background-color:#00fa00} +.maroon{color:#600000} +.maroon-background{background-color:#7d0000} +.navy{color:#000060} +.navy-background{background-color:#00007d} +.olive{color:#606000} +.olive-background{background-color:#7d7d00} +.purple{color:#600060} +.purple-background{background-color:#7d007d} +.red{color:#bf0000} +.red-background{background-color:#fa0000} +.silver{color:#909090} +.silver-background{background-color:#bcbcbc} +.teal{color:#006060} +.teal-background{background-color:#007d7d} +.white{color:#bfbfbf} +.white-background{background-color:#fafafa} +.yellow{color:#bfbf00} +.yellow-background{background-color:#fafa00} +span.icon>.fa{cursor:default} +.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default} +.admonitionblock td.icon .icon-note:before{content:"\f05a";color:#19407c} +.admonitionblock td.icon .icon-tip:before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111} +.admonitionblock td.icon .icon-warning:before{content:"\f071";color:#bf6900} +.admonitionblock td.icon .icon-caution:before{content:"\f06d";color:#bf3400} +.admonitionblock td.icon .icon-important:before{content:"\f06a";color:#bf0000} +.conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold} +.conum[data-value] *{color:#fff!important} +.conum[data-value]+b{display:none} +.conum[data-value]:after{content:attr(data-value)} +pre .conum[data-value]{position:relative;top:-.125em} +b.conum *{color:inherit!important} +.conum:not([data-value]):empty{display:none} +dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility} +h1,h2,p,td.content,span.alt{letter-spacing:-.01em} +p strong,td.content strong,div.footnote strong{letter-spacing:-.005em} +p,blockquote,dt,td.content,span.alt{font-size:1.0625rem} +p{margin-bottom:1.25rem} +.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em} +.exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc} +.print-only{display:none!important} +@media print{@page{margin:1.25cm .75cm} +*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important} +a{color:inherit!important;text-decoration:underline!important} +a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important} +a[href^="http:"]:not(.bare):after,a[href^="https:"]:not(.bare):after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em} +abbr[title]:after{content:" (" attr(title) ")"} +pre,blockquote,tr,img,object,svg{page-break-inside:avoid} +thead{display:table-header-group} +svg{max-width:100%} +p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3} +h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid} +#toc,.sidebarblock,.exampleblock>.content{background:none!important} +#toc{border-bottom:1px solid #ddddd8!important;padding-bottom:0!important} +.sect1{padding-bottom:0!important} +.sect1+.sect1{border:0!important} +#header>h1:first-child{margin-top:1.25rem} +body.book #header{text-align:center} +body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em 0} +body.book #header .details{border:0!important;display:block;padding:0!important} +body.book #header .details span:first-child{margin-left:0!important} +body.book #header .details br{display:block} +body.book #header .details br+span:before{content:none!important} +body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important} +body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always} +.listingblock code[data-lang]:before{display:block} +#footer{background:none!important;padding:0 .9375em} +#footer-text{color:rgba(0,0,0,.6)!important;font-size:.9em} +.hide-on-print{display:none!important} +.print-only{display:block!important} +.hide-for-print{display:none!important} +.show-for-print{display:inherit!important}} diff --git a/docs/stylesheets/gh-pages.css b/docs/stylesheets/gh-pages.css index 121cac3885f..e5e4d8a44cb 100644 --- a/docs/stylesheets/gh-pages.css +++ b/docs/stylesheets/gh-pages.css @@ -1,214 +1,214 @@ -@import url(https://fonts.googleapis.com/css?family=Montserrat|Open+Sans); -@import "asciidoctor.css"; /* Default asciidoc style framework - important */ - -/* Custom block: details */ - -.sidebarblock.details > .content { - border-left: .25rem solid rgba(0, 0, 0, 0.1); -} - -.sidebarblock.details > .content { - padding-left: .5rem -} - -.sidebarblock.details { - background-color: transparent; - border: none; - padding-bottom: 0; - padding-top: 0; -} - -/* Overrides for asciidoctor.css */ - -a { - color: #0074c7; -} - -h1, -#content h1 > a.link, -h2, -h2 > a.link, -h3, -h3 > a.link, -#toctitle, -#toctitle > a.link, -.sidebarblock > .content > .title, -.sidebarblock > .content > .title > a.link, -h4, -h4 > a.link, -h5, -h5 > a.link, -h6, -h6 > a.link { - color: #e46c0a; -} - -.subheader, -.admonitionblock td.content > .title, -.audioblock > .title, -.exampleblock > .title, -.imageblock > .title, -.listingblock > .title, -.literalblock > .title, -.stemblock > .title, -.openblock > .title, -.paragraph >.title, -.quoteblock > .title, -table.tableblock > .title, -.verseblock > .title, -.videoblock > .title, -.dlist > .title, -.olist > .title, -.ulist > .title, -.qlist > .title, -.hdlist > .title { - color: rgb(197, 90, 17); -} - -@media screen { - #footer { - background-color: #f6f6f6; - border-top: 1px #d2d2d2 solid; - border-bottom: 1px #d2d2d2 solid; - font-family: "Open Sans", "DejaVu Sans", sans-serif; - } - - #footer-text { - color: #595959; - line-height: 1; - } -} - -/* Utilities */ - -.container { - width: 100%; - max-width: 62.5rem; - margin-left: auto; - margin-right: auto; -} - -/* Colors */ - -.bg-light { - background-color: #f8f9fa; -} - -.bg-lighter { - background-color: #fbfbfb; -} - - -/* Navbar */ - -.navbar { - display: flex; - flex-wrap: nowrap; - justify-content: center; - font-family: "Open Sans", "DejaVu Sans", sans-serif; - font-size: 1rem; - padding: 0px 1rem; -} - -.navbar-lg { - font-size: 1.3rem; -} - -.navbar-light { - border-bottom: 1px #d2d2d2 solid; -} - -.navbar a { - text-decoration: none; -} - -.navbar-light a { - color: #595959; -} - -.navbar-light a:hover, -.navbar-light a:focus { - color: #000000; -} - -.navbar a.active, -.navbar a.active:hover, -.navbar a.active:focus { - font-weight: bold; -} - -.navbar-light a.active, -.navbar-light a.active:hover, -.navbar-light a.active:focus { - color: #000000; -} - -.navbar-light .nav-link { - border-bottom: 2px transparent solid; -} - -.navbar-light .nav-link.active { - border-bottom: 2px #e46c0a solid; -} - -.navbar-lg .nav-link.active { - border-bottom: 0; -} - -.navbar > .container { - display: flex; - flex-wrap: wrap; - justify-content: center; -} - -.navbar-brand { - display: inline-block; - margin-right: 1rem; - padding: 0.8125rem 0rem; - padding-left: 0.9375rem; - font-size: 1.25rem; -} - -.navbar-brand img { - height: 1.4rem; - margin: 0rem 0.4rem; - padding: 0; - vertical-align: middle; -} - -.navbar-lg .navbar-brand { - font-size: 1.7rem; -} - -.navbar-lg .navbar-brand img { - height: 2.3rem; -} - -.navbar-nav { - display: flex; - flex-wrap: wrap; - flex-grow: 1; - align-items: center; - margin: 0px; - padding: 0px; - list-style: none; - line-height: inherit; -} - -.nav-link { - display: block; - margin: 0px; - border: 0px; - padding: 1rem 1rem; -} - -/* Do not display site header on print mediums */ -@media print { - #seedu-header { - display: none; - } - - #site-header { - display: none; - } -} +@import url(https://fonts.googleapis.com/css?family=Montserrat|Open+Sans); +@import "asciidoctor.css"; /* Default asciidoc style framework - important */ + +/* Custom block: details */ + +.sidebarblock.details > .content { + border-left: .25rem solid rgba(0, 0, 0, 0.1); +} + +.sidebarblock.details > .content { + padding-left: .5rem +} + +.sidebarblock.details { + background-color: transparent; + border: none; + padding-bottom: 0; + padding-top: 0; +} + +/* Overrides for asciidoctor.css */ + +a { + color: #0074c7; +} + +h1, +#content h1 > a.link, +h2, +h2 > a.link, +h3, +h3 > a.link, +#toctitle, +#toctitle > a.link, +.sidebarblock > .content > .title, +.sidebarblock > .content > .title > a.link, +h4, +h4 > a.link, +h5, +h5 > a.link, +h6, +h6 > a.link { + color: #e46c0a; +} + +.subheader, +.admonitionblock td.content > .title, +.audioblock > .title, +.exampleblock > .title, +.imageblock > .title, +.listingblock > .title, +.literalblock > .title, +.stemblock > .title, +.openblock > .title, +.paragraph >.title, +.quoteblock > .title, +table.tableblock > .title, +.verseblock > .title, +.videoblock > .title, +.dlist > .title, +.olist > .title, +.ulist > .title, +.qlist > .title, +.hdlist > .title { + color: rgb(197, 90, 17); +} + +@media screen { + #footer { + background-color: #f6f6f6; + border-top: 1px #d2d2d2 solid; + border-bottom: 1px #d2d2d2 solid; + font-family: "Open Sans", "DejaVu Sans", sans-serif; + } + + #footer-text { + color: #595959; + line-height: 1; + } +} + +/* Utilities */ + +.container { + width: 100%; + max-width: 62.5rem; + margin-left: auto; + margin-right: auto; +} + +/* Colors */ + +.bg-light { + background-color: #f8f9fa; +} + +.bg-lighter { + background-color: #fbfbfb; +} + + +/* Navbar */ + +.navbar { + display: flex; + flex-wrap: nowrap; + justify-content: center; + font-family: "Open Sans", "DejaVu Sans", sans-serif; + font-size: 1rem; + padding: 0px 1rem; +} + +.navbar-lg { + font-size: 1.3rem; +} + +.navbar-light { + border-bottom: 1px #d2d2d2 solid; +} + +.navbar a { + text-decoration: none; +} + +.navbar-light a { + color: #595959; +} + +.navbar-light a:hover, +.navbar-light a:focus { + color: #000000; +} + +.navbar a.active, +.navbar a.active:hover, +.navbar a.active:focus { + font-weight: bold; +} + +.navbar-light a.active, +.navbar-light a.active:hover, +.navbar-light a.active:focus { + color: #000000; +} + +.navbar-light .nav-link { + border-bottom: 2px transparent solid; +} + +.navbar-light .nav-link.active { + border-bottom: 2px #e46c0a solid; +} + +.navbar-lg .nav-link.active { + border-bottom: 0; +} + +.navbar > .container { + display: flex; + flex-wrap: wrap; + justify-content: center; +} + +.navbar-brand { + display: inline-block; + margin-right: 1rem; + padding: 0.8125rem 0rem; + padding-left: 0.9375rem; + font-size: 1.25rem; +} + +.navbar-brand img { + height: 1.4rem; + margin: 0rem 0.4rem; + padding: 0; + vertical-align: middle; +} + +.navbar-lg .navbar-brand { + font-size: 1.7rem; +} + +.navbar-lg .navbar-brand img { + height: 2.3rem; +} + +.navbar-nav { + display: flex; + flex-wrap: wrap; + flex-grow: 1; + align-items: center; + margin: 0px; + padding: 0px; + list-style: none; + line-height: inherit; +} + +.nav-link { + display: block; + margin: 0px; + border: 0px; + padding: 1rem 1rem; +} + +/* Do not display site header on print mediums */ +@media print { + #seedu-header { + display: none; + } + + #site-header { + display: none; + } +} diff --git a/docs/team/johndoe.adoc b/docs/team/johndoe.adoc index f39e76e49b2..cf82e65a652 100644 --- a/docs/team/johndoe.adoc +++ b/docs/team/johndoe.adoc @@ -1,72 +1,72 @@ -= John Doe - Project Portfolio -:site-section: AboutUs -:imagesDir: ../images -:stylesDir: ../stylesheets - -== PROJECT: AddressBook - Level 3 - ---- - -== Overview - -AddressBook - Level 3 is a desktop address book application used for teaching Software Engineering principles. The user interacts with it using a CLI, and it has a GUI created with JavaFX. It is written in Java, and has about 10 kLoC. - -== Summary of contributions - -* *Major enhancement*: added *the ability to undo/redo previous commands* -** What it does: allows the user to undo all previous commands one at a time. Preceding undo commands can be reversed by using the redo command. -** Justification: This feature improves the product significantly because a user can make mistakes in commands and the app should provide a convenient way to rectify them. -** Highlights: This enhancement affects existing commands and commands to be added in future. It required an in-depth analysis of design alternatives. The implementation too was challenging as it required changes to existing commands. -** Credits: _{mention here if you reused any code/ideas from elsewhere or if a third-party library is heavily used in the feature so that a reader can make a more accurate judgement of how much effort went into the feature}_ - -* *Minor enhancement*: added a history command that allows the user to navigate to previous commands using up/down keys. - -* *Code contributed*: [https://github.com[Functional code]] [https://github.com[Test code]] _{give links to collated code files}_ - -* *Other contributions*: - -** Project management: -*** Managed releases `v1.3` - `v1.5rc` (3 releases) on GitHub -** Enhancements to existing features: -*** Updated the GUI color scheme (Pull requests https://github.com[#33], https://github.com[#34]) -*** Wrote additional tests for existing features to increase coverage from 88% to 92% (Pull requests https://github.com[#36], https://github.com[#38]) -** Documentation: -*** Did cosmetic tweaks to existing contents of the User Guide: https://github.com[#14] -** Community: -*** PRs reviewed (with non-trivial review comments): https://github.com[#12], https://github.com[#32], https://github.com[#19], https://github.com[#42] -*** Contributed to forum discussions (examples: https://github.com[1], https://github.com[2], https://github.com[3], https://github.com[4]) -*** Reported bugs and suggestions for other teams in the class (examples: https://github.com[1], https://github.com[2], https://github.com[3]) -*** Some parts of the history feature I added was adopted by several other class mates (https://github.com[1], https://github.com[2]) -** Tools: -*** Integrated a third party library (Natty) to the project (https://github.com[#42]) -*** Integrated a new Github plugin (CircleCI) to the team repo - -_{you can add/remove categories in the list above}_ - -== Contributions to the User Guide - - -|=== -|_Given below are sections I contributed to the User Guide. They showcase my ability to write documentation targeting end-users._ -|=== - -include::../UserGuide.adoc[tag=delete] - -include::../UserGuide.adoc[tag=dataencryption] - -== Contributions to the Developer Guide - -|=== -|_Given below are sections I contributed to the Developer Guide. They showcase my ability to write technical documentation and the technical depth of my contributions to the project._ -|=== - -include::../DeveloperGuide.adoc[tag=undoredo] - -include::../DeveloperGuide.adoc[tag=dataencryption] - - -== PROJECT: PowerPointLabs - ---- - -_{Optionally, you may include other projects in your portfolio.}_ += John Doe - Project Portfolio +:site-section: AboutUs +:imagesDir: ../images +:stylesDir: ../stylesheets + +== PROJECT: AddressBook - Level 3 + +--- + +== Overview + +AddressBook - Level 3 is a desktop address book application used for teaching Software Engineering principles. The user interacts with it using a CLI, and it has a GUI created with JavaFX. It is written in Java, and has about 10 kLoC. + +== Summary of contributions + +* *Major enhancement*: added *the ability to undo/redo previous commands* +** What it does: allows the user to undo all previous commands one at a time. Preceding undo commands can be reversed by using the redo command. +** Justification: This feature improves the product significantly because a user can make mistakes in commands and the app should provide a convenient way to rectify them. +** Highlights: This enhancement affects existing commands and commands to be added in future. It required an in-depth analysis of design alternatives. The implementation too was challenging as it required changes to existing commands. +** Credits: _{mention here if you reused any code/ideas from elsewhere or if a third-party library is heavily used in the feature so that a reader can make a more accurate judgement of how much effort went into the feature}_ + +* *Minor enhancement*: added a history command that allows the user to navigate to previous commands using up/down keys. + +* *Code contributed*: [https://github.com[Functional code]] [https://github.com[Test code]] _{give links to collated code files}_ + +* *Other contributions*: + +** Project management: +*** Managed releases `v1.3` - `v1.5rc` (3 releases) on GitHub +** Enhancements to existing features: +*** Updated the GUI color scheme (Pull requests https://github.com[#33], https://github.com[#34]) +*** Wrote additional tests for existing features to increase coverage from 88% to 92% (Pull requests https://github.com[#36], https://github.com[#38]) +** Documentation: +*** Did cosmetic tweaks to existing contents of the User Guide: https://github.com[#14] +** Community: +*** PRs reviewed (with non-trivial review comments): https://github.com[#12], https://github.com[#32], https://github.com[#19], https://github.com[#42] +*** Contributed to forum discussions (examples: https://github.com[1], https://github.com[2], https://github.com[3], https://github.com[4]) +*** Reported bugs and suggestions for other teams in the class (examples: https://github.com[1], https://github.com[2], https://github.com[3]) +*** Some parts of the history feature I added was adopted by several other class mates (https://github.com[1], https://github.com[2]) +** Tools: +*** Integrated a third party library (Natty) to the project (https://github.com[#42]) +*** Integrated a new Github plugin (CircleCI) to the team repo + +_{you can add/remove categories in the list above}_ + +== Contributions to the User Guide + + +|=== +|_Given below are sections I contributed to the User Guide. They showcase my ability to write documentation targeting end-users._ +|=== + +include::../UserGuide.adoc[tag=delete] + +include::../UserGuide.adoc[tag=dataencryption] + +== Contributions to the Developer Guide + +|=== +|_Given below are sections I contributed to the Developer Guide. They showcase my ability to write technical documentation and the technical depth of my contributions to the project._ +|=== + +include::../DeveloperGuide.adoc[tag=undoredo] + +include::../DeveloperGuide.adoc[tag=dataencryption] + + +== PROJECT: PowerPointLabs + +--- + +_{Optionally, you may include other projects in your portfolio.}_ diff --git a/docs/templates/LICENSE b/docs/templates/LICENSE index 2073b44dee6..c1a33fe984a 100644 --- a/docs/templates/LICENSE +++ b/docs/templates/LICENSE @@ -1,24 +1,24 @@ -This directory contains code from the Asciidoctor Project. -(https://asciidoctor.org/) - -MIT License - -Copyright (C) 2012-2018 Dan Allen, Ryan Waldron and the Asciidoctor Project - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +This directory contains code from the Asciidoctor Project. +(https://asciidoctor.org/) + +MIT License + +Copyright (C) 2012-2018 Dan Allen, Ryan Waldron and the Asciidoctor Project + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/docs/templates/_footer.html.slim b/docs/templates/_footer.html.slim index 938ed7ddc61..bdd876ddc53 100644 --- a/docs/templates/_footer.html.slim +++ b/docs/templates/_footer.html.slim @@ -1,12 +1,12 @@ -/ NOTE: You must restart the gradle daemon after modifying any template file for the changes to take effect. -#footer - .container - #footer-text - - if attr? :revnumber - |#{attr 'version-label'} #{attr :revnumber} - - if attr? :revnumber && (attr? 'last-update-label') - br - - if attr? 'last-update-label' - |#{attr 'last-update-label'} #{attr :docdatetime} - - unless (docinfo_content = (docinfo :footer)).empty? - =docinfo_content +/ NOTE: You must restart the gradle daemon after modifying any template file for the changes to take effect. +#footer + .container + #footer-text + - if attr? :revnumber + |#{attr 'version-label'} #{attr :revnumber} + - if attr? :revnumber && (attr? 'last-update-label') + br + - if attr? 'last-update-label' + |#{attr 'last-update-label'} #{attr :docdatetime} + - unless (docinfo_content = (docinfo :footer)).empty? + =docinfo_content diff --git a/docs/templates/_footnotes.html.slim b/docs/templates/_footnotes.html.slim index 0cacda3e529..fafd75058c5 100644 --- a/docs/templates/_footnotes.html.slim +++ b/docs/templates/_footnotes.html.slim @@ -1,7 +1,7 @@ -/ NOTE: You must restart the gradle daemon after modifying any template file for the changes to take effect. -#footnotes - hr - - footnotes.each do |fn| - .footnote id=(footnote_id fn.index) - a href="##{footnoteref_id fn.index}" =fn.index - |. #{fn.text} +/ NOTE: You must restart the gradle daemon after modifying any template file for the changes to take effect. +#footnotes + hr + - footnotes.each do |fn| + .footnote id=(footnote_id fn.index) + a href="##{footnoteref_id fn.index}" =fn.index + |. #{fn.text} diff --git a/docs/templates/_header.html.slim b/docs/templates/_header.html.slim index 3c2d5aed43c..820e7bba0c4 100644 --- a/docs/templates/_header.html.slim +++ b/docs/templates/_header.html.slim @@ -1,76 +1,76 @@ -/ NOTE: You must restart the gradle daemon after modifying any template file for the changes to take effect. -- if !(attr? 'no-site-header') && (attr? 'site-seedu') - #seedu-header - nav.navbar.navbar-lg.navbar-light.bg-lighter - .container - a.navbar-brand href='https://se-edu.github.io/' - img src=(site_url 'images/SeEduLogo.png') alt='SE-EDU' - ul.navbar-nav - li.nav-item - a.nav-link href='https://se-edu.github.io/addressbook-level1' AB-1 - li.nav-item - a.nav-link href='https://se-edu.github.io/addressbook-level2' AB-2 - li.nav-item - a.nav-link.active href=(site_url 'index.html') AB-3 - li.nav-item - a.nav-link href='https://se-edu.github.io/addressbook-level4' AB-4 - li.nav-item - a.nav-link href='https://se-edu.github.io/collate' Collate - li.nav-item - a.nav-link href='https://se-edu.github.io/se-book' Book - li.nav-item - a.nav-link href='https://se-edu.github.io/learningresources' Resources - -- if !(attr? 'no-site-header') - #site-header - nav.navbar.navbar-light.bg-light - .container - - if attr? 'site-name' - a.navbar-brand href=(site_url 'index.html') =(attr 'site-name') - ul.navbar-nav - li.nav-item - =nav_link('UserGuide', 'UserGuide.html', 'User Guide') - li.nav-item - =nav_link('DeveloperGuide', 'DeveloperGuide.html', 'Developer Guide') - - if attr? 'site-seedu' - li.nav-item - =nav_link('LearningOutcomes', 'LearningOutcomes.html', 'LOs') - li.nav-item - =nav_link('AboutUs', 'AboutUs.html', 'About Us') - li.nav-item - =nav_link('ContactUs', 'ContactUs.html', 'Contact Us') - - if attr? 'site-githuburl' - li.navitem - a.nav-link href=(attr 'site-githuburl') - span.fa.fa-github.fa-lg aria-hidden='true' - |  View on GitHub - -/ AsciiDoc leaves an empty header div even if there's no doctitle -#header - - if has_header? - - unless notitle - h1 =header.title - - if [:author, :revnumber, :revdate, :revremark].any? {|a| attr? a } - .details - - if attr? :author - span.author#author =(attr :author) - br - - if attr? :email - span.email#email =sub_macros(attr :email) - br - - if (authorcount = (attr :authorcount).to_i) > 1 - - (2..authorcount).each do |idx| - span.author id="author#{idx}" =(attr "author_#{idx}") - br - - if attr? "email_#{idx}" - span.email id="email#{idx}" =sub_macros(attr "email_#{idx}") - - if attr? :revnumber - span#revnumber #{((attr 'version-label') || '').downcase} #{attr :revnumber}#{',' if attr? :revdate} - ' - - if attr? :revdate - span#revdate =attr :revdate - - if attr? :revremark - br - span#revremark =(attr :revremark) - - if (attr? :toc) && (attr? 'toc-placement', 'auto') - include _toc.html +/ NOTE: You must restart the gradle daemon after modifying any template file for the changes to take effect. +- if !(attr? 'no-site-header') && (attr? 'site-seedu') + #seedu-header + nav.navbar.navbar-lg.navbar-light.bg-lighter + .container + a.navbar-brand href='https://se-edu.github.io/' + img src=(site_url 'images/SeEduLogo.png') alt='SE-EDU' + ul.navbar-nav + li.nav-item + a.nav-link href='https://se-edu.github.io/addressbook-level1' AB-1 + li.nav-item + a.nav-link href='https://se-edu.github.io/addressbook-level2' AB-2 + li.nav-item + a.nav-link.active href=(site_url 'index.html') AB-3 + li.nav-item + a.nav-link href='https://se-edu.github.io/addressbook-level4' AB-4 + li.nav-item + a.nav-link href='https://se-edu.github.io/collate' Collate + li.nav-item + a.nav-link href='https://se-edu.github.io/se-book' Book + li.nav-item + a.nav-link href='https://se-edu.github.io/learningresources' Resources + +- if !(attr? 'no-site-header') + #site-header + nav.navbar.navbar-light.bg-light + .container + - if attr? 'site-name' + a.navbar-brand href=(site_url 'index.html') =(attr 'site-name') + ul.navbar-nav + li.nav-item + =nav_link('UserGuide', 'UserGuide.html', 'User Guide') + li.nav-item + =nav_link('DeveloperGuide', 'DeveloperGuide.html', 'Developer Guide') + - if attr? 'site-seedu' + li.nav-item + =nav_link('LearningOutcomes', 'LearningOutcomes.html', 'LOs') + li.nav-item + =nav_link('AboutUs', 'AboutUs.html', 'About Us') + li.nav-item + =nav_link('ContactUs', 'ContactUs.html', 'Contact Us') + - if attr? 'site-githuburl' + li.navitem + a.nav-link href=(attr 'site-githuburl') + span.fa.fa-github.fa-lg aria-hidden='true' + |  View on GitHub + +/ AsciiDoc leaves an empty header div even if there's no doctitle +#header + - if has_header? + - unless notitle + h1 =header.title + - if [:author, :revnumber, :revdate, :revremark].any? {|a| attr? a } + .details + - if attr? :author + span.author#author =(attr :author) + br + - if attr? :email + span.email#email =sub_macros(attr :email) + br + - if (authorcount = (attr :authorcount).to_i) > 1 + - (2..authorcount).each do |idx| + span.author id="author#{idx}" =(attr "author_#{idx}") + br + - if attr? "email_#{idx}" + span.email id="email#{idx}" =sub_macros(attr "email_#{idx}") + - if attr? :revnumber + span#revnumber #{((attr 'version-label') || '').downcase} #{attr :revnumber}#{',' if attr? :revdate} + ' + - if attr? :revdate + span#revdate =attr :revdate + - if attr? :revremark + br + span#revremark =(attr :revremark) + - if (attr? :toc) && (attr? 'toc-placement', 'auto') + include _toc.html diff --git a/docs/templates/_toc.html.slim b/docs/templates/_toc.html.slim index f0ad719fe0f..40123a8c9bb 100644 --- a/docs/templates/_toc.html.slim +++ b/docs/templates/_toc.html.slim @@ -1,5 +1,5 @@ -/ NOTE: You must restart the gradle daemon after modifying any template file for the changes to take effect. -#toc class=(attr 'toc-class', 'toc') - #toctitle =(attr 'toc-title') - / Renders block_outline.html. - = converter.convert document, 'outline' +/ NOTE: You must restart the gradle daemon after modifying any template file for the changes to take effect. +#toc class=(attr 'toc-class', 'toc') + #toctitle =(attr 'toc-title') + / Renders block_outline.html. + = converter.convert document, 'outline' diff --git a/docs/templates/document.html.slim b/docs/templates/document.html.slim index 3e1961d4afa..17c3ea94752 100644 --- a/docs/templates/document.html.slim +++ b/docs/templates/document.html.slim @@ -1,29 +1,29 @@ -/ NOTE: You must restart the gradle daemon after modifying any template file for the changes to take effect. -doctype 5 -html lang=(attr :lang, 'en' unless attr? :nolang) - head - meta charset=(attr :encoding, 'UTF-8') - /[if IE] - meta http-equiv="X-UA-Compatible" content="IE=edge" - meta name='viewport' content='width=device-width, initial-scale=1.0' - meta name='generator' content="Asciidoctor #{attr 'asciidoctor-version'}" - = html_meta_if 'application-name', (attr 'app-name') - = html_meta_if 'author', (attr :authors) - = html_meta_if 'copyright', (attr :copyright) - = html_meta_if 'description', (attr :description) - = html_meta_if 'keywords', (attr :keywords) - title=((doctitle sanitize: true) || (attr 'untitled-label')) - = styles_and_scripts - - unless (docinfo_content = docinfo).empty? - =docinfo_content - body( - id=id - class=[(attr :doctype), ("#{attr 'toc-class'} toc-#{attr 'toc-position', 'left'}" if (attr? 'toc-class') && (attr? :toc) && (attr? 'toc-placement', 'auto'))] - style=style_value(max_width: (attr 'max-width'))) - - unless noheader - include _header.html - #content =content - - unless !footnotes? || (attr? :nofootnotes) - include _footnotes.html - - unless nofooter - include _footer.html +/ NOTE: You must restart the gradle daemon after modifying any template file for the changes to take effect. +doctype 5 +html lang=(attr :lang, 'en' unless attr? :nolang) + head + meta charset=(attr :encoding, 'UTF-8') + /[if IE] + meta http-equiv="X-UA-Compatible" content="IE=edge" + meta name='viewport' content='width=device-width, initial-scale=1.0' + meta name='generator' content="Asciidoctor #{attr 'asciidoctor-version'}" + = html_meta_if 'application-name', (attr 'app-name') + = html_meta_if 'author', (attr :authors) + = html_meta_if 'copyright', (attr :copyright) + = html_meta_if 'description', (attr :description) + = html_meta_if 'keywords', (attr :keywords) + title=((doctitle sanitize: true) || (attr 'untitled-label')) + = styles_and_scripts + - unless (docinfo_content = docinfo).empty? + =docinfo_content + body( + id=id + class=[(attr :doctype), ("#{attr 'toc-class'} toc-#{attr 'toc-position', 'left'}" if (attr? 'toc-class') && (attr? :toc) && (attr? 'toc-placement', 'auto'))] + style=style_value(max_width: (attr 'max-width'))) + - unless noheader + include _header.html + #content =content + - unless !footnotes? || (attr? :nofootnotes) + include _footnotes.html + - unless nofooter + include _footer.html diff --git a/docs/templates/helpers.rb b/docs/templates/helpers.rb index 7060efe223e..6a064def10e 100644 --- a/docs/templates/helpers.rb +++ b/docs/templates/helpers.rb @@ -1,300 +1,300 @@ -# NOTE: You must restart the gradle daemon after modifying any template file for the changes to take effect. -require 'asciidoctor' -require 'json' - -if Gem::Version.new(Asciidoctor::VERSION) <= Gem::Version.new('1.5.1') - fail 'asciidoctor: FAILED: HTML5/Slim backend needs Asciidoctor >=1.5.2!' -end - -unless defined? Slim::Include - fail 'asciidoctor: FAILED: HTML5/Slim backend needs Slim >= 2.1.0!' -end - -# Add custom functions to this module that you want to use in your Slim -# templates. Within the template you can invoke them as top-level functions -# just like in Haml. -module Slim::Helpers - - # URIs of external assets. - FONT_AWESOME_URI = '//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css' - HIGHLIGHTJS_BASE_URI = '//cdnjs.cloudflare.com/ajax/libs/highlight.js/7.4' - MATHJAX_JS_URI = '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_HTMLorMML' - PRETTIFY_BASE_URI = '//cdnjs.cloudflare.com/ajax/libs/prettify/r298' - - # Defaults - DEFAULT_HIGHLIGHTJS_THEME = 'github' - DEFAULT_PRETTIFY_THEME = 'prettify' - DEFAULT_SECTNUMLEVELS = 3 - DEFAULT_TOCLEVELS = 2 - - # The MathJax configuration. - MATHJAX_CONFIG = { - tex2jax: { - inlineMath: [::Asciidoctor::INLINE_MATH_DELIMITERS[:latexmath]], - displayMath: [::Asciidoctor::BLOCK_MATH_DELIMITERS[:latexmath]], - ignoreClass: 'nostem|nolatexmath' - }, - asciimath2jax: { - delimiters: [::Asciidoctor::BLOCK_MATH_DELIMITERS[:asciimath]], - ignoreClass: 'nostem|noasciimath' - } - }.to_json - - VOID_ELEMENTS = %w(area base br col command embed hr img input keygen link meta param source track wbr) - - - ## - # Creates an HTML tag with the given name and optionally attributes. Can take - # a block that will run between the opening and closing tags. - # - # @param name [#to_s] the name of the tag. - # @param attributes [Hash] - # @param content [#to_s] the content; +nil+ to call the block. - # @yield The block of Slim/HTML code within the tag (optional). - # @return [String] a rendered HTML element. - # - def html_tag(name, attributes = {}, content = nil) - attrs = attributes.reject { |_, v| - v.nil? || (v.respond_to?(:empty?) && v.empty?) - }.map do |k, v| - v = v.compact.join(' ') if v.is_a? Array - v = nil if v == true - v = %("#{v}") if v - [k, v] * '=' - end - attrs_str = attrs.empty? ? '' : attrs.join(' ').prepend(' ') - - if VOID_ELEMENTS.include? name.to_s - %(<#{name}#{attrs_str}>) - else - content ||= yield if block_given? - %(<#{name}#{attrs_str}>#{content}) - end - end - - ## - # Formats the given hash as CSS declarations for an inline style. - # - # @example - # style_value(text_align: 'right', float: 'left') - # => "text-align: right; float: left;" - # - # style_value(text_align: nil, float: 'left') - # => "float: left;" - # - # style_value(width: [90, '%'], height: '50px') - # => "width: 90%; height: 50px;" - # - # style_value(width: ['120px', 'px']) - # => "width: 90px;" - # - # style_value(width: [nil, 'px']) - # => nil - # - # @param declarations [Hash] - # @return [String, nil] - # - def style_value(declarations) - decls = [] - - declarations.each do |prop, value| - next if value.nil? - - if value.is_a? Array - value, unit = value - next if value.nil? - value = value.to_s + unit unless value.end_with? unit - end - prop = prop.to_s.gsub('_', '-') - decls << %(#{prop}: #{value}) - end - - decls.empty? ? nil : decls.join('; ') + ';' - end - - def urlize(*segments) - path = segments * '/' - if path.start_with? '//' - @_uri_scheme ||= document.attr 'asset-uri-scheme', 'https' - path = %(#{@_uri_scheme}:#{path}) unless @_uri_scheme.empty? - end - normalize_web_path path - end - - - ## - # @param index [Integer] the footnote's index. - # @return [String] footnote id to be used in a link. - def footnote_id(index = (attr :index)) - %(_footnote_#{index}) - end - - ## - # @param index (see #footnote_id) - # @return [String] footnoteref id to be used in a link. - def footnoteref_id(index = (attr :index)) - %(_footnoteref_#{index}) - end - - def icons? - document.attr? :icons - end - - def font_icons? - document.attr? :icons, 'font' - end - - def nowrap? - 'nowrap' if !document.attr?(:prewrap) || option?('nowrap') - end - - #-------------------------------------------------------- - # _header - # - - ## - # Constructs a relative path to the target page. - # - # @param href [String] Path to the target page, relative to the site root. - # @return [String] Path to the target page, relative to the current document. - def site_url(href) - path_resolver = (@path_resolver ||= PathResolver.new) - base_dir = path_resolver.posixify(@document.base_dir) - site_root = path_resolver.posixify(@document.attr('site-root', base_dir)) - unless path_resolver.is_root? site_root - raise ::ArgumentError, %(site-root must be an absolute path: #{site_root}) - end - base_dir_to_root = nil - if (base_dir != site_root) && (base_dir.start_with? site_root) - comp, root = path_resolver.partition_path(base_dir.slice(site_root.length + 1, base_dir.length)) - base_dir_to_root = '../' * comp.length - end - path_resolver.web_path(href, base_dir_to_root) - end - - ## - # Constructs a HTML tag representing a link in the navigation bar. - # - # @param section [String] Name of the site section represented by the link. - # This is used to highlight the navigation item if the current document - # sets its site-section attribute to this String, indicating that the - # reader is browsing this section of the site. - # @param href [String] Path to the target page, relative to the site root. - # @param content [String] Link content. This is usually the human-readable name - # of the link target. - # @return [String] The rendered tag. - def nav_link(section, href, content) - attributes = { - :class => ['nav-link'], - :href => site_url(href), - } - attributes[:class].push('active') if (attr 'site-section') == section - html_tag('a', attributes, content) - end - - #-------------------------------------------------------- - # document - # - - ## - # Returns HTML meta tag if the given +content+ is not +nil+. - # - # @param name [#to_s] the name for the metadata. - # @param content [#to_s, nil] the value of the metadata, or +nil+. - # @return [String, nil] the meta tag, or +nil+ if the +content+ is +nil+. - # - def html_meta_if(name, content) - %() if content - end - - # Returns formatted style/link and script tags for header. - def styles_and_scripts - scripts = [] - styles = [] - tags = [] - - stylesheet = attr :stylesheet - stylesdir = attr :stylesdir, '' - default_style = ::Asciidoctor::DEFAULT_STYLESHEET_KEYS.include? stylesheet - linkcss = (attr? :linkcss) || safe >= ::Asciidoctor::SafeMode::SECURE - ss = ::Asciidoctor::Stylesheets.instance - - if linkcss - path = default_style ? ::Asciidoctor::DEFAULT_STYLESHEET_NAME : stylesheet - styles << { href: [stylesdir, path] } - elsif default_style - styles << { text: ss.primary_stylesheet_data } - else - styles << { text: read_asset(normalize_system_path(stylesheet, stylesdir), true) } - end - - if attr? :icons, 'font' - if attr? 'iconfont-remote' - styles << { href: (attr 'iconfont-cdn', FONT_AWESOME_URI) } - else - styles << { href: [stylesdir, %(#{attr 'iconfont-name', 'font-awesome'}.css)] } - end - end - - if attr? 'stem' - scripts << { src: MATHJAX_JS_URI } - scripts << { type: 'text/x-mathjax-config', text: %(MathJax.Hub.Config(#{MATHJAX_CONFIG});) } - end - - case attr 'source-highlighter' - when 'coderay' - if (attr 'coderay-css', 'class') == 'class' - if linkcss - styles << { href: [stylesdir, ss.coderay_stylesheet_name] } - else - styles << { text: ss.coderay_stylesheet_data } - end - end - - when 'pygments' - if (attr 'pygments-css', 'class') == 'class' - if linkcss - styles << { href: [stylesdir, ss.pygments_stylesheet_name(attr 'pygments-style')] } - else - styles << { text: ss.pygments_stylesheet_data(attr 'pygments-style') } - end - end - - when 'highlightjs' - hjs_base = attr :highlightjsdir, HIGHLIGHTJS_BASE_URI - hjs_theme = attr 'highlightjs-theme', DEFAULT_HIGHLIGHTJS_THEME - - scripts << { src: [hjs_base, 'highlight.min.js'] } - scripts << { src: [hjs_base, 'lang/common.min.js'] } - scripts << { text: 'hljs.initHighlightingOnLoad()' } - styles << { href: [hjs_base, %(styles/#{hjs_theme}.min.css)] } - - when 'prettify' - prettify_base = attr :prettifydir, PRETTIFY_BASE_URI - prettify_theme = attr 'prettify-theme', DEFAULT_PRETTIFY_THEME - - scripts << { src: [prettify_base, 'prettify.min.js'] } - scripts << { text: 'document.addEventListener("DOMContentLoaded", prettyPrint)' } - styles << { href: [prettify_base, %(#{prettify_theme}.min.css)] } - end - - styles.each do |item| - if item.key?(:text) - tags << html_tag(:style, {}, item[:text]) - else - tags << html_tag(:link, rel: 'stylesheet', href: urlize(*item[:href])) - end - end - - scripts.each do |item| - if item.key? :text - tags << html_tag(:script, {type: item[:type]}, item[:text]) - else - tags << html_tag(:script, type: item[:type], src: urlize(*item[:src])) - end - end - - tags.join "\n" - end - -end +# NOTE: You must restart the gradle daemon after modifying any template file for the changes to take effect. +require 'asciidoctor' +require 'json' + +if Gem::Version.new(Asciidoctor::VERSION) <= Gem::Version.new('1.5.1') + fail 'asciidoctor: FAILED: HTML5/Slim backend needs Asciidoctor >=1.5.2!' +end + +unless defined? Slim::Include + fail 'asciidoctor: FAILED: HTML5/Slim backend needs Slim >= 2.1.0!' +end + +# Add custom functions to this module that you want to use in your Slim +# templates. Within the template you can invoke them as top-level functions +# just like in Haml. +module Slim::Helpers + + # URIs of external assets. + FONT_AWESOME_URI = '//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css' + HIGHLIGHTJS_BASE_URI = '//cdnjs.cloudflare.com/ajax/libs/highlight.js/7.4' + MATHJAX_JS_URI = '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_HTMLorMML' + PRETTIFY_BASE_URI = '//cdnjs.cloudflare.com/ajax/libs/prettify/r298' + + # Defaults + DEFAULT_HIGHLIGHTJS_THEME = 'github' + DEFAULT_PRETTIFY_THEME = 'prettify' + DEFAULT_SECTNUMLEVELS = 3 + DEFAULT_TOCLEVELS = 2 + + # The MathJax configuration. + MATHJAX_CONFIG = { + tex2jax: { + inlineMath: [::Asciidoctor::INLINE_MATH_DELIMITERS[:latexmath]], + displayMath: [::Asciidoctor::BLOCK_MATH_DELIMITERS[:latexmath]], + ignoreClass: 'nostem|nolatexmath' + }, + asciimath2jax: { + delimiters: [::Asciidoctor::BLOCK_MATH_DELIMITERS[:asciimath]], + ignoreClass: 'nostem|noasciimath' + } + }.to_json + + VOID_ELEMENTS = %w(area base br col command embed hr img input keygen link meta param source track wbr) + + + ## + # Creates an HTML tag with the given name and optionally attributes. Can take + # a block that will run between the opening and closing tags. + # + # @param name [#to_s] the name of the tag. + # @param attributes [Hash] + # @param content [#to_s] the content; +nil+ to call the block. + # @yield The block of Slim/HTML code within the tag (optional). + # @return [String] a rendered HTML element. + # + def html_tag(name, attributes = {}, content = nil) + attrs = attributes.reject { |_, v| + v.nil? || (v.respond_to?(:empty?) && v.empty?) + }.map do |k, v| + v = v.compact.join(' ') if v.is_a? Array + v = nil if v == true + v = %("#{v}") if v + [k, v] * '=' + end + attrs_str = attrs.empty? ? '' : attrs.join(' ').prepend(' ') + + if VOID_ELEMENTS.include? name.to_s + %(<#{name}#{attrs_str}>) + else + content ||= yield if block_given? + %(<#{name}#{attrs_str}>#{content}) + end + end + + ## + # Formats the given hash as CSS declarations for an inline style. + # + # @example + # style_value(text_align: 'right', float: 'left') + # => "text-align: right; float: left;" + # + # style_value(text_align: nil, float: 'left') + # => "float: left;" + # + # style_value(width: [90, '%'], height: '50px') + # => "width: 90%; height: 50px;" + # + # style_value(width: ['120px', 'px']) + # => "width: 90px;" + # + # style_value(width: [nil, 'px']) + # => nil + # + # @param declarations [Hash] + # @return [String, nil] + # + def style_value(declarations) + decls = [] + + declarations.each do |prop, value| + next if value.nil? + + if value.is_a? Array + value, unit = value + next if value.nil? + value = value.to_s + unit unless value.end_with? unit + end + prop = prop.to_s.gsub('_', '-') + decls << %(#{prop}: #{value}) + end + + decls.empty? ? nil : decls.join('; ') + ';' + end + + def urlize(*segments) + path = segments * '/' + if path.start_with? '//' + @_uri_scheme ||= document.attr 'asset-uri-scheme', 'https' + path = %(#{@_uri_scheme}:#{path}) unless @_uri_scheme.empty? + end + normalize_web_path path + end + + + ## + # @param index [Integer] the footnote's index. + # @return [String] footnote id to be used in a link. + def footnote_id(index = (attr :index)) + %(_footnote_#{index}) + end + + ## + # @param index (see #footnote_id) + # @return [String] footnoteref id to be used in a link. + def footnoteref_id(index = (attr :index)) + %(_footnoteref_#{index}) + end + + def icons? + document.attr? :icons + end + + def font_icons? + document.attr? :icons, 'font' + end + + def nowrap? + 'nowrap' if !document.attr?(:prewrap) || option?('nowrap') + end + + #-------------------------------------------------------- + # _header + # + + ## + # Constructs a relative path to the target page. + # + # @param href [String] Path to the target page, relative to the site root. + # @return [String] Path to the target page, relative to the current document. + def site_url(href) + path_resolver = (@path_resolver ||= PathResolver.new) + base_dir = path_resolver.posixify(@document.base_dir) + site_root = path_resolver.posixify(@document.attr('site-root', base_dir)) + unless path_resolver.is_root? site_root + raise ::ArgumentError, %(site-root must be an absolute path: #{site_root}) + end + base_dir_to_root = nil + if (base_dir != site_root) && (base_dir.start_with? site_root) + comp, root = path_resolver.partition_path(base_dir.slice(site_root.length + 1, base_dir.length)) + base_dir_to_root = '../' * comp.length + end + path_resolver.web_path(href, base_dir_to_root) + end + + ## + # Constructs a HTML tag representing a link in the navigation bar. + # + # @param section [String] Name of the site section represented by the link. + # This is used to highlight the navigation item if the current document + # sets its site-section attribute to this String, indicating that the + # reader is browsing this section of the site. + # @param href [String] Path to the target page, relative to the site root. + # @param content [String] Link content. This is usually the human-readable name + # of the link target. + # @return [String] The rendered tag. + def nav_link(section, href, content) + attributes = { + :class => ['nav-link'], + :href => site_url(href), + } + attributes[:class].push('active') if (attr 'site-section') == section + html_tag('a', attributes, content) + end + + #-------------------------------------------------------- + # document + # + + ## + # Returns HTML meta tag if the given +content+ is not +nil+. + # + # @param name [#to_s] the name for the metadata. + # @param content [#to_s, nil] the value of the metadata, or +nil+. + # @return [String, nil] the meta tag, or +nil+ if the +content+ is +nil+. + # + def html_meta_if(name, content) + %() if content + end + + # Returns formatted style/link and script tags for header. + def styles_and_scripts + scripts = [] + styles = [] + tags = [] + + stylesheet = attr :stylesheet + stylesdir = attr :stylesdir, '' + default_style = ::Asciidoctor::DEFAULT_STYLESHEET_KEYS.include? stylesheet + linkcss = (attr? :linkcss) || safe >= ::Asciidoctor::SafeMode::SECURE + ss = ::Asciidoctor::Stylesheets.instance + + if linkcss + path = default_style ? ::Asciidoctor::DEFAULT_STYLESHEET_NAME : stylesheet + styles << { href: [stylesdir, path] } + elsif default_style + styles << { text: ss.primary_stylesheet_data } + else + styles << { text: read_asset(normalize_system_path(stylesheet, stylesdir), true) } + end + + if attr? :icons, 'font' + if attr? 'iconfont-remote' + styles << { href: (attr 'iconfont-cdn', FONT_AWESOME_URI) } + else + styles << { href: [stylesdir, %(#{attr 'iconfont-name', 'font-awesome'}.css)] } + end + end + + if attr? 'stem' + scripts << { src: MATHJAX_JS_URI } + scripts << { type: 'text/x-mathjax-config', text: %(MathJax.Hub.Config(#{MATHJAX_CONFIG});) } + end + + case attr 'source-highlighter' + when 'coderay' + if (attr 'coderay-css', 'class') == 'class' + if linkcss + styles << { href: [stylesdir, ss.coderay_stylesheet_name] } + else + styles << { text: ss.coderay_stylesheet_data } + end + end + + when 'pygments' + if (attr 'pygments-css', 'class') == 'class' + if linkcss + styles << { href: [stylesdir, ss.pygments_stylesheet_name(attr 'pygments-style')] } + else + styles << { text: ss.pygments_stylesheet_data(attr 'pygments-style') } + end + end + + when 'highlightjs' + hjs_base = attr :highlightjsdir, HIGHLIGHTJS_BASE_URI + hjs_theme = attr 'highlightjs-theme', DEFAULT_HIGHLIGHTJS_THEME + + scripts << { src: [hjs_base, 'highlight.min.js'] } + scripts << { src: [hjs_base, 'lang/common.min.js'] } + scripts << { text: 'hljs.initHighlightingOnLoad()' } + styles << { href: [hjs_base, %(styles/#{hjs_theme}.min.css)] } + + when 'prettify' + prettify_base = attr :prettifydir, PRETTIFY_BASE_URI + prettify_theme = attr 'prettify-theme', DEFAULT_PRETTIFY_THEME + + scripts << { src: [prettify_base, 'prettify.min.js'] } + scripts << { text: 'document.addEventListener("DOMContentLoaded", prettyPrint)' } + styles << { href: [prettify_base, %(#{prettify_theme}.min.css)] } + end + + styles.each do |item| + if item.key?(:text) + tags << html_tag(:style, {}, item[:text]) + else + tags << html_tag(:link, rel: 'stylesheet', href: urlize(*item[:href])) + end + end + + scripts.each do |item| + if item.key? :text + tags << html_tag(:script, {type: item[:type]}, item[:text]) + else + tags << html_tag(:script, type: item[:type], src: urlize(*item[:src])) + end + end + + tags.join "\n" + end + +end diff --git a/docs/tutorials/AddRemark.adoc b/docs/tutorials/AddRemark.adoc index 51044c36494..3ff160d362a 100644 --- a/docs/tutorials/AddRemark.adoc +++ b/docs/tutorials/AddRemark.adoc @@ -1,425 +1,425 @@ -= Tutorial - Adding a new Command -:toc: macro -:site-section: DeveloperGuide -:imagesDir: ../images/add-remark -:stylesDir: ../stylesheets -:xrefstyle: full -ifdef::env-github[] -:tip-caption: :bulb: -:note-caption: :information_source: -:warning-caption: :warning: -endif::[] - -toc::[] - -== Introduction - -In this tutorial, we'll walk you through the implementation of a new command -- `remark`. - -This command allows users of the AddressBook application to add optional remarks to people in their address book and edit it if required. -The command should have the format of `remark INDEX r/REMARK`. -An example of the command is `remark 2 r/Likes baseball`. - -We'll assume that you have already set up the development environment as outlined in the Developer's Guide. - -== Create a new `remark` command - -Looking in the `logic.command` package, you will notice that each existing command have their own class. -All the commands inherit from the abstract class `Command` which means that they must override `execute()`. -Each `Command` returns an instance of `CommandResult` upon success and `CommandResult#feedbackToUser` is printed to the `ResultDisplay`. - -Let's start by creating a new `RemarkCommand` class in the `src/main/java/seedu/address/logic/command` directory. - -For now, let's keep `RemarkCommand` as simple as possible and print some output. -We accomplish that by returning a `CommandResult` with an accompanying message. - -.RemarkCommand.java -[source, java] ----- -package seedu.address.logic.commands; - -import seedu.address.model.Model; - -/** - * Changes the remark of an existing person in the address book. - */ -public class RemarkCommand extends Command { - - public static final String COMMAND_WORD = "remark"; - - @Override - public CommandResult execute(Model model) { - return new CommandResult("Hello from remark"); - } -} ----- - -=== Hook `RemarkCommand` into the application - -Now that we have our `RemarkCommand` ready to be executed, we need to update `AddressBookParser#parseCommand()` to recognize the `remark` keyword. -Add the new command to the `switch` block by creating a new `case` that returns a new instance of `RemarkCommand`. - -You can refer to the changes in this link:https://github.com/nus-cs2103-AY1920S1/addressbook-level3/commit/7d04e49e364dad661cd88f462f01923fba972d2c#diff-5338391f3f6fbb4022c44add6590b74f[diff]. - -=== Run the application - -Run `Main#main` and try out your new `RemarkCommand`. -If everything went well, you should see something like this: - -.Output displayed -image::RemarkHello.png[] - -== Change `RemarkCommand` to throw an exception - -While we have successfully printed a message to `ResultDisplay`, the command does not do what it is supposed to do. -Let's change the command to throw an `CommandException` to accurately reflect that our command is still a work in progress. - -.The relationship between RemarkCommand and Command -image::CommandInterface.png[] - -Following the convention in other commands, we add relevant messages as constants and use them. - -.RemarkCommand.java -[source, java] ----- - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the remark of the person identified " - + "by the index number used in the last person listing. " - + "Existing remark will be overwritten by the input.\n" - + "Parameters: INDEX (must be a positive integer) " - + "r/ [REMARK]\n" - + "Example: " + COMMAND_WORD + " 1 " - + "r/ Likes to swim."; - - public static final String MESSAGE_NOT_IMPLEMENTED_YET = "Remark command not implemented yet"; - - @Override - public CommandResult execute(Model model) throws CommandException { - throw new CommandException(MESSAGE_NOT_IMPLEMENTED_YET); - } ----- - -== Enhancing `RemarkCommand` - -Let's change `RemarkCommand` to parse input from the user. - -=== Make the command accept parameters - -We start by modifying the constructor of `RemarkCommand` to accept an `Index` and a `String`. -While we are at it, let's change the error message to echo the values. -While this is not a replacement for tests, it is an obvious way to tell if our code is functioning as intended. - -[source, java] ----- -import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; -//... -public class RemarkCommand extends Command { - //... - public static final String MESSAGE_ARGUMENTS = "Index: %1$d, Remark: %2$s"; - - private final Index index; - private final String remark; - - /** - * @param index of the person in the filtered person list to edit the remark - * @param remark of the person to be updated to - */ - public RemarkCommand(Index index, String remark) { - requireAllNonNull(index, remark); - - this.index = index; - this.remark = remark; - } - @Override - public CommandResult execute(Model model) throws CommandException { - throw new CommandException(String.format(MESSAGE_ARGUMENTS, index.getOneBased(), remark)); - } - - @Override - public boolean equals(Object other) { - // short circuit if same object - if (other == this) { - return true; - } - - // instanceof handles nulls - if (!(other instanceof RemarkCommand)) { - return false; - } - - // state check - RemarkCommand e = (RemarkCommand) other; - return index.equals(e.index) - && remark.equals(e.remark); - } -} ----- - -Your code should look something like link:https://github.com/nus-cs2103-AY1920S1/addressbook-level3/commit/83dd9e6b03d6b83199ceb6f3b66166483155abed#diff-34ace715a8a8d2e5a66e71289f017b47[this] after you are done. - -=== Parse user input - -Now let's move on to writing a parser that will extract the index and remark from the input provided by the user. - -Create a `RemarkCommandParser` class in the `seedu.address.logic.parser` package. -The class must extend the `Parser` interface. - -.The relationship between Parser and RemarkCommandParser -image::ParserInterface.png[] - -Thankfully, `ArgumentTokenizer#tokenize()` makes it trivial to parse user input. -Let's take a look at the JavaDoc provided for the function to understand what it does. - -[source, java] -.ArgumentTokenizer.java ----- -/** - * Tokenizes an arguments string and returns an {@code ArgumentMultimap} - * object that maps prefixes to their respective argument values. Only the - * given prefixes will be recognized in the arguments string. - * - * @param argsString Arguments string of the form: - * {@code preamble value value ...} - * @param prefixes Prefixes to tokenize the arguments string with - * @return ArgumentMultimap object that maps prefixes to their - * arguments - */ ----- - -We can tell `ArgumentTokenizer#tokenize()` to look out for our new prefix `r/` and it will return us an instance of `ArgumentMultimap`. -Now let's find out what we need to do in order to obtain the Index and String that we need. -Let's look through `ArgumentMultimap` : - -[source, java] -.ArgumentMultimap.java ----- -/** - * Returns the last value of {@code prefix}. - */ -public Optional getValue(Prefix prefix) { - List values = getAllValues(prefix); - return values.isEmpty() ? Optional.empty() : - Optional.of(values.get(values.size() - 1)); -} ----- - -This appears to be what we need to get a String of the remark. -But what about the Index? Taking a quick peek at existing an `Command`... - -[source, java] -.DeleteCommandParser.java ----- -Index index = ParserUtil.parseIndex(args); -return new DeleteCommand(index); ----- - -There appears to be another utility class that obtains an `Index` from the input provided by the user. - -Now that we have the know-how to extract the data that we need from the user's input, we can create a new instance of `RemarkCommand`. - -[source, java] -.RemarkCommandParser.java ----- -public RemarkCommand parse(String args) throws ParseException { - requireNonNull(args); - ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, - PREFIX_REMARK); - - Index index; - try { - index = ParserUtil.parseIndex(argMultimap.getPreamble()); - } catch (IllegalValueException ive) { - throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, - RemarkCommand.MESSAGE_USAGE), ive); - } - - String remark = argMultimap.getValue(PREFIX_REMARK).orElse(""); - - return new RemarkCommand(index, remark); -} ----- - -NOTE: Don't forget to update `AddressBookParser` to use our new `RemarkCommandParser`! - -If you are stuck, check out the sample link:https://github.com/nus-cs2103-AY1920S1/addressbook-level3/commit/efdcdf0e80cec9489f7b47e3f65824f4688ad8f7#diff-fc19ecee89c3732a62fbc8c840250508[here]. - -== Add `Remark` to the model - -Now that we have all the information that we need, let's lay the groundwork for some _persistent_ changes. -We achieve that by working with the `Person` model. -Each field in a Person is implemented as a separate class (e.g. a `Name` object represents the person's name). -That means we should add a `Remark` class so that we can use a `Remark` object to represent a remark given to a person. - -=== Add a new `Remark` class - -Create a new `Remark` in `seedu.address.model.person`. Since a `Remark` is a field that is similar to `Address`, we can reuse a significant bit of code. - -A copy-paste and search-replace later, you should have something like link:https://github.com/nus-cs2103-AY1920S1/addressbook-level3/commit/b7a47c50c8e5f0430d343a23d2863446b6ce9298#diff-af2f075d24dfcd333876f0fbce321f25[this]. -Note how `Remark` has no constrains and thus does not require input validation. - -=== Make use of `Remark` - -Let's change `RemarkCommand` and `RemarkCommandParser` to use the new `Remark` class instead of plain `String`. -These should be relatively simple changes. - -== Add a placeholder element for remark to the UI - -Without getting too deep into `fxml`, let's go on a 5 minute adventure to get some placeholder text to show up for each person. - -Simply add -[source, java] -.PersonCard.java -``` -@FXML -private Label remark; -``` - -to link:https://github.com/nus-cs2103-AY1920S1/addressbook-level3/commit/2758455583f0101ed918a318fc75679270843a0d#diff-0c6b6abcfac8c205e075294f25e851fe[`seedu.address.ui.PersonCard`]. -`@FXML` is an annotation that marks a private or protected field and makes it accessible to FXML. -It might sound like Greek to you right now, don't worry -- we will get back to it later. - -Then insert - -``` -
getAddress() { - return Optional.ofNullable(address); - } - - /** - * Sets {@code tags} to this object's {@code tags}. - * A defensive copy of {@code tags} is used internally. - */ - public void setTags(Set tags) { - this.tags = (tags != null) ? new HashSet<>(tags) : null; - } - - /** - * Returns an unmodifiable tag set, which throws {@code UnsupportedOperationException} - * if modification is attempted. - * Returns {@code Optional#empty()} if {@code tags} is null. - */ - public Optional> getTags() { - return (tags != null) ? Optional.of(Collections.unmodifiableSet(tags)) : Optional.empty(); - } - - @Override - public boolean equals(Object other) { - // short circuit if same object - if (other == this) { - return true; - } - - // instanceof handles nulls - if (!(other instanceof EditPersonDescriptor)) { - return false; - } - - // state check - EditPersonDescriptor e = (EditPersonDescriptor) other; - - return getName().equals(e.getName()) - && getPhone().equals(e.getPhone()) - && getEmail().equals(e.getEmail()) - && getAddress().equals(e.getAddress()) - && getTags().equals(e.getTags()); - } - } -} +package seedu.address.logic.commands; + +import static java.util.Objects.requireNonNull; +import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; +import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; +import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; +import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; +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.HashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; + +import seedu.address.commons.core.Messages; +import seedu.address.commons.core.index.Index; +import seedu.address.commons.util.CollectionUtil; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.Model; +import seedu.address.model.person.Email; +import seedu.address.model.person.Name; +import seedu.address.model.person.Person; +import seedu.address.model.person.Phone; +import seedu.address.model.tag.Tag; + +/** + * Edits the details of an existing person in the address book. + */ +public class EditCommand extends Command { + + public static final String COMMAND_WORD = "edit"; + + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified " + + "by the index number used in the displayed person list. " + + "Existing values will be overwritten by the input values.\n" + + "Parameters: INDEX (must be a positive integer) " + + "[" + PREFIX_NAME + "NAME] " + + "[" + PREFIX_PHONE + "PHONE] " + + "[" + PREFIX_EMAIL + "EMAIL] " + + "[" + PREFIX_ADDRESS + "ADDRESS] " + + "[" + PREFIX_TAG + "TAG]...\n" + + "Example: " + COMMAND_WORD + " 1 " + + PREFIX_PHONE + "91234567 " + + PREFIX_EMAIL + "johndoe@example.com"; + + 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 final Index index; + private final EditPersonDescriptor editPersonDescriptor; + + /** + * @param index of the person in the filtered person list to edit + * @param editPersonDescriptor details to edit the person with + */ + public EditCommand(Index index, EditPersonDescriptor editPersonDescriptor) { + requireNonNull(index); + requireNonNull(editPersonDescriptor); + + this.index = index; + this.editPersonDescriptor = new EditPersonDescriptor(editPersonDescriptor); + } + + @Override + public CommandResult execute(Model model) throws CommandException { + requireNonNull(model); + List lastShownList = model.getFilteredPersonList(); + + if (index.getZeroBased() >= lastShownList.size()) { + throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + } + + Person personToEdit = lastShownList.get(index.getZeroBased()); + Person editedPerson = createEditedPerson(personToEdit, editPersonDescriptor); + + if (!personToEdit.isSamePerson(editedPerson) && model.hasPerson(editedPerson)) { + throw new CommandException(MESSAGE_DUPLICATE_PERSON); + } + + model.setPerson(personToEdit, editedPerson); + model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); + return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, editedPerson)); + } + + /** + * Creates and returns a {@code Person} with the details of {@code personToEdit} + * edited with {@code editPersonDescriptor}. + */ + private static Person createEditedPerson(Person personToEdit, EditPersonDescriptor editPersonDescriptor) { + assert personToEdit != null; + + Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName()); + Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); + Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); + Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); + + return new Person(updatedName, updatedPhone, updatedEmail, updatedTags); + } + + @Override + public boolean equals(Object other) { + // short circuit if same object + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof EditCommand)) { + return false; + } + + // state check + EditCommand e = (EditCommand) other; + return index.equals(e.index) + && editPersonDescriptor.equals(e.editPersonDescriptor); + } + + /** + * Stores the details to edit the person with. Each non-empty field value will replace the + * corresponding field value of the person. + */ + public static class EditPersonDescriptor { + private Name name; + private Phone phone; + private Email email; + private Set tags; + + public EditPersonDescriptor() {} + + /** + * Copy constructor. + * A defensive copy of {@code tags} is used internally. + */ + public EditPersonDescriptor(EditPersonDescriptor toCopy) { + setName(toCopy.name); + setPhone(toCopy.phone); + setEmail(toCopy.email); + setTags(toCopy.tags); + } + + /** + * Returns true if at least one field is edited. + */ + public boolean isAnyFieldEdited() { + return CollectionUtil.isAnyNonNull(name, phone, email, tags); + } + + public void setName(Name name) { + this.name = name; + } + + public Optional getName() { + return Optional.ofNullable(name); + } + + public void setPhone(Phone phone) { + this.phone = phone; + } + + public Optional getPhone() { + return Optional.ofNullable(phone); + } + + public void setEmail(Email email) { + this.email = email; + } + + public Optional getEmail() { + return Optional.ofNullable(email); + } + + /** + * Sets {@code tags} to this object's {@code tags}. + * A defensive copy of {@code tags} is used internally. + */ + public void setTags(Set tags) { + this.tags = (tags != null) ? new HashSet<>(tags) : null; + } + + /** + * Returns an unmodifiable tag set, which throws {@code UnsupportedOperationException} + * if modification is attempted. + * Returns {@code Optional#empty()} if {@code tags} is null. + */ + public Optional> getTags() { + return (tags != null) ? Optional.of(Collections.unmodifiableSet(tags)) : Optional.empty(); + } + + @Override + public boolean equals(Object other) { + // short circuit if same object + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof EditPersonDescriptor)) { + return false; + } + + // state check + EditPersonDescriptor e = (EditPersonDescriptor) other; + + return getName().equals(e.getName()) + && getPhone().equals(e.getPhone()) + && getEmail().equals(e.getEmail()) + && getTags().equals(e.getTags()); + } + } +} diff --git a/src/main/java/seedu/address/logic/commands/ExitCommand.java b/src/main/java/seedu/address/logic/commands/ExitCommand.java index 3dd85a8ba90..3fb8bc556ff 100644 --- a/src/main/java/seedu/address/logic/commands/ExitCommand.java +++ b/src/main/java/seedu/address/logic/commands/ExitCommand.java @@ -1,19 +1,19 @@ -package seedu.address.logic.commands; - -import seedu.address.model.Model; - -/** - * Terminates the program. - */ -public class ExitCommand extends Command { - - public static final String COMMAND_WORD = "exit"; - - public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting Address Book as requested ..."; - - @Override - public CommandResult execute(Model model) { - return new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true); - } - -} +package seedu.address.logic.commands; + +import seedu.address.model.Model; + +/** + * Terminates the program. + */ +public class ExitCommand extends Command { + + public static final String COMMAND_WORD = "exit"; + + public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting Address Book as requested ..."; + + @Override + public CommandResult execute(Model model) { + return new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true); + } + +} diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index d6b19b0a0de..632e8797f91 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -1,42 +1,42 @@ -package seedu.address.logic.commands; - -import static java.util.Objects.requireNonNull; - -import seedu.address.commons.core.Messages; -import seedu.address.model.Model; -import seedu.address.model.person.NameContainsKeywordsPredicate; - -/** - * Finds and lists all persons in address book whose name contains any of the argument keywords. - * Keyword matching is case insensitive. - */ -public class FindCommand extends Command { - - public static final String COMMAND_WORD = "find"; - - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of " - + "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 final NameContainsKeywordsPredicate predicate; - - public FindCommand(NameContainsKeywordsPredicate predicate) { - this.predicate = predicate; - } - - @Override - public CommandResult execute(Model model) { - requireNonNull(model); - model.updateFilteredPersonList(predicate); - return new CommandResult( - String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredPersonList().size())); - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof FindCommand // instanceof handles nulls - && predicate.equals(((FindCommand) other).predicate)); // state check - } -} +package seedu.address.logic.commands; + +import static java.util.Objects.requireNonNull; + +import seedu.address.commons.core.Messages; +import seedu.address.model.Model; +import seedu.address.model.person.NameContainsKeywordsPredicate; + +/** + * Finds and lists all persons in address book whose name contains any of the argument keywords. + * Keyword matching is case insensitive. + */ +public class FindCommand extends Command { + + public static final String COMMAND_WORD = "find"; + + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of " + + "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 final NameContainsKeywordsPredicate predicate; + + public FindCommand(NameContainsKeywordsPredicate predicate) { + this.predicate = predicate; + } + + @Override + public CommandResult execute(Model model) { + requireNonNull(model); + model.updateFilteredPersonList(predicate); + return new CommandResult( + String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredPersonList().size())); + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof FindCommand // instanceof handles nulls + && predicate.equals(((FindCommand) other).predicate)); // state check + } +} diff --git a/src/main/java/seedu/address/logic/commands/HelpCommand.java b/src/main/java/seedu/address/logic/commands/HelpCommand.java index bf824f91bd0..5ba45ed9946 100644 --- a/src/main/java/seedu/address/logic/commands/HelpCommand.java +++ b/src/main/java/seedu/address/logic/commands/HelpCommand.java @@ -1,21 +1,21 @@ -package seedu.address.logic.commands; - -import seedu.address.model.Model; - -/** - * Format full help instructions for every command for display. - */ -public class HelpCommand extends Command { - - public static final String COMMAND_WORD = "help"; - - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Shows program usage instructions.\n" - + "Example: " + COMMAND_WORD; - - public static final String SHOWING_HELP_MESSAGE = "Opened help window."; - - @Override - public CommandResult execute(Model model) { - return new CommandResult(SHOWING_HELP_MESSAGE, true, false); - } -} +package seedu.address.logic.commands; + +import seedu.address.model.Model; + +/** + * Format full help instructions for every command for display. + */ +public class HelpCommand extends Command { + + public static final String COMMAND_WORD = "help"; + + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Shows program usage instructions.\n" + + "Example: " + COMMAND_WORD; + + public static final String SHOWING_HELP_MESSAGE = "Opened help window."; + + @Override + public CommandResult execute(Model model) { + return new CommandResult(SHOWING_HELP_MESSAGE, true, false); + } +} diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index 84be6ad2596..ac52f904caa 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -1,24 +1,24 @@ -package seedu.address.logic.commands; - -import static java.util.Objects.requireNonNull; -import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; - -import seedu.address.model.Model; - -/** - * Lists all persons in the address book to the user. - */ -public class ListCommand extends Command { - - public static final String COMMAND_WORD = "list"; - - public static final String MESSAGE_SUCCESS = "Listed all persons"; - - - @Override - public CommandResult execute(Model model) { - requireNonNull(model); - model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); - return new CommandResult(MESSAGE_SUCCESS); - } -} +package seedu.address.logic.commands; + +import static java.util.Objects.requireNonNull; +import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; + +import seedu.address.model.Model; + +/** + * Lists all persons in the address book to the user. + */ +public class ListCommand extends Command { + + public static final String COMMAND_WORD = "list"; + + public static final String MESSAGE_SUCCESS = "Listed all persons"; + + + @Override + public CommandResult execute(Model model) { + requireNonNull(model); + model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); + return new CommandResult(MESSAGE_SUCCESS); + } +} diff --git a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java b/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java index a16bd14f2cd..fcf52f1c7a5 100644 --- a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java +++ b/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java @@ -1,17 +1,17 @@ -package seedu.address.logic.commands.exceptions; - -/** - * Represents an error which occurs during execution of a {@link Command}. - */ -public class CommandException extends Exception { - public CommandException(String message) { - super(message); - } - - /** - * Constructs a new {@code CommandException} with the specified detail {@code message} and {@code cause}. - */ - public CommandException(String message, Throwable cause) { - super(message, cause); - } -} +package seedu.address.logic.commands.exceptions; + +/** + * Represents an error which occurs during execution of a {@link Command}. + */ +public class CommandException extends Exception { + public CommandException(String message) { + super(message); + } + + /** + * Constructs a new {@code CommandException} with the specified detail {@code message} and {@code cause}. + */ + public CommandException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 3b8bfa035e8..2c77f4a280e 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -1,60 +1,57 @@ -package seedu.address.logic.parser; - -import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; -import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; - -import java.util.Set; -import java.util.stream.Stream; - -import seedu.address.logic.commands.AddCommand; -import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; -import seedu.address.model.tag.Tag; - -/** - * Parses input arguments and creates a new AddCommand object - */ -public class AddCommandParser implements Parser { - - /** - * Parses the given {@code String} of arguments in the context of the AddCommand - * and returns an AddCommand object for execution. - * @throws ParseException if the user input does not conform the expected format - */ - public AddCommand parse(String args) throws ParseException { - ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG); - - if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL) - || !argMultimap.getPreamble().isEmpty()) { - throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); - } - - Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); - Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()); - Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()); - Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()); - Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); - - Person person = new Person(name, phone, email, address, tagList); - - return new AddCommand(person); - } - - /** - * Returns true if none of the prefixes contains empty {@code Optional} values in the given - * {@code ArgumentMultimap}. - */ - private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) { - return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent()); - } - -} +package seedu.address.logic.parser; + +import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; +import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; +import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; +import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; + +import java.util.Set; +import java.util.stream.Stream; + +import seedu.address.logic.commands.AddCommand; +import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.person.Email; +import seedu.address.model.person.Name; +import seedu.address.model.person.Person; +import seedu.address.model.person.Phone; +import seedu.address.model.tag.Tag; + +/** + * Parses input arguments and creates a new AddCommand object + */ +public class AddCommandParser implements Parser { + + /** + * Parses the given {@code String} of arguments in the context of the AddCommand + * and returns an AddCommand object for execution. + * @throws ParseException if the user input does not conform the expected format + */ + public AddCommand parse(String args) throws ParseException { + ArgumentMultimap argMultimap = + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_TAG); + + if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL) + || !argMultimap.getPreamble().isEmpty()) { + throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); + } + + Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); + Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()); + Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()); + Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); + + Person person = new Person(name, phone, email, tagList); + + return new AddCommand(person); + } + + /** + * Returns true if none of the prefixes contains empty {@code Optional} values in the given + * {@code ArgumentMultimap}. + */ + private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) { + return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent()); + } + +} diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 1e466792b46..cee318df905 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -1,76 +1,76 @@ -package seedu.address.logic.parser; - -import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.commons.core.Messages.MESSAGE_UNKNOWN_COMMAND; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import seedu.address.logic.commands.AddCommand; -import seedu.address.logic.commands.ClearCommand; -import seedu.address.logic.commands.Command; -import seedu.address.logic.commands.DeleteCommand; -import seedu.address.logic.commands.EditCommand; -import seedu.address.logic.commands.ExitCommand; -import seedu.address.logic.commands.FindCommand; -import seedu.address.logic.commands.HelpCommand; -import seedu.address.logic.commands.ListCommand; -import seedu.address.logic.parser.exceptions.ParseException; - -/** - * Parses user input. - */ -public class AddressBookParser { - - /** - * Used for initial separation of command word and args. - */ - private static final Pattern BASIC_COMMAND_FORMAT = Pattern.compile("(?\\S+)(?.*)"); - - /** - * Parses user input into command for execution. - * - * @param userInput full user input string - * @return the command based on the user input - * @throws ParseException if the user input does not conform the expected format - */ - public Command parseCommand(String userInput) throws ParseException { - final Matcher matcher = BASIC_COMMAND_FORMAT.matcher(userInput.trim()); - if (!matcher.matches()) { - throw new ParseException(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 new AddCommandParser().parse(arguments); - - case EditCommand.COMMAND_WORD: - return new EditCommandParser().parse(arguments); - - case DeleteCommand.COMMAND_WORD: - return new DeleteCommandParser().parse(arguments); - - case ClearCommand.COMMAND_WORD: - return new ClearCommand(); - - case FindCommand.COMMAND_WORD: - return new FindCommandParser().parse(arguments); - - case ListCommand.COMMAND_WORD: - return new ListCommand(); - - case ExitCommand.COMMAND_WORD: - return new ExitCommand(); - - case HelpCommand.COMMAND_WORD: - return new HelpCommand(); - - default: - throw new ParseException(MESSAGE_UNKNOWN_COMMAND); - } - } - -} +package seedu.address.logic.parser; + +import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import static seedu.address.commons.core.Messages.MESSAGE_UNKNOWN_COMMAND; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import seedu.address.logic.commands.AddCommand; +import seedu.address.logic.commands.ClearCommand; +import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.DeleteCommand; +import seedu.address.logic.commands.EditCommand; +import seedu.address.logic.commands.ExitCommand; +import seedu.address.logic.commands.FindCommand; +import seedu.address.logic.commands.HelpCommand; +import seedu.address.logic.commands.ListCommand; +import seedu.address.logic.parser.exceptions.ParseException; + +/** + * Parses user input. + */ +public class AddressBookParser { + + /** + * Used for initial separation of command word and args. + */ + private static final Pattern BASIC_COMMAND_FORMAT = Pattern.compile("(?\\S+)(?.*)"); + + /** + * Parses user input into command for execution. + * + * @param userInput full user input string + * @return the command based on the user input + * @throws ParseException if the user input does not conform the expected format + */ + public Command parseCommand(String userInput) throws ParseException { + final Matcher matcher = BASIC_COMMAND_FORMAT.matcher(userInput.trim()); + if (!matcher.matches()) { + throw new ParseException(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 new AddCommandParser().parse(arguments); + + case EditCommand.COMMAND_WORD: + return new EditCommandParser().parse(arguments); + + case DeleteCommand.COMMAND_WORD: + return new DeleteCommandParser().parse(arguments); + + case ClearCommand.COMMAND_WORD: + return new ClearCommand(); + + case FindCommand.COMMAND_WORD: + return new FindCommandParser().parse(arguments); + + case ListCommand.COMMAND_WORD: + return new ListCommand(); + + case ExitCommand.COMMAND_WORD: + return new ExitCommand(); + + case HelpCommand.COMMAND_WORD: + return new HelpCommand(); + + default: + throw new ParseException(MESSAGE_UNKNOWN_COMMAND); + } + } + +} diff --git a/src/main/java/seedu/address/logic/parser/ArgumentMultimap.java b/src/main/java/seedu/address/logic/parser/ArgumentMultimap.java index 954c8e18f8e..74455b9d84a 100644 --- a/src/main/java/seedu/address/logic/parser/ArgumentMultimap.java +++ b/src/main/java/seedu/address/logic/parser/ArgumentMultimap.java @@ -1,60 +1,60 @@ -package seedu.address.logic.parser; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * Stores mapping of prefixes to their respective arguments. - * Each key may be associated with multiple argument values. - * Values for a given key are stored in a list, and the insertion ordering is maintained. - * Keys are unique, but the list of argument values may contain duplicate argument values, i.e. the same argument value - * can be inserted multiple times for the same prefix. - */ -public class ArgumentMultimap { - - /** Prefixes mapped to their respective arguments**/ - private final Map> argMultimap = new HashMap<>(); - - /** - * Associates the specified argument value with {@code prefix} key in this map. - * If the map previously contained a mapping for the key, the new value is appended to the list of existing values. - * - * @param prefix Prefix key with which the specified argument value is to be associated - * @param argValue Argument value to be associated with the specified prefix key - */ - public void put(Prefix prefix, String argValue) { - List argValues = getAllValues(prefix); - argValues.add(argValue); - argMultimap.put(prefix, argValues); - } - - /** - * Returns the last value of {@code prefix}. - */ - public Optional getValue(Prefix prefix) { - List values = getAllValues(prefix); - return values.isEmpty() ? Optional.empty() : Optional.of(values.get(values.size() - 1)); - } - - /** - * Returns all values of {@code prefix}. - * If the prefix does not exist or has no values, this will return an empty list. - * Modifying the returned list will not affect the underlying data structure of the ArgumentMultimap. - */ - public List getAllValues(Prefix prefix) { - if (!argMultimap.containsKey(prefix)) { - return new ArrayList<>(); - } - return new ArrayList<>(argMultimap.get(prefix)); - } - - /** - * Returns the preamble (text before the first valid prefix). Trims any leading/trailing spaces. - */ - public String getPreamble() { - return getValue(new Prefix("")).orElse(""); - } -} +package seedu.address.logic.parser; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * Stores mapping of prefixes to their respective arguments. + * Each key may be associated with multiple argument values. + * Values for a given key are stored in a list, and the insertion ordering is maintained. + * Keys are unique, but the list of argument values may contain duplicate argument values, i.e. the same argument value + * can be inserted multiple times for the same prefix. + */ +public class ArgumentMultimap { + + /** Prefixes mapped to their respective arguments**/ + private final Map> argMultimap = new HashMap<>(); + + /** + * Associates the specified argument value with {@code prefix} key in this map. + * If the map previously contained a mapping for the key, the new value is appended to the list of existing values. + * + * @param prefix Prefix key with which the specified argument value is to be associated + * @param argValue Argument value to be associated with the specified prefix key + */ + public void put(Prefix prefix, String argValue) { + List argValues = getAllValues(prefix); + argValues.add(argValue); + argMultimap.put(prefix, argValues); + } + + /** + * Returns the last value of {@code prefix}. + */ + public Optional getValue(Prefix prefix) { + List values = getAllValues(prefix); + return values.isEmpty() ? Optional.empty() : Optional.of(values.get(values.size() - 1)); + } + + /** + * Returns all values of {@code prefix}. + * If the prefix does not exist or has no values, this will return an empty list. + * Modifying the returned list will not affect the underlying data structure of the ArgumentMultimap. + */ + public List getAllValues(Prefix prefix) { + if (!argMultimap.containsKey(prefix)) { + return new ArrayList<>(); + } + return new ArrayList<>(argMultimap.get(prefix)); + } + + /** + * Returns the preamble (text before the first valid prefix). Trims any leading/trailing spaces. + */ + public String getPreamble() { + return getValue(new Prefix("")).orElse(""); + } +} diff --git a/src/main/java/seedu/address/logic/parser/ArgumentTokenizer.java b/src/main/java/seedu/address/logic/parser/ArgumentTokenizer.java index 5c9aebfa488..783d6506621 100644 --- a/src/main/java/seedu/address/logic/parser/ArgumentTokenizer.java +++ b/src/main/java/seedu/address/logic/parser/ArgumentTokenizer.java @@ -1,148 +1,148 @@ -package seedu.address.logic.parser; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Tokenizes arguments string of the form: {@code preamble value value ...}
- * e.g. {@code some preamble text t/ 11.00 t/12.00 k/ m/ July} where prefixes are {@code t/ k/ m/}.
- * 1. An argument's value can be an empty string e.g. the value of {@code k/} in the above example.
- * 2. Leading and trailing whitespaces of an argument value will be discarded.
- * 3. An argument may be repeated and all its values will be accumulated e.g. the value of {@code t/} - * in the above example.
- */ -public class ArgumentTokenizer { - - /** - * Tokenizes an arguments string and returns an {@code ArgumentMultimap} object that maps prefixes to their - * respective argument values. Only the given prefixes will be recognized in the arguments string. - * - * @param argsString Arguments string of the form: {@code preamble value value ...} - * @param prefixes Prefixes to tokenize the arguments string with - * @return ArgumentMultimap object that maps prefixes to their arguments - */ - public static ArgumentMultimap tokenize(String argsString, Prefix... prefixes) { - List positions = findAllPrefixPositions(argsString, prefixes); - return extractArguments(argsString, positions); - } - - /** - * Finds all zero-based prefix positions in the given arguments string. - * - * @param argsString Arguments string of the form: {@code preamble value value ...} - * @param prefixes Prefixes to find in the arguments string - * @return List of zero-based prefix positions in the given arguments string - */ - private static List findAllPrefixPositions(String argsString, Prefix... prefixes) { - return Arrays.stream(prefixes) - .flatMap(prefix -> findPrefixPositions(argsString, prefix).stream()) - .collect(Collectors.toList()); - } - - /** - * {@see findAllPrefixPositions} - */ - private static List findPrefixPositions(String argsString, Prefix prefix) { - List positions = new ArrayList<>(); - - int prefixPosition = findPrefixPosition(argsString, prefix.getPrefix(), 0); - while (prefixPosition != -1) { - PrefixPosition extendedPrefix = new PrefixPosition(prefix, prefixPosition); - positions.add(extendedPrefix); - prefixPosition = findPrefixPosition(argsString, prefix.getPrefix(), prefixPosition); - } - - return positions; - } - - /** - * Returns the index of the first occurrence of {@code prefix} in - * {@code argsString} starting from index {@code fromIndex}. An occurrence - * is valid if there is a whitespace before {@code prefix}. Returns -1 if no - * such occurrence can be found. - * - * E.g if {@code argsString} = "e/hip/900", {@code prefix} = "p/" and - * {@code fromIndex} = 0, this method returns -1 as there are no valid - * occurrences of "p/" with whitespace before it. However, if - * {@code argsString} = "e/hi p/900", {@code prefix} = "p/" and - * {@code fromIndex} = 0, this method returns 5. - */ - private static int findPrefixPosition(String argsString, String prefix, int fromIndex) { - int prefixIndex = argsString.indexOf(" " + prefix, fromIndex); - return prefixIndex == -1 ? -1 - : prefixIndex + 1; // +1 as offset for whitespace - } - - /** - * Extracts prefixes and their argument values, and returns an {@code ArgumentMultimap} object that maps the - * extracted prefixes to their respective arguments. Prefixes are extracted based on their zero-based positions in - * {@code argsString}. - * - * @param argsString Arguments string of the form: {@code preamble value value ...} - * @param prefixPositions Zero-based positions of all prefixes in {@code argsString} - * @return ArgumentMultimap object that maps prefixes to their arguments - */ - private static ArgumentMultimap extractArguments(String argsString, List prefixPositions) { - - // Sort by start position - prefixPositions.sort((prefix1, prefix2) -> prefix1.getStartPosition() - prefix2.getStartPosition()); - - // Insert a PrefixPosition to represent the preamble - PrefixPosition preambleMarker = new PrefixPosition(new Prefix(""), 0); - prefixPositions.add(0, preambleMarker); - - // Add a dummy PrefixPosition to represent the end of the string - PrefixPosition endPositionMarker = new PrefixPosition(new Prefix(""), argsString.length()); - prefixPositions.add(endPositionMarker); - - // Map prefixes to their argument values (if any) - ArgumentMultimap argMultimap = new ArgumentMultimap(); - for (int i = 0; i < prefixPositions.size() - 1; i++) { - // Extract and store prefixes and their arguments - Prefix argPrefix = prefixPositions.get(i).getPrefix(); - String argValue = extractArgumentValue(argsString, prefixPositions.get(i), prefixPositions.get(i + 1)); - argMultimap.put(argPrefix, argValue); - } - - return argMultimap; - } - - /** - * Returns the trimmed value of the argument in the arguments string specified by {@code currentPrefixPosition}. - * The end position of the value is determined by {@code nextPrefixPosition}. - */ - private static String extractArgumentValue(String argsString, - PrefixPosition currentPrefixPosition, - PrefixPosition nextPrefixPosition) { - Prefix prefix = currentPrefixPosition.getPrefix(); - - int valueStartPos = currentPrefixPosition.getStartPosition() + prefix.getPrefix().length(); - String value = argsString.substring(valueStartPos, nextPrefixPosition.getStartPosition()); - - return value.trim(); - } - - /** - * Represents a prefix's position in an arguments string. - */ - private static class PrefixPosition { - private int startPosition; - private final Prefix prefix; - - PrefixPosition(Prefix prefix, int startPosition) { - this.prefix = prefix; - this.startPosition = startPosition; - } - - int getStartPosition() { - return startPosition; - } - - Prefix getPrefix() { - return prefix; - } - } - -} +package seedu.address.logic.parser; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Tokenizes arguments string of the form: {@code preamble value value ...}
+ * e.g. {@code some preamble text t/ 11.00 t/12.00 k/ m/ July} where prefixes are {@code t/ k/ m/}.
+ * 1. An argument's value can be an empty string e.g. the value of {@code k/} in the above example.
+ * 2. Leading and trailing whitespaces of an argument value will be discarded.
+ * 3. An argument may be repeated and all its values will be accumulated e.g. the value of {@code t/} + * in the above example.
+ */ +public class ArgumentTokenizer { + + /** + * Tokenizes an arguments string and returns an {@code ArgumentMultimap} object that maps prefixes to their + * respective argument values. Only the given prefixes will be recognized in the arguments string. + * + * @param argsString Arguments string of the form: {@code preamble value value ...} + * @param prefixes Prefixes to tokenize the arguments string with + * @return ArgumentMultimap object that maps prefixes to their arguments + */ + public static ArgumentMultimap tokenize(String argsString, Prefix... prefixes) { + List positions = findAllPrefixPositions(argsString, prefixes); + return extractArguments(argsString, positions); + } + + /** + * Finds all zero-based prefix positions in the given arguments string. + * + * @param argsString Arguments string of the form: {@code preamble value value ...} + * @param prefixes Prefixes to find in the arguments string + * @return List of zero-based prefix positions in the given arguments string + */ + private static List findAllPrefixPositions(String argsString, Prefix... prefixes) { + return Arrays.stream(prefixes) + .flatMap(prefix -> findPrefixPositions(argsString, prefix).stream()) + .collect(Collectors.toList()); + } + + /** + * {@see findAllPrefixPositions} + */ + private static List findPrefixPositions(String argsString, Prefix prefix) { + List positions = new ArrayList<>(); + + int prefixPosition = findPrefixPosition(argsString, prefix.getPrefix(), 0); + while (prefixPosition != -1) { + PrefixPosition extendedPrefix = new PrefixPosition(prefix, prefixPosition); + positions.add(extendedPrefix); + prefixPosition = findPrefixPosition(argsString, prefix.getPrefix(), prefixPosition); + } + + return positions; + } + + /** + * Returns the index of the first occurrence of {@code prefix} in + * {@code argsString} starting from index {@code fromIndex}. An occurrence + * is valid if there is a whitespace before {@code prefix}. Returns -1 if no + * such occurrence can be found. + * + * E.g if {@code argsString} = "e/hip/900", {@code prefix} = "p/" and + * {@code fromIndex} = 0, this method returns -1 as there are no valid + * occurrences of "p/" with whitespace before it. However, if + * {@code argsString} = "e/hi p/900", {@code prefix} = "p/" and + * {@code fromIndex} = 0, this method returns 5. + */ + private static int findPrefixPosition(String argsString, String prefix, int fromIndex) { + int prefixIndex = argsString.indexOf(" " + prefix, fromIndex); + return prefixIndex == -1 ? -1 + : prefixIndex + 1; // +1 as offset for whitespace + } + + /** + * Extracts prefixes and their argument values, and returns an {@code ArgumentMultimap} object that maps the + * extracted prefixes to their respective arguments. Prefixes are extracted based on their zero-based positions in + * {@code argsString}. + * + * @param argsString Arguments string of the form: {@code preamble value value ...} + * @param prefixPositions Zero-based positions of all prefixes in {@code argsString} + * @return ArgumentMultimap object that maps prefixes to their arguments + */ + private static ArgumentMultimap extractArguments(String argsString, List prefixPositions) { + + // Sort by start position + prefixPositions.sort((prefix1, prefix2) -> prefix1.getStartPosition() - prefix2.getStartPosition()); + + // Insert a PrefixPosition to represent the preamble + PrefixPosition preambleMarker = new PrefixPosition(new Prefix(""), 0); + prefixPositions.add(0, preambleMarker); + + // Add a dummy PrefixPosition to represent the end of the string + PrefixPosition endPositionMarker = new PrefixPosition(new Prefix(""), argsString.length()); + prefixPositions.add(endPositionMarker); + + // Map prefixes to their argument values (if any) + ArgumentMultimap argMultimap = new ArgumentMultimap(); + for (int i = 0; i < prefixPositions.size() - 1; i++) { + // Extract and store prefixes and their arguments + Prefix argPrefix = prefixPositions.get(i).getPrefix(); + String argValue = extractArgumentValue(argsString, prefixPositions.get(i), prefixPositions.get(i + 1)); + argMultimap.put(argPrefix, argValue); + } + + return argMultimap; + } + + /** + * Returns the trimmed value of the argument in the arguments string specified by {@code currentPrefixPosition}. + * The end position of the value is determined by {@code nextPrefixPosition}. + */ + private static String extractArgumentValue(String argsString, + PrefixPosition currentPrefixPosition, + PrefixPosition nextPrefixPosition) { + Prefix prefix = currentPrefixPosition.getPrefix(); + + int valueStartPos = currentPrefixPosition.getStartPosition() + prefix.getPrefix().length(); + String value = argsString.substring(valueStartPos, nextPrefixPosition.getStartPosition()); + + return value.trim(); + } + + /** + * Represents a prefix's position in an arguments string. + */ + private static class PrefixPosition { + private int startPosition; + private final Prefix prefix; + + PrefixPosition(Prefix prefix, int startPosition) { + this.prefix = prefix; + this.startPosition = startPosition; + } + + int getStartPosition() { + return startPosition; + } + + Prefix getPrefix() { + return prefix; + } + } + +} diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 75b1a9bf119..2ad5229b2fe 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -1,15 +1,15 @@ -package seedu.address.logic.parser; - -/** - * Contains Command Line Interface (CLI) syntax definitions common to multiple commands - */ -public class CliSyntax { - - /* Prefix definitions */ - public static final Prefix PREFIX_NAME = new Prefix("n/"); - public static final Prefix PREFIX_PHONE = new Prefix("p/"); - public static final Prefix PREFIX_EMAIL = new Prefix("e/"); - public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); - public static final Prefix PREFIX_TAG = new Prefix("t/"); - -} +package seedu.address.logic.parser; + +/** + * Contains Command Line Interface (CLI) syntax definitions common to multiple commands + */ +public class CliSyntax { + + /* Prefix definitions */ + public static final Prefix PREFIX_NAME = new Prefix("n/"); + public static final Prefix PREFIX_PHONE = new Prefix("p/"); + public static final Prefix PREFIX_EMAIL = new Prefix("e/"); + public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); + public static final Prefix PREFIX_TAG = new Prefix("t/"); + +} diff --git a/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java b/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java index 522b93081cc..cbae175db1e 100644 --- a/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java @@ -1,29 +1,29 @@ -package seedu.address.logic.parser; - -import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; - -import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.DeleteCommand; -import seedu.address.logic.parser.exceptions.ParseException; - -/** - * Parses input arguments and creates a new DeleteCommand object - */ -public class DeleteCommandParser implements Parser { - - /** - * Parses the given {@code String} of arguments in the context of the DeleteCommand - * and returns a DeleteCommand object for execution. - * @throws ParseException if the user input does not conform the expected format - */ - public DeleteCommand parse(String args) throws ParseException { - try { - Index index = ParserUtil.parseIndex(args); - return new DeleteCommand(index); - } catch (ParseException pe) { - throw new ParseException( - String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE), pe); - } - } - -} +package seedu.address.logic.parser; + +import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; + +import seedu.address.commons.core.index.Index; +import seedu.address.logic.commands.DeleteCommand; +import seedu.address.logic.parser.exceptions.ParseException; + +/** + * Parses input arguments and creates a new DeleteCommand object + */ +public class DeleteCommandParser implements Parser { + + /** + * Parses the given {@code String} of arguments in the context of the DeleteCommand + * and returns a DeleteCommand object for execution. + * @throws ParseException if the user input does not conform the expected format + */ + public DeleteCommand parse(String args) throws ParseException { + try { + Index index = ParserUtil.parseIndex(args); + return new DeleteCommand(index); + } catch (ParseException pe) { + throw new ParseException( + String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE), pe); + } + } + +} diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index 845644b7dea..f339a87f6a6 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -1,82 +1,78 @@ -package seedu.address.logic.parser; - -import static java.util.Objects.requireNonNull; -import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; -import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; - -import java.util.Collection; -import java.util.Collections; -import java.util.Optional; -import java.util.Set; - -import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.EditCommand; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.tag.Tag; - -/** - * Parses input arguments and creates a new EditCommand object - */ -public class EditCommandParser implements Parser { - - /** - * Parses the given {@code String} of arguments in the context of the EditCommand - * and returns an EditCommand object for execution. - * @throws ParseException if the user input does not conform the expected format - */ - public EditCommand parse(String args) throws ParseException { - requireNonNull(args); - ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG); - - Index index; - - try { - index = ParserUtil.parseIndex(argMultimap.getPreamble()); - } catch (ParseException pe) { - throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE), pe); - } - - EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); - if (argMultimap.getValue(PREFIX_NAME).isPresent()) { - editPersonDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get())); - } - if (argMultimap.getValue(PREFIX_PHONE).isPresent()) { - editPersonDescriptor.setPhone(ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get())); - } - if (argMultimap.getValue(PREFIX_EMAIL).isPresent()) { - editPersonDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get())); - } - if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) { - editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get())); - } - parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags); - - if (!editPersonDescriptor.isAnyFieldEdited()) { - throw new ParseException(EditCommand.MESSAGE_NOT_EDITED); - } - - return new EditCommand(index, editPersonDescriptor); - } - - /** - * Parses {@code Collection tags} into a {@code Set} if {@code tags} is non-empty. - * If {@code tags} contain only one element which is an empty string, it will be parsed into a - * {@code Set} containing zero tags. - */ - private Optional> parseTagsForEdit(Collection tags) throws ParseException { - assert tags != null; - - if (tags.isEmpty()) { - return Optional.empty(); - } - Collection tagSet = tags.size() == 1 && tags.contains("") ? Collections.emptySet() : tags; - return Optional.of(ParserUtil.parseTags(tagSet)); - } - -} +package seedu.address.logic.parser; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; +import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; +import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; +import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; + +import java.util.Collection; +import java.util.Collections; +import java.util.Optional; +import java.util.Set; + +import seedu.address.commons.core.index.Index; +import seedu.address.logic.commands.EditCommand; +import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; +import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.tag.Tag; + +/** + * Parses input arguments and creates a new EditCommand object + */ +public class EditCommandParser implements Parser { + + /** + * Parses the given {@code String} of arguments in the context of the EditCommand + * and returns an EditCommand object for execution. + * @throws ParseException if the user input does not conform the expected format + */ + public EditCommand parse(String args) throws ParseException { + requireNonNull(args); + ArgumentMultimap argMultimap = + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_TAG); + + Index index; + + try { + index = ParserUtil.parseIndex(argMultimap.getPreamble()); + } catch (ParseException pe) { + throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE), pe); + } + + EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); + if (argMultimap.getValue(PREFIX_NAME).isPresent()) { + editPersonDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get())); + } + if (argMultimap.getValue(PREFIX_PHONE).isPresent()) { + editPersonDescriptor.setPhone(ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get())); + } + if (argMultimap.getValue(PREFIX_EMAIL).isPresent()) { + editPersonDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get())); + } + parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags); + + if (!editPersonDescriptor.isAnyFieldEdited()) { + throw new ParseException(EditCommand.MESSAGE_NOT_EDITED); + } + + return new EditCommand(index, editPersonDescriptor); + } + + /** + * Parses {@code Collection tags} into a {@code Set} if {@code tags} is non-empty. + * If {@code tags} contain only one element which is an empty string, it will be parsed into a + * {@code Set} containing zero tags. + */ + private Optional> parseTagsForEdit(Collection tags) throws ParseException { + assert tags != null; + + if (tags.isEmpty()) { + return Optional.empty(); + } + Collection tagSet = tags.size() == 1 && tags.contains("") ? Collections.emptySet() : tags; + return Optional.of(ParserUtil.parseTags(tagSet)); + } + +} diff --git a/src/main/java/seedu/address/logic/parser/FindCommandParser.java b/src/main/java/seedu/address/logic/parser/FindCommandParser.java index 4fb71f23103..8356458131b 100644 --- a/src/main/java/seedu/address/logic/parser/FindCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/FindCommandParser.java @@ -1,33 +1,33 @@ -package seedu.address.logic.parser; - -import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; - -import java.util.Arrays; - -import seedu.address.logic.commands.FindCommand; -import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.NameContainsKeywordsPredicate; - -/** - * Parses input arguments and creates a new FindCommand object - */ -public class FindCommandParser implements Parser { - - /** - * Parses the given {@code String} of arguments in the context of the FindCommand - * and returns a FindCommand object for execution. - * @throws ParseException if the user input does not conform the expected format - */ - public FindCommand parse(String args) throws ParseException { - String trimmedArgs = args.trim(); - if (trimmedArgs.isEmpty()) { - throw new ParseException( - String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE)); - } - - String[] nameKeywords = trimmedArgs.split("\\s+"); - - return new FindCommand(new NameContainsKeywordsPredicate(Arrays.asList(nameKeywords))); - } - -} +package seedu.address.logic.parser; + +import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; + +import java.util.Arrays; + +import seedu.address.logic.commands.FindCommand; +import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.person.NameContainsKeywordsPredicate; + +/** + * Parses input arguments and creates a new FindCommand object + */ +public class FindCommandParser implements Parser { + + /** + * Parses the given {@code String} of arguments in the context of the FindCommand + * and returns a FindCommand object for execution. + * @throws ParseException if the user input does not conform the expected format + */ + public FindCommand parse(String args) throws ParseException { + String trimmedArgs = args.trim(); + if (trimmedArgs.isEmpty()) { + throw new ParseException( + String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE)); + } + + String[] nameKeywords = trimmedArgs.split("\\s+"); + + return new FindCommand(new NameContainsKeywordsPredicate(Arrays.asList(nameKeywords))); + } + +} diff --git a/src/main/java/seedu/address/logic/parser/Parser.java b/src/main/java/seedu/address/logic/parser/Parser.java index d6551ad8e3f..4ec1a486645 100644 --- a/src/main/java/seedu/address/logic/parser/Parser.java +++ b/src/main/java/seedu/address/logic/parser/Parser.java @@ -1,16 +1,16 @@ -package seedu.address.logic.parser; - -import seedu.address.logic.commands.Command; -import seedu.address.logic.parser.exceptions.ParseException; - -/** - * Represents a Parser that is able to parse user input into a {@code Command} of type {@code T}. - */ -public interface Parser { - - /** - * Parses {@code userInput} into a command and returns it. - * @throws ParseException if {@code userInput} does not conform the expected format - */ - T parse(String userInput) throws ParseException; -} +package seedu.address.logic.parser; + +import seedu.address.logic.commands.Command; +import seedu.address.logic.parser.exceptions.ParseException; + +/** + * Represents a Parser that is able to parse user input into a {@code Command} of type {@code T}. + */ +public interface Parser { + + /** + * Parses {@code userInput} into a command and returns it. + * @throws ParseException if {@code userInput} does not conform the expected format + */ + T parse(String userInput) throws ParseException; +} diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index b117acb9c55..23173fe790f 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -1,124 +1,108 @@ -package seedu.address.logic.parser; - -import static java.util.Objects.requireNonNull; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import seedu.address.commons.core.index.Index; -import seedu.address.commons.util.StringUtil; -import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Phone; -import seedu.address.model.tag.Tag; - -/** - * Contains utility methods used for parsing strings in the various *Parser classes. - */ -public class ParserUtil { - - public static final String MESSAGE_INVALID_INDEX = "Index is not a non-zero unsigned integer."; - - /** - * Parses {@code oneBasedIndex} into an {@code Index} and returns it. Leading and trailing whitespaces will be - * trimmed. - * @throws ParseException if the specified index is invalid (not non-zero unsigned integer). - */ - public static Index parseIndex(String oneBasedIndex) throws ParseException { - String trimmedIndex = oneBasedIndex.trim(); - if (!StringUtil.isNonZeroUnsignedInteger(trimmedIndex)) { - throw new ParseException(MESSAGE_INVALID_INDEX); - } - return Index.fromOneBased(Integer.parseInt(trimmedIndex)); - } - - /** - * Parses a {@code String name} into a {@code Name}. - * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code name} is invalid. - */ - public static Name parseName(String name) throws ParseException { - requireNonNull(name); - String trimmedName = name.trim(); - if (!Name.isValidName(trimmedName)) { - throw new ParseException(Name.MESSAGE_CONSTRAINTS); - } - return new Name(trimmedName); - } - - /** - * Parses a {@code String phone} into a {@code Phone}. - * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code phone} is invalid. - */ - public static Phone parsePhone(String phone) throws ParseException { - requireNonNull(phone); - String trimmedPhone = phone.trim(); - if (!Phone.isValidPhone(trimmedPhone)) { - throw new ParseException(Phone.MESSAGE_CONSTRAINTS); - } - return new Phone(trimmedPhone); - } - - /** - * Parses a {@code String address} into an {@code Address}. - * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code address} is invalid. - */ - public static Address parseAddress(String address) throws ParseException { - requireNonNull(address); - String trimmedAddress = address.trim(); - if (!Address.isValidAddress(trimmedAddress)) { - throw new ParseException(Address.MESSAGE_CONSTRAINTS); - } - return new Address(trimmedAddress); - } - - /** - * Parses a {@code String email} into an {@code Email}. - * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code email} is invalid. - */ - public static Email parseEmail(String email) throws ParseException { - requireNonNull(email); - String trimmedEmail = email.trim(); - if (!Email.isValidEmail(trimmedEmail)) { - throw new ParseException(Email.MESSAGE_CONSTRAINTS); - } - return new Email(trimmedEmail); - } - - /** - * Parses a {@code String tag} into a {@code Tag}. - * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code tag} is invalid. - */ - public static Tag parseTag(String tag) throws ParseException { - requireNonNull(tag); - String trimmedTag = tag.trim(); - if (!Tag.isValidTagName(trimmedTag)) { - throw new ParseException(Tag.MESSAGE_CONSTRAINTS); - } - return new Tag(trimmedTag); - } - - /** - * Parses {@code Collection tags} into a {@code Set}. - */ - public static Set parseTags(Collection tags) throws ParseException { - requireNonNull(tags); - final Set tagSet = new HashSet<>(); - for (String tagName : tags) { - tagSet.add(parseTag(tagName)); - } - return tagSet; - } -} +package seedu.address.logic.parser; + +import static java.util.Objects.requireNonNull; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import seedu.address.commons.core.index.Index; +import seedu.address.commons.util.StringUtil; +import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.person.Email; +import seedu.address.model.person.Name; +import seedu.address.model.person.Phone; +import seedu.address.model.tag.Tag; + +/** + * Contains utility methods used for parsing strings in the various *Parser classes. + */ +public class ParserUtil { + + public static final String MESSAGE_INVALID_INDEX = "Index is not a non-zero unsigned integer."; + + /** + * Parses {@code oneBasedIndex} into an {@code Index} and returns it. Leading and trailing whitespaces will be + * trimmed. + * @throws ParseException if the specified index is invalid (not non-zero unsigned integer). + */ + public static Index parseIndex(String oneBasedIndex) throws ParseException { + String trimmedIndex = oneBasedIndex.trim(); + if (!StringUtil.isNonZeroUnsignedInteger(trimmedIndex)) { + throw new ParseException(MESSAGE_INVALID_INDEX); + } + return Index.fromOneBased(Integer.parseInt(trimmedIndex)); + } + + /** + * Parses a {@code String name} into a {@code Name}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws ParseException if the given {@code name} is invalid. + */ + public static Name parseName(String name) throws ParseException { + requireNonNull(name); + String trimmedName = name.trim(); + if (!Name.isValidName(trimmedName)) { + throw new ParseException(Name.MESSAGE_CONSTRAINTS); + } + return new Name(trimmedName); + } + + /** + * Parses a {@code String phone} into a {@code Phone}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws ParseException if the given {@code phone} is invalid. + */ + public static Phone parsePhone(String phone) throws ParseException { + requireNonNull(phone); + String trimmedPhone = phone.trim(); + if (!Phone.isValidPhone(trimmedPhone)) { + throw new ParseException(Phone.MESSAGE_CONSTRAINTS); + } + return new Phone(trimmedPhone); + } + + /** + * Parses a {@code String email} into an {@code Email}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws ParseException if the given {@code email} is invalid. + */ + public static Email parseEmail(String email) throws ParseException { + requireNonNull(email); + String trimmedEmail = email.trim(); + if (!Email.isValidEmail(trimmedEmail)) { + throw new ParseException(Email.MESSAGE_CONSTRAINTS); + } + return new Email(trimmedEmail); + } + + /** + * Parses a {@code String tag} into a {@code Tag}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws ParseException if the given {@code tag} is invalid. + */ + public static Tag parseTag(String tag) throws ParseException { + requireNonNull(tag); + String trimmedTag = tag.trim(); + if (!Tag.isValidTagName(trimmedTag)) { + throw new ParseException(Tag.MESSAGE_CONSTRAINTS); + } + return new Tag(trimmedTag); + } + + /** + * Parses {@code Collection tags} into a {@code Set}. + */ + public static Set parseTags(Collection tags) throws ParseException { + requireNonNull(tags); + final Set tagSet = new HashSet<>(); + for (String tagName : tags) { + tagSet.add(parseTag(tagName)); + } + return tagSet; + } +} diff --git a/src/main/java/seedu/address/logic/parser/Prefix.java b/src/main/java/seedu/address/logic/parser/Prefix.java index c859d5fa5db..21ed9b7610f 100644 --- a/src/main/java/seedu/address/logic/parser/Prefix.java +++ b/src/main/java/seedu/address/logic/parser/Prefix.java @@ -1,39 +1,39 @@ -package seedu.address.logic.parser; - -/** - * A prefix that marks the beginning of an argument in an arguments string. - * E.g. 't/' in 'add James t/ friend'. - */ -public class Prefix { - private final String prefix; - - public Prefix(String prefix) { - this.prefix = prefix; - } - - public String getPrefix() { - return prefix; - } - - public String toString() { - return getPrefix(); - } - - @Override - public int hashCode() { - return prefix == null ? 0 : prefix.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof Prefix)) { - return false; - } - if (obj == this) { - return true; - } - - Prefix otherPrefix = (Prefix) obj; - return otherPrefix.getPrefix().equals(getPrefix()); - } -} +package seedu.address.logic.parser; + +/** + * A prefix that marks the beginning of an argument in an arguments string. + * E.g. 't/' in 'add James t/ friend'. + */ +public class Prefix { + private final String prefix; + + public Prefix(String prefix) { + this.prefix = prefix; + } + + public String getPrefix() { + return prefix; + } + + public String toString() { + return getPrefix(); + } + + @Override + public int hashCode() { + return prefix == null ? 0 : prefix.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Prefix)) { + return false; + } + if (obj == this) { + return true; + } + + Prefix otherPrefix = (Prefix) obj; + return otherPrefix.getPrefix().equals(getPrefix()); + } +} diff --git a/src/main/java/seedu/address/logic/parser/exceptions/ParseException.java b/src/main/java/seedu/address/logic/parser/exceptions/ParseException.java index 158a1a54c1c..6e9fe6d196e 100644 --- a/src/main/java/seedu/address/logic/parser/exceptions/ParseException.java +++ b/src/main/java/seedu/address/logic/parser/exceptions/ParseException.java @@ -1,17 +1,17 @@ -package seedu.address.logic.parser.exceptions; - -import seedu.address.commons.exceptions.IllegalValueException; - -/** - * Represents a parse error encountered by a parser. - */ -public class ParseException extends IllegalValueException { - - public ParseException(String message) { - super(message); - } - - public ParseException(String message, Throwable cause) { - super(message, cause); - } -} +package seedu.address.logic.parser.exceptions; + +import seedu.address.commons.exceptions.IllegalValueException; + +/** + * Represents a parse error encountered by a parser. + */ +public class ParseException extends IllegalValueException { + + public ParseException(String message) { + super(message); + } + + public ParseException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index 1a943a0781a..7e46399e4d1 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -1,120 +1,120 @@ -package seedu.address.model; - -import static java.util.Objects.requireNonNull; - -import java.util.List; - -import javafx.collections.ObservableList; -import seedu.address.model.person.Person; -import seedu.address.model.person.UniquePersonList; - -/** - * Wraps all data at the address-book level - * Duplicates are not allowed (by .isSamePerson comparison) - */ -public class AddressBook implements ReadOnlyAddressBook { - - private final UniquePersonList persons; - - /* - * The 'unusual' code block below is a non-static initialization block, sometimes used to avoid duplication - * between constructors. See https://docs.oracle.com/javase/tutorial/java/javaOO/initial.html - * - * Note that non-static init blocks are not recommended to use. There are other ways to avoid duplication - * among constructors. - */ - { - persons = new UniquePersonList(); - } - - public AddressBook() {} - - /** - * Creates an AddressBook using the Persons in the {@code toBeCopied} - */ - public AddressBook(ReadOnlyAddressBook toBeCopied) { - this(); - resetData(toBeCopied); - } - - //// list overwrite operations - - /** - * Replaces the contents of the person list with {@code persons}. - * {@code persons} must not contain duplicate persons. - */ - public void setPersons(List persons) { - this.persons.setPersons(persons); - } - - /** - * Resets the existing data of this {@code AddressBook} with {@code newData}. - */ - public void resetData(ReadOnlyAddressBook newData) { - requireNonNull(newData); - - setPersons(newData.getPersonList()); - } - - //// person-level operations - - /** - * Returns true if a person with the same identity as {@code person} exists in the address book. - */ - public boolean hasPerson(Person person) { - requireNonNull(person); - return persons.contains(person); - } - - /** - * Adds a person to the address book. - * The person must not already exist in the address book. - */ - public void addPerson(Person p) { - persons.add(p); - } - - /** - * Replaces the given person {@code target} in the list with {@code editedPerson}. - * {@code target} must exist in the address book. - * The person identity of {@code editedPerson} must not be the same as another existing person in the address book. - */ - public void setPerson(Person target, Person editedPerson) { - requireNonNull(editedPerson); - - persons.setPerson(target, editedPerson); - } - - /** - * Removes {@code key} from this {@code AddressBook}. - * {@code key} must exist in the address book. - */ - public void removePerson(Person key) { - persons.remove(key); - } - - //// util methods - - @Override - public String toString() { - return persons.asUnmodifiableObservableList().size() + " persons"; - // TODO: refine later - } - - @Override - public ObservableList getPersonList() { - return persons.asUnmodifiableObservableList(); - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof AddressBook // instanceof handles nulls - && persons.equals(((AddressBook) other).persons)); - } - - @Override - public int hashCode() { - return persons.hashCode(); - } -} +package seedu.address.model; + +import static java.util.Objects.requireNonNull; + +import java.util.List; + +import javafx.collections.ObservableList; +import seedu.address.model.person.Person; +import seedu.address.model.person.UniquePersonList; + +/** + * Wraps all data at the address-book level + * Duplicates are not allowed (by .isSamePerson comparison) + */ +public class AddressBook implements ReadOnlyAddressBook { + + private final UniquePersonList persons; + + /* + * The 'unusual' code block below is a non-static initialization block, sometimes used to avoid duplication + * between constructors. See https://docs.oracle.com/javase/tutorial/java/javaOO/initial.html + * + * Note that non-static init blocks are not recommended to use. There are other ways to avoid duplication + * among constructors. + */ + { + persons = new UniquePersonList(); + } + + public AddressBook() {} + + /** + * Creates an AddressBook using the Persons in the {@code toBeCopied} + */ + public AddressBook(ReadOnlyAddressBook toBeCopied) { + this(); + resetData(toBeCopied); + } + + //// list overwrite operations + + /** + * Replaces the contents of the person list with {@code persons}. + * {@code persons} must not contain duplicate persons. + */ + public void setPersons(List persons) { + this.persons.setPersons(persons); + } + + /** + * Resets the existing data of this {@code AddressBook} with {@code newData}. + */ + public void resetData(ReadOnlyAddressBook newData) { + requireNonNull(newData); + + setPersons(newData.getPersonList()); + } + + //// person-level operations + + /** + * Returns true if a person with the same identity as {@code person} exists in the address book. + */ + public boolean hasPerson(Person person) { + requireNonNull(person); + return persons.contains(person); + } + + /** + * Adds a person to the address book. + * The person must not already exist in the address book. + */ + public void addPerson(Person p) { + persons.add(p); + } + + /** + * Replaces the given person {@code target} in the list with {@code editedPerson}. + * {@code target} must exist in the address book. + * The person identity of {@code editedPerson} must not be the same as another existing person in the address book. + */ + public void setPerson(Person target, Person editedPerson) { + requireNonNull(editedPerson); + + persons.setPerson(target, editedPerson); + } + + /** + * Removes {@code key} from this {@code AddressBook}. + * {@code key} must exist in the address book. + */ + public void removePerson(Person key) { + persons.remove(key); + } + + //// util methods + + @Override + public String toString() { + return persons.asUnmodifiableObservableList().size() + " persons"; + // TODO: refine later + } + + @Override + public ObservableList getPersonList() { + return persons.asUnmodifiableObservableList(); + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof AddressBook // instanceof handles nulls + && persons.equals(((AddressBook) other).persons)); + } + + @Override + public int hashCode() { + return persons.hashCode(); + } +} diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index d54df471c1f..dbc98dd1341 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -1,87 +1,87 @@ -package seedu.address.model; - -import java.nio.file.Path; -import java.util.function.Predicate; - -import javafx.collections.ObservableList; -import seedu.address.commons.core.GuiSettings; -import seedu.address.model.person.Person; - -/** - * The API of the Model component. - */ -public interface Model { - /** {@code Predicate} that always evaluate to true */ - Predicate PREDICATE_SHOW_ALL_PERSONS = unused -> true; - - /** - * Replaces user prefs data with the data in {@code userPrefs}. - */ - void setUserPrefs(ReadOnlyUserPrefs userPrefs); - - /** - * Returns the user prefs. - */ - ReadOnlyUserPrefs getUserPrefs(); - - /** - * Returns the user prefs' GUI settings. - */ - GuiSettings getGuiSettings(); - - /** - * Sets the user prefs' GUI settings. - */ - void setGuiSettings(GuiSettings guiSettings); - - /** - * Returns the user prefs' address book file path. - */ - Path getAddressBookFilePath(); - - /** - * Sets the user prefs' address book file path. - */ - void setAddressBookFilePath(Path addressBookFilePath); - - /** - * Replaces address book data with the data in {@code addressBook}. - */ - void setAddressBook(ReadOnlyAddressBook addressBook); - - /** Returns the AddressBook */ - ReadOnlyAddressBook getAddressBook(); - - /** - * Returns true if a person with the same identity as {@code person} exists in the address book. - */ - boolean hasPerson(Person person); - - /** - * Deletes the given person. - * The person must exist in the address book. - */ - void deletePerson(Person target); - - /** - * Adds the given person. - * {@code person} must not already exist in the address book. - */ - void addPerson(Person person); - - /** - * Replaces the given person {@code target} with {@code editedPerson}. - * {@code target} must exist in the address book. - * The person identity of {@code editedPerson} must not be the same as another existing person in the address book. - */ - void setPerson(Person target, Person editedPerson); - - /** Returns an unmodifiable view of the filtered person list */ - ObservableList getFilteredPersonList(); - - /** - * Updates the filter of the filtered person list to filter by the given {@code predicate}. - * @throws NullPointerException if {@code predicate} is null. - */ - void updateFilteredPersonList(Predicate predicate); -} +package seedu.address.model; + +import java.nio.file.Path; +import java.util.function.Predicate; + +import javafx.collections.ObservableList; +import seedu.address.commons.core.GuiSettings; +import seedu.address.model.person.Person; + +/** + * The API of the Model component. + */ +public interface Model { + /** {@code Predicate} that always evaluate to true */ + Predicate PREDICATE_SHOW_ALL_PERSONS = unused -> true; + + /** + * Replaces user prefs data with the data in {@code userPrefs}. + */ + void setUserPrefs(ReadOnlyUserPrefs userPrefs); + + /** + * Returns the user prefs. + */ + ReadOnlyUserPrefs getUserPrefs(); + + /** + * Returns the user prefs' GUI settings. + */ + GuiSettings getGuiSettings(); + + /** + * Sets the user prefs' GUI settings. + */ + void setGuiSettings(GuiSettings guiSettings); + + /** + * Returns the user prefs' address book file path. + */ + Path getAddressBookFilePath(); + + /** + * Sets the user prefs' address book file path. + */ + void setAddressBookFilePath(Path addressBookFilePath); + + /** + * Replaces address book data with the data in {@code addressBook}. + */ + void setAddressBook(ReadOnlyAddressBook addressBook); + + /** Returns the AddressBook */ + ReadOnlyAddressBook getAddressBook(); + + /** + * Returns true if a person with the same identity as {@code person} exists in the address book. + */ + boolean hasPerson(Person person); + + /** + * Deletes the given person. + * The person must exist in the address book. + */ + void deletePerson(Person target); + + /** + * Adds the given person. + * {@code person} must not already exist in the address book. + */ + void addPerson(Person person); + + /** + * Replaces the given person {@code target} with {@code editedPerson}. + * {@code target} must exist in the address book. + * The person identity of {@code editedPerson} must not be the same as another existing person in the address book. + */ + void setPerson(Person target, Person editedPerson); + + /** Returns an unmodifiable view of the filtered person list */ + ObservableList getFilteredPersonList(); + + /** + * Updates the filter of the filtered person list to filter by the given {@code predicate}. + * @throws NullPointerException if {@code predicate} is null. + */ + void updateFilteredPersonList(Predicate predicate); +} diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 0650c954f5c..900c9f8fefb 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -1,151 +1,151 @@ -package seedu.address.model; - -import static java.util.Objects.requireNonNull; -import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; - -import java.nio.file.Path; -import java.util.function.Predicate; -import java.util.logging.Logger; - -import javafx.collections.ObservableList; -import javafx.collections.transformation.FilteredList; -import seedu.address.commons.core.GuiSettings; -import seedu.address.commons.core.LogsCenter; -import seedu.address.model.person.Person; - -/** - * Represents the in-memory model of the address book data. - */ -public class ModelManager implements Model { - private static final Logger logger = LogsCenter.getLogger(ModelManager.class); - - private final AddressBook addressBook; - private final UserPrefs userPrefs; - private final FilteredList filteredPersons; - - /** - * Initializes a ModelManager with the given addressBook and userPrefs. - */ - public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs) { - super(); - requireAllNonNull(addressBook, userPrefs); - - logger.fine("Initializing with address book: " + addressBook + " and user prefs " + userPrefs); - - this.addressBook = new AddressBook(addressBook); - this.userPrefs = new UserPrefs(userPrefs); - filteredPersons = new FilteredList<>(this.addressBook.getPersonList()); - } - - public ModelManager() { - this(new AddressBook(), new UserPrefs()); - } - - //=========== UserPrefs ================================================================================== - - @Override - public void setUserPrefs(ReadOnlyUserPrefs userPrefs) { - requireNonNull(userPrefs); - this.userPrefs.resetData(userPrefs); - } - - @Override - public ReadOnlyUserPrefs getUserPrefs() { - return userPrefs; - } - - @Override - public GuiSettings getGuiSettings() { - return userPrefs.getGuiSettings(); - } - - @Override - public void setGuiSettings(GuiSettings guiSettings) { - requireNonNull(guiSettings); - userPrefs.setGuiSettings(guiSettings); - } - - @Override - public Path getAddressBookFilePath() { - return userPrefs.getAddressBookFilePath(); - } - - @Override - public void setAddressBookFilePath(Path addressBookFilePath) { - requireNonNull(addressBookFilePath); - userPrefs.setAddressBookFilePath(addressBookFilePath); - } - - //=========== AddressBook ================================================================================ - - @Override - public void setAddressBook(ReadOnlyAddressBook addressBook) { - this.addressBook.resetData(addressBook); - } - - @Override - public ReadOnlyAddressBook getAddressBook() { - return addressBook; - } - - @Override - public boolean hasPerson(Person person) { - requireNonNull(person); - return addressBook.hasPerson(person); - } - - @Override - public void deletePerson(Person target) { - addressBook.removePerson(target); - } - - @Override - public void addPerson(Person person) { - addressBook.addPerson(person); - updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); - } - - @Override - public void setPerson(Person target, Person editedPerson) { - requireAllNonNull(target, editedPerson); - - addressBook.setPerson(target, editedPerson); - } - - //=========== Filtered Person List Accessors ============================================================= - - /** - * Returns an unmodifiable view of the list of {@code Person} backed by the internal list of - * {@code versionedAddressBook} - */ - @Override - public ObservableList getFilteredPersonList() { - return filteredPersons; - } - - @Override - public void updateFilteredPersonList(Predicate predicate) { - requireNonNull(predicate); - filteredPersons.setPredicate(predicate); - } - - @Override - public boolean equals(Object obj) { - // short circuit if same object - if (obj == this) { - return true; - } - - // instanceof handles nulls - if (!(obj instanceof ModelManager)) { - return false; - } - - // state check - ModelManager other = (ModelManager) obj; - return addressBook.equals(other.addressBook) - && userPrefs.equals(other.userPrefs) - && filteredPersons.equals(other.filteredPersons); - } - -} +package seedu.address.model; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; + +import java.nio.file.Path; +import java.util.function.Predicate; +import java.util.logging.Logger; + +import javafx.collections.ObservableList; +import javafx.collections.transformation.FilteredList; +import seedu.address.commons.core.GuiSettings; +import seedu.address.commons.core.LogsCenter; +import seedu.address.model.person.Person; + +/** + * Represents the in-memory model of the address book data. + */ +public class ModelManager implements Model { + private static final Logger logger = LogsCenter.getLogger(ModelManager.class); + + private final AddressBook addressBook; + private final UserPrefs userPrefs; + private final FilteredList filteredPersons; + + /** + * Initializes a ModelManager with the given addressBook and userPrefs. + */ + public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs) { + super(); + requireAllNonNull(addressBook, userPrefs); + + logger.fine("Initializing with address book: " + addressBook + " and user prefs " + userPrefs); + + this.addressBook = new AddressBook(addressBook); + this.userPrefs = new UserPrefs(userPrefs); + filteredPersons = new FilteredList<>(this.addressBook.getPersonList()); + } + + public ModelManager() { + this(new AddressBook(), new UserPrefs()); + } + + //=========== UserPrefs ================================================================================== + + @Override + public void setUserPrefs(ReadOnlyUserPrefs userPrefs) { + requireNonNull(userPrefs); + this.userPrefs.resetData(userPrefs); + } + + @Override + public ReadOnlyUserPrefs getUserPrefs() { + return userPrefs; + } + + @Override + public GuiSettings getGuiSettings() { + return userPrefs.getGuiSettings(); + } + + @Override + public void setGuiSettings(GuiSettings guiSettings) { + requireNonNull(guiSettings); + userPrefs.setGuiSettings(guiSettings); + } + + @Override + public Path getAddressBookFilePath() { + return userPrefs.getAddressBookFilePath(); + } + + @Override + public void setAddressBookFilePath(Path addressBookFilePath) { + requireNonNull(addressBookFilePath); + userPrefs.setAddressBookFilePath(addressBookFilePath); + } + + //=========== AddressBook ================================================================================ + + @Override + public void setAddressBook(ReadOnlyAddressBook addressBook) { + this.addressBook.resetData(addressBook); + } + + @Override + public ReadOnlyAddressBook getAddressBook() { + return addressBook; + } + + @Override + public boolean hasPerson(Person person) { + requireNonNull(person); + return addressBook.hasPerson(person); + } + + @Override + public void deletePerson(Person target) { + addressBook.removePerson(target); + } + + @Override + public void addPerson(Person person) { + addressBook.addPerson(person); + updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); + } + + @Override + public void setPerson(Person target, Person editedPerson) { + requireAllNonNull(target, editedPerson); + + addressBook.setPerson(target, editedPerson); + } + + //=========== Filtered Person List Accessors ============================================================= + + /** + * Returns an unmodifiable view of the list of {@code Person} backed by the internal list of + * {@code versionedAddressBook} + */ + @Override + public ObservableList getFilteredPersonList() { + return filteredPersons; + } + + @Override + public void updateFilteredPersonList(Predicate predicate) { + requireNonNull(predicate); + filteredPersons.setPredicate(predicate); + } + + @Override + public boolean equals(Object obj) { + // short circuit if same object + if (obj == this) { + return true; + } + + // instanceof handles nulls + if (!(obj instanceof ModelManager)) { + return false; + } + + // state check + ModelManager other = (ModelManager) obj; + return addressBook.equals(other.addressBook) + && userPrefs.equals(other.userPrefs) + && filteredPersons.equals(other.filteredPersons); + } + +} diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java index 6ddc2cd9a29..c1b2d1ccd95 100644 --- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java +++ b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java @@ -1,17 +1,17 @@ -package seedu.address.model; - -import javafx.collections.ObservableList; -import seedu.address.model.person.Person; - -/** - * Unmodifiable view of an address book - */ -public interface ReadOnlyAddressBook { - - /** - * Returns an unmodifiable view of the persons list. - * This list will not contain any duplicate persons. - */ - ObservableList getPersonList(); - -} +package seedu.address.model; + +import javafx.collections.ObservableList; +import seedu.address.model.person.Person; + +/** + * Unmodifiable view of an address book + */ +public interface ReadOnlyAddressBook { + + /** + * Returns an unmodifiable view of the persons list. + * This list will not contain any duplicate persons. + */ + ObservableList getPersonList(); + +} diff --git a/src/main/java/seedu/address/model/ReadOnlyUserPrefs.java b/src/main/java/seedu/address/model/ReadOnlyUserPrefs.java index befd58a4c73..ef2c49d8272 100644 --- a/src/main/java/seedu/address/model/ReadOnlyUserPrefs.java +++ b/src/main/java/seedu/address/model/ReadOnlyUserPrefs.java @@ -1,16 +1,16 @@ -package seedu.address.model; - -import java.nio.file.Path; - -import seedu.address.commons.core.GuiSettings; - -/** - * Unmodifiable view of user prefs. - */ -public interface ReadOnlyUserPrefs { - - GuiSettings getGuiSettings(); - - Path getAddressBookFilePath(); - -} +package seedu.address.model; + +import java.nio.file.Path; + +import seedu.address.commons.core.GuiSettings; + +/** + * Unmodifiable view of user prefs. + */ +public interface ReadOnlyUserPrefs { + + GuiSettings getGuiSettings(); + + Path getAddressBookFilePath(); + +} diff --git a/src/main/java/seedu/address/model/UserPrefs.java b/src/main/java/seedu/address/model/UserPrefs.java index 25a5fd6eab9..600a23deb92 100644 --- a/src/main/java/seedu/address/model/UserPrefs.java +++ b/src/main/java/seedu/address/model/UserPrefs.java @@ -1,87 +1,87 @@ -package seedu.address.model; - -import static java.util.Objects.requireNonNull; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Objects; - -import seedu.address.commons.core.GuiSettings; - -/** - * Represents User's preferences. - */ -public class UserPrefs implements ReadOnlyUserPrefs { - - private GuiSettings guiSettings = new GuiSettings(); - private Path addressBookFilePath = Paths.get("data" , "addressbook.json"); - - /** - * Creates a {@code UserPrefs} with default values. - */ - public UserPrefs() {} - - /** - * Creates a {@code UserPrefs} with the prefs in {@code userPrefs}. - */ - public UserPrefs(ReadOnlyUserPrefs userPrefs) { - this(); - resetData(userPrefs); - } - - /** - * Resets the existing data of this {@code UserPrefs} with {@code newUserPrefs}. - */ - public void resetData(ReadOnlyUserPrefs newUserPrefs) { - requireNonNull(newUserPrefs); - setGuiSettings(newUserPrefs.getGuiSettings()); - setAddressBookFilePath(newUserPrefs.getAddressBookFilePath()); - } - - public GuiSettings getGuiSettings() { - return guiSettings; - } - - public void setGuiSettings(GuiSettings guiSettings) { - requireNonNull(guiSettings); - this.guiSettings = guiSettings; - } - - public Path getAddressBookFilePath() { - return addressBookFilePath; - } - - public void setAddressBookFilePath(Path addressBookFilePath) { - requireNonNull(addressBookFilePath); - this.addressBookFilePath = addressBookFilePath; - } - - @Override - public boolean equals(Object other) { - if (other == this) { - return true; - } - if (!(other instanceof UserPrefs)) { //this handles null as well. - return false; - } - - UserPrefs o = (UserPrefs) other; - - return guiSettings.equals(o.guiSettings) - && addressBookFilePath.equals(o.addressBookFilePath); - } - - @Override - public int hashCode() { - return Objects.hash(guiSettings, addressBookFilePath); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("Gui Settings : " + guiSettings); - sb.append("\nLocal data file location : " + addressBookFilePath); - return sb.toString(); - } - -} +package seedu.address.model; + +import static java.util.Objects.requireNonNull; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Objects; + +import seedu.address.commons.core.GuiSettings; + +/** + * Represents User's preferences. + */ +public class UserPrefs implements ReadOnlyUserPrefs { + + private GuiSettings guiSettings = new GuiSettings(); + private Path addressBookFilePath = Paths.get("data" , "addressbook.json"); + + /** + * Creates a {@code UserPrefs} with default values. + */ + public UserPrefs() {} + + /** + * Creates a {@code UserPrefs} with the prefs in {@code userPrefs}. + */ + public UserPrefs(ReadOnlyUserPrefs userPrefs) { + this(); + resetData(userPrefs); + } + + /** + * Resets the existing data of this {@code UserPrefs} with {@code newUserPrefs}. + */ + public void resetData(ReadOnlyUserPrefs newUserPrefs) { + requireNonNull(newUserPrefs); + setGuiSettings(newUserPrefs.getGuiSettings()); + setAddressBookFilePath(newUserPrefs.getAddressBookFilePath()); + } + + public GuiSettings getGuiSettings() { + return guiSettings; + } + + public void setGuiSettings(GuiSettings guiSettings) { + requireNonNull(guiSettings); + this.guiSettings = guiSettings; + } + + public Path getAddressBookFilePath() { + return addressBookFilePath; + } + + public void setAddressBookFilePath(Path addressBookFilePath) { + requireNonNull(addressBookFilePath); + this.addressBookFilePath = addressBookFilePath; + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if (!(other instanceof UserPrefs)) { //this handles null as well. + return false; + } + + UserPrefs o = (UserPrefs) other; + + return guiSettings.equals(o.guiSettings) + && addressBookFilePath.equals(o.addressBookFilePath); + } + + @Override + public int hashCode() { + return Objects.hash(guiSettings, addressBookFilePath); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Gui Settings : " + guiSettings); + sb.append("\nLocal data file location : " + addressBookFilePath); + return sb.toString(); + } + +} diff --git a/src/main/java/seedu/address/model/person/Address.java b/src/main/java/seedu/address/model/person/Address.java deleted file mode 100644 index 60472ca22a0..00000000000 --- a/src/main/java/seedu/address/model/person/Address.java +++ /dev/null @@ -1,57 +0,0 @@ -package seedu.address.model.person; - -import static java.util.Objects.requireNonNull; -import static seedu.address.commons.util.AppUtil.checkArgument; - -/** - * Represents a Person's address in the address book. - * Guarantees: immutable; is valid as declared in {@link #isValidAddress(String)} - */ -public class Address { - - public static final String MESSAGE_CONSTRAINTS = "Addresses can take any values, and it should not be blank"; - - /* - * The first character of the address must not be a whitespace, - * otherwise " " (a blank string) becomes a valid input. - */ - public static final String VALIDATION_REGEX = "[^\\s].*"; - - public final String value; - - /** - * Constructs an {@code Address}. - * - * @param address A valid address. - */ - public Address(String address) { - requireNonNull(address); - checkArgument(isValidAddress(address), MESSAGE_CONSTRAINTS); - value = address; - } - - /** - * Returns true if a given string is a valid email. - */ - public static boolean isValidAddress(String test) { - return test.matches(VALIDATION_REGEX); - } - - @Override - public String toString() { - return value; - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof Address // instanceof handles nulls - && value.equals(((Address) other).value)); // state check - } - - @Override - public int hashCode() { - return value.hashCode(); - } - -} diff --git a/src/main/java/seedu/address/model/person/Email.java b/src/main/java/seedu/address/model/person/Email.java index a5bbe0b6a5f..5a042e939a0 100644 --- a/src/main/java/seedu/address/model/person/Email.java +++ b/src/main/java/seedu/address/model/person/Email.java @@ -1,67 +1,67 @@ -package seedu.address.model.person; - -import static java.util.Objects.requireNonNull; -import static seedu.address.commons.util.AppUtil.checkArgument; - -/** - * Represents a Person's email in the address book. - * Guarantees: immutable; is valid as declared in {@link #isValidEmail(String)} - */ -public class Email { - - private static final String SPECIAL_CHARACTERS = "!#$%&'*+/=?`{|}~^.-"; - public static final String MESSAGE_CONSTRAINTS = "Emails should be of the format local-part@domain " - + "and adhere to the following constraints:\n" - + "1. The local-part should only contain alphanumeric characters and these special characters, excluding " - + "the parentheses, (" + SPECIAL_CHARACTERS + ") .\n" - + "2. This is followed by a '@' and then a domain name. " - + "The domain name must:\n" - + " - be at least 2 characters long\n" - + " - start and end with alphanumeric characters\n" - + " - consist of alphanumeric characters, a period or a hyphen for the characters in between, if any."; - // alphanumeric and special characters - private static final String LOCAL_PART_REGEX = "^[\\w" + SPECIAL_CHARACTERS + "]+"; - private static final String DOMAIN_FIRST_CHARACTER_REGEX = "[^\\W_]"; // alphanumeric characters except underscore - private static final String DOMAIN_MIDDLE_REGEX = "[a-zA-Z0-9.-]*"; // alphanumeric, period and hyphen - private static final String DOMAIN_LAST_CHARACTER_REGEX = "[^\\W_]$"; - public static final String VALIDATION_REGEX = LOCAL_PART_REGEX + "@" - + DOMAIN_FIRST_CHARACTER_REGEX + DOMAIN_MIDDLE_REGEX + DOMAIN_LAST_CHARACTER_REGEX; - - public final String value; - - /** - * Constructs an {@code Email}. - * - * @param email A valid email address. - */ - public Email(String email) { - requireNonNull(email); - checkArgument(isValidEmail(email), MESSAGE_CONSTRAINTS); - value = email; - } - - /** - * Returns if a given string is a valid email. - */ - public static boolean isValidEmail(String test) { - return test.matches(VALIDATION_REGEX); - } - - @Override - public String toString() { - return value; - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof Email // instanceof handles nulls - && value.equals(((Email) other).value)); // state check - } - - @Override - public int hashCode() { - return value.hashCode(); - } - -} +package seedu.address.model.person; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; + +/** + * Represents a Person's email in the address book. + * Guarantees: immutable; is valid as declared in {@link #isValidEmail(String)} + */ +public class Email { + + private static final String SPECIAL_CHARACTERS = "!#$%&'*+/=?`{|}~^.-"; + public static final String MESSAGE_CONSTRAINTS = "Emails should be of the format local-part@domain " + + "and adhere to the following constraints:\n" + + "1. The local-part should only contain alphanumeric characters and these special characters, excluding " + + "the parentheses, (" + SPECIAL_CHARACTERS + ") .\n" + + "2. This is followed by a '@' and then a domain name. " + + "The domain name must:\n" + + " - be at least 2 characters long\n" + + " - start and end with alphanumeric characters\n" + + " - consist of alphanumeric characters, a period or a hyphen for the characters in between, if any."; + // alphanumeric and special characters + private static final String LOCAL_PART_REGEX = "^[\\w" + SPECIAL_CHARACTERS + "]+"; + private static final String DOMAIN_FIRST_CHARACTER_REGEX = "[^\\W_]"; // alphanumeric characters except underscore + private static final String DOMAIN_MIDDLE_REGEX = "[a-zA-Z0-9.-]*"; // alphanumeric, period and hyphen + private static final String DOMAIN_LAST_CHARACTER_REGEX = "[^\\W_]$"; + public static final String VALIDATION_REGEX = LOCAL_PART_REGEX + "@" + + DOMAIN_FIRST_CHARACTER_REGEX + DOMAIN_MIDDLE_REGEX + DOMAIN_LAST_CHARACTER_REGEX; + + public final String value; + + /** + * Constructs an {@code Email}. + * + * @param email A valid email address. + */ + public Email(String email) { + requireNonNull(email); + checkArgument(isValidEmail(email), MESSAGE_CONSTRAINTS); + value = email; + } + + /** + * Returns if a given string is a valid email. + */ + public static boolean isValidEmail(String test) { + return test.matches(VALIDATION_REGEX); + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof Email // instanceof handles nulls + && value.equals(((Email) other).value)); // state check + } + + @Override + public int hashCode() { + return value.hashCode(); + } + +} diff --git a/src/main/java/seedu/address/model/person/Name.java b/src/main/java/seedu/address/model/person/Name.java index 79244d71cf7..22add7aff6a 100644 --- a/src/main/java/seedu/address/model/person/Name.java +++ b/src/main/java/seedu/address/model/person/Name.java @@ -1,59 +1,59 @@ -package seedu.address.model.person; - -import static java.util.Objects.requireNonNull; -import static seedu.address.commons.util.AppUtil.checkArgument; - -/** - * Represents a Person's name in the address book. - * Guarantees: immutable; is valid as declared in {@link #isValidName(String)} - */ -public class Name { - - public static final String MESSAGE_CONSTRAINTS = - "Names should only contain alphanumeric characters and spaces, and it should not be blank"; - - /* - * The first character of the address must not be a whitespace, - * otherwise " " (a blank string) becomes a valid input. - */ - public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*"; - - public final String fullName; - - /** - * Constructs a {@code Name}. - * - * @param name A valid name. - */ - public Name(String name) { - requireNonNull(name); - checkArgument(isValidName(name), MESSAGE_CONSTRAINTS); - fullName = name; - } - - /** - * Returns true if a given string is a valid name. - */ - public static boolean isValidName(String test) { - return test.matches(VALIDATION_REGEX); - } - - - @Override - public String toString() { - return fullName; - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof Name // instanceof handles nulls - && fullName.equals(((Name) other).fullName)); // state check - } - - @Override - public int hashCode() { - return fullName.hashCode(); - } - -} +package seedu.address.model.person; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; + +/** + * Represents a Person's name in the address book. + * Guarantees: immutable; is valid as declared in {@link #isValidName(String)} + */ +public class Name { + + public static final String MESSAGE_CONSTRAINTS = + "Names should only contain alphanumeric characters and spaces, and it should not be blank"; + + /* + * The first character of the address must not be a whitespace, + * otherwise " " (a blank string) becomes a valid input. + */ + public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*"; + + public final String fullName; + + /** + * Constructs a {@code Name}. + * + * @param name A valid name. + */ + public Name(String name) { + requireNonNull(name); + checkArgument(isValidName(name), MESSAGE_CONSTRAINTS); + fullName = name; + } + + /** + * Returns true if a given string is a valid name. + */ + public static boolean isValidName(String test) { + return test.matches(VALIDATION_REGEX); + } + + + @Override + public String toString() { + return fullName; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof Name // instanceof handles nulls + && fullName.equals(((Name) other).fullName)); // state check + } + + @Override + public int hashCode() { + return fullName.hashCode(); + } + +} diff --git a/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java b/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java index c9b5868427c..81f8fe208be 100644 --- a/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java +++ b/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java @@ -1,31 +1,31 @@ -package seedu.address.model.person; - -import java.util.List; -import java.util.function.Predicate; - -import seedu.address.commons.util.StringUtil; - -/** - * Tests that a {@code Person}'s {@code Name} matches any of the keywords given. - */ -public class NameContainsKeywordsPredicate implements Predicate { - private final List keywords; - - public NameContainsKeywordsPredicate(List keywords) { - this.keywords = keywords; - } - - @Override - public boolean test(Person person) { - return keywords.stream() - .anyMatch(keyword -> StringUtil.containsWordIgnoreCase(person.getName().fullName, keyword)); - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof NameContainsKeywordsPredicate // instanceof handles nulls - && keywords.equals(((NameContainsKeywordsPredicate) other).keywords)); // state check - } - -} +package seedu.address.model.person; + +import java.util.List; +import java.util.function.Predicate; + +import seedu.address.commons.util.StringUtil; + +/** + * Tests that a {@code Person}'s {@code Name} matches any of the keywords given. + */ +public class NameContainsKeywordsPredicate implements Predicate { + private final List keywords; + + public NameContainsKeywordsPredicate(List keywords) { + this.keywords = keywords; + } + + @Override + public boolean test(Person person) { + return keywords.stream() + .anyMatch(keyword -> StringUtil.containsWordIgnoreCase(person.getName().fullName, keyword)); + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof NameContainsKeywordsPredicate // instanceof handles nulls + && keywords.equals(((NameContainsKeywordsPredicate) other).keywords)); // state check + } + +} diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 557a7a60cd5..d82a0fdc99f 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -1,120 +1,112 @@ -package seedu.address.model.person; - -import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - -import seedu.address.model.tag.Tag; - -/** - * Represents a Person in the address book. - * Guarantees: details are present and not null, field values are validated, immutable. - */ -public class Person { - - // Identity fields - private final Name name; - private final Phone phone; - private final Email email; - - // Data fields - private final Address address; - private final Set tags = new HashSet<>(); - - /** - * Every field must be present and not null. - */ - public Person(Name name, Phone phone, Email email, Address address, Set tags) { - requireAllNonNull(name, phone, email, address, tags); - this.name = name; - this.phone = phone; - this.email = email; - this.address = address; - this.tags.addAll(tags); - } - - public Name getName() { - return name; - } - - public Phone getPhone() { - return phone; - } - - public Email getEmail() { - return email; - } - - public Address getAddress() { - return address; - } - - /** - * Returns an immutable tag set, which throws {@code UnsupportedOperationException} - * if modification is attempted. - */ - public Set getTags() { - return Collections.unmodifiableSet(tags); - } - - /** - * Returns true if both persons of the same name have at least one other identity field that is the same. - * This defines a weaker notion of equality between two persons. - */ - public boolean isSamePerson(Person otherPerson) { - if (otherPerson == this) { - return true; - } - - return otherPerson != null - && otherPerson.getName().equals(getName()) - && (otherPerson.getPhone().equals(getPhone()) || otherPerson.getEmail().equals(getEmail())); - } - - /** - * Returns true if both persons have the same identity and data fields. - * This defines a stronger notion of equality between two persons. - */ - @Override - public boolean equals(Object other) { - if (other == this) { - return true; - } - - if (!(other instanceof Person)) { - return false; - } - - Person otherPerson = (Person) other; - return otherPerson.getName().equals(getName()) - && otherPerson.getPhone().equals(getPhone()) - && otherPerson.getEmail().equals(getEmail()) - && otherPerson.getAddress().equals(getAddress()) - && otherPerson.getTags().equals(getTags()); - } - - @Override - public int hashCode() { - // use this method for custom fields hashing instead of implementing your own - return Objects.hash(name, phone, email, address, tags); - } - - @Override - public String toString() { - final StringBuilder builder = new StringBuilder(); - builder.append(getName()) - .append(" Phone: ") - .append(getPhone()) - .append(" Email: ") - .append(getEmail()) - .append(" Address: ") - .append(getAddress()) - .append(" Tags: "); - getTags().forEach(builder::append); - return builder.toString(); - } - -} +package seedu.address.model.person; + +import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +import seedu.address.model.tag.Tag; + +/** + * Represents a Person in the address book. + * Guarantees: details are present and not null, field values are validated, immutable. + */ +public class Person { + + // Identity fields + private final Name name; + private final Phone phone; + private final Email email; + + // Data fields + private final Set tags = new HashSet<>(); + + /** + * Every field must be present and not null. + */ + public Person(Name name, Phone phone, Email email, Set tags) { + requireAllNonNull(name, phone, email, tags); + this.name = name; + this.phone = phone; + this.email = email; + this.tags.addAll(tags); + } + + public Name getName() { + return name; + } + + public Phone getPhone() { + return phone; + } + + public Email getEmail() { + return email; + } + + /** + * Returns an immutable tag set, which throws {@code UnsupportedOperationException} + * if modification is attempted. + */ + public Set getTags() { + return Collections.unmodifiableSet(tags); + } + + /** + * Returns true if both persons of the same name have at least one other identity field that is the same. + * This defines a weaker notion of equality between two persons. + */ + public boolean isSamePerson(Person otherPerson) { + if (otherPerson == this) { + return true; + } + + return otherPerson != null + && otherPerson.getName().equals(getName()) + && (otherPerson.getPhone().equals(getPhone()) || otherPerson.getEmail().equals(getEmail())); + } + + /** + * Returns true if both persons have the same identity and data fields. + * This defines a stronger notion of equality between two persons. + */ + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + + if (!(other instanceof Person)) { + return false; + } + + Person otherPerson = (Person) other; + return otherPerson.getName().equals(getName()) + && otherPerson.getPhone().equals(getPhone()) + && otherPerson.getEmail().equals(getEmail()) + && otherPerson.getTags().equals(getTags()); + } + + @Override + public int hashCode() { + // use this method for custom fields hashing instead of implementing your own + return Objects.hash(name, phone, email, tags); + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append(getName()) + .append(" Phone: ") + .append(getPhone()) + .append(" Email: ") + .append(getEmail()) + .append(" Address: ") + .append(" Tags: "); + getTags().forEach(builder::append); + return builder.toString(); + } + +} diff --git a/src/main/java/seedu/address/model/person/Phone.java b/src/main/java/seedu/address/model/person/Phone.java index 872c76b382f..d42130c13ba 100644 --- a/src/main/java/seedu/address/model/person/Phone.java +++ b/src/main/java/seedu/address/model/person/Phone.java @@ -1,53 +1,53 @@ -package seedu.address.model.person; - -import static java.util.Objects.requireNonNull; -import static seedu.address.commons.util.AppUtil.checkArgument; - -/** - * Represents a Person's phone number in the address book. - * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} - */ -public class Phone { - - - public static final String MESSAGE_CONSTRAINTS = - "Phone numbers should only contain numbers, and it should be at least 3 digits long"; - public static final String VALIDATION_REGEX = "\\d{3,}"; - public final String value; - - /** - * Constructs a {@code Phone}. - * - * @param phone A valid phone number. - */ - public Phone(String phone) { - requireNonNull(phone); - checkArgument(isValidPhone(phone), MESSAGE_CONSTRAINTS); - value = phone; - } - - /** - * Returns true if a given string is a valid phone number. - */ - public static boolean isValidPhone(String test) { - return test.matches(VALIDATION_REGEX); - } - - @Override - public String toString() { - return value; - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof Phone // instanceof handles nulls - && value.equals(((Phone) other).value)); // state check - } - - @Override - public int hashCode() { - return value.hashCode(); - } - -} +package seedu.address.model.person; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; + +/** + * Represents a Person's phone number in the address book. + * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} + */ +public class Phone { + + + public static final String MESSAGE_CONSTRAINTS = + "Phone numbers should only contain numbers, and it should be at least 3 digits long"; + public static final String VALIDATION_REGEX = "\\d{3,}"; + public final String value; + + /** + * Constructs a {@code Phone}. + * + * @param phone A valid phone number. + */ + public Phone(String phone) { + requireNonNull(phone); + checkArgument(isValidPhone(phone), MESSAGE_CONSTRAINTS); + value = phone; + } + + /** + * Returns true if a given string is a valid phone number. + */ + public static boolean isValidPhone(String test) { + return test.matches(VALIDATION_REGEX); + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof Phone // instanceof handles nulls + && value.equals(((Phone) other).value)); // state check + } + + @Override + public int hashCode() { + return value.hashCode(); + } + +} diff --git a/src/main/java/seedu/address/model/person/UniquePersonList.java b/src/main/java/seedu/address/model/person/UniquePersonList.java index 0fee4fe57e6..0a743261b3b 100644 --- a/src/main/java/seedu/address/model/person/UniquePersonList.java +++ b/src/main/java/seedu/address/model/person/UniquePersonList.java @@ -1,137 +1,137 @@ -package seedu.address.model.person; - -import static java.util.Objects.requireNonNull; -import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; - -import java.util.Iterator; -import java.util.List; - -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import seedu.address.model.person.exceptions.DuplicatePersonException; -import seedu.address.model.person.exceptions.PersonNotFoundException; - -/** - * A list of persons that enforces uniqueness between its elements and does not allow nulls. - * A person is considered unique by comparing using {@code Person#isSamePerson(Person)}. As such, adding and updating of - * persons uses Person#isSamePerson(Person) for equality so as to ensure that the person being added or updated is - * unique in terms of identity in the UniquePersonList. However, the removal of a person uses Person#equals(Object) so - * as to ensure that the person with exactly the same fields will be removed. - * - * Supports a minimal set of list operations. - * - * @see Person#isSamePerson(Person) - */ -public class UniquePersonList implements Iterable { - - private final ObservableList internalList = FXCollections.observableArrayList(); - private final ObservableList internalUnmodifiableList = - FXCollections.unmodifiableObservableList(internalList); - - /** - * Returns true if the list contains an equivalent person as the given argument. - */ - public boolean contains(Person toCheck) { - requireNonNull(toCheck); - return internalList.stream().anyMatch(toCheck::isSamePerson); - } - - /** - * Adds a person to the list. - * The person must not already exist in the list. - */ - public void add(Person toAdd) { - requireNonNull(toAdd); - if (contains(toAdd)) { - throw new DuplicatePersonException(); - } - internalList.add(toAdd); - } - - /** - * Replaces the person {@code target} in the list with {@code editedPerson}. - * {@code target} must exist in the list. - * The person identity of {@code editedPerson} must not be the same as another existing person in the list. - */ - public void setPerson(Person target, Person editedPerson) { - requireAllNonNull(target, editedPerson); - - int index = internalList.indexOf(target); - if (index == -1) { - throw new PersonNotFoundException(); - } - - if (!target.isSamePerson(editedPerson) && contains(editedPerson)) { - throw new DuplicatePersonException(); - } - - internalList.set(index, editedPerson); - } - - /** - * Removes the equivalent person from the list. - * The person must exist in the list. - */ - public void remove(Person toRemove) { - requireNonNull(toRemove); - if (!internalList.remove(toRemove)) { - throw new PersonNotFoundException(); - } - } - - public void setPersons(UniquePersonList replacement) { - requireNonNull(replacement); - internalList.setAll(replacement.internalList); - } - - /** - * Replaces the contents of this list with {@code persons}. - * {@code persons} must not contain duplicate persons. - */ - public void setPersons(List persons) { - requireAllNonNull(persons); - if (!personsAreUnique(persons)) { - throw new DuplicatePersonException(); - } - - internalList.setAll(persons); - } - - /** - * Returns the backing list as an unmodifiable {@code ObservableList}. - */ - public ObservableList asUnmodifiableObservableList() { - return internalUnmodifiableList; - } - - @Override - public Iterator iterator() { - return internalList.iterator(); - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof UniquePersonList // instanceof handles nulls - && internalList.equals(((UniquePersonList) other).internalList)); - } - - @Override - public int hashCode() { - return internalList.hashCode(); - } - - /** - * Returns true if {@code persons} contains only unique persons. - */ - private boolean personsAreUnique(List persons) { - for (int i = 0; i < persons.size() - 1; i++) { - for (int j = i + 1; j < persons.size(); j++) { - if (persons.get(i).isSamePerson(persons.get(j))) { - return false; - } - } - } - return true; - } -} +package seedu.address.model.person; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; + +import java.util.Iterator; +import java.util.List; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import seedu.address.model.person.exceptions.DuplicatePersonException; +import seedu.address.model.person.exceptions.PersonNotFoundException; + +/** + * A list of persons that enforces uniqueness between its elements and does not allow nulls. + * A person is considered unique by comparing using {@code Person#isSamePerson(Person)}. As such, adding and updating of + * persons uses Person#isSamePerson(Person) for equality so as to ensure that the person being added or updated is + * unique in terms of identity in the UniquePersonList. However, the removal of a person uses Person#equals(Object) so + * as to ensure that the person with exactly the same fields will be removed. + * + * Supports a minimal set of list operations. + * + * @see Person#isSamePerson(Person) + */ +public class UniquePersonList implements Iterable { + + private final ObservableList internalList = FXCollections.observableArrayList(); + private final ObservableList internalUnmodifiableList = + FXCollections.unmodifiableObservableList(internalList); + + /** + * Returns true if the list contains an equivalent person as the given argument. + */ + public boolean contains(Person toCheck) { + requireNonNull(toCheck); + return internalList.stream().anyMatch(toCheck::isSamePerson); + } + + /** + * Adds a person to the list. + * The person must not already exist in the list. + */ + public void add(Person toAdd) { + requireNonNull(toAdd); + if (contains(toAdd)) { + throw new DuplicatePersonException(); + } + internalList.add(toAdd); + } + + /** + * Replaces the person {@code target} in the list with {@code editedPerson}. + * {@code target} must exist in the list. + * The person identity of {@code editedPerson} must not be the same as another existing person in the list. + */ + public void setPerson(Person target, Person editedPerson) { + requireAllNonNull(target, editedPerson); + + int index = internalList.indexOf(target); + if (index == -1) { + throw new PersonNotFoundException(); + } + + if (!target.isSamePerson(editedPerson) && contains(editedPerson)) { + throw new DuplicatePersonException(); + } + + internalList.set(index, editedPerson); + } + + /** + * Removes the equivalent person from the list. + * The person must exist in the list. + */ + public void remove(Person toRemove) { + requireNonNull(toRemove); + if (!internalList.remove(toRemove)) { + throw new PersonNotFoundException(); + } + } + + public void setPersons(UniquePersonList replacement) { + requireNonNull(replacement); + internalList.setAll(replacement.internalList); + } + + /** + * Replaces the contents of this list with {@code persons}. + * {@code persons} must not contain duplicate persons. + */ + public void setPersons(List persons) { + requireAllNonNull(persons); + if (!personsAreUnique(persons)) { + throw new DuplicatePersonException(); + } + + internalList.setAll(persons); + } + + /** + * Returns the backing list as an unmodifiable {@code ObservableList}. + */ + public ObservableList asUnmodifiableObservableList() { + return internalUnmodifiableList; + } + + @Override + public Iterator iterator() { + return internalList.iterator(); + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof UniquePersonList // instanceof handles nulls + && internalList.equals(((UniquePersonList) other).internalList)); + } + + @Override + public int hashCode() { + return internalList.hashCode(); + } + + /** + * Returns true if {@code persons} contains only unique persons. + */ + private boolean personsAreUnique(List persons) { + for (int i = 0; i < persons.size() - 1; i++) { + for (int j = i + 1; j < persons.size(); j++) { + if (persons.get(i).isSamePerson(persons.get(j))) { + return false; + } + } + } + return true; + } +} diff --git a/src/main/java/seedu/address/model/person/exceptions/DuplicatePersonException.java b/src/main/java/seedu/address/model/person/exceptions/DuplicatePersonException.java index d7290f59442..52e39e82d2a 100644 --- a/src/main/java/seedu/address/model/person/exceptions/DuplicatePersonException.java +++ b/src/main/java/seedu/address/model/person/exceptions/DuplicatePersonException.java @@ -1,11 +1,11 @@ -package seedu.address.model.person.exceptions; - -/** - * Signals that the operation will result in duplicate Persons (Persons are considered duplicates if they have the same - * identity). - */ -public class DuplicatePersonException extends RuntimeException { - public DuplicatePersonException() { - super("Operation would result in duplicate persons"); - } -} +package seedu.address.model.person.exceptions; + +/** + * Signals that the operation will result in duplicate Persons (Persons are considered duplicates if they have the same + * identity). + */ +public class DuplicatePersonException extends RuntimeException { + public DuplicatePersonException() { + super("Operation would result in duplicate persons"); + } +} diff --git a/src/main/java/seedu/address/model/person/exceptions/PersonNotFoundException.java b/src/main/java/seedu/address/model/person/exceptions/PersonNotFoundException.java index fa764426ca7..f66703d9380 100644 --- a/src/main/java/seedu/address/model/person/exceptions/PersonNotFoundException.java +++ b/src/main/java/seedu/address/model/person/exceptions/PersonNotFoundException.java @@ -1,6 +1,6 @@ -package seedu.address.model.person.exceptions; - -/** - * Signals that the operation is unable to find the specified person. - */ -public class PersonNotFoundException extends RuntimeException {} +package seedu.address.model.person.exceptions; + +/** + * Signals that the operation is unable to find the specified person. + */ +public class PersonNotFoundException extends RuntimeException {} diff --git a/src/main/java/seedu/address/model/tag/Tag.java b/src/main/java/seedu/address/model/tag/Tag.java index b0ea7e7dad7..20290257bc1 100644 --- a/src/main/java/seedu/address/model/tag/Tag.java +++ b/src/main/java/seedu/address/model/tag/Tag.java @@ -1,54 +1,54 @@ -package seedu.address.model.tag; - -import static java.util.Objects.requireNonNull; -import static seedu.address.commons.util.AppUtil.checkArgument; - -/** - * Represents a Tag in the address book. - * Guarantees: immutable; name is valid as declared in {@link #isValidTagName(String)} - */ -public class Tag { - - public static final String MESSAGE_CONSTRAINTS = "Tags names should be alphanumeric"; - public static final String VALIDATION_REGEX = "\\p{Alnum}+"; - - public final String tagName; - - /** - * Constructs a {@code Tag}. - * - * @param tagName A valid tag name. - */ - public Tag(String tagName) { - requireNonNull(tagName); - checkArgument(isValidTagName(tagName), MESSAGE_CONSTRAINTS); - this.tagName = tagName; - } - - /** - * Returns true if a given string is a valid tag name. - */ - public static boolean isValidTagName(String test) { - return test.matches(VALIDATION_REGEX); - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof Tag // instanceof handles nulls - && tagName.equals(((Tag) other).tagName)); // state check - } - - @Override - public int hashCode() { - return tagName.hashCode(); - } - - /** - * Format state as text for viewing. - */ - public String toString() { - return '[' + tagName + ']'; - } - -} +package seedu.address.model.tag; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; + +/** + * Represents a Tag in the address book. + * Guarantees: immutable; name is valid as declared in {@link #isValidTagName(String)} + */ +public class Tag { + + public static final String MESSAGE_CONSTRAINTS = "Tags names should be alphanumeric"; + public static final String VALIDATION_REGEX = "\\p{Alnum}+"; + + public final String tagName; + + /** + * Constructs a {@code Tag}. + * + * @param tagName A valid tag name. + */ + public Tag(String tagName) { + requireNonNull(tagName); + checkArgument(isValidTagName(tagName), MESSAGE_CONSTRAINTS); + this.tagName = tagName; + } + + /** + * Returns true if a given string is a valid tag name. + */ + public static boolean isValidTagName(String test) { + return test.matches(VALIDATION_REGEX); + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof Tag // instanceof handles nulls + && tagName.equals(((Tag) other).tagName)); // state check + } + + @Override + public int hashCode() { + return tagName.hashCode(); + } + + /** + * Format state as text for viewing. + */ + public String toString() { + return '[' + tagName + ']'; + } + +} diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 1806da4facf..955d9938765 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -1,60 +1,53 @@ -package seedu.address.model.util; - -import java.util.Arrays; -import java.util.Set; -import java.util.stream.Collectors; - -import seedu.address.model.AddressBook; -import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; -import seedu.address.model.tag.Tag; - -/** - * Contains utility methods for populating {@code AddressBook} with sample data. - */ -public class SampleDataUtil { - public static Person[] getSamplePersons() { - return new Person[] { - new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), - new Address("Blk 30 Geylang Street 29, #06-40"), - getTagSet("friends")), - new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), - new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), - getTagSet("colleagues", "friends")), - new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), - new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), - getTagSet("neighbours")), - new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), - new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), - getTagSet("family")), - new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), - new Address("Blk 47 Tampines Street 20, #17-35"), - getTagSet("classmates")), - new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), - new Address("Blk 45 Aljunied Street 85, #11-31"), - getTagSet("colleagues")) - }; - } - - public static ReadOnlyAddressBook getSampleAddressBook() { - AddressBook sampleAb = new AddressBook(); - for (Person samplePerson : getSamplePersons()) { - sampleAb.addPerson(samplePerson); - } - return sampleAb; - } - - /** - * Returns a tag set containing the list of strings given. - */ - public static Set getTagSet(String... strings) { - return Arrays.stream(strings) - .map(Tag::new) - .collect(Collectors.toSet()); - } - -} +package seedu.address.model.util; + +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; + +import seedu.address.model.AddressBook; +import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.person.Email; +import seedu.address.model.person.Name; +import seedu.address.model.person.Person; +import seedu.address.model.person.Phone; +import seedu.address.model.tag.Tag; + +/** + * Contains utility methods for populating {@code AddressBook} with sample data. + */ +public class SampleDataUtil { + public static Person[] getSamplePersons() { + return new Person[] { + new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), + getTagSet("friends")), + new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), + getTagSet("colleagues", "friends")), + new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), + getTagSet("neighbours")), + new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), + getTagSet("family")), + new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), + getTagSet("classmates")), + new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), + getTagSet("colleagues")) + }; + } + + public static ReadOnlyAddressBook getSampleAddressBook() { + AddressBook sampleAb = new AddressBook(); + for (Person samplePerson : getSamplePersons()) { + sampleAb.addPerson(samplePerson); + } + return sampleAb; + } + + /** + * Returns a tag set containing the list of strings given. + */ + public static Set getTagSet(String... strings) { + return Arrays.stream(strings) + .map(Tag::new) + .collect(Collectors.toSet()); + } + +} diff --git a/src/main/java/seedu/address/storage/AddressBookStorage.java b/src/main/java/seedu/address/storage/AddressBookStorage.java index 4599182b3f9..bd237086543 100644 --- a/src/main/java/seedu/address/storage/AddressBookStorage.java +++ b/src/main/java/seedu/address/storage/AddressBookStorage.java @@ -1,45 +1,45 @@ -package seedu.address.storage; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Optional; - -import seedu.address.commons.exceptions.DataConversionException; -import seedu.address.model.ReadOnlyAddressBook; - -/** - * Represents a storage for {@link seedu.address.model.AddressBook}. - */ -public interface AddressBookStorage { - - /** - * Returns the file path of the data file. - */ - Path getAddressBookFilePath(); - - /** - * Returns AddressBook data as a {@link ReadOnlyAddressBook}. - * Returns {@code Optional.empty()} if storage file is not found. - * @throws DataConversionException if the data in storage is not in the expected format. - * @throws IOException if there was any problem when reading from the storage. - */ - Optional readAddressBook() throws DataConversionException, IOException; - - /** - * @see #getAddressBookFilePath() - */ - Optional readAddressBook(Path filePath) throws DataConversionException, IOException; - - /** - * Saves the given {@link ReadOnlyAddressBook} to the storage. - * @param addressBook cannot be null. - * @throws IOException if there was any problem writing to the file. - */ - void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException; - - /** - * @see #saveAddressBook(ReadOnlyAddressBook) - */ - void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException; - -} +package seedu.address.storage; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Optional; + +import seedu.address.commons.exceptions.DataConversionException; +import seedu.address.model.ReadOnlyAddressBook; + +/** + * Represents a storage for {@link seedu.address.model.AddressBook}. + */ +public interface AddressBookStorage { + + /** + * Returns the file path of the data file. + */ + Path getAddressBookFilePath(); + + /** + * Returns AddressBook data as a {@link ReadOnlyAddressBook}. + * Returns {@code Optional.empty()} if storage file is not found. + * @throws DataConversionException if the data in storage is not in the expected format. + * @throws IOException if there was any problem when reading from the storage. + */ + Optional readAddressBook() throws DataConversionException, IOException; + + /** + * @see #getAddressBookFilePath() + */ + Optional readAddressBook(Path filePath) throws DataConversionException, IOException; + + /** + * Saves the given {@link ReadOnlyAddressBook} to the storage. + * @param addressBook cannot be null. + * @throws IOException if there was any problem writing to the file. + */ + void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException; + + /** + * @see #saveAddressBook(ReadOnlyAddressBook) + */ + void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException; + +} diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java index a6321cec2ea..776c7d43424 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java @@ -1,109 +1,97 @@ -package seedu.address.storage; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; -import seedu.address.model.tag.Tag; - -/** - * Jackson-friendly version of {@link Person}. - */ -class JsonAdaptedPerson { - - public static final String MISSING_FIELD_MESSAGE_FORMAT = "Person's %s field is missing!"; - - private final String name; - private final String phone; - private final String email; - private final String address; - private final List tagged = new ArrayList<>(); - - /** - * Constructs a {@code JsonAdaptedPerson} with the given person details. - */ - @JsonCreator - public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone, - @JsonProperty("email") String email, @JsonProperty("address") String address, - @JsonProperty("tagged") List tagged) { - this.name = name; - this.phone = phone; - this.email = email; - this.address = address; - if (tagged != null) { - this.tagged.addAll(tagged); - } - } - - /** - * Converts a given {@code Person} into this class for Jackson use. - */ - public JsonAdaptedPerson(Person source) { - name = source.getName().fullName; - phone = source.getPhone().value; - email = source.getEmail().value; - address = source.getAddress().value; - tagged.addAll(source.getTags().stream() - .map(JsonAdaptedTag::new) - .collect(Collectors.toList())); - } - - /** - * Converts this Jackson-friendly adapted person object into the model's {@code Person} object. - * - * @throws IllegalValueException if there were any data constraints violated in the adapted person. - */ - public Person toModelType() throws IllegalValueException { - final List personTags = new ArrayList<>(); - for (JsonAdaptedTag tag : tagged) { - personTags.add(tag.toModelType()); - } - - if (name == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName())); - } - if (!Name.isValidName(name)) { - throw new IllegalValueException(Name.MESSAGE_CONSTRAINTS); - } - final Name modelName = new Name(name); - - if (phone == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName())); - } - if (!Phone.isValidPhone(phone)) { - throw new IllegalValueException(Phone.MESSAGE_CONSTRAINTS); - } - final Phone modelPhone = new Phone(phone); - - if (email == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName())); - } - if (!Email.isValidEmail(email)) { - throw new IllegalValueException(Email.MESSAGE_CONSTRAINTS); - } - final Email modelEmail = new Email(email); - - if (address == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName())); - } - if (!Address.isValidAddress(address)) { - throw new IllegalValueException(Address.MESSAGE_CONSTRAINTS); - } - final Address modelAddress = new Address(address); - - final Set modelTags = new HashSet<>(personTags); - return new Person(modelName, modelPhone, modelEmail, modelAddress, modelTags); - } - -} +package seedu.address.storage; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.model.person.Email; +import seedu.address.model.person.Name; +import seedu.address.model.person.Person; +import seedu.address.model.person.Phone; +import seedu.address.model.tag.Tag; + +/** + * Jackson-friendly version of {@link Person}. + */ +class JsonAdaptedPerson { + + public static final String MISSING_FIELD_MESSAGE_FORMAT = "Person's %s field is missing!"; + + private final String name; + private final String phone; + private final String email; + private final List tagged = new ArrayList<>(); + + /** + * Constructs a {@code JsonAdaptedPerson} with the given person details. + */ + @JsonCreator + public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone, + @JsonProperty("email") String email, + @JsonProperty("tagged") List tagged) { + this.name = name; + this.phone = phone; + this.email = email; + if (tagged != null) { + this.tagged.addAll(tagged); + } + } + + /** + * Converts a given {@code Person} into this class for Jackson use. + */ + public JsonAdaptedPerson(Person source) { + name = source.getName().fullName; + phone = source.getPhone().value; + email = source.getEmail().value; + tagged.addAll(source.getTags().stream() + .map(JsonAdaptedTag::new) + .collect(Collectors.toList())); + } + + /** + * Converts this Jackson-friendly adapted person object into the model's {@code Person} object. + * + * @throws IllegalValueException if there were any data constraints violated in the adapted person. + */ + public Person toModelType() throws IllegalValueException { + final List personTags = new ArrayList<>(); + for (JsonAdaptedTag tag : tagged) { + personTags.add(tag.toModelType()); + } + + if (name == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName())); + } + if (!Name.isValidName(name)) { + throw new IllegalValueException(Name.MESSAGE_CONSTRAINTS); + } + final Name modelName = new Name(name); + + if (phone == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName())); + } + if (!Phone.isValidPhone(phone)) { + throw new IllegalValueException(Phone.MESSAGE_CONSTRAINTS); + } + final Phone modelPhone = new Phone(phone); + + if (email == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName())); + } + if (!Email.isValidEmail(email)) { + throw new IllegalValueException(Email.MESSAGE_CONSTRAINTS); + } + final Email modelEmail = new Email(email); + + final Set modelTags = new HashSet<>(personTags); + return new Person(modelName, modelPhone, modelEmail, modelTags); + } + +} diff --git a/src/main/java/seedu/address/storage/JsonAdaptedTag.java b/src/main/java/seedu/address/storage/JsonAdaptedTag.java index 0df22bdb754..67815371d72 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedTag.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedTag.java @@ -1,48 +1,48 @@ -package seedu.address.storage; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.tag.Tag; - -/** - * Jackson-friendly version of {@link Tag}. - */ -class JsonAdaptedTag { - - private final String tagName; - - /** - * Constructs a {@code JsonAdaptedTag} with the given {@code tagName}. - */ - @JsonCreator - public JsonAdaptedTag(String tagName) { - this.tagName = tagName; - } - - /** - * Converts a given {@code Tag} into this class for Jackson use. - */ - public JsonAdaptedTag(Tag source) { - tagName = source.tagName; - } - - @JsonValue - public String getTagName() { - return tagName; - } - - /** - * Converts this Jackson-friendly adapted tag object into the model's {@code Tag} object. - * - * @throws IllegalValueException if there were any data constraints violated in the adapted tag. - */ - public Tag toModelType() throws IllegalValueException { - if (!Tag.isValidTagName(tagName)) { - throw new IllegalValueException(Tag.MESSAGE_CONSTRAINTS); - } - return new Tag(tagName); - } - -} +package seedu.address.storage; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.model.tag.Tag; + +/** + * Jackson-friendly version of {@link Tag}. + */ +class JsonAdaptedTag { + + private final String tagName; + + /** + * Constructs a {@code JsonAdaptedTag} with the given {@code tagName}. + */ + @JsonCreator + public JsonAdaptedTag(String tagName) { + this.tagName = tagName; + } + + /** + * Converts a given {@code Tag} into this class for Jackson use. + */ + public JsonAdaptedTag(Tag source) { + tagName = source.tagName; + } + + @JsonValue + public String getTagName() { + return tagName; + } + + /** + * Converts this Jackson-friendly adapted tag object into the model's {@code Tag} object. + * + * @throws IllegalValueException if there were any data constraints violated in the adapted tag. + */ + public Tag toModelType() throws IllegalValueException { + if (!Tag.isValidTagName(tagName)) { + throw new IllegalValueException(Tag.MESSAGE_CONSTRAINTS); + } + return new Tag(tagName); + } + +} diff --git a/src/main/java/seedu/address/storage/JsonAddressBookStorage.java b/src/main/java/seedu/address/storage/JsonAddressBookStorage.java index dfab9daaa0d..ee0fc765e99 100644 --- a/src/main/java/seedu/address/storage/JsonAddressBookStorage.java +++ b/src/main/java/seedu/address/storage/JsonAddressBookStorage.java @@ -1,80 +1,80 @@ -package seedu.address.storage; - -import static java.util.Objects.requireNonNull; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Optional; -import java.util.logging.Logger; - -import seedu.address.commons.core.LogsCenter; -import seedu.address.commons.exceptions.DataConversionException; -import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.commons.util.FileUtil; -import seedu.address.commons.util.JsonUtil; -import seedu.address.model.ReadOnlyAddressBook; - -/** - * A class to access AddressBook data stored as a json file on the hard disk. - */ -public class JsonAddressBookStorage implements AddressBookStorage { - - private static final Logger logger = LogsCenter.getLogger(JsonAddressBookStorage.class); - - private Path filePath; - - public JsonAddressBookStorage(Path filePath) { - this.filePath = filePath; - } - - public Path getAddressBookFilePath() { - return filePath; - } - - @Override - public Optional readAddressBook() throws DataConversionException { - return readAddressBook(filePath); - } - - /** - * Similar to {@link #readAddressBook()}. - * - * @param filePath location of the data. Cannot be null. - * @throws DataConversionException if the file is not in the correct format. - */ - public Optional readAddressBook(Path filePath) throws DataConversionException { - requireNonNull(filePath); - - Optional jsonAddressBook = JsonUtil.readJsonFile( - filePath, JsonSerializableAddressBook.class); - if (!jsonAddressBook.isPresent()) { - return Optional.empty(); - } - - try { - return Optional.of(jsonAddressBook.get().toModelType()); - } catch (IllegalValueException ive) { - logger.info("Illegal values found in " + filePath + ": " + ive.getMessage()); - throw new DataConversionException(ive); - } - } - - @Override - public void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException { - saveAddressBook(addressBook, filePath); - } - - /** - * Similar to {@link #saveAddressBook(ReadOnlyAddressBook)}. - * - * @param filePath location of the data. Cannot be null. - */ - public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException { - requireNonNull(addressBook); - requireNonNull(filePath); - - FileUtil.createIfMissing(filePath); - JsonUtil.saveJsonFile(new JsonSerializableAddressBook(addressBook), filePath); - } - -} +package seedu.address.storage; + +import static java.util.Objects.requireNonNull; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Optional; +import java.util.logging.Logger; + +import seedu.address.commons.core.LogsCenter; +import seedu.address.commons.exceptions.DataConversionException; +import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.commons.util.FileUtil; +import seedu.address.commons.util.JsonUtil; +import seedu.address.model.ReadOnlyAddressBook; + +/** + * A class to access AddressBook data stored as a json file on the hard disk. + */ +public class JsonAddressBookStorage implements AddressBookStorage { + + private static final Logger logger = LogsCenter.getLogger(JsonAddressBookStorage.class); + + private Path filePath; + + public JsonAddressBookStorage(Path filePath) { + this.filePath = filePath; + } + + public Path getAddressBookFilePath() { + return filePath; + } + + @Override + public Optional readAddressBook() throws DataConversionException { + return readAddressBook(filePath); + } + + /** + * Similar to {@link #readAddressBook()}. + * + * @param filePath location of the data. Cannot be null. + * @throws DataConversionException if the file is not in the correct format. + */ + public Optional readAddressBook(Path filePath) throws DataConversionException { + requireNonNull(filePath); + + Optional jsonAddressBook = JsonUtil.readJsonFile( + filePath, JsonSerializableAddressBook.class); + if (!jsonAddressBook.isPresent()) { + return Optional.empty(); + } + + try { + return Optional.of(jsonAddressBook.get().toModelType()); + } catch (IllegalValueException ive) { + logger.info("Illegal values found in " + filePath + ": " + ive.getMessage()); + throw new DataConversionException(ive); + } + } + + @Override + public void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException { + saveAddressBook(addressBook, filePath); + } + + /** + * Similar to {@link #saveAddressBook(ReadOnlyAddressBook)}. + * + * @param filePath location of the data. Cannot be null. + */ + public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException { + requireNonNull(addressBook); + requireNonNull(filePath); + + FileUtil.createIfMissing(filePath); + JsonUtil.saveJsonFile(new JsonSerializableAddressBook(addressBook), filePath); + } + +} diff --git a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java index 5efd834091d..0a80de62bae 100644 --- a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java @@ -1,60 +1,60 @@ -package seedu.address.storage; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; - -import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.AddressBook; -import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.Person; - -/** - * An Immutable AddressBook that is serializable to JSON format. - */ -@JsonRootName(value = "addressbook") -class JsonSerializableAddressBook { - - public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate person(s)."; - - private final List persons = new ArrayList<>(); - - /** - * Constructs a {@code JsonSerializableAddressBook} with the given persons. - */ - @JsonCreator - public JsonSerializableAddressBook(@JsonProperty("persons") List persons) { - this.persons.addAll(persons); - } - - /** - * Converts a given {@code ReadOnlyAddressBook} into this class for Jackson use. - * - * @param source future changes to this will not affect the created {@code JsonSerializableAddressBook}. - */ - public JsonSerializableAddressBook(ReadOnlyAddressBook source) { - persons.addAll(source.getPersonList().stream().map(JsonAdaptedPerson::new).collect(Collectors.toList())); - } - - /** - * Converts this address book into the model's {@code AddressBook} object. - * - * @throws IllegalValueException if there were any data constraints violated. - */ - public AddressBook toModelType() throws IllegalValueException { - AddressBook addressBook = new AddressBook(); - for (JsonAdaptedPerson jsonAdaptedPerson : persons) { - Person person = jsonAdaptedPerson.toModelType(); - if (addressBook.hasPerson(person)) { - throw new IllegalValueException(MESSAGE_DUPLICATE_PERSON); - } - addressBook.addPerson(person); - } - return addressBook; - } - -} +package seedu.address.storage; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.model.AddressBook; +import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.person.Person; + +/** + * An Immutable AddressBook that is serializable to JSON format. + */ +@JsonRootName(value = "addressbook") +class JsonSerializableAddressBook { + + public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate person(s)."; + + private final List persons = new ArrayList<>(); + + /** + * Constructs a {@code JsonSerializableAddressBook} with the given persons. + */ + @JsonCreator + public JsonSerializableAddressBook(@JsonProperty("persons") List persons) { + this.persons.addAll(persons); + } + + /** + * Converts a given {@code ReadOnlyAddressBook} into this class for Jackson use. + * + * @param source future changes to this will not affect the created {@code JsonSerializableAddressBook}. + */ + public JsonSerializableAddressBook(ReadOnlyAddressBook source) { + persons.addAll(source.getPersonList().stream().map(JsonAdaptedPerson::new).collect(Collectors.toList())); + } + + /** + * Converts this address book into the model's {@code AddressBook} object. + * + * @throws IllegalValueException if there were any data constraints violated. + */ + public AddressBook toModelType() throws IllegalValueException { + AddressBook addressBook = new AddressBook(); + for (JsonAdaptedPerson jsonAdaptedPerson : persons) { + Person person = jsonAdaptedPerson.toModelType(); + if (addressBook.hasPerson(person)) { + throw new IllegalValueException(MESSAGE_DUPLICATE_PERSON); + } + addressBook.addPerson(person); + } + return addressBook; + } + +} diff --git a/src/main/java/seedu/address/storage/JsonUserPrefsStorage.java b/src/main/java/seedu/address/storage/JsonUserPrefsStorage.java index bc2bbad84aa..c0f2922e648 100644 --- a/src/main/java/seedu/address/storage/JsonUserPrefsStorage.java +++ b/src/main/java/seedu/address/storage/JsonUserPrefsStorage.java @@ -1,47 +1,47 @@ -package seedu.address.storage; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Optional; - -import seedu.address.commons.exceptions.DataConversionException; -import seedu.address.commons.util.JsonUtil; -import seedu.address.model.ReadOnlyUserPrefs; -import seedu.address.model.UserPrefs; - -/** - * A class to access UserPrefs stored in the hard disk as a json file - */ -public class JsonUserPrefsStorage implements UserPrefsStorage { - - private Path filePath; - - public JsonUserPrefsStorage(Path filePath) { - this.filePath = filePath; - } - - @Override - public Path getUserPrefsFilePath() { - return filePath; - } - - @Override - public Optional readUserPrefs() throws DataConversionException { - return readUserPrefs(filePath); - } - - /** - * Similar to {@link #readUserPrefs()} - * @param prefsFilePath location of the data. Cannot be null. - * @throws DataConversionException if the file format is not as expected. - */ - public Optional readUserPrefs(Path prefsFilePath) throws DataConversionException { - return JsonUtil.readJsonFile(prefsFilePath, UserPrefs.class); - } - - @Override - public void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException { - JsonUtil.saveJsonFile(userPrefs, filePath); - } - -} +package seedu.address.storage; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Optional; + +import seedu.address.commons.exceptions.DataConversionException; +import seedu.address.commons.util.JsonUtil; +import seedu.address.model.ReadOnlyUserPrefs; +import seedu.address.model.UserPrefs; + +/** + * A class to access UserPrefs stored in the hard disk as a json file + */ +public class JsonUserPrefsStorage implements UserPrefsStorage { + + private Path filePath; + + public JsonUserPrefsStorage(Path filePath) { + this.filePath = filePath; + } + + @Override + public Path getUserPrefsFilePath() { + return filePath; + } + + @Override + public Optional readUserPrefs() throws DataConversionException { + return readUserPrefs(filePath); + } + + /** + * Similar to {@link #readUserPrefs()} + * @param prefsFilePath location of the data. Cannot be null. + * @throws DataConversionException if the file format is not as expected. + */ + public Optional readUserPrefs(Path prefsFilePath) throws DataConversionException { + return JsonUtil.readJsonFile(prefsFilePath, UserPrefs.class); + } + + @Override + public void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException { + JsonUtil.saveJsonFile(userPrefs, filePath); + } + +} diff --git a/src/main/java/seedu/address/storage/Storage.java b/src/main/java/seedu/address/storage/Storage.java index beda8bd9f11..fe83cda7cbd 100644 --- a/src/main/java/seedu/address/storage/Storage.java +++ b/src/main/java/seedu/address/storage/Storage.java @@ -1,32 +1,32 @@ -package seedu.address.storage; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Optional; - -import seedu.address.commons.exceptions.DataConversionException; -import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.ReadOnlyUserPrefs; -import seedu.address.model.UserPrefs; - -/** - * API of the Storage component - */ -public interface Storage extends AddressBookStorage, UserPrefsStorage { - - @Override - Optional readUserPrefs() throws DataConversionException, IOException; - - @Override - void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException; - - @Override - Path getAddressBookFilePath(); - - @Override - Optional readAddressBook() throws DataConversionException, IOException; - - @Override - void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException; - -} +package seedu.address.storage; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Optional; + +import seedu.address.commons.exceptions.DataConversionException; +import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyUserPrefs; +import seedu.address.model.UserPrefs; + +/** + * API of the Storage component + */ +public interface Storage extends AddressBookStorage, UserPrefsStorage { + + @Override + Optional readUserPrefs() throws DataConversionException, IOException; + + @Override + void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException; + + @Override + Path getAddressBookFilePath(); + + @Override + Optional readAddressBook() throws DataConversionException, IOException; + + @Override + void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException; + +} diff --git a/src/main/java/seedu/address/storage/StorageManager.java b/src/main/java/seedu/address/storage/StorageManager.java index e4f452b6cbf..0fe2cfa29a2 100644 --- a/src/main/java/seedu/address/storage/StorageManager.java +++ b/src/main/java/seedu/address/storage/StorageManager.java @@ -1,77 +1,77 @@ -package seedu.address.storage; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Optional; -import java.util.logging.Logger; - -import seedu.address.commons.core.LogsCenter; -import seedu.address.commons.exceptions.DataConversionException; -import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.ReadOnlyUserPrefs; -import seedu.address.model.UserPrefs; - -/** - * Manages storage of AddressBook data in local storage. - */ -public class StorageManager implements Storage { - - private static final Logger logger = LogsCenter.getLogger(StorageManager.class); - private AddressBookStorage addressBookStorage; - private UserPrefsStorage userPrefsStorage; - - - public StorageManager(AddressBookStorage addressBookStorage, UserPrefsStorage userPrefsStorage) { - super(); - this.addressBookStorage = addressBookStorage; - this.userPrefsStorage = userPrefsStorage; - } - - // ================ UserPrefs methods ============================== - - @Override - public Path getUserPrefsFilePath() { - return userPrefsStorage.getUserPrefsFilePath(); - } - - @Override - public Optional readUserPrefs() throws DataConversionException, IOException { - return userPrefsStorage.readUserPrefs(); - } - - @Override - public void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException { - userPrefsStorage.saveUserPrefs(userPrefs); - } - - - // ================ AddressBook methods ============================== - - @Override - public Path getAddressBookFilePath() { - return addressBookStorage.getAddressBookFilePath(); - } - - @Override - public Optional readAddressBook() throws DataConversionException, IOException { - return readAddressBook(addressBookStorage.getAddressBookFilePath()); - } - - @Override - public Optional readAddressBook(Path filePath) throws DataConversionException, IOException { - logger.fine("Attempting to read data from file: " + filePath); - return addressBookStorage.readAddressBook(filePath); - } - - @Override - public void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException { - saveAddressBook(addressBook, addressBookStorage.getAddressBookFilePath()); - } - - @Override - public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException { - logger.fine("Attempting to write to data file: " + filePath); - addressBookStorage.saveAddressBook(addressBook, filePath); - } - -} +package seedu.address.storage; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Optional; +import java.util.logging.Logger; + +import seedu.address.commons.core.LogsCenter; +import seedu.address.commons.exceptions.DataConversionException; +import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyUserPrefs; +import seedu.address.model.UserPrefs; + +/** + * Manages storage of AddressBook data in local storage. + */ +public class StorageManager implements Storage { + + private static final Logger logger = LogsCenter.getLogger(StorageManager.class); + private AddressBookStorage addressBookStorage; + private UserPrefsStorage userPrefsStorage; + + + public StorageManager(AddressBookStorage addressBookStorage, UserPrefsStorage userPrefsStorage) { + super(); + this.addressBookStorage = addressBookStorage; + this.userPrefsStorage = userPrefsStorage; + } + + // ================ UserPrefs methods ============================== + + @Override + public Path getUserPrefsFilePath() { + return userPrefsStorage.getUserPrefsFilePath(); + } + + @Override + public Optional readUserPrefs() throws DataConversionException, IOException { + return userPrefsStorage.readUserPrefs(); + } + + @Override + public void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException { + userPrefsStorage.saveUserPrefs(userPrefs); + } + + + // ================ AddressBook methods ============================== + + @Override + public Path getAddressBookFilePath() { + return addressBookStorage.getAddressBookFilePath(); + } + + @Override + public Optional readAddressBook() throws DataConversionException, IOException { + return readAddressBook(addressBookStorage.getAddressBookFilePath()); + } + + @Override + public Optional readAddressBook(Path filePath) throws DataConversionException, IOException { + logger.fine("Attempting to read data from file: " + filePath); + return addressBookStorage.readAddressBook(filePath); + } + + @Override + public void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException { + saveAddressBook(addressBook, addressBookStorage.getAddressBookFilePath()); + } + + @Override + public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException { + logger.fine("Attempting to write to data file: " + filePath); + addressBookStorage.saveAddressBook(addressBook, filePath); + } + +} diff --git a/src/main/java/seedu/address/storage/UserPrefsStorage.java b/src/main/java/seedu/address/storage/UserPrefsStorage.java index 29eef178dbc..a691f6408fb 100644 --- a/src/main/java/seedu/address/storage/UserPrefsStorage.java +++ b/src/main/java/seedu/address/storage/UserPrefsStorage.java @@ -1,36 +1,36 @@ -package seedu.address.storage; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Optional; - -import seedu.address.commons.exceptions.DataConversionException; -import seedu.address.model.ReadOnlyUserPrefs; -import seedu.address.model.UserPrefs; - -/** - * Represents a storage for {@link seedu.address.model.UserPrefs}. - */ -public interface UserPrefsStorage { - - /** - * Returns the file path of the UserPrefs data file. - */ - Path getUserPrefsFilePath(); - - /** - * Returns UserPrefs data from storage. - * Returns {@code Optional.empty()} if storage file is not found. - * @throws DataConversionException if the data in storage is not in the expected format. - * @throws IOException if there was any problem when reading from the storage. - */ - Optional readUserPrefs() throws DataConversionException, IOException; - - /** - * Saves the given {@link seedu.address.model.ReadOnlyUserPrefs} to the storage. - * @param userPrefs cannot be null. - * @throws IOException if there was any problem writing to the file. - */ - void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException; - -} +package seedu.address.storage; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Optional; + +import seedu.address.commons.exceptions.DataConversionException; +import seedu.address.model.ReadOnlyUserPrefs; +import seedu.address.model.UserPrefs; + +/** + * Represents a storage for {@link seedu.address.model.UserPrefs}. + */ +public interface UserPrefsStorage { + + /** + * Returns the file path of the UserPrefs data file. + */ + Path getUserPrefsFilePath(); + + /** + * Returns UserPrefs data from storage. + * Returns {@code Optional.empty()} if storage file is not found. + * @throws DataConversionException if the data in storage is not in the expected format. + * @throws IOException if there was any problem when reading from the storage. + */ + Optional readUserPrefs() throws DataConversionException, IOException; + + /** + * Saves the given {@link seedu.address.model.ReadOnlyUserPrefs} to the storage. + * @param userPrefs cannot be null. + * @throws IOException if there was any problem writing to the file. + */ + void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException; + +} diff --git a/src/main/java/seedu/address/ui/CommandBox.java b/src/main/java/seedu/address/ui/CommandBox.java index 7d76e691f52..a74be65231f 100644 --- a/src/main/java/seedu/address/ui/CommandBox.java +++ b/src/main/java/seedu/address/ui/CommandBox.java @@ -1,77 +1,77 @@ -package seedu.address.ui; - -import javafx.collections.ObservableList; -import javafx.fxml.FXML; -import javafx.scene.control.TextField; -import javafx.scene.layout.Region; -import seedu.address.logic.commands.CommandResult; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.logic.parser.exceptions.ParseException; - -/** - * The UI component that is responsible for receiving user command inputs. - */ -public class CommandBox extends UiPart { - - public static final String ERROR_STYLE_CLASS = "error"; - private static final String FXML = "CommandBox.fxml"; - - private final CommandExecutor commandExecutor; - - @FXML - private TextField commandTextField; - - public CommandBox(CommandExecutor commandExecutor) { - super(FXML); - this.commandExecutor = commandExecutor; - // calls #setStyleToDefault() whenever there is a change to the text of the command box. - commandTextField.textProperty().addListener((unused1, unused2, unused3) -> setStyleToDefault()); - } - - /** - * Handles the Enter button pressed event. - */ - @FXML - private void handleCommandEntered() { - try { - commandExecutor.execute(commandTextField.getText()); - commandTextField.setText(""); - } catch (CommandException | ParseException e) { - setStyleToIndicateCommandFailure(); - } - } - - /** - * Sets the command box style to use the default style. - */ - private void setStyleToDefault() { - commandTextField.getStyleClass().remove(ERROR_STYLE_CLASS); - } - - /** - * Sets the command box style to indicate a failed command. - */ - private void setStyleToIndicateCommandFailure() { - ObservableList styleClass = commandTextField.getStyleClass(); - - if (styleClass.contains(ERROR_STYLE_CLASS)) { - return; - } - - styleClass.add(ERROR_STYLE_CLASS); - } - - /** - * Represents a function that can execute commands. - */ - @FunctionalInterface - public interface CommandExecutor { - /** - * Executes the command and returns the result. - * - * @see seedu.address.logic.Logic#execute(String) - */ - CommandResult execute(String commandText) throws CommandException, ParseException; - } - -} +package seedu.address.ui; + +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.scene.control.TextField; +import javafx.scene.layout.Region; +import seedu.address.logic.commands.CommandResult; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.logic.parser.exceptions.ParseException; + +/** + * The UI component that is responsible for receiving user command inputs. + */ +public class CommandBox extends UiPart { + + public static final String ERROR_STYLE_CLASS = "error"; + private static final String FXML = "CommandBox.fxml"; + + private final CommandExecutor commandExecutor; + + @FXML + private TextField commandTextField; + + public CommandBox(CommandExecutor commandExecutor) { + super(FXML); + this.commandExecutor = commandExecutor; + // calls #setStyleToDefault() whenever there is a change to the text of the command box. + commandTextField.textProperty().addListener((unused1, unused2, unused3) -> setStyleToDefault()); + } + + /** + * Handles the Enter button pressed event. + */ + @FXML + private void handleCommandEntered() { + try { + commandExecutor.execute(commandTextField.getText()); + commandTextField.setText(""); + } catch (CommandException | ParseException e) { + setStyleToIndicateCommandFailure(); + } + } + + /** + * Sets the command box style to use the default style. + */ + private void setStyleToDefault() { + commandTextField.getStyleClass().remove(ERROR_STYLE_CLASS); + } + + /** + * Sets the command box style to indicate a failed command. + */ + private void setStyleToIndicateCommandFailure() { + ObservableList styleClass = commandTextField.getStyleClass(); + + if (styleClass.contains(ERROR_STYLE_CLASS)) { + return; + } + + styleClass.add(ERROR_STYLE_CLASS); + } + + /** + * Represents a function that can execute commands. + */ + @FunctionalInterface + public interface CommandExecutor { + /** + * Executes the command and returns the result. + * + * @see seedu.address.logic.Logic#execute(String) + */ + CommandResult execute(String commandText) throws CommandException, ParseException; + } + +} diff --git a/src/main/java/seedu/address/ui/HelpWindow.java b/src/main/java/seedu/address/ui/HelpWindow.java index 9a665915949..8ce022e227c 100644 --- a/src/main/java/seedu/address/ui/HelpWindow.java +++ b/src/main/java/seedu/address/ui/HelpWindow.java @@ -1,102 +1,102 @@ -package seedu.address.ui; - -import java.util.logging.Logger; - -import javafx.fxml.FXML; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.input.Clipboard; -import javafx.scene.input.ClipboardContent; -import javafx.stage.Stage; -import seedu.address.commons.core.LogsCenter; - -/** - * Controller for a help page - */ -public class HelpWindow extends UiPart { - - public static final String USERGUIDE_URL = "https://se-education.org/addressbook-level3/UserGuide.html"; - public static final String HELP_MESSAGE = "Refer to the user guide: " + USERGUIDE_URL; - - private static final Logger logger = LogsCenter.getLogger(HelpWindow.class); - private static final String FXML = "HelpWindow.fxml"; - - @FXML - private Button copyButton; - - @FXML - private Label helpMessage; - - /** - * Creates a new HelpWindow. - * - * @param root Stage to use as the root of the HelpWindow. - */ - public HelpWindow(Stage root) { - super(FXML, root); - helpMessage.setText(HELP_MESSAGE); - } - - /** - * Creates a new HelpWindow. - */ - public HelpWindow() { - this(new Stage()); - } - - /** - * Shows the help window. - * @throws IllegalStateException - *
    - *
  • - * if this method is called on a thread other than the JavaFX Application Thread. - *
  • - *
  • - * if this method is called during animation or layout processing. - *
  • - *
  • - * if this method is called on the primary stage. - *
  • - *
  • - * if {@code dialogStage} is already showing. - *
  • - *
- */ - public void show() { - logger.fine("Showing help page about the application."); - getRoot().show(); - getRoot().centerOnScreen(); - } - - /** - * Returns true if the help window is currently being shown. - */ - public boolean isShowing() { - return getRoot().isShowing(); - } - - /** - * Hides the help window. - */ - public void hide() { - getRoot().hide(); - } - - /** - * Focuses on the help window. - */ - public void focus() { - getRoot().requestFocus(); - } - - /** - * Copies the URL to the user guide to the clipboard. - */ - @FXML - private void copyUrl() { - final Clipboard clipboard = Clipboard.getSystemClipboard(); - final ClipboardContent url = new ClipboardContent(); - url.putString(USERGUIDE_URL); - clipboard.setContent(url); - } -} +package seedu.address.ui; + +import java.util.logging.Logger; + +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.input.Clipboard; +import javafx.scene.input.ClipboardContent; +import javafx.stage.Stage; +import seedu.address.commons.core.LogsCenter; + +/** + * Controller for a help page + */ +public class HelpWindow extends UiPart { + + public static final String USERGUIDE_URL = "https://se-education.org/addressbook-level3/UserGuide.html"; + public static final String HELP_MESSAGE = "Refer to the user guide: " + USERGUIDE_URL; + + private static final Logger logger = LogsCenter.getLogger(HelpWindow.class); + private static final String FXML = "HelpWindow.fxml"; + + @FXML + private Button copyButton; + + @FXML + private Label helpMessage; + + /** + * Creates a new HelpWindow. + * + * @param root Stage to use as the root of the HelpWindow. + */ + public HelpWindow(Stage root) { + super(FXML, root); + helpMessage.setText(HELP_MESSAGE); + } + + /** + * Creates a new HelpWindow. + */ + public HelpWindow() { + this(new Stage()); + } + + /** + * Shows the help window. + * @throws IllegalStateException + *
    + *
  • + * if this method is called on a thread other than the JavaFX Application Thread. + *
  • + *
  • + * if this method is called during animation or layout processing. + *
  • + *
  • + * if this method is called on the primary stage. + *
  • + *
  • + * if {@code dialogStage} is already showing. + *
  • + *
+ */ + public void show() { + logger.fine("Showing help page about the application."); + getRoot().show(); + getRoot().centerOnScreen(); + } + + /** + * Returns true if the help window is currently being shown. + */ + public boolean isShowing() { + return getRoot().isShowing(); + } + + /** + * Hides the help window. + */ + public void hide() { + getRoot().hide(); + } + + /** + * Focuses on the help window. + */ + public void focus() { + getRoot().requestFocus(); + } + + /** + * Copies the URL to the user guide to the clipboard. + */ + @FXML + private void copyUrl() { + final Clipboard clipboard = Clipboard.getSystemClipboard(); + final ClipboardContent url = new ClipboardContent(); + url.putString(USERGUIDE_URL); + clipboard.setContent(url); + } +} diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 90bbf11de97..ed5597c84c8 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -1,193 +1,193 @@ -package seedu.address.ui; - -import java.util.logging.Logger; - -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.scene.control.MenuItem; -import javafx.scene.control.TextInputControl; -import javafx.scene.input.KeyCombination; -import javafx.scene.input.KeyEvent; -import javafx.scene.layout.StackPane; -import javafx.stage.Stage; -import seedu.address.commons.core.GuiSettings; -import seedu.address.commons.core.LogsCenter; -import seedu.address.logic.Logic; -import seedu.address.logic.commands.CommandResult; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.logic.parser.exceptions.ParseException; - -/** - * The Main Window. Provides the basic application layout containing - * a menu bar and space where other JavaFX elements can be placed. - */ -public class MainWindow extends UiPart { - - private static final String FXML = "MainWindow.fxml"; - - private final Logger logger = LogsCenter.getLogger(getClass()); - - private Stage primaryStage; - private Logic logic; - - // Independent Ui parts residing in this Ui container - private PersonListPanel personListPanel; - private ResultDisplay resultDisplay; - private HelpWindow helpWindow; - - @FXML - private StackPane commandBoxPlaceholder; - - @FXML - private MenuItem helpMenuItem; - - @FXML - private StackPane personListPanelPlaceholder; - - @FXML - private StackPane resultDisplayPlaceholder; - - @FXML - private StackPane statusbarPlaceholder; - - public MainWindow(Stage primaryStage, Logic logic) { - super(FXML, primaryStage); - - // Set dependencies - this.primaryStage = primaryStage; - this.logic = logic; - - // Configure the UI - setWindowDefaultSize(logic.getGuiSettings()); - - setAccelerators(); - - helpWindow = new HelpWindow(); - } - - public Stage getPrimaryStage() { - return primaryStage; - } - - private void setAccelerators() { - setAccelerator(helpMenuItem, KeyCombination.valueOf("F1")); - } - - /** - * Sets the accelerator of a MenuItem. - * @param keyCombination the KeyCombination value of the accelerator - */ - private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) { - menuItem.setAccelerator(keyCombination); - - /* - * TODO: the code below can be removed once the bug reported here - * https://bugs.openjdk.java.net/browse/JDK-8131666 - * is fixed in later version of SDK. - * - * According to the bug report, TextInputControl (TextField, TextArea) will - * consume function-key events. Because CommandBox contains a TextField, and - * ResultDisplay contains a TextArea, thus some accelerators (e.g F1) will - * not work when the focus is in them because the key event is consumed by - * the TextInputControl(s). - * - * For now, we add following event filter to capture such key events and open - * help window purposely so to support accelerators even when focus is - * in CommandBox or ResultDisplay. - */ - getRoot().addEventFilter(KeyEvent.KEY_PRESSED, event -> { - if (event.getTarget() instanceof TextInputControl && keyCombination.match(event)) { - menuItem.getOnAction().handle(new ActionEvent()); - event.consume(); - } - }); - } - - /** - * Fills up all the placeholders of this window. - */ - void fillInnerParts() { - personListPanel = new PersonListPanel(logic.getFilteredPersonList()); - personListPanelPlaceholder.getChildren().add(personListPanel.getRoot()); - - resultDisplay = new ResultDisplay(); - resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot()); - - StatusBarFooter statusBarFooter = new StatusBarFooter(logic.getAddressBookFilePath()); - statusbarPlaceholder.getChildren().add(statusBarFooter.getRoot()); - - CommandBox commandBox = new CommandBox(this::executeCommand); - commandBoxPlaceholder.getChildren().add(commandBox.getRoot()); - } - - /** - * Sets the default size based on {@code guiSettings}. - */ - private void setWindowDefaultSize(GuiSettings guiSettings) { - primaryStage.setHeight(guiSettings.getWindowHeight()); - primaryStage.setWidth(guiSettings.getWindowWidth()); - if (guiSettings.getWindowCoordinates() != null) { - primaryStage.setX(guiSettings.getWindowCoordinates().getX()); - primaryStage.setY(guiSettings.getWindowCoordinates().getY()); - } - } - - /** - * Opens the help window or focuses on it if it's already opened. - */ - @FXML - public void handleHelp() { - if (!helpWindow.isShowing()) { - helpWindow.show(); - } else { - helpWindow.focus(); - } - } - - void show() { - primaryStage.show(); - } - - /** - * Closes the application. - */ - @FXML - private void handleExit() { - GuiSettings guiSettings = new GuiSettings(primaryStage.getWidth(), primaryStage.getHeight(), - (int) primaryStage.getX(), (int) primaryStage.getY()); - logic.setGuiSettings(guiSettings); - helpWindow.hide(); - primaryStage.hide(); - } - - public PersonListPanel getPersonListPanel() { - return personListPanel; - } - - /** - * Executes the command and returns the result. - * - * @see seedu.address.logic.Logic#execute(String) - */ - private CommandResult executeCommand(String commandText) throws CommandException, ParseException { - try { - CommandResult commandResult = logic.execute(commandText); - logger.info("Result: " + commandResult.getFeedbackToUser()); - resultDisplay.setFeedbackToUser(commandResult.getFeedbackToUser()); - - if (commandResult.isShowHelp()) { - handleHelp(); - } - - if (commandResult.isExit()) { - handleExit(); - } - - return commandResult; - } catch (CommandException | ParseException e) { - logger.info("Invalid command: " + commandText); - resultDisplay.setFeedbackToUser(e.getMessage()); - throw e; - } - } -} +package seedu.address.ui; + +import java.util.logging.Logger; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.MenuItem; +import javafx.scene.control.TextInputControl; +import javafx.scene.input.KeyCombination; +import javafx.scene.input.KeyEvent; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; +import seedu.address.commons.core.GuiSettings; +import seedu.address.commons.core.LogsCenter; +import seedu.address.logic.Logic; +import seedu.address.logic.commands.CommandResult; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.logic.parser.exceptions.ParseException; + +/** + * The Main Window. Provides the basic application layout containing + * a menu bar and space where other JavaFX elements can be placed. + */ +public class MainWindow extends UiPart { + + private static final String FXML = "MainWindow.fxml"; + + private final Logger logger = LogsCenter.getLogger(getClass()); + + private Stage primaryStage; + private Logic logic; + + // Independent Ui parts residing in this Ui container + private PersonListPanel personListPanel; + private ResultDisplay resultDisplay; + private HelpWindow helpWindow; + + @FXML + private StackPane commandBoxPlaceholder; + + @FXML + private MenuItem helpMenuItem; + + @FXML + private StackPane personListPanelPlaceholder; + + @FXML + private StackPane resultDisplayPlaceholder; + + @FXML + private StackPane statusbarPlaceholder; + + public MainWindow(Stage primaryStage, Logic logic) { + super(FXML, primaryStage); + + // Set dependencies + this.primaryStage = primaryStage; + this.logic = logic; + + // Configure the UI + setWindowDefaultSize(logic.getGuiSettings()); + + setAccelerators(); + + helpWindow = new HelpWindow(); + } + + public Stage getPrimaryStage() { + return primaryStage; + } + + private void setAccelerators() { + setAccelerator(helpMenuItem, KeyCombination.valueOf("F1")); + } + + /** + * Sets the accelerator of a MenuItem. + * @param keyCombination the KeyCombination value of the accelerator + */ + private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) { + menuItem.setAccelerator(keyCombination); + + /* + * TODO: the code below can be removed once the bug reported here + * https://bugs.openjdk.java.net/browse/JDK-8131666 + * is fixed in later version of SDK. + * + * According to the bug report, TextInputControl (TextField, TextArea) will + * consume function-key events. Because CommandBox contains a TextField, and + * ResultDisplay contains a TextArea, thus some accelerators (e.g F1) will + * not work when the focus is in them because the key event is consumed by + * the TextInputControl(s). + * + * For now, we add following event filter to capture such key events and open + * help window purposely so to support accelerators even when focus is + * in CommandBox or ResultDisplay. + */ + getRoot().addEventFilter(KeyEvent.KEY_PRESSED, event -> { + if (event.getTarget() instanceof TextInputControl && keyCombination.match(event)) { + menuItem.getOnAction().handle(new ActionEvent()); + event.consume(); + } + }); + } + + /** + * Fills up all the placeholders of this window. + */ + void fillInnerParts() { + personListPanel = new PersonListPanel(logic.getFilteredPersonList()); + personListPanelPlaceholder.getChildren().add(personListPanel.getRoot()); + + resultDisplay = new ResultDisplay(); + resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot()); + + StatusBarFooter statusBarFooter = new StatusBarFooter(logic.getAddressBookFilePath()); + statusbarPlaceholder.getChildren().add(statusBarFooter.getRoot()); + + CommandBox commandBox = new CommandBox(this::executeCommand); + commandBoxPlaceholder.getChildren().add(commandBox.getRoot()); + } + + /** + * Sets the default size based on {@code guiSettings}. + */ + private void setWindowDefaultSize(GuiSettings guiSettings) { + primaryStage.setHeight(guiSettings.getWindowHeight()); + primaryStage.setWidth(guiSettings.getWindowWidth()); + if (guiSettings.getWindowCoordinates() != null) { + primaryStage.setX(guiSettings.getWindowCoordinates().getX()); + primaryStage.setY(guiSettings.getWindowCoordinates().getY()); + } + } + + /** + * Opens the help window or focuses on it if it's already opened. + */ + @FXML + public void handleHelp() { + if (!helpWindow.isShowing()) { + helpWindow.show(); + } else { + helpWindow.focus(); + } + } + + void show() { + primaryStage.show(); + } + + /** + * Closes the application. + */ + @FXML + private void handleExit() { + GuiSettings guiSettings = new GuiSettings(primaryStage.getWidth(), primaryStage.getHeight(), + (int) primaryStage.getX(), (int) primaryStage.getY()); + logic.setGuiSettings(guiSettings); + helpWindow.hide(); + primaryStage.hide(); + } + + public PersonListPanel getPersonListPanel() { + return personListPanel; + } + + /** + * Executes the command and returns the result. + * + * @see seedu.address.logic.Logic#execute(String) + */ + private CommandResult executeCommand(String commandText) throws CommandException, ParseException { + try { + CommandResult commandResult = logic.execute(commandText); + logger.info("Result: " + commandResult.getFeedbackToUser()); + resultDisplay.setFeedbackToUser(commandResult.getFeedbackToUser()); + + if (commandResult.isShowHelp()) { + handleHelp(); + } + + if (commandResult.isExit()) { + handleExit(); + } + + return commandResult; + } catch (CommandException | ParseException e) { + logger.info("Invalid command: " + commandText); + resultDisplay.setFeedbackToUser(e.getMessage()); + throw e; + } + } +} diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 0684b088868..9c044711450 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -1,74 +1,71 @@ -package seedu.address.ui; - -import java.util.Comparator; - -import javafx.fxml.FXML; -import javafx.scene.control.Label; -import javafx.scene.layout.FlowPane; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Region; -import seedu.address.model.person.Person; - -/** - * An UI component that displays information of a {@code Person}. - */ -public class PersonCard extends UiPart { - - private static final String FXML = "PersonListCard.fxml"; - - /** - * Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX. - * As a consequence, UI elements' variable names cannot be set to such keywords - * or an exception will be thrown by JavaFX during runtime. - * - * @see
The issue on AddressBook level 4 - */ - - public final Person person; - - @FXML - private HBox cardPane; - @FXML - private Label name; - @FXML - private Label id; - @FXML - private Label phone; - @FXML - private Label address; - @FXML - private Label email; - @FXML - private FlowPane tags; - - public PersonCard(Person person, int displayedIndex) { - super(FXML); - this.person = person; - id.setText(displayedIndex + ". "); - name.setText(person.getName().fullName); - phone.setText(person.getPhone().value); - address.setText(person.getAddress().value); - email.setText(person.getEmail().value); - person.getTags().stream() - .sorted(Comparator.comparing(tag -> tag.tagName)) - .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); - } - - @Override - public boolean equals(Object other) { - // short circuit if same object - if (other == this) { - return true; - } - - // instanceof handles nulls - if (!(other instanceof PersonCard)) { - return false; - } - - // state check - PersonCard card = (PersonCard) other; - return id.getText().equals(card.id.getText()) - && person.equals(card.person); - } -} +package seedu.address.ui; + +import java.util.Comparator; + +import javafx.fxml.FXML; +import javafx.scene.control.Label; +import javafx.scene.layout.FlowPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Region; +import seedu.address.model.person.Person; + +/** + * An UI component that displays information of a {@code Person}. + */ +public class PersonCard extends UiPart { + + private static final String FXML = "PersonListCard.fxml"; + + /** + * Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX. + * As a consequence, UI elements' variable names cannot be set to such keywords + * or an exception will be thrown by JavaFX during runtime. + * + * @see The issue on AddressBook level 4 + */ + + public final Person person; + + @FXML + private HBox cardPane; + @FXML + private Label name; + @FXML + private Label id; + @FXML + private Label phone; + @FXML + private Label email; + @FXML + private FlowPane tags; + + public PersonCard(Person person, int displayedIndex) { + super(FXML); + this.person = person; + id.setText(displayedIndex + ". "); + name.setText(person.getName().fullName); + phone.setText(person.getPhone().value); + email.setText(person.getEmail().value); + person.getTags().stream() + .sorted(Comparator.comparing(tag -> tag.tagName)) + .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); + } + + @Override + public boolean equals(Object other) { + // short circuit if same object + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof PersonCard)) { + return false; + } + + // state check + PersonCard card = (PersonCard) other; + return id.getText().equals(card.id.getText()) + && person.equals(card.person); + } +} diff --git a/src/main/java/seedu/address/ui/PersonListPanel.java b/src/main/java/seedu/address/ui/PersonListPanel.java index 1328917096e..21fb56490c1 100644 --- a/src/main/java/seedu/address/ui/PersonListPanel.java +++ b/src/main/java/seedu/address/ui/PersonListPanel.java @@ -1,46 +1,46 @@ -package seedu.address.ui; - -import java.util.logging.Logger; - -import javafx.collections.ObservableList; -import javafx.fxml.FXML; -import javafx.scene.control.ListCell; -import javafx.scene.control.ListView; -import javafx.scene.layout.Region; -import seedu.address.commons.core.LogsCenter; -import seedu.address.model.person.Person; - -/** - * Panel containing the list of persons. - */ -public class PersonListPanel extends UiPart { - private static final String FXML = "PersonListPanel.fxml"; - private final Logger logger = LogsCenter.getLogger(PersonListPanel.class); - - @FXML - private ListView personListView; - - public PersonListPanel(ObservableList personList) { - super(FXML); - personListView.setItems(personList); - personListView.setCellFactory(listView -> new PersonListViewCell()); - } - - /** - * Custom {@code ListCell} that displays the graphics of a {@code Person} using a {@code PersonCard}. - */ - class PersonListViewCell extends ListCell { - @Override - protected void updateItem(Person person, boolean empty) { - super.updateItem(person, empty); - - if (empty || person == null) { - setGraphic(null); - setText(null); - } else { - setGraphic(new PersonCard(person, getIndex() + 1).getRoot()); - } - } - } - -} +package seedu.address.ui; + +import java.util.logging.Logger; + +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; +import javafx.scene.layout.Region; +import seedu.address.commons.core.LogsCenter; +import seedu.address.model.person.Person; + +/** + * Panel containing the list of persons. + */ +public class PersonListPanel extends UiPart { + private static final String FXML = "PersonListPanel.fxml"; + private final Logger logger = LogsCenter.getLogger(PersonListPanel.class); + + @FXML + private ListView personListView; + + public PersonListPanel(ObservableList personList) { + super(FXML); + personListView.setItems(personList); + personListView.setCellFactory(listView -> new PersonListViewCell()); + } + + /** + * Custom {@code ListCell} that displays the graphics of a {@code Person} using a {@code PersonCard}. + */ + class PersonListViewCell extends ListCell { + @Override + protected void updateItem(Person person, boolean empty) { + super.updateItem(person, empty); + + if (empty || person == null) { + setGraphic(null); + setText(null); + } else { + setGraphic(new PersonCard(person, getIndex() + 1).getRoot()); + } + } + } + +} diff --git a/src/main/java/seedu/address/ui/ResultDisplay.java b/src/main/java/seedu/address/ui/ResultDisplay.java index 7d98e84eedf..bd709ad54df 100644 --- a/src/main/java/seedu/address/ui/ResultDisplay.java +++ b/src/main/java/seedu/address/ui/ResultDisplay.java @@ -1,28 +1,28 @@ -package seedu.address.ui; - -import static java.util.Objects.requireNonNull; - -import javafx.fxml.FXML; -import javafx.scene.control.TextArea; -import javafx.scene.layout.Region; - -/** - * A ui for the status bar that is displayed at the header of the application. - */ -public class ResultDisplay extends UiPart { - - private static final String FXML = "ResultDisplay.fxml"; - - @FXML - private TextArea resultDisplay; - - public ResultDisplay() { - super(FXML); - } - - public void setFeedbackToUser(String feedbackToUser) { - requireNonNull(feedbackToUser); - resultDisplay.setText(feedbackToUser); - } - -} +package seedu.address.ui; + +import static java.util.Objects.requireNonNull; + +import javafx.fxml.FXML; +import javafx.scene.control.TextArea; +import javafx.scene.layout.Region; + +/** + * A ui for the status bar that is displayed at the header of the application. + */ +public class ResultDisplay extends UiPart { + + private static final String FXML = "ResultDisplay.fxml"; + + @FXML + private TextArea resultDisplay; + + public ResultDisplay() { + super(FXML); + } + + public void setFeedbackToUser(String feedbackToUser) { + requireNonNull(feedbackToUser); + resultDisplay.setText(feedbackToUser); + } + +} diff --git a/src/main/java/seedu/address/ui/StatusBarFooter.java b/src/main/java/seedu/address/ui/StatusBarFooter.java index 7e17911323f..b6ab45b42c3 100644 --- a/src/main/java/seedu/address/ui/StatusBarFooter.java +++ b/src/main/java/seedu/address/ui/StatusBarFooter.java @@ -1,26 +1,26 @@ -package seedu.address.ui; - -import java.nio.file.Path; -import java.nio.file.Paths; - -import javafx.fxml.FXML; -import javafx.scene.control.Label; -import javafx.scene.layout.Region; - -/** - * A ui for the status bar that is displayed at the footer of the application. - */ -public class StatusBarFooter extends UiPart { - - private static final String FXML = "StatusBarFooter.fxml"; - - @FXML - private Label saveLocationStatus; - - - public StatusBarFooter(Path saveLocation) { - super(FXML); - saveLocationStatus.setText(Paths.get(".").resolve(saveLocation).toString()); - } - -} +package seedu.address.ui; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import javafx.fxml.FXML; +import javafx.scene.control.Label; +import javafx.scene.layout.Region; + +/** + * A ui for the status bar that is displayed at the footer of the application. + */ +public class StatusBarFooter extends UiPart { + + private static final String FXML = "StatusBarFooter.fxml"; + + @FXML + private Label saveLocationStatus; + + + public StatusBarFooter(Path saveLocation) { + super(FXML); + saveLocationStatus.setText(Paths.get(".").resolve(saveLocation).toString()); + } + +} diff --git a/src/main/java/seedu/address/ui/Ui.java b/src/main/java/seedu/address/ui/Ui.java index 17aa0b494fe..4928c43ac32 100644 --- a/src/main/java/seedu/address/ui/Ui.java +++ b/src/main/java/seedu/address/ui/Ui.java @@ -1,13 +1,13 @@ -package seedu.address.ui; - -import javafx.stage.Stage; - -/** - * API of UI component - */ -public interface Ui { - - /** Starts the UI (and the App). */ - void start(Stage primaryStage); - -} +package seedu.address.ui; + +import javafx.stage.Stage; + +/** + * API of UI component + */ +public interface Ui { + + /** Starts the UI (and the App). */ + void start(Stage primaryStage); + +} diff --git a/src/main/java/seedu/address/ui/UiManager.java b/src/main/java/seedu/address/ui/UiManager.java index 876621d79b9..9b21c461547 100644 --- a/src/main/java/seedu/address/ui/UiManager.java +++ b/src/main/java/seedu/address/ui/UiManager.java @@ -1,86 +1,86 @@ -package seedu.address.ui; - -import java.util.logging.Logger; - -import javafx.application.Platform; -import javafx.scene.control.Alert; -import javafx.scene.control.Alert.AlertType; -import javafx.scene.image.Image; -import javafx.stage.Stage; -import seedu.address.MainApp; -import seedu.address.commons.core.LogsCenter; -import seedu.address.commons.util.StringUtil; -import seedu.address.logic.Logic; - -/** - * The manager of the UI component. - */ -public class UiManager implements Ui { - - public static final String ALERT_DIALOG_PANE_FIELD_ID = "alertDialogPane"; - - private static final Logger logger = LogsCenter.getLogger(UiManager.class); - private static final String ICON_APPLICATION = "/images/address_book_32.png"; - - private Logic logic; - private MainWindow mainWindow; - - public UiManager(Logic logic) { - super(); - this.logic = logic; - } - - @Override - public void start(Stage primaryStage) { - logger.info("Starting UI..."); - - //Set the application icon. - primaryStage.getIcons().add(getImage(ICON_APPLICATION)); - - try { - mainWindow = new MainWindow(primaryStage, logic); - mainWindow.show(); //This should be called before creating other UI parts - mainWindow.fillInnerParts(); - - } catch (Throwable e) { - logger.severe(StringUtil.getDetails(e)); - showFatalErrorDialogAndShutdown("Fatal error during initializing", e); - } - } - - private Image getImage(String imagePath) { - return new Image(MainApp.class.getResourceAsStream(imagePath)); - } - - void showAlertDialogAndWait(Alert.AlertType type, String title, String headerText, String contentText) { - showAlertDialogAndWait(mainWindow.getPrimaryStage(), type, title, headerText, contentText); - } - - /** - * Shows an alert dialog on {@code owner} with the given parameters. - * This method only returns after the user has closed the alert dialog. - */ - private static void showAlertDialogAndWait(Stage owner, AlertType type, String title, String headerText, - String contentText) { - final Alert alert = new Alert(type); - alert.getDialogPane().getStylesheets().add("view/DarkTheme.css"); - alert.initOwner(owner); - alert.setTitle(title); - alert.setHeaderText(headerText); - alert.setContentText(contentText); - alert.getDialogPane().setId(ALERT_DIALOG_PANE_FIELD_ID); - alert.showAndWait(); - } - - /** - * Shows an error alert dialog with {@code title} and error message, {@code e}, - * and exits the application after the user has closed the alert dialog. - */ - private void showFatalErrorDialogAndShutdown(String title, Throwable e) { - logger.severe(title + " " + e.getMessage() + StringUtil.getDetails(e)); - showAlertDialogAndWait(Alert.AlertType.ERROR, title, e.getMessage(), e.toString()); - Platform.exit(); - System.exit(1); - } - -} +package seedu.address.ui; + +import java.util.logging.Logger; + +import javafx.application.Platform; +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.image.Image; +import javafx.stage.Stage; +import seedu.address.MainApp; +import seedu.address.commons.core.LogsCenter; +import seedu.address.commons.util.StringUtil; +import seedu.address.logic.Logic; + +/** + * The manager of the UI component. + */ +public class UiManager implements Ui { + + public static final String ALERT_DIALOG_PANE_FIELD_ID = "alertDialogPane"; + + private static final Logger logger = LogsCenter.getLogger(UiManager.class); + private static final String ICON_APPLICATION = "/images/address_book_32.png"; + + private Logic logic; + private MainWindow mainWindow; + + public UiManager(Logic logic) { + super(); + this.logic = logic; + } + + @Override + public void start(Stage primaryStage) { + logger.info("Starting UI..."); + + //Set the application icon. + primaryStage.getIcons().add(getImage(ICON_APPLICATION)); + + try { + mainWindow = new MainWindow(primaryStage, logic); + mainWindow.show(); //This should be called before creating other UI parts + mainWindow.fillInnerParts(); + + } catch (Throwable e) { + logger.severe(StringUtil.getDetails(e)); + showFatalErrorDialogAndShutdown("Fatal error during initializing", e); + } + } + + private Image getImage(String imagePath) { + return new Image(MainApp.class.getResourceAsStream(imagePath)); + } + + void showAlertDialogAndWait(Alert.AlertType type, String title, String headerText, String contentText) { + showAlertDialogAndWait(mainWindow.getPrimaryStage(), type, title, headerText, contentText); + } + + /** + * Shows an alert dialog on {@code owner} with the given parameters. + * This method only returns after the user has closed the alert dialog. + */ + private static void showAlertDialogAndWait(Stage owner, AlertType type, String title, String headerText, + String contentText) { + final Alert alert = new Alert(type); + alert.getDialogPane().getStylesheets().add("view/DarkTheme.css"); + alert.initOwner(owner); + alert.setTitle(title); + alert.setHeaderText(headerText); + alert.setContentText(contentText); + alert.getDialogPane().setId(ALERT_DIALOG_PANE_FIELD_ID); + alert.showAndWait(); + } + + /** + * Shows an error alert dialog with {@code title} and error message, {@code e}, + * and exits the application after the user has closed the alert dialog. + */ + private void showFatalErrorDialogAndShutdown(String title, Throwable e) { + logger.severe(title + " " + e.getMessage() + StringUtil.getDetails(e)); + showAlertDialogAndWait(Alert.AlertType.ERROR, title, e.getMessage(), e.toString()); + Platform.exit(); + System.exit(1); + } + +} diff --git a/src/main/java/seedu/address/ui/UiPart.java b/src/main/java/seedu/address/ui/UiPart.java index fc820e01a9c..4ca667e3ad8 100644 --- a/src/main/java/seedu/address/ui/UiPart.java +++ b/src/main/java/seedu/address/ui/UiPart.java @@ -1,88 +1,88 @@ -package seedu.address.ui; - -import static java.util.Objects.requireNonNull; - -import java.io.IOException; -import java.net.URL; - -import javafx.fxml.FXMLLoader; -import seedu.address.MainApp; - -/** - * Represents a distinct part of the UI. e.g. Windows, dialogs, panels, status bars, etc. - * It contains a scene graph with a root node of type {@code T}. - */ -public abstract class UiPart { - - /** Resource folder where FXML files are stored. */ - public static final String FXML_FILE_FOLDER = "/view/"; - - private final FXMLLoader fxmlLoader = new FXMLLoader(); - - /** - * Constructs a UiPart with the specified FXML file URL. - * The FXML file must not specify the {@code fx:controller} attribute. - */ - public UiPart(URL fxmlFileUrl) { - loadFxmlFile(fxmlFileUrl, null); - } - - /** - * Constructs a UiPart using the specified FXML file within {@link #FXML_FILE_FOLDER}. - * @see #UiPart(URL) - */ - public UiPart(String fxmlFileName) { - this(getFxmlFileUrl(fxmlFileName)); - } - - /** - * Constructs a UiPart with the specified FXML file URL and root object. - * The FXML file must not specify the {@code fx:controller} attribute. - */ - public UiPart(URL fxmlFileUrl, T root) { - loadFxmlFile(fxmlFileUrl, root); - } - - /** - * Constructs a UiPart with the specified FXML file within {@link #FXML_FILE_FOLDER} and root object. - * @see #UiPart(URL, T) - */ - public UiPart(String fxmlFileName, T root) { - this(getFxmlFileUrl(fxmlFileName), root); - } - - /** - * Returns the root object of the scene graph of this UiPart. - */ - public T getRoot() { - return fxmlLoader.getRoot(); - } - - /** - * Loads the object hierarchy from a FXML document. - * @param location Location of the FXML document. - * @param root Specifies the root of the object hierarchy. - */ - private void loadFxmlFile(URL location, T root) { - requireNonNull(location); - fxmlLoader.setLocation(location); - fxmlLoader.setController(this); - fxmlLoader.setRoot(root); - try { - fxmlLoader.load(); - } catch (IOException e) { - throw new AssertionError(e); - } - } - - /** - * Returns the FXML file URL for the specified FXML file name within {@link #FXML_FILE_FOLDER}. - */ - private static URL getFxmlFileUrl(String fxmlFileName) { - requireNonNull(fxmlFileName); - String fxmlFileNameWithFolder = FXML_FILE_FOLDER + fxmlFileName; - URL fxmlFileUrl = MainApp.class.getResource(fxmlFileNameWithFolder); - return requireNonNull(fxmlFileUrl); - } - -} +package seedu.address.ui; + +import static java.util.Objects.requireNonNull; + +import java.io.IOException; +import java.net.URL; + +import javafx.fxml.FXMLLoader; +import seedu.address.MainApp; + +/** + * Represents a distinct part of the UI. e.g. Windows, dialogs, panels, status bars, etc. + * It contains a scene graph with a root node of type {@code T}. + */ +public abstract class UiPart { + + /** Resource folder where FXML files are stored. */ + public static final String FXML_FILE_FOLDER = "/view/"; + + private final FXMLLoader fxmlLoader = new FXMLLoader(); + + /** + * Constructs a UiPart with the specified FXML file URL. + * The FXML file must not specify the {@code fx:controller} attribute. + */ + public UiPart(URL fxmlFileUrl) { + loadFxmlFile(fxmlFileUrl, null); + } + + /** + * Constructs a UiPart using the specified FXML file within {@link #FXML_FILE_FOLDER}. + * @see #UiPart(URL) + */ + public UiPart(String fxmlFileName) { + this(getFxmlFileUrl(fxmlFileName)); + } + + /** + * Constructs a UiPart with the specified FXML file URL and root object. + * The FXML file must not specify the {@code fx:controller} attribute. + */ + public UiPart(URL fxmlFileUrl, T root) { + loadFxmlFile(fxmlFileUrl, root); + } + + /** + * Constructs a UiPart with the specified FXML file within {@link #FXML_FILE_FOLDER} and root object. + * @see #UiPart(URL, T) + */ + public UiPart(String fxmlFileName, T root) { + this(getFxmlFileUrl(fxmlFileName), root); + } + + /** + * Returns the root object of the scene graph of this UiPart. + */ + public T getRoot() { + return fxmlLoader.getRoot(); + } + + /** + * Loads the object hierarchy from a FXML document. + * @param location Location of the FXML document. + * @param root Specifies the root of the object hierarchy. + */ + private void loadFxmlFile(URL location, T root) { + requireNonNull(location); + fxmlLoader.setLocation(location); + fxmlLoader.setController(this); + fxmlLoader.setRoot(root); + try { + fxmlLoader.load(); + } catch (IOException e) { + throw new AssertionError(e); + } + } + + /** + * Returns the FXML file URL for the specified FXML file name within {@link #FXML_FILE_FOLDER}. + */ + private static URL getFxmlFileUrl(String fxmlFileName) { + requireNonNull(fxmlFileName); + String fxmlFileNameWithFolder = FXML_FILE_FOLDER + fxmlFileName; + URL fxmlFileUrl = MainApp.class.getResource(fxmlFileNameWithFolder); + return requireNonNull(fxmlFileUrl); + } + +} diff --git a/src/main/resources/view/CommandBox.fxml b/src/main/resources/view/CommandBox.fxml index 09f6d6fe9e4..d613c6d08eb 100644 --- a/src/main/resources/view/CommandBox.fxml +++ b/src/main/resources/view/CommandBox.fxml @@ -1,9 +1,9 @@ - - - - - - - - - + + + + + + + + + diff --git a/src/main/resources/view/DarkTheme.css b/src/main/resources/view/DarkTheme.css index 36e6b001cd8..6f69d1e495f 100644 --- a/src/main/resources/view/DarkTheme.css +++ b/src/main/resources/view/DarkTheme.css @@ -1,352 +1,352 @@ -.background { - -fx-background-color: derive(#1d1d1d, 20%); - background-color: #383838; /* Used in the default.html file */ -} - -.label { - -fx-font-size: 11pt; - -fx-font-family: "Segoe UI Semibold"; - -fx-text-fill: #555555; - -fx-opacity: 0.9; -} - -.label-bright { - -fx-font-size: 11pt; - -fx-font-family: "Segoe UI Semibold"; - -fx-text-fill: white; - -fx-opacity: 1; -} - -.label-header { - -fx-font-size: 32pt; - -fx-font-family: "Segoe UI Light"; - -fx-text-fill: white; - -fx-opacity: 1; -} - -.text-field { - -fx-font-size: 12pt; - -fx-font-family: "Segoe UI Semibold"; -} - -.tab-pane { - -fx-padding: 0 0 0 1; -} - -.tab-pane .tab-header-area { - -fx-padding: 0 0 0 0; - -fx-min-height: 0; - -fx-max-height: 0; -} - -.table-view { - -fx-base: #1d1d1d; - -fx-control-inner-background: #1d1d1d; - -fx-background-color: #1d1d1d; - -fx-table-cell-border-color: transparent; - -fx-table-header-border-color: transparent; - -fx-padding: 5; -} - -.table-view .column-header-background { - -fx-background-color: transparent; -} - -.table-view .column-header, .table-view .filler { - -fx-size: 35; - -fx-border-width: 0 0 1 0; - -fx-background-color: transparent; - -fx-border-color: - transparent - transparent - derive(-fx-base, 80%) - transparent; - -fx-border-insets: 0 10 1 0; -} - -.table-view .column-header .label { - -fx-font-size: 20pt; - -fx-font-family: "Segoe UI Light"; - -fx-text-fill: white; - -fx-alignment: center-left; - -fx-opacity: 1; -} - -.table-view:focused .table-row-cell:filled:focused:selected { - -fx-background-color: -fx-focus-color; -} - -.split-pane:horizontal .split-pane-divider { - -fx-background-color: derive(#1d1d1d, 20%); - -fx-border-color: transparent transparent transparent #4d4d4d; -} - -.split-pane { - -fx-border-radius: 1; - -fx-border-width: 1; - -fx-background-color: derive(#1d1d1d, 20%); -} - -.list-view { - -fx-background-insets: 0; - -fx-padding: 0; - -fx-background-color: derive(#1d1d1d, 20%); -} - -.list-cell { - -fx-label-padding: 0 0 0 0; - -fx-graphic-text-gap : 0; - -fx-padding: 0 0 0 0; -} - -.list-cell:filled:even { - -fx-background-color: #3c3e3f; -} - -.list-cell:filled:odd { - -fx-background-color: #515658; -} - -.list-cell:filled:selected { - -fx-background-color: #424d5f; -} - -.list-cell:filled:selected #cardPane { - -fx-border-color: #3e7b91; - -fx-border-width: 1; -} - -.list-cell .label { - -fx-text-fill: white; -} - -.cell_big_label { - -fx-font-family: "Segoe UI Semibold"; - -fx-font-size: 16px; - -fx-text-fill: #010504; -} - -.cell_small_label { - -fx-font-family: "Segoe UI"; - -fx-font-size: 13px; - -fx-text-fill: #010504; -} - -.stack-pane { - -fx-background-color: derive(#1d1d1d, 20%); -} - -.pane-with-border { - -fx-background-color: derive(#1d1d1d, 20%); - -fx-border-color: derive(#1d1d1d, 10%); - -fx-border-top-width: 1px; -} - -.status-bar { - -fx-background-color: derive(#1d1d1d, 30%); -} - -.result-display { - -fx-background-color: transparent; - -fx-font-family: "Segoe UI Light"; - -fx-font-size: 13pt; - -fx-text-fill: white; -} - -.result-display .label { - -fx-text-fill: black !important; -} - -.status-bar .label { - -fx-font-family: "Segoe UI Light"; - -fx-text-fill: white; - -fx-padding: 4px; - -fx-pref-height: 30px; -} - -.status-bar-with-border { - -fx-background-color: derive(#1d1d1d, 30%); - -fx-border-color: derive(#1d1d1d, 25%); - -fx-border-width: 1px; -} - -.status-bar-with-border .label { - -fx-text-fill: white; -} - -.grid-pane { - -fx-background-color: derive(#1d1d1d, 30%); - -fx-border-color: derive(#1d1d1d, 30%); - -fx-border-width: 1px; -} - -.grid-pane .stack-pane { - -fx-background-color: derive(#1d1d1d, 30%); -} - -.context-menu { - -fx-background-color: derive(#1d1d1d, 50%); -} - -.context-menu .label { - -fx-text-fill: white; -} - -.menu-bar { - -fx-background-color: derive(#1d1d1d, 20%); -} - -.menu-bar .label { - -fx-font-size: 14pt; - -fx-font-family: "Segoe UI Light"; - -fx-text-fill: white; - -fx-opacity: 0.9; -} - -.menu .left-container { - -fx-background-color: black; -} - -/* - * Metro style Push Button - * Author: Pedro Duque Vieira - * http://pixelduke.wordpress.com/2012/10/23/jmetro-windows-8-controls-on-java/ - */ -.button { - -fx-padding: 5 22 5 22; - -fx-border-color: #e2e2e2; - -fx-border-width: 2; - -fx-background-radius: 0; - -fx-background-color: #1d1d1d; - -fx-font-family: "Segoe UI", Helvetica, Arial, sans-serif; - -fx-font-size: 11pt; - -fx-text-fill: #d8d8d8; - -fx-background-insets: 0 0 0 0, 0, 1, 2; -} - -.button:hover { - -fx-background-color: #3a3a3a; -} - -.button:pressed, .button:default:hover:pressed { - -fx-background-color: white; - -fx-text-fill: #1d1d1d; -} - -.button:focused { - -fx-border-color: white, white; - -fx-border-width: 1, 1; - -fx-border-style: solid, segments(1, 1); - -fx-border-radius: 0, 0; - -fx-border-insets: 1 1 1 1, 0; -} - -.button:disabled, .button:default:disabled { - -fx-opacity: 0.4; - -fx-background-color: #1d1d1d; - -fx-text-fill: white; -} - -.button:default { - -fx-background-color: -fx-focus-color; - -fx-text-fill: #ffffff; -} - -.button:default:hover { - -fx-background-color: derive(-fx-focus-color, 30%); -} - -.dialog-pane { - -fx-background-color: #1d1d1d; -} - -.dialog-pane > *.button-bar > *.container { - -fx-background-color: #1d1d1d; -} - -.dialog-pane > *.label.content { - -fx-font-size: 14px; - -fx-font-weight: bold; - -fx-text-fill: white; -} - -.dialog-pane:header *.header-panel { - -fx-background-color: derive(#1d1d1d, 25%); -} - -.dialog-pane:header *.header-panel *.label { - -fx-font-size: 18px; - -fx-font-style: italic; - -fx-fill: white; - -fx-text-fill: white; -} - -.scroll-bar { - -fx-background-color: derive(#1d1d1d, 20%); -} - -.scroll-bar .thumb { - -fx-background-color: derive(#1d1d1d, 50%); - -fx-background-insets: 3; -} - -.scroll-bar .increment-button, .scroll-bar .decrement-button { - -fx-background-color: transparent; - -fx-padding: 0 0 0 0; -} - -.scroll-bar .increment-arrow, .scroll-bar .decrement-arrow { - -fx-shape: " "; -} - -.scroll-bar:vertical .increment-arrow, .scroll-bar:vertical .decrement-arrow { - -fx-padding: 1 8 1 8; -} - -.scroll-bar:horizontal .increment-arrow, .scroll-bar:horizontal .decrement-arrow { - -fx-padding: 8 1 8 1; -} - -#cardPane { - -fx-background-color: transparent; - -fx-border-width: 0; -} - -#commandTypeLabel { - -fx-font-size: 11px; - -fx-text-fill: #F70D1A; -} - -#commandTextField { - -fx-background-color: transparent #383838 transparent #383838; - -fx-background-insets: 0; - -fx-border-color: #383838 #383838 #ffffff #383838; - -fx-border-insets: 0; - -fx-border-width: 1; - -fx-font-family: "Segoe UI Light"; - -fx-font-size: 13pt; - -fx-text-fill: white; -} - -#filterField, #personListPanel, #personWebpage { - -fx-effect: innershadow(gaussian, black, 10, 0, 0, 0); -} - -#resultDisplay .content { - -fx-background-color: transparent, #383838, transparent, #383838; - -fx-background-radius: 0; -} - -#tags { - -fx-hgap: 7; - -fx-vgap: 3; -} - -#tags .label { - -fx-text-fill: white; - -fx-background-color: #3e7b91; - -fx-padding: 1 3 1 3; - -fx-border-radius: 2; - -fx-background-radius: 2; - -fx-font-size: 11; -} +.background { + -fx-background-color: derive(#1d1d1d, 20%); + background-color: #383838; /* Used in the default.html file */ +} + +.label { + -fx-font-size: 11pt; + -fx-font-family: "Segoe UI Semibold"; + -fx-text-fill: #555555; + -fx-opacity: 0.9; +} + +.label-bright { + -fx-font-size: 11pt; + -fx-font-family: "Segoe UI Semibold"; + -fx-text-fill: white; + -fx-opacity: 1; +} + +.label-header { + -fx-font-size: 32pt; + -fx-font-family: "Segoe UI Light"; + -fx-text-fill: white; + -fx-opacity: 1; +} + +.text-field { + -fx-font-size: 12pt; + -fx-font-family: "Segoe UI Semibold"; +} + +.tab-pane { + -fx-padding: 0 0 0 1; +} + +.tab-pane .tab-header-area { + -fx-padding: 0 0 0 0; + -fx-min-height: 0; + -fx-max-height: 0; +} + +.table-view { + -fx-base: #1d1d1d; + -fx-control-inner-background: #1d1d1d; + -fx-background-color: #1d1d1d; + -fx-table-cell-border-color: transparent; + -fx-table-header-border-color: transparent; + -fx-padding: 5; +} + +.table-view .column-header-background { + -fx-background-color: transparent; +} + +.table-view .column-header, .table-view .filler { + -fx-size: 35; + -fx-border-width: 0 0 1 0; + -fx-background-color: transparent; + -fx-border-color: + transparent + transparent + derive(-fx-base, 80%) + transparent; + -fx-border-insets: 0 10 1 0; +} + +.table-view .column-header .label { + -fx-font-size: 20pt; + -fx-font-family: "Segoe UI Light"; + -fx-text-fill: white; + -fx-alignment: center-left; + -fx-opacity: 1; +} + +.table-view:focused .table-row-cell:filled:focused:selected { + -fx-background-color: -fx-focus-color; +} + +.split-pane:horizontal .split-pane-divider { + -fx-background-color: derive(#1d1d1d, 20%); + -fx-border-color: transparent transparent transparent #4d4d4d; +} + +.split-pane { + -fx-border-radius: 1; + -fx-border-width: 1; + -fx-background-color: derive(#1d1d1d, 20%); +} + +.list-view { + -fx-background-insets: 0; + -fx-padding: 0; + -fx-background-color: derive(#1d1d1d, 20%); +} + +.list-cell { + -fx-label-padding: 0 0 0 0; + -fx-graphic-text-gap : 0; + -fx-padding: 0 0 0 0; +} + +.list-cell:filled:even { + -fx-background-color: #3c3e3f; +} + +.list-cell:filled:odd { + -fx-background-color: #515658; +} + +.list-cell:filled:selected { + -fx-background-color: #424d5f; +} + +.list-cell:filled:selected #cardPane { + -fx-border-color: #3e7b91; + -fx-border-width: 1; +} + +.list-cell .label { + -fx-text-fill: white; +} + +.cell_big_label { + -fx-font-family: "Segoe UI Semibold"; + -fx-font-size: 16px; + -fx-text-fill: #010504; +} + +.cell_small_label { + -fx-font-family: "Segoe UI"; + -fx-font-size: 13px; + -fx-text-fill: #010504; +} + +.stack-pane { + -fx-background-color: derive(#1d1d1d, 20%); +} + +.pane-with-border { + -fx-background-color: derive(#1d1d1d, 20%); + -fx-border-color: derive(#1d1d1d, 10%); + -fx-border-top-width: 1px; +} + +.status-bar { + -fx-background-color: derive(#1d1d1d, 30%); +} + +.result-display { + -fx-background-color: transparent; + -fx-font-family: "Segoe UI Light"; + -fx-font-size: 13pt; + -fx-text-fill: white; +} + +.result-display .label { + -fx-text-fill: black !important; +} + +.status-bar .label { + -fx-font-family: "Segoe UI Light"; + -fx-text-fill: white; + -fx-padding: 4px; + -fx-pref-height: 30px; +} + +.status-bar-with-border { + -fx-background-color: derive(#1d1d1d, 30%); + -fx-border-color: derive(#1d1d1d, 25%); + -fx-border-width: 1px; +} + +.status-bar-with-border .label { + -fx-text-fill: white; +} + +.grid-pane { + -fx-background-color: derive(#1d1d1d, 30%); + -fx-border-color: derive(#1d1d1d, 30%); + -fx-border-width: 1px; +} + +.grid-pane .stack-pane { + -fx-background-color: derive(#1d1d1d, 30%); +} + +.context-menu { + -fx-background-color: derive(#1d1d1d, 50%); +} + +.context-menu .label { + -fx-text-fill: white; +} + +.menu-bar { + -fx-background-color: derive(#1d1d1d, 20%); +} + +.menu-bar .label { + -fx-font-size: 14pt; + -fx-font-family: "Segoe UI Light"; + -fx-text-fill: white; + -fx-opacity: 0.9; +} + +.menu .left-container { + -fx-background-color: black; +} + +/* + * Metro style Push Button + * Author: Pedro Duque Vieira + * http://pixelduke.wordpress.com/2012/10/23/jmetro-windows-8-controls-on-java/ + */ +.button { + -fx-padding: 5 22 5 22; + -fx-border-color: #e2e2e2; + -fx-border-width: 2; + -fx-background-radius: 0; + -fx-background-color: #1d1d1d; + -fx-font-family: "Segoe UI", Helvetica, Arial, sans-serif; + -fx-font-size: 11pt; + -fx-text-fill: #d8d8d8; + -fx-background-insets: 0 0 0 0, 0, 1, 2; +} + +.button:hover { + -fx-background-color: #3a3a3a; +} + +.button:pressed, .button:default:hover:pressed { + -fx-background-color: white; + -fx-text-fill: #1d1d1d; +} + +.button:focused { + -fx-border-color: white, white; + -fx-border-width: 1, 1; + -fx-border-style: solid, segments(1, 1); + -fx-border-radius: 0, 0; + -fx-border-insets: 1 1 1 1, 0; +} + +.button:disabled, .button:default:disabled { + -fx-opacity: 0.4; + -fx-background-color: #1d1d1d; + -fx-text-fill: white; +} + +.button:default { + -fx-background-color: -fx-focus-color; + -fx-text-fill: #ffffff; +} + +.button:default:hover { + -fx-background-color: derive(-fx-focus-color, 30%); +} + +.dialog-pane { + -fx-background-color: #1d1d1d; +} + +.dialog-pane > *.button-bar > *.container { + -fx-background-color: #1d1d1d; +} + +.dialog-pane > *.label.content { + -fx-font-size: 14px; + -fx-font-weight: bold; + -fx-text-fill: white; +} + +.dialog-pane:header *.header-panel { + -fx-background-color: derive(#1d1d1d, 25%); +} + +.dialog-pane:header *.header-panel *.label { + -fx-font-size: 18px; + -fx-font-style: italic; + -fx-fill: white; + -fx-text-fill: white; +} + +.scroll-bar { + -fx-background-color: derive(#1d1d1d, 20%); +} + +.scroll-bar .thumb { + -fx-background-color: derive(#1d1d1d, 50%); + -fx-background-insets: 3; +} + +.scroll-bar .increment-button, .scroll-bar .decrement-button { + -fx-background-color: transparent; + -fx-padding: 0 0 0 0; +} + +.scroll-bar .increment-arrow, .scroll-bar .decrement-arrow { + -fx-shape: " "; +} + +.scroll-bar:vertical .increment-arrow, .scroll-bar:vertical .decrement-arrow { + -fx-padding: 1 8 1 8; +} + +.scroll-bar:horizontal .increment-arrow, .scroll-bar:horizontal .decrement-arrow { + -fx-padding: 8 1 8 1; +} + +#cardPane { + -fx-background-color: transparent; + -fx-border-width: 0; +} + +#commandTypeLabel { + -fx-font-size: 11px; + -fx-text-fill: #F70D1A; +} + +#commandTextField { + -fx-background-color: transparent #383838 transparent #383838; + -fx-background-insets: 0; + -fx-border-color: #383838 #383838 #ffffff #383838; + -fx-border-insets: 0; + -fx-border-width: 1; + -fx-font-family: "Segoe UI Light"; + -fx-font-size: 13pt; + -fx-text-fill: white; +} + +#filterField, #personListPanel, #personWebpage { + -fx-effect: innershadow(gaussian, black, 10, 0, 0, 0); +} + +#resultDisplay .content { + -fx-background-color: transparent, #383838, transparent, #383838; + -fx-background-radius: 0; +} + +#tags { + -fx-hgap: 7; + -fx-vgap: 3; +} + +#tags .label { + -fx-text-fill: white; + -fx-background-color: #3e7b91; + -fx-padding: 1 3 1 3; + -fx-border-radius: 2; + -fx-background-radius: 2; + -fx-font-size: 11; +} diff --git a/src/main/resources/view/Extensions.css b/src/main/resources/view/Extensions.css index bfe82a85964..139a9be6136 100644 --- a/src/main/resources/view/Extensions.css +++ b/src/main/resources/view/Extensions.css @@ -1,20 +1,20 @@ - -.error { - -fx-text-fill: #d06651 !important; /* The error class should always override the default text-fill style */ -} - -.list-cell:empty { - /* Empty cells will not have alternating colours */ - -fx-background: #383838; -} - -.tag-selector { - -fx-border-width: 1; - -fx-border-color: white; - -fx-border-radius: 3; - -fx-background-radius: 3; -} - -.tooltip-text { - -fx-text-fill: white; -} + +.error { + -fx-text-fill: #d06651 !important; /* The error class should always override the default text-fill style */ +} + +.list-cell:empty { + /* Empty cells will not have alternating colours */ + -fx-background: #383838; +} + +.tag-selector { + -fx-border-width: 1; + -fx-border-color: white; + -fx-border-radius: 3; + -fx-background-radius: 3; +} + +.tooltip-text { + -fx-text-fill: white; +} diff --git a/src/main/resources/view/HelpWindow.fxml b/src/main/resources/view/HelpWindow.fxml index fa0fb54d9f4..eb2c398d166 100644 --- a/src/main/resources/view/HelpWindow.fxml +++ b/src/main/resources/view/HelpWindow.fxml @@ -1,39 +1,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index a431648f6c0..3e29ab3abfd 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -1,60 +1,60 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml index f08ea32ad55..2783b408afd 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -1,36 +1,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/view/PersonListPanel.fxml b/src/main/resources/view/PersonListPanel.fxml index 8836d323cc5..9fd6823d68d 100644 --- a/src/main/resources/view/PersonListPanel.fxml +++ b/src/main/resources/view/PersonListPanel.fxml @@ -1,8 +1,8 @@ - - - - - - - - + + + + + + + + diff --git a/src/main/resources/view/ResultDisplay.fxml b/src/main/resources/view/ResultDisplay.fxml index 58d5ad3dc56..016cdc7e84f 100644 --- a/src/main/resources/view/ResultDisplay.fxml +++ b/src/main/resources/view/ResultDisplay.fxml @@ -1,9 +1,9 @@ - - - - - - -