From 4d4135bd71c0b4fdd585f0682650a9682a5a6511 Mon Sep 17 00:00:00 2001 From: Charles Goh Date: Mon, 6 Nov 2017 22:07:21 +0800 Subject: [PATCH 01/16] [PRIVACY] Added bug fixing method to support avatar in ChangePrivacyCommand --- .../logic/commands/ChangePrivacyCommand.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/java/seedu/address/logic/commands/ChangePrivacyCommand.java b/src/main/java/seedu/address/logic/commands/ChangePrivacyCommand.java index 89ed5f5257b6..b597fe8c334b 100644 --- a/src/main/java/seedu/address/logic/commands/ChangePrivacyCommand.java +++ b/src/main/java/seedu/address/logic/commands/ChangePrivacyCommand.java @@ -264,6 +264,32 @@ private static Remark createRemarkWithPrivacy(ReadOnlyPerson person, PersonPriva return r; } + //@@author charlesgoh + /** + * Creates a new (@code Avatar) based on the input (@code Person) and (@code PersonPrivacySettings) + * @return A (@code Avatar) with the same value as that of the (@code Person)'s but with the privacy set to that + * of the (@code PersonPrivacySettings) + */ + private static Avatar createAvatarWithPrivacy(ReadOnlyPerson person, PersonPrivacySettings pps) { + Avatar v; + try { + if (person.getAvatar().isPrivate()) { + person.getAvatar().setPrivate(false); + v = new Avatar(person.getAvatar().toString()); + person.getAvatar().setPrivate(true); + } else { + v = new Avatar(person.getAvatar().toString()); + } + } catch (IllegalValueException e) { + throw new AssertionError("Invalid Avatar"); + } + if (pps.getAvatarIsPrivate() != null) { + v.setPrivate(pps.getAvatarIsPrivate()); + } + return v; + } + //@@author + public Index getIndex() { return index; } From 67fc2dbd0f8bb615b21dcab39dc04d43598815a5 Mon Sep 17 00:00:00 2001 From: Charles Goh Date: Mon, 6 Nov 2017 22:18:51 +0800 Subject: [PATCH 02/16] [STORAGE] Deleted unused method from storage manager --- .../java/seedu/address/storage/StorageManager.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main/java/seedu/address/storage/StorageManager.java b/src/main/java/seedu/address/storage/StorageManager.java index 46b9aa2aa95b..d2c197c39058 100644 --- a/src/main/java/seedu/address/storage/StorageManager.java +++ b/src/main/java/seedu/address/storage/StorageManager.java @@ -90,16 +90,6 @@ public void backupAddressBook(ReadOnlyAddressBook addressBook, String filePath) logger.fine("Attempting to write to backup data file in custom location"); this.saveAddressBook(addressBook, filePath); } - - /** - * Default back up data which saves file in the same directory as the main save file - * @param addressBook - * @throws IOException - */ - public void backupAddressBookDefault(ReadOnlyAddressBook addressBook) throws IOException { - logger.fine("Attempting to write to backup data file"); - this.saveAddressBook(addressBook, addressBookStorage.getAddressBookFilePath() + "-backup.xml"); - } //@@author @Override From 97b13563703c35e6d51693890afb830419a63535 Mon Sep 17 00:00:00 2001 From: Charles Goh Date: Mon, 6 Nov 2017 22:20:17 +0800 Subject: [PATCH 03/16] [CHECKSTYLE] Cleaned up unused code --- .../java/seedu/address/logic/commands/ChangePrivacyCommand.java | 2 +- src/main/java/seedu/address/logic/parser/ParserUtil.java | 2 +- src/main/java/seedu/address/ui/PersonCard.java | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/ChangePrivacyCommand.java b/src/main/java/seedu/address/logic/commands/ChangePrivacyCommand.java index b597fe8c334b..3100b97bb809 100644 --- a/src/main/java/seedu/address/logic/commands/ChangePrivacyCommand.java +++ b/src/main/java/seedu/address/logic/commands/ChangePrivacyCommand.java @@ -419,7 +419,7 @@ public Boolean getAvatarIsPrivate() { return avatarIsPrivate; } - public void setAvatarIsPrivate(boolean AvatarIsPrivate) { + public void setAvatarIsPrivate(boolean avatarIsPrivate) { requireNonNull(avatarIsPrivate); this.avatarIsPrivate = avatarIsPrivate; } diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index f7c567ff040c..069586c67731 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -134,7 +134,7 @@ public static Optional parseAvatar(Optional avatar, boolean isPr requireNonNull(avatar); return avatar.isPresent() ? Optional.of(new Avatar(avatar.get(), isPrivate)) : Optional.empty(); } - + /** * Parses a {@code Optional remark} into an {@code Optional} if {@code remark} is present. * See header comment of this class regarding the use of {@code Optional} parameters. diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 164800818cda..6ec82fe41988 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -5,9 +5,7 @@ import javafx.beans.binding.Bindings; import javafx.fxml.FXML; -import javafx.scene.control.Button; import javafx.scene.control.Label; -import javafx.scene.image.ImageView; import javafx.scene.layout.FlowPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; From 819e33846e3083cc514801d6a4ba7603b2b04675 Mon Sep 17 00:00:00 2001 From: Charles Goh Date: Mon, 6 Nov 2017 22:55:13 +0800 Subject: [PATCH 04/16] [PERSONCARD] Added getter for avatar --- src/main/java/seedu/address/ui/PersonCard.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 6ec82fe41988..524d8dcf9f5b 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -3,6 +3,8 @@ import java.util.HashMap; import java.util.Random; +import javax.swing.text.html.ImageView; + import javafx.beans.binding.Bindings; import javafx.fxml.FXML; import javafx.scene.control.Label; @@ -56,6 +58,8 @@ private enum Colours { @FXML private Label remark; @FXML + private ImageView avatar; + @FXML private Label email; @FXML private FlowPane tags; @@ -176,6 +180,8 @@ public Label getEmail() { return email; } + public ImageView getAvatar() { return avatar; } + public int getFontSizeMultipler() { return fontSizeMultipler; } From 0145dc9d593504f01b080ba46728bef7cb81208e Mon Sep 17 00:00:00 2001 From: Charles Goh Date: Mon, 6 Nov 2017 22:59:54 +0800 Subject: [PATCH 05/16] [READONLYPERSON] Added avatar string in ReadOnlyPerson get as text --- src/main/java/seedu/address/model/person/ReadOnlyPerson.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/seedu/address/model/person/ReadOnlyPerson.java b/src/main/java/seedu/address/model/person/ReadOnlyPerson.java index 3683eb261419..56c2929b9ada 100644 --- a/src/main/java/seedu/address/model/person/ReadOnlyPerson.java +++ b/src/main/java/seedu/address/model/person/ReadOnlyPerson.java @@ -58,6 +58,8 @@ default String getAsText() { .append(getAddress()) .append(" Remark: ") .append(getRemark()) + .append(" Avatar: ") + .append(getAvatar()) .append(" Tags: "); getTags().forEach(builder::append); return builder.toString(); From 0963c2709ac4914ecad1dc58e9386aa27c5e2710 Mon Sep 17 00:00:00 2001 From: Charles Goh Date: Tue, 7 Nov 2017 17:36:26 +0800 Subject: [PATCH 06/16] [EVENT] Added new event for avatar change --- .../commons/events/ui/ChangedAvatarEvent.java | 30 +++++++++++++++++++ .../java/seedu/address/ui/PersonCard.java | 4 ++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/main/java/seedu/address/commons/events/ui/ChangedAvatarEvent.java diff --git a/src/main/java/seedu/address/commons/events/ui/ChangedAvatarEvent.java b/src/main/java/seedu/address/commons/events/ui/ChangedAvatarEvent.java new file mode 100644 index 000000000000..132ae0a48089 --- /dev/null +++ b/src/main/java/seedu/address/commons/events/ui/ChangedAvatarEvent.java @@ -0,0 +1,30 @@ +package seedu.address.commons.events.ui; + +import seedu.address.commons.events.BaseEvent; +import seedu.address.model.person.ReadOnlyPerson; + +/** + * Represents an avatar change event + */ +//author charlesgoh +public class ChangedAvatarEvent extends BaseEvent { + + private ReadOnlyPerson targetPerson; + + public ChangedAvatarEvent(ReadOnlyPerson person) { + this.targetPerson = person; + } + + public ReadOnlyPerson getTargetPerson() { + return targetPerson; + } + + public void setTargetPerson(ReadOnlyPerson targetPerson) { + this.targetPerson = targetPerson; + } + + @Override + public String toString() { + return "New Event: Avatar changed"; + } +} \ No newline at end of file diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 524d8dcf9f5b..9abea14c4706 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -180,7 +180,9 @@ public Label getEmail() { return email; } - public ImageView getAvatar() { return avatar; } + public ImageView getAvatar() { + return avatar; + } public int getFontSizeMultipler() { return fontSizeMultipler; From 2e497ebafe2b09eef3c26f0cac266ca147e9da74 Mon Sep 17 00:00:00 2001 From: Charles Goh Date: Tue, 7 Nov 2017 17:37:38 +0800 Subject: [PATCH 07/16] [AVATAR][EVENTS] Added newline --- .../seedu/address/commons/events/ui/ChangedAvatarEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/commons/events/ui/ChangedAvatarEvent.java b/src/main/java/seedu/address/commons/events/ui/ChangedAvatarEvent.java index 132ae0a48089..700090a37ff3 100644 --- a/src/main/java/seedu/address/commons/events/ui/ChangedAvatarEvent.java +++ b/src/main/java/seedu/address/commons/events/ui/ChangedAvatarEvent.java @@ -27,4 +27,4 @@ public void setTargetPerson(ReadOnlyPerson targetPerson) { public String toString() { return "New Event: Avatar changed"; } -} \ No newline at end of file +} From 71a130b04140ce9d19355ca1cf382434af01b1ab Mon Sep 17 00:00:00 2001 From: Charles Goh Date: Tue, 7 Nov 2017 21:12:04 +0800 Subject: [PATCH 08/16] [COLLATE] Added collate comments --- src/main/java/seedu/address/ui/PersonCard.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 9abea14c4706..0ef1f7b123a5 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -17,12 +17,10 @@ * An UI component that displays information of a {@code Person}. */ public class PersonCard extends UiPart { - //@@author charlesgoh public static final int DEFAULT_NAME_SIZE = 15; public static final int DEFAULT_ATTRIBUTE_SIZE = 10; public static final int FONT_SIZE_EXTENDER = 5; public static final int DEFAULT_FONT_SIZE_MULTIPLIER = 0; - //@@author private static final String FXML = "PersonListCard.fxml"; /** * Preset values for random selection later. @@ -137,7 +135,6 @@ public void updateAttributeSizes() { } //@@author - @Override public boolean equals(Object other) { // short circuit if same object @@ -156,6 +153,7 @@ public boolean equals(Object other) { && person.equals(card.person); } + //@@author charlesgoh public Label getName() { return name; } @@ -191,4 +189,5 @@ public int getFontSizeMultipler() { public void setFontSizeMultipler(int fontSizeMultipler) { this.fontSizeMultipler = fontSizeMultipler; } + //author } From c3d92d50da9b66a27119227c5b84add12cde5f01 Mon Sep 17 00:00:00 2001 From: Charles Goh Date: Tue, 7 Nov 2017 21:39:12 +0800 Subject: [PATCH 09/16] [PERSONCARD] Remove avatar variable --- src/main/java/seedu/address/ui/PersonCard.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 0ef1f7b123a5..018d9e8f7489 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -3,8 +3,6 @@ import java.util.HashMap; import java.util.Random; -import javax.swing.text.html.ImageView; - import javafx.beans.binding.Bindings; import javafx.fxml.FXML; import javafx.scene.control.Label; @@ -56,8 +54,6 @@ private enum Colours { @FXML private Label remark; @FXML - private ImageView avatar; - @FXML private Label email; @FXML private FlowPane tags; @@ -178,10 +174,6 @@ public Label getEmail() { return email; } - public ImageView getAvatar() { - return avatar; - } - public int getFontSizeMultipler() { return fontSizeMultipler; } From 0c43fa5180579ccf7cdc0d6855bcecaa52ca499b Mon Sep 17 00:00:00 2001 From: Charles Goh Date: Tue, 7 Nov 2017 21:52:22 +0800 Subject: [PATCH 10/16] [AVATAR] Took down avatar from person list cards in panel --- .../java/seedu/address/ui/MainWindow.java | 57 +-------- src/main/resources/view/MainWindow.fxml | 114 ++++++++---------- src/main/resources/view/PersonListCard.fxml | 14 --- 3 files changed, 51 insertions(+), 134 deletions(-) diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index ae1fe1123778..9e374c33897d 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -98,15 +98,6 @@ public class MainWindow extends UiPart { @FXML private MenuItem resetSizeMenuItem; - @FXML - private Button increaseFontSizeButton; - - @FXML - private Button decreaseFontSizeButton; - - @FXML - private Button resetFontSizeButton; - @FXML private StackPane personListPanelPlaceholder; @@ -286,21 +277,6 @@ GuiSettings getCurrentGuiSetting() { */ @FXML public void handleIncreaseFontSize() { - increaseFontSize(); - } - - /** - * Handle increase font size command for button - */ - @FXML - public void handleIncreaseFontSizeButton() { - increaseFontSize(); - } - - /** - * Calls method to increase font size - */ - public void increaseFontSize() { logger.info("Handling increase in font size"); raise(new ChangeFontSizeEvent(ChangeFontSizeEvent.getIncreaseSizeEventIndex())); } @@ -310,23 +286,7 @@ public void increaseFontSize() { */ @FXML public void handleDecreaseFontSize() { - decreaseFontSize(); - } - - /** - * Handle decrease font size command for button - */ - @FXML - public void handleDecreaseFontSizeButton() { - decreaseFontSize(); - } - - /** - * Calls method to decrease font size - */ - public void decreaseFontSize() { - logger.info("Handling increase in font size"); - personListPanel.decreaseFontSize(); + logger.info("Handling decrease in font size"); raise(new ChangeFontSizeEvent(ChangeFontSizeEvent.getDecreaseSizeEventIndex())); } @@ -335,21 +295,6 @@ public void decreaseFontSize() { */ @FXML public void handleResetFontSize() { - resetFontSize(); - } - - /** - * Handle reset font size command for button - */ - @FXML - public void handleResetFontSizeButton() { - resetFontSize(); - } - - /** - * Calls method to reset font size - */ - public void resetFontSize() { logger.info("Handling reset in font size"); raise(new ChangeFontSizeEvent(ChangeFontSizeEvent.getResetSizeEventIndex())); } diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 008af2cc24b0..9741b133963b 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -2,14 +2,12 @@ - - @@ -18,68 +16,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -