From 4b99eb594378e44bae3dcf454c2b94cd2215d183 Mon Sep 17 00:00:00 2001 From: Paul Tan Date: Fri, 2 Dec 2016 21:37:11 +0800 Subject: [PATCH 01/29] [183] UiParts should not store a reference to the primaryStage * UiPart: move setIcon() into MainWindow UiPart::setIcon() is only used by MainWindow. Furthermore, UiParts should not be allowed to change the primary stage's icon at their whim and fancy, as it may lead to multiple UiParts conflicting with each other because they all want to set the primary stage's icons. So, make it clear that only MainWindow is allowed to do this by moving UiPart::setIcon() into MainWindow, and making it private. * UiPart: move setIcon() into FxViewUtil UiPart::setIcon() does not depend on any internal data of UiPart, and thus is better suited to be in an external utility class as a static method. This is done to make it clear that calling setIcon() will not modify the state of any objects, besides the Stage passed in as an argument. * FxViewUtil: rename setIcon() to setStageIcon() This is done to make it clear that the method operates on a Stage. * UiPart: push down primaryStage Currently, all UiParts store a reference to their primaryStage, which means that they can modify the primaryStage at their own whim and fancy. We want to prevent that -- UiParts should not be able to access the primaryStage as it makes it hard to reason about which UiPart is controlling the primaryStage and which is not. As such, we want to remove the reference to the primaryStage from all UiParts. Of all the UiParts, we note that only MainWindow requires a reference to the primaryStage. All other UiParts do not, and SHOULD NOT, keep a reference to the primaryStage. So, we push down the `primaryStage` field from UiPart to MainWindow only. All other UiParts thus effectively lose access to the primaryStage, which is a good thing for encapsulation. * UiPartLoader: rename loadUiPart() to initUiPart() All other variants of loadUiPart() will reconstruct the UiPart based on the value of "fx:controller" in its FXML file. Only loadUiPart(T seedUiPart) does not -- it simply sets up the FXML scene graph using the existing UiPart object provided. To highlight the difference in behaviour of this method from the others, rename this method to `initUiPart()`. * UiPartLoader: add single argument variant of loadUiPart() --- .../address/commons/util/FxViewUtil.java | 10 ++++++ .../java/seedu/address/ui/CommandBox.java | 5 ++- .../java/seedu/address/ui/HelpWindow.java | 6 ++-- .../java/seedu/address/ui/MainWindow.java | 34 +++++++++++++------ .../java/seedu/address/ui/PersonCard.java | 2 +- .../seedu/address/ui/PersonListPanel.java | 6 ++-- .../java/seedu/address/ui/ResultDisplay.java | 5 ++- .../seedu/address/ui/StatusBarFooter.java | 5 ++- src/main/java/seedu/address/ui/UiPart.java | 32 ----------------- .../java/seedu/address/ui/UiPartLoader.java | 31 +++++++++-------- 10 files changed, 63 insertions(+), 73 deletions(-) diff --git a/src/main/java/seedu/address/commons/util/FxViewUtil.java b/src/main/java/seedu/address/commons/util/FxViewUtil.java index 900efa6bf5c3..9a1a8833f5c7 100644 --- a/src/main/java/seedu/address/commons/util/FxViewUtil.java +++ b/src/main/java/seedu/address/commons/util/FxViewUtil.java @@ -2,6 +2,7 @@ import javafx.scene.Node; import javafx.scene.layout.AnchorPane; +import javafx.stage.Stage; /** * Contains utility methods for JavaFX views @@ -14,4 +15,13 @@ public static void applyAnchorBoundaryParameters(Node node, double left, double AnchorPane.setRightAnchor(node, right); AnchorPane.setTopAnchor(node, top); } + + /** + * Sets the given image as the icon for the given stage. + * @param iconSource e.g. {@code "/images/help_icon.png"} + */ + public static void setStageIcon(Stage stage, String iconSource) { + stage.getIcons().setAll(AppUtil.getImage(iconSource)); + } + } diff --git a/src/main/java/seedu/address/ui/CommandBox.java b/src/main/java/seedu/address/ui/CommandBox.java index fae5ff72522e..c23231856ead 100644 --- a/src/main/java/seedu/address/ui/CommandBox.java +++ b/src/main/java/seedu/address/ui/CommandBox.java @@ -6,7 +6,6 @@ import javafx.scene.control.SplitPane; import javafx.scene.control.TextField; import javafx.scene.layout.AnchorPane; -import javafx.stage.Stage; import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.ui.IncorrectCommandAttemptedEvent; import seedu.address.commons.events.ui.NewResultAvailableEvent; @@ -29,8 +28,8 @@ public class CommandBox extends UiPart { @FXML private TextField commandTextField; - public static CommandBox load(Stage primaryStage, AnchorPane commandBoxPlaceholder, Logic logic) { - CommandBox commandBox = UiPartLoader.loadUiPart(primaryStage, commandBoxPlaceholder, new CommandBox()); + public static CommandBox load(AnchorPane commandBoxPlaceholder, Logic logic) { + CommandBox commandBox = UiPartLoader.loadUiPart(commandBoxPlaceholder, new CommandBox()); commandBox.configure(logic); commandBox.addToPlaceholder(); return commandBox; diff --git a/src/main/java/seedu/address/ui/HelpWindow.java b/src/main/java/seedu/address/ui/HelpWindow.java index 45b765ab6a0c..e9a530e5cf64 100644 --- a/src/main/java/seedu/address/ui/HelpWindow.java +++ b/src/main/java/seedu/address/ui/HelpWindow.java @@ -26,9 +26,9 @@ public class HelpWindow extends UiPart { private Stage dialogStage; - public static HelpWindow load(Stage primaryStage) { + public static HelpWindow load() { logger.fine("Showing help page about the application."); - HelpWindow helpWindow = UiPartLoader.loadUiPart(primaryStage, new HelpWindow()); + HelpWindow helpWindow = UiPartLoader.loadUiPart(new HelpWindow()); helpWindow.configure(); return helpWindow; } @@ -48,7 +48,7 @@ private void configure(){ //Null passed as the parent stage to make it non-modal. dialogStage = createDialogStage(TITLE, null, scene); dialogStage.setMaximized(true); //TODO: set a more appropriate initial size - setIcon(dialogStage, ICON); + FxViewUtil.setStageIcon(dialogStage, ICON); WebView browser = new WebView(); browser.getEngine().load(USERGUIDE_URL); diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 520e56608e29..ba00e17f61c3 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -11,6 +11,7 @@ import seedu.address.commons.core.Config; import seedu.address.commons.core.GuiSettings; import seedu.address.commons.events.ui.ExitAppRequestEvent; +import seedu.address.commons.util.FxViewUtil; import seedu.address.logic.Logic; import seedu.address.model.UserPrefs; import seedu.address.model.person.ReadOnlyPerson; @@ -26,6 +27,7 @@ public class MainWindow extends UiPart { private static final int MIN_HEIGHT = 600; private static final int MIN_WIDTH = 450; + private Stage primaryStage; private Logic logic; // Independent Ui parts residing in this Ui container @@ -70,16 +72,21 @@ public String getFxmlPath() { return FXML; } + public Stage getPrimaryStage() { + return primaryStage; + } + public static MainWindow load(Stage primaryStage, Config config, UserPrefs prefs, Logic logic) { - MainWindow mainWindow = UiPartLoader.loadUiPart(primaryStage, new MainWindow()); - mainWindow.configure(config.getAppTitle(), config.getAddressBookName(), config, prefs, logic); + MainWindow mainWindow = UiPartLoader.loadUiPart(new MainWindow()); + mainWindow.configure(primaryStage, config.getAppTitle(), config.getAddressBookName(), config, prefs, logic); return mainWindow; } - private void configure(String appTitle, String addressBookName, Config config, UserPrefs prefs, - Logic logic) { + private void configure(Stage primaryStage, String appTitle, String addressBookName, Config config, + UserPrefs prefs, Logic logic) { // Set dependencies + this.primaryStage = primaryStage; this.logic = logic; this.addressBookName = addressBookName; this.config = config; @@ -102,11 +109,10 @@ private void setAccelerators() { void fillInnerParts() { browserPanel = BrowserPanel.load(browserPlaceholder); - personListPanel = PersonListPanel.load(primaryStage, getPersonListPlaceholder(), logic.getFilteredPersonList()); - resultDisplay = ResultDisplay.load(primaryStage, getResultDisplayPlaceholder()); - statusBarFooter = StatusBarFooter.load(primaryStage, getStatusbarPlaceholder(), - config.getAddressBookFilePath()); - commandBox = CommandBox.load(primaryStage, getCommandBoxPlaceholder(), logic); + personListPanel = PersonListPanel.load(getPersonListPlaceholder(), logic.getFilteredPersonList()); + resultDisplay = ResultDisplay.load(getResultDisplayPlaceholder()); + statusBarFooter = StatusBarFooter.load(getStatusbarPlaceholder(), config.getAddressBookFilePath()); + commandBox = CommandBox.load(getCommandBoxPlaceholder(), logic); } private AnchorPane getCommandBoxPlaceholder() { @@ -133,6 +139,14 @@ private void setTitle(String appTitle) { primaryStage.setTitle(appTitle); } + /** + * Sets the given image as the icon of the main window. + * @param iconSource e.g. {@code "/images/help_icon.png"} + */ + private void setIcon(String iconSource) { + FxViewUtil.setStageIcon(primaryStage, iconSource); + } + /** * Sets the default size based on user preferences. */ @@ -160,7 +174,7 @@ GuiSettings getCurrentGuiSetting() { @FXML public void handleHelp() { - HelpWindow helpWindow = HelpWindow.load(primaryStage); + HelpWindow helpWindow = HelpWindow.load(); helpWindow.show(); } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index f9af1bdaa97e..94b432281cc8 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -33,7 +33,7 @@ public static PersonCard load(ReadOnlyPerson person, int displayedIndex) { PersonCard card = new PersonCard(); card.person = person; card.displayedIndex = displayedIndex; - return UiPartLoader.loadUiPart(card); + return UiPartLoader.initUiPart(card); } @FXML diff --git a/src/main/java/seedu/address/ui/PersonListPanel.java b/src/main/java/seedu/address/ui/PersonListPanel.java index 4f18bfb53f7f..00224d974d7b 100644 --- a/src/main/java/seedu/address/ui/PersonListPanel.java +++ b/src/main/java/seedu/address/ui/PersonListPanel.java @@ -9,7 +9,6 @@ import javafx.scene.control.SplitPane; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.VBox; -import javafx.stage.Stage; import seedu.address.commons.events.ui.PersonPanelSelectionChangedEvent; import seedu.address.model.person.ReadOnlyPerson; import seedu.address.commons.core.LogsCenter; @@ -43,10 +42,9 @@ public void setPlaceholder(AnchorPane pane) { this.placeHolderPane = pane; } - public static PersonListPanel load(Stage primaryStage, AnchorPane personListPlaceholder, + public static PersonListPanel load(AnchorPane personListPlaceholder, ObservableList personList) { - PersonListPanel personListPanel = - UiPartLoader.loadUiPart(primaryStage, personListPlaceholder, new PersonListPanel()); + PersonListPanel personListPanel = UiPartLoader.loadUiPart(personListPlaceholder, new PersonListPanel()); personListPanel.configure(personList); return personListPanel; } diff --git a/src/main/java/seedu/address/ui/ResultDisplay.java b/src/main/java/seedu/address/ui/ResultDisplay.java index 12723451c7fd..dad04e5d950a 100644 --- a/src/main/java/seedu/address/ui/ResultDisplay.java +++ b/src/main/java/seedu/address/ui/ResultDisplay.java @@ -7,7 +7,6 @@ import javafx.scene.Node; import javafx.scene.control.TextArea; import javafx.scene.layout.AnchorPane; -import javafx.stage.Stage; import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.ui.NewResultAvailableEvent; import seedu.address.commons.util.FxViewUtil; @@ -33,8 +32,8 @@ public class ResultDisplay extends UiPart { @FXML private TextArea resultDisplay; - public static ResultDisplay load(Stage primaryStage, AnchorPane placeHolder) { - ResultDisplay resultDisplay = UiPartLoader.loadUiPart(primaryStage, placeHolder, new ResultDisplay()); + public static ResultDisplay load(AnchorPane placeHolder) { + ResultDisplay resultDisplay = UiPartLoader.loadUiPart(placeHolder, new ResultDisplay()); resultDisplay.configure(); return resultDisplay; } diff --git a/src/main/java/seedu/address/ui/StatusBarFooter.java b/src/main/java/seedu/address/ui/StatusBarFooter.java index f74f66be6fc9..9291f8faadae 100644 --- a/src/main/java/seedu/address/ui/StatusBarFooter.java +++ b/src/main/java/seedu/address/ui/StatusBarFooter.java @@ -5,7 +5,6 @@ import javafx.scene.Node; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.GridPane; -import javafx.stage.Stage; import org.controlsfx.control.StatusBar; import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.model.AddressBookChangedEvent; @@ -34,8 +33,8 @@ public class StatusBarFooter extends UiPart { private static final String FXML = "StatusBarFooter.fxml"; - public static StatusBarFooter load(Stage stage, AnchorPane placeHolder, String saveLocation) { - StatusBarFooter statusBarFooter = UiPartLoader.loadUiPart(stage, placeHolder, new StatusBarFooter()); + public static StatusBarFooter load(AnchorPane placeHolder, String saveLocation) { + StatusBarFooter statusBarFooter = UiPartLoader.loadUiPart(placeHolder, new StatusBarFooter()); statusBarFooter.configure(saveLocation); return statusBarFooter; } diff --git a/src/main/java/seedu/address/ui/UiPart.java b/src/main/java/seedu/address/ui/UiPart.java index 492b4eebf61a..70207cafaab5 100644 --- a/src/main/java/seedu/address/ui/UiPart.java +++ b/src/main/java/seedu/address/ui/UiPart.java @@ -7,7 +7,6 @@ import javafx.stage.Stage; import seedu.address.commons.core.EventsCenter; import seedu.address.commons.events.BaseEvent; -import seedu.address.commons.util.AppUtil; /** * Base class for UI parts. @@ -15,12 +14,6 @@ */ public abstract class UiPart { - /** - * The primary stage for the UI Part. - */ - Stage primaryStage; - - /** * Raises the event via {@link EventsCenter#post(BaseEvent)} * @param event @@ -49,11 +42,6 @@ protected void registerAsAnEventHandler(Object handler) { */ public abstract String getFxmlPath(); - public void setStage(Stage primaryStage) { - this.primaryStage = primaryStage; - } - - /** * Creates a modal dialog. * @param title Title of the dialog. @@ -70,23 +58,6 @@ protected Stage createDialogStage(String title, Stage parentStage, Scene scene) return dialogStage; } - /** - * Sets the given image as the icon for the primary stage of this UI Part. - * @param iconSource e.g. {@code "/images/help_icon.png"} - */ - protected void setIcon(String iconSource) { - primaryStage.getIcons().add(AppUtil.getImage(iconSource)); - } - - /** - * Sets the given image as the icon for the given stage. - * @param stage - * @param iconSource e.g. {@code "/images/help_icon.png"} - */ - protected void setIcon(Stage stage, String iconSource) { - stage.getIcons().add(AppUtil.getImage(iconSource)); - } - /** * Sets the placeholder for UI parts that reside inside another UI part. * @param placeholder @@ -95,7 +66,4 @@ public void setPlaceholder(AnchorPane placeholder) { //Do nothing by default. } - public Stage getPrimaryStage() { - return primaryStage; - } } diff --git a/src/main/java/seedu/address/ui/UiPartLoader.java b/src/main/java/seedu/address/ui/UiPartLoader.java index 86e0182846eb..f3898240632f 100644 --- a/src/main/java/seedu/address/ui/UiPartLoader.java +++ b/src/main/java/seedu/address/ui/UiPartLoader.java @@ -3,7 +3,6 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Node; import javafx.scene.layout.AnchorPane; -import javafx.stage.Stage; import seedu.address.MainApp; /** @@ -12,37 +11,41 @@ public class UiPartLoader { private static final String FXML_FILE_FOLDER = "/view/"; - public static T loadUiPart(Stage primaryStage, T controllerSeed) { - return loadUiPart(primaryStage, null, controllerSeed); - } - /** * Returns the ui class for a specific UI Part. * - * @param primaryStage The primary stage for the view. - * @param placeholder The placeholder where the loaded Ui Part is added. * @param sampleUiPart The sample of the expected UiPart class. * @param The type of the UiPart */ - public static T loadUiPart(Stage primaryStage, AnchorPane placeholder, T sampleUiPart) { + public static T loadUiPart(T sampleUiPart) { FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainApp.class.getResource(FXML_FILE_FOLDER + sampleUiPart.getFxmlPath())); Node mainNode = loadLoader(loader, sampleUiPart.getFxmlPath()); - UiPart controller = loader.getController(); - controller.setStage(primaryStage); - controller.setPlaceholder(placeholder); + T controller = loader.getController(); controller.setNode(mainNode); - return (T) controller; + return controller; } /** * Returns the ui class for a specific UI Part. * - * @param seedUiPart The UiPart object to be used as the ui. + * @param placeholder The placeholder where the loaded Ui Part is added. + * @param sampleUiPart The sample of the expected UiPart class. * @param The type of the UiPart */ + public static T loadUiPart(AnchorPane placeholder, T sampleUiPart) { + T controller = loadUiPart(sampleUiPart); + controller.setPlaceholder(placeholder); + return controller; + } - public static T loadUiPart(T seedUiPart) { + /** + * Initialize the FXML scene graph of the provided UI Part. + * + * @param seedUiPart The UiPart object to be used as the ui. + * @param The type of the UiPart + */ + public static T initUiPart(T seedUiPart) { FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainApp.class.getResource(FXML_FILE_FOLDER + seedUiPart.getFxmlPath())); loader.setController(seedUiPart); From 6c99bdbd9ba4aac9c64643106428409cf0d769b7 Mon Sep 17 00:00:00 2001 From: Paul Tan Date: Thu, 8 Dec 2016 19:10:38 +0800 Subject: [PATCH 02/29] build.gradle: add `run` and `runShadow` tasks (#178) The `run` and `runShadow` tasks provide a convenient way for developers to run the built application from its *.class files or the built fat JAR respectively. This is accomplished using the application plugin[1] which implements the 'run' task. The shadow plugin, which we already use, will automatically detect the `application` plugin and will integrate with it[2], providing the `runShadow` task. It also knows that `mainClassName` should be used as the "Main-Class" of the JAR manifest, so we don't need to specify that anymore. We add the `mainClassName` and `plugin` lines OUTSIDE of the `allprojects` block because the question of "which class should be run" is Gradle project-specific and only applicable to the root project. [1] https://docs.gradle.org/current/userguide/application_plugin.html [2] http://imperceptiblethoughts.com/shadow/#integrating_with_application_plugin --- build.gradle | 8 ++++---- docs/UsingGradle.md | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 74669b84902c..9d03209f31eb 100644 --- a/build.gradle +++ b/build.gradle @@ -8,8 +8,12 @@ plugins { id "com.github.kt3k.coveralls" version "2.4.0" id "com.github.johnrengelman.shadow" version '1.2.3' + id 'application' } +// Specifies the entry point of the application +mainClassName = 'seedu.address.MainApp' + allprojects { apply plugin: 'idea' apply plugin: 'java' @@ -83,10 +87,6 @@ allprojects { shadowJar { archiveName = "addressbook.jar" - manifest { - attributes "Main-Class": "seedu.address.MainApp" - } - destinationDir = file("${buildDir}/jar/") } } diff --git a/docs/UsingGradle.md b/docs/UsingGradle.md index 4eac109ce89d..e0fe66c5b4bf 100644 --- a/docs/UsingGradle.md +++ b/docs/UsingGradle.md @@ -47,6 +47,14 @@ If we package only our own class files into the JAR file, it will not work prope 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 fil, we use the Gradle plugin [shadow jar](https://github.com/johnrengelman/shadow). +## 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`**
From 7ff3ad82caaf32e71def3d26f133c1152cad0ac6 Mon Sep 17 00:00:00 2001 From: Paul Tan Date: Thu, 8 Dec 2016 19:10:58 +0800 Subject: [PATCH 03/29] checkstyle: check for trailing whitespace #179 (#180) * codestyle: remove trailing whitespace Some lines in the code look like an empty line, but actually contain spaces. To be consistent with the rest of the code, let's make sure all empty lines are actually empty. * checkstyle: check for trailing whitespace To ensure that no more trailing whitespace is introduced into our code base, add a check for it. --- config/checkstyle/checkstyle.xml | 7 +++++ .../core/UnmodifiableObservableList.java | 30 +++++++++---------- .../seedu/address/model/person/Address.java | 2 +- .../guihandles/PersonListPanelHandle.java | 2 +- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index c786caa1b993..40c6d06b3ff7 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -236,6 +236,13 @@ + + + + + + + diff --git a/src/main/java/seedu/address/commons/core/UnmodifiableObservableList.java b/src/main/java/seedu/address/commons/core/UnmodifiableObservableList.java index 92ee6cf7ba13..87a0a566f29c 100644 --- a/src/main/java/seedu/address/commons/core/UnmodifiableObservableList.java +++ b/src/main/java/seedu/address/commons/core/UnmodifiableObservableList.java @@ -26,7 +26,7 @@ public UnmodifiableObservableList(ObservableList backingList) { assert backingList != null; this.backingList = backingList; } - + @Override public final void addListener(ListChangeListener listener) { backingList.addListener(listener); @@ -61,12 +61,12 @@ public final boolean setAll(Object... elements) { public final boolean setAll(Collection col) { throw new UnsupportedOperationException(MUTATION_OP_EXCEPTION_MESSAGE); } - + @Override public final boolean removeAll(Object... elements) { throw new UnsupportedOperationException(MUTATION_OP_EXCEPTION_MESSAGE); } - + @Override public final boolean retainAll(Object... elements) { throw new UnsupportedOperationException(MUTATION_OP_EXCEPTION_MESSAGE); @@ -108,12 +108,12 @@ public final int size() { public final boolean isEmpty() { return backingList.isEmpty(); } - + @Override public final boolean contains(Object o) { return backingList.contains(o); } - + @Override public final Iterator iterator() { return new Iterator() { @@ -150,7 +150,7 @@ public final T[] toArray(T[] a) { public final boolean add(E o) { throw new UnsupportedOperationException(MUTATION_OP_EXCEPTION_MESSAGE); } - + @Override public final boolean remove(Object o) { throw new UnsupportedOperationException(MUTATION_OP_EXCEPTION_MESSAGE); @@ -170,12 +170,12 @@ public final boolean addAll(Collection c) { public final boolean addAll(int index, Collection c) { throw new UnsupportedOperationException(MUTATION_OP_EXCEPTION_MESSAGE); } - + @Override public final boolean removeAll(Collection c) { throw new UnsupportedOperationException(MUTATION_OP_EXCEPTION_MESSAGE); } - + @Override public final boolean retainAll(Collection c) { throw new UnsupportedOperationException(MUTATION_OP_EXCEPTION_MESSAGE); @@ -190,13 +190,13 @@ public final void replaceAll(UnaryOperator operator) { public final void sort(Comparator c) { throw new UnsupportedOperationException(MUTATION_OP_EXCEPTION_MESSAGE); } - + @Override public final void clear() { throw new UnsupportedOperationException(MUTATION_OP_EXCEPTION_MESSAGE); } - + @Override public final boolean equals(Object o) { return o == this || backingList.equals(o); @@ -207,7 +207,7 @@ public final int hashCode() { return backingList.hashCode(); } - + @Override public final E get(int index) { return backingList.get(index); @@ -228,12 +228,12 @@ public final void add(int index, Object element) { public final E remove(int index) { throw new UnsupportedOperationException(MUTATION_OP_EXCEPTION_MESSAGE); } - + @Override public final int indexOf(Object o) { return backingList.indexOf(o); } - + @Override public final int lastIndexOf(Object o) { return backingList.lastIndexOf(o); @@ -243,7 +243,7 @@ public final int lastIndexOf(Object o) { public final ListIterator listIterator() { return listIterator(0); } - + @Override public final ListIterator listIterator(int index) { return new ListIterator() { @@ -300,7 +300,7 @@ public final boolean removeIf(Predicate filter) { public final Stream stream() { return (Stream) backingList.stream(); } - + @Override public final void forEach(Consumer action) { backingList.forEach(action); diff --git a/src/main/java/seedu/address/model/person/Address.java b/src/main/java/seedu/address/model/person/Address.java index 30099e36bc40..4cb19ecd2291 100644 --- a/src/main/java/seedu/address/model/person/Address.java +++ b/src/main/java/seedu/address/model/person/Address.java @@ -8,7 +8,7 @@ * Guarantees: immutable; is valid as declared in {@link #isValidAddress(String)} */ public class Address { - + public static final String MESSAGE_ADDRESS_CONSTRAINTS = "Person addresses can be in any format"; public static final String ADDRESS_VALIDATION_REGEX = ".+"; diff --git a/src/test/java/guitests/guihandles/PersonListPanelHandle.java b/src/test/java/guitests/guihandles/PersonListPanelHandle.java index 755699841117..ce03fdcaa020 100644 --- a/src/test/java/guitests/guihandles/PersonListPanelHandle.java +++ b/src/test/java/guitests/guihandles/PersonListPanelHandle.java @@ -47,7 +47,7 @@ public ListView getListView() { public boolean isListMatching(ReadOnlyPerson... persons) { return this.isListMatching(0, persons); } - + /** * Clicks on the ListView. */ From 8d9ff226f33c05a1acac43e611d94220c089d8f8 Mon Sep 17 00:00:00 2001 From: Jia Yee Date: Fri, 9 Dec 2016 18:05:18 +0700 Subject: [PATCH 04/29] Correct typos and grammatical errors in DG (#198) --- docs/DeveloperGuide.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index c8fb444cfc2e..e83ea7385bd4 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -63,7 +63,7 @@ **Problem: Eclipse reports some required libraries missing** * Reason: Required libraries may not have been downloaded during the project import. -* Solution: [Run tests using Gardle](UsingGradle.md) once (to refresh the libraries). +* Solution: [Run tests using Gradle](UsingGradle.md) once (to refresh the libraries). ## Design @@ -75,17 +75,17 @@ The **_Architecture Diagram_** given above explains the high-level design of the Given below is a quick overview of each component. `Main` has only one class called [`MainApp`](../src/main/java/seedu/address/MainApp.java). It is responsible for, -* At app launch: Initializes the components in the correct sequence, and connect them up with each other. -* At shut down: Shuts down the components and invoke cleanup method where necessary. +* 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. [**`Commons`**](#common-classes) represents a collection of classes used by multiple other components. Two of those classes play important roles at the architecture level. -* `EventsCentre` : This class (written using [Google's Event Bus library](https://github.com/google/guava/wiki/EventBusExplained)) +* `EventsCenter` : This class (written using [Google's Event Bus library](https://github.com/google/guava/wiki/EventBusExplained)) is used by components to communicate with other components using events (i.e. a form of _Event Driven_ design) * `LogsCenter` : Used by many classes to write log messages to the App's log file. -The rest of the App consists four components. -* [**`UI`**](#ui-component) : The UI of tha App. +The rest of the App consists of four components. +* [**`UI`**](#ui-component) : The UI of the App. * [**`Logic`**](#logic-component) : The command executor. * [**`Model`**](#model-component) : Holds the data of the App in-memory. * [**`Storage`**](#storage-component) : Reads data from, and writes data to, the hard disk. @@ -268,7 +268,7 @@ Here are the steps to create a new release. 1. Generate a JAR file [using Gradle](UsingGradle.md#creating-the-jar-file). 2. Tag the repo with the version number. e.g. `v0.1` 2. [Create a new release using GitHub](https://help.github.com/articles/creating-releases/) - and upload the JAR file your created. + and upload the JAR file you created. ### Managing Dependencies From ba0900e84dd5ca552cd93a6f6c10634bbcf56426 Mon Sep 17 00:00:00 2001 From: Paul Tan Date: Sat, 10 Dec 2016 20:52:36 +0700 Subject: [PATCH 05/29] [188] Construct StatusBarFooter in FXML fully StatusBarFooter currently constructs and sets up its StatusBar controls using pure code. The StatusBar control is actually a real control that can be initialized directly in the FXML file. We can avoid placeholder elements and make things simpler by just doing that. Now, one may think: "This means Scene Builder cannot edit this FXML file any more!", since the StatusBar control comes from controlsfx, which is not supported by Scene Builder by default. However, 1. Scene Builder can actually be configured[1] to support the custom controls from controlsfx, allowing it to edit the FXML file. 2. Having too many placeholder nodes, and constructing the actual scene graph in code, kind of defeats the advantage of FXML which is to construct the scene graph declaratively without code. [1] http://stackoverflow.com/a/30078204 --- .../seedu/address/ui/StatusBarFooter.java | 23 +++---------------- src/main/resources/view/StatusBarFooter.fxml | 5 ++-- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/main/java/seedu/address/ui/StatusBarFooter.java b/src/main/java/seedu/address/ui/StatusBarFooter.java index 9291f8faadae..861cb3735baf 100644 --- a/src/main/java/seedu/address/ui/StatusBarFooter.java +++ b/src/main/java/seedu/address/ui/StatusBarFooter.java @@ -18,17 +18,14 @@ */ public class StatusBarFooter extends UiPart { private static final Logger logger = LogsCenter.getLogger(StatusBarFooter.class); + + @FXML private StatusBar syncStatus; + @FXML private StatusBar saveLocationStatus; private GridPane mainPane; - @FXML - private AnchorPane saveLocStatusBarPane; - - @FXML - private AnchorPane syncStatusBarPane; - private AnchorPane placeHolder; private static final String FXML = "StatusBarFooter.fxml"; @@ -41,9 +38,7 @@ public static StatusBarFooter load(AnchorPane placeHolder, String saveLocation) public void configure(String saveLocation) { addMainPane(); - addSyncStatus(); setSyncStatus("Not updated yet in this session"); - addSaveLocation(); setSaveLocation("./" + saveLocation); registerAsAnEventHandler(this); } @@ -57,22 +52,10 @@ private void setSaveLocation(String location) { this.saveLocationStatus.setText(location); } - private void addSaveLocation() { - this.saveLocationStatus = new StatusBar(); - FxViewUtil.applyAnchorBoundaryParameters(saveLocationStatus, 0.0, 0.0, 0.0, 0.0); - saveLocStatusBarPane.getChildren().add(saveLocationStatus); - } - private void setSyncStatus(String status) { this.syncStatus.setText(status); } - private void addSyncStatus() { - this.syncStatus = new StatusBar(); - FxViewUtil.applyAnchorBoundaryParameters(syncStatus, 0.0, 0.0, 0.0, 0.0); - syncStatusBarPane.getChildren().add(syncStatus); - } - @Override public void setNode(Node node) { mainPane = (GridPane) node; diff --git a/src/main/resources/view/StatusBarFooter.fxml b/src/main/resources/view/StatusBarFooter.fxml index 2656558b6eb7..d86870f338ae 100644 --- a/src/main/resources/view/StatusBarFooter.fxml +++ b/src/main/resources/view/StatusBarFooter.fxml @@ -1,13 +1,14 @@ + - - + + From e088d3dd380e3f58ef7153611d817250d2cef333 Mon Sep 17 00:00:00 2001 From: Paul Tan Date: Sat, 10 Dec 2016 21:52:42 +0700 Subject: [PATCH 06/29] checkstyle: accept LF, CR or CRLF as line endings (#194) Checking out this repo on a Windows machine with a vanilla Git config, then running `gradlew.bat checkstyleMain` gives the following errors: [ant:checkstyle] [ERROR] C:\Users\pyokagan\pyk\addressbook-level4\src\main\java\ seedu\address\MainApp.java:0: File does not end with a newline. [NewlineAtEndOfF ile] [ant:checkstyle] [ERROR] C:\Users\pyokagan\pyk\addressbook-level4\src\main\java\ seedu\address\commons\core\ComponentManager.java:0: File does not end with a new line. [NewlineAtEndOfFile] [ant:checkstyle] [ERROR] C:\Users\pyokagan\pyk\addressbook-level4\src\main\java\ seedu\address\commons\core\Config.java:0: File does not end with a newline. [New lineAtEndOfFile] [ant:checkstyle] [ERROR] C:\Users\pyokagan\pyk\addressbook-level4\src\main\java\ seedu\address\commons\core\EventsCenter.java:0: File does not end with a newline . [NewlineAtEndOfFile] [ant:checkstyle] [ERROR] C:\Users\pyokagan\pyk\addressbook-level4\src\main\java\ seedu\address\commons\core\GuiSettings.java:0: File does not end with a newline. [NewlineAtEndOfFile] [ant:checkstyle] [ERROR] C:\Users\pyokagan\pyk\addressbook-level4\src\main\java\ seedu\address\commons\core\LogsCenter.java:0: File does not end with a newline. [NewlineAtEndOfFile] [ant:checkstyle] [ERROR] C:\Users\pyokagan\pyk\addressbook-level4\src\main\java\ seedu\address\commons\core\Messages.java:0: File does not end with a newline. [N ewlineAtEndOfFile] [ant:checkstyle] [ERROR] C:\Users\pyokagan\pyk\addressbook-level4\src\main\java\ seedu\address\commons\core\UnmodifiableObservableList.java:0: File does not end with a newline. [NewlineAtEndOfFile] ...etc This goes on for every single Java file. This is because this repo's files uses LF as the line separator. However, the default "lineSeparator" value of the "NewlineAtEndOfFile" check is CRLF on Windows[1], hence these errors. One may argue that we could switch on `core.autocrlf` in Git, which would tell Git to automatically convert all LF line endings to CRLF, thus avoiding this problem. However, this not only places an additional burden on Windows users to configure Git properly, it also does not handle the use cases where a developer is not using Git. The developer may, for example, instead get hold of the repo by downloading the ZIP file using Github's "Download as ZIP"[2] functionality, and will thus still have this problem as the downloaded ZIP contents will still contain LF line endings. Thus, we should either switch the "lineSeparator" property to "lf", accepting only LF line endings, or "lf_cr_crlf", accepting LF, CR or CRLF line endings. (Checkstyle does not support just LF and CRLF only) However, some developers may have `core.autocrlf` accidentally set, or may even prefer to use CRLF line endings in their working copy. As such, let's go the route of allowing LF, CR or CRLF as line endings. [1] http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile [2] https://github.com/se-edu/addressbook-level4/archive/master.zip --- config/checkstyle/checkstyle.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 40c6d06b3ff7..ddb9159eb7de 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -14,7 +14,10 @@ - + + + + From e68f4529ea42ac5929472b76fbb4a7bf9e8cbbf2 Mon Sep 17 00:00:00 2001 From: Paul Tan Date: Sat, 10 Dec 2016 21:53:24 +0700 Subject: [PATCH 07/29] checkstyle: ensure curly brackets have whitespace around them #181 (#182) * codestyle: ensure curly brackets are separated by whitespace The Java coding standard[1] requires that curly brackets ({}) be surrounded by whitespace. However, there are several violations of this requirement in the code base. e.g. protected void raise(BaseEvent event){ -------------------------------------^ Space required before '{' Fix all of these code style violations. [1] https://oss-generic.github.io/process/codingstandards/coding-standards-java.html#methods * checkstyle: ensure curly brackets have whitespace around them There used to be methods in the code base where the curly brackets ({}) are not separated by whitespace: protected void raise(BaseEvent event){ -------------------------------------^ Space required before '{' Our checkstyle configuration failed to catch these errors because we did not tell checkstyle to check for the LCURLY, RCURLY and SLIST (statement list) tokens. Fix this in the checkstyle config file so that such code style violations will not happen again. --- config/checkstyle/checkstyle.xml | 14 ++++++++++++-- src/main/java/seedu/address/MainApp.java | 2 +- .../address/commons/core/ComponentManager.java | 4 ++-- .../java/seedu/address/commons/core/Config.java | 6 +++--- .../seedu/address/commons/core/GuiSettings.java | 6 +++--- .../events/model/AddressBookChangedEvent.java | 2 +- .../events/storage/DataSavingExceptionEvent.java | 2 +- .../ui/PersonPanelSelectionChangedEvent.java | 2 +- .../seedu/address/commons/util/StringUtil.java | 6 +++--- .../address/logic/commands/IncorrectCommand.java | 2 +- .../java/seedu/address/logic/parser/Parser.java | 2 +- .../java/seedu/address/model/ModelManager.java | 2 +- src/main/java/seedu/address/model/UserPrefs.java | 4 ++-- .../address/storage/JsonUserPrefsStorage.java | 2 +- .../address/storage/XmlAddressBookStorage.java | 4 ++-- src/main/java/seedu/address/ui/BrowserPanel.java | 6 +++--- src/main/java/seedu/address/ui/CommandBox.java | 2 +- src/main/java/seedu/address/ui/HelpWindow.java | 2 +- src/main/java/seedu/address/ui/UiPart.java | 2 +- src/test/java/guitests/CommandBoxTest.java | 2 +- src/test/java/guitests/ErrorDialogGuiTest.java | 2 +- src/test/java/guitests/FindCommandTest.java | 2 +- src/test/java/guitests/GuiRobot.java | 2 +- src/test/java/guitests/SelectCommandTest.java | 2 +- .../java/guitests/guihandles/CommandBoxHandle.java | 2 +- .../java/guitests/guihandles/PersonCardHandle.java | 2 +- .../guitests/guihandles/PersonListPanelHandle.java | 2 +- .../seedu/address/commons/core/ConfigTest.java | 2 +- .../seedu/address/commons/util/AppUtilTest.java | 4 ++-- .../seedu/address/commons/util/FileUtilTest.java | 2 +- .../seedu/address/commons/util/StringUtilTest.java | 14 +++++++------- .../java/seedu/address/logic/LogicManagerTest.java | 12 ++++++------ .../seedu/address/storage/StorageManagerTest.java | 4 ++-- .../seedu/address/testutil/AddressBookBuilder.java | 4 ++-- .../seedu/address/testutil/EventsCollector.java | 10 +++++----- 35 files changed, 75 insertions(+), 65 deletions(-) diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index ddb9159eb7de..afef652d6091 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -218,11 +218,21 @@ --> + RCURLY, SL, SLIST, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/> + + + + + + + + + + diff --git a/src/main/java/seedu/address/MainApp.java b/src/main/java/seedu/address/MainApp.java index a270b024b975..eac4aea5f4af 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/seedu/address/MainApp.java @@ -62,7 +62,7 @@ public void init() throws Exception { initEventsCenter(); } - private String getApplicationParameter(String parameterName){ + private String getApplicationParameter(String parameterName) { Map applicationParameters = getParameters().getNamed(); return applicationParameters.get(parameterName); } diff --git a/src/main/java/seedu/address/commons/core/ComponentManager.java b/src/main/java/seedu/address/commons/core/ComponentManager.java index 4bc8564e5824..05a400773ae8 100644 --- a/src/main/java/seedu/address/commons/core/ComponentManager.java +++ b/src/main/java/seedu/address/commons/core/ComponentManager.java @@ -13,7 +13,7 @@ public abstract class ComponentManager { /** * Uses default {@link EventsCenter} */ - public ComponentManager(){ + public ComponentManager() { this(EventsCenter.getInstance()); } @@ -22,7 +22,7 @@ public ComponentManager(EventsCenter eventsCenter) { eventsCenter.registerHandler(this); } - protected void raise(BaseEvent event){ + protected void raise(BaseEvent event) { eventsCenter.post(event); } } diff --git a/src/main/java/seedu/address/commons/core/Config.java b/src/main/java/seedu/address/commons/core/Config.java index ce6994269a77..d4dc73132d5c 100644 --- a/src/main/java/seedu/address/commons/core/Config.java +++ b/src/main/java/seedu/address/commons/core/Config.java @@ -61,10 +61,10 @@ public void setAddressBookName(String addressBookName) { @Override public boolean equals(Object other) { - if (other == this){ + if (other == this) { return true; } - if (!(other instanceof Config)){ //this handles null as well. + if (!(other instanceof Config)) { //this handles null as well. return false; } @@ -83,7 +83,7 @@ public int hashCode() { } @Override - public String toString(){ + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("App title : " + appTitle); sb.append("\nCurrent log level : " + logLevel); diff --git a/src/main/java/seedu/address/commons/core/GuiSettings.java b/src/main/java/seedu/address/commons/core/GuiSettings.java index 561606aebba0..727a1e6a5e97 100644 --- a/src/main/java/seedu/address/commons/core/GuiSettings.java +++ b/src/main/java/seedu/address/commons/core/GuiSettings.java @@ -42,10 +42,10 @@ public Point getWindowCoordinates() { @Override public boolean equals(Object other) { - if (other == this){ + if (other == this) { return true; } - if (!(other instanceof GuiSettings)){ //this handles null as well. + if (!(other instanceof GuiSettings)) { //this handles null as well. return false; } @@ -63,7 +63,7 @@ public int hashCode() { } @Override - public String toString(){ + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Width : " + windowWidth + "\n"); sb.append("Height : " + windowHeight + "\n"); diff --git a/src/main/java/seedu/address/commons/events/model/AddressBookChangedEvent.java b/src/main/java/seedu/address/commons/events/model/AddressBookChangedEvent.java index 347a8359e0d5..7db9b5c48ed6 100644 --- a/src/main/java/seedu/address/commons/events/model/AddressBookChangedEvent.java +++ b/src/main/java/seedu/address/commons/events/model/AddressBookChangedEvent.java @@ -8,7 +8,7 @@ public class AddressBookChangedEvent extends BaseEvent { public final ReadOnlyAddressBook data; - public AddressBookChangedEvent(ReadOnlyAddressBook data){ + public AddressBookChangedEvent(ReadOnlyAddressBook data) { this.data = data; } diff --git a/src/main/java/seedu/address/commons/events/storage/DataSavingExceptionEvent.java b/src/main/java/seedu/address/commons/events/storage/DataSavingExceptionEvent.java index f0a0640ee523..51cf8ce68a76 100644 --- a/src/main/java/seedu/address/commons/events/storage/DataSavingExceptionEvent.java +++ b/src/main/java/seedu/address/commons/events/storage/DataSavingExceptionEvent.java @@ -14,7 +14,7 @@ public DataSavingExceptionEvent(Exception exception) { } @Override - public String toString(){ + public String toString() { return exception.toString(); } diff --git a/src/main/java/seedu/address/commons/events/ui/PersonPanelSelectionChangedEvent.java b/src/main/java/seedu/address/commons/events/ui/PersonPanelSelectionChangedEvent.java index 95377b326fa6..76e08f587e02 100644 --- a/src/main/java/seedu/address/commons/events/ui/PersonPanelSelectionChangedEvent.java +++ b/src/main/java/seedu/address/commons/events/ui/PersonPanelSelectionChangedEvent.java @@ -11,7 +11,7 @@ public class PersonPanelSelectionChangedEvent extends BaseEvent { private final ReadOnlyPerson newSelection; - public PersonPanelSelectionChangedEvent(ReadOnlyPerson newSelection){ + public PersonPanelSelectionChangedEvent(ReadOnlyPerson newSelection) { this.newSelection = newSelection; } diff --git a/src/main/java/seedu/address/commons/util/StringUtil.java b/src/main/java/seedu/address/commons/util/StringUtil.java index fd7fb71516cb..7f1998fa4c51 100644 --- a/src/main/java/seedu/address/commons/util/StringUtil.java +++ b/src/main/java/seedu/address/commons/util/StringUtil.java @@ -30,7 +30,7 @@ public static boolean containsWordIgnoreCase(String sentence, String word) { String preppedSentence = sentence; String[] wordsInPreppedSentence = preppedSentence.split("\\s+"); - for (String wordInSentence: wordsInPreppedSentence){ + for (String wordInSentence: wordsInPreppedSentence) { if (wordInSentence.equalsIgnoreCase(preppedWord)) return true; } return false; @@ -39,7 +39,7 @@ public static boolean containsWordIgnoreCase(String sentence, String word) { /** * Returns a detailed message of the t, including the stack trace. */ - public static String getDetails(Throwable t){ + public static String getDetails(Throwable t) { assert t != null; StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); @@ -52,7 +52,7 @@ public static String getDetails(Throwable t){ * null, empty string, "-1", "0", "+1", and " 2 " (untrimmed) "3 0" (contains whitespace). * @param s Should be trimmed. */ - public static boolean isUnsignedInteger(String s){ + public static boolean isUnsignedInteger(String s) { return s != null && s.matches("^0*[1-9]\\d*$"); } } diff --git a/src/main/java/seedu/address/logic/commands/IncorrectCommand.java b/src/main/java/seedu/address/logic/commands/IncorrectCommand.java index 491d9cb9da35..0b1960871c34 100644 --- a/src/main/java/seedu/address/logic/commands/IncorrectCommand.java +++ b/src/main/java/seedu/address/logic/commands/IncorrectCommand.java @@ -8,7 +8,7 @@ public class IncorrectCommand extends Command { public final String feedbackToUser; - public IncorrectCommand(String feedbackToUser){ + public IncorrectCommand(String feedbackToUser) { this.feedbackToUser = feedbackToUser; } diff --git a/src/main/java/seedu/address/logic/parser/Parser.java b/src/main/java/seedu/address/logic/parser/Parser.java index 80179b54147b..866a1b2da4c6 100644 --- a/src/main/java/seedu/address/logic/parser/Parser.java +++ b/src/main/java/seedu/address/logic/parser/Parser.java @@ -82,7 +82,7 @@ public Command parseCommand(String userInput) { * @param args full command args string * @return the prepared command */ - private Command prepareAdd(String args){ + private Command prepareAdd(String args) { ArgumentTokenizer argsTokenizer = new ArgumentTokenizer(phoneNumberPrefix, emailPrefix, addressPrefix, tagsPrefix); argsTokenizer.tokenize(args); diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index f77b3987c020..6c0f3edc42ff 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -90,7 +90,7 @@ public void updateFilteredListToShowAll() { } @Override - public void updateFilteredPersonList(Set keywords){ + public void updateFilteredPersonList(Set keywords) { updateFilteredPersonList(new PredicateExpression(new NameQualifier(keywords))); } diff --git a/src/main/java/seedu/address/model/UserPrefs.java b/src/main/java/seedu/address/model/UserPrefs.java index 0cbf893ad026..5393df76460d 100644 --- a/src/main/java/seedu/address/model/UserPrefs.java +++ b/src/main/java/seedu/address/model/UserPrefs.java @@ -19,7 +19,7 @@ public void updateLastUsedGuiSetting(GuiSettings guiSettings) { this.guiSettings = guiSettings; } - public UserPrefs(){ + public UserPrefs() { this.setGuiSettings(500, 500, 0, 0); } @@ -47,7 +47,7 @@ public int hashCode() { } @Override - public String toString(){ + public String toString() { return guiSettings.toString(); } diff --git a/src/main/java/seedu/address/storage/JsonUserPrefsStorage.java b/src/main/java/seedu/address/storage/JsonUserPrefsStorage.java index 10905d644168..bca57788e05f 100644 --- a/src/main/java/seedu/address/storage/JsonUserPrefsStorage.java +++ b/src/main/java/seedu/address/storage/JsonUserPrefsStorage.java @@ -14,7 +14,7 @@ public class JsonUserPrefsStorage implements UserPrefsStorage { private String filePath; - public JsonUserPrefsStorage(String filePath){ + public JsonUserPrefsStorage(String filePath) { this.filePath = filePath; } diff --git a/src/main/java/seedu/address/storage/XmlAddressBookStorage.java b/src/main/java/seedu/address/storage/XmlAddressBookStorage.java index bfeda7b006a8..80fa00805068 100644 --- a/src/main/java/seedu/address/storage/XmlAddressBookStorage.java +++ b/src/main/java/seedu/address/storage/XmlAddressBookStorage.java @@ -20,11 +20,11 @@ public class XmlAddressBookStorage implements AddressBookStorage { private String filePath; - public XmlAddressBookStorage(String filePath){ + public XmlAddressBookStorage(String filePath) { this.filePath = filePath; } - public String getAddressBookFilePath(){ + public String getAddressBookFilePath() { return filePath; } diff --git a/src/main/java/seedu/address/ui/BrowserPanel.java b/src/main/java/seedu/address/ui/BrowserPanel.java index cdd192a615df..48abca3ae00f 100644 --- a/src/main/java/seedu/address/ui/BrowserPanel.java +++ b/src/main/java/seedu/address/ui/BrowserPanel.java @@ -13,7 +13,7 @@ /** * The Browser Panel of the App. */ -public class BrowserPanel extends UiPart{ +public class BrowserPanel extends UiPart { private static Logger logger = LogsCenter.getLogger(BrowserPanel.class); private WebView browser; @@ -40,7 +40,7 @@ public String getFxmlPath() { * This method should be called after the FX runtime is initialized and in FX application thread. * @param placeholder The AnchorPane where the BrowserPanel must be inserted */ - public static BrowserPanel load(AnchorPane placeholder){ + public static BrowserPanel load(AnchorPane placeholder) { logger.info("Initializing browser"); BrowserPanel browserPanel = new BrowserPanel(); browserPanel.browser = new WebView(); @@ -55,7 +55,7 @@ public void loadPersonPage(ReadOnlyPerson person) { loadPage("https://www.google.com.sg/#safe=off&q=" + person.getName().fullName.replaceAll(" ", "+")); } - public void loadPage(String url){ + public void loadPage(String url) { browser.getEngine().load(url); } diff --git a/src/main/java/seedu/address/ui/CommandBox.java b/src/main/java/seedu/address/ui/CommandBox.java index c23231856ead..018956f3020a 100644 --- a/src/main/java/seedu/address/ui/CommandBox.java +++ b/src/main/java/seedu/address/ui/CommandBox.java @@ -87,7 +87,7 @@ private void setStyleToIndicateCorrectCommand() { } @Subscribe - private void handleIncorrectCommandAttempted(IncorrectCommandAttemptedEvent event){ + private void handleIncorrectCommandAttempted(IncorrectCommandAttemptedEvent event) { logger.info(LogsCenter.getEventHandlingLogMessage(event, "Invalid command: " + previousCommandText)); setStyleToIndicateIncorrectCommand(); restoreCommandText(); diff --git a/src/main/java/seedu/address/ui/HelpWindow.java b/src/main/java/seedu/address/ui/HelpWindow.java index e9a530e5cf64..238defddd668 100644 --- a/src/main/java/seedu/address/ui/HelpWindow.java +++ b/src/main/java/seedu/address/ui/HelpWindow.java @@ -43,7 +43,7 @@ public String getFxmlPath() { return FXML; } - private void configure(){ + private void configure() { Scene scene = new Scene(mainPane); //Null passed as the parent stage to make it non-modal. dialogStage = createDialogStage(TITLE, null, scene); diff --git a/src/main/java/seedu/address/ui/UiPart.java b/src/main/java/seedu/address/ui/UiPart.java index 70207cafaab5..a0b09ba63203 100644 --- a/src/main/java/seedu/address/ui/UiPart.java +++ b/src/main/java/seedu/address/ui/UiPart.java @@ -18,7 +18,7 @@ public abstract class UiPart { * Raises the event via {@link EventsCenter#post(BaseEvent)} * @param event */ - protected void raise(BaseEvent event){ + protected void raise(BaseEvent event) { EventsCenter.getInstance().post(event); } diff --git a/src/test/java/guitests/CommandBoxTest.java b/src/test/java/guitests/CommandBoxTest.java index 1379198bf8b0..38a4b9b7d217 100644 --- a/src/test/java/guitests/CommandBoxTest.java +++ b/src/test/java/guitests/CommandBoxTest.java @@ -13,7 +13,7 @@ public void commandBox_commandSucceeds_textCleared() { } @Test - public void commandBox_commandFails_textStays(){ + public void commandBox_commandFails_textStays() { commandBox.runCommand("invalid command"); assertEquals(commandBox.getCommandInput(), "invalid command"); //TODO: confirm the text box color turns to red diff --git a/src/test/java/guitests/ErrorDialogGuiTest.java b/src/test/java/guitests/ErrorDialogGuiTest.java index 5b2341c758c1..1e957580000e 100644 --- a/src/test/java/guitests/ErrorDialogGuiTest.java +++ b/src/test/java/guitests/ErrorDialogGuiTest.java @@ -8,7 +8,7 @@ import static junit.framework.TestCase.assertTrue; -public class ErrorDialogGuiTest extends AddressBookGuiTest{ +public class ErrorDialogGuiTest extends AddressBookGuiTest { @Test public void showErrorDialogs() throws InterruptedException { diff --git a/src/test/java/guitests/FindCommandTest.java b/src/test/java/guitests/FindCommandTest.java index a4504ae94fff..67db26b12e53 100644 --- a/src/test/java/guitests/FindCommandTest.java +++ b/src/test/java/guitests/FindCommandTest.java @@ -19,7 +19,7 @@ public void find_nonEmptyList() { } @Test - public void find_emptyList(){ + public void find_emptyList() { commandBox.runCommand("clear"); assertFindResult("find Jean"); // no results } diff --git a/src/test/java/guitests/GuiRobot.java b/src/test/java/guitests/GuiRobot.java index 44aa9edb48aa..71fa1f1463b8 100644 --- a/src/test/java/guitests/GuiRobot.java +++ b/src/test/java/guitests/GuiRobot.java @@ -10,7 +10,7 @@ */ public class GuiRobot extends FxRobot { - public GuiRobot push(KeyCodeCombination keyCodeCombination){ + public GuiRobot push(KeyCodeCombination keyCodeCombination) { return (GuiRobot) super.push(TestUtil.scrub(keyCodeCombination)); } diff --git a/src/test/java/guitests/SelectCommandTest.java b/src/test/java/guitests/SelectCommandTest.java index 91a8d50c3b57..d21fb5c13b28 100644 --- a/src/test/java/guitests/SelectCommandTest.java +++ b/src/test/java/guitests/SelectCommandTest.java @@ -27,7 +27,7 @@ public void selectPerson_nonEmptyList() { } @Test - public void selectPerson_emptyList(){ + public void selectPerson_emptyList() { commandBox.runCommand("clear"); assertListSize(0); assertSelectionInvalid(1); //invalid index diff --git a/src/test/java/guitests/guihandles/CommandBoxHandle.java b/src/test/java/guitests/guihandles/CommandBoxHandle.java index dcd3155636cd..ccf484b9c42e 100644 --- a/src/test/java/guitests/guihandles/CommandBoxHandle.java +++ b/src/test/java/guitests/guihandles/CommandBoxHandle.java @@ -6,7 +6,7 @@ /** * A handle to the Command Box in the GUI. */ -public class CommandBoxHandle extends GuiHandle{ +public class CommandBoxHandle extends GuiHandle { private static final String COMMAND_INPUT_FIELD_ID = "#commandTextField"; diff --git a/src/test/java/guitests/guihandles/PersonCardHandle.java b/src/test/java/guitests/guihandles/PersonCardHandle.java index a64d9b9ecd4e..dc5e8e025618 100644 --- a/src/test/java/guitests/guihandles/PersonCardHandle.java +++ b/src/test/java/guitests/guihandles/PersonCardHandle.java @@ -16,7 +16,7 @@ public class PersonCardHandle extends GuiHandle { private Node node; - public PersonCardHandle(GuiRobot guiRobot, Stage primaryStage, Node node){ + public PersonCardHandle(GuiRobot guiRobot, Stage primaryStage, Node node) { super(guiRobot, primaryStage, null); this.node = node; } diff --git a/src/test/java/guitests/guihandles/PersonListPanelHandle.java b/src/test/java/guitests/guihandles/PersonListPanelHandle.java index ce03fdcaa020..2334f5b60086 100644 --- a/src/test/java/guitests/guihandles/PersonListPanelHandle.java +++ b/src/test/java/guitests/guihandles/PersonListPanelHandle.java @@ -63,7 +63,7 @@ public boolean containsInOrder(int startPosition, ReadOnlyPerson... persons) { List personsInList = getListView().getItems(); // Return false if the list in panel is too short to contain the given list - if (startPosition + persons.length > personsInList.size()){ + if (startPosition + persons.length > personsInList.size()) { return false; } diff --git a/src/test/java/seedu/address/commons/core/ConfigTest.java b/src/test/java/seedu/address/commons/core/ConfigTest.java index 77b4fff22688..a06a48c890fd 100644 --- a/src/test/java/seedu/address/commons/core/ConfigTest.java +++ b/src/test/java/seedu/address/commons/core/ConfigTest.java @@ -22,7 +22,7 @@ public void toString_defaultObject_stringReturned() { } @Test - public void equalsMethod(){ + public void equalsMethod() { Config defaultConfig = new Config(); assertNotNull(defaultConfig); assertTrue(defaultConfig.equals(defaultConfig)); diff --git a/src/test/java/seedu/address/commons/util/AppUtilTest.java b/src/test/java/seedu/address/commons/util/AppUtilTest.java index fbea1d0c1e8e..2899e4aeb054 100644 --- a/src/test/java/seedu/address/commons/util/AppUtilTest.java +++ b/src/test/java/seedu/address/commons/util/AppUtilTest.java @@ -14,13 +14,13 @@ public class AppUtilTest { @Test - public void getImage_exitingImage(){ + public void getImage_exitingImage() { assertNotNull(AppUtil.getImage("/images/address_book_32.png")); } @Test - public void getImage_nullGiven_assertionError(){ + public void getImage_nullGiven_assertionError() { thrown.expect(AssertionError.class); AppUtil.getImage(null); } diff --git a/src/test/java/seedu/address/commons/util/FileUtilTest.java b/src/test/java/seedu/address/commons/util/FileUtilTest.java index 564a35ada340..c566dd9b5b12 100644 --- a/src/test/java/seedu/address/commons/util/FileUtilTest.java +++ b/src/test/java/seedu/address/commons/util/FileUtilTest.java @@ -15,7 +15,7 @@ public class FileUtilTest { public ExpectedException thrown = ExpectedException.none(); @Test - public void getPath(){ + public void getPath() { // valid case assertEquals("folder" + File.separator + "sub-folder", FileUtil.getPath("folder/sub-folder")); diff --git a/src/test/java/seedu/address/commons/util/StringUtilTest.java b/src/test/java/seedu/address/commons/util/StringUtilTest.java index cea531819726..8fcf575d4467 100644 --- a/src/test/java/seedu/address/commons/util/StringUtilTest.java +++ b/src/test/java/seedu/address/commons/util/StringUtilTest.java @@ -58,7 +58,7 @@ public void isUnsignedPositiveInteger() { */ @Test - public void containsWordIgnoreCase_nullWord_exceptionThrown(){ + public void containsWordIgnoreCase_nullWord_exceptionThrown() { assertExceptionThrown("typical sentence", null, "Word parameter cannot be null"); } @@ -69,17 +69,17 @@ private void assertExceptionThrown(String sentence, String word, String errorMes } @Test - public void containsWordIgnoreCase_emptyWord_exceptionThrown(){ + public void containsWordIgnoreCase_emptyWord_exceptionThrown() { assertExceptionThrown("typical sentence", " ", "Word parameter cannot be empty"); } @Test - public void containsWordIgnoreCase_multipleWords_exceptionThrown(){ + public void containsWordIgnoreCase_multipleWords_exceptionThrown() { assertExceptionThrown("typical sentence", "aaa BBB", "Word parameter should be a single word"); } @Test - public void containsWordIgnoreCase_nullSentence_exceptionThrown(){ + public void containsWordIgnoreCase_nullSentence_exceptionThrown() { assertExceptionThrown(null, "abc", "Sentence parameter cannot be null"); } @@ -109,7 +109,7 @@ public void containsWordIgnoreCase_nullSentence_exceptionThrown(){ */ @Test - public void containsWordIgnoreCase_validInputs_correctResult(){ + public void containsWordIgnoreCase_validInputs_correctResult() { // Empty sentence assertFalse(StringUtil.containsWordIgnoreCase("", "abc")); // Boundary case @@ -137,13 +137,13 @@ public void containsWordIgnoreCase_validInputs_correctResult(){ */ @Test - public void getDetails_exceptionGiven(){ + public void getDetails_exceptionGiven() { assertThat(StringUtil.getDetails(new FileNotFoundException("file not found")), containsString("java.io.FileNotFoundException: file not found")); } @Test - public void getDetails_nullGiven_assertionError(){ + public void getDetails_nullGiven_assertionError() { thrown.expect(AssertionError.class); StringUtil.getDetails(null); } diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index fad79d725c32..d4583aaf1e0f 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -378,7 +378,7 @@ public void execute_find_matchesIfAnyKeywordPresent() throws Exception { /** * A utility class to generate test data. */ - class TestDataHelper{ + class TestDataHelper { Person adam() throws Exception { Name name = new Name("Adam Brown"); @@ -430,7 +430,7 @@ String generateAddCommand(Person p) { /** * Generates an AddressBook with auto-generated persons. */ - AddressBook generateAddressBook(int numGenerated) throws Exception{ + AddressBook generateAddressBook(int numGenerated) throws Exception { AddressBook addressBook = new AddressBook(); addToAddressBook(addressBook, numGenerated); return addressBook; @@ -439,7 +439,7 @@ AddressBook generateAddressBook(int numGenerated) throws Exception{ /** * Generates an AddressBook based on the list of Persons given. */ - AddressBook generateAddressBook(List persons) throws Exception{ + AddressBook generateAddressBook(List persons) throws Exception { AddressBook addressBook = new AddressBook(); addToAddressBook(addressBook, persons); return addressBook; @@ -466,14 +466,14 @@ void addToAddressBook(AddressBook addressBook, List personsToAdd) throws * Adds auto-generated Person objects to the given model * @param model The model to which the Persons will be added */ - void addToModel(Model model, int numGenerated) throws Exception{ + void addToModel(Model model, int numGenerated) throws Exception { addToModel(model, generatePersonList(numGenerated)); } /** * Adds the given list of Persons to the given model */ - void addToModel(Model model, List personsToAdd) throws Exception{ + void addToModel(Model model, List personsToAdd) throws Exception { for (Person p: personsToAdd) { model.addPerson(p); } @@ -482,7 +482,7 @@ void addToModel(Model model, List personsToAdd) throws Exception{ /** * Generates a list of Persons based on the flags. */ - List generatePersonList(int numGenerated) throws Exception{ + List generatePersonList(int numGenerated) throws Exception { List persons = new ArrayList<>(); for (int i = 1; i <= numGenerated; i++) { persons.add(generatePerson(i)); diff --git a/src/test/java/seedu/address/storage/StorageManagerTest.java b/src/test/java/seedu/address/storage/StorageManagerTest.java index 60dd8987ee84..b783b7514d91 100644 --- a/src/test/java/seedu/address/storage/StorageManagerTest.java +++ b/src/test/java/seedu/address/storage/StorageManagerTest.java @@ -66,7 +66,7 @@ public void addressBookReadSave() throws Exception { } @Test - public void getAddressBookFilePath(){ + public void getAddressBookFilePath() { assertNotNull(storageManager.getAddressBookFilePath()); } @@ -84,7 +84,7 @@ public void handleAddressBookChangedEvent_exceptionThrown_eventRaised() throws I /** * A Stub class to throw an exception when the save method is called */ - class XmlAddressBookStorageExceptionThrowingStub extends XmlAddressBookStorage{ + class XmlAddressBookStorageExceptionThrowingStub extends XmlAddressBookStorage { public XmlAddressBookStorageExceptionThrowingStub(String filePath) { super(filePath); diff --git a/src/test/java/seedu/address/testutil/AddressBookBuilder.java b/src/test/java/seedu/address/testutil/AddressBookBuilder.java index a623b81c878f..a4fd4c1687a6 100644 --- a/src/test/java/seedu/address/testutil/AddressBookBuilder.java +++ b/src/test/java/seedu/address/testutil/AddressBookBuilder.java @@ -15,7 +15,7 @@ public class AddressBookBuilder { private AddressBook addressBook; - public AddressBookBuilder(AddressBook addressBook){ + public AddressBookBuilder(AddressBook addressBook) { this.addressBook = addressBook; } @@ -29,7 +29,7 @@ public AddressBookBuilder withTag(String tagName) throws IllegalValueException { return this; } - public AddressBook build(){ + public AddressBook build() { return addressBook; } } diff --git a/src/test/java/seedu/address/testutil/EventsCollector.java b/src/test/java/seedu/address/testutil/EventsCollector.java index 5945e0c793c3..44310ceb86bb 100644 --- a/src/test/java/seedu/address/testutil/EventsCollector.java +++ b/src/test/java/seedu/address/testutil/EventsCollector.java @@ -10,10 +10,10 @@ /** * A class that collects events raised by other classes. */ -public class EventsCollector{ +public class EventsCollector { private List events = new ArrayList(); - public EventsCollector(){ + public EventsCollector() { EventsCenter.getInstance().registerHandler(this); } @@ -21,21 +21,21 @@ public EventsCollector(){ * Collects any event raised by any class */ @Subscribe - public void collectEvent(BaseEvent event){ + public void collectEvent(BaseEvent event) { events.add(event); } /** * Removes collected events from the collected list */ - public void reset(){ + public void reset() { events.clear(); } /** * Returns the event at the specified index */ - public BaseEvent get(int index){ + public BaseEvent get(int index) { return events.get(index); } } From 845249d099d355a00bb33922e1a379033b0006dc Mon Sep 17 00:00:00 2001 From: Paul Tan Date: Tue, 13 Dec 2016 00:47:47 +0700 Subject: [PATCH 08/29] [#186] Construct BrowserPanel in FXML (#208) * Construct BrowserPanel using FXML The DeveloperGuide states that the layout of individual UiParts are specified in matching `.fxml` files. e.g. The layout of `MainWindow.java` is specified in `MainWindow.fxml`. While this is true for almost all UiParts, there is one oddball UiPart that does not have a corresponding `.fxml` file -- BrowserPanel. For consistency with the rest of the UiParts, let's construct the BrowserPanel using FXML rather than using code. * Remove DefaultBrowserPlaceHolderScreen.fxml It is not being used at all. --- .../java/seedu/address/ui/BrowserPanel.java | 16 ++++++-------- src/main/resources/view/BrowserPanel.fxml | 8 +++++++ .../view/DefaultBrowserPlaceHolderScreen.fxml | 21 ------------------- 3 files changed, 14 insertions(+), 31 deletions(-) create mode 100644 src/main/resources/view/BrowserPanel.fxml delete mode 100644 src/main/resources/view/DefaultBrowserPlaceHolderScreen.fxml diff --git a/src/main/java/seedu/address/ui/BrowserPanel.java b/src/main/java/seedu/address/ui/BrowserPanel.java index 48abca3ae00f..2ac2a568efa8 100644 --- a/src/main/java/seedu/address/ui/BrowserPanel.java +++ b/src/main/java/seedu/address/ui/BrowserPanel.java @@ -1,6 +1,7 @@ package seedu.address.ui; import javafx.event.Event; +import javafx.fxml.FXML; import javafx.scene.Node; import javafx.scene.layout.AnchorPane; import javafx.scene.web.WebView; @@ -16,14 +17,10 @@ public class BrowserPanel extends UiPart { private static Logger logger = LogsCenter.getLogger(BrowserPanel.class); - private WebView browser; - - /** - * Constructor is kept private as {@link #load(AnchorPane)} is the only way to create a BrowserPanel. - */ - private BrowserPanel() { + private static final String FXML = "BrowserPanel.fxml"; - } + @FXML + private WebView browser; @Override public void setNode(Node node) { @@ -32,7 +29,7 @@ public void setNode(Node node) { @Override public String getFxmlPath() { - return null; //not applicable + return FXML; } /** @@ -42,8 +39,7 @@ public String getFxmlPath() { */ public static BrowserPanel load(AnchorPane placeholder) { logger.info("Initializing browser"); - BrowserPanel browserPanel = new BrowserPanel(); - browserPanel.browser = new WebView(); + BrowserPanel browserPanel = UiPartLoader.loadUiPart(placeholder, new BrowserPanel()); placeholder.setOnKeyPressed(Event::consume); // To prevent triggering events for typing inside the // loaded Web page. FxViewUtil.applyAnchorBoundaryParameters(browserPanel.browser, 0.0, 0.0, 0.0, 0.0); diff --git a/src/main/resources/view/BrowserPanel.fxml b/src/main/resources/view/BrowserPanel.fxml new file mode 100644 index 000000000000..21c41d4db57f --- /dev/null +++ b/src/main/resources/view/BrowserPanel.fxml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/main/resources/view/DefaultBrowserPlaceHolderScreen.fxml b/src/main/resources/view/DefaultBrowserPlaceHolderScreen.fxml deleted file mode 100644 index bc761118235a..000000000000 --- a/src/main/resources/view/DefaultBrowserPlaceHolderScreen.fxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - From 38a52f5ad5e1bb97574f38950aa3b1246cc3b469 Mon Sep 17 00:00:00 2001 From: "Damith C. Rajapakse" Date: Wed, 14 Dec 2016 15:39:27 +0800 Subject: [PATCH 09/29] Move page title to the top of README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 448687e2e4af..3ab95a5d4ff4 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ +# Address Book (Level 4) + [![Build Status](https://travis-ci.org/se-edu/addressbook-level4.svg?branch=master)](https://travis-ci.org/se-edu/addressbook-level4) [![Coverage Status](https://coveralls.io/repos/github/se-edu/addressbook-level4/badge.svg?branch=master)](https://coveralls.io/github/se-edu/addressbook-level4?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/fc0b7775cf7f4fdeaf08776f3d8e364a)](https://www.codacy.com/app/damith/addressbook-level4?utm_source=github.com&utm_medium=referral&utm_content=se-edu/addressbook-level4&utm_campaign=Badge_Grade) -# Address Book (Level 4) -
* This is a desktop Address Book application. It has a GUI but most of the user interactions happen using From d1d17d8b8f5caa337653ab376411c27110303e40 Mon Sep 17 00:00:00 2001 From: Edmund Mok Date: Sun, 18 Dec 2016 16:29:19 +0800 Subject: [PATCH 10/29] [#173] Add background color to tags (#200) --- .../address/model/person/ReadOnlyPerson.java | 14 ------- .../java/seedu/address/ui/PersonCard.java | 9 +++- src/main/resources/view/DarkTheme.css | 14 +++++++ src/main/resources/view/PersonListCard.fxml | 19 +++++---- .../guitests/guihandles/PersonCardHandle.java | 42 +++++++++++++++++-- 5 files changed, 72 insertions(+), 26 deletions(-) diff --git a/src/main/java/seedu/address/model/person/ReadOnlyPerson.java b/src/main/java/seedu/address/model/person/ReadOnlyPerson.java index d45be4b5fe36..929fa3f70ddd 100644 --- a/src/main/java/seedu/address/model/person/ReadOnlyPerson.java +++ b/src/main/java/seedu/address/model/person/ReadOnlyPerson.java @@ -48,18 +48,4 @@ default String getAsText() { return builder.toString(); } - /** - * Returns a string representation of this Person's tags - */ - default String tagsString() { - final StringBuffer buffer = new StringBuffer(); - final String separator = ", "; - getTags().forEach(tag -> buffer.append(tag).append(separator)); - if (buffer.length() == 0) { - return ""; - } else { - return buffer.substring(0, buffer.length() - separator.length()); - } - } - } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 94b432281cc8..571bd0d21433 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -3,6 +3,7 @@ import javafx.fxml.FXML; import javafx.scene.Node; import javafx.scene.control.Label; +import javafx.scene.layout.FlowPane; import javafx.scene.layout.HBox; import seedu.address.model.person.ReadOnlyPerson; @@ -23,7 +24,7 @@ public class PersonCard extends UiPart { @FXML private Label email; @FXML - private Label tags; + private FlowPane tags; private ReadOnlyPerson person; private int displayedIndex; @@ -43,7 +44,7 @@ public void initialize() { phone.setText(person.getPhone().value); address.setText(person.getAddress().value); email.setText(person.getEmail().value); - tags.setText(person.tagsString()); + initTags(); } public HBox getLayout() { @@ -59,4 +60,8 @@ public void setNode(Node node) { public String getFxmlPath() { return FXML; } + + private void initTags() { + person.getTags().forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); + } } diff --git a/src/main/resources/view/DarkTheme.css b/src/main/resources/view/DarkTheme.css index 8043b344253a..93f7a7c9b708 100644 --- a/src/main/resources/view/DarkTheme.css +++ b/src/main/resources/view/DarkTheme.css @@ -285,4 +285,18 @@ #filterField, #personListPanel, #personWebpage { -fx-effect: innershadow(gaussian, black, 10, 0, 0, 0); +} + +#tags { + -fx-hgap: 7; + -fx-vgap: 3; +} + +#tags .label { + -fx-text-fill: white; + -fx-background-color: #383838; + -fx-padding: 1 3 1 3; + -fx-border-radius: 2; + -fx-background-radius: 2; + -fx-font-size: 11; } \ No newline at end of file diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml index 13d4b149651b..a8e0ee4f2a80 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -1,18 +1,23 @@ - - - + + + + + + + + + - + - - + @@ -28,9 +33,9 @@ -