From c57d910d7c70a3d1bec9732514fe3cd07970b720 Mon Sep 17 00:00:00 2001 From: "Notmoo-PC\\Notmoo" Date: Wed, 8 Nov 2017 14:59:55 +0100 Subject: [PATCH] =?UTF-8?q?Module=20Client,=20=C3=A9cran=20StatScreen=20:?= =?UTF-8?q?=20les=20statistiques=20sont=20d=C3=A9sormais=20actualis=C3=A9e?= =?UTF-8?q?s=20=C3=A0=20chaque=20vente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/sale_screen/SaleScreenModel.java | 4 ++-- .../modules/stat_screen/StatScreenView.java | 5 ++++- .../module/ClientBackEndModuleManager.java | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenModel.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenModel.java index f0f30588..85152b8d 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenModel.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenModel.java @@ -16,6 +16,7 @@ import com.pqt.core.entities.user_account.Account; import com.pqt.core.entities.user_account.AccountLevel; import javax.swing.event.EventListenerList; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -47,7 +48,6 @@ class SaleScreenModel { if(saleId == SaleScreenModel.this.tempSaleId){ SaleScreenModel.this.fireSaleValidatedEvent(); } - stockService.refreshProductList(); } @Override @@ -151,7 +151,7 @@ class SaleScreenModel { } List getSaleTypeList() { - return saleService.getSaleTypes(); + return new ArrayList<>(saleService.getSaleTypes()); } Sale getCurrentSale() { diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenView.java index a9a79644..f42fa43d 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenView.java @@ -42,7 +42,10 @@ class StatScreenView implements IFXComponent { .map(key->String.format(" * %s : %s", key, statistics.get(key))) .collect(Collectors.toList())); - Platform.runLater(()->lines.forEach(line -> statTextArea.appendText(line+"\n"))); + Platform.runLater(()-> { + statTextArea.setText(""); + lines.forEach(line -> statTextArea.appendText(line + "\n")); + }); } @Override diff --git a/Workspace/client/src/main/java/com/pqt/client/module/ClientBackEndModuleManager.java b/Workspace/client/src/main/java/com/pqt/client/module/ClientBackEndModuleManager.java index d48e8f6a..929402d0 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/ClientBackEndModuleManager.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/ClientBackEndModuleManager.java @@ -6,6 +6,7 @@ import com.pqt.client.module.network.NetworkService; import com.pqt.client.module.network.listeners.INetworkServiceListener; import com.pqt.client.module.query.QueryExecutor; import com.pqt.client.module.sale.SaleService; +import com.pqt.client.module.sale.listeners.ISaleListener; import com.pqt.client.module.stat.StatService; import com.pqt.client.module.stock.StockService; @@ -48,6 +49,24 @@ public class ClientBackEndModuleManager { statService.refreshStats(); } }); + + saleService.addListener(new ISaleListener() { + @Override + public void onSaleValidationSuccess(long saleId) { + stockService.refreshProductList(); + statService.refreshStats(); + } + + @Override + public void onSaleValidationError(long saleId, Throwable cause) { + //No-op + } + + @Override + public void onSaleValidationRefused(long saleId, Throwable cause) { + //No-op + } + }); } public SaleService getSaleService() {