From 70bddee2b51d987212876ab75625b58b5f44d89e Mon Sep 17 00:00:00 2001 From: Lin Yuxiang Date: Fri, 2 Mar 2018 02:53:14 +0800 Subject: [PATCH 001/234] v.10 team milestone discussion --- v10Discussion.txt | Bin 0 -> 8190 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 v10Discussion.txt diff --git a/v10Discussion.txt b/v10Discussion.txt new file mode 100644 index 0000000000000000000000000000000000000000..f5f0860df496501da277755c0c08d4efe07743a3 GIT binary patch literal 8190 zcmd6sOOG2x6oqRGi2vXf0x5!hb^#=a1X84g>^-)}abkPS*qMPp51g;g+*EbD-DNA2 z2w5KYbl{fnZMsQs(<05%Ax+ZHX{9^1;O^i+3$*VS#>r8l~Mmgf3E zv)AWGJ-JEmbblq!5q+vCmw# zlGA@O$&%NZ*CIb>&0ZSp)7RQ;on96s^+i*3gkqxWg=jXqx=GjiJ4@>at{{5I>u1t1q+`D=tLd=(Pf07fhdr+( z|2E?Uzds}yd4ch@R;+dBX}0}&Q|EhGhnMd4_cnX(eb&c3@!gd;f>PKzOMmOXZzW@y zzSq^W^jzO34_CjW@3Q1yvmfmJt!TqL$m;qU8Te-@xho;IlI386bz32@kp|W#@a)D0 zxP-KM=5U?q@gqFoMpP`bh4>d=4fDc3#~Kz}7wIoa*o!K>S9=!>c3MvaAbTaL>#RZX zEHw2RqftkLpHH=Va|V{qPJBlU-AN*GeIwkkvSb6Afg*R%J@oI!IC^5;X?)&^%T5#p z6C^q($lc9@?ZIIxYA`|G;loqM2vuPrkK4O*{gSz8w37y2X#5mZJja(lThuGvy zk2(@}C*n&bIOJ%oB^eji1_n36%{(^`$VI;Igrhlti>nP>iNLAia-DO5YPFF(ya2x3 zhXXzc89$}plqbci$mZ9gUyBlYS4q%f9q|)2tD7;Wt0Q<0S3@!!o^P^7AW2q+K4c)Z znTlR&GxT1!7FQ|(E5Haj#3@|rx(R*MGd$~Tc1`7(F|rIefKYgoyu*t`6BULSW(^vH z{af9+(r+MFD&I@dp_6l)=P&YqzDGoSp>@wP7pl!SlZpP0eel$Mwge5FBi~HEn!xAM z&r9i6qY7_FD;&d`F|NeW>CRI;TX-yGKlqVH(Z7zP#yN?0Lv^!o^VMC(_rBsdUM+|h z{8&ENTK+q}a+I^C)+eesu|{^qM8JC2b~;h<|1sao?hNs4X>JKEs>}UIMv_mSio%n% zciqQ`>aKrJ+e}o<#g#5qM@Q*VR0EJc~GC(kU!##1)cvOS+s zfy%nED>@y$uEwa#ua-J*TGjOr6|J5FT9{bV7F7$mV|%BH1ttfgEV@CzTOY3)zf&W} zWWcl=^S~z8gyE?GOj;I>Oa5F>`+dx_75&{gh{yh{Hp!gPzu*$F`PzmwRuxjz<;#K{_z)<5}19 zam)O)WSMQDZ!veWn`DY&x+;~P96#^Vvi>|SHPv`+33>5budJ^xN1aJMc9z|lBDxc^ zHhpiFXB+B|XT5s<2wLm%PWawvHY{DC@L+OT#KMi@jX8|j!BZPoK8^8?W7rbcHgq9MiDq^MYwZ?5u`7j21m!a0 z$#mq3Xuo-fGM5(YZd%q4YcqEDRHl6ztdC=@>*J^vF&B0tZYi9+H>)iwJmchND#Ryw zZ%PGPPhZ2Oa0b8_=$Q$IsHIW&g)#^ zeC}eaW1sIV^91jcJ?bj+6B^XKj!(2W|7&4jtXfnpq~i20kjE;jwXLJ)`h>ll$y`Z) zXsF=$7>^sb!lQphG>qZGbi+h-j@_Ua(Zv-L5T|LUPTtSm`+Yo;{Wl)bDa%aP&lgV@ z_33lG4e^_wK8|>WTI0ROsVpo$J;k|Y>&J6wNodDqAIa4Pqui&Ou-|b_ literal 0 HcmV?d00001 From 145a38ef2832c05e4112bd0739e374818339380c Mon Sep 17 00:00:00 2001 From: Lin Yuxiang Date: Sun, 4 Mar 2018 00:31:55 +0800 Subject: [PATCH 002/234] added dependency for JFoeniX (material design JAVAFX liberary) --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index 50cd2ae52efc..0d67aad8946c 100644 --- a/build.gradle +++ b/build.gradle @@ -46,6 +46,7 @@ dependencies { compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.0' compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.7.4' compile group: 'com.google.guava', name: 'guava', version: '19.0' + compile 'com.jfoenix:jfoenix:8.0.1' testCompile group: 'junit', name: 'junit', version: '4.12' testCompile group: 'org.testfx', name: 'testfx-core', version: testFxVersion From bdf3a6d518504966e1201f0bd6e31f90e845506b Mon Sep 17 00:00:00 2001 From: Lin Yuxiang Date: Sun, 4 Mar 2018 00:35:17 +0800 Subject: [PATCH 003/234] Seperated MenuPanerl away from Mainwindow New MenuPanel class to handle All menu UI related task --- .../java/seedu/address/ui/MainWindow.java | 89 +++++++---------- src/main/java/seedu/address/ui/MenuPanel.java | 97 +++++++++++++++++++ 2 files changed, 131 insertions(+), 55 deletions(-) create mode 100644 src/main/java/seedu/address/ui/MenuPanel.java diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 20ad5fee906a..f452f7f07731 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -2,21 +2,18 @@ import java.util.logging.Logger; -import com.google.common.eventbus.Subscribe; +import com.jfoenix.controls.JFXDrawer; +import com.jfoenix.controls.JFXHamburger; -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.input.MouseEvent; import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; import javafx.stage.Stage; + import seedu.address.commons.core.Config; import seedu.address.commons.core.GuiSettings; import seedu.address.commons.core.LogsCenter; -import seedu.address.commons.events.ui.ExitAppRequestEvent; -import seedu.address.commons.events.ui.ShowHelpRequestEvent; import seedu.address.logic.Logic; import seedu.address.model.UserPrefs; @@ -26,7 +23,7 @@ */ public class MainWindow extends UiPart { - private static final String FXML = "MainWindow.fxml"; + private static final String FXML = "NewMainWindow.fxml"; private final Logger logger = LogsCenter.getLogger(this.getClass()); @@ -36,6 +33,7 @@ public class MainWindow extends UiPart { // Independent Ui parts residing in this Ui container private BrowserPanel browserPanel; private PersonListPanel personListPanel; + private MenuPanel menuPanel; private Config config; private UserPrefs prefs; @@ -45,9 +43,6 @@ public class MainWindow extends UiPart { @FXML private StackPane commandBoxPlaceholder; - @FXML - private MenuItem helpMenuItem; - @FXML private StackPane personListPanelPlaceholder; @@ -57,6 +52,12 @@ public class MainWindow extends UiPart { @FXML private StackPane statusbarPlaceholder; + @FXML + private JFXDrawer menuDrawer; + + @FXML + private JFXHamburger menuButton; + public MainWindow(Stage primaryStage, Config config, UserPrefs prefs, Logic logic) { super(FXML, primaryStage); @@ -69,8 +70,7 @@ public MainWindow(Stage primaryStage, Config config, UserPrefs prefs, Logic logi // Configure the UI setTitle(config.getAppTitle()); setWindowDefaultSize(prefs); - - setAccelerators(); + setHamburgerListenerAndContent(); registerAsAnEventHandler(this); } @@ -78,40 +78,26 @@ 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 + * Sets Listener to hamburger to bring out the drawer. */ - 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(); + private void setHamburgerListenerAndContent() { + menuButton.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> { + if (menuDrawer.isShown()) { + menuDrawer.close(); + } else { + menuDrawer.open(); } }); } + /** + * Sets Content to drawer. + */ + private void setDrawerContent(VBox menu) { + menuDrawer.setSidePane(menu); + } + /** * Fills up all the placeholders of this window. */ @@ -122,6 +108,9 @@ void fillInnerParts() { personListPanel = new PersonListPanel(logic.getFilteredPersonList()); personListPanelPlaceholder.getChildren().add(personListPanel.getRoot()); + menuPanel = new MenuPanel(menuDrawer); + setDrawerContent(menuPanel.returnMenuVBox()); + ResultDisplay resultDisplay = new ResultDisplay(); resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot()); @@ -130,6 +119,8 @@ void fillInnerParts() { CommandBox commandBox = new CommandBox(logic); commandBoxPlaceholder.getChildren().add(commandBox.getRoot()); + + } void hide() { @@ -173,13 +164,7 @@ void show() { primaryStage.show(); } - /** - * Closes the application. - */ - @FXML - private void handleExit() { - raise(new ExitAppRequestEvent()); - } + public PersonListPanel getPersonListPanel() { return this.personListPanel; @@ -188,10 +173,4 @@ public PersonListPanel getPersonListPanel() { void releaseResources() { browserPanel.freeResources(); } - - @Subscribe - private void handleShowHelpEvent(ShowHelpRequestEvent event) { - logger.info(LogsCenter.getEventHandlingLogMessage(event)); - handleHelp(); - } } diff --git a/src/main/java/seedu/address/ui/MenuPanel.java b/src/main/java/seedu/address/ui/MenuPanel.java new file mode 100644 index 000000000000..0eefda1678ee --- /dev/null +++ b/src/main/java/seedu/address/ui/MenuPanel.java @@ -0,0 +1,97 @@ +package seedu.address.ui; + +import java.util.logging.Logger; + +import javax.swing.plaf.synth.Region; + +import com.google.common.eventbus.Subscribe; +import com.jfoenix.controls.JFXButton; +import com.jfoenix.controls.JFXDrawer; + +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.scene.input.KeyCombination; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.VBox; +import seedu.address.commons.core.LogsCenter; +import seedu.address.commons.events.ui.ExitAppRequestEvent; +import seedu.address.commons.events.ui.ShowHelpRequestEvent; + + +/** + * Panel containing menu buttons. + */ +public class MenuPanel extends UiPart { + + private static final String FXML = "MenuPanel.fxml"; + + private final Logger logger = LogsCenter.getLogger(PersonListPanel.class); + + @FXML + private VBox menuVbox; + + @FXML + private JFXButton helpMenuItem; + + @FXML + private JFXButton closeMenuButton; + + public MenuPanel(JFXDrawer drawer) { + super(FXML); + // setAccelerators(); + setcloseMenuButton(drawer); + registerAsAnEventHandler(this); + } + + 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(JFXButton menuItem, KeyCombination keyCombination) { + menuItem.getScene().getAccelerators().put(keyCombination, () -> helpMenuItem.fire()); + } + + /** + * Closes the application. + */ + @FXML + private void handleExit() { + raise(new ExitAppRequestEvent()); + } + + @Subscribe + private void handleShowHelpEvent(ShowHelpRequestEvent event) { + logger.info(LogsCenter.getEventHandlingLogMessage(event)); + handleHelp(); + } + + /** + * Opens the help window. + */ + @FXML + public void handleHelp() { + HelpWindow helpWindow = new HelpWindow(); + helpWindow.show(); + } + + /** + * close the menu panel. + */ + public void setcloseMenuButton(JFXDrawer drawer) { + closeMenuButton.addEventHandler(MouseEvent.MOUSE_PRESSED, new EventHandler() { + @Override + public void handle(MouseEvent e) { + drawer.close(); + } + }); + + } + + VBox returnMenuVBox() { + return menuVbox; + } +} From a8b470943f5a46b5eeb147baa35dda849142c496 Mon Sep 17 00:00:00 2001 From: Lin Yuxiang Date: Sun, 4 Mar 2018 00:36:03 +0800 Subject: [PATCH 004/234] Menu Panel JAVAFX layout --- src/main/resources/view/MenuPanel.fxml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/resources/view/MenuPanel.fxml diff --git a/src/main/resources/view/MenuPanel.fxml b/src/main/resources/view/MenuPanel.fxml new file mode 100644 index 000000000000..195dd15784f7 --- /dev/null +++ b/src/main/resources/view/MenuPanel.fxml @@ -0,0 +1,12 @@ + + + + + + + + + + + + From 4a6aa848c2c2e650b5355dfb70de31ec19574930 Mon Sep 17 00:00:00 2001 From: Lin Yuxiang Date: Sun, 4 Mar 2018 00:37:29 +0800 Subject: [PATCH 005/234] added menu button into main window new main window layout menu button now bring out a drawer that contains the menu panel --- src/main/resources/view/MainWindow.fxml | 13 ++--- src/main/resources/view/NewMainWindow.fxml | 67 ++++++++++++++++++++++ 2 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/view/NewMainWindow.fxml diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 1dadb95b6ffe..41a5fe8a8a84 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -11,6 +11,8 @@ + + @@ -24,14 +26,9 @@ - - - - - - - - + + + diff --git a/src/main/resources/view/NewMainWindow.fxml b/src/main/resources/view/NewMainWindow.fxml new file mode 100644 index 000000000000..419b5d4eee23 --- /dev/null +++ b/src/main/resources/view/NewMainWindow.fxml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a2e761a16f4992d8226c4c2646b4f4ba95998645 Mon Sep 17 00:00:00 2001 From: Lin Yuxiang Date: Sun, 4 Mar 2018 00:38:01 +0800 Subject: [PATCH 006/234] added animated textfield in CommandBox edited CSS theme --- src/main/resources/view/CommandBox.fxml | 9 +++++---- src/main/resources/view/DarkTheme.css | 3 --- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/resources/view/CommandBox.fxml b/src/main/resources/view/CommandBox.fxml index 16553ce8eadb..9fe388613d2b 100644 --- a/src/main/resources/view/CommandBox.fxml +++ b/src/main/resources/view/CommandBox.fxml @@ -1,9 +1,10 @@ - - + + - + + + - diff --git a/src/main/resources/view/DarkTheme.css b/src/main/resources/view/DarkTheme.css index d06336391cca..e39e6b71463e 100644 --- a/src/main/resources/view/DarkTheme.css +++ b/src/main/resources/view/DarkTheme.css @@ -319,9 +319,6 @@ #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; From 839f58a632ac326bbf46d335803987839be185be Mon Sep 17 00:00:00 2001 From: charleschang Date: Sun, 4 Mar 2018 11:27:19 +0800 Subject: [PATCH 007/234] add some comments for understanding --- src/main/java/seedu/address/MainApp.java | 6 +++++- src/main/java/seedu/address/commons/core/EventsCenter.java | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/MainApp.java b/src/main/java/seedu/address/MainApp.java index fa0800d55cb9..bf12b869a85d 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/seedu/address/MainApp.java @@ -52,6 +52,10 @@ public class MainApp extends Application { protected UserPrefs userPrefs; + /** + * This init method is called automatically by Application in javafx package + * @throws Exception + */ @Override public void init() throws Exception { logger.info("=============================[ Initializing AddressBook ]==========================="); @@ -76,7 +80,7 @@ public void init() throws Exception { } private String getApplicationParameter(String parameterName) { - Map applicationParameters = getParameters().getNamed(); + Map applicationParameters = this.getParameters().getNamed(); return applicationParameters.get(parameterName); } diff --git a/src/main/java/seedu/address/commons/core/EventsCenter.java b/src/main/java/seedu/address/commons/core/EventsCenter.java index 799b976f7eb7..80b8a72aa1b5 100644 --- a/src/main/java/seedu/address/commons/core/EventsCenter.java +++ b/src/main/java/seedu/address/commons/core/EventsCenter.java @@ -14,6 +14,9 @@ public class EventsCenter { private static EventsCenter instance; private final EventBus eventBus; + /** + * Private constructor to create global singleton + */ private EventsCenter() { eventBus = new EventBus(); } From e926aae6b6009a539635eeb4f616a61024486b08 Mon Sep 17 00:00:00 2001 From: charleschang Date: Sun, 4 Mar 2018 11:27:39 +0800 Subject: [PATCH 008/234] add an income field for the person model --- .../seedu/address/model/person/Income.java | 48 +++++++++++++++++++ .../seedu/address/model/person/Person.java | 6 +++ .../java/seedu/address/ui/PersonCard.java | 3 ++ src/main/resources/view/PersonListCard.fxml | 1 + 4 files changed, 58 insertions(+) create mode 100644 src/main/java/seedu/address/model/person/Income.java diff --git a/src/main/java/seedu/address/model/person/Income.java b/src/main/java/seedu/address/model/person/Income.java new file mode 100644 index 000000000000..cf8f1eca59b8 --- /dev/null +++ b/src/main/java/seedu/address/model/person/Income.java @@ -0,0 +1,48 @@ +package seedu.address.model.person; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; + +import java.text.NumberFormat; +import java.util.Locale; + + +/** + * Represents a Person's income in the address book + * Guarantees: immutable; is valid as declare in {@link #isValidIncome(float)}} + */ +public class Income { + public static final String MESSAGE_INCOME_CONSTRAITS = + "Person income must be positive numerical numbers, floating point value"; + + public final float income; + + /** + * @param income a valid income + */ + public Income(float income) { + requireNonNull(income); + checkArgument(this.isValidIncome(income), this.MESSAGE_INCOME_CONSTRAITS); + this.income = income; + } + + + private static boolean isValidIncome(float income) { + return (income >= 0); + } + + @Override + public String toString() { + NumberFormat format = NumberFormat.getCurrencyInstance(Locale.US); + return format.format(this.income); + } + + + @Override + public boolean equals(Object other) { + return other == this + || (other instanceof Income + && this.income == ((Income) other).income); + } + +} diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index ec9f2aa5e919..6b48af702399 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -21,6 +21,7 @@ public class Person { private final Address address; private final UniqueTagList tags; + private final Income income; /** * Every field must be present and not null. @@ -33,6 +34,7 @@ public Person(Name name, Phone phone, Email email, Address address, Set tag this.address = address; // protect internal tags from changes in the arg list this.tags = new UniqueTagList(tags); + this.income = new Income(29000); } public Name getName() { @@ -51,6 +53,10 @@ public Address getAddress() { return address; } + public Income getIncome() { + return this.income; + } + /** * Returns an immutable tag set, which throws {@code UnsupportedOperationException} * if modification is attempted. diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index f6727ea83abd..1eb8eff31d43 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -38,6 +38,8 @@ public class PersonCard extends UiPart { private Label email; @FXML private FlowPane tags; + @FXML + private Label income; public PersonCard(Person person, int displayedIndex) { super(FXML); @@ -47,6 +49,7 @@ public PersonCard(Person person, int displayedIndex) { phone.setText(person.getPhone().value); address.setText(person.getAddress().value); email.setText(person.getEmail().value); + income.setText(person.getIncome().toString()); person.getTags().forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); } diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml index f08ea32ad558..0ae9e89174e6 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -31,6 +31,7 @@ From 5f48e6cb73f0e38156844196b9b34ab04c7e8c59 Mon Sep 17 00:00:00 2001 From: charleschang Date: Mon, 5 Mar 2018 22:02:23 +0800 Subject: [PATCH 009/234] updating income field halfway --- .../address/logic/commands/AddCommand.java | 10 +++----- .../address/logic/commands/EditCommand.java | 4 ++- .../logic/parser/AddCommandParser.java | 10 +++++--- .../seedu/address/logic/parser/CliSyntax.java | 1 + .../address/logic/parser/ParserUtil.java | 25 +++++++++++++++++++ .../seedu/address/model/ModelManager.java | 2 +- .../seedu/address/model/person/Income.java | 6 ++--- .../seedu/address/model/person/Person.java | 4 +-- .../address/storage/XmlAdaptedPerson.java | 5 +++- 9 files changed, 50 insertions(+), 17 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index c334710c0ea3..300afa7069da 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -1,11 +1,7 @@ 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.logic.parser.CliSyntax.*; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.person.Person; @@ -24,6 +20,7 @@ public class AddCommand extends UndoableCommand { + PREFIX_PHONE + "PHONE " + PREFIX_EMAIL + "EMAIL " + PREFIX_ADDRESS + "ADDRESS " + + PREFIX_INCOME + "INCOME " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " " + PREFIX_NAME + "John Doe " @@ -31,7 +28,8 @@ public class AddCommand extends UndoableCommand { + PREFIX_EMAIL + "johnd@example.com " + PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " + PREFIX_TAG + "friends " - + PREFIX_TAG + "owesMoney"; + + PREFIX_TAG + "owesMoney" + + PREFIX_INCOME + "29000 "; public static final String MESSAGE_SUCCESS = "New person added: %1$s"; public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book"; diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index e6c3a3e034bc..5dbc8ace526f 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -21,6 +21,7 @@ import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Income; import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; @@ -107,8 +108,9 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); + Income updatedIncome = new Income(20000); - return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags); + return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags, updatedIncome); } @Override diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 3c729b388554..ecf07b035822 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -3,6 +3,7 @@ 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_INCOME; 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; @@ -15,6 +16,7 @@ import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Income; import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; @@ -28,13 +30,14 @@ 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); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_INCOME, PREFIX_TAG); - if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL) + if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_INCOME) || !argMultimap.getPreamble().isEmpty()) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } @@ -44,9 +47,10 @@ public AddCommand parse(String args) throws ParseException { 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(); + Income income = ParserUtil.parseIncome(argMultimap.getValue(PREFIX_INCOME)).get(); Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); - Person person = new Person(name, phone, email, address, tagList); + Person person = new Person(name, phone, email, address, tagList, income); return new AddCommand(person); } catch (IllegalValueException ive) { diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 75b1a9bf1190..8fb54871387b 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -11,5 +11,6 @@ public class CliSyntax { 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/"); + public static final Prefix PREFIX_INCOME = new Prefix("i/"); } diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index 5d6d4ae3f7b1..7dfbb000369f 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -12,6 +12,7 @@ import seedu.address.commons.util.StringUtil; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Income; import seedu.address.model.person.Name; import seedu.address.model.person.Phone; import seedu.address.model.tag.Tag; @@ -139,6 +140,30 @@ public static Optional parseEmail(Optional email) throws IllegalV return email.isPresent() ? Optional.of(parseEmail(email.get())) : Optional.empty(); } + /** + * Parses a {@code String income} into an {@code income}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws IllegalValueException if the given {@code income} is invalid. + */ + public static Income parseIncome(String income) throws IllegalValueException { + requireNonNull(income); + Float trimmedIncome = Float.parseFloat(income.trim()); + if (!Income.isValidIncome(trimmedIncome)) { + throw new IllegalValueException(Income.MESSAGE_INCOME_CONSTRAINTS); + } + return new Income(trimmedIncome); + } + + /** + * Parses a {@code Optional income} into an {@code Optional} if {@code income} is present. + * See header comment of this class regarding the use of {@code Optional} parameters. + */ + public static Optional parseIncome(Optional income) throws IllegalValueException { + requireNonNull(income); + return income.isPresent() ? Optional.of(parseIncome(income.get())) : Optional.empty(); + } + /** * Parses a {@code String tag} into a {@code Tag}. * Leading and trailing whitespaces will be trimmed. diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 22a7d0eb3f4d..369b0f878f4f 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -78,7 +78,7 @@ public void updatePerson(Person target, Person editedPerson) requireAllNonNull(target, editedPerson); addressBook.updatePerson(target, editedPerson); - indicateAddressBookChanged(); + this.indicateAddressBookChanged(); } //=========== Filtered Person List Accessors ============================================================= diff --git a/src/main/java/seedu/address/model/person/Income.java b/src/main/java/seedu/address/model/person/Income.java index cf8f1eca59b8..e45ecfe892fd 100644 --- a/src/main/java/seedu/address/model/person/Income.java +++ b/src/main/java/seedu/address/model/person/Income.java @@ -12,7 +12,7 @@ * Guarantees: immutable; is valid as declare in {@link #isValidIncome(float)}} */ public class Income { - public static final String MESSAGE_INCOME_CONSTRAITS = + public static final String MESSAGE_INCOME_CONSTRAINTS = "Person income must be positive numerical numbers, floating point value"; public final float income; @@ -22,12 +22,12 @@ public class Income { */ public Income(float income) { requireNonNull(income); - checkArgument(this.isValidIncome(income), this.MESSAGE_INCOME_CONSTRAITS); + checkArgument(this.isValidIncome(income), this.MESSAGE_INCOME_CONSTRAINTS); this.income = income; } - private static boolean isValidIncome(float income) { + public static boolean isValidIncome(float income) { return (income >= 0); } diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 6b48af702399..73e6f34c58c7 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -26,7 +26,7 @@ public class Person { /** * Every field must be present and not null. */ - public Person(Name name, Phone phone, Email email, Address address, Set tags) { + public Person(Name name, Phone phone, Email email, Address address, Set tags, Income income) { requireAllNonNull(name, phone, email, address, tags); this.name = name; this.phone = phone; @@ -34,7 +34,7 @@ public Person(Name name, Phone phone, Email email, Address address, Set tag this.address = address; // protect internal tags from changes in the arg list this.tags = new UniqueTagList(tags); - this.income = new Income(29000); + this.income = income; } public Name getName() { diff --git a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java index 2cd92dc4fd20..bbcf2dfb14c2 100644 --- a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java @@ -31,6 +31,8 @@ public class XmlAdaptedPerson { private String email; @XmlElement(required = true) private String address; + @XmlElement(required = true) + private String income; @XmlElement private List tagged = new ArrayList<>(); @@ -44,11 +46,12 @@ public XmlAdaptedPerson() {} /** * Constructs an {@code XmlAdaptedPerson} with the given person details. */ - public XmlAdaptedPerson(String name, String phone, String email, String address, List tagged) { + public XmlAdaptedPerson(String name, String phone, String email, String address, List tagged, String income) { this.name = name; this.phone = phone; this.email = email; this.address = address; + this.income = income; if (tagged != null) { this.tagged = new ArrayList<>(tagged); } From 30cd8ab1fe40be1be39792bd920d8c5ada97f156 Mon Sep 17 00:00:00 2001 From: Jonathan Wen Date: Wed, 7 Mar 2018 23:22:20 +0800 Subject: [PATCH 010/234] added age field --- .../java/seedu/address/model/person/Age.java | 34 +++++++++++++++++++ .../seedu/address/model/person/Person.java | 4 +++ 2 files changed, 38 insertions(+) create mode 100644 src/main/java/seedu/address/model/person/Age.java diff --git a/src/main/java/seedu/address/model/person/Age.java b/src/main/java/seedu/address/model/person/Age.java new file mode 100644 index 000000000000..dd391da58fdc --- /dev/null +++ b/src/main/java/seedu/address/model/person/Age.java @@ -0,0 +1,34 @@ +package seedu.address.model.person; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; + +public class Age { + public static final String AGE_CONSTRAINTS = + "Persons age must be above 0 years old and under 150."; + + public final Integer age; + + public Age(Integer age) { + requireNonNull(age); + checkArgument(isValidAge(age), AGE_CONSTRAINTS); + this.age = age; + } + + public static boolean isValidAge(Integer age) { + return age >= 0 && age < 150; + } + + @Override + public String toString() { + return age.toString(); + } + + @Override + public boolean equals(Object other) { + return other == this + || (other instanceof Age + && this.age == ((Age) other).age); + } + +} diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index ec9f2aa5e919..bbdd1b3981a9 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -16,6 +16,7 @@ public class Person { private final Name name; + private final Age age; private final Phone phone; private final Email email; private final Address address; @@ -28,6 +29,7 @@ public class Person { public Person(Name name, Phone phone, Email email, Address address, Set tags) { requireAllNonNull(name, phone, email, address, tags); this.name = name; + this.age = new Age(12); this.phone = phone; this.email = email; this.address = address; @@ -39,6 +41,8 @@ public Name getName() { return name; } + public Age getAge() { return age; } + public Phone getPhone() { return phone; } From 57442ab83c988f4834a02e188338d8ecc7eac66d Mon Sep 17 00:00:00 2001 From: charleschang Date: Thu, 8 Mar 2018 15:21:37 +0800 Subject: [PATCH 011/234] incomplete income filed update --- .../address/logic/commands/EditCommand.java | 2 +- .../address/logic/parser/ParserUtil.java | 8 ++-- .../java/seedu/address/model/AddressBook.java | 23 +++++------ .../seedu/address/model/person/Income.java | 22 +++++------ .../address/model/util/SampleDataUtil.java | 39 ++++++++++--------- .../address/storage/XmlAdaptedPerson.java | 16 ++++++-- src/main/resources/view/PersonListCard.fxml | 2 +- 7 files changed, 61 insertions(+), 51 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 5dbc8ace526f..78600476d106 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -108,7 +108,7 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); - Income updatedIncome = new Income(20000); + Income updatedIncome = new Income(20000.0); return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags, updatedIncome); } diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index 7dfbb000369f..19d58f0e46cc 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -141,14 +141,14 @@ public static Optional parseEmail(Optional email) throws IllegalV } /** - * Parses a {@code String income} into an {@code income}. + * Parses a {@code String value} into an {@code value}. * Leading and trailing whitespaces will be trimmed. * - * @throws IllegalValueException if the given {@code income} is invalid. + * @throws IllegalValueException if the given {@code value} is invalid. */ public static Income parseIncome(String income) throws IllegalValueException { requireNonNull(income); - Float trimmedIncome = Float.parseFloat(income.trim()); + Double trimmedIncome = Double.parseDouble(income.trim()); if (!Income.isValidIncome(trimmedIncome)) { throw new IllegalValueException(Income.MESSAGE_INCOME_CONSTRAINTS); } @@ -156,7 +156,7 @@ public static Income parseIncome(String income) throws IllegalValueException { } /** - * Parses a {@code Optional income} into an {@code Optional} if {@code income} is present. + * Parses a {@code Optional value} into an {@code Optional} if {@code value} is present. * See header comment of this class regarding the use of {@code Optional} parameters. */ public static Optional parseIncome(Optional income) throws IllegalValueException { diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index f8d0260de159..48e5681230f3 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -33,13 +33,13 @@ public class AddressBook implements ReadOnlyAddressBook { * * Note that non-static init blocks are not recommended to use. There are other ways to avoid duplication * among constructors. - */ - { + */ { persons = new UniquePersonList(); tags = new UniqueTagList(); } - public AddressBook() {} + public AddressBook() { + } /** * Creates an AddressBook using the Persons and Tags in the {@code toBeCopied} @@ -98,9 +98,8 @@ public void addPerson(Person p) throws DuplicatePersonException { * {@code AddressBook}'s tag list will be updated with the tags of {@code editedPerson}. * * @throws DuplicatePersonException if updating the person's details causes the person to be equivalent to - * another existing person in the list. - * @throws PersonNotFoundException if {@code target} could not be found in the list. - * + * another existing person in the list. + * @throws PersonNotFoundException if {@code target} could not be found in the list. * @see #syncWithMasterTagList(Person) */ public void updatePerson(Person target, Person editedPerson) @@ -115,9 +114,10 @@ public void updatePerson(Person target, Person editedPerson) } /** - * Updates the master tag list to include tags in {@code person} that are not in the list. - * @return a copy of this {@code person} such that every tag in this person points to a Tag object in the master - * list. + * Updates the master tag list to include tags in {@code person} that are not in the list. + * + * @return a copy of this {@code person} such that every tag in this person points to a Tag object in the master + * list. */ private Person syncWithMasterTagList(Person person) { final UniqueTagList personTags = new UniqueTagList(person.getTags()); @@ -132,11 +132,12 @@ private Person syncWithMasterTagList(Person person) { final Set correctTagReferences = new HashSet<>(); personTags.forEach(tag -> correctTagReferences.add(masterTagObjects.get(tag))); return new Person( - person.getName(), person.getPhone(), person.getEmail(), person.getAddress(), correctTagReferences); + person.getName(), person.getPhone(), person.getEmail(), person.getAddress(), correctTagReferences, person.getIncome()); } /** * Removes {@code key} from this {@code AddressBook}. + * * @throws PersonNotFoundException if the {@code key} is not in this {@code AddressBook}. */ public boolean removePerson(Person key) throws PersonNotFoundException { @@ -157,7 +158,7 @@ public void addTag(Tag t) throws UniqueTagList.DuplicateTagException { @Override public String toString() { - return persons.asObservableList().size() + " persons, " + tags.asObservableList().size() + " tags"; + return persons.asObservableList().size() + " persons, " + tags.asObservableList().size() + " tags"; // TODO: refine later } diff --git a/src/main/java/seedu/address/model/person/Income.java b/src/main/java/seedu/address/model/person/Income.java index e45ecfe892fd..e1d7cd85113f 100644 --- a/src/main/java/seedu/address/model/person/Income.java +++ b/src/main/java/seedu/address/model/person/Income.java @@ -8,33 +8,33 @@ /** - * Represents a Person's income in the address book + * Represents a Person's value in the address book * Guarantees: immutable; is valid as declare in {@link #isValidIncome(float)}} */ public class Income { public static final String MESSAGE_INCOME_CONSTRAINTS = - "Person income must be positive numerical numbers, floating point value"; + "Person value must be positive numerical numbers, floating point value"; - public final float income; + public final Double value; /** - * @param income a valid income + * @param value a valid value */ - public Income(float income) { - requireNonNull(income); - checkArgument(this.isValidIncome(income), this.MESSAGE_INCOME_CONSTRAINTS); - this.income = income; + public Income(Double value) { + requireNonNull(value); + checkArgument(this.isValidIncome(value), this.MESSAGE_INCOME_CONSTRAINTS); + this.value = value; } - public static boolean isValidIncome(float income) { + public static boolean isValidIncome(Double income) { return (income >= 0); } @Override public String toString() { NumberFormat format = NumberFormat.getCurrencyInstance(Locale.US); - return format.format(this.income); + return format.format(this.value); } @@ -42,7 +42,7 @@ public String toString() { public boolean equals(Object other) { return other == this || (other instanceof Income - && this.income == ((Income) other).income); + && this.value == ((Income) other).value); } } diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index aea96bfb31f3..9f0e0fd273f3 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -7,6 +7,7 @@ import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Income; import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; @@ -18,25 +19,25 @@ */ 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")) + 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 Income(2000.00)), + 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 Income(2200.00)), + 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 Income(34550.00)), + 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 Income(202323.00)), + 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 Income(5000.00)), + 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"), new Income(7000.00)) }; } diff --git a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java index bbcf2dfb14c2..54c8c335692f 100644 --- a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java @@ -11,6 +11,7 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Income; import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; @@ -32,7 +33,7 @@ public class XmlAdaptedPerson { @XmlElement(required = true) private String address; @XmlElement(required = true) - private String income; + private Double income; @XmlElement private List tagged = new ArrayList<>(); @@ -41,12 +42,13 @@ public class XmlAdaptedPerson { * Constructs an XmlAdaptedPerson. * This is the no-arg constructor that is required by JAXB. */ - public XmlAdaptedPerson() {} + public XmlAdaptedPerson() { + } /** * Constructs an {@code XmlAdaptedPerson} with the given person details. */ - public XmlAdaptedPerson(String name, String phone, String email, String address, List tagged, String income) { + public XmlAdaptedPerson(String name, String phone, String email, String address, List tagged, Double income) { this.name = name; this.phone = phone; this.email = email; @@ -67,6 +69,7 @@ public XmlAdaptedPerson(Person source) { phone = source.getPhone().value; email = source.getEmail().value; address = source.getAddress().value; + income = source.getIncome().value; tagged = new ArrayList<>(); for (Tag tag : source.getTags()) { tagged.add(new XmlAdaptedTag(tag)); @@ -116,8 +119,13 @@ public Person toModelType() throws IllegalValueException { } final Address address = new Address(this.address); + if (!Income.isValidIncome(this.income)) { + throw new IllegalValueException(Income.MESSAGE_INCOME_CONSTRAINTS); + } + final Income income = new Income(this.income); + final Set tags = new HashSet<>(personTags); - return new Person(name, phone, email, address, tags); + return new Person(name, phone, email, address, tags, income); } @Override diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml index 0ae9e89174e6..463c82bfe49c 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -31,7 +31,7 @@