From 0c64c49f0f68095febb54d4cd80a2ce8126b6779 Mon Sep 17 00:00:00 2001 From: "Notmoo-PC\\Notmoo" Date: Sat, 4 Nov 2017 20:49:52 +0100 Subject: [PATCH] =?UTF-8?q?Module=20Client,=20=C3=A9cran=20Stock=20:=20cor?= =?UTF-8?q?rection=20d'un=20bug=20emp=C3=AAchant=20la=20mise=20=C3=A0=20jo?= =?UTF-8?q?ur=20du=20stock=20de=20produit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/gui/modules/stat_screen/StatScreen.java | 1 + .../gui/modules/stat_screen/StatScreenModel.java | 2 +- .../gui/modules/stock_screen/StockScreenModel.java | 9 +++++++++ .../java/com/pqt/client/module/stock/StockDao.java | 12 ++++++++++-- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreen.java index 6ef1f98b..0c49f769 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreen.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreen.java @@ -15,6 +15,7 @@ public class StatScreen implements IGuiModule { StatScreenController ctrl = new StatScreenController(model); view = new StatScreenView(); + model.addListener(ctrl); ctrl.setView(view); } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenModel.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenModel.java index 2add8f38..4395140e 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenModel.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenModel.java @@ -18,7 +18,7 @@ class StatScreenModel { listenerList = new EventListenerList(); this.statService.addListener(new StatListenerAdapter() { @Override - public void onGetStatSuccess() { + public void onStatChangedEvent() { Arrays.stream(listenerList.getListeners(IStatScreenModelListener.class)).forEach(IStatScreenModelListener::onStatisticsChangedEvent); } }); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenModel.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenModel.java index 225fcb4f..42264767 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenModel.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenModel.java @@ -24,6 +24,7 @@ class StockScreenModel { this.stockService.addListener(new StockListenerAdapter(){ @Override public void onProductListChangedEvent() { + System.out.println("Product list changed event"); StockScreenModel.this.fireProductCollectionChanged(); } }); @@ -57,6 +58,14 @@ class StockScreenModel { } Collection getProductCollection() { + {//TODO delete print block + System.out.println("------------------------------------------"); + System.out.println("Stock service's list : "); + for(Product p : stockService.getProducts()){ + System.out.println(p); + } + System.out.println("------------------------------------------"); + } return stockService.getProducts(); } diff --git a/Workspace/client/src/main/java/com/pqt/client/module/stock/StockDao.java b/Workspace/client/src/main/java/com/pqt/client/module/stock/StockDao.java index 8ea55f44..a4db5396 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/stock/StockDao.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/stock/StockDao.java @@ -43,7 +43,7 @@ public class StockDao { executor.executeStockQuery(new ICollectionItemMessageCallback() { @Override public void ack(Collection obj) { - replaceProductList(products); + replaceProductList(obj); eventFirerer.fireGetProductListSuccessEvent(); //TODO add log line } @@ -66,7 +66,15 @@ public class StockDao { return lastRefreshTimestamp; } - private synchronized void replaceProductList(List products){ + private synchronized void replaceProductList(Collection products){ + {//TODO delete print block + System.out.println("------------------------------------------"); + System.out.println("Stock dao's list : "); + for(Product p : products){ + System.out.println(p); + } + System.out.println("------------------------------------------"); + } this.products.clear(); this.products.addAll(products); this.lastRefreshTimestamp = new Date();