Module Client, écran Stock : correction d'un bug empêchant la mise à jour du stock de produit

This commit is contained in:
Notmoo-PC\Notmoo 2017-11-04 20:49:52 +01:00
parent 4cc9d53742
commit 0c64c49f0f
4 changed files with 21 additions and 3 deletions

View File

@ -15,6 +15,7 @@ public class StatScreen implements IGuiModule {
StatScreenController ctrl = new StatScreenController(model);
view = new StatScreenView();
model.addListener(ctrl);
ctrl.setView(view);
}

View File

@ -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);
}
});

View File

@ -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<Product> 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();
}

View File

@ -43,7 +43,7 @@ public class StockDao {
executor.executeStockQuery(new ICollectionItemMessageCallback<Product>() {
@Override
public void ack(Collection<Product> 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<Product> products){
private synchronized void replaceProductList(Collection<Product> 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();