From 165a63b188ddaa16e0e10c0d1a02c85f132c578d Mon Sep 17 00:00:00 2001 From: Dominic Chong Date: Wed, 24 Oct 2018 10:21:44 +0800 Subject: [PATCH 1/4] Add getters in Logic to access WishTransactions --- src/main/java/seedu/address/logic/Logic.java | 6 ++++++ src/main/java/seedu/address/logic/LogicManager.java | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java index d10413236484..2657ab5e8073 100644 --- a/src/main/java/seedu/address/logic/Logic.java +++ b/src/main/java/seedu/address/logic/Logic.java @@ -4,6 +4,7 @@ import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.WishTransaction; import seedu.address.model.wish.Wish; /** @@ -24,4 +25,9 @@ public interface Logic { /** Returns the list of input entered by the user, encapsulated in a {@code ListElementPointer} object */ ListElementPointer getHistorySnapshot(); + + /** Returns the WishTransaction object in the model. */ + WishTransaction getWishTransaction(); + + } diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index d4344a145951..d7122f8f84f4 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -12,6 +12,7 @@ import seedu.address.logic.parser.WishBookParser; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.Model; +import seedu.address.model.WishTransaction; import seedu.address.model.wish.Wish; /** @@ -50,4 +51,7 @@ public ObservableList getFilteredWishList() { public ListElementPointer getHistorySnapshot() { return new ListElementPointer(history.getHistory()); } + + @Override + public WishTransaction getWishTransaction() { return model.getWishTransaction(); } } From 1d8bc8b821c5be6c4ecfb53fc4ee23cc967de692 Mon Sep 17 00:00:00 2001 From: Dominic Chong Date: Wed, 24 Oct 2018 10:29:38 +0800 Subject: [PATCH 2/4] Add new constructor to WishListPanel (for transactions) --- src/main/java/seedu/address/ui/MainWindow.java | 5 +++++ src/main/java/seedu/address/ui/WishListPanel.java | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index c87a97849729..0b0072b3339d 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -19,6 +19,7 @@ import seedu.address.commons.events.ui.ShowHelpRequestEvent; import seedu.address.logic.Logic; import seedu.address.model.UserPrefs; +import seedu.address.model.WishTransaction; /** * The Main Window. Provides the basic application layout containing @@ -119,10 +120,14 @@ private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) { * Fills up all the placeholders of this window. */ void fillInnerParts() { + WishTransaction transaction = logic.getWishTransaction(); // Access to WishTransaction + wishDetailPanel = new WishDetailPanel(); wishDetailPlaceholder.getChildren().add(wishDetailPanel.getRoot()); wishListPanel = new WishListPanel(logic.getFilteredWishList()); + // New constructor below to be used to access WishTransaction in model + // wishListPanel = new WishListPanel(logic.getFilteredWishList(), logic.getWishTransaction()); wishListPanelPlaceholder.getChildren().add(wishListPanel.getRoot()); ResultDisplay resultDisplay = new ResultDisplay(); diff --git a/src/main/java/seedu/address/ui/WishListPanel.java b/src/main/java/seedu/address/ui/WishListPanel.java index 5dfbf9b69721..0e3f2c3835c7 100644 --- a/src/main/java/seedu/address/ui/WishListPanel.java +++ b/src/main/java/seedu/address/ui/WishListPanel.java @@ -13,6 +13,7 @@ import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.ui.JumpToListRequestEvent; import seedu.address.commons.events.ui.WishPanelSelectionChangedEvent; +import seedu.address.model.WishTransaction; import seedu.address.model.wish.Wish; /** @@ -29,6 +30,16 @@ public WishListPanel(ObservableList wishList) { super(FXML); setConnections(wishList); registerAsAnEventHandler(this); + // TODO: [Jiho] Remove this constructor once the one immediately below this is used. + } + + + public WishListPanel(ObservableList wishList, WishTransaction wishTransaction) { + super(FXML); + setConnections(wishList); + registerAsAnEventHandler(this); + + // TODO: [Jiho] Utilize wishTransaction's data in the WishListPanel } private void setConnections(ObservableList wishList) { From e11fde5f6fc1f6aebb3811e218801c05be939e80 Mon Sep 17 00:00:00 2001 From: Dominic Chong Date: Wed, 24 Oct 2018 10:33:34 +0800 Subject: [PATCH 3/4] Fix style --- src/main/java/seedu/address/logic/LogicManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index d7122f8f84f4..796a1c016620 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -53,5 +53,7 @@ public ListElementPointer getHistorySnapshot() { } @Override - public WishTransaction getWishTransaction() { return model.getWishTransaction(); } + public WishTransaction getWishTransaction() { + return model.getWishTransaction(); + } } From 26dd5a6c8a69cff8cad3b6afc4b3a4304659329b Mon Sep 17 00:00:00 2001 From: Dominic Chong Date: Wed, 24 Oct 2018 10:42:17 +0800 Subject: [PATCH 4/4] Add new constructor for WishDetailPanel --- .../java/seedu/address/ui/WishDetailPanel.java | 14 ++++++++++++++ src/main/java/seedu/address/ui/WishListPanel.java | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/ui/WishDetailPanel.java b/src/main/java/seedu/address/ui/WishDetailPanel.java index 0a7e92205ed7..084f65a28889 100644 --- a/src/main/java/seedu/address/ui/WishDetailPanel.java +++ b/src/main/java/seedu/address/ui/WishDetailPanel.java @@ -11,6 +11,7 @@ import javafx.scene.layout.Region; import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.ui.WishPanelSelectionChangedEvent; +import seedu.address.model.WishTransaction; import seedu.address.model.wish.Wish; /** @@ -51,6 +52,19 @@ public WishDetailPanel() { loadDefaultPage(); registerAsAnEventHandler(this); + + // TODO: [Jiho] Remove this constructor once the one immediately below this is used. + } + + public WishDetailPanel(WishTransaction wishTransaction) { + super(FXML); + + // To prevent triggering events for typing inside the loaded Web page. + getRoot().setOnKeyPressed(Event::consume); + + loadDefaultPage(); + registerAsAnEventHandler(this); + // TODO: [Jiho] Utilize wishTransaction's data in the WishDetailPanel (if wanted). } /** diff --git a/src/main/java/seedu/address/ui/WishListPanel.java b/src/main/java/seedu/address/ui/WishListPanel.java index 0e3f2c3835c7..edfc26126a4c 100644 --- a/src/main/java/seedu/address/ui/WishListPanel.java +++ b/src/main/java/seedu/address/ui/WishListPanel.java @@ -39,7 +39,7 @@ public WishListPanel(ObservableList wishList, WishTransaction wishTransact setConnections(wishList); registerAsAnEventHandler(this); - // TODO: [Jiho] Utilize wishTransaction's data in the WishListPanel + // TODO: [Jiho] Utilize wishTransaction's data in the WishListPanel (if wanted). } private void setConnections(ObservableList wishList) {