From 5183b47330113d6f287f66db6dfadd7d0fff227f Mon Sep 17 00:00:00 2001 From: Notmoo Date: Thu, 10 Aug 2017 11:16:34 +0200 Subject: [PATCH 01/36] =?UTF-8?q?Module=20client,=20packg=20gui=20:=20ajou?= =?UTF-8?q?t=20interface=20g=C3=A9n=C3=A9rales=20des=20componsants=20GUI?= =?UTF-8?q?=20(part=201/=3F=3F=3F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ressources/components/IFXComponent.java | 7 +++ .../products/IFXStockDisplayerComponent.java | 13 +++++ .../listeners/IStockComponentFirerer.java | 16 ++++++ .../listeners/IStockComponentListener.java | 14 +++++ .../SimpleStockComponentFirerer.java | 51 +++++++++++++++++++ .../sale/IFXSaleCreatorComponent.java | 8 +++ .../sale/IFXSaleDisplayerComponent.java | 11 ++++ .../sale/listeners/ISaleComponentFirerer.java | 5 ++ .../listeners/ISaleComponentListener.java | 7 +++ .../listeners/SimpleSaleComponentFirerer.java | 5 ++ .../validation/IFXValidatorComponent.java | 10 ++++ .../listeners/IValidatorComponentFirerer.java | 9 ++++ .../IValidatorComponentListener.java | 8 +++ .../SimpleValidatorComponentFirerer.java | 33 ++++++++++++ 14 files changed, 197 insertions(+) create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/IFXComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/IFXStockDisplayerComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentFirerer.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentListener.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/SimpleStockComponentFirerer.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleCreatorComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleDisplayerComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentFirerer.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentListener.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/SimpleSaleComponentFirerer.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/IFXValidatorComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/IValidatorComponentFirerer.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/IValidatorComponentListener.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/SimpleValidatorComponentFirerer.java diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/IFXComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/IFXComponent.java new file mode 100644 index 00000000..57448371 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/IFXComponent.java @@ -0,0 +1,7 @@ +package com.pqt.client.module.gui.ressources.components; + +import javafx.scene.layout.Pane; + +public interface IFXComponent { + Pane getPane(); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/IFXStockDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/IFXStockDisplayerComponent.java new file mode 100644 index 00000000..0f9d53a3 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/IFXStockDisplayerComponent.java @@ -0,0 +1,13 @@ +package com.pqt.client.module.gui.ressources.components.products; + +import com.pqt.client.module.gui.ressources.components.IFXComponent; +import com.pqt.client.module.gui.ressources.components.products.listeners.IStockComponentListener; +import com.pqt.core.entities.product.Product; + +import java.util.Collection; + +public interface IFXStockDisplayerComponent extends IFXComponent { + void display(Collection products); + void addListener(IStockComponentListener l); + void removeListener(IStockComponentListener l); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentFirerer.java new file mode 100644 index 00000000..073bfa10 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentFirerer.java @@ -0,0 +1,16 @@ +package com.pqt.client.module.gui.ressources.components.products.listeners; + +import com.pqt.core.entities.product.Product; +import javafx.event.Event; + +public interface IStockComponentFirerer { + + void addListener(IStockComponentListener l); + void removeListener(IStockComponentListener l); + + void fireProductClickEvent(Event event, Product product); + void fireAddProductRequestEvent(); + void fireRemoveProductRequestEvent(Product product); + void fireDetailProductRequestEvent(Product product); + void fireRefreshProductListRequestEvent(); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentListener.java new file mode 100644 index 00000000..52a6425b --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentListener.java @@ -0,0 +1,14 @@ +package com.pqt.client.module.gui.ressources.components.products.listeners; + +import com.pqt.core.entities.product.Product; +import javafx.event.Event; + +import java.util.EventListener; + +public interface IStockComponentListener extends EventListener { + void onProductClickEvent(Event event, Product product); + void onAddProductRequestEvent(); + void onRemoveProductRequestEvent(Product product); + void onDetailProductRequestEvent(Product product); + void onRefreshProductListRequestEvent(); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/SimpleStockComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/SimpleStockComponentFirerer.java new file mode 100644 index 00000000..a3584229 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/SimpleStockComponentFirerer.java @@ -0,0 +1,51 @@ +package com.pqt.client.module.gui.ressources.components.products.listeners; + +import com.pqt.core.entities.product.Product; +import javafx.event.Event; + +import javax.swing.event.EventListenerList; +import java.util.Arrays; + +public class SimpleStockComponentFirerer implements IStockComponentFirerer { + + private EventListenerList listenerList; + + public SimpleStockComponentFirerer() { + listenerList = new EventListenerList(); + } + + @Override + public void addListener(IStockComponentListener l) { + listenerList.add(IStockComponentListener.class, l); + } + + @Override + public void removeListener(IStockComponentListener l) { + listenerList.remove(IStockComponentListener.class, l); + } + + @Override + public void fireProductClickEvent(Event event, Product product) { + Arrays.stream(listenerList.getListeners(IStockComponentListener.class)).forEach(l->l.onProductClickEvent(event, product)); + } + + @Override + public void fireAddProductRequestEvent() { + Arrays.stream(listenerList.getListeners(IStockComponentListener.class)).forEach(IStockComponentListener::onAddProductRequestEvent); + } + + @Override + public void fireRemoveProductRequestEvent(Product product) { + Arrays.stream(listenerList.getListeners(IStockComponentListener.class)).forEach(l->l.onRemoveProductRequestEvent(product)); + } + + @Override + public void fireDetailProductRequestEvent(Product product) { + Arrays.stream(listenerList.getListeners(IStockComponentListener.class)).forEach(l->l.onDetailProductRequestEvent(product)); + } + + @Override + public void fireRefreshProductListRequestEvent() { + Arrays.stream(listenerList.getListeners(IStockComponentListener.class)).forEach(IStockComponentListener::onRefreshProductListRequestEvent); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleCreatorComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleCreatorComponent.java new file mode 100644 index 00000000..d577fcc0 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleCreatorComponent.java @@ -0,0 +1,8 @@ +package com.pqt.client.module.gui.ressources.components.sale; + +import com.pqt.client.module.gui.ressources.components.IFXComponent; +import com.pqt.core.entities.sale.Sale; + +public interface IFXSaleCreatorComponent extends IFXComponent{ + Sale create(); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleDisplayerComponent.java new file mode 100644 index 00000000..8065fc7a --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleDisplayerComponent.java @@ -0,0 +1,11 @@ +package com.pqt.client.module.gui.ressources.components.sale; + +import com.pqt.client.module.gui.ressources.components.IFXComponent; +import com.pqt.client.module.gui.ressources.components.sale.listeners.ISaleComponentListener; +import com.pqt.core.entities.sale.Sale; + +public interface IFXSaleDisplayerComponent extends IFXComponent { + void display(Sale sale); + void addListener(ISaleComponentListener l); + void removeListener(ISaleComponentListener l); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentFirerer.java new file mode 100644 index 00000000..12b36cf1 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentFirerer.java @@ -0,0 +1,5 @@ +package com.pqt.client.module.gui.ressources.components.sale.listeners; + +public interface ISaleComponentFirerer { + //TODO faire ça +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentListener.java new file mode 100644 index 00000000..f50b5c00 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentListener.java @@ -0,0 +1,7 @@ +package com.pqt.client.module.gui.ressources.components.sale.listeners; + +import java.util.EventListener; + +public interface ISaleComponentListener extends EventListener { + //TODO faire ça +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/SimpleSaleComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/SimpleSaleComponentFirerer.java new file mode 100644 index 00000000..b62b7be6 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/SimpleSaleComponentFirerer.java @@ -0,0 +1,5 @@ +package com.pqt.client.module.gui.ressources.components.sale.listeners; + +public class SimpleSaleComponentFirerer implements ISaleComponentFirerer { + //TODO faire ça +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/IFXValidatorComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/IFXValidatorComponent.java new file mode 100644 index 00000000..793d0545 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/IFXValidatorComponent.java @@ -0,0 +1,10 @@ +package com.pqt.client.module.gui.ressources.components.validation; + +import com.pqt.client.module.gui.ressources.components.IFXComponent; +import com.pqt.client.module.gui.ressources.components.products.listeners.IStockComponentListener; +import com.pqt.client.module.gui.ressources.components.validation.listeners.IValidatorComponentListener; + +public interface IFXValidatorComponent extends IFXComponent{ + void addListener(IValidatorComponentListener l); + void removeListener(IValidatorComponentListener l); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/IValidatorComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/IValidatorComponentFirerer.java new file mode 100644 index 00000000..121a5a54 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/IValidatorComponentFirerer.java @@ -0,0 +1,9 @@ +package com.pqt.client.module.gui.ressources.components.validation.listeners; + +public interface IValidatorComponentFirerer { + void addListener(IValidatorComponentListener l); + void removeListener(IValidatorComponentListener l); + + void fireValidationEvent(); + void fireCancelEvent(); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/IValidatorComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/IValidatorComponentListener.java new file mode 100644 index 00000000..13ec8414 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/IValidatorComponentListener.java @@ -0,0 +1,8 @@ +package com.pqt.client.module.gui.ressources.components.validation.listeners; + +import java.util.EventListener; + +public interface IValidatorComponentListener extends EventListener { + void onValidationEvent(); + void onCancelEvent(); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/SimpleValidatorComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/SimpleValidatorComponentFirerer.java new file mode 100644 index 00000000..6fed05a9 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/SimpleValidatorComponentFirerer.java @@ -0,0 +1,33 @@ +package com.pqt.client.module.gui.ressources.components.validation.listeners; + +import javax.swing.event.EventListenerList; +import java.util.Arrays; + +public class SimpleValidatorComponentFirerer implements IValidatorComponentFirerer { + + private EventListenerList listenerList; + + public SimpleValidatorComponentFirerer() { + listenerList = new EventListenerList(); + } + + @Override + public void addListener(IValidatorComponentListener l) { + listenerList.add(IValidatorComponentListener.class, l); + } + + @Override + public void removeListener(IValidatorComponentListener l) { + listenerList.remove(IValidatorComponentListener.class, l); + } + + @Override + public void fireValidationEvent() { + Arrays.stream(listenerList.getListeners(IValidatorComponentListener.class)).forEach(IValidatorComponentListener::onValidationEvent); + } + + @Override + public void fireCancelEvent() { + Arrays.stream(listenerList.getListeners(IValidatorComponentListener.class)).forEach(IValidatorComponentListener::onCancelEvent); + } +} From 6e0f3f625c1197084acc8d4e4306217707f9ffad Mon Sep 17 00:00:00 2001 From: Notmoo Date: Thu, 10 Aug 2017 20:22:18 +0200 Subject: [PATCH 02/36] =?UTF-8?q?Module=20client,=20packg=20GUI=20:=20ajou?= =?UTF-8?q?t=20interfaces=20g=C3=A9n=C3=A9rales=20des=20composants=20GUI?= =?UTF-8?q?=20(part=202/2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../products/IFXStockDisplayerComponent.java | 13 ----- .../listeners/IStockComponentFirerer.java | 16 ----- .../listeners/IStockComponentListener.java | 14 ----- .../SimpleStockComponentFirerer.java | 51 ---------------- .../sale/IFXSaleCreatorComponent.java | 8 --- .../sale/IFXSaleDisplayerComponent.java | 11 ---- .../sale/listeners/ISaleComponentFirerer.java | 5 -- .../listeners/ISaleComponentListener.java | 7 --- .../listeners/SimpleSaleComponentFirerer.java | 5 -- .../validation/IFXValidatorComponent.java | 10 ---- .../IFXComponent.java | 2 +- .../creators/IFXCreatorComponent.java | 8 +++ .../displayers/IFXDisplayerComponent.java | 10 ++++ .../listeners/IDisplayerComponentFirerer.java | 13 +++++ .../IDisplayerComponentListener.java | 13 +++++ .../SimpleDisplayerComponentFirerer.java | 58 +++++++++++++++++++ .../validators/IFXValidatorComponent.java | 9 +++ .../listeners/IValidatorComponentFirerer.java | 2 +- .../IValidatorComponentListener.java | 2 +- .../SimpleValidatorComponentFirerer.java | 2 +- .../IFXAccountsDisplayerComponent.java | 11 ++++ .../listeners/IAccountComponentListener.java | 7 +++ .../SimpleAccountComponentFirerer.java | 10 ++++ .../IFXProductsDisplayerComponent.java | 10 ++++ .../listeners/IStockComponentListener.java | 7 +++ .../SimpleStockComponentFirerer.java | 11 ++++ .../sale/IFXSaleDisplayerComponent.java | 8 +++ .../listeners/ISaleComponentListener.java | 10 ++++ .../listeners/SimpleSaleComponentFirerer.java | 19 ++++++ .../gui/ressources/strings/GUIStringTool.java | 40 +++++++++++++ .../strings/IObjectStringRenderer.java | 5 ++ .../IObjectWithQuantityStringRenderer.java | 5 ++ 32 files changed, 258 insertions(+), 144 deletions(-) delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/IFXStockDisplayerComponent.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentFirerer.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentListener.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/SimpleStockComponentFirerer.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleCreatorComponent.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleDisplayerComponent.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentFirerer.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentListener.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/SimpleSaleComponentFirerer.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/IFXValidatorComponent.java rename Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/{components => generics}/IFXComponent.java (60%) create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/creators/IFXCreatorComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/IFXDisplayerComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/IDisplayerComponentFirerer.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/IDisplayerComponentListener.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/IFXValidatorComponent.java rename Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/{components/validation => generics/validators}/listeners/IValidatorComponentFirerer.java (73%) rename Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/{components/validation => generics/validators}/listeners/IValidatorComponentListener.java (67%) rename Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/{components/validation => generics/validators}/listeners/SimpleValidatorComponentFirerer.java (92%) create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/IAccountComponentListener.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/IStockComponentListener.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/SimpleStockComponentFirerer.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/listeners/ISaleComponentListener.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/listeners/SimpleSaleComponentFirerer.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/GUIStringTool.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/IObjectStringRenderer.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/IObjectWithQuantityStringRenderer.java diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/IFXStockDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/IFXStockDisplayerComponent.java deleted file mode 100644 index 0f9d53a3..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/IFXStockDisplayerComponent.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.pqt.client.module.gui.ressources.components.products; - -import com.pqt.client.module.gui.ressources.components.IFXComponent; -import com.pqt.client.module.gui.ressources.components.products.listeners.IStockComponentListener; -import com.pqt.core.entities.product.Product; - -import java.util.Collection; - -public interface IFXStockDisplayerComponent extends IFXComponent { - void display(Collection products); - void addListener(IStockComponentListener l); - void removeListener(IStockComponentListener l); -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentFirerer.java deleted file mode 100644 index 073bfa10..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentFirerer.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.pqt.client.module.gui.ressources.components.products.listeners; - -import com.pqt.core.entities.product.Product; -import javafx.event.Event; - -public interface IStockComponentFirerer { - - void addListener(IStockComponentListener l); - void removeListener(IStockComponentListener l); - - void fireProductClickEvent(Event event, Product product); - void fireAddProductRequestEvent(); - void fireRemoveProductRequestEvent(Product product); - void fireDetailProductRequestEvent(Product product); - void fireRefreshProductListRequestEvent(); -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentListener.java deleted file mode 100644 index 52a6425b..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/IStockComponentListener.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.pqt.client.module.gui.ressources.components.products.listeners; - -import com.pqt.core.entities.product.Product; -import javafx.event.Event; - -import java.util.EventListener; - -public interface IStockComponentListener extends EventListener { - void onProductClickEvent(Event event, Product product); - void onAddProductRequestEvent(); - void onRemoveProductRequestEvent(Product product); - void onDetailProductRequestEvent(Product product); - void onRefreshProductListRequestEvent(); -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/SimpleStockComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/SimpleStockComponentFirerer.java deleted file mode 100644 index a3584229..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/products/listeners/SimpleStockComponentFirerer.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.pqt.client.module.gui.ressources.components.products.listeners; - -import com.pqt.core.entities.product.Product; -import javafx.event.Event; - -import javax.swing.event.EventListenerList; -import java.util.Arrays; - -public class SimpleStockComponentFirerer implements IStockComponentFirerer { - - private EventListenerList listenerList; - - public SimpleStockComponentFirerer() { - listenerList = new EventListenerList(); - } - - @Override - public void addListener(IStockComponentListener l) { - listenerList.add(IStockComponentListener.class, l); - } - - @Override - public void removeListener(IStockComponentListener l) { - listenerList.remove(IStockComponentListener.class, l); - } - - @Override - public void fireProductClickEvent(Event event, Product product) { - Arrays.stream(listenerList.getListeners(IStockComponentListener.class)).forEach(l->l.onProductClickEvent(event, product)); - } - - @Override - public void fireAddProductRequestEvent() { - Arrays.stream(listenerList.getListeners(IStockComponentListener.class)).forEach(IStockComponentListener::onAddProductRequestEvent); - } - - @Override - public void fireRemoveProductRequestEvent(Product product) { - Arrays.stream(listenerList.getListeners(IStockComponentListener.class)).forEach(l->l.onRemoveProductRequestEvent(product)); - } - - @Override - public void fireDetailProductRequestEvent(Product product) { - Arrays.stream(listenerList.getListeners(IStockComponentListener.class)).forEach(l->l.onDetailProductRequestEvent(product)); - } - - @Override - public void fireRefreshProductListRequestEvent() { - Arrays.stream(listenerList.getListeners(IStockComponentListener.class)).forEach(IStockComponentListener::onRefreshProductListRequestEvent); - } -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleCreatorComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleCreatorComponent.java deleted file mode 100644 index d577fcc0..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleCreatorComponent.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.pqt.client.module.gui.ressources.components.sale; - -import com.pqt.client.module.gui.ressources.components.IFXComponent; -import com.pqt.core.entities.sale.Sale; - -public interface IFXSaleCreatorComponent extends IFXComponent{ - Sale create(); -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleDisplayerComponent.java deleted file mode 100644 index 8065fc7a..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/IFXSaleDisplayerComponent.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pqt.client.module.gui.ressources.components.sale; - -import com.pqt.client.module.gui.ressources.components.IFXComponent; -import com.pqt.client.module.gui.ressources.components.sale.listeners.ISaleComponentListener; -import com.pqt.core.entities.sale.Sale; - -public interface IFXSaleDisplayerComponent extends IFXComponent { - void display(Sale sale); - void addListener(ISaleComponentListener l); - void removeListener(ISaleComponentListener l); -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentFirerer.java deleted file mode 100644 index 12b36cf1..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentFirerer.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.pqt.client.module.gui.ressources.components.sale.listeners; - -public interface ISaleComponentFirerer { - //TODO faire ça -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentListener.java deleted file mode 100644 index f50b5c00..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/ISaleComponentListener.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.pqt.client.module.gui.ressources.components.sale.listeners; - -import java.util.EventListener; - -public interface ISaleComponentListener extends EventListener { - //TODO faire ça -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/SimpleSaleComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/SimpleSaleComponentFirerer.java deleted file mode 100644 index b62b7be6..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/sale/listeners/SimpleSaleComponentFirerer.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.pqt.client.module.gui.ressources.components.sale.listeners; - -public class SimpleSaleComponentFirerer implements ISaleComponentFirerer { - //TODO faire ça -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/IFXValidatorComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/IFXValidatorComponent.java deleted file mode 100644 index 793d0545..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/IFXValidatorComponent.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.pqt.client.module.gui.ressources.components.validation; - -import com.pqt.client.module.gui.ressources.components.IFXComponent; -import com.pqt.client.module.gui.ressources.components.products.listeners.IStockComponentListener; -import com.pqt.client.module.gui.ressources.components.validation.listeners.IValidatorComponentListener; - -public interface IFXValidatorComponent extends IFXComponent{ - void addListener(IValidatorComponentListener l); - void removeListener(IValidatorComponentListener l); -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/IFXComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/IFXComponent.java similarity index 60% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/IFXComponent.java rename to Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/IFXComponent.java index 57448371..973b1e74 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/IFXComponent.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/IFXComponent.java @@ -1,4 +1,4 @@ -package com.pqt.client.module.gui.ressources.components; +package com.pqt.client.module.gui.ressources.generics; import javafx.scene.layout.Pane; diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/creators/IFXCreatorComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/creators/IFXCreatorComponent.java new file mode 100644 index 00000000..70b1436d --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/creators/IFXCreatorComponent.java @@ -0,0 +1,8 @@ +package com.pqt.client.module.gui.ressources.generics.creators; + +import com.pqt.client.module.gui.ressources.generics.IFXComponent; + +public interface IFXCreatorComponent extends IFXComponent{ + T create(); + boolean isCreationPossible(); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/IFXDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/IFXDisplayerComponent.java new file mode 100644 index 00000000..df7f3e95 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/IFXDisplayerComponent.java @@ -0,0 +1,10 @@ +package com.pqt.client.module.gui.ressources.generics.displayers; + +import com.pqt.client.module.gui.ressources.generics.IFXComponent; +import com.pqt.client.module.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; + +public interface IFXDisplayerComponent extends IFXComponent{ + void display(T content); + void addListener(U l); + void removeListener(U l); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/IDisplayerComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/IDisplayerComponentFirerer.java new file mode 100644 index 00000000..5df54246 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/IDisplayerComponentFirerer.java @@ -0,0 +1,13 @@ +package com.pqt.client.module.gui.ressources.generics.displayers.listeners; + +import javafx.event.Event; + +public interface IDisplayerComponentFirerer { + void fireRefreshContentRequestEvent(); + void fireContentClickEvent(Event event, T eventTarget); + void fireAddContentRequestEvent(); + void fireRemoveContentRequestEvent(T content); + void fireDetailContentRequestEvent(T content); + void addListener(IDisplayerComponentListener l); + void removeListener(IDisplayerComponentListener l); +} \ No newline at end of file diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/IDisplayerComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/IDisplayerComponentListener.java new file mode 100644 index 00000000..12ce0198 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/IDisplayerComponentListener.java @@ -0,0 +1,13 @@ +package com.pqt.client.module.gui.ressources.generics.displayers.listeners; + +import javafx.event.Event; + +import java.util.EventListener; + +public interface IDisplayerComponentListener extends EventListener { + void onRefreshContentRequestEvent(); + void onContentClickEvent(Event event, T eventTarget); + void onAddContentRequestEvent(); + void onRemoveContentRequestEvent(T content); + void onDetailContentRequestEvent(T content); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java new file mode 100644 index 00000000..c2758529 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java @@ -0,0 +1,58 @@ +package com.pqt.client.module.gui.ressources.generics.displayers.listeners; + +import javafx.event.Event; + +import javax.swing.event.EventListenerList; +import java.util.Arrays; + +public class SimpleDisplayerComponentFirerer> implements IDisplayerComponentFirerer { + + protected EventListenerList listenerList; + protected Class clazz; + + public SimpleDisplayerComponentFirerer(Class clazz) { + listenerList = new EventListenerList(); + this.clazz = clazz; + } + + @Override + public void fireRefreshContentRequestEvent() { + Arrays.stream(listenerList.getListeners(clazz)).forEach(IDisplayerComponentListener::onRefreshContentRequestEvent); + } + + @Override + public void fireContentClickEvent(Event event, T eventTarget) { + Arrays.stream(listenerList.getListeners(clazz)).forEach(l->l.onContentClickEvent(event, eventTarget)); + } + + @Override + public void fireAddContentRequestEvent() { + Arrays.stream(listenerList.getListeners(clazz)).forEach(IDisplayerComponentListener::onAddContentRequestEvent); + } + + @Override + public void fireRemoveContentRequestEvent(T content) { + Arrays.stream(listenerList.getListeners(clazz)).forEach(l->l.onRemoveContentRequestEvent(content)); + } + + @Override + public void fireDetailContentRequestEvent(T content) { + Arrays.stream(listenerList.getListeners(clazz)).forEach(l->l.onDetailContentRequestEvent(content)); + } + + @Override + public void addListener(IDisplayerComponentListener l) throws IllegalArgumentException { + if(clazz.isInstance(l)){ + listenerList.add(clazz, clazz.cast(l)); + }else{ + throw new IllegalArgumentException("Listener must implement the following interface : "+clazz.getName()); + } + } + + @Override + public void removeListener(IDisplayerComponentListener l) { + if (clazz.isInstance(l)) { + listenerList.remove(clazz, clazz.cast(l)); + } + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/IFXValidatorComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/IFXValidatorComponent.java new file mode 100644 index 00000000..4171c452 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/IFXValidatorComponent.java @@ -0,0 +1,9 @@ +package com.pqt.client.module.gui.ressources.generics.validators; + +import com.pqt.client.module.gui.ressources.generics.IFXComponent; +import com.pqt.client.module.gui.ressources.generics.validators.listeners.IValidatorComponentListener; + +public interface IFXValidatorComponent extends IFXComponent{ + void addListener(IValidatorComponentListener l); + void removeListener(IValidatorComponentListener l); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/IValidatorComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/IValidatorComponentFirerer.java similarity index 73% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/IValidatorComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/IValidatorComponentFirerer.java index 121a5a54..ab66cdf4 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/IValidatorComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/IValidatorComponentFirerer.java @@ -1,4 +1,4 @@ -package com.pqt.client.module.gui.ressources.components.validation.listeners; +package com.pqt.client.module.gui.ressources.generics.validators.listeners; public interface IValidatorComponentFirerer { void addListener(IValidatorComponentListener l); diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/IValidatorComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/IValidatorComponentListener.java similarity index 67% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/IValidatorComponentListener.java rename to Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/IValidatorComponentListener.java index 13ec8414..57f7198f 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/IValidatorComponentListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/IValidatorComponentListener.java @@ -1,4 +1,4 @@ -package com.pqt.client.module.gui.ressources.components.validation.listeners; +package com.pqt.client.module.gui.ressources.generics.validators.listeners; import java.util.EventListener; diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/SimpleValidatorComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/SimpleValidatorComponentFirerer.java similarity index 92% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/SimpleValidatorComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/SimpleValidatorComponentFirerer.java index 6fed05a9..a06b07e9 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/validation/listeners/SimpleValidatorComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/SimpleValidatorComponentFirerer.java @@ -1,4 +1,4 @@ -package com.pqt.client.module.gui.ressources.components.validation.listeners; +package com.pqt.client.module.gui.ressources.generics.validators.listeners; import javax.swing.event.EventListenerList; import java.util.Arrays; diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java new file mode 100644 index 00000000..60b3a247 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java @@ -0,0 +1,11 @@ +package com.pqt.client.module.gui.ressources.specifics.account; + +import com.pqt.client.module.gui.ressources.specifics.account.listeners.IAccountComponentListener; +import com.pqt.client.module.gui.ressources.generics.displayers.IFXDisplayerComponent; +import com.pqt.core.entities.user_account.Account; + +import java.util.Collection; + +public interface IFXAccountsDisplayerComponent extends IFXDisplayerComponent, IAccountComponentListener>{ + +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/IAccountComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/IAccountComponentListener.java new file mode 100644 index 00000000..23fbf16c --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/IAccountComponentListener.java @@ -0,0 +1,7 @@ +package com.pqt.client.module.gui.ressources.specifics.account.listeners; + +import com.pqt.client.module.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; +import com.pqt.core.entities.user_account.Account; + +public interface IAccountComponentListener extends IDisplayerComponentListener{ +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java new file mode 100644 index 00000000..aa16640f --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java @@ -0,0 +1,10 @@ +package com.pqt.client.module.gui.ressources.specifics.account.listeners; + +import com.pqt.client.module.gui.ressources.generics.displayers.listeners.SimpleDisplayerComponentFirerer; +import com.pqt.core.entities.user_account.Account; + +public class SimpleAccountComponentFirerer extends SimpleDisplayerComponentFirerer{ + public SimpleAccountComponentFirerer() { + super(IAccountComponentListener.class); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java new file mode 100644 index 00000000..e69a6a85 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java @@ -0,0 +1,10 @@ +package com.pqt.client.module.gui.ressources.specifics.products; + +import com.pqt.client.module.gui.ressources.specifics.products.listeners.IStockComponentListener; +import com.pqt.client.module.gui.ressources.generics.displayers.IFXDisplayerComponent; +import com.pqt.core.entities.product.Product; + +import java.util.Collection; + +public interface IFXProductsDisplayerComponent extends IFXDisplayerComponent, IStockComponentListener> { +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/IStockComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/IStockComponentListener.java new file mode 100644 index 00000000..05a8a695 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/IStockComponentListener.java @@ -0,0 +1,7 @@ +package com.pqt.client.module.gui.ressources.specifics.products.listeners; + +import com.pqt.client.module.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; +import com.pqt.core.entities.product.Product; + +public interface IStockComponentListener extends IDisplayerComponentListener { +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/SimpleStockComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/SimpleStockComponentFirerer.java new file mode 100644 index 00000000..0f3b5933 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/SimpleStockComponentFirerer.java @@ -0,0 +1,11 @@ +package com.pqt.client.module.gui.ressources.specifics.products.listeners; + +import com.pqt.client.module.gui.ressources.generics.displayers.listeners.SimpleDisplayerComponentFirerer; +import com.pqt.core.entities.product.Product; + +public class SimpleStockComponentFirerer extends SimpleDisplayerComponentFirerer { + + public SimpleStockComponentFirerer() { + super(IStockComponentListener.class); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java new file mode 100644 index 00000000..c394a2d3 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java @@ -0,0 +1,8 @@ +package com.pqt.client.module.gui.ressources.specifics.sale; + +import com.pqt.client.module.gui.ressources.specifics.sale.listeners.ISaleComponentListener; +import com.pqt.client.module.gui.ressources.generics.displayers.IFXDisplayerComponent; +import com.pqt.core.entities.sale.Sale; + +public interface IFXSaleDisplayerComponent extends IFXDisplayerComponent { +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/listeners/ISaleComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/listeners/ISaleComponentListener.java new file mode 100644 index 00000000..bc1284af --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/listeners/ISaleComponentListener.java @@ -0,0 +1,10 @@ +package com.pqt.client.module.gui.ressources.specifics.sale.listeners; + +import com.pqt.client.module.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; +import com.pqt.core.entities.product.Product; +import com.pqt.core.entities.sale.Sale; +import javafx.event.Event; + +public interface ISaleComponentListener extends IDisplayerComponentListener { + void onComponentClickEvent(Event event, Product product); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/listeners/SimpleSaleComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/listeners/SimpleSaleComponentFirerer.java new file mode 100644 index 00000000..fa746589 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/listeners/SimpleSaleComponentFirerer.java @@ -0,0 +1,19 @@ +package com.pqt.client.module.gui.ressources.specifics.sale.listeners; + +import com.pqt.client.module.gui.ressources.generics.displayers.listeners.SimpleDisplayerComponentFirerer; +import com.pqt.core.entities.product.Product; +import com.pqt.core.entities.sale.Sale; +import javafx.event.Event; + +import java.util.Arrays; + +public class SimpleSaleComponentFirerer extends SimpleDisplayerComponentFirerer { + + public SimpleSaleComponentFirerer() { + super(ISaleComponentListener.class); + } + + public void fireComponentClickEvent(Event event, Product product) { + Arrays.stream(listenerList.getListeners(ISaleComponentListener.class)).forEach(l->l.onComponentClickEvent(event, product)); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/GUIStringTool.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/GUIStringTool.java new file mode 100644 index 00000000..915ffc6b --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/GUIStringTool.java @@ -0,0 +1,40 @@ +package com.pqt.client.module.gui.ressources.strings; + +import com.pqt.core.entities.product.Product; + +//TODO faire ça un peu mieux +public class GUIStringTool { + public static String getValidationButtonLabel() { + return "Valider"; + } + + public static String getConfirmationValidationButtonLabel() { + return "Confirmer"; + } + + public static String getCancelButtonLabel() { + return "Annuler"; + } + + public static String getConfirmationCancelButtonLabel() { + return "Confirmer"; + } + + public static String getCategorytabStockDisplayerTitle() { + return "Produits"; + } + + public static IObjectStringRenderer getProductStringRenderer(){ + return product->String.format("%s - %.2f€ (%s)", product.getName(), product.getPrice(), (product.getAmountRemaining()>=30?"30+": Integer.toString(product.getAmountRemaining()))); + } + + public static String getCommandComposerTitleTitle() { + return "Commande"; + } + + public static IObjectWithQuantityStringRenderer getSaleItemStringRenderer(){ + return (product, qté)->String.format("%s - %.2f€ (%s)", product.getName(), product.getPrice(), (product.getAmountRemaining()>=30?"30+": Integer.toString(product.getAmountRemaining()))); + } +} + + diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/IObjectStringRenderer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/IObjectStringRenderer.java new file mode 100644 index 00000000..98709239 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/IObjectStringRenderer.java @@ -0,0 +1,5 @@ +package com.pqt.client.module.gui.ressources.strings; + +public interface IObjectStringRenderer { + String render(T obj); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/IObjectWithQuantityStringRenderer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/IObjectWithQuantityStringRenderer.java new file mode 100644 index 00000000..8cc2fc9c --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/IObjectWithQuantityStringRenderer.java @@ -0,0 +1,5 @@ +package com.pqt.client.module.gui.ressources.strings; + +public interface IObjectWithQuantityStringRenderer { + String render(T obj, int quantity); +} From 5c1d71f733df117a29e3b331d9d86f59a32b0c70 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Thu, 10 Aug 2017 20:23:10 +0200 Subject: [PATCH 03/36] Module Client, packg GUI : ajout composants d'interface --- .../components/CategoryTabStockDisplayer.java | 113 ++++++++++++++++++ .../CommandComposerSaleDisplayer.java | 85 +++++++++++++ .../components/SimpleValidator.java | 99 +++++++++++++++ 3 files changed, 297 insertions(+) create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/CategoryTabStockDisplayer.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/CommandComposerSaleDisplayer.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/SimpleValidator.java diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/CategoryTabStockDisplayer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/CategoryTabStockDisplayer.java new file mode 100644 index 00000000..aa17ad38 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/CategoryTabStockDisplayer.java @@ -0,0 +1,113 @@ +package com.pqt.client.module.gui.ressources.components; + +import com.pqt.client.module.gui.ressources.generics.displayers.IFXDisplayerComponent; +import com.pqt.client.module.gui.ressources.specifics.products.listeners.IStockComponentListener; +import com.pqt.client.module.gui.ressources.specifics.products.listeners.SimpleStockComponentFirerer; +import com.pqt.client.module.gui.ressources.strings.GUIStringTool; +import com.pqt.client.module.gui.ressources.strings.IObjectStringRenderer; +import com.pqt.core.entities.product.Product; +import javafx.application.Platform; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.scene.control.*; +import javafx.scene.input.KeyCode; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.Pane; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +public class CategoryTabStockDisplayer implements IFXDisplayerComponent, IStockComponentListener>{ + + private SimpleStockComponentFirerer firerer; + private BorderPane mainPane; + private TabPane tabPane; + + public CategoryTabStockDisplayer() { + init(); + firerer = new SimpleStockComponentFirerer(); + } + + @Override + public void display(Collection content) { + final ObservableList tabs = FXCollections.emptyObservableList(); + if(content!=null){ + List categories = content.stream().map(product->product.getCategory().getName()).distinct().collect(Collectors.toList()); + + for(String cat : categories){ + tabs.add(createCategoryTab(cat, content.stream().filter(p->p.getCategory().getName().equals(cat)).collect(Collectors.toList()))); + } + + } + + Platform.runLater(()->{ + tabPane.getTabs().clear(); + tabPane.getTabs().addAll(tabs); + }); + } + + @Override + public void addListener(IStockComponentListener l) { + firerer.addListener(l); + } + + @Override + public void removeListener(IStockComponentListener l) { + firerer.removeListener(l); + } + + @Override + public Pane getPane() { + return mainPane; + } + + private void init(){ + mainPane = new BorderPane(); + Label title = new Label(GUIStringTool.getCategorytabStockDisplayerTitle()); + mainPane.setTop(title); + + tabPane = new TabPane(); + mainPane.setCenter(tabPane); + } + + private Tab createCategoryTab(String categoryName, Collection products){ + Tab tab = new Tab(categoryName); + tab.closableProperty().setValue(false); + + ListView listView = new ListView<>(); + listView.setCellFactory(list->new ListCell(){ + + @Override + protected void updateItem(Product item, boolean empty) { + super.updateItem(item, empty); + + if (empty || item == null) { + setText(null); + setGraphic(null); + } else { + setText(CategoryTabStockDisplayer.getProductRenderer().render(item)); + } + } + }); + + listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); + listView.setEditable(false); + listView.setOnMouseClicked(event->firerer.fireContentClickEvent(event, listView.getSelectionModel().getSelectedItem())); + listView.setOnKeyTyped(event -> { + if(event.getCode().equals(KeyCode.ENTER)){ + firerer.fireContentClickEvent(event, listView.getSelectionModel().getSelectedItem()); + event.consume(); + } + }); + + listView.setItems(FXCollections.observableArrayList(products)); + + tab.setContent(listView); + return tab; + } + + private static IObjectStringRenderer getProductRenderer(){ + return GUIStringTool.getProductStringRenderer(); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/CommandComposerSaleDisplayer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/CommandComposerSaleDisplayer.java new file mode 100644 index 00000000..190aa7ac --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/CommandComposerSaleDisplayer.java @@ -0,0 +1,85 @@ +package com.pqt.client.module.gui.ressources.components; + +import com.pqt.client.module.gui.ressources.specifics.sale.IFXSaleDisplayerComponent; +import com.pqt.client.module.gui.ressources.specifics.sale.listeners.ISaleComponentListener; +import com.pqt.client.module.gui.ressources.specifics.sale.listeners.SimpleSaleComponentFirerer; +import com.pqt.client.module.gui.ressources.strings.GUIStringTool; +import com.pqt.core.entities.product.Product; +import com.pqt.core.entities.sale.Sale; +import javafx.application.Platform; +import javafx.collections.FXCollections; +import javafx.scene.control.*; +import javafx.scene.input.KeyCode; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.Pane; + +import java.util.ArrayList; +import java.util.stream.Collectors; + +public class CommandComposerSaleDisplayer implements IFXSaleDisplayerComponent { + + private SimpleSaleComponentFirerer firerer; + private BorderPane mainPane; + private ListView listView; + + private Sale sale; + + public CommandComposerSaleDisplayer() { + firerer = new SimpleSaleComponentFirerer(); + init(); + } + + private void init() { + mainPane = new BorderPane(); + Label title = new Label(GUIStringTool.getCommandComposerTitleTitle()); + mainPane.setTop(title); + + listView = new ListView<>(); + listView.setCellFactory(list->new ListCell(){ + @Override + protected void updateItem(Product item, boolean empty) { + super.updateItem(item, empty); + + if (empty || item == null) { + setText(null); + setGraphic(null); + } else { + setText(GUIStringTool.getSaleItemStringRenderer().render(item, sale.getProducts().get(item))); + } + } + }); + listView.setEditable(false); + listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); + listView.setOnMouseClicked(event->firerer.fireComponentClickEvent(event, listView.getSelectionModel().getSelectedItem())); + listView.setOnKeyTyped(event -> { + if(event.getCode().equals(KeyCode.ENTER)){ + firerer.fireComponentClickEvent(event, listView.getSelectionModel().getSelectedItem()); + } + }); + mainPane.setCenter(listView); + } + + @Override + public void display(Sale content) { + if(content ==null) + return; + + this.sale = content; + Platform.runLater(()->this.listView.setItems(FXCollections.observableList(new ArrayList<>(this.sale.getProducts().keySet())))); + } + + @Override + public void addListener(ISaleComponentListener l) { + firerer.addListener(l); + } + + @Override + public void removeListener(ISaleComponentListener l) { + firerer.removeListener(l); + } + + @Override + public Pane getPane() { + return mainPane; + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/SimpleValidator.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/SimpleValidator.java new file mode 100644 index 00000000..1f6a9e35 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/SimpleValidator.java @@ -0,0 +1,99 @@ +package com.pqt.client.module.gui.ressources.components; + +import com.pqt.client.module.gui.ressources.generics.validators.IFXValidatorComponent; +import com.pqt.client.module.gui.ressources.generics.validators.listeners.IValidatorComponentFirerer; +import com.pqt.client.module.gui.ressources.generics.validators.listeners.IValidatorComponentListener; +import com.pqt.client.module.gui.ressources.generics.validators.listeners.SimpleValidatorComponentFirerer; +import com.pqt.client.module.gui.ressources.strings.GUIStringTool; +import javafx.application.Platform; +import javafx.scene.control.Button; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Pane; + +public class SimpleValidator implements IFXValidatorComponent{ + + private final IValidatorComponentFirerer firerer; + private Pane pane; + private boolean askConfirmation; + private Button validationButton, cancelButton; + + public SimpleValidator() { + this(false); + } + + public SimpleValidator(boolean askConfirmation) { + firerer = new SimpleValidatorComponentFirerer(); + this.askConfirmation = askConfirmation; + + } + + @Override + public void addListener(IValidatorComponentListener l) { + firerer.addListener(l); + } + + @Override + public void removeListener(IValidatorComponentListener l) { + firerer.removeListener(l); + } + + @Override + public Pane getPane() { + if(pane == null) + pane = createPane(); + return pane; + } + + private Pane createPane(){ + HBox hbox = new HBox(); + + validationButton = new Button(GUIStringTool.getValidationButtonLabel()); + validationButton.setOnMouseClicked(event->{ + getValidationButtonProcess().process(); + }); + hbox.getChildren().add(validationButton); + + cancelButton = new Button(GUIStringTool.getCancelButtonLabel()); + cancelButton.setOnMouseClicked(event->{ + getCancelButtonProcess().process(); + }); + hbox.getChildren().add(cancelButton); + + return hbox; + } + + private IButtonProcess getValidationButtonProcess(){ + return ()->{ + if(validationButton.getText().equals(GUIStringTool.getValidationButtonLabel())){ + if(askConfirmation) + Platform.runLater(()->validationButton.setText(GUIStringTool.getConfirmationValidationButtonLabel())); + else + firerer.fireValidationEvent(); + }else{ + if(validationButton.getText().equals(GUIStringTool.getConfirmationValidationButtonLabel())) + firerer.fireValidationEvent(); + Platform.runLater(()->validationButton.setText(GUIStringTool.getValidationButtonLabel())); + } + }; + } + + private IButtonProcess getCancelButtonProcess(){ + return ()->{ + if(cancelButton.getText().equals(GUIStringTool.getCancelButtonLabel())){ + if(askConfirmation) + Platform.runLater(()->cancelButton.setText(GUIStringTool.getConfirmationCancelButtonLabel())); + else + firerer.fireCancelEvent(); + }else{ + Platform.runLater(()->cancelButton.setText(GUIStringTool.getCancelButtonLabel())); + firerer.fireCancelEvent(); + } + }; + + + } + + private interface IButtonProcess{ + void process(); + } +} From 29bd24ad657fef93c8973d453e55470c412fd7b5 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sun, 13 Aug 2017 21:55:25 +0200 Subject: [PATCH 04/36] =?UTF-8?q?Module=20Client=20:=20d=C3=A9placement=20?= =?UTF-8?q?du=20packg=20"gui"=20du=20packg=20"client.module"=20vers=20le?= =?UTF-8?q?=20packg=20"client"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ressources/components/AccountManager.java | 153 ++++++++++++++++++ .../components/CategoryTabStockDisplayer.java | 14 +- .../CommandComposerSaleDisplayer.java | 11 +- .../components/SimpleValidator.java | 14 +- .../SaleValidationScreen.java | 85 ++++++++++ .../ISaleValidationScreenListener.java | 7 + .../client/gui/ressources/css/GUICssTool.java | 7 + .../gui/ressources/generics/IFXComponent.java | 2 +- .../creators/IFXCreatorComponent.java | 8 + .../displayers/IFXDisplayerComponent.java | 10 ++ .../listeners/IDisplayerComponentFirerer.java | 2 +- .../IDisplayerComponentListener.java | 2 +- .../SimpleDisplayerComponentFirerer.java | 2 +- .../validators/IFXValidatorComponent.java | 9 ++ .../listeners/IValidatorComponentFirerer.java | 2 +- .../IValidatorComponentListener.java | 2 +- .../SimpleValidatorComponentFirerer.java | 2 +- .../IFXAccountsDisplayerComponent.java | 11 ++ .../listeners/IAccountComponentListener.java | 7 + .../SimpleAccountComponentFirerer.java | 10 ++ .../IFXProductsDisplayerComponent.java | 10 ++ .../listeners/IStockComponentListener.java | 7 + .../SimpleStockComponentFirerer.java | 4 +- .../sale/IFXSaleDisplayerComponent.java | 8 + .../listeners/ISaleComponentListener.java | 4 +- .../listeners/SimpleSaleComponentFirerer.java | 4 +- .../gui/ressources/strings/GUIStringTool.java | 153 ++++++++++++++++++ .../strings/IObjectStringRenderer.java | 2 +- .../IObjectWithQuantityStringRenderer.java | 2 +- .../creators/IFXCreatorComponent.java | 8 - .../displayers/IFXDisplayerComponent.java | 10 -- .../validators/IFXValidatorComponent.java | 9 -- .../IFXAccountsDisplayerComponent.java | 11 -- .../listeners/IAccountComponentListener.java | 7 - .../SimpleAccountComponentFirerer.java | 10 -- .../IFXProductsDisplayerComponent.java | 10 -- .../listeners/IStockComponentListener.java | 7 - .../sale/IFXSaleDisplayerComponent.java | 8 - .../gui/ressources/strings/GUIStringTool.java | 40 ----- 39 files changed, 519 insertions(+), 155 deletions(-) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/AccountManager.java rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/components/CategoryTabStockDisplayer.java (86%) rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/components/CommandComposerSaleDisplayer.java (85%) rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/components/SimpleValidator.java (82%) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/sale_validation_screen/SaleValidationScreen.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/sale_validation_screen/listeners/ISaleValidationScreenListener.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/generics/IFXComponent.java (61%) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/creators/IFXCreatorComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/IFXDisplayerComponent.java rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/generics/displayers/listeners/IDisplayerComponentFirerer.java (85%) rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/generics/displayers/listeners/IDisplayerComponentListener.java (82%) rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java (96%) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/IFXValidatorComponent.java rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/generics/validators/listeners/IValidatorComponentFirerer.java (74%) rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/generics/validators/listeners/IValidatorComponentListener.java (67%) rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/generics/validators/listeners/SimpleValidatorComponentFirerer.java (92%) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/IAccountComponentListener.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/listeners/IStockComponentListener.java rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/specifics/products/listeners/SimpleStockComponentFirerer.java (59%) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/specifics/sale/listeners/ISaleComponentListener.java (60%) rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/specifics/sale/listeners/SimpleSaleComponentFirerer.java (75%) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/strings/IObjectStringRenderer.java (57%) rename Workspace/client/src/main/java/com/pqt/client/{module => }/gui/ressources/strings/IObjectWithQuantityStringRenderer.java (64%) delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/creators/IFXCreatorComponent.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/IFXDisplayerComponent.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/IFXValidatorComponent.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/IAccountComponentListener.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/IStockComponentListener.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/GUIStringTool.java diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/AccountManager.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/AccountManager.java new file mode 100644 index 00000000..b5f8b213 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/AccountManager.java @@ -0,0 +1,153 @@ +package com.pqt.client.gui.ressources.components; + +import com.pqt.client.gui.ressources.generics.creators.IFXCreatorComponent; +import com.pqt.client.gui.ressources.generics.validators.IFXValidatorComponent; +import com.pqt.client.gui.ressources.specifics.account.listeners.IAccountComponentListener; +import com.pqt.client.gui.ressources.generics.validators.listeners.IValidatorComponentListener; +import com.pqt.client.gui.ressources.generics.validators.listeners.SimpleValidatorComponentFirerer; +import com.pqt.client.gui.ressources.specifics.account.IFXAccountsDisplayerComponent; +import com.pqt.client.gui.ressources.specifics.account.listeners.SimpleAccountComponentFirerer; +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.core.entities.user_account.Account; +import javafx.application.Platform; +import javafx.collections.FXCollections; +import javafx.scene.control.Button; +import javafx.scene.control.ChoiceBox; +import javafx.scene.control.PasswordField; +import javafx.scene.control.TextField; +import javafx.scene.input.KeyCode; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Pane; +import javafx.scene.layout.VBox; + +import java.util.Collection; + +public class AccountManager implements IFXAccountsDisplayerComponent, IFXValidatorComponent, IFXCreatorComponent { + + private Pane mainPane; + + private HBox mainDisconnectedPane, mainConnectedPane; + private TextField connectedUsernameField; + private ChoiceBox disconnectedUsernameField; + private PasswordField passwordField; + + private SimpleAccountComponentFirerer accountEventFirerer; + private SimpleValidatorComponentFirerer validatorEventFirerer; + + private Account currentAccount; + + public AccountManager() { + accountEventFirerer = new SimpleAccountComponentFirerer(); + validatorEventFirerer = new SimpleValidatorComponentFirerer(); + + currentAccount = null; + + init(); + } + + private void init() { + mainPane = new Pane(); + + mainConnectedPane = new HBox(); + mainDisconnectedPane = new HBox(); + + connectedUsernameField = new TextField(); + connectedUsernameField.setEditable(false); + + Button disconnectButton = new Button(GUIStringTool.getLogoutButtonLabel()); + disconnectButton.setOnMouseClicked(event->validatorEventFirerer.fireCancelEvent()); + disconnectButton.setOnKeyTyped(event->{if(event.getCode().equals(KeyCode.ENTER)) validatorEventFirerer.fireCancelEvent();}); + + mainConnectedPane.getChildren().addAll(connectedUsernameField, disconnectButton); + + + disconnectedUsernameField = new ChoiceBox<>(); + disconnectedUsernameField.setConverter(GUIStringTool.getAccountStringConverter()); + + passwordField = new PasswordField(); + passwordField.setPromptText(GUIStringTool.getPasswordFieldPromptText()); + + VBox leftDisconnectedPaneContent = new VBox(); + leftDisconnectedPaneContent.getChildren().addAll(disconnectedUsernameField, passwordField); + + Button validationButton = new Button(GUIStringTool.getLoginButtonLabel()); + validationButton.setOnMouseClicked(event-> validatorEventFirerer.fireValidationEvent()); + validationButton.setOnKeyTyped(event->{if(event.getCode().equals(KeyCode.ENTER)) validatorEventFirerer.fireValidationEvent();}); + + mainDisconnectedPane.getChildren().addAll(leftDisconnectedPaneContent, validationButton); + + refreshMainPane(); + } + + @Override + public void display(Collection content) { + Platform.runLater(()->disconnectedUsernameField.setItems(FXCollections.observableArrayList(content))); + } + + public void setCurrentAccount(Account account){ + currentAccount = account; + Platform.runLater(()->connectedUsernameField.setText(GUIStringTool.getAccountStringConverter().toString(currentAccount))); + refreshMainPane(); + } + + private void refreshMainPane() { + if(currentAccount!=null) + Platform.runLater( + ()->{ + mainPane.getChildren().clear(); + mainPane.getChildren().add(mainConnectedPane); + } + ); + else + Platform.runLater( + ()->{ + mainPane.getChildren().clear(); + mainPane.getChildren().add(mainDisconnectedPane); + } + ); + } + + public Account getCurrentAccount() { + return currentAccount; + } + + @Override + public void addListener(IAccountComponentListener l) { + accountEventFirerer.addListener(l); + } + + @Override + public void removeListener(IAccountComponentListener l) { + accountEventFirerer.removeListener(l); + } + + @Override + public Pane getPane() { + return mainPane; + } + + @Override + public void addListener(IValidatorComponentListener l) { + validatorEventFirerer.addListener(l); + } + + @Override + public void removeListener(IValidatorComponentListener l) { + validatorEventFirerer.removeListener(l); + } + + @Override + public Account create() { + if(!isCreationPossible()) + return null; + + return new Account(disconnectedUsernameField.getValue().getUsername(), passwordField.getText(), disconnectedUsernameField.getValue().getPermissionLevel()); + } + + @Override + public boolean isCreationPossible() { + return currentAccount==null + && !disconnectedUsernameField.getAccessibleText().isEmpty() + && !passwordField.getText().isEmpty(); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/CategoryTabStockDisplayer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java similarity index 86% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/CategoryTabStockDisplayer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java index aa17ad38..a4f2f582 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/CategoryTabStockDisplayer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java @@ -1,10 +1,10 @@ -package com.pqt.client.module.gui.ressources.components; +package com.pqt.client.gui.ressources.components; -import com.pqt.client.module.gui.ressources.generics.displayers.IFXDisplayerComponent; -import com.pqt.client.module.gui.ressources.specifics.products.listeners.IStockComponentListener; -import com.pqt.client.module.gui.ressources.specifics.products.listeners.SimpleStockComponentFirerer; -import com.pqt.client.module.gui.ressources.strings.GUIStringTool; -import com.pqt.client.module.gui.ressources.strings.IObjectStringRenderer; +import com.pqt.client.gui.ressources.generics.displayers.IFXDisplayerComponent; +import com.pqt.client.gui.ressources.specifics.products.listeners.IStockComponentListener; +import com.pqt.client.gui.ressources.specifics.products.listeners.SimpleStockComponentFirerer; +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.client.gui.ressources.strings.IObjectStringRenderer; import com.pqt.core.entities.product.Product; import javafx.application.Platform; import javafx.collections.FXCollections; @@ -18,7 +18,7 @@ import java.util.Collection; import java.util.List; import java.util.stream.Collectors; -public class CategoryTabStockDisplayer implements IFXDisplayerComponent, IStockComponentListener>{ +public class CategoryTabStockDisplayer implements IFXDisplayerComponent, IStockComponentListener> { private SimpleStockComponentFirerer firerer; private BorderPane mainPane; diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/CommandComposerSaleDisplayer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CommandComposerSaleDisplayer.java similarity index 85% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/CommandComposerSaleDisplayer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CommandComposerSaleDisplayer.java index 190aa7ac..300de5a1 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/CommandComposerSaleDisplayer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CommandComposerSaleDisplayer.java @@ -1,9 +1,9 @@ -package com.pqt.client.module.gui.ressources.components; +package com.pqt.client.gui.ressources.components; -import com.pqt.client.module.gui.ressources.specifics.sale.IFXSaleDisplayerComponent; -import com.pqt.client.module.gui.ressources.specifics.sale.listeners.ISaleComponentListener; -import com.pqt.client.module.gui.ressources.specifics.sale.listeners.SimpleSaleComponentFirerer; -import com.pqt.client.module.gui.ressources.strings.GUIStringTool; +import com.pqt.client.gui.ressources.specifics.sale.IFXSaleDisplayerComponent; +import com.pqt.client.gui.ressources.specifics.sale.listeners.ISaleComponentListener; +import com.pqt.client.gui.ressources.specifics.sale.listeners.SimpleSaleComponentFirerer; +import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.core.entities.product.Product; import com.pqt.core.entities.sale.Sale; import javafx.application.Platform; @@ -14,7 +14,6 @@ import javafx.scene.layout.BorderPane; import javafx.scene.layout.Pane; import java.util.ArrayList; -import java.util.stream.Collectors; public class CommandComposerSaleDisplayer implements IFXSaleDisplayerComponent { diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/SimpleValidator.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/SimpleValidator.java similarity index 82% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/SimpleValidator.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/SimpleValidator.java index 1f6a9e35..aeb426b7 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/components/SimpleValidator.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/SimpleValidator.java @@ -1,16 +1,16 @@ -package com.pqt.client.module.gui.ressources.components; +package com.pqt.client.gui.ressources.components; -import com.pqt.client.module.gui.ressources.generics.validators.IFXValidatorComponent; -import com.pqt.client.module.gui.ressources.generics.validators.listeners.IValidatorComponentFirerer; -import com.pqt.client.module.gui.ressources.generics.validators.listeners.IValidatorComponentListener; -import com.pqt.client.module.gui.ressources.generics.validators.listeners.SimpleValidatorComponentFirerer; -import com.pqt.client.module.gui.ressources.strings.GUIStringTool; +import com.pqt.client.gui.ressources.generics.validators.IFXValidatorComponent; +import com.pqt.client.gui.ressources.generics.validators.listeners.IValidatorComponentFirerer; +import com.pqt.client.gui.ressources.generics.validators.listeners.IValidatorComponentListener; +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.client.gui.ressources.generics.validators.listeners.SimpleValidatorComponentFirerer; import javafx.application.Platform; import javafx.scene.control.Button; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; -public class SimpleValidator implements IFXValidatorComponent{ +public class SimpleValidator implements IFXValidatorComponent { private final IValidatorComponentFirerer firerer; private Pane pane; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/sale_validation_screen/SaleValidationScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/sale_validation_screen/SaleValidationScreen.java new file mode 100644 index 00000000..8398ac61 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/sale_validation_screen/SaleValidationScreen.java @@ -0,0 +1,85 @@ +package com.pqt.client.gui.ressources.components.sale_validation_screen; + +import com.pqt.client.gui.ressources.components.sale_validation_screen.listeners.ISaleValidationScreenListener; +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.core.entities.sale.Sale; +import com.pqt.core.entities.sale.SaleStatus; +import javafx.application.Platform; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.ProgressIndicator; +import javafx.scene.control.TextField; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Pane; + +import javax.swing.event.EventListenerList; +import java.util.Arrays; + +public class SaleValidationScreen { + + private Pane mainPane; + + private TextField saleStatusTextField; + private SaleStatus saleStatus; + private ProgressIndicator progressIndicator; + private Button validationButton; + + private EventListenerList listeners; + + public SaleValidationScreen(long saleId, Sale sale) { + listeners = new EventListenerList(); + mainPane = new Pane(); + + BorderPane mainPaneContent = new BorderPane(); + + GridPane centerPane = new GridPane(); + + Label saleIdLabel = new Label(GUIStringTool.getSaleIdLabel()); + centerPane.add(saleIdLabel, 0, 0); + + TextField saleIdTextField = new TextField(Long.toString(saleId)); + saleIdTextField.setEditable(false); + centerPane.add(saleIdTextField, 1, 0); + + Label saleStatusLabel = new Label(GUIStringTool.getSaleStatusLabel()); + centerPane.add(saleStatusLabel, 0, 1); + + saleStatusTextField = new TextField(GUIStringTool.getSaleStatusRenderer().render(SaleStatus.PENDING)); + saleStatusTextField.setEditable(false); + centerPane.add(saleStatusTextField, 1, 1); + + mainPaneContent.setCenter(centerPane); + + progressIndicator = new ProgressIndicator(); + progressIndicator.setPrefSize(50, 50); + mainPaneContent.setLeft(progressIndicator); + + validationButton = new Button(GUIStringTool.getOkButtonLabel()); + validationButton.setOnMouseClicked(event->fireScreenClose(saleStatus.equals(SaleStatus.ACCEPTED))); + } + + private void fireScreenClose(boolean saleValidateddSuccessFully) { + if(!validationButton.isDisable()){ + Arrays.stream(listeners.getListeners(ISaleValidationScreenListener.class)) + .forEach(listener->listener.onScreenClose(saleValidateddSuccessFully)); + } + } + + public void addListener(ISaleValidationScreenListener listener){ + listeners.add(ISaleValidationScreenListener.class, listener); + } + + public void setSaleStatus(SaleStatus status){ + saleStatus = status; + Platform.runLater(()->{ + validationButton.setDisable(saleStatus.equals(SaleStatus.PENDING)); + saleStatusTextField.setText(GUIStringTool.getSaleStatusRenderer().render(status)); + progressIndicator.setProgress((status.equals(SaleStatus.PENDING)?ProgressIndicator.INDETERMINATE_PROGRESS:1F)); + }); + } + + public Pane getPane(){ + return mainPane; + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/sale_validation_screen/listeners/ISaleValidationScreenListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/sale_validation_screen/listeners/ISaleValidationScreenListener.java new file mode 100644 index 00000000..8bb1eb7c --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/sale_validation_screen/listeners/ISaleValidationScreenListener.java @@ -0,0 +1,7 @@ +package com.pqt.client.gui.ressources.components.sale_validation_screen.listeners; + +import java.util.EventListener; + +public interface ISaleValidationScreenListener extends EventListener { + void onScreenClose(boolean saleValidatedSuccessfully); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java new file mode 100644 index 00000000..b4c48833 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java @@ -0,0 +1,7 @@ +package com.pqt.client.gui.ressources.css; + +public class GUICssTool { + public static String getGreyIntermediaryPaneCssId(){ + return "grey-pane"; + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/IFXComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/IFXComponent.java similarity index 61% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/IFXComponent.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/IFXComponent.java index 973b1e74..0bee2445 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/IFXComponent.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/IFXComponent.java @@ -1,4 +1,4 @@ -package com.pqt.client.module.gui.ressources.generics; +package com.pqt.client.gui.ressources.generics; import javafx.scene.layout.Pane; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/creators/IFXCreatorComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/creators/IFXCreatorComponent.java new file mode 100644 index 00000000..7a5e06f2 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/creators/IFXCreatorComponent.java @@ -0,0 +1,8 @@ +package com.pqt.client.gui.ressources.generics.creators; + +import com.pqt.client.gui.ressources.generics.IFXComponent; + +public interface IFXCreatorComponent extends IFXComponent{ + T create(); + boolean isCreationPossible(); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/IFXDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/IFXDisplayerComponent.java new file mode 100644 index 00000000..1137609d --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/IFXDisplayerComponent.java @@ -0,0 +1,10 @@ +package com.pqt.client.gui.ressources.generics.displayers; + +import com.pqt.client.gui.ressources.generics.IFXComponent; +import com.pqt.client.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; + +public interface IFXDisplayerComponent extends IFXComponent{ + void display(T content); + void addListener(U l); + void removeListener(U l); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/IDisplayerComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/IDisplayerComponentFirerer.java similarity index 85% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/IDisplayerComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/IDisplayerComponentFirerer.java index 5df54246..f3bd32d7 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/IDisplayerComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/IDisplayerComponentFirerer.java @@ -1,4 +1,4 @@ -package com.pqt.client.module.gui.ressources.generics.displayers.listeners; +package com.pqt.client.gui.ressources.generics.displayers.listeners; import javafx.event.Event; diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/IDisplayerComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/IDisplayerComponentListener.java similarity index 82% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/IDisplayerComponentListener.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/IDisplayerComponentListener.java index 12ce0198..d2da215f 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/IDisplayerComponentListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/IDisplayerComponentListener.java @@ -1,4 +1,4 @@ -package com.pqt.client.module.gui.ressources.generics.displayers.listeners; +package com.pqt.client.gui.ressources.generics.displayers.listeners; import javafx.event.Event; diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java similarity index 96% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java index c2758529..e97916e4 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java @@ -1,4 +1,4 @@ -package com.pqt.client.module.gui.ressources.generics.displayers.listeners; +package com.pqt.client.gui.ressources.generics.displayers.listeners; import javafx.event.Event; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/IFXValidatorComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/IFXValidatorComponent.java new file mode 100644 index 00000000..67d961b4 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/IFXValidatorComponent.java @@ -0,0 +1,9 @@ +package com.pqt.client.gui.ressources.generics.validators; + +import com.pqt.client.gui.ressources.generics.IFXComponent; +import com.pqt.client.gui.ressources.generics.validators.listeners.IValidatorComponentListener; + +public interface IFXValidatorComponent extends IFXComponent{ + void addListener(IValidatorComponentListener l); + void removeListener(IValidatorComponentListener l); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/IValidatorComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/IValidatorComponentFirerer.java similarity index 74% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/IValidatorComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/IValidatorComponentFirerer.java index ab66cdf4..083f6602 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/IValidatorComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/IValidatorComponentFirerer.java @@ -1,4 +1,4 @@ -package com.pqt.client.module.gui.ressources.generics.validators.listeners; +package com.pqt.client.gui.ressources.generics.validators.listeners; public interface IValidatorComponentFirerer { void addListener(IValidatorComponentListener l); diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/IValidatorComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/IValidatorComponentListener.java similarity index 67% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/IValidatorComponentListener.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/IValidatorComponentListener.java index 57f7198f..34c29bbd 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/IValidatorComponentListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/IValidatorComponentListener.java @@ -1,4 +1,4 @@ -package com.pqt.client.module.gui.ressources.generics.validators.listeners; +package com.pqt.client.gui.ressources.generics.validators.listeners; import java.util.EventListener; diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/SimpleValidatorComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/SimpleValidatorComponentFirerer.java similarity index 92% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/SimpleValidatorComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/SimpleValidatorComponentFirerer.java index a06b07e9..ab0c32a1 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/listeners/SimpleValidatorComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/SimpleValidatorComponentFirerer.java @@ -1,4 +1,4 @@ -package com.pqt.client.module.gui.ressources.generics.validators.listeners; +package com.pqt.client.gui.ressources.generics.validators.listeners; import javax.swing.event.EventListenerList; import java.util.Arrays; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java new file mode 100644 index 00000000..29fe49d9 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java @@ -0,0 +1,11 @@ +package com.pqt.client.gui.ressources.specifics.account; + +import com.pqt.client.gui.ressources.generics.displayers.IFXDisplayerComponent; +import com.pqt.client.gui.ressources.specifics.account.listeners.IAccountComponentListener; +import com.pqt.core.entities.user_account.Account; + +import java.util.Collection; + +public interface IFXAccountsDisplayerComponent extends IFXDisplayerComponent, IAccountComponentListener> { + +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/IAccountComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/IAccountComponentListener.java new file mode 100644 index 00000000..12d70b4f --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/IAccountComponentListener.java @@ -0,0 +1,7 @@ +package com.pqt.client.gui.ressources.specifics.account.listeners; + +import com.pqt.client.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; +import com.pqt.core.entities.user_account.Account; + +public interface IAccountComponentListener extends IDisplayerComponentListener{ +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java new file mode 100644 index 00000000..d0e5cfbd --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java @@ -0,0 +1,10 @@ +package com.pqt.client.gui.ressources.specifics.account.listeners; + +import com.pqt.client.gui.ressources.generics.displayers.listeners.SimpleDisplayerComponentFirerer; +import com.pqt.core.entities.user_account.Account; + +public class SimpleAccountComponentFirerer extends SimpleDisplayerComponentFirerer { + public SimpleAccountComponentFirerer() { + super(IAccountComponentListener.class); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java new file mode 100644 index 00000000..d4186480 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java @@ -0,0 +1,10 @@ +package com.pqt.client.gui.ressources.specifics.products; + +import com.pqt.client.gui.ressources.generics.displayers.IFXDisplayerComponent; +import com.pqt.client.gui.ressources.specifics.products.listeners.IStockComponentListener; +import com.pqt.core.entities.product.Product; + +import java.util.Collection; + +public interface IFXProductsDisplayerComponent extends IFXDisplayerComponent, IStockComponentListener> { +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/listeners/IStockComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/listeners/IStockComponentListener.java new file mode 100644 index 00000000..45bf72eb --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/listeners/IStockComponentListener.java @@ -0,0 +1,7 @@ +package com.pqt.client.gui.ressources.specifics.products.listeners; + +import com.pqt.client.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; +import com.pqt.core.entities.product.Product; + +public interface IStockComponentListener extends IDisplayerComponentListener { +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/SimpleStockComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/listeners/SimpleStockComponentFirerer.java similarity index 59% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/SimpleStockComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/listeners/SimpleStockComponentFirerer.java index 0f3b5933..daedf4b0 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/SimpleStockComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/listeners/SimpleStockComponentFirerer.java @@ -1,6 +1,6 @@ -package com.pqt.client.module.gui.ressources.specifics.products.listeners; +package com.pqt.client.gui.ressources.specifics.products.listeners; -import com.pqt.client.module.gui.ressources.generics.displayers.listeners.SimpleDisplayerComponentFirerer; +import com.pqt.client.gui.ressources.generics.displayers.listeners.SimpleDisplayerComponentFirerer; import com.pqt.core.entities.product.Product; public class SimpleStockComponentFirerer extends SimpleDisplayerComponentFirerer { diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java new file mode 100644 index 00000000..e4e8c143 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java @@ -0,0 +1,8 @@ +package com.pqt.client.gui.ressources.specifics.sale; + +import com.pqt.client.gui.ressources.generics.displayers.IFXDisplayerComponent; +import com.pqt.client.gui.ressources.specifics.sale.listeners.ISaleComponentListener; +import com.pqt.core.entities.sale.Sale; + +public interface IFXSaleDisplayerComponent extends IFXDisplayerComponent { +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/listeners/ISaleComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/listeners/ISaleComponentListener.java similarity index 60% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/listeners/ISaleComponentListener.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/listeners/ISaleComponentListener.java index bc1284af..cc3510ec 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/listeners/ISaleComponentListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/listeners/ISaleComponentListener.java @@ -1,6 +1,6 @@ -package com.pqt.client.module.gui.ressources.specifics.sale.listeners; +package com.pqt.client.gui.ressources.specifics.sale.listeners; -import com.pqt.client.module.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; +import com.pqt.client.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; import com.pqt.core.entities.product.Product; import com.pqt.core.entities.sale.Sale; import javafx.event.Event; diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/listeners/SimpleSaleComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/listeners/SimpleSaleComponentFirerer.java similarity index 75% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/listeners/SimpleSaleComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/listeners/SimpleSaleComponentFirerer.java index fa746589..9a669f88 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/listeners/SimpleSaleComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/listeners/SimpleSaleComponentFirerer.java @@ -1,6 +1,6 @@ -package com.pqt.client.module.gui.ressources.specifics.sale.listeners; +package com.pqt.client.gui.ressources.specifics.sale.listeners; -import com.pqt.client.module.gui.ressources.generics.displayers.listeners.SimpleDisplayerComponentFirerer; +import com.pqt.client.gui.ressources.generics.displayers.listeners.SimpleDisplayerComponentFirerer; import com.pqt.core.entities.product.Product; import com.pqt.core.entities.sale.Sale; import javafx.event.Event; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java new file mode 100644 index 00000000..4d33ab11 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java @@ -0,0 +1,153 @@ +package com.pqt.client.gui.ressources.strings; + +import com.pqt.core.entities.product.Product; +import com.pqt.core.entities.sale.SaleStatus; +import com.pqt.core.entities.sale.SaleType; +import com.pqt.core.entities.user_account.Account; +import com.pqt.core.entities.user_account.AccountLevel; +import javafx.util.StringConverter; + +import java.text.NumberFormat; +import java.util.EnumSet; + +//TODO faire ça un peu mieux +public class GUIStringTool { + + private static String saleIdLabel; + + public static String getValidationButtonLabel() { + return "Valider"; + } + + public static String getConfirmationValidationButtonLabel() { + return "Confirmer"; + } + + public static String getCancelButtonLabel() { + return "Annuler"; + } + + public static String getConfirmationCancelButtonLabel() { + return "Confirmer"; + } + + public static String getCategorytabStockDisplayerTitle() { + return "Produits"; + } + + public static IObjectStringRenderer getProductStringRenderer(){ + return product->String.format("%s - %.2f€ (%s)", product.getName(), product.getPrice(), (product.getAmountRemaining()>=30?"30+": Integer.toString(product.getAmountRemaining()))); + } + + public static String getCommandComposerTitleTitle() { + return "Commande"; + } + + public static IObjectWithQuantityStringRenderer getSaleItemStringRenderer(){ + return (product, qte)->String.format("%dx %s", qte, product.getName()); + } + + public static String getPasswordFieldPromptText() { + return "mot de passe"; + } + + public static StringConverter getAccountStringConverter() { + return new StringConverter() { + @Override + public String toString(Account object) { + return String.format("%s - %s)", object.getUsername(), object.getPermissionLevel().name()); + } + + @Override + public Account fromString(String string) { + Account reply = new Account(); + + String[] pieces = string.split(" - "); + reply.setUsername(pieces[0]); + if(pieces.length>1) + for(AccountLevel al : EnumSet.allOf(AccountLevel.class)){ + if(al.name().equals(pieces[1])) + reply.setPermissionLevel(al); + } + + return reply; + } + }; + } + + public static String getLogoutButtonLabel() { + return "Déconnexion"; + } + + public static String getLoginButtonLabel() { + return "Connexion"; + } + + public static IObjectStringRenderer getPriceRenderer() { + return price -> NumberFormat.getCurrencyInstance().format(price); + } + + public static String getSaleMakerTextFieldPromptText() { + return "Auteur"; + } + + public static String getSaleMakerTextFieldLabel() { + return "Fait par : "; + } + + public static String getSaleBeneficiaryTextFieldLabel() { + return "Fait pour : "; + } + + public static String getSaleTypeTextFieldLabel() { + return "Type de paiement : "; + } + + public static String getSalePriceTextFieldLabel() { + return "Prix de la commande : "; + } + + public static StringConverter getSaleTypeStringConverter() { + return new StringConverter() { + @Override + public String toString(SaleType object) { + return object.name(); + } + + @Override + public SaleType fromString(String string) { + return EnumSet.allOf(SaleType.class).stream().filter(type->type.name().equals(string)).findFirst().orElse(null); + } + }; + } + + public static String getSalePriceTextFieldPromptText() { + return getPriceRenderer().render(0d); + } + + public static String getCommandValidationErrorMessage() { + return "La commande n'a pas pu être validée"; + } + + public static String getCommandValidationErrorMessage(Throwable cause) { + return "La commande n'a pas pu être validée : "+cause.getMessage(); + } + + public static String getSaleIdLabel() { + return "Numéro de commande : "; + } + + public static String getSaleStatusLabel() { + return "Etat actuel"; + } + + public static IObjectStringRenderer getSaleStatusRenderer() { + return Enum::name; + } + + public static String getOkButtonLabel() { + return "OK"; + } +} + + diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/IObjectStringRenderer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/IObjectStringRenderer.java similarity index 57% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/IObjectStringRenderer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/IObjectStringRenderer.java index 98709239..ebbb8c6a 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/IObjectStringRenderer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/IObjectStringRenderer.java @@ -1,4 +1,4 @@ -package com.pqt.client.module.gui.ressources.strings; +package com.pqt.client.gui.ressources.strings; public interface IObjectStringRenderer { String render(T obj); diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/IObjectWithQuantityStringRenderer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/IObjectWithQuantityStringRenderer.java similarity index 64% rename from Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/IObjectWithQuantityStringRenderer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/IObjectWithQuantityStringRenderer.java index 8cc2fc9c..52dbbed2 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/IObjectWithQuantityStringRenderer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/IObjectWithQuantityStringRenderer.java @@ -1,4 +1,4 @@ -package com.pqt.client.module.gui.ressources.strings; +package com.pqt.client.gui.ressources.strings; public interface IObjectWithQuantityStringRenderer { String render(T obj, int quantity); diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/creators/IFXCreatorComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/creators/IFXCreatorComponent.java deleted file mode 100644 index 70b1436d..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/creators/IFXCreatorComponent.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.pqt.client.module.gui.ressources.generics.creators; - -import com.pqt.client.module.gui.ressources.generics.IFXComponent; - -public interface IFXCreatorComponent extends IFXComponent{ - T create(); - boolean isCreationPossible(); -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/IFXDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/IFXDisplayerComponent.java deleted file mode 100644 index df7f3e95..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/displayers/IFXDisplayerComponent.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.pqt.client.module.gui.ressources.generics.displayers; - -import com.pqt.client.module.gui.ressources.generics.IFXComponent; -import com.pqt.client.module.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; - -public interface IFXDisplayerComponent extends IFXComponent{ - void display(T content); - void addListener(U l); - void removeListener(U l); -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/IFXValidatorComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/IFXValidatorComponent.java deleted file mode 100644 index 4171c452..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/generics/validators/IFXValidatorComponent.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.pqt.client.module.gui.ressources.generics.validators; - -import com.pqt.client.module.gui.ressources.generics.IFXComponent; -import com.pqt.client.module.gui.ressources.generics.validators.listeners.IValidatorComponentListener; - -public interface IFXValidatorComponent extends IFXComponent{ - void addListener(IValidatorComponentListener l); - void removeListener(IValidatorComponentListener l); -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java deleted file mode 100644 index 60b3a247..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pqt.client.module.gui.ressources.specifics.account; - -import com.pqt.client.module.gui.ressources.specifics.account.listeners.IAccountComponentListener; -import com.pqt.client.module.gui.ressources.generics.displayers.IFXDisplayerComponent; -import com.pqt.core.entities.user_account.Account; - -import java.util.Collection; - -public interface IFXAccountsDisplayerComponent extends IFXDisplayerComponent, IAccountComponentListener>{ - -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/IAccountComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/IAccountComponentListener.java deleted file mode 100644 index 23fbf16c..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/IAccountComponentListener.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.pqt.client.module.gui.ressources.specifics.account.listeners; - -import com.pqt.client.module.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; -import com.pqt.core.entities.user_account.Account; - -public interface IAccountComponentListener extends IDisplayerComponentListener{ -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java deleted file mode 100644 index aa16640f..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.pqt.client.module.gui.ressources.specifics.account.listeners; - -import com.pqt.client.module.gui.ressources.generics.displayers.listeners.SimpleDisplayerComponentFirerer; -import com.pqt.core.entities.user_account.Account; - -public class SimpleAccountComponentFirerer extends SimpleDisplayerComponentFirerer{ - public SimpleAccountComponentFirerer() { - super(IAccountComponentListener.class); - } -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java deleted file mode 100644 index e69a6a85..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.pqt.client.module.gui.ressources.specifics.products; - -import com.pqt.client.module.gui.ressources.specifics.products.listeners.IStockComponentListener; -import com.pqt.client.module.gui.ressources.generics.displayers.IFXDisplayerComponent; -import com.pqt.core.entities.product.Product; - -import java.util.Collection; - -public interface IFXProductsDisplayerComponent extends IFXDisplayerComponent, IStockComponentListener> { -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/IStockComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/IStockComponentListener.java deleted file mode 100644 index 05a8a695..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/products/listeners/IStockComponentListener.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.pqt.client.module.gui.ressources.specifics.products.listeners; - -import com.pqt.client.module.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; -import com.pqt.core.entities.product.Product; - -public interface IStockComponentListener extends IDisplayerComponentListener { -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java deleted file mode 100644 index c394a2d3..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.pqt.client.module.gui.ressources.specifics.sale; - -import com.pqt.client.module.gui.ressources.specifics.sale.listeners.ISaleComponentListener; -import com.pqt.client.module.gui.ressources.generics.displayers.IFXDisplayerComponent; -import com.pqt.core.entities.sale.Sale; - -public interface IFXSaleDisplayerComponent extends IFXDisplayerComponent { -} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/GUIStringTool.java b/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/GUIStringTool.java deleted file mode 100644 index 915ffc6b..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/module/gui/ressources/strings/GUIStringTool.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.pqt.client.module.gui.ressources.strings; - -import com.pqt.core.entities.product.Product; - -//TODO faire ça un peu mieux -public class GUIStringTool { - public static String getValidationButtonLabel() { - return "Valider"; - } - - public static String getConfirmationValidationButtonLabel() { - return "Confirmer"; - } - - public static String getCancelButtonLabel() { - return "Annuler"; - } - - public static String getConfirmationCancelButtonLabel() { - return "Confirmer"; - } - - public static String getCategorytabStockDisplayerTitle() { - return "Produits"; - } - - public static IObjectStringRenderer getProductStringRenderer(){ - return product->String.format("%s - %.2f€ (%s)", product.getName(), product.getPrice(), (product.getAmountRemaining()>=30?"30+": Integer.toString(product.getAmountRemaining()))); - } - - public static String getCommandComposerTitleTitle() { - return "Commande"; - } - - public static IObjectWithQuantityStringRenderer getSaleItemStringRenderer(){ - return (product, qté)->String.format("%s - %.2f€ (%s)", product.getName(), product.getPrice(), (product.getAmountRemaining()>=30?"30+": Integer.toString(product.getAmountRemaining()))); - } -} - - From 543e571e8260a3ae5e1c1262015f3af195f66bac Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sun, 13 Aug 2017 21:57:03 +0200 Subject: [PATCH 05/36] =?UTF-8?q?Module=20Client,=20packg=20"client.gui.mo?= =?UTF-8?q?dules"=20:=20ajout=20classes=20gui=20=C3=A9cran=20composition?= =?UTF-8?q?=20commandes=20(PRE-TEST)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/modules/sale_screen/SaleScreen.java | 27 +++ .../sale_screen/SaleScreenController.java | 169 ++++++++++++++ .../modules/sale_screen/SaleScreenModel.java | 184 +++++++++++++++ .../modules/sale_screen/SaleScreenView.java | 215 ++++++++++++++++++ .../listeners/ISaleScreenModelListener.java | 12 + 5 files changed, 607 insertions(+) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenModel.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/listeners/ISaleScreenModelListener.java diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java new file mode 100644 index 00000000..82a8b8ca --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java @@ -0,0 +1,27 @@ +package com.pqt.client.gui.modules.sale_screen; + +import com.pqt.client.gui.ressources.generics.IFXComponent; +import com.pqt.client.module.account.AccountService; +import com.pqt.client.module.sale.SaleService; +import com.pqt.client.module.stock.StockService; +import javafx.scene.layout.Pane; + +public class SaleScreen implements IFXComponent { + + private SaleScreenModel model; + private SaleScreenController ctrl; + private SaleScreenView view; + + public SaleScreen(AccountService accountService, StockService stockService, SaleService saleService) { + model = new SaleScreenModel(accountService, stockService, saleService); + ctrl = new SaleScreenController(model); + view = new SaleScreenView(ctrl); + + ctrl.setView(view); + } + + @Override + public Pane getPane() { + return view.getPane(); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java new file mode 100644 index 00000000..d907084c --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java @@ -0,0 +1,169 @@ +package com.pqt.client.gui.modules.sale_screen; + +import com.pqt.client.gui.modules.sale_screen.listeners.ISaleScreenModelListener; +import com.pqt.client.gui.ressources.components.sale_validation_screen.listeners.ISaleValidationScreenListener; +import com.pqt.client.gui.ressources.specifics.products.listeners.IStockComponentListener; +import com.pqt.client.gui.ressources.generics.validators.listeners.IValidatorComponentListener; +import com.pqt.client.gui.ressources.specifics.sale.listeners.ISaleComponentListener; +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.core.entities.product.Product; +import com.pqt.core.entities.sale.Sale; +import com.pqt.core.entities.sale.SaleStatus; +import com.pqt.core.entities.sale.SaleType; +import com.pqt.core.entities.user_account.Account; +import com.pqt.core.entities.user_account.AccountLevel; +import javafx.event.Event; +import javafx.scene.control.Alert; + +import java.util.List; + +class SaleScreenController { + + private SaleScreenModel model; + private SaleScreenView view; + + SaleScreenController(SaleScreenModel model) { + this.model = model; + this.model.addListener(new ISaleScreenModelListener() { + @Override + public void onSaleValidatedEvent() { + SaleScreenController.this.onSaleValidationSuccess(); + } + + @Override + public void onSaleNotValidatedEvent(SaleStatus status, Throwable cause) { + SaleScreenController.this.onSaleValidationError(status, cause); + } + + @Override + public void onStockUpdatedEvent() { + view.setProducts(model.getProductList()); + } + + @Override + public void onAccountListUpdatedEvent() { + view.setAccounts(model.getAccountList()); + } + }); + } + + private void onSaleValidationSuccess() { + view.setSaleStatus(SaleStatus.ACCEPTED); + } + + private void onSaleValidationError(SaleStatus status, Throwable cause) { + view.setSaleStatus(status); + } + + void setView(SaleScreenView view) { + this.view = view; + } + + void onAccountSelectedAsBeneficiary(Account account){ + model.setSaleBeneficiary(account); + } + + private Sale getCurrentSale(){ + return model.getCurrentSale(); + } + + void updateView(){ + view.setProducts(fetchProductList()); + view.setSaleTypes(fetchSaleTypeList()); + view.setAccounts(fetchAccountList()); + + view.setSale(getCurrentSale()); + } + + private List fetchProductList(){ + return model.getProductList(); + } + private List fetchAccountList(){ + return model.getAccountList(); + } + private List fetchSaleTypeList(){ + return model.getSaleTypeList(); + } + + ISaleComponentListener getSaleDisplayerListener() { + return new ISaleComponentListener() { + @Override + public void onComponentClickEvent(Event event, Product product) { + model.removeProductFromSale(product); + SaleScreenController.this.updateView(); + } + + @Override + public void onRefreshContentRequestEvent() {} + + @Override + public void onContentClickEvent(Event event, Sale eventTarget) {} + + @Override + public void onAddContentRequestEvent() {} + + @Override + public void onRemoveContentRequestEvent(Sale content) {} + + @Override + public void onDetailContentRequestEvent(Sale content) {} + }; + } + + IStockComponentListener getStockDisplayerListener() { + return new IStockComponentListener() { + @Override + public void onRefreshContentRequestEvent() {} + + @Override + public void onContentClickEvent(Event event, Product eventTarget) { + model.addProductToSale(eventTarget); + SaleScreenController.this.updateView(); + } + + @Override + public void onAddContentRequestEvent() {} + + @Override + public void onRemoveContentRequestEvent(Product content) {} + + @Override + public void onDetailContentRequestEvent(Product content) {} + }; + } + + Account getDefaultAccount() { + return new Account(" - ", null, AccountLevel.getLowest()); + } + + IValidatorComponentListener getValidatorListener() { + return new IValidatorComponentListener() { + @Override + public void onValidationEvent() { + model.commitSale(); + view.switchToSaleValidationWaitingMode(model.getTempSaleId(), model.getCurrentSale()); + } + + @Override + public void onCancelEvent() { + model.clearSale(); + SaleScreenController.this.updateView(); + } + }; + } + + void onSaleTypeSelected(SaleType saleType) { + model.setSaleType(saleType); + } + + ISaleValidationScreenListener getSaleValidationScreenListener() { + return saleValidatedSuccessfully -> { + view.switchToSaleCompositionMode(); + if(saleValidatedSuccessfully){ + model.clearSale(); + } + + updateView(); + }; + } +} 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 new file mode 100644 index 00000000..1bb32666 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenModel.java @@ -0,0 +1,184 @@ +package com.pqt.client.gui.modules.sale_screen; + +import com.pqt.client.gui.modules.sale_screen.listeners.ISaleScreenModelListener; +import com.pqt.client.module.account.AccountService; +import com.pqt.client.module.account.listeners.IAccountListener; +import com.pqt.client.module.sale.SaleBuilder; +import com.pqt.client.module.sale.SaleService; +import com.pqt.client.module.sale.listeners.ISaleListener; +import com.pqt.client.module.stock.Listeners.IStockListener; +import com.pqt.client.module.stock.StockService; +import com.pqt.core.entities.product.Product; +import com.pqt.core.entities.sale.Sale; +import com.pqt.core.entities.sale.SaleStatus; +import com.pqt.core.entities.sale.SaleType; +import com.pqt.core.entities.user_account.Account; + +import javax.swing.event.EventListenerList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +class SaleScreenModel { + + private EventListenerList listeners; + + private AccountService accountService; + private StockService stockService; + private SaleService saleService; + + private SaleBuilder currentSaleBuilder; + private long tempSaleId; + + SaleScreenModel(AccountService accountService, StockService stockService, SaleService saleService) { + this.accountService = accountService; + this.stockService = stockService; + this.saleService = saleService; + + saleService.addListener(new ISaleListener() { + @Override + public void onSaleValidationSuccess(long saleId) { + if(saleId == SaleScreenModel.this.tempSaleId){ + SaleScreenModel.this.fireSaleValidatedEvent(); + } + } + + @Override + public void onSaleValidationError(long saleId, Throwable cause) { + if(saleId == SaleScreenModel.this.tempSaleId){ + SaleScreenModel.this.fireSaleNotValidatedEvent(SaleStatus.ABORTED, cause); + } + } + + @Override + public void onSaleValidationRefused(long saleId, Throwable cause) { + if(saleId == SaleScreenModel.this.tempSaleId){ + SaleScreenModel.this.fireSaleNotValidatedEvent(SaleStatus.REFUSED, cause); + } + } + }); + stockService.addListener(new IStockListener() { + @Override + public void onGetProductListSuccessEvent() { + + } + + @Override + public void onGetProductListErrorEvent(Throwable cause) { + + } + + @Override + public void onGetProductListRefusedEvent(Throwable cause) { + + } + + @Override + public void onProductListUpdateSuccessEvent(long id) { + + } + + @Override + public void onProductListUpdateErrorEvent(long id, Throwable cause) { + + } + + @Override + public void onProductListUpdateRefusedEvent(long id, Throwable cause) { + + } + + @Override + public void onProductListChangedEvent() { + fireStockUpdatedEvent(); + } + }); + accountService.addListener(new IAccountListener() { + @Override + public void onAccountStatusChangedEvent(boolean status) { + + } + + @Override + public void onAccountListChangedEvent() { + fireAccountListUpdatedEvent(); + } + }); + } + + private void fireSaleValidatedEvent() { + Arrays.stream(listeners.getListeners(ISaleScreenModelListener.class)) + .forEach(ISaleScreenModelListener::onSaleValidatedEvent); + } + + private void fireSaleNotValidatedEvent(SaleStatus status, Throwable cause) { + Arrays.stream(listeners.getListeners(ISaleScreenModelListener.class)) + .forEach(l->l.onSaleNotValidatedEvent(status, cause)); + } + + private void fireStockUpdatedEvent(){ + Arrays.stream(listeners.getListeners(ISaleScreenModelListener.class)) + .forEach(ISaleScreenModelListener::onStockUpdatedEvent); + } + + private void fireAccountListUpdatedEvent(){ + Arrays.stream(listeners.getListeners(ISaleScreenModelListener.class)) + .forEach(ISaleScreenModelListener::onAccountListUpdatedEvent); + } + + List getAccountList() { + return accountService.getAllAccounts(); + } + + List getSaleTypeList() { + return saleService.getSaleTypes(); + } + + Sale getCurrentSale() { + return currentSaleBuilder.build(); + } + + List getProductList() { + return stockService.getProducts().stream().filter(Product::isSellable).collect(Collectors.toList()); + } + + void clearSale() { + currentSaleBuilder = saleService.getNewSaleBuilder(); + currentSaleBuilder.orderedBy(accountService.getCurrentAccount()); + currentSaleBuilder.saleType(SaleType.CASH); + + tempSaleId = -1; + } + + void commitSale() { + tempSaleId = saleService.commitSale(currentSaleBuilder); + } + + long getTempSaleId(){ + return tempSaleId; + } + + void addProductToSale(Product product) { + currentSaleBuilder.addProduct(product); + } + + void removeProductFromSale(Product product) { + currentSaleBuilder.removeProduct(product); + } + + void setSaleType(SaleType saleType) { + currentSaleBuilder.saleType(saleType); + } + + void setSaleBeneficiary(Account saleBeneficiary) { + currentSaleBuilder.orderedFor(saleBeneficiary); + } + + void addListener(ISaleScreenModelListener listener){ + listeners.add(ISaleScreenModelListener.class, listener); + } + + void removeListener(ISaleScreenModelListener listener){ + listeners.remove(ISaleScreenModelListener.class, listener); + } +} \ No newline at end of file diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java new file mode 100644 index 00000000..e35cb17f --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java @@ -0,0 +1,215 @@ +package com.pqt.client.gui.modules.sale_screen; + +import com.pqt.client.gui.ressources.components.sale_validation_screen.SaleValidationScreen; +import com.pqt.client.gui.ressources.components.CommandComposerSaleDisplayer; +import com.pqt.client.gui.ressources.components.SimpleValidator; +import com.pqt.client.gui.ressources.css.GUICssTool; +import com.pqt.client.gui.ressources.generics.IFXComponent; +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.client.gui.ressources.components.CategoryTabStockDisplayer; +import com.pqt.core.entities.product.Product; +import com.pqt.core.entities.sale.Sale; +import com.pqt.core.entities.sale.SaleStatus; +import com.pqt.core.entities.sale.SaleType; +import com.pqt.core.entities.user_account.Account; +import javafx.application.Platform; + +import javafx.scene.Node; +import javafx.scene.control.*; +import javafx.scene.layout.*; + +import java.util.List; +import java.util.stream.Collectors; + +class SaleScreenView implements IFXComponent { + + private SaleScreenController ctrl; + + private SaleValidationScreen saleValidationScreen; + private StackPane mainPane; + private BorderPane mainPaneContent; + + private CategoryTabStockDisplayer stockDisplayer; + private CommandComposerSaleDisplayer saleDisplayer; + private TextField saleMakerAccountDisplayer; + private ChoiceBox saleBeneficiaryAccountDisplayer; + private ChoiceBox saleTypeDisplayer; + private TextField salePriceDisplayer; + + SaleScreenView(SaleScreenController ctrl) { + this.ctrl = ctrl; + initGui(); + } + + private void initGui() { + mainPane = new StackPane(); + + mainPaneContent = new BorderPane(); + + /* + -----------------------CENTER PANE----------------------- + */ + { + mainPane.getChildren().add(mainPaneContent); + mainPaneContent.prefWidthProperty().bind(mainPane.widthProperty()); + mainPaneContent.prefHeightProperty().bind(mainPane.heightProperty()); + + stockDisplayer = new CategoryTabStockDisplayer(); + stockDisplayer.addListener(ctrl.getStockDisplayerListener()); + + saleDisplayer = new CommandComposerSaleDisplayer(); + saleDisplayer.addListener(ctrl.getSaleDisplayerListener()); + + HBox mainContentCenterPane = new HBox(); + mainContentCenterPane.getChildren().addAll(stockDisplayer.getPane(), saleDisplayer.getPane()); + mainContentCenterPane.setFillHeight(true); + stockDisplayer.getPane().prefWidthProperty().bind(mainContentCenterPane.widthProperty().divide(2)); + saleDisplayer.getPane().prefWidthProperty().bind(mainContentCenterPane.widthProperty().divide(2)); + + mainPaneContent.setCenter(mainContentCenterPane); + } + /* + -----------------------BOTTOM PANE----------------------- + */ + { + AnchorPane mainContentBottomPane = new AnchorPane(); + // Sale secondary data configuration (author, beneficiary, payment type, etc... + { + saleMakerAccountDisplayer = new TextField(); + saleMakerAccountDisplayer.setEditable(false); + saleMakerAccountDisplayer.setPromptText(GUIStringTool.getSaleMakerTextFieldPromptText()); + + saleBeneficiaryAccountDisplayer = new ChoiceBox<>(); + saleBeneficiaryAccountDisplayer.setConverter(GUIStringTool.getAccountStringConverter()); + saleBeneficiaryAccountDisplayer.getSelectionModel() + .selectedItemProperty() + .addListener((observable, oldElem, newElem) -> ctrl.onAccountSelectedAsBeneficiary(newElem)); + + saleTypeDisplayer = new ChoiceBox<>(); + saleTypeDisplayer.setConverter(GUIStringTool.getSaleTypeStringConverter()); + saleTypeDisplayer.getSelectionModel() + .selectedItemProperty() + .addListener((observable, oldElem, newElem) -> ctrl.onSaleTypeSelected(newElem)); + + salePriceDisplayer = new TextField(); + salePriceDisplayer.setEditable(false); + salePriceDisplayer.setPromptText(GUIStringTool.getSalePriceTextFieldPromptText()); + + + GridPane mainContentBottomLeftPane = new GridPane(); + mainContentBottomLeftPane.add(new Label(GUIStringTool.getSaleMakerTextFieldLabel()), 0, 0); + mainContentBottomLeftPane.add(saleMakerAccountDisplayer, 1, 0); + mainContentBottomLeftPane.add(new Label(GUIStringTool.getSaleBeneficiaryTextFieldLabel()), 0, 1); + mainContentBottomLeftPane.add(saleBeneficiaryAccountDisplayer, 1, 1); + mainContentBottomLeftPane.add(new Label(GUIStringTool.getSaleTypeTextFieldLabel()), 0, 2); + mainContentBottomLeftPane.add(saleTypeDisplayer, 1, 2); + mainContentBottomLeftPane.add(new Label(GUIStringTool.getSalePriceTextFieldLabel()), 0, 3); + mainContentBottomLeftPane.add(salePriceDisplayer, 1, 3); + + mainContentBottomPane.getChildren().add(mainContentBottomLeftPane); + AnchorPane.setBottomAnchor(mainContentBottomLeftPane, 0d); + AnchorPane.setTopAnchor(mainContentBottomLeftPane, 0d); + AnchorPane.setLeftAnchor(mainContentBottomLeftPane, 0d); + } + //Sale Validator + { + SimpleValidator validator = new SimpleValidator(true); + validator.addListener(ctrl.getValidatorListener()); + + mainContentBottomPane.getChildren().add(validator.getPane()); + AnchorPane.setBottomAnchor(validator.getPane(), 0d); + AnchorPane.setTopAnchor(validator.getPane(), 0d); + AnchorPane.setRightAnchor(validator.getPane(), 0d); + } + mainPaneContent.setBottom(mainContentBottomPane); + } + /* + ------------------------MAIN PANE------------------------ + */ + mainPane.getChildren().add(mainPaneContent); + + /* + -------------------------UPDATE-------------------------- + */ + ctrl.updateView(); + } + + @Override + public Pane getPane() { + return mainPane; + } + + void switchToSaleValidationWaitingMode(long saleId, Sale sale){ + boolean clearChildren = mainPane.getChildren().size()>1; + + Pane greyIntermediaryPane = new Pane(); + greyIntermediaryPane.setId(GUICssTool.getGreyIntermediaryPaneCssId()); + + saleValidationScreen = new SaleValidationScreen(saleId, sale); + saleValidationScreen.addListener(ctrl.getSaleValidationScreenListener()); + Platform.runLater(()->{ + if(clearChildren){ + mainPane.getChildren().clear(); + mainPane.getChildren().add(mainPaneContent); + } + + mainPane.getChildren().addAll(greyIntermediaryPane, saleValidationScreen.getPane()); + }); + } + + void switchToSaleCompositionMode(){ + Node[] childrenToRemove = mainPane.getChildren() + .stream() + .filter(child->!child.equals(mainPaneContent)) + .collect(Collectors.toList()) + .toArray(new Node[]{}); + Platform.runLater(()->mainPane.getChildren().removeAll(childrenToRemove)); + } + + void setProducts(List products) { + stockDisplayer.display(products); + } + + void setSaleTypes(List saleTypes) { + Platform.runLater(()->{ + saleTypeDisplayer.getItems().clear(); + saleTypeDisplayer.getItems().addAll(saleTypes); + }); + } + + void setAccounts(List accounts) { + Platform.runLater(()->{ + saleBeneficiaryAccountDisplayer.getItems().clear(); + saleBeneficiaryAccountDisplayer.getItems().add(ctrl.getDefaultAccount()); + saleBeneficiaryAccountDisplayer.getItems().addAll(accounts); + }); + } + + void setSale(Sale sale) { + saleDisplayer.display(sale); + + String price = GUIStringTool.getPriceRenderer().render(sale.getTotalPrice()); + String currentAccount = GUIStringTool.getAccountStringConverter().toString(sale.getOrderedBy()); + + Platform.runLater(()->{ + salePriceDisplayer.setText(price); + saleMakerAccountDisplayer.setText(currentAccount); + + selectElement(saleTypeDisplayer, sale.getType()); + selectElement(saleBeneficiaryAccountDisplayer, sale.getOrderedFor()); + }); + } + + private void selectElement(ChoiceBox choiceBox, T element){ + if(element!=null){ + if(!choiceBox.getItems().contains(element)) + choiceBox.getItems().add(element); + choiceBox.getSelectionModel().select(element); + }else + choiceBox.getSelectionModel().clearSelection(); + } + + void setSaleStatus(SaleStatus status){ + this.saleValidationScreen.setSaleStatus(status); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/listeners/ISaleScreenModelListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/listeners/ISaleScreenModelListener.java new file mode 100644 index 00000000..bfec4762 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/listeners/ISaleScreenModelListener.java @@ -0,0 +1,12 @@ +package com.pqt.client.gui.modules.sale_screen.listeners; + +import com.pqt.core.entities.sale.SaleStatus; + +import java.util.EventListener; + +public interface ISaleScreenModelListener extends EventListener { + void onSaleValidatedEvent(); + void onSaleNotValidatedEvent(SaleStatus status, Throwable cause); + void onStockUpdatedEvent(); + void onAccountListUpdatedEvent(); +} From 0eef751c417818c8846381e52440fa3d9b2101b4 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sun, 13 Aug 2017 21:57:39 +0200 Subject: [PATCH 06/36] =?UTF-8?q?Modules=20Client=20et=20Core=20:=20modifi?= =?UTF-8?q?cations=20diverses=20classes=20suite=20ajout=20clss=20gui=20(vo?= =?UTF-8?q?ir=20pr=C3=A9c=C3=A9dent=20commit)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/pqt/client/module/account/AccountService.java | 3 +++ .../module/account/listeners/AccountListenerAdapter.java | 4 ++-- .../client/module/account/listeners/IAccountListener.java | 4 ++-- .../main/java/com/pqt/client/module/sale/SaleService.java | 7 +++++++ .../java/com/pqt/core/entities/user_account/Account.java | 7 +++---- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/module/account/AccountService.java b/Workspace/client/src/main/java/com/pqt/client/module/account/AccountService.java index c3affffa..fd36f41e 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/account/AccountService.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/account/AccountService.java @@ -42,4 +42,7 @@ public class AccountService { } + public List getAllAccounts() { + return null; + } } diff --git a/Workspace/client/src/main/java/com/pqt/client/module/account/listeners/AccountListenerAdapter.java b/Workspace/client/src/main/java/com/pqt/client/module/account/listeners/AccountListenerAdapter.java index 50243c75..421c1f6d 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/account/listeners/AccountListenerAdapter.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/account/listeners/AccountListenerAdapter.java @@ -6,9 +6,9 @@ public class AccountListenerAdapter implements IAccountListener { /** - * @see com.pqt.client.module.account.listeners.IAccountListener#onAccountStatusChanged(boolean) + * @see com.pqt.client.module.account.listeners.IAccountListener#onAccountStatusChangedEvent(boolean) */ - public void onAccountStatusChanged(boolean status) { + public void onAccountStatusChangedEvent(boolean status) { } diff --git a/Workspace/client/src/main/java/com/pqt/client/module/account/listeners/IAccountListener.java b/Workspace/client/src/main/java/com/pqt/client/module/account/listeners/IAccountListener.java index 7fa6dfef..0de33085 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/account/listeners/IAccountListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/account/listeners/IAccountListener.java @@ -4,6 +4,6 @@ import java.util.EventListener; public interface IAccountListener extends EventListener { - public void onAccountStatusChanged(boolean status); - + void onAccountStatusChangedEvent(boolean status); + void onAccountListChangedEvent(); } diff --git a/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleService.java b/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleService.java index cdaf60b9..081df440 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleService.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleService.java @@ -6,6 +6,9 @@ import com.pqt.client.module.query.query_callback.IIdQueryCallback; import com.pqt.client.module.sale.listeners.ISaleFirerer; import com.pqt.client.module.sale.listeners.ISaleListener; import com.pqt.client.module.sale.listeners.SimpleSaleFirerer; +import com.pqt.core.entities.sale.SaleType; + +import java.util.List; //TODO écrire javadoc //TODO add log lines @@ -55,4 +58,8 @@ public class SaleService { eventFirerer.removeListener(listener); } + public List getSaleTypes() { + //TODO + return null; + } } diff --git a/Workspace/core/src/main/java/com/pqt/core/entities/user_account/Account.java b/Workspace/core/src/main/java/com/pqt/core/entities/user_account/Account.java index be090371..a37517d1 100644 --- a/Workspace/core/src/main/java/com/pqt/core/entities/user_account/Account.java +++ b/Workspace/core/src/main/java/com/pqt/core/entities/user_account/Account.java @@ -49,7 +49,7 @@ public class Account implements ILoggable, Serializable { @Override public int hashCode() { - return Objects.hash(id, username, passwordHash, permissionLevel); + return Objects.hash(username, password, permissionLevel); } @Override @@ -61,9 +61,8 @@ public class Account implements ILoggable, Serializable { return false; Account acc = Account.class.cast(obj); - return this.id == acc.id - && Objects.equals(this.username, acc.username) - && Objects.equals(this.passwordHash, acc.passwordHash) + return Objects.equals(this.username, acc.username) + && Objects.equals(this.password, acc.password) && Objects.equals(this.permissionLevel, acc.permissionLevel); } } From d1fdc64cadbc8db7b1e305e49f00190bb8d71b89 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Mon, 14 Aug 2017 16:38:03 +0200 Subject: [PATCH 07/36] =?UTF-8?q?Module=20Client=20:=20test=20de=20l'?= =?UTF-8?q?=C3=A9cran=20de=20composition=20des=20ventes;=20correction=20bu?= =?UTF-8?q?gs;=20ajout=20fichier=20css;=20r=C3=A9organisation=20packages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/pqt/client/Main.java | 32 +++ .../gui/modules/sale_screen/SaleScreen.java | 9 +- .../sale_screen/SaleScreenController.java | 16 +- .../modules/sale_screen/SaleScreenModel.java | 44 +++- .../modules/sale_screen/SaleScreenView.java | 87 ++++---- .../SaleValidationScreen.java | 28 ++- .../ISaleValidationScreenListener.java | 2 +- .../ressources/components/AccountManager.java | 14 +- .../components/CategoryTabStockDisplayer.java | 19 +- .../CommandComposerSaleDisplayer.java | 18 +- .../components/SimpleValidator.java | 27 ++- .../generics/IFXComponent.java | 2 +- .../creators/IFXCreatorComponent.java | 8 + .../displayers/IFXDisplayerComponent.java | 10 + .../listeners/IDisplayerComponentFirerer.java | 2 +- .../IDisplayerComponentListener.java | 2 +- .../SimpleDisplayerComponentFirerer.java | 2 +- .../javafx_override/CssEnabledGridPane.java | 11 + .../validators/IFXValidatorComponent.java | 9 + .../listeners/IValidatorComponentFirerer.java | 2 +- .../IValidatorComponentListener.java | 2 +- .../SimpleValidatorComponentFirerer.java | 2 +- .../IFXAccountsDisplayerComponent.java | 11 + .../listeners/IAccountComponentListener.java | 7 + .../SimpleAccountComponentFirerer.java | 4 +- .../IFXProductsDisplayerComponent.java | 10 + .../listeners/IStockComponentListener.java | 7 + .../SimpleStockComponentFirerer.java | 4 +- .../sale/IFXSaleDisplayerComponent.java | 8 + .../listeners/ISaleComponentListener.java | 4 +- .../listeners/SimpleSaleComponentFirerer.java | 4 +- .../client/gui/ressources/css/GUICssTool.java | 4 +- .../creators/IFXCreatorComponent.java | 8 - .../displayers/IFXDisplayerComponent.java | 10 - .../validators/IFXValidatorComponent.java | 9 - .../IFXAccountsDisplayerComponent.java | 11 - .../listeners/IAccountComponentListener.java | 7 - .../IFXProductsDisplayerComponent.java | 10 - .../listeners/IStockComponentListener.java | 7 - .../sale/IFXSaleDisplayerComponent.java | 8 - .../gui/ressources/strings/GUIStringTool.java | 5 +- .../listeners/AccountListenerAdapter.java | 7 + .../module/sale/listeners/ISaleListener.java | 8 +- .../pqt/client/module/stock/StockService.java | 2 +- .../client/src/main/resources/dark-theme.css | 209 ++++++++++++++++++ .../com/pqt/core/entities/members/Client.java | 15 -- 46 files changed, 522 insertions(+), 205 deletions(-) create mode 100644 Workspace/client/src/main/java/com/pqt/client/Main.java rename Workspace/client/src/main/java/com/pqt/client/gui/{ressources/components => modules/sale_screen}/sale_validation_screen/SaleValidationScreen.java (75%) rename Workspace/client/src/main/java/com/pqt/client/gui/{ressources/components => modules/sale_screen}/sale_validation_screen/listeners/ISaleValidationScreenListener.java (66%) rename Workspace/client/src/main/java/com/pqt/client/gui/ressources/{ => components}/generics/IFXComponent.java (60%) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/creators/IFXCreatorComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/displayers/IFXDisplayerComponent.java rename Workspace/client/src/main/java/com/pqt/client/gui/ressources/{ => components}/generics/displayers/listeners/IDisplayerComponentFirerer.java (84%) rename Workspace/client/src/main/java/com/pqt/client/gui/ressources/{ => components}/generics/displayers/listeners/IDisplayerComponentListener.java (82%) rename Workspace/client/src/main/java/com/pqt/client/gui/ressources/{ => components}/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java (96%) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/CssEnabledGridPane.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/validators/IFXValidatorComponent.java rename Workspace/client/src/main/java/com/pqt/client/gui/ressources/{ => components}/generics/validators/listeners/IValidatorComponentFirerer.java (73%) rename Workspace/client/src/main/java/com/pqt/client/gui/ressources/{ => components}/generics/validators/listeners/IValidatorComponentListener.java (66%) rename Workspace/client/src/main/java/com/pqt/client/gui/ressources/{ => components}/generics/validators/listeners/SimpleValidatorComponentFirerer.java (92%) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/account/IFXAccountsDisplayerComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/account/listeners/IAccountComponentListener.java rename Workspace/client/src/main/java/com/pqt/client/gui/ressources/{ => components}/specifics/account/listeners/SimpleAccountComponentFirerer.java (59%) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/products/IFXProductsDisplayerComponent.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/products/listeners/IStockComponentListener.java rename Workspace/client/src/main/java/com/pqt/client/gui/ressources/{ => components}/specifics/products/listeners/SimpleStockComponentFirerer.java (58%) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/sale/IFXSaleDisplayerComponent.java rename Workspace/client/src/main/java/com/pqt/client/gui/ressources/{ => components}/specifics/sale/listeners/ISaleComponentListener.java (59%) rename Workspace/client/src/main/java/com/pqt/client/gui/ressources/{ => components}/specifics/sale/listeners/SimpleSaleComponentFirerer.java (75%) delete mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/creators/IFXCreatorComponent.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/IFXDisplayerComponent.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/IFXValidatorComponent.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/IAccountComponentListener.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/listeners/IStockComponentListener.java delete mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java create mode 100644 Workspace/client/src/main/resources/dark-theme.css diff --git a/Workspace/client/src/main/java/com/pqt/client/Main.java b/Workspace/client/src/main/java/com/pqt/client/Main.java new file mode 100644 index 00000000..4eed78eb --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/Main.java @@ -0,0 +1,32 @@ +package com.pqt.client; + +import com.pqt.client.gui.modules.sale_screen.SaleScreen; +import com.pqt.client.gui.ressources.css.GUICssTool; +import com.pqt.client.module.account.AccountService; +import com.pqt.client.module.sale.SaleService; +import com.pqt.client.module.stock.StockService; +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.stage.Stage; + +public class Main extends Application{ + + public static void main(String[] args){ + launch(args); + } + + @Override + public void start(Stage primaryStage) throws Exception { + SaleService saleService = new SaleService(); + StockService stockService = new StockService(); + AccountService accountService = new AccountService(); + + SaleScreen saleScreen = new SaleScreen(accountService, stockService, saleService); + Scene scene = new Scene(saleScreen.getPane(), 800, 600); + scene.getStylesheets().clear(); + scene.getStylesheets().addAll(getClass().getResource(GUICssTool.getCssFilePath()).toExternalForm()); + + primaryStage.setScene(scene); + primaryStage.show(); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java index 82a8b8ca..ad94fafd 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java @@ -1,6 +1,6 @@ package com.pqt.client.gui.modules.sale_screen; -import com.pqt.client.gui.ressources.generics.IFXComponent; +import com.pqt.client.gui.ressources.components.generics.IFXComponent; import com.pqt.client.module.account.AccountService; import com.pqt.client.module.sale.SaleService; import com.pqt.client.module.stock.StockService; @@ -8,16 +8,15 @@ import javafx.scene.layout.Pane; public class SaleScreen implements IFXComponent { - private SaleScreenModel model; - private SaleScreenController ctrl; private SaleScreenView view; public SaleScreen(AccountService accountService, StockService stockService, SaleService saleService) { - model = new SaleScreenModel(accountService, stockService, saleService); - ctrl = new SaleScreenController(model); + SaleScreenModel model = new SaleScreenModel(accountService, stockService, saleService); + SaleScreenController ctrl = new SaleScreenController(model); view = new SaleScreenView(ctrl); ctrl.setView(view); + ctrl.updateView(); } @Override diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java index d907084c..a3f93988 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java @@ -1,11 +1,10 @@ package com.pqt.client.gui.modules.sale_screen; import com.pqt.client.gui.modules.sale_screen.listeners.ISaleScreenModelListener; -import com.pqt.client.gui.ressources.components.sale_validation_screen.listeners.ISaleValidationScreenListener; -import com.pqt.client.gui.ressources.specifics.products.listeners.IStockComponentListener; -import com.pqt.client.gui.ressources.generics.validators.listeners.IValidatorComponentListener; -import com.pqt.client.gui.ressources.specifics.sale.listeners.ISaleComponentListener; -import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.client.gui.modules.sale_screen.sale_validation_screen.listeners.ISaleValidationScreenListener; +import com.pqt.client.gui.ressources.components.specifics.products.listeners.IStockComponentListener; +import com.pqt.client.gui.ressources.components.generics.validators.listeners.IValidatorComponentListener; +import com.pqt.client.gui.ressources.components.specifics.sale.listeners.ISaleComponentListener; import com.pqt.core.entities.product.Product; import com.pqt.core.entities.sale.Sale; import com.pqt.core.entities.sale.SaleStatus; @@ -13,7 +12,6 @@ import com.pqt.core.entities.sale.SaleType; import com.pqt.core.entities.user_account.Account; import com.pqt.core.entities.user_account.AccountLevel; import javafx.event.Event; -import javafx.scene.control.Alert; import java.util.List; @@ -73,6 +71,8 @@ class SaleScreenController { view.setAccounts(fetchAccountList()); view.setSale(getCurrentSale()); + + view.setValidationButtonEnabled(model.checkValidity(getCurrentSale())); } private List fetchProductList(){ @@ -140,8 +140,8 @@ class SaleScreenController { return new IValidatorComponentListener() { @Override public void onValidationEvent() { - model.commitSale(); - view.switchToSaleValidationWaitingMode(model.getTempSaleId(), model.getCurrentSale()); + if(model.commitSale()) + view.switchToSaleValidationWaitingMode(model.getTempSaleId(), model.getCurrentSale()); } @Override 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 1bb32666..94d59bf2 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 @@ -31,6 +31,10 @@ class SaleScreenModel { private long tempSaleId; SaleScreenModel(AccountService accountService, StockService stockService, SaleService saleService) { + if(accountService==null || stockService==null || saleService==null) + throw new NullPointerException("At least one of the following services is null : account, stock, sale"); + + listeners = new EventListenerList(); this.accountService = accountService; this.stockService = stockService; this.saleService = saleService; @@ -104,6 +108,8 @@ class SaleScreenModel { fireAccountListUpdatedEvent(); } }); + + clearSale(); } private void fireSaleValidatedEvent() { @@ -135,7 +141,7 @@ class SaleScreenModel { } Sale getCurrentSale() { - return currentSaleBuilder.build(); + return currentSaleBuilder!=null?currentSaleBuilder.build():null; } List getProductList() { @@ -143,15 +149,29 @@ class SaleScreenModel { } void clearSale() { - currentSaleBuilder = saleService.getNewSaleBuilder(); - currentSaleBuilder.orderedBy(accountService.getCurrentAccount()); - currentSaleBuilder.saleType(SaleType.CASH); - + currentSaleBuilder = getNewSaleBuilder(); tempSaleId = -1; } - void commitSale() { + private SaleBuilder getNewSaleBuilder(){ + SaleBuilder saleBuilder = saleService.getNewSaleBuilder(); + saleBuilder.orderedBy(accountService.getCurrentAccount()); + saleBuilder.saleType(SaleType.CASH); + return saleBuilder; + } + + boolean commitSale() { + if(!checkValidity(currentSaleBuilder.build())) + return false; + tempSaleId = saleService.commitSale(currentSaleBuilder); + return tempSaleId!=-1; + } + + boolean checkValidity(Sale sale) { + return sale.getProducts().size()>0 + && sale.getOrderedBy()!=null + && sale.getType()!=null; } long getTempSaleId(){ @@ -159,19 +179,23 @@ class SaleScreenModel { } void addProductToSale(Product product) { - currentSaleBuilder.addProduct(product); + if(currentSaleBuilder!=null) + currentSaleBuilder.addProduct(product); } void removeProductFromSale(Product product) { - currentSaleBuilder.removeProduct(product); + if(currentSaleBuilder!=null) + currentSaleBuilder.removeProduct(product); } void setSaleType(SaleType saleType) { - currentSaleBuilder.saleType(saleType); + if(currentSaleBuilder!=null) + currentSaleBuilder.saleType(saleType); } void setSaleBeneficiary(Account saleBeneficiary) { - currentSaleBuilder.orderedFor(saleBeneficiary); + if(currentSaleBuilder!=null) + currentSaleBuilder.orderedFor(saleBeneficiary); } void addListener(ISaleScreenModelListener listener){ diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java index e35cb17f..ade15612 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java @@ -1,10 +1,11 @@ package com.pqt.client.gui.modules.sale_screen; -import com.pqt.client.gui.ressources.components.sale_validation_screen.SaleValidationScreen; +import com.pqt.client.gui.modules.sale_screen.sale_validation_screen.SaleValidationScreen; import com.pqt.client.gui.ressources.components.CommandComposerSaleDisplayer; import com.pqt.client.gui.ressources.components.SimpleValidator; +import com.pqt.client.gui.ressources.components.generics.javafx_override.CssEnabledGridPane; import com.pqt.client.gui.ressources.css.GUICssTool; -import com.pqt.client.gui.ressources.generics.IFXComponent; +import com.pqt.client.gui.ressources.components.generics.IFXComponent; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.client.gui.ressources.components.CategoryTabStockDisplayer; import com.pqt.core.entities.product.Product; @@ -14,6 +15,7 @@ import com.pqt.core.entities.sale.SaleType; import com.pqt.core.entities.user_account.Account; import javafx.application.Platform; +import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.control.*; import javafx.scene.layout.*; @@ -35,6 +37,7 @@ class SaleScreenView implements IFXComponent { private ChoiceBox saleBeneficiaryAccountDisplayer; private ChoiceBox saleTypeDisplayer; private TextField salePriceDisplayer; + private SimpleValidator validator; SaleScreenView(SaleScreenController ctrl) { this.ctrl = ctrl; @@ -43,6 +46,7 @@ class SaleScreenView implements IFXComponent { private void initGui() { mainPane = new StackPane(); + mainPane.getStyleClass().add("main-module-pane"); mainPaneContent = new BorderPane(); @@ -50,7 +54,6 @@ class SaleScreenView implements IFXComponent { -----------------------CENTER PANE----------------------- */ { - mainPane.getChildren().add(mainPaneContent); mainPaneContent.prefWidthProperty().bind(mainPane.widthProperty()); mainPaneContent.prefHeightProperty().bind(mainPane.heightProperty()); @@ -72,7 +75,9 @@ class SaleScreenView implements IFXComponent { -----------------------BOTTOM PANE----------------------- */ { - AnchorPane mainContentBottomPane = new AnchorPane(); + HBox mainContentBottomPane = new HBox(); + mainContentBottomPane.setFillHeight(true); + mainContentBottomPane.setAlignment(Pos.CENTER); // Sale secondary data configuration (author, beneficiary, payment type, etc... { saleMakerAccountDisplayer = new TextField(); @@ -96,30 +101,29 @@ class SaleScreenView implements IFXComponent { salePriceDisplayer.setPromptText(GUIStringTool.getSalePriceTextFieldPromptText()); - GridPane mainContentBottomLeftPane = new GridPane(); - mainContentBottomLeftPane.add(new Label(GUIStringTool.getSaleMakerTextFieldLabel()), 0, 0); - mainContentBottomLeftPane.add(saleMakerAccountDisplayer, 1, 0); - mainContentBottomLeftPane.add(new Label(GUIStringTool.getSaleBeneficiaryTextFieldLabel()), 0, 1); - mainContentBottomLeftPane.add(saleBeneficiaryAccountDisplayer, 1, 1); - mainContentBottomLeftPane.add(new Label(GUIStringTool.getSaleTypeTextFieldLabel()), 0, 2); - mainContentBottomLeftPane.add(saleTypeDisplayer, 1, 2); - mainContentBottomLeftPane.add(new Label(GUIStringTool.getSalePriceTextFieldLabel()), 0, 3); - mainContentBottomLeftPane.add(salePriceDisplayer, 1, 3); + GridPane mainContentBottomCenterPane = new CssEnabledGridPane(); + mainContentBottomCenterPane.add(new Label(GUIStringTool.getSaleMakerTextFieldLabel()), 0, 0); + mainContentBottomCenterPane.add(saleMakerAccountDisplayer, 1, 0); + mainContentBottomCenterPane.add(new Label(GUIStringTool.getSaleBeneficiaryTextFieldLabel()), 0, 1); + mainContentBottomCenterPane.add(saleBeneficiaryAccountDisplayer, 1, 1); + mainContentBottomCenterPane.add(new Label(GUIStringTool.getSaleTypeTextFieldLabel()), 0, 2); + mainContentBottomCenterPane.add(saleTypeDisplayer, 1, 2); + mainContentBottomCenterPane.add(new Label(GUIStringTool.getSalePriceTextFieldLabel()), 0, 3); + mainContentBottomCenterPane.add(salePriceDisplayer, 1, 3); - mainContentBottomPane.getChildren().add(mainContentBottomLeftPane); - AnchorPane.setBottomAnchor(mainContentBottomLeftPane, 0d); - AnchorPane.setTopAnchor(mainContentBottomLeftPane, 0d); - AnchorPane.setLeftAnchor(mainContentBottomLeftPane, 0d); + mainContentBottomPane.getChildren().add(mainContentBottomCenterPane); } //Sale Validator { - SimpleValidator validator = new SimpleValidator(true); + AnchorPane anchorPane = new AnchorPane(); + validator = new SimpleValidator(true); validator.addListener(ctrl.getValidatorListener()); - - mainContentBottomPane.getChildren().add(validator.getPane()); - AnchorPane.setBottomAnchor(validator.getPane(), 0d); - AnchorPane.setTopAnchor(validator.getPane(), 0d); + anchorPane.getChildren().add(validator.getPane()); AnchorPane.setRightAnchor(validator.getPane(), 0d); + AnchorPane.setBottomAnchor(validator.getPane(), 0d); + + mainContentBottomPane.getChildren().add(anchorPane); + HBox.setHgrow(anchorPane, Priority.ALWAYS); } mainPaneContent.setBottom(mainContentBottomPane); } @@ -127,11 +131,6 @@ class SaleScreenView implements IFXComponent { ------------------------MAIN PANE------------------------ */ mainPane.getChildren().add(mainPaneContent); - - /* - -------------------------UPDATE-------------------------- - */ - ctrl.updateView(); } @Override @@ -143,7 +142,8 @@ class SaleScreenView implements IFXComponent { boolean clearChildren = mainPane.getChildren().size()>1; Pane greyIntermediaryPane = new Pane(); - greyIntermediaryPane.setId(GUICssTool.getGreyIntermediaryPaneCssId()); + greyIntermediaryPane.getStyleClass().clear(); + greyIntermediaryPane.getStyleClass().add("grey-intermediary-pane"); saleValidationScreen = new SaleValidationScreen(saleId, sale); saleValidationScreen.addListener(ctrl.getSaleValidationScreenListener()); @@ -153,6 +153,7 @@ class SaleScreenView implements IFXComponent { mainPane.getChildren().add(mainPaneContent); } + StackPane.setAlignment(saleValidationScreen.getPane(), Pos.CENTER); mainPane.getChildren().addAll(greyIntermediaryPane, saleValidationScreen.getPane()); }); } @@ -173,7 +174,8 @@ class SaleScreenView implements IFXComponent { void setSaleTypes(List saleTypes) { Platform.runLater(()->{ saleTypeDisplayer.getItems().clear(); - saleTypeDisplayer.getItems().addAll(saleTypes); + if(saleTypes!=null) + saleTypeDisplayer.getItems().addAll(saleTypes); }); } @@ -181,23 +183,26 @@ class SaleScreenView implements IFXComponent { Platform.runLater(()->{ saleBeneficiaryAccountDisplayer.getItems().clear(); saleBeneficiaryAccountDisplayer.getItems().add(ctrl.getDefaultAccount()); - saleBeneficiaryAccountDisplayer.getItems().addAll(accounts); + if(accounts!=null) + saleBeneficiaryAccountDisplayer.getItems().addAll(accounts); }); } void setSale(Sale sale) { - saleDisplayer.display(sale); + if(sale!=null) { + saleDisplayer.display(sale); - String price = GUIStringTool.getPriceRenderer().render(sale.getTotalPrice()); - String currentAccount = GUIStringTool.getAccountStringConverter().toString(sale.getOrderedBy()); + String price = GUIStringTool.getPriceRenderer().render(sale.getTotalPrice()); + String currentAccount = GUIStringTool.getAccountStringConverter().toString(sale.getOrderedBy()); - Platform.runLater(()->{ - salePriceDisplayer.setText(price); - saleMakerAccountDisplayer.setText(currentAccount); + Platform.runLater(() -> { + salePriceDisplayer.setText(price); + saleMakerAccountDisplayer.setText(currentAccount); - selectElement(saleTypeDisplayer, sale.getType()); - selectElement(saleBeneficiaryAccountDisplayer, sale.getOrderedFor()); - }); + selectElement(saleTypeDisplayer, sale.getType()); + selectElement(saleBeneficiaryAccountDisplayer, sale.getOrderedFor()); + }); + } } private void selectElement(ChoiceBox choiceBox, T element){ @@ -212,4 +217,8 @@ class SaleScreenView implements IFXComponent { void setSaleStatus(SaleStatus status){ this.saleValidationScreen.setSaleStatus(status); } + + void setValidationButtonEnabled(boolean validationButtonEnabled) { + validator.setValidationButtonEnable(validationButtonEnabled); + } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/sale_validation_screen/SaleValidationScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/sale_validation_screen/SaleValidationScreen.java similarity index 75% rename from Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/sale_validation_screen/SaleValidationScreen.java rename to Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/sale_validation_screen/SaleValidationScreen.java index 8398ac61..9153b679 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/sale_validation_screen/SaleValidationScreen.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/sale_validation_screen/SaleValidationScreen.java @@ -1,10 +1,12 @@ -package com.pqt.client.gui.ressources.components.sale_validation_screen; +package com.pqt.client.gui.modules.sale_screen.sale_validation_screen; -import com.pqt.client.gui.ressources.components.sale_validation_screen.listeners.ISaleValidationScreenListener; +import com.pqt.client.gui.modules.sale_screen.sale_validation_screen.listeners.ISaleValidationScreenListener; +import com.pqt.client.gui.ressources.components.generics.javafx_override.CssEnabledGridPane; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.core.entities.sale.Sale; import com.pqt.core.entities.sale.SaleStatus; import javafx.application.Platform; +import javafx.geometry.Pos; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.ProgressIndicator; @@ -31,9 +33,12 @@ public class SaleValidationScreen { listeners = new EventListenerList(); mainPane = new Pane(); + saleStatus = sale.getStatus(); + BorderPane mainPaneContent = new BorderPane(); - GridPane centerPane = new GridPane(); + GridPane centerPane = new CssEnabledGridPane(); + centerPane.setAlignment(Pos.CENTER); Label saleIdLabel = new Label(GUIStringTool.getSaleIdLabel()); centerPane.add(saleIdLabel, 0, 0); @@ -45,24 +50,29 @@ public class SaleValidationScreen { Label saleStatusLabel = new Label(GUIStringTool.getSaleStatusLabel()); centerPane.add(saleStatusLabel, 0, 1); - saleStatusTextField = new TextField(GUIStringTool.getSaleStatusRenderer().render(SaleStatus.PENDING)); + saleStatusTextField = new TextField(GUIStringTool.getSaleStatusRenderer().render(saleStatus)); saleStatusTextField.setEditable(false); centerPane.add(saleStatusTextField, 1, 1); + validationButton = new Button(GUIStringTool.getOkButtonLabel()); + validationButton.setDisable(saleStatus.equals(SaleStatus.PENDING)); + validationButton.setOnMouseClicked(event->fireScreenClose(saleStatus.equals(SaleStatus.ACCEPTED))); + centerPane.add(validationButton, 1,2); + mainPaneContent.setCenter(centerPane); progressIndicator = new ProgressIndicator(); - progressIndicator.setPrefSize(50, 50); mainPaneContent.setLeft(progressIndicator); - validationButton = new Button(GUIStringTool.getOkButtonLabel()); - validationButton.setOnMouseClicked(event->fireScreenClose(saleStatus.equals(SaleStatus.ACCEPTED))); + mainPaneContent.prefHeightProperty().bind(mainPane.heightProperty()); + mainPaneContent.prefWidthProperty().bind(mainPane.widthProperty()); + mainPane.getChildren().add(mainPaneContent); } - private void fireScreenClose(boolean saleValidateddSuccessFully) { + private void fireScreenClose(boolean saleValidatedSuccessFully) { if(!validationButton.isDisable()){ Arrays.stream(listeners.getListeners(ISaleValidationScreenListener.class)) - .forEach(listener->listener.onScreenClose(saleValidateddSuccessFully)); + .forEach(listener->listener.onScreenClose(saleValidatedSuccessFully)); } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/sale_validation_screen/listeners/ISaleValidationScreenListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/sale_validation_screen/listeners/ISaleValidationScreenListener.java similarity index 66% rename from Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/sale_validation_screen/listeners/ISaleValidationScreenListener.java rename to Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/sale_validation_screen/listeners/ISaleValidationScreenListener.java index 8bb1eb7c..e2011357 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/sale_validation_screen/listeners/ISaleValidationScreenListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/sale_validation_screen/listeners/ISaleValidationScreenListener.java @@ -1,4 +1,4 @@ -package com.pqt.client.gui.ressources.components.sale_validation_screen.listeners; +package com.pqt.client.gui.modules.sale_screen.sale_validation_screen.listeners; import java.util.EventListener; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/AccountManager.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/AccountManager.java index b5f8b213..34dd4cd3 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/AccountManager.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/AccountManager.java @@ -1,12 +1,12 @@ package com.pqt.client.gui.ressources.components; -import com.pqt.client.gui.ressources.generics.creators.IFXCreatorComponent; -import com.pqt.client.gui.ressources.generics.validators.IFXValidatorComponent; -import com.pqt.client.gui.ressources.specifics.account.listeners.IAccountComponentListener; -import com.pqt.client.gui.ressources.generics.validators.listeners.IValidatorComponentListener; -import com.pqt.client.gui.ressources.generics.validators.listeners.SimpleValidatorComponentFirerer; -import com.pqt.client.gui.ressources.specifics.account.IFXAccountsDisplayerComponent; -import com.pqt.client.gui.ressources.specifics.account.listeners.SimpleAccountComponentFirerer; +import com.pqt.client.gui.ressources.components.generics.creators.IFXCreatorComponent; +import com.pqt.client.gui.ressources.components.generics.validators.IFXValidatorComponent; +import com.pqt.client.gui.ressources.components.specifics.account.listeners.IAccountComponentListener; +import com.pqt.client.gui.ressources.components.generics.validators.listeners.IValidatorComponentListener; +import com.pqt.client.gui.ressources.components.generics.validators.listeners.SimpleValidatorComponentFirerer; +import com.pqt.client.gui.ressources.components.specifics.account.IFXAccountsDisplayerComponent; +import com.pqt.client.gui.ressources.components.specifics.account.listeners.SimpleAccountComponentFirerer; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.core.entities.user_account.Account; import javafx.application.Platform; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java index a4f2f582..d79b83c3 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java @@ -1,17 +1,19 @@ package com.pqt.client.gui.ressources.components; -import com.pqt.client.gui.ressources.generics.displayers.IFXDisplayerComponent; -import com.pqt.client.gui.ressources.specifics.products.listeners.IStockComponentListener; -import com.pqt.client.gui.ressources.specifics.products.listeners.SimpleStockComponentFirerer; +import com.pqt.client.gui.ressources.components.generics.displayers.IFXDisplayerComponent; +import com.pqt.client.gui.ressources.components.specifics.products.listeners.IStockComponentListener; +import com.pqt.client.gui.ressources.components.specifics.products.listeners.SimpleStockComponentFirerer; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.client.gui.ressources.strings.IObjectStringRenderer; import com.pqt.core.entities.product.Product; import javafx.application.Platform; import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import javafx.geometry.Pos; import javafx.scene.control.*; import javafx.scene.input.KeyCode; import javafx.scene.layout.BorderPane; +import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import java.util.Collection; @@ -64,8 +66,17 @@ public class CategoryTabStockDisplayer implements IFXDisplayerComponent(); listView.setCellFactory(list->new ListCell(){ diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/SimpleValidator.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/SimpleValidator.java index aeb426b7..0d895aa4 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/SimpleValidator.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/SimpleValidator.java @@ -1,12 +1,13 @@ package com.pqt.client.gui.ressources.components; -import com.pqt.client.gui.ressources.generics.validators.IFXValidatorComponent; -import com.pqt.client.gui.ressources.generics.validators.listeners.IValidatorComponentFirerer; -import com.pqt.client.gui.ressources.generics.validators.listeners.IValidatorComponentListener; +import com.pqt.client.gui.ressources.components.generics.validators.IFXValidatorComponent; +import com.pqt.client.gui.ressources.components.generics.validators.listeners.IValidatorComponentFirerer; +import com.pqt.client.gui.ressources.components.generics.validators.listeners.IValidatorComponentListener; import com.pqt.client.gui.ressources.strings.GUIStringTool; -import com.pqt.client.gui.ressources.generics.validators.listeners.SimpleValidatorComponentFirerer; +import com.pqt.client.gui.ressources.components.generics.validators.listeners.SimpleValidatorComponentFirerer; import javafx.application.Platform; import javafx.scene.control.Button; +import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; @@ -24,7 +25,6 @@ public class SimpleValidator implements IFXValidatorComponent { public SimpleValidator(boolean askConfirmation) { firerer = new SimpleValidatorComponentFirerer(); this.askConfirmation = askConfirmation; - } @Override @@ -45,21 +45,22 @@ public class SimpleValidator implements IFXValidatorComponent { } private Pane createPane(){ - HBox hbox = new HBox(); + GridPane grid = new GridPane(); + grid.getStyleClass().add("validator"); validationButton = new Button(GUIStringTool.getValidationButtonLabel()); validationButton.setOnMouseClicked(event->{ getValidationButtonProcess().process(); }); - hbox.getChildren().add(validationButton); + grid.add(validationButton, 0,0); cancelButton = new Button(GUIStringTool.getCancelButtonLabel()); cancelButton.setOnMouseClicked(event->{ getCancelButtonProcess().process(); }); - hbox.getChildren().add(cancelButton); + grid.add(cancelButton, 1, 0); - return hbox; + return grid; } private IButtonProcess getValidationButtonProcess(){ @@ -96,4 +97,12 @@ public class SimpleValidator implements IFXValidatorComponent { private interface IButtonProcess{ void process(); } + + public void setValidationButtonEnable(boolean enable){ + this.validationButton.setDisable(!enable); + } + + public void setCancelationButtonEnable(boolean enable){ + this.cancelButton.setDisable(!enable); + } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/IFXComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/IFXComponent.java similarity index 60% rename from Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/IFXComponent.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/IFXComponent.java index 0bee2445..d333e909 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/IFXComponent.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/IFXComponent.java @@ -1,4 +1,4 @@ -package com.pqt.client.gui.ressources.generics; +package com.pqt.client.gui.ressources.components.generics; import javafx.scene.layout.Pane; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/creators/IFXCreatorComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/creators/IFXCreatorComponent.java new file mode 100644 index 00000000..4a79f9d1 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/creators/IFXCreatorComponent.java @@ -0,0 +1,8 @@ +package com.pqt.client.gui.ressources.components.generics.creators; + +import com.pqt.client.gui.ressources.components.generics.IFXComponent; + +public interface IFXCreatorComponent extends IFXComponent{ + T create(); + boolean isCreationPossible(); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/displayers/IFXDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/displayers/IFXDisplayerComponent.java new file mode 100644 index 00000000..6d9ea7fb --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/displayers/IFXDisplayerComponent.java @@ -0,0 +1,10 @@ +package com.pqt.client.gui.ressources.components.generics.displayers; + +import com.pqt.client.gui.ressources.components.generics.IFXComponent; +import com.pqt.client.gui.ressources.components.generics.displayers.listeners.IDisplayerComponentListener; + +public interface IFXDisplayerComponent extends IFXComponent{ + void display(T content); + void addListener(U l); + void removeListener(U l); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/IDisplayerComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/displayers/listeners/IDisplayerComponentFirerer.java similarity index 84% rename from Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/IDisplayerComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/displayers/listeners/IDisplayerComponentFirerer.java index f3bd32d7..9824dd5f 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/IDisplayerComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/displayers/listeners/IDisplayerComponentFirerer.java @@ -1,4 +1,4 @@ -package com.pqt.client.gui.ressources.generics.displayers.listeners; +package com.pqt.client.gui.ressources.components.generics.displayers.listeners; import javafx.event.Event; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/IDisplayerComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/displayers/listeners/IDisplayerComponentListener.java similarity index 82% rename from Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/IDisplayerComponentListener.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/displayers/listeners/IDisplayerComponentListener.java index d2da215f..e2c28d07 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/IDisplayerComponentListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/displayers/listeners/IDisplayerComponentListener.java @@ -1,4 +1,4 @@ -package com.pqt.client.gui.ressources.generics.displayers.listeners; +package com.pqt.client.gui.ressources.components.generics.displayers.listeners; import javafx.event.Event; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java similarity index 96% rename from Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java index e97916e4..c1909ad0 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/displayers/listeners/SimpleDisplayerComponentFirerer.java @@ -1,4 +1,4 @@ -package com.pqt.client.gui.ressources.generics.displayers.listeners; +package com.pqt.client.gui.ressources.components.generics.displayers.listeners; import javafx.event.Event; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/CssEnabledGridPane.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/CssEnabledGridPane.java new file mode 100644 index 00000000..3ef68e26 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/CssEnabledGridPane.java @@ -0,0 +1,11 @@ +package com.pqt.client.gui.ressources.components.generics.javafx_override; + +import javafx.scene.layout.GridPane; + +public class CssEnabledGridPane extends GridPane { + + public CssEnabledGridPane() { + super(); + this.getStyleClass().add("grid-pane"); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/validators/IFXValidatorComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/validators/IFXValidatorComponent.java new file mode 100644 index 00000000..01f96276 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/validators/IFXValidatorComponent.java @@ -0,0 +1,9 @@ +package com.pqt.client.gui.ressources.components.generics.validators; + +import com.pqt.client.gui.ressources.components.generics.IFXComponent; +import com.pqt.client.gui.ressources.components.generics.validators.listeners.IValidatorComponentListener; + +public interface IFXValidatorComponent extends IFXComponent{ + void addListener(IValidatorComponentListener l); + void removeListener(IValidatorComponentListener l); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/IValidatorComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/validators/listeners/IValidatorComponentFirerer.java similarity index 73% rename from Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/IValidatorComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/validators/listeners/IValidatorComponentFirerer.java index 083f6602..2e44be06 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/IValidatorComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/validators/listeners/IValidatorComponentFirerer.java @@ -1,4 +1,4 @@ -package com.pqt.client.gui.ressources.generics.validators.listeners; +package com.pqt.client.gui.ressources.components.generics.validators.listeners; public interface IValidatorComponentFirerer { void addListener(IValidatorComponentListener l); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/IValidatorComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/validators/listeners/IValidatorComponentListener.java similarity index 66% rename from Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/IValidatorComponentListener.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/validators/listeners/IValidatorComponentListener.java index 34c29bbd..c4144f91 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/IValidatorComponentListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/validators/listeners/IValidatorComponentListener.java @@ -1,4 +1,4 @@ -package com.pqt.client.gui.ressources.generics.validators.listeners; +package com.pqt.client.gui.ressources.components.generics.validators.listeners; import java.util.EventListener; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/SimpleValidatorComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/validators/listeners/SimpleValidatorComponentFirerer.java similarity index 92% rename from Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/SimpleValidatorComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/validators/listeners/SimpleValidatorComponentFirerer.java index ab0c32a1..cdaa979c 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/listeners/SimpleValidatorComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/validators/listeners/SimpleValidatorComponentFirerer.java @@ -1,4 +1,4 @@ -package com.pqt.client.gui.ressources.generics.validators.listeners; +package com.pqt.client.gui.ressources.components.generics.validators.listeners; import javax.swing.event.EventListenerList; import java.util.Arrays; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/account/IFXAccountsDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/account/IFXAccountsDisplayerComponent.java new file mode 100644 index 00000000..1c459115 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/account/IFXAccountsDisplayerComponent.java @@ -0,0 +1,11 @@ +package com.pqt.client.gui.ressources.components.specifics.account; + +import com.pqt.client.gui.ressources.components.generics.displayers.IFXDisplayerComponent; +import com.pqt.client.gui.ressources.components.specifics.account.listeners.IAccountComponentListener; +import com.pqt.core.entities.user_account.Account; + +import java.util.Collection; + +public interface IFXAccountsDisplayerComponent extends IFXDisplayerComponent, IAccountComponentListener> { + +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/account/listeners/IAccountComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/account/listeners/IAccountComponentListener.java new file mode 100644 index 00000000..9fe3ff70 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/account/listeners/IAccountComponentListener.java @@ -0,0 +1,7 @@ +package com.pqt.client.gui.ressources.components.specifics.account.listeners; + +import com.pqt.client.gui.ressources.components.generics.displayers.listeners.IDisplayerComponentListener; +import com.pqt.core.entities.user_account.Account; + +public interface IAccountComponentListener extends IDisplayerComponentListener{ +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/account/listeners/SimpleAccountComponentFirerer.java similarity index 59% rename from Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/account/listeners/SimpleAccountComponentFirerer.java index d0e5cfbd..8f06f6a2 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/SimpleAccountComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/account/listeners/SimpleAccountComponentFirerer.java @@ -1,6 +1,6 @@ -package com.pqt.client.gui.ressources.specifics.account.listeners; +package com.pqt.client.gui.ressources.components.specifics.account.listeners; -import com.pqt.client.gui.ressources.generics.displayers.listeners.SimpleDisplayerComponentFirerer; +import com.pqt.client.gui.ressources.components.generics.displayers.listeners.SimpleDisplayerComponentFirerer; import com.pqt.core.entities.user_account.Account; public class SimpleAccountComponentFirerer extends SimpleDisplayerComponentFirerer { diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/products/IFXProductsDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/products/IFXProductsDisplayerComponent.java new file mode 100644 index 00000000..5411b73d --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/products/IFXProductsDisplayerComponent.java @@ -0,0 +1,10 @@ +package com.pqt.client.gui.ressources.components.specifics.products; + +import com.pqt.client.gui.ressources.components.generics.displayers.IFXDisplayerComponent; +import com.pqt.client.gui.ressources.components.specifics.products.listeners.IStockComponentListener; +import com.pqt.core.entities.product.Product; + +import java.util.Collection; + +public interface IFXProductsDisplayerComponent extends IFXDisplayerComponent, IStockComponentListener> { +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/products/listeners/IStockComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/products/listeners/IStockComponentListener.java new file mode 100644 index 00000000..0dffba47 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/products/listeners/IStockComponentListener.java @@ -0,0 +1,7 @@ +package com.pqt.client.gui.ressources.components.specifics.products.listeners; + +import com.pqt.client.gui.ressources.components.generics.displayers.listeners.IDisplayerComponentListener; +import com.pqt.core.entities.product.Product; + +public interface IStockComponentListener extends IDisplayerComponentListener { +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/listeners/SimpleStockComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/products/listeners/SimpleStockComponentFirerer.java similarity index 58% rename from Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/listeners/SimpleStockComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/products/listeners/SimpleStockComponentFirerer.java index daedf4b0..5832a288 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/listeners/SimpleStockComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/products/listeners/SimpleStockComponentFirerer.java @@ -1,6 +1,6 @@ -package com.pqt.client.gui.ressources.specifics.products.listeners; +package com.pqt.client.gui.ressources.components.specifics.products.listeners; -import com.pqt.client.gui.ressources.generics.displayers.listeners.SimpleDisplayerComponentFirerer; +import com.pqt.client.gui.ressources.components.generics.displayers.listeners.SimpleDisplayerComponentFirerer; import com.pqt.core.entities.product.Product; public class SimpleStockComponentFirerer extends SimpleDisplayerComponentFirerer { diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/sale/IFXSaleDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/sale/IFXSaleDisplayerComponent.java new file mode 100644 index 00000000..5f0a0fbc --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/sale/IFXSaleDisplayerComponent.java @@ -0,0 +1,8 @@ +package com.pqt.client.gui.ressources.components.specifics.sale; + +import com.pqt.client.gui.ressources.components.generics.displayers.IFXDisplayerComponent; +import com.pqt.client.gui.ressources.components.specifics.sale.listeners.ISaleComponentListener; +import com.pqt.core.entities.sale.Sale; + +public interface IFXSaleDisplayerComponent extends IFXDisplayerComponent { +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/listeners/ISaleComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/sale/listeners/ISaleComponentListener.java similarity index 59% rename from Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/listeners/ISaleComponentListener.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/sale/listeners/ISaleComponentListener.java index cc3510ec..f64fbc7f 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/listeners/ISaleComponentListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/sale/listeners/ISaleComponentListener.java @@ -1,6 +1,6 @@ -package com.pqt.client.gui.ressources.specifics.sale.listeners; +package com.pqt.client.gui.ressources.components.specifics.sale.listeners; -import com.pqt.client.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; +import com.pqt.client.gui.ressources.components.generics.displayers.listeners.IDisplayerComponentListener; import com.pqt.core.entities.product.Product; import com.pqt.core.entities.sale.Sale; import javafx.event.Event; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/listeners/SimpleSaleComponentFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/sale/listeners/SimpleSaleComponentFirerer.java similarity index 75% rename from Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/listeners/SimpleSaleComponentFirerer.java rename to Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/sale/listeners/SimpleSaleComponentFirerer.java index 9a669f88..aa83a903 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/listeners/SimpleSaleComponentFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/specifics/sale/listeners/SimpleSaleComponentFirerer.java @@ -1,6 +1,6 @@ -package com.pqt.client.gui.ressources.specifics.sale.listeners; +package com.pqt.client.gui.ressources.components.specifics.sale.listeners; -import com.pqt.client.gui.ressources.generics.displayers.listeners.SimpleDisplayerComponentFirerer; +import com.pqt.client.gui.ressources.components.generics.displayers.listeners.SimpleDisplayerComponentFirerer; import com.pqt.core.entities.product.Product; import com.pqt.core.entities.sale.Sale; import javafx.event.Event; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java index b4c48833..3beba068 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java @@ -1,7 +1,7 @@ package com.pqt.client.gui.ressources.css; public class GUICssTool { - public static String getGreyIntermediaryPaneCssId(){ - return "grey-pane"; + public static String getCssFilePath(){ + return "/dark-theme.css"; } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/creators/IFXCreatorComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/creators/IFXCreatorComponent.java deleted file mode 100644 index 7a5e06f2..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/creators/IFXCreatorComponent.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.pqt.client.gui.ressources.generics.creators; - -import com.pqt.client.gui.ressources.generics.IFXComponent; - -public interface IFXCreatorComponent extends IFXComponent{ - T create(); - boolean isCreationPossible(); -} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/IFXDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/IFXDisplayerComponent.java deleted file mode 100644 index 1137609d..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/displayers/IFXDisplayerComponent.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.pqt.client.gui.ressources.generics.displayers; - -import com.pqt.client.gui.ressources.generics.IFXComponent; -import com.pqt.client.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; - -public interface IFXDisplayerComponent extends IFXComponent{ - void display(T content); - void addListener(U l); - void removeListener(U l); -} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/IFXValidatorComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/IFXValidatorComponent.java deleted file mode 100644 index 67d961b4..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/generics/validators/IFXValidatorComponent.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.pqt.client.gui.ressources.generics.validators; - -import com.pqt.client.gui.ressources.generics.IFXComponent; -import com.pqt.client.gui.ressources.generics.validators.listeners.IValidatorComponentListener; - -public interface IFXValidatorComponent extends IFXComponent{ - void addListener(IValidatorComponentListener l); - void removeListener(IValidatorComponentListener l); -} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java deleted file mode 100644 index 29fe49d9..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/IFXAccountsDisplayerComponent.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pqt.client.gui.ressources.specifics.account; - -import com.pqt.client.gui.ressources.generics.displayers.IFXDisplayerComponent; -import com.pqt.client.gui.ressources.specifics.account.listeners.IAccountComponentListener; -import com.pqt.core.entities.user_account.Account; - -import java.util.Collection; - -public interface IFXAccountsDisplayerComponent extends IFXDisplayerComponent, IAccountComponentListener> { - -} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/IAccountComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/IAccountComponentListener.java deleted file mode 100644 index 12d70b4f..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/account/listeners/IAccountComponentListener.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.pqt.client.gui.ressources.specifics.account.listeners; - -import com.pqt.client.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; -import com.pqt.core.entities.user_account.Account; - -public interface IAccountComponentListener extends IDisplayerComponentListener{ -} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java deleted file mode 100644 index d4186480..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/IFXProductsDisplayerComponent.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.pqt.client.gui.ressources.specifics.products; - -import com.pqt.client.gui.ressources.generics.displayers.IFXDisplayerComponent; -import com.pqt.client.gui.ressources.specifics.products.listeners.IStockComponentListener; -import com.pqt.core.entities.product.Product; - -import java.util.Collection; - -public interface IFXProductsDisplayerComponent extends IFXDisplayerComponent, IStockComponentListener> { -} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/listeners/IStockComponentListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/listeners/IStockComponentListener.java deleted file mode 100644 index 45bf72eb..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/products/listeners/IStockComponentListener.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.pqt.client.gui.ressources.specifics.products.listeners; - -import com.pqt.client.gui.ressources.generics.displayers.listeners.IDisplayerComponentListener; -import com.pqt.core.entities.product.Product; - -public interface IStockComponentListener extends IDisplayerComponentListener { -} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java deleted file mode 100644 index e4e8c143..00000000 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/specifics/sale/IFXSaleDisplayerComponent.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.pqt.client.gui.ressources.specifics.sale; - -import com.pqt.client.gui.ressources.generics.displayers.IFXDisplayerComponent; -import com.pqt.client.gui.ressources.specifics.sale.listeners.ISaleComponentListener; -import com.pqt.core.entities.sale.Sale; - -public interface IFXSaleDisplayerComponent extends IFXDisplayerComponent { -} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java index 4d33ab11..c4d5818a 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java @@ -55,7 +55,10 @@ public class GUIStringTool { return new StringConverter() { @Override public String toString(Account object) { - return String.format("%s - %s)", object.getUsername(), object.getPermissionLevel().name()); + if(object!=null) + return String.format("%s - %s)", object.getUsername(), object.getPermissionLevel()); + + return "null"; } @Override diff --git a/Workspace/client/src/main/java/com/pqt/client/module/account/listeners/AccountListenerAdapter.java b/Workspace/client/src/main/java/com/pqt/client/module/account/listeners/AccountListenerAdapter.java index 421c1f6d..6abd0649 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/account/listeners/AccountListenerAdapter.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/account/listeners/AccountListenerAdapter.java @@ -12,4 +12,11 @@ public class AccountListenerAdapter implements IAccountListener { } + /** + * @see com.pqt.client.module.account.listeners.IAccountListener#onAccountListChangedEvent() + */ + public void onAccountListChangedEvent() { + + } + } diff --git a/Workspace/client/src/main/java/com/pqt/client/module/sale/listeners/ISaleListener.java b/Workspace/client/src/main/java/com/pqt/client/module/sale/listeners/ISaleListener.java index ddb44c48..8369a112 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/sale/listeners/ISaleListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/sale/listeners/ISaleListener.java @@ -1,15 +1,13 @@ package com.pqt.client.module.sale.listeners; -import com.pqt.core.entities.sale.Sale; - import java.util.EventListener; public interface ISaleListener extends EventListener { - public abstract void onSaleValidationSuccess(long saleId); + void onSaleValidationSuccess(long saleId); - public abstract void onSaleValidationError(long saleId, Throwable cause); + void onSaleValidationError(long saleId, Throwable cause); - public abstract void onSaleValidationRefused(long saleId, Throwable cause); + void onSaleValidationRefused(long saleId, Throwable cause); } diff --git a/Workspace/client/src/main/java/com/pqt/client/module/stock/StockService.java b/Workspace/client/src/main/java/com/pqt/client/module/stock/StockService.java index 95644e61..559fa0ae 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/stock/StockService.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/stock/StockService.java @@ -13,7 +13,7 @@ public class StockService { private StockDao dao; - private StockService() { + public StockService() { dao = new StockDao(); } diff --git a/Workspace/client/src/main/resources/dark-theme.css b/Workspace/client/src/main/resources/dark-theme.css new file mode 100644 index 00000000..5789bca8 --- /dev/null +++ b/Workspace/client/src/main/resources/dark-theme.css @@ -0,0 +1,209 @@ +.root { + -fx-background-color: #1d1d1d; +} + +.label { + -fx-font-size: 11pt; + -fx-font-family: "Segoe UI Semibold"; + -fx-text-fill: white; + -fx-opacity: 0.6; +} + +.label-bright { + -fx-font-size: 11pt; + -fx-font-family: "Segoe UI Semibold"; + -fx-text-fill: white; + -fx-opacity: 1; +} + +.label-header { + -fx-font-size: 32pt; + -fx-font-family: "Segoe UI Light"; + -fx-text-fill: white; + -fx-opacity: 1; +} + +.list-view { + -fx-base: #1d1d1d; + -fx-control-inner-background: #1d1d1d; + -fx-background-color: #1d1d1d; + -fx-table-cell-border-color: transparent; + -fx-table-header-border-color: transparent; + -fx-padding: 5; +} + +.list-view .list-cell .label{ + -fx-font-size: 20pt; + -fx-font-family: "Segoe UI Light"; + -fx-text-fill: white; + -fx-alignment: center-left; + -fx-opacity: 1; +} + +.list-view:focused .list-cell:filled:focused:selected { + -fx-background-color: -fx-focus-color; +} + +.table-view { + -fx-base: #1d1d1d; + -fx-control-inner-background: #1d1d1d; + -fx-background-color: #1d1d1d; + -fx-table-cell-border-color: transparent; + -fx-table-header-border-color: transparent; + -fx-padding: 5; +} + +.table-view .column-header-background { + -fx-background-color: transparent; +} + +.table-view .column-header, .table-view .filler { + -fx-size: 35px; + -fx-border-width: 0 0 1 0; + -fx-background-color: transparent; + -fx-border-color: + transparent + transparent + derive(-fx-base, 80%) + transparent; + -fx-border-insets: 0 10 1 0; +} + +.table-view .column-header .label { + -fx-font-size: 20pt; + -fx-font-family: "Segoe UI Light"; + -fx-text-fill: white; + -fx-alignment: center-left; + -fx-opacity: 1; +} + +.table-view:focused .table-row-cell:filled:focused:selected { + -fx-background-color: -fx-focus-color; +} + +.split-pane:horizontal > .split-pane-divider { + -fx-border-color: transparent #1d1d1d transparent #1d1d1d; + -fx-background-color: transparent, derive(#1d1d1d,20%); +} + +.split-pane { + -fx-padding: 1 0 0 0; +} + +.grid-pane { + -fx-hgap: 10; + -fx-vgap: 10; +} + +.menu-bar { + -fx-background-color: derive(#1d1d1d,20%); +} + +.context-menu { + -fx-background-color: derive(#1d1d1d,50%); +} + +.menu-bar .label { + -fx-font-size: 14pt; + -fx-font-family: "Segoe UI Light"; + -fx-text-fill: white; + -fx-opacity: 0.9; +} + +.menu .left-container { + -fx-background-color: black; +} + +.text-field { + -fx-font-size: 12pt; + -fx-font-family: "Segoe UI Semibold"; + -fx-pref-width: 125; + -fx-pref-height: 30; + -fx-background-radius: 0; + -fx-background-color: #1d1d1d; + -fx-background-insets: 0 0 0 0, 0, 1, 2; + -fx-border-color: #e2e2e2; + -fx-border-width: 2; + -fx-text-fill: #d8d8d8; +} + +.button { + -fx-padding: 5 22 5 22; + -fx-border-color: #e2e2e2; + -fx-border-width: 2; + -fx-background-radius: 0; + -fx-background-color: #1d1d1d; + -fx-font-family: "Segoe UI", Helvetica, Arial, sans-serif; + -fx-font-size: 11pt; + -fx-text-fill: #d8d8d8; + -fx-background-insets: 0 0 0 0, 0, 1, 2; + -fx-pref-width: 125; + -fx-pref-height: 30; +} + +.button:hover { + -fx-background-color: #3a3a3a; +} + +.button:pressed, .button:default:hover:pressed { + -fx-background-color: white; + -fx-text-fill: #1d1d1d; +} + +.button:focused { + -fx-border-color: white, white; + -fx-border-width: 1, 1; + -fx-border-style: solid, segments(1, 1); + -fx-border-radius: 0, 0; + -fx-border-insets: 1 1 1 1, 0; +} + +.button:disabled, .button:default:disabled { + -fx-opacity: 0.4; + -fx-background-color: #1d1d1d; + -fx-text-fill: white; +} + +.button:default { + -fx-background-color: -fx-focus-color; + -fx-text-fill: #ffffff; +} + +.button:default:hover { + -fx-background-color: derive(-fx-focus-color,30%); +} + +.choice-box { + -fx-pref-width: 150; + -fx-pref-height: 30; + -fx-background-radius: 0; + -fx-background-color: #1d1d1d; + -fx-background-insets: 0 0 0 0, 0, 1, 2; + -fx-border-color: #e2e2e2; + -fx-border-width: 2; + -fx-text-fill: #d8d8d8; +} + +.progress-indicator { + -fx-pref-width: 50; + -fx-pref-height: 50; +} + +.grey-intermediary-pane { + -fx-background-color: #1d1d1d; + -fx-opacity: 60%; +} + +.main-module-pane { + -fx-padding: 10 10 10 10; +} + +.validator { + -fx-padding: 10 10 10 10; + -fx-hgap: 10; + -fx-vgap: 10; +} +.validator .button{ + -fx-pref-width: 150; + -fx-pref-height: 50; + } \ No newline at end of file diff --git a/Workspace/core/src/main/java/com/pqt/core/entities/members/Client.java b/Workspace/core/src/main/java/com/pqt/core/entities/members/Client.java index a4498012..aaa92a4d 100644 --- a/Workspace/core/src/main/java/com/pqt/core/entities/members/Client.java +++ b/Workspace/core/src/main/java/com/pqt/core/entities/members/Client.java @@ -27,21 +27,6 @@ public class Client extends PqtMember{ this.address = address; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Client client = (Client) o; - - return address.equals(client.address) && id==client.id && type.equals(client.type); - } - - @Override - public int hashCode() { - return address.hashCode() + type.hashCode() + Integer.class.cast(id); - } - @Override public int hashCode() { return Objects.hash(super.hashCode(), address); From 60e3caf4de3a213c50778b4fc8c59237c6c7d772 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Tue, 15 Aug 2017 00:40:51 +0200 Subject: [PATCH 08/36] =?UTF-8?q?Module=20Client,=20=C3=A9cran=20de=20vent?= =?UTF-8?q?e=20:=20clss=20SaleScreen=20impl=C3=A9mente=20d=C3=A9sormais=20?= =?UTF-8?q?IGuiModule;=20Corrections=20mineures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/pqt/client/gui/modules/IGuiModule.java | 7 +++++++ .../pqt/client/gui/modules/sale_screen/SaleScreen.java | 9 ++++++++- .../gui/modules/sale_screen/SaleScreenController.java | 2 +- .../client/gui/modules/sale_screen/SaleScreenView.java | 1 - 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/IGuiModule.java diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/IGuiModule.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/IGuiModule.java new file mode 100644 index 00000000..a6a06023 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/IGuiModule.java @@ -0,0 +1,7 @@ +package com.pqt.client.gui.modules; + +import com.pqt.client.gui.ressources.components.generics.IFXComponent; + +public interface IGuiModule extends IFXComponent{ + String getModuleName(); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java index ad94fafd..d9007117 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java @@ -1,12 +1,14 @@ package com.pqt.client.gui.modules.sale_screen; +import com.pqt.client.gui.modules.IGuiModule; import com.pqt.client.gui.ressources.components.generics.IFXComponent; +import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.client.module.account.AccountService; import com.pqt.client.module.sale.SaleService; import com.pqt.client.module.stock.StockService; import javafx.scene.layout.Pane; -public class SaleScreen implements IFXComponent { +public class SaleScreen implements IGuiModule { private SaleScreenView view; @@ -23,4 +25,9 @@ public class SaleScreen implements IFXComponent { public Pane getPane() { return view.getPane(); } + + @Override + public String getModuleName() { + return GUIStringTool.getSaleGuiModuleName(); + } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java index a3f93988..5a65ebc5 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java @@ -133,7 +133,7 @@ class SaleScreenController { } Account getDefaultAccount() { - return new Account(" - ", null, AccountLevel.getLowest()); + return new Account(null, null, AccountLevel.getLowest()); } IValidatorComponentListener getValidatorListener() { diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java index ade15612..24adaa81 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java @@ -4,7 +4,6 @@ import com.pqt.client.gui.modules.sale_screen.sale_validation_screen.SaleValidat import com.pqt.client.gui.ressources.components.CommandComposerSaleDisplayer; import com.pqt.client.gui.ressources.components.SimpleValidator; import com.pqt.client.gui.ressources.components.generics.javafx_override.CssEnabledGridPane; -import com.pqt.client.gui.ressources.css.GUICssTool; import com.pqt.client.gui.ressources.components.generics.IFXComponent; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.client.gui.ressources.components.CategoryTabStockDisplayer; From 330dc78f88e412155601060a60011bdc82be7248 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Tue, 15 Aug 2017 00:41:43 +0200 Subject: [PATCH 09/36] =?UTF-8?q?Module=20Client,=20clss=20AccountManager?= =?UTF-8?q?=20:=20correction=20erreur=20compilation;=20modification=20du?= =?UTF-8?q?=20layout=20(d=C3=A9sormais=20en=20colonne)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ressources/components/AccountManager.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/AccountManager.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/AccountManager.java index 34dd4cd3..a88fb26c 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/AccountManager.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/AccountManager.java @@ -9,6 +9,7 @@ import com.pqt.client.gui.ressources.components.specifics.account.IFXAccountsDis import com.pqt.client.gui.ressources.components.specifics.account.listeners.SimpleAccountComponentFirerer; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.core.entities.user_account.Account; +import com.pqt.core.entities.user_account.AccountLevel; import javafx.application.Platform; import javafx.collections.FXCollections; import javafx.scene.control.Button; @@ -26,7 +27,7 @@ public class AccountManager implements IFXAccountsDisplayerComponent, IFXValidat private Pane mainPane; - private HBox mainDisconnectedPane, mainConnectedPane; + private VBox mainDisconnectedPane, mainConnectedPane; private TextField connectedUsernameField; private ChoiceBox disconnectedUsernameField; private PasswordField passwordField; @@ -48,8 +49,8 @@ public class AccountManager implements IFXAccountsDisplayerComponent, IFXValidat private void init() { mainPane = new Pane(); - mainConnectedPane = new HBox(); - mainDisconnectedPane = new HBox(); + mainConnectedPane = new VBox(); + mainDisconnectedPane = new VBox(); connectedUsernameField = new TextField(); connectedUsernameField.setEditable(false); @@ -67,21 +68,26 @@ public class AccountManager implements IFXAccountsDisplayerComponent, IFXValidat passwordField = new PasswordField(); passwordField.setPromptText(GUIStringTool.getPasswordFieldPromptText()); - VBox leftDisconnectedPaneContent = new VBox(); - leftDisconnectedPaneContent.getChildren().addAll(disconnectedUsernameField, passwordField); - Button validationButton = new Button(GUIStringTool.getLoginButtonLabel()); validationButton.setOnMouseClicked(event-> validatorEventFirerer.fireValidationEvent()); validationButton.setOnKeyTyped(event->{if(event.getCode().equals(KeyCode.ENTER)) validatorEventFirerer.fireValidationEvent();}); - mainDisconnectedPane.getChildren().addAll(leftDisconnectedPaneContent, validationButton); + mainDisconnectedPane.getChildren().addAll(disconnectedUsernameField, passwordField, validationButton); refreshMainPane(); + display(null); } @Override public void display(Collection content) { - Platform.runLater(()->disconnectedUsernameField.setItems(FXCollections.observableArrayList(content))); + Platform.runLater(()->{ + if(content!=null && content.size()>0) + disconnectedUsernameField.setItems(FXCollections.observableArrayList(content)); + else{ + disconnectedUsernameField.getItems().clear(); + disconnectedUsernameField.getItems().add(new Account("null", "", AccountLevel.getLowest())); + } + }); } public void setCurrentAccount(Account account){ @@ -147,7 +153,10 @@ public class AccountManager implements IFXAccountsDisplayerComponent, IFXValidat @Override public boolean isCreationPossible() { return currentAccount==null + && disconnectedUsernameField.getAccessibleText()!=null && !disconnectedUsernameField.getAccessibleText().isEmpty() + && passwordField.getText()!=null && !passwordField.getText().isEmpty(); + } } From a10f397b06b24d202b2e923eaf40fbca8be66b0c Mon Sep 17 00:00:00 2001 From: Notmoo Date: Tue, 15 Aug 2017 00:42:20 +0200 Subject: [PATCH 10/36] Module Client, clss AccountService : Ajustement AccountService --- .../java/com/pqt/client/module/account/AccountService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/module/account/AccountService.java b/Workspace/client/src/main/java/com/pqt/client/module/account/AccountService.java index fd36f41e..9f6c76a0 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/account/AccountService.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/account/AccountService.java @@ -18,7 +18,7 @@ public class AccountService { } - public boolean isAccountLoggedIn(Account account) { + public boolean isCurrentAccountLoggedIn() { return false; } @@ -26,7 +26,7 @@ public class AccountService { } - public void logOutCurrentAccount(String password) { + public void logOutCurrentAccount() { } From 62eccf6528d23e23c56970a5a32b118e87299d44 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Tue, 15 Aug 2017 00:44:20 +0200 Subject: [PATCH 11/36] Module Client : ajout MainFrame; Ajout composant SideBar; Update dark-theme.css; Update GUICssTool et GUIStringTool --- .../src/main/java/com/pqt/client/Main.java | 13 +- .../pqt/client/gui/main_frame/MainFrame.java | 30 +++++ .../gui/main_frame/MainFrameController.java | 81 ++++++++++++ .../client/gui/main_frame/MainFrameModel.java | 65 ++++++++++ .../client/gui/main_frame/MainFrameView.java | 102 +++++++++++++++ .../listeners/IMainFrameModelListener.java | 8 ++ .../components/generics/others/SideBar.java | 118 ++++++++++++++++++ .../others/listeners/ISideBarListener.java | 9 ++ .../client/gui/ressources/css/GUICssTool.java | 8 ++ .../gui/ressources/strings/GUIStringTool.java | 18 ++- .../client/src/main/resources/dark-theme.css | 32 +++-- 11 files changed, 468 insertions(+), 16 deletions(-) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameModel.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/main_frame/listeners/IMainFrameModelListener.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/others/SideBar.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/others/listeners/ISideBarListener.java diff --git a/Workspace/client/src/main/java/com/pqt/client/Main.java b/Workspace/client/src/main/java/com/pqt/client/Main.java index 4eed78eb..a15ac623 100644 --- a/Workspace/client/src/main/java/com/pqt/client/Main.java +++ b/Workspace/client/src/main/java/com/pqt/client/Main.java @@ -1,12 +1,18 @@ package com.pqt.client; +import com.pqt.client.gui.main_frame.MainFrame; import com.pqt.client.gui.modules.sale_screen.SaleScreen; +import com.pqt.client.gui.ressources.components.generics.others.SideBar; +import com.pqt.client.gui.ressources.components.generics.others.listeners.ISideBarListener; import com.pqt.client.gui.ressources.css.GUICssTool; +import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.client.module.account.AccountService; import com.pqt.client.module.sale.SaleService; import com.pqt.client.module.stock.StockService; import javafx.application.Application; import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.layout.BorderPane; import javafx.stage.Stage; public class Main extends Application{ @@ -21,11 +27,14 @@ public class Main extends Application{ StockService stockService = new StockService(); AccountService accountService = new AccountService(); - SaleScreen saleScreen = new SaleScreen(accountService, stockService, saleService); - Scene scene = new Scene(saleScreen.getPane(), 800, 600); + MainFrame mainFrame = new MainFrame(accountService); + mainFrame.addModule(new SaleScreen(accountService, stockService, saleService)); + + Scene scene = new Scene(mainFrame.getPane(), 800, 600); scene.getStylesheets().clear(); scene.getStylesheets().addAll(getClass().getResource(GUICssTool.getCssFilePath()).toExternalForm()); + primaryStage.setTitle(GUIStringTool.getAppTitle()); primaryStage.setScene(scene); primaryStage.show(); } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java new file mode 100644 index 00000000..ea60287c --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java @@ -0,0 +1,30 @@ +package com.pqt.client.gui.main_frame; + +import com.pqt.client.gui.modules.IGuiModule; +import com.pqt.client.gui.ressources.components.generics.IFXComponent; +import com.pqt.client.module.account.AccountService; +import javafx.scene.layout.Pane; + +public class MainFrame implements IFXComponent { + + private MainFrameView view; + private MainFrameController ctrl; + + public MainFrame(AccountService accountService) { + MainFrameModel model = new MainFrameModel(accountService); + ctrl = new MainFrameController(model); + model.addListener(ctrl); + + view = new MainFrameView(ctrl); + ctrl.setView(view); + } + + public void addModule(IGuiModule module){ + ctrl.addModule(module); + } + + @Override + public Pane getPane() { + return view.getPane(); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java new file mode 100644 index 00000000..c432978e --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java @@ -0,0 +1,81 @@ +package com.pqt.client.gui.main_frame; + +import com.pqt.client.gui.main_frame.listeners.IMainFrameModelListener; +import com.pqt.client.gui.modules.IGuiModule; +import com.pqt.client.gui.ressources.components.generics.validators.listeners.IValidatorComponentListener; +import com.pqt.client.gui.ressources.components.specifics.account.listeners.IAccountComponentListener; +import com.pqt.core.entities.user_account.Account; +import javafx.event.Event; + +class MainFrameController implements IMainFrameModelListener { + + private MainFrameModel model; + private MainFrameView view; + private IValidatorComponentListener accountManagerAccountListener; + + MainFrameController(MainFrameModel model) { + this.model = model; + } + + void setView(MainFrameView view) { + this.view = view; + } + + void addModule(IGuiModule module) { + this.view.addGuiModule(module.getModuleName(),module.getPane()); + } + + IValidatorComponentListener getAccountManagerValidatorListener() { + return new IValidatorComponentListener() { + @Override + public void onValidationEvent() { + if(view.isAccountCreationPossible()) + model.connectAccount(view.create()); + } + + @Override + public void onCancelEvent() { + model.disconnectCurrentAccount(); + } + }; + } + + IAccountComponentListener getAccountManagerAccountListener() { + return new IAccountComponentListener() { + @Override + public void onRefreshContentRequestEvent() { + + } + + @Override + public void onContentClickEvent(Event event, Account eventTarget) { + + } + + @Override + public void onAddContentRequestEvent() { + + } + + @Override + public void onRemoveContentRequestEvent(Account content) { + + } + + @Override + public void onDetailContentRequestEvent(Account content) { + + } + }; + } + + @Override + public void onAccountStatusChangedEvent(boolean status) { + view.setCurrentAccount(model.getCurrentAccount()); + } + + @Override + public void onAccountCollectionChangedEvent() { + view.feedAccountCollectionToManager(model.getAccounts()); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameModel.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameModel.java new file mode 100644 index 00000000..c8cb5fc7 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameModel.java @@ -0,0 +1,65 @@ +package com.pqt.client.gui.main_frame; + +import com.pqt.client.gui.main_frame.listeners.IMainFrameModelListener; +import com.pqt.client.module.account.AccountService; +import com.pqt.client.module.account.listeners.IAccountListener; +import com.pqt.core.entities.user_account.Account; + +import javax.swing.event.EventListenerList; +import java.util.Arrays; +import java.util.Collection; + +class MainFrameModel { + + private EventListenerList listenerList; + private AccountService accountService; + + MainFrameModel(AccountService accountService) { + listenerList = new EventListenerList(); + this.accountService = accountService; + this.accountService.addListener(new IAccountListener() { + @Override + public void onAccountStatusChangedEvent(boolean status) { + MainFrameModel.this.fireAccountStatusChangedEvent(status); + } + + @Override + public void onAccountListChangedEvent() { + MainFrameModel.this.fireAccountCollectionChangedEvent(); + } + }); + } + + private void fireAccountCollectionChangedEvent() { + Arrays.stream(listenerList.getListeners(IMainFrameModelListener.class)).forEach(IMainFrameModelListener::onAccountCollectionChangedEvent); + } + + private void fireAccountStatusChangedEvent(boolean status) { + Arrays.stream(listenerList.getListeners(IMainFrameModelListener.class)).forEach(l->l.onAccountStatusChangedEvent(status)); + } + + void connectAccount(Account account) { + accountService.setCurrentAccount(account); + accountService.logInCurrentAccount(account.getPassword()); + } + + void disconnectCurrentAccount() { + accountService.logOutCurrentAccount(); + } + + Collection getAccounts(){ + return accountService.getAllAccounts(); + } + + void addListener(IMainFrameModelListener listener){ + listenerList.add(IMainFrameModelListener.class, listener); + } + + void removeListener(IMainFrameModelListener listener){ + listenerList.remove(IMainFrameModelListener.class, listener); + } + + Account getCurrentAccount() { + return accountService.getCurrentAccount(); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java new file mode 100644 index 00000000..12464cab --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java @@ -0,0 +1,102 @@ +package com.pqt.client.gui.main_frame; + +import com.pqt.client.gui.ressources.components.AccountManager; +import com.pqt.client.gui.ressources.components.generics.IFXComponent; +import com.pqt.client.gui.ressources.components.generics.others.SideBar; +import com.pqt.client.gui.ressources.components.generics.others.listeners.ISideBarListener; +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.core.entities.user_account.Account; +import javafx.geometry.Orientation; +import javafx.scene.control.Button; +import javafx.scene.control.ToolBar; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.Pane; +import javafx.scene.layout.Priority; + +import java.util.Collection; + +class MainFrameView implements IFXComponent{ + + private final MainFrameController ctrl; + + private BorderPane mainPane; + private ToolBar moduleListToolbar; + private AccountManager accountManager; + + MainFrameView(MainFrameController ctrl) { + + this.ctrl = ctrl; + initGui(); + } + + private void initGui(){ + mainPane = new BorderPane(); + mainPane.getStyleClass().addAll("main-module-pane", "main-frame"); + + moduleListToolbar = new ToolBar(); + moduleListToolbar.setOrientation(Orientation.VERTICAL); + + SideBar sidebar = new SideBar(); + sidebar.setFillWidth(true); + SideBar.setVgrow(moduleListToolbar, Priority.ALWAYS); + sidebar.getChildren().add(moduleListToolbar); + + accountManager = new AccountManager(); + accountManager.addListener(ctrl.getAccountManagerValidatorListener()); + accountManager.addListener(ctrl.getAccountManagerAccountListener()); + sidebar.getChildren().add(accountManager.getPane()); + + mainPane.setLeft(sidebar); + + Button sidebarCtrl = new Button(); + if(sidebar.isExpanded()) + sidebarCtrl.setText(GUIStringTool.getSideBarCollapseButtonLabel()); + else + sidebarCtrl.setText(GUIStringTool.getSideBarExpandButtonLabel()); + sidebarCtrl.setOnMouseClicked(event -> { + if(sidebar.isExpanded()) + sidebar.collapse(); + else if(sidebar.isCollapsed()) + sidebar.expand(); + }); + sidebar.addListener(new ISideBarListener() { + @Override + public void onCollapsedFinished() { + sidebarCtrl.setText(GUIStringTool.getSideBarExpandButtonLabel()); + } + + @Override + public void onExpandFinished() { + sidebarCtrl.setText(GUIStringTool.getSideBarCollapseButtonLabel()); + } + }); + mainPane.setTop(sidebarCtrl); + } + + @Override + public Pane getPane() { + return mainPane; + } + + void addGuiModule(String moduleName, Pane moduleContent){ + Button button = new Button(moduleName); + button.setOnMouseClicked(event->mainPane.setCenter(moduleContent)); + moduleListToolbar.getItems().add(button); + } + + boolean isAccountCreationPossible(){ + return accountManager.isCreationPossible(); + } + + Account create(){ + return accountManager.create(); + } + + void setCurrentAccount(Account account){ + accountManager.setCurrentAccount(account); + } + + void feedAccountCollectionToManager(Collection accounts){ + accountManager.display(accounts); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/listeners/IMainFrameModelListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/listeners/IMainFrameModelListener.java new file mode 100644 index 00000000..5c876e26 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/listeners/IMainFrameModelListener.java @@ -0,0 +1,8 @@ +package com.pqt.client.gui.main_frame.listeners; + +import java.util.EventListener; + +public interface IMainFrameModelListener extends EventListener{ + void onAccountStatusChangedEvent(boolean status); + void onAccountCollectionChangedEvent(); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/others/SideBar.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/others/SideBar.java new file mode 100644 index 00000000..94807320 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/others/SideBar.java @@ -0,0 +1,118 @@ +package com.pqt.client.gui.ressources.components.generics.others; + +import com.pqt.client.gui.ressources.components.generics.others.listeners.ISideBarListener; +import javafx.animation.Animation; +import javafx.animation.Transition; +import javafx.beans.value.ObservableValue; +import javafx.css.*; +import javafx.geometry.Pos; +import javafx.scene.Node; +import javafx.scene.layout.VBox; +import javafx.util.Duration; + +import javax.swing.event.EventListenerList; +import java.util.Arrays; +import java.util.List; + +public class SideBar extends VBox { + + private static final StyleablePropertyFactory FACTORY = new StyleablePropertyFactory<>(VBox.getClassCssMetaData()); + + private static final CssMetaData EXPANDED_WIDTH = + FACTORY.createSizeCssMetaData("-pqt-expanded-width",p->p.expandedWidth, 100, false); + + private StyleableProperty expandedWidth; + private EventListenerList listenerList; + private Animation collapseSideBar, expandSideBar; + + /** creates a sidebar containing a vertical alignment of the given nodes */ + public SideBar(Node... children) { + listenerList = new EventListenerList(); + getStyleClass().add("sidebar"); + this.setMinWidth(0); + this.expandedWidth = new SimpleStyleableDoubleProperty(EXPANDED_WIDTH, this, "expanded-width"); + this.setPrefWidth(expandedWidth.getValue().doubleValue()); + + setAlignment(Pos.CENTER); + getChildren().addAll(children); + + // create an animation to show a sidebar. + expandSideBar = new Transition() { + { + setCycleDuration(Duration.millis(250)); + } + protected void interpolate(double frac) { + final double curWidth = expandedWidth.getValue().doubleValue() * frac; + setPrefWidth(curWidth); + setTranslateX(-expandedWidth.getValue().doubleValue() + curWidth); + } + }; + expandSideBar.onFinishedProperty().set(actionEvent -> + Arrays.stream(listenerList.getListeners(ISideBarListener.class)) + .forEach(ISideBarListener::onExpandFinished) + ); + + + // create an animation to hide sidebar. + collapseSideBar = new Transition() { + { + setCycleDuration(Duration.millis(250)); + } + protected void interpolate(double frac) { + final double curWidth = expandedWidth.getValue().doubleValue() * (1.0 - frac); + setPrefWidth(curWidth); + setTranslateX(-expandedWidth.getValue().doubleValue() + curWidth); + } + }; + collapseSideBar.onFinishedProperty().set(actionEvent -> + Arrays.stream(listenerList.getListeners(ISideBarListener.class)) + .forEach(ISideBarListener::onCollapsedFinished)); + collapse(); + } + + public void expand(){ + if (expandSideBar.statusProperty().get() == Animation.Status.STOPPED + && collapseSideBar.statusProperty().get() == Animation.Status.STOPPED) { + if (!isVisible()) { + setVisible(true); + expandSideBar.play(); + } + } + } + + public void collapse(){ + if (expandSideBar.statusProperty().get() == Animation.Status.STOPPED + && collapseSideBar.statusProperty().get() == Animation.Status.STOPPED) { + if (isVisible()) { + collapseSideBar.play(); + setVisible(false); + } + } + } + + public boolean isExpanded(){ + return isVisible() && expandSideBar.statusProperty().get().equals(Animation.Status.STOPPED); + } + + public boolean isCollapsed() { + return !isVisible() && collapseSideBar.statusProperty().get().equals(Animation.Status.STOPPED); + } + + public void addListener(ISideBarListener listener){ + listenerList.add(ISideBarListener.class, listener); + } + + public void removeListener(ISideBarListener listener){ + listenerList.remove(ISideBarListener.class, listener); + } + + + public static List> getClassCssMetaData() { + return FACTORY.getCssMetaData(); + } + + @Override + public List> getCssMetaData() { + return FACTORY.getCssMetaData(); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/others/listeners/ISideBarListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/others/listeners/ISideBarListener.java new file mode 100644 index 00000000..2a1314ff --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/others/listeners/ISideBarListener.java @@ -0,0 +1,9 @@ +package com.pqt.client.gui.ressources.components.generics.others.listeners; + +import java.util.EventListener; + +public interface ISideBarListener extends EventListener { + + void onCollapsedFinished(); + void onExpandFinished(); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java index 3beba068..7c85140a 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java @@ -4,4 +4,12 @@ public class GUICssTool { public static String getCssFilePath(){ return "/dark-theme.css"; } + + public static String getCollapsedSideBarCssStyle() { + return "sidebar-collapsed"; + } + + public static String getExpandedSideBarCssStyle() { + return "sidebar-expanded"; + } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java index c4d5818a..0e58801d 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java @@ -56,7 +56,7 @@ public class GUIStringTool { @Override public String toString(Account object) { if(object!=null) - return String.format("%s - %s)", object.getUsername(), object.getPermissionLevel()); + return String.format("%s - (%s)", object.getUsername(), object.getPermissionLevel()); return "null"; } @@ -151,6 +151,22 @@ public class GUIStringTool { public static String getOkButtonLabel() { return "OK"; } + + public static String getAppTitle() { + return "Client PQT - Gargotte"; + } + + public static String getSideBarCollapseButtonLabel() { + return "Hide"; + } + + public static String getSideBarExpandButtonLabel() { + return "Show"; + } + + public static String getSaleGuiModuleName() { + return "Vente"; + } } diff --git a/Workspace/client/src/main/resources/dark-theme.css b/Workspace/client/src/main/resources/dark-theme.css index 5789bca8..7ba8b06a 100644 --- a/Workspace/client/src/main/resources/dark-theme.css +++ b/Workspace/client/src/main/resources/dark-theme.css @@ -114,7 +114,7 @@ -fx-background-color: black; } -.text-field { +.text-field, .password-field, .choice-box { -fx-font-size: 12pt; -fx-font-family: "Segoe UI Semibold"; -fx-pref-width: 125; @@ -173,17 +173,6 @@ -fx-background-color: derive(-fx-focus-color,30%); } -.choice-box { - -fx-pref-width: 150; - -fx-pref-height: 30; - -fx-background-radius: 0; - -fx-background-color: #1d1d1d; - -fx-background-insets: 0 0 0 0, 0, 1, 2; - -fx-border-color: #e2e2e2; - -fx-border-width: 2; - -fx-text-fill: #d8d8d8; -} - .progress-indicator { -fx-pref-width: 50; -fx-pref-height: 50; @@ -206,4 +195,21 @@ .validator .button{ -fx-pref-width: 150; -fx-pref-height: 50; - } \ No newline at end of file + } + +.sidebar { + -fx-background-color: #2e2e2e; + -fx-padding: 5 22 5 22; + -fx-border-color: #e2e2e2; + -fx-border-width: 2; + -fx-background-radius: 0; + -fx-background-insets: 0 0 0 0, 0, 1, 2; + -pqt-expanded-width : 200px; +} + +.tool-bar { + -fx-background-color: #2e2e2e; + -fx-padding: 5 5 5 5; + -fx-background-radius: 0; + -fx-background-insets: 0 0 0 0, 0, 1, 2; +} \ No newline at end of file From f817ae6ab3a69773ff0c93776ff1802941f79f12 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Tue, 15 Aug 2017 19:04:47 +0200 Subject: [PATCH 12/36] =?UTF-8?q?Module=20Client,=20main=20frame=20:=20ajo?= =?UTF-8?q?ut=20coloration=20diff=C3=A9rente=20pour=20le=20bouton=20du=20m?= =?UTF-8?q?odule=20affich=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pqt/client/gui/main_frame/MainFrameView.java | 16 +++++++++++++++- .../gui/ressources/strings/GUIStringTool.java | 6 ++---- .../client/src/main/resources/dark-theme.css | 10 ++++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java index 12464cab..a802ac71 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java @@ -6,7 +6,9 @@ import com.pqt.client.gui.ressources.components.generics.others.SideBar; import com.pqt.client.gui.ressources.components.generics.others.listeners.ISideBarListener; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.core.entities.user_account.Account; +import javafx.application.Platform; import javafx.geometry.Orientation; +import javafx.scene.Node; import javafx.scene.control.Button; import javafx.scene.control.ToolBar; import javafx.scene.layout.BorderPane; @@ -80,7 +82,19 @@ class MainFrameView implements IFXComponent{ void addGuiModule(String moduleName, Pane moduleContent){ Button button = new Button(moduleName); - button.setOnMouseClicked(event->mainPane.setCenter(moduleContent)); + button.getStyleClass().add("menu-button"); + button.setOnMouseClicked(event->{ + moduleListToolbar.getItems() + .stream() + .filter(Button.class::isInstance) + .map(Button.class::cast) + .forEach(b-> b.getStyleClass().remove("menu-button-selected")); + button.getStyleClass().add("menu-button-selected"); + Platform.runLater(()->{ + moduleListToolbar.getItems().forEach(Node::applyCss); + mainPane.setCenter(moduleContent); + }); + }); moduleListToolbar.getItems().add(button); } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java index 0e58801d..aa9574d9 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java @@ -13,8 +13,6 @@ import java.util.EnumSet; //TODO faire ça un peu mieux public class GUIStringTool { - private static String saleIdLabel; - public static String getValidationButtonLabel() { return "Valider"; } @@ -157,11 +155,11 @@ public class GUIStringTool { } public static String getSideBarCollapseButtonLabel() { - return "Hide"; + return "Réduire"; } public static String getSideBarExpandButtonLabel() { - return "Show"; + return "Menu"; } public static String getSaleGuiModuleName() { diff --git a/Workspace/client/src/main/resources/dark-theme.css b/Workspace/client/src/main/resources/dark-theme.css index 7ba8b06a..5049497a 100644 --- a/Workspace/client/src/main/resources/dark-theme.css +++ b/Workspace/client/src/main/resources/dark-theme.css @@ -173,6 +173,16 @@ -fx-background-color: derive(-fx-focus-color,30%); } +.menu-button-selected { + -fx-background-color: #d8d8d8; + -fx-text-fill: #1d1d1d; +} + +.menu-button-selected:hover { + -fx-background-color: white; + -fx-text-fill: #1d1d1d; +} + .progress-indicator { -fx-pref-width: 50; -fx-pref-height: 50; From eb594e029369d3e24e8fda2a3a0dac68da02e4e2 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Tue, 15 Aug 2017 19:05:09 +0200 Subject: [PATCH 13/36] =?UTF-8?q?Module=20Client=20:=20ajout=20=C3=A9cran?= =?UTF-8?q?=20stock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/pqt/client/Main.java | 4 +- .../gui/modules/stock_screen/StockScreen.java | 28 ++++ .../stock_screen/StockScreenController.java | 66 ++++++++ .../stock_screen/StockScreenModel.java | 56 +++++++ .../modules/stock_screen/StockScreenView.java | 157 ++++++++++++++++++ .../listeners/IStockItemEventListener.java | 7 + .../listeners/IStockScreenModelListener.java | 7 + .../gui/ressources/strings/GUIStringTool.java | 51 +++++- 8 files changed, 373 insertions(+), 3 deletions(-) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreen.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenController.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenModel.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/listeners/IStockItemEventListener.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/listeners/IStockScreenModelListener.java diff --git a/Workspace/client/src/main/java/com/pqt/client/Main.java b/Workspace/client/src/main/java/com/pqt/client/Main.java index a15ac623..f552abf4 100644 --- a/Workspace/client/src/main/java/com/pqt/client/Main.java +++ b/Workspace/client/src/main/java/com/pqt/client/Main.java @@ -2,6 +2,7 @@ package com.pqt.client; import com.pqt.client.gui.main_frame.MainFrame; import com.pqt.client.gui.modules.sale_screen.SaleScreen; +import com.pqt.client.gui.modules.stock_screen.StockScreen; import com.pqt.client.gui.ressources.components.generics.others.SideBar; import com.pqt.client.gui.ressources.components.generics.others.listeners.ISideBarListener; import com.pqt.client.gui.ressources.css.GUICssTool; @@ -11,8 +12,6 @@ import com.pqt.client.module.sale.SaleService; import com.pqt.client.module.stock.StockService; import javafx.application.Application; import javafx.scene.Scene; -import javafx.scene.control.Button; -import javafx.scene.layout.BorderPane; import javafx.stage.Stage; public class Main extends Application{ @@ -29,6 +28,7 @@ public class Main extends Application{ MainFrame mainFrame = new MainFrame(accountService); mainFrame.addModule(new SaleScreen(accountService, stockService, saleService)); + mainFrame.addModule(new StockScreen(stockService)); Scene scene = new Scene(mainFrame.getPane(), 800, 600); scene.getStylesheets().clear(); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreen.java new file mode 100644 index 00000000..3d9d298c --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreen.java @@ -0,0 +1,28 @@ +package com.pqt.client.gui.modules.stock_screen; + +import com.pqt.client.gui.modules.IGuiModule; +import com.pqt.client.module.stock.StockService; +import javafx.scene.layout.Pane; + +public class StockScreen implements IGuiModule { + + private StockScreenView view; + + public StockScreen(StockService stockService) { + StockScreenModel model = new StockScreenModel(stockService); + StockScreenController ctrl = new StockScreenController(model); + view = new StockScreenView(ctrl); + + ctrl.setView(view); + } + + @Override + public String getModuleName() { + return "Stock"; + } + + @Override + public Pane getPane() { + return view.getPane(); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenController.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenController.java new file mode 100644 index 00000000..a0847c7b --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenController.java @@ -0,0 +1,66 @@ +package com.pqt.client.gui.modules.stock_screen; + + +import com.pqt.client.gui.modules.stock_screen.listeners.IStockItemEventListener; +import com.pqt.client.gui.modules.stock_screen.listeners.IStockScreenModelListener; +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.core.entities.product.Product; + +class StockScreenController implements IStockScreenModelListener{ + + private StockScreenModel model; + private StockScreenView view; + + StockScreenController(StockScreenModel model) { + this.model = model; + } + + void setView(StockScreenView view) { + this.view = view; + } + + void onAddProductRequest() { + detailProduct(null); + } + + void onDetailProductRequest() { + detailProduct(view.getSelectedProduct()); + } + + private void detailProduct(Product product){ + //TODO à faire + } + + void onDeleteProductRequest() { + deleteProduct(view.getSelectedProduct()); + } + + private void addProduct(Product product){ + model.commitProductAddition(product); + } + + private void modifyProduct(Product oldProduct, Product newProduct){ + model.commitProductModification(oldProduct, newProduct); + } + + private void deleteProduct(Product product){ + model.commitProductDeletion(product);; + } + + void onRefreshProductsRequest() { + refreshView(); + } + + IStockItemEventListener getProductActivationListener() { + return this::detailProduct; + } + + private void refreshView(){ + view.display(model.getProductCollection()); + } + + @Override + public void onStockUpdatedEvent() { + refreshView(); + } +} 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 new file mode 100644 index 00000000..429120eb --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenModel.java @@ -0,0 +1,56 @@ +package com.pqt.client.gui.modules.stock_screen; + +import com.pqt.client.gui.modules.stock_screen.listeners.IStockScreenModelListener; +import com.pqt.client.module.stock.Listeners.StockListenerAdapter; +import com.pqt.client.module.stock.StockService; +import com.pqt.core.entities.product.Product; + +import javax.swing.event.EventListenerList; +import java.util.Arrays; +import java.util.Collection; + +class StockScreenModel { + + private StockService stockService; + private EventListenerList listenerList; + + StockScreenModel(StockService stockService) { + listenerList = new EventListenerList(); + this.stockService = stockService; + this.stockService.addListener(new StockListenerAdapter(){ + @Override + public void onProductListChangedEvent() { + StockScreenModel.this.fireProductCollectionChanged(); + } + }); + } + + private void fireProductCollectionChanged() { + Arrays.stream(listenerList.getListeners(IStockScreenModelListener.class)) + .forEach(IStockScreenModelListener::onStockUpdatedEvent); + } + + Collection getProductCollection() { + return stockService.getProducts(); + } + + void commitProductDeletion(Product product) { + + } + + void commitProductModification(Product oldProduct, Product newProduct) { + + } + + void commitProductAddition(Product product) { + + } + + void addListener(IStockScreenModelListener l){ + listenerList.add(IStockScreenModelListener.class, l); + } + + void removeListener(IStockScreenModelListener l){ + listenerList.remove(IStockScreenModelListener.class, l); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java new file mode 100644 index 00000000..bb167158 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java @@ -0,0 +1,157 @@ +package com.pqt.client.gui.modules.stock_screen; + +import com.pqt.client.gui.ressources.components.generics.IFXComponent; +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.client.gui.ressources.strings.IObjectStringRenderer; +import com.pqt.core.entities.product.Product; +import javafx.application.Platform; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.SimpleDoubleProperty; +import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.value.ObservableValue; +import javafx.scene.control.*; +import javafx.scene.input.KeyCode; +import javafx.scene.input.MouseButton; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Pane; +import javafx.scene.layout.Priority; +import javafx.util.Callback; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +class StockScreenView implements IFXComponent { + + private StockScreenController ctrl; + private Pane mainPane; + private TableView stockTableView; + + StockScreenView(StockScreenController ctrl) { + this.ctrl = ctrl; + initGui(); + } + + private void initGui() { + mainPane = new Pane(); + mainPane.getStyleClass().add("main-module-pane"); + BorderPane mainPaneContent = new BorderPane(); + mainPane.getChildren().add(mainPaneContent); + mainPaneContent.prefWidthProperty().bind(mainPane.widthProperty()); + mainPaneContent.prefHeightProperty().bind(mainPane.heightProperty()); + + Button addProductButton = new Button(GUIStringTool.getAddButtonLabel()); + addProductButton.setOnMouseClicked(event -> ctrl.onAddProductRequest()); + Button detailProductButton = new Button(GUIStringTool.getDetailButtonLabel()); + detailProductButton.setOnMouseClicked(event -> ctrl.onDetailProductRequest()); + Button removeProductButton = new Button(GUIStringTool.getRemoveButtonLabel()); + removeProductButton.setOnMouseClicked(event -> ctrl.onDeleteProductRequest()); + Button refreshProductButton = new Button(GUIStringTool.getRefreshButtonLabel()); + refreshProductButton.setOnMouseClicked(event -> ctrl.onRefreshProductsRequest()); + + ToolBar actionToolbar = new ToolBar(); + actionToolbar.getItems().addAll(addProductButton, detailProductButton, removeProductButton, refreshProductButton); + + HBox mainPaneTopContent = new HBox(); + HBox separator = new HBox(); + mainPaneTopContent.getChildren().addAll(separator, actionToolbar); + HBox.setHgrow(separator, Priority.ALWAYS); + mainPaneContent.setTop(mainPaneTopContent); + + stockTableView = new TableView<>(); + stockTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); + stockTableView.setRowFactory(tableView->{ + TableRow row = new TableRow<>(); + row.setOnMouseClicked(event -> { + if (event.getButton().equals(MouseButton.PRIMARY) && event.getClickCount() == 2) + ctrl.getProductActivationListener().onProductActivated(row.getItem()); + }); + row.setOnKeyTyped(event -> { + if (event.getCode().equals(KeyCode.ENTER)) + ctrl.getProductActivationListener().onProductActivated(row.getItem()); + }); + return row; + }); + stockTableView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); + List> columns = new ArrayList<>(); + + columns.add(createNewTableColumn(String.class, + GUIStringTool.getProductNameColumnHeader(), + param -> new SimpleStringProperty(param.getValue().getName()), + null + )); + columns.add(createNewTableColumn(String.class, + GUIStringTool.getProductCategoryColumnHeader(), + param -> new SimpleStringProperty(param.getValue().getCategory().getName()), + null + )); + columns.add(createNewTableColumn(Integer.class, + GUIStringTool.getProductAmountRemainingColumnHeader(), + param -> new SimpleIntegerProperty(param.getValue().getAmountRemaining()).asObject(), + null + )); + columns.add(createNewTableColumn(Integer.class, + GUIStringTool.getProductAmountSoldColumnHeader(), + param -> new SimpleIntegerProperty(param.getValue().getAmountSold()).asObject(), + null + )); + columns.add(createNewTableColumn(Double.class, + GUIStringTool.getProductPriceColumnHeader(), + param -> new SimpleDoubleProperty(param.getValue().getAmountSold()).asObject(), + GUIStringTool.getPriceRenderer() + )); + columns.add(createNewTableColumn(Boolean.class, + GUIStringTool.getProductIsSellableColumnHeader(), + param -> new SimpleBooleanProperty(param.getValue().isSellable()), + GUIStringTool.getBooleanRenderer() + )); + + stockTableView.getColumns().addAll(columns); + mainPaneContent.setCenter(stockTableView); + } + + private TableColumn createNewTableColumn(Class clazz, + String header, + Callback, ObservableValue> cellValueFactory, + IObjectStringRenderer renderer){ + TableColumn column = new TableColumn<>(); + if(header!=null) + column.setText(header); + if(cellValueFactory!=null) + column.setCellValueFactory(cellValueFactory); + if(renderer!=null) + column.setCellFactory(table -> new TableCell() { + @Override + protected void updateItem(T item, boolean empty) { + super.updateItem(item, empty); + if (item == null || empty) { + setText(null); + setStyle(""); + } else { + setText(renderer.render(item)); + } + } + } + ); + + return column; + } + + void display(Collection productCollection){ + Platform.runLater(()->{ + this.stockTableView.getItems().clear(); + this.stockTableView.getItems().addAll(productCollection); + }); + } + + @Override + public Pane getPane() { + return mainPane; + } + + Product getSelectedProduct() { + return stockTableView.getSelectionModel().getSelectedItem(); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/listeners/IStockItemEventListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/listeners/IStockItemEventListener.java new file mode 100644 index 00000000..08e002eb --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/listeners/IStockItemEventListener.java @@ -0,0 +1,7 @@ +package com.pqt.client.gui.modules.stock_screen.listeners; + +import com.pqt.core.entities.product.Product; + +public interface IStockItemEventListener { + void onProductActivated(Product product); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/listeners/IStockScreenModelListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/listeners/IStockScreenModelListener.java new file mode 100644 index 00000000..b4035570 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/listeners/IStockScreenModelListener.java @@ -0,0 +1,7 @@ +package com.pqt.client.gui.modules.stock_screen.listeners; + +import java.util.EventListener; + +public interface IStockScreenModelListener extends EventListener { + void onStockUpdatedEvent(); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java index aa9574d9..c70207f8 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java @@ -34,7 +34,12 @@ public class GUIStringTool { } public static IObjectStringRenderer getProductStringRenderer(){ - return product->String.format("%s - %.2f€ (%s)", product.getName(), product.getPrice(), (product.getAmountRemaining()>=30?"30+": Integer.toString(product.getAmountRemaining()))); + return product->{ + if(product!=null) + return String.format("%s - %.2f€ (%s)", product.getName(), product.getPrice(), (product.getAmountRemaining()>=30?"30+": Integer.toString(product.getAmountRemaining()))); + else + return "null"; + }; } public static String getCommandComposerTitleTitle() { @@ -165,6 +170,50 @@ public class GUIStringTool { public static String getSaleGuiModuleName() { return "Vente"; } + + public static String getAddButtonLabel() { + return "Ajouter"; + } + + public static String getDetailButtonLabel() { + return "Détail"; + } + + public static String getRemoveButtonLabel() { + return "Supprimer"; + } + + public static String getRefreshButtonLabel() { + return "Rafraichir"; + } + + public static String getProductNameColumnHeader() { + return "Nom"; + } + + public static String getProductCategoryColumnHeader() { + return "Catégorie"; + } + + public static String getProductAmountRemainingColumnHeader() { + return "Stock"; + } + + public static String getProductAmountSoldColumnHeader() { + return "Vendu"; + } + + public static String getProductPriceColumnHeader() { + return "Prix"; + } + + public static String getProductIsSellableColumnHeader() { + return "Vendable"; + } + + public static IObjectStringRenderer getBooleanRenderer() { + return bool->bool?"Oui":"Non"; + } } From 517ac8bdeb92a28b61916b7bf083062ca9f57ee6 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Tue, 15 Aug 2017 21:46:48 +0200 Subject: [PATCH 14/36] =?UTF-8?q?Module=20Client=20:=20ajout=20=C3=A9cran?= =?UTF-8?q?=20stat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/pqt/client/Main.java | 4 ++ .../gui/modules/stat_screen/StatScreen.java | 29 +++++++++++ .../stat_screen/StatScreenController.java | 22 ++++++++ .../modules/stat_screen/StatScreenModel.java | 38 ++++++++++++++ .../modules/stat_screen/StatScreenView.java | 52 +++++++++++++++++++ .../listeners/IStatScreenModelListener.java | 7 +++ .../gui/ressources/strings/GUIStringTool.java | 4 ++ .../client/src/main/resources/dark-theme.css | 11 +++- 8 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreen.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenController.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenModel.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenView.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/listeners/IStatScreenModelListener.java diff --git a/Workspace/client/src/main/java/com/pqt/client/Main.java b/Workspace/client/src/main/java/com/pqt/client/Main.java index f552abf4..8e364c0f 100644 --- a/Workspace/client/src/main/java/com/pqt/client/Main.java +++ b/Workspace/client/src/main/java/com/pqt/client/Main.java @@ -2,6 +2,7 @@ package com.pqt.client; import com.pqt.client.gui.main_frame.MainFrame; import com.pqt.client.gui.modules.sale_screen.SaleScreen; +import com.pqt.client.gui.modules.stat_screen.StatScreen; import com.pqt.client.gui.modules.stock_screen.StockScreen; import com.pqt.client.gui.ressources.components.generics.others.SideBar; import com.pqt.client.gui.ressources.components.generics.others.listeners.ISideBarListener; @@ -9,6 +10,7 @@ import com.pqt.client.gui.ressources.css.GUICssTool; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.client.module.account.AccountService; import com.pqt.client.module.sale.SaleService; +import com.pqt.client.module.stat.StatService; import com.pqt.client.module.stock.StockService; import javafx.application.Application; import javafx.scene.Scene; @@ -25,10 +27,12 @@ public class Main extends Application{ SaleService saleService = new SaleService(); StockService stockService = new StockService(); AccountService accountService = new AccountService(); + StatService statService = new StatService(); MainFrame mainFrame = new MainFrame(accountService); mainFrame.addModule(new SaleScreen(accountService, stockService, saleService)); mainFrame.addModule(new StockScreen(stockService)); + mainFrame.addModule(new StatScreen(statService)); Scene scene = new Scene(mainFrame.getPane(), 800, 600); scene.getStylesheets().clear(); 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 new file mode 100644 index 00000000..3634cc8b --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreen.java @@ -0,0 +1,29 @@ +package com.pqt.client.gui.modules.stat_screen; + +import com.pqt.client.gui.modules.IGuiModule; +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.client.module.stat.StatService; +import javafx.scene.layout.Pane; + +public class StatScreen implements IGuiModule { + + private StatScreenView view; + + public StatScreen(StatService statService) { + StatScreenModel model = new StatScreenModel(statService); + StatScreenController ctrl = new StatScreenController(model); + view = new StatScreenView(); + + ctrl.setView(view); + } + + @Override + public String getModuleName() { + return GUIStringTool.getStatGuiModuleName(); + } + + @Override + public Pane getPane() { + return view.getPane(); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenController.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenController.java new file mode 100644 index 00000000..5f2510e3 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenController.java @@ -0,0 +1,22 @@ +package com.pqt.client.gui.modules.stat_screen; + +import com.pqt.client.gui.modules.stat_screen.listeners.IStatScreenModelListener; + +class StatScreenController implements IStatScreenModelListener{ + + private StatScreenModel model; + private StatScreenView view; + + StatScreenController(StatScreenModel model) { + this.model = model; + } + + void setView(StatScreenView view) { + this.view = view; + } + + @Override + public void onStatisticsChangedEvent() { + view.display(model.getStatistics()); + } +} 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 new file mode 100644 index 00000000..2add8f38 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenModel.java @@ -0,0 +1,38 @@ +package com.pqt.client.gui.modules.stat_screen; + +import com.pqt.client.gui.modules.stat_screen.listeners.IStatScreenModelListener; +import com.pqt.client.module.stat.StatService; +import com.pqt.client.module.stat.listeners.IStatListener; +import com.pqt.client.module.stat.listeners.StatListenerAdapter; + +import javax.swing.event.EventListenerList; +import java.util.Arrays; +import java.util.Map; + +class StatScreenModel { + private EventListenerList listenerList; + private StatService statService; + + StatScreenModel(StatService statService) { + this.statService = statService; + listenerList = new EventListenerList(); + this.statService.addListener(new StatListenerAdapter() { + @Override + public void onGetStatSuccess() { + Arrays.stream(listenerList.getListeners(IStatScreenModelListener.class)).forEach(IStatScreenModelListener::onStatisticsChangedEvent); + } + }); + } + + Map getStatistics() { + return statService.getStats(); + } + + void addListener(IStatScreenModelListener l){ + listenerList.add(IStatScreenModelListener.class, l); + } + + void removeListener(IStatScreenModelListener l){ + listenerList.remove(IStatScreenModelListener.class, l); + } +} 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 new file mode 100644 index 00000000..5fd5485d --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/StatScreenView.java @@ -0,0 +1,52 @@ +package com.pqt.client.gui.modules.stat_screen; + +import com.pqt.client.gui.ressources.components.generics.IFXComponent; +import com.sun.deploy.util.StringUtils; +import javafx.application.Platform; +import javafx.scene.control.TextArea; +import javafx.scene.layout.Pane; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +class StatScreenView implements IFXComponent { + + private TextArea statTextArea; + private Pane mainPane; + + StatScreenView() { + initGui(); + } + + private void initGui() { + mainPane = new Pane(); + mainPane.getStyleClass().add("main-module-pane"); + + statTextArea = new TextArea(); + mainPane.getChildren().add(statTextArea); + statTextArea.setId("stat-screen-text-area"); + statTextArea.setWrapText(true); + statTextArea.setEditable(false); + statTextArea.prefWidthProperty().bind(mainPane.widthProperty()); + statTextArea.prefHeightProperty().bind(mainPane.heightProperty()); + } + + void display(Map statistics){ + List lines = new ArrayList<>(); + + if(statistics!=null) + lines.addAll(statistics.keySet() + .stream() + .map(key->String.format(" * %s : %s", key, statistics.get(key))) + .collect(Collectors.toList())); + + Platform.runLater(()->statTextArea.setText(StringUtils.join(lines, "\n"))); + } + + @Override + public Pane getPane() { + return mainPane; + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/listeners/IStatScreenModelListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/listeners/IStatScreenModelListener.java new file mode 100644 index 00000000..c02c49f8 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stat_screen/listeners/IStatScreenModelListener.java @@ -0,0 +1,7 @@ +package com.pqt.client.gui.modules.stat_screen.listeners; + +import java.util.EventListener; + +public interface IStatScreenModelListener extends EventListener { + void onStatisticsChangedEvent(); +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java index c70207f8..4dcb8bd3 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java @@ -214,6 +214,10 @@ public class GUIStringTool { public static IObjectStringRenderer getBooleanRenderer() { return bool->bool?"Oui":"Non"; } + + public static String getStatGuiModuleName() { + return "Statistiques"; + } } diff --git a/Workspace/client/src/main/resources/dark-theme.css b/Workspace/client/src/main/resources/dark-theme.css index 5049497a..4e154cd3 100644 --- a/Workspace/client/src/main/resources/dark-theme.css +++ b/Workspace/client/src/main/resources/dark-theme.css @@ -114,7 +114,7 @@ -fx-background-color: black; } -.text-field, .password-field, .choice-box { +.text-field, .password-field, .choice-box, .text-area { -fx-font-size: 12pt; -fx-font-family: "Segoe UI Semibold"; -fx-pref-width: 125; @@ -127,6 +127,15 @@ -fx-text-fill: #d8d8d8; } +.text-area .content { + -fx-background-color: #1d1d1d; + -fx-padding: 15 15 15 15; +} + +#stat-screen-text-area { + -fx-border-width: 0; +} + .button { -fx-padding: 5 22 5 22; -fx-border-color: #e2e2e2; From 11be8f08892f1b79c4f1efde8675498d280c2f24 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Thu, 17 Aug 2017 23:44:39 +0200 Subject: [PATCH 15/36] =?UTF-8?q?Module=20client=20:=20ajout=20composant?= =?UTF-8?q?=20Toast=20+=20factory=20associ=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/pqt/client/Main.java | 2 + .../components/generics/toast/Toast.java | 54 +++++++++++++++++++ .../generics/toast/ToastFactory.java | 46 ++++++++++++++++ .../client/src/main/resources/dark-theme.css | 14 +++++ 4 files changed, 116 insertions(+) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/toast/Toast.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/toast/ToastFactory.java diff --git a/Workspace/client/src/main/java/com/pqt/client/Main.java b/Workspace/client/src/main/java/com/pqt/client/Main.java index 8e364c0f..f65aa47c 100644 --- a/Workspace/client/src/main/java/com/pqt/client/Main.java +++ b/Workspace/client/src/main/java/com/pqt/client/Main.java @@ -6,6 +6,7 @@ import com.pqt.client.gui.modules.stat_screen.StatScreen; import com.pqt.client.gui.modules.stock_screen.StockScreen; import com.pqt.client.gui.ressources.components.generics.others.SideBar; import com.pqt.client.gui.ressources.components.generics.others.listeners.ISideBarListener; +import com.pqt.client.gui.ressources.components.generics.toast.ToastFactory; import com.pqt.client.gui.ressources.css.GUICssTool; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.client.module.account.AccountService; @@ -38,6 +39,7 @@ public class Main extends Application{ scene.getStylesheets().clear(); scene.getStylesheets().addAll(getClass().getResource(GUICssTool.getCssFilePath()).toExternalForm()); + ToastFactory.init(primaryStage); primaryStage.setTitle(GUIStringTool.getAppTitle()); primaryStage.setScene(scene); primaryStage.show(); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/toast/Toast.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/toast/Toast.java new file mode 100644 index 00000000..051cc5ac --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/toast/Toast.java @@ -0,0 +1,54 @@ +package com.pqt.client.gui.ressources.components.generics.toast; + +import com.pqt.client.gui.ressources.css.GUICssTool; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Scene; +import javafx.scene.layout.StackPane; +import javafx.scene.paint.Color; +import javafx.scene.text.Text; +import javafx.stage.Stage; +import javafx.stage.StageStyle; +import javafx.util.Duration; + +final class Toast { + static void toast(Stage ownerStage, String toastMsg, int toastDelay, int fadeInDelay, int fadeOutDelay) { + Stage toastStage = new Stage(); + toastStage.initOwner(ownerStage); + toastStage.setResizable(false); + toastStage.initStyle(StageStyle.TRANSPARENT); + + Text text = new Text(toastMsg); + text.getStyleClass().add("toast-text"); + + StackPane root = new StackPane(text); + root.getStyleClass().add("toast-pane"); + root.setOpacity(0); + + Scene scene = new Scene(root); + scene.setFill(Color.TRANSPARENT); + scene.getStylesheets().addAll(Toast.class.getResource(GUICssTool.getCssFilePath()).toExternalForm()); + toastStage.setScene(scene); + toastStage.show(); + + Timeline fadeInTimeline = new Timeline(); + KeyFrame fadeInKey1 = new KeyFrame(Duration.millis(fadeInDelay), new KeyValue (toastStage.getScene().getRoot().opacityProperty(), 1)); + fadeInTimeline.getKeyFrames().add(fadeInKey1); + fadeInTimeline.setOnFinished((ae) -> + new Thread(() -> { + try { + Thread.sleep(toastDelay); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + Timeline fadeOutTimeline = new Timeline(); + KeyFrame fadeOutKey1 = new KeyFrame(Duration.millis(fadeOutDelay), new KeyValue (toastStage.getScene().getRoot().opacityProperty(), 0)); + fadeOutTimeline.getKeyFrames().add(fadeOutKey1); + fadeOutTimeline.setOnFinished((aeb) -> toastStage.close()); + fadeOutTimeline.play(); + }).start()); + fadeInTimeline.play(); + } +} \ No newline at end of file diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/toast/ToastFactory.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/toast/ToastFactory.java new file mode 100644 index 00000000..d174244e --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/toast/ToastFactory.java @@ -0,0 +1,46 @@ +package com.pqt.client.gui.ressources.components.generics.toast; + +import javafx.stage.Stage; + +public class ToastFactory { + + private static ToastFactory INSTANCE = null; + + private Stage stage; + private int delay, fadeInDelay, fadeOutDelay; + + private ToastFactory(Stage stage){ + this.stage = stage; + delay = 3000; + fadeInDelay = 250; + fadeOutDelay = 250; + } + + public void setToastDelay(int msDelay){ + this.delay = msDelay; + } + + public void setToastFadeInDelay(int msDelay){ + this.fadeInDelay = msDelay; + } + + public void setToastFadeOutDelay(int msDelay){ + this.fadeOutDelay = msDelay; + } + + public void toast(String message){ + Toast.toast(stage, message, delay, fadeInDelay, fadeOutDelay); + } + + public static void init(Stage stage){ + INSTANCE = new ToastFactory(stage); + } + + public static boolean isInitialized(){ + return INSTANCE!=null; + } + + public static ToastFactory getINSTANCE(){ + return INSTANCE; + } +} diff --git a/Workspace/client/src/main/resources/dark-theme.css b/Workspace/client/src/main/resources/dark-theme.css index 4e154cd3..273b47a2 100644 --- a/Workspace/client/src/main/resources/dark-theme.css +++ b/Workspace/client/src/main/resources/dark-theme.css @@ -231,4 +231,18 @@ -fx-padding: 5 5 5 5; -fx-background-radius: 0; -fx-background-insets: 0 0 0 0, 0, 1, 2; + +.toast-text{ + -fx-font: 50px "Impact"; + -fx-fill: whitesmoke; +} + +.toast-pane { + -fx-background-radius: 10px; + -fx-background-color: rgba(0, 0, 0, 0.4); + -fx-border-width: 2px; + -fx-border-color: whitesmoke; + -fx-border-radius: 6px; + -fx-padding: 25px; +} } \ No newline at end of file From bf089d325c2844e4ee5aaa65e1b907b37dadad05 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Thu, 17 Aug 2017 23:45:59 +0200 Subject: [PATCH 16/36] =?UTF-8?q?Module=20Client,=20packg=20gui.main=5Ffra?= =?UTF-8?q?me=20:=20ajout=20possibilit=C3=A9=20de=20passer=20un=20module?= =?UTF-8?q?=20en=20actif=20=C3=A0=20l'ajout;=20ajout=20TODO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/pqt/client/Main.java | 3 ++- .../pqt/client/gui/main_frame/MainFrame.java | 6 ++++- .../gui/main_frame/MainFrameController.java | 4 ++-- .../client/gui/main_frame/MainFrameView.java | 22 +++++++++++-------- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/Main.java b/Workspace/client/src/main/java/com/pqt/client/Main.java index f65aa47c..5e978bc4 100644 --- a/Workspace/client/src/main/java/com/pqt/client/Main.java +++ b/Workspace/client/src/main/java/com/pqt/client/Main.java @@ -31,9 +31,10 @@ public class Main extends Application{ StatService statService = new StatService(); MainFrame mainFrame = new MainFrame(accountService); - mainFrame.addModule(new SaleScreen(accountService, stockService, saleService)); + mainFrame.addModule(new SaleScreen(accountService, stockService, saleService), true); mainFrame.addModule(new StockScreen(stockService)); mainFrame.addModule(new StatScreen(statService)); + //TODO ajouter un module AccountScreen Scene scene = new Scene(mainFrame.getPane(), 800, 600); scene.getStylesheets().clear(); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java index ea60287c..bc1674a6 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java @@ -20,7 +20,11 @@ public class MainFrame implements IFXComponent { } public void addModule(IGuiModule module){ - ctrl.addModule(module); + ctrl.addModule(module, false); + } + + public void addModule(IGuiModule module, boolean setActive){ + ctrl.addModule(module, setActive); } @Override diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java index c432978e..43686466 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java @@ -21,8 +21,8 @@ class MainFrameController implements IMainFrameModelListener { this.view = view; } - void addModule(IGuiModule module) { - this.view.addGuiModule(module.getModuleName(),module.getPane()); + void addModule(IGuiModule module, boolean setActive) { + this.view.addGuiModule(module.getModuleName(),module.getPane(), setActive); } IValidatorComponentListener getAccountManagerValidatorListener() { diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java index a802ac71..5793fa3d 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java @@ -14,6 +14,7 @@ import javafx.scene.control.ToolBar; import javafx.scene.layout.BorderPane; import javafx.scene.layout.Pane; import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; import java.util.Collection; @@ -22,8 +23,8 @@ class MainFrameView implements IFXComponent{ private final MainFrameController ctrl; private BorderPane mainPane; - private ToolBar moduleListToolbar; private AccountManager accountManager; + private VBox buttonHolder; MainFrameView(MainFrameController ctrl) { @@ -35,17 +36,18 @@ class MainFrameView implements IFXComponent{ mainPane = new BorderPane(); mainPane.getStyleClass().addAll("main-module-pane", "main-frame"); - moduleListToolbar = new ToolBar(); - moduleListToolbar.setOrientation(Orientation.VERTICAL); + buttonHolder = new VBox(); SideBar sidebar = new SideBar(); sidebar.setFillWidth(true); - SideBar.setVgrow(moduleListToolbar, Priority.ALWAYS); - sidebar.getChildren().add(moduleListToolbar); + SideBar.setVgrow(buttonHolder, Priority.ALWAYS); + buttonHolder.prefWidthProperty().bind(sidebar.widthProperty()); + sidebar.getChildren().add(buttonHolder); accountManager = new AccountManager(); accountManager.addListener(ctrl.getAccountManagerValidatorListener()); accountManager.addListener(ctrl.getAccountManagerAccountListener()); + accountManager.getPane().prefWidthProperty().bind(sidebar.widthProperty()); sidebar.getChildren().add(accountManager.getPane()); mainPane.setLeft(sidebar); @@ -80,22 +82,24 @@ class MainFrameView implements IFXComponent{ return mainPane; } - void addGuiModule(String moduleName, Pane moduleContent){ + void addGuiModule(String moduleName, Pane moduleContent, boolean setActive){ Button button = new Button(moduleName); button.getStyleClass().add("menu-button"); button.setOnMouseClicked(event->{ - moduleListToolbar.getItems() + buttonHolder.getChildren() .stream() .filter(Button.class::isInstance) .map(Button.class::cast) .forEach(b-> b.getStyleClass().remove("menu-button-selected")); button.getStyleClass().add("menu-button-selected"); Platform.runLater(()->{ - moduleListToolbar.getItems().forEach(Node::applyCss); + buttonHolder.getChildren().forEach(Node::applyCss); mainPane.setCenter(moduleContent); }); }); - moduleListToolbar.getItems().add(button); + if(setActive) + button.getOnMouseClicked().handle(null); + buttonHolder.getChildren().add(button); } boolean isAccountCreationPossible(){ From 3efe9476b72a8918b2c961d9305daefeeda52b38 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Thu, 17 Aug 2017 23:47:42 +0200 Subject: [PATCH 17/36] =?UTF-8?q?Module=20Client=20:=20Ajout=20m=C3=A9thod?= =?UTF-8?q?es=20GUICssTool=20et=20GUIStringTool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/gui/ressources/css/GUICssTool.java | 16 +++++ .../gui/ressources/strings/GUIStringTool.java | 60 ++++++++++++++++++- 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java index 7c85140a..69b4fdc2 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java @@ -12,4 +12,20 @@ public class GUICssTool { public static String getExpandedSideBarCssStyle() { return "sidebar-expanded"; } + + public static String getMainModulePaneCssClass() { + return "main-module-pane"; + } + + public static String getIntermediaryPaneStyleClass() { + return "grey-intermediary-pane"; + } + + public static String getTitleTextStyleClass() { + return "label-header"; + } + + public static String getContainerStyleClass() { + return "pqt-container"; + } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java index 4dcb8bd3..22fe69f3 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java @@ -1,5 +1,6 @@ package com.pqt.client.gui.ressources.strings; +import com.pqt.core.entities.product.Category; import com.pqt.core.entities.product.Product; import com.pqt.core.entities.sale.SaleStatus; import com.pqt.core.entities.sale.SaleType; @@ -33,7 +34,7 @@ public class GUIStringTool { return "Produits"; } - public static IObjectStringRenderer getProductStringRenderer(){ + public static IObjectStringRenderer getDetailledProductStringRenderer(){ return product->{ if(product!=null) return String.format("%s - %.2f€ (%s)", product.getName(), product.getPrice(), (product.getAmountRemaining()>=30?"30+": Integer.toString(product.getAmountRemaining()))); @@ -42,6 +43,15 @@ public class GUIStringTool { }; } + public static IObjectStringRenderer getSimpleProductStringRenderer(){ + return product->{ + if(product!=null) + return String.format("%s - %.2f€", product.getName(), product.getPrice()); + else + return "null"; + }; + } + public static String getCommandComposerTitleTitle() { return "Commande"; } @@ -218,6 +228,54 @@ public class GUIStringTool { public static String getStatGuiModuleName() { return "Statistiques"; } + + public static String getProductNameLabel() { + return "Nom : "; + } + + public static String getProductCategoryLabel() { + return "Catégorie : "; + } + + public static String getProductAmountRemainingLabel() { + return "En stock : "; + } + + public static String getProductAmountSoldLabel() { + return "Vendu : "; + } + + public static String getProductSellableLabel() { + return "Vendable : "; + } + + public static String getProductPriceLabel() { + return "Prix : "; + } + + public static StringConverter getCategoryStringConverter() { + return new StringConverter() { + @Override + public String toString(Category object) { + if(object!=null) + return object.getName(); + else + return ""; + } + + @Override + public Category fromString(String string) { + if(string!=null) + return new Category(-1, string); + else + return null; + } + }; + } + + public static String getComponentListTitleLabel() { + return "Composants"; + } } From 26e94d8078b2e8e65f0b70482d08c786ea701c56 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Thu, 17 Aug 2017 23:48:32 +0200 Subject: [PATCH 18/36] Module Client, packg gui.ressources.components.generics.javafx_override : ajout clss HighlightListCell --- .../javafx_override/HighlightListCell.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/HighlightListCell.java diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/HighlightListCell.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/HighlightListCell.java new file mode 100644 index 00000000..7bab5db3 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/HighlightListCell.java @@ -0,0 +1,18 @@ +package com.pqt.client.gui.ressources.components.generics.javafx_override; + +import javafx.scene.control.ListCell; + +public class HighlightListCell extends ListCell { + public void setHighLight(boolean highLight){ + if(highLight){ + if(!getStyleClass().contains("list-cell-highlighted")) + getStyleClass().add("list-cell-highlighted"); + } + else + getStyleClass().remove("list-cell-highlighted"); + } + + public boolean isHightlighted(){ + return getStyleClass().contains("list-cell-highlighted"); + } +} From 651f9766018e3d1a0b967e255ef095185458f79a Mon Sep 17 00:00:00 2001 From: Notmoo Date: Thu, 17 Aug 2017 23:49:05 +0200 Subject: [PATCH 19/36] =?UTF-8?q?Module=20Core,=20clss=20Product=20:=20upd?= =?UTF-8?q?ate=20m=C3=A9thode=20equals();=20ajout=20TODO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/pqt/core/entities/product/Product.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Workspace/core/src/main/java/com/pqt/core/entities/product/Product.java b/Workspace/core/src/main/java/com/pqt/core/entities/product/Product.java index ec5d5074..6c40e894 100644 --- a/Workspace/core/src/main/java/com/pqt/core/entities/product/Product.java +++ b/Workspace/core/src/main/java/com/pqt/core/entities/product/Product.java @@ -6,7 +6,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Objects; - +//TODO faire en sorte que les composés reprennent les qté dispo des composants /** * Created by Notmoo on 18/07/2017. */ @@ -123,6 +123,7 @@ public class Product implements ILoggable, Serializable{ return this.id == other.id && Objects.equals(this.name, other.name) && Objects.equals(this.components, other.components) - && Objects.equals(this.category, other.category); + && Objects.equals(this.category, other.category) + && Objects.equals(this.price, other.price); } } From aaaa45039eceaa41ffd214e5d8f388c9564b4c04 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Thu, 17 Aug 2017 23:51:58 +0200 Subject: [PATCH 20/36] =?UTF-8?q?Module=20Client,=20=C3=A9cran=20stock=20:?= =?UTF-8?q?=20ajout=20des=20classes=20de=20l'=C3=A9cran=20stocks;=20divers?= =?UTF-8?q?es=20modifications=20annexes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/modules/stock_screen/StockScreen.java | 5 +- .../stock_screen/StockScreenController.java | 30 ++- .../modules/stock_screen/StockScreenView.java | 78 ++++++- .../ProductManagerScreen.java | 56 +++++ .../ProductManagerScreenController.java | 93 ++++++++ .../ProductManagerScreenFactory.java | 17 ++ .../ProductManagerScreenModel.java | 100 ++++++++ .../ProductManagerScreenView.java | 213 ++++++++++++++++++ .../pqt/client/module/sale/SaleBuilder.java | 39 +++- .../com/pqt/client/module/stock/StockDao.java | 8 +- .../pqt/client/module/stock/StockService.java | 33 ++- .../client/src/main/resources/dark-theme.css | 9 + 12 files changed, 650 insertions(+), 31 deletions(-) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreen.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenController.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenFactory.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenModel.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenView.java diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreen.java index 3d9d298c..64f4e145 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreen.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreen.java @@ -1,6 +1,8 @@ package com.pqt.client.gui.modules.stock_screen; import com.pqt.client.gui.modules.IGuiModule; +import com.pqt.client.gui.modules.stock_screen.product_manager_screen.ProductManagerScreen; +import com.pqt.client.gui.modules.stock_screen.product_manager_screen.ProductManagerScreenFactory; import com.pqt.client.module.stock.StockService; import javafx.scene.layout.Pane; @@ -11,9 +13,10 @@ public class StockScreen implements IGuiModule { public StockScreen(StockService stockService) { StockScreenModel model = new StockScreenModel(stockService); StockScreenController ctrl = new StockScreenController(model); - view = new StockScreenView(ctrl); + view = new StockScreenView(ctrl, new ProductManagerScreenFactory(stockService)); ctrl.setView(view); + ctrl.refreshView(); } @Override diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenController.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenController.java index a0847c7b..2d85f01d 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenController.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenController.java @@ -3,6 +3,8 @@ package com.pqt.client.gui.modules.stock_screen; import com.pqt.client.gui.modules.stock_screen.listeners.IStockItemEventListener; import com.pqt.client.gui.modules.stock_screen.listeners.IStockScreenModelListener; +import com.pqt.client.gui.modules.stock_screen.product_manager_screen.ProductManagerScreen; +import com.pqt.client.gui.ressources.components.generics.validators.listeners.IValidatorComponentListener; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.core.entities.product.Product; @@ -24,11 +26,33 @@ class StockScreenController implements IStockScreenModelListener{ } void onDetailProductRequest() { - detailProduct(view.getSelectedProduct()); + if(view.getSelectedProduct()!=null) + detailProduct(view.getSelectedProduct()); } private void detailProduct(Product product){ - //TODO à faire + view.switchToDetailMode(product); + } + + IValidatorComponentListener getDetailScreenValidationListener(){ + return new IValidatorComponentListener() { + @Override + public void onValidationEvent() { + if(view.isDetailScreenCreationPossible()) { + if (view.hasDetailScreenInitialValue()){ + modifyProduct(view.getDetailScreenInitialValue(), view.getDetailScreenCreation()); + }else{ + addProduct(view.getDetailScreenCreation()); + } + view.switchToGeneralMode(); + } + } + + @Override + public void onCancelEvent() { + view.switchToGeneralMode(); + } + }; } void onDeleteProductRequest() { @@ -55,7 +79,7 @@ class StockScreenController implements IStockScreenModelListener{ return this::detailProduct; } - private void refreshView(){ + void refreshView(){ view.display(model.getProductCollection()); } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java index bb167158..c3a16606 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java @@ -1,6 +1,9 @@ package com.pqt.client.gui.modules.stock_screen; +import com.pqt.client.gui.modules.stock_screen.product_manager_screen.ProductManagerScreen; +import com.pqt.client.gui.modules.stock_screen.product_manager_screen.ProductManagerScreenFactory; import com.pqt.client.gui.ressources.components.generics.IFXComponent; +import com.pqt.client.gui.ressources.css.GUICssTool; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.client.gui.ressources.strings.IObjectStringRenderer; import com.pqt.core.entities.product.Product; @@ -10,34 +13,37 @@ import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.value.ObservableValue; +import javafx.scene.Node; import javafx.scene.control.*; import javafx.scene.input.KeyCode; import javafx.scene.input.MouseButton; -import javafx.scene.layout.BorderPane; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Pane; -import javafx.scene.layout.Priority; +import javafx.scene.layout.*; import javafx.util.Callback; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; class StockScreenView implements IFXComponent { private StockScreenController ctrl; - private Pane mainPane; + private StackPane mainPane; + private BorderPane mainPaneContent; private TableView stockTableView; + private ProductManagerScreenFactory productManagerScreenFactory; + private ProductManagerScreen currentDetailScreen; - StockScreenView(StockScreenController ctrl) { + StockScreenView(StockScreenController ctrl, ProductManagerScreenFactory productManagerScreenFactory) { this.ctrl = ctrl; + this.productManagerScreenFactory = productManagerScreenFactory; initGui(); } private void initGui() { - mainPane = new Pane(); - mainPane.getStyleClass().add("main-module-pane"); - BorderPane mainPaneContent = new BorderPane(); + mainPane = new StackPane(); + mainPane.getStyleClass().add(GUICssTool.getMainModulePaneCssClass()); + mainPaneContent = new BorderPane(); mainPane.getChildren().add(mainPaneContent); mainPaneContent.prefWidthProperty().bind(mainPane.widthProperty()); mainPaneContent.prefHeightProperty().bind(mainPane.heightProperty()); @@ -46,7 +52,9 @@ class StockScreenView implements IFXComponent { addProductButton.setOnMouseClicked(event -> ctrl.onAddProductRequest()); Button detailProductButton = new Button(GUIStringTool.getDetailButtonLabel()); detailProductButton.setOnMouseClicked(event -> ctrl.onDetailProductRequest()); + detailProductButton.setDisable(true); Button removeProductButton = new Button(GUIStringTool.getRemoveButtonLabel()); + removeProductButton.setDisable(true); removeProductButton.setOnMouseClicked(event -> ctrl.onDeleteProductRequest()); Button refreshProductButton = new Button(GUIStringTool.getRefreshButtonLabel()); refreshProductButton.setOnMouseClicked(event -> ctrl.onRefreshProductsRequest()); @@ -75,6 +83,10 @@ class StockScreenView implements IFXComponent { return row; }); stockTableView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); + stockTableView.getSelectionModel().selectedItemProperty().addListener((obs, oldVal, newVal)->{ + detailProductButton.setDisable(newVal==null); + removeProductButton.setDisable(newVal==null); + }); List> columns = new ArrayList<>(); columns.add(createNewTableColumn(String.class, @@ -99,7 +111,7 @@ class StockScreenView implements IFXComponent { )); columns.add(createNewTableColumn(Double.class, GUIStringTool.getProductPriceColumnHeader(), - param -> new SimpleDoubleProperty(param.getValue().getAmountSold()).asObject(), + param -> new SimpleDoubleProperty(param.getValue().getPrice()).asObject(), GUIStringTool.getPriceRenderer() )); columns.add(createNewTableColumn(Boolean.class, @@ -154,4 +166,50 @@ class StockScreenView implements IFXComponent { Product getSelectedProduct() { return stockTableView.getSelectionModel().getSelectedItem(); } + + void switchToDetailMode(Product product) { + if(currentDetailScreen==null){ + currentDetailScreen = productManagerScreenFactory.create(product); + currentDetailScreen.addListener(ctrl.getDetailScreenValidationListener()); + Pane separator = new Pane(); + separator.getStyleClass().add(GUICssTool.getIntermediaryPaneStyleClass()); + Platform.runLater(()->mainPane.getChildren().addAll(separator, currentDetailScreen.getPane())); + } + } + + void switchToGeneralMode() { + if(currentDetailScreen!=null){ + List toRemove = mainPane.getChildren() + .stream() + .filter(node->!node.equals(mainPaneContent)) + .collect(Collectors.toList()); + Platform.runLater(()->{ + mainPane.getChildren().removeAll(toRemove); + currentDetailScreen = null; + }); + } + } + + boolean isDetailScreenCreationPossible() { + System.out.println("test creation possible : "); + return currentDetailScreen!=null && currentDetailScreen.isCreationPossible(); + } + + boolean hasDetailScreenInitialValue() { + return currentDetailScreen!=null && currentDetailScreen.hasInitialValue(); + } + + Product getDetailScreenInitialValue() { + if(currentDetailScreen!=null) + return currentDetailScreen.getInitialValueSnapshot(); + else + return null; + } + + Product getDetailScreenCreation() { + if(currentDetailScreen!=null) + return currentDetailScreen.create(); + else + return null; + } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreen.java new file mode 100644 index 00000000..d5aee803 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreen.java @@ -0,0 +1,56 @@ +package com.pqt.client.gui.modules.stock_screen.product_manager_screen; + +import com.pqt.client.gui.ressources.components.generics.creators.IFXCreatorComponent; +import com.pqt.client.gui.ressources.components.generics.validators.IFXValidatorComponent; +import com.pqt.client.gui.ressources.components.generics.validators.listeners.IValidatorComponentListener; +import com.pqt.client.module.stock.StockService; +import com.pqt.core.entities.product.Product; +import javafx.scene.layout.Pane; + +public class ProductManagerScreen implements IFXCreatorComponent, IFXValidatorComponent { + + private ProductManagerScreenView view; + private ProductManagerScreenModel model; + private ProductManagerScreenController ctrl; + + public ProductManagerScreen(Product initialData, StockService stockService){ + model = new ProductManagerScreenModel(initialData, stockService); + ctrl = new ProductManagerScreenController(model); + view = new ProductManagerScreenView(ctrl); + ctrl.setView(view); + ctrl.updateView(); + } + + @Override + public Product create() { + return model.create(); + } + + @Override + public boolean isCreationPossible() { + return model.isProductCreationPossible(); + } + + @Override + public Pane getPane() { + return view.getPane(); + } + + @Override + public void addListener(IValidatorComponentListener l) { + ctrl.addListener(l); + } + + @Override + public void removeListener(IValidatorComponentListener l) { + ctrl.removeListener(l); + } + + public boolean hasInitialValue(){ + return model.hasInitialData(); + } + + public Product getInitialValueSnapshot(){ + return new Product(model.getInitialData()); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenController.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenController.java new file mode 100644 index 00000000..b948bf82 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenController.java @@ -0,0 +1,93 @@ +package com.pqt.client.gui.modules.stock_screen.product_manager_screen; + +import com.pqt.client.gui.ressources.components.generics.validators.listeners.IValidatorComponentListener; +import com.pqt.core.entities.product.Category; +import com.pqt.core.entities.product.Product; +import javafx.beans.value.ChangeListener; + +import javax.swing.event.EventListenerList; +import java.util.Arrays; + +class ProductManagerScreenController { + + private EventListenerList listenerList; + private ProductManagerScreenModel model; + private ProductManagerScreenView view; + + ProductManagerScreenController(ProductManagerScreenModel model) { + listenerList = new EventListenerList(); + this.model = model; + } + + void setView(ProductManagerScreenView view){ + this.view = view; + } + + ChangeListener getProductComponentSelectionListener() { + return (obs, oldValue, newValue)->{ + if(newValue!=null) { + if (model.isComponent(newValue)) + model.removeComponent(newValue); + else + model.addComponent(newValue); + updateView(); + } + }; + } + + void updateView() { + view.setProduct(model.getActualProductState()); + view.setCategoryCollection(model.getCategoryCollection()); + view.setProductCollection(model.getEligibleComponentList()); + } + + IValidatorComponentListener getValidatorListener() { + return new IValidatorComponentListener() { + @Override + public void onValidationEvent() { + Arrays.stream(listenerList.getListeners(IValidatorComponentListener.class)).forEach(IValidatorComponentListener::onValidationEvent); + } + + @Override + public void onCancelEvent() { + Arrays.stream(listenerList.getListeners(IValidatorComponentListener.class)).forEach(IValidatorComponentListener::onCancelEvent); + } + }; + } + + public void addListener(IValidatorComponentListener l) { + listenerList.add(IValidatorComponentListener.class, l); + } + + public void removeListener(IValidatorComponentListener l) { + listenerList.remove(IValidatorComponentListener.class, l); + } + + boolean isProductHighlighted(Product product) { + return model.getActualProductState().getComponents().contains(product); + } + + void onNameChanged(String oldVal, String newVal) { + model.changeName(newVal); + } + + void onPriceChanged(double oldVal, double newVal) { + model.changePrice(newVal); + } + + void onCategoryChanged(Category oldVal, Category newVal) { + model.changeCategory(newVal); + } + + void onAmountRemainingChanged(int oldVal, int newVal) { + model.changeAmountRemaining(newVal); + } + + void onAmountSoldChanged(int oldVal, int newVal) { + model.changeAmountSold(newVal); + } + + void onSellableStateChanged(boolean oldVal, boolean newVal) { + model.setSellable(newVal); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenFactory.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenFactory.java new file mode 100644 index 00000000..c583115c --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenFactory.java @@ -0,0 +1,17 @@ +package com.pqt.client.gui.modules.stock_screen.product_manager_screen; + +import com.pqt.client.module.stock.StockService; +import com.pqt.core.entities.product.Product; + +public final class ProductManagerScreenFactory { + + private StockService stockService; + + public ProductManagerScreenFactory(StockService stockService) { + this.stockService = stockService; + } + + public ProductManagerScreen create(Product product){ + return new ProductManagerScreen(product, stockService); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenModel.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenModel.java new file mode 100644 index 00000000..962390fb --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenModel.java @@ -0,0 +1,100 @@ +package com.pqt.client.gui.modules.stock_screen.product_manager_screen; + +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.client.module.stock.StockService; +import com.pqt.core.entities.product.Category; +import com.pqt.core.entities.product.LightweightProduct; +import com.pqt.core.entities.product.Product; + +import java.util.*; +import java.util.stream.Collectors; + +class ProductManagerScreenModel { + + private StockService stockService; + private Product initialData; + private Product currentData; + + ProductManagerScreenModel(Product initialData, StockService stockService) { + this.stockService = stockService; + this.initialData = initialData; + if(initialData==null) + currentData = new Product(); + else + currentData = new Product(initialData); + } + + List getEligibleComponentList() { + return stockService.getProductsExcluding(currentData); + } + + Product getActualProductState(){ + return currentData; + } + + Product create() { + if(isProductCreationPossible()) + return currentData; + else + return null; + } + + boolean isProductCreationPossible() { + return (initialData!=null && !currentData.equals(initialData)) + && !currentData.getName().isEmpty() + && currentData.getCategory()!=null + && currentData.getPrice()>=0; + } + + void addComponent(Product product) { + currentData.getComponents().add(product); + } + + void removeComponent(Product product) { + currentData.getComponents().remove(product); + } + + void changeCategory(Category category){ + this.currentData.setCategory(category); + } + + void changePrice(double price){ + this.currentData.setPrice(price); + } + + void changeName(String name){ + this.currentData.setName(name); + } + + void changeAmountRemaining(int amount){ + this.currentData.setAmountRemaining(amount); + } + + void changeAmountSold(int amount){ + this.currentData.setAmountSold(amount); + } + + void setSellable(boolean sellable){ + this.currentData.setSellable(sellable); + } + + Collection getCategoryCollection() { + return stockService.getProducts() + .stream() + .map(Product::getCategory) + .distinct() + .collect(Collectors.toList()); + } + + boolean isComponent(Product product) { + return currentData.getComponents().contains(product); + } + + boolean hasInitialData(){ + return initialData!=null; + } + + Product getInitialData(){ + return initialData; + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenView.java new file mode 100644 index 00000000..3ece4942 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenView.java @@ -0,0 +1,213 @@ +package com.pqt.client.gui.modules.stock_screen.product_manager_screen; + +import com.pqt.client.gui.ressources.components.SimpleValidator; +import com.pqt.client.gui.ressources.components.generics.IFXComponent; +import com.pqt.client.gui.ressources.components.generics.javafx_override.CssEnabledGridPane; +import com.pqt.client.gui.ressources.components.generics.javafx_override.HighlightListCell; +import com.pqt.client.gui.ressources.css.GUICssTool; +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.core.entities.product.Category; +import com.pqt.core.entities.product.Product; +import javafx.application.Platform; +import javafx.geometry.Pos; +import javafx.scene.Node; +import javafx.scene.control.*; +import javafx.scene.layout.*; + +import java.text.NumberFormat; +import java.text.ParseException; +import java.util.Collection; + +class ProductManagerScreenView implements IFXComponent { + + private ProductManagerScreenController ctrl; + + private int gridLines; + private StackPane mainPane; + private BorderPane mainPaneContent; + private TextField productNameTextField, + productAmountRemainingTextField, + productAmountSoldTextField, + productPriceTextField; + private ComboBox productCategoryComboBox; + private CheckBox productSellableCheckBox; + private ListView productComponentsListView; + + ProductManagerScreenView(ProductManagerScreenController ctrl) { + this.ctrl = ctrl; + initGui(); + } + + private void initGui() { + mainPane = new StackPane(); + mainPane.getStyleClass().add(GUICssTool.getMainModulePaneCssClass()); + + mainPaneContent = new BorderPane(); + + GridPane mainPaneCenterContent = new CssEnabledGridPane(); + mainPaneCenterContent.setAlignment(Pos.CENTER); + gridLines = 0; + NumberFormat priceFormat = NumberFormat.getNumberInstance(); + NumberFormat intFormat = NumberFormat.getIntegerInstance(); + + Label productNameLabel = new Label(GUIStringTool.getProductNameLabel()); + productNameTextField = new TextField(); + productNameTextField.textProperty().addListener((obs, oldVal, newVal)->ctrl.onNameChanged(oldVal,newVal)); + addLineToGrid(mainPaneCenterContent, productNameLabel, productNameTextField); + + Label productCategoryLabel = new Label(GUIStringTool.getProductCategoryLabel()); + productCategoryComboBox = new ComboBox<>(); + productCategoryComboBox.setEditable(true); + productCategoryComboBox.setConverter(GUIStringTool.getCategoryStringConverter()); + productCategoryComboBox.valueProperty().addListener((obs, oldVal, newVal)->ctrl.onCategoryChanged(oldVal, newVal)); + addLineToGrid(mainPaneCenterContent, productCategoryLabel, productCategoryComboBox); + + Label productAmountRemainingLabel = new Label(GUIStringTool.getProductAmountRemainingLabel()); + productAmountRemainingTextField = getNumberOnlyTextField(intFormat); + productAmountRemainingTextField.textProperty().addListener((obs, oldVal, newVal)->{ + try{ + int oldInt = oldVal.isEmpty()?0:Integer.parseInt(oldVal); + int newInt = newVal.isEmpty()?0:Integer.parseInt(newVal); + ctrl.onAmountRemainingChanged(oldInt, newInt); + }catch(NumberFormatException e){ + e.printStackTrace(); + } + }); + addLineToGrid(mainPaneCenterContent, productAmountRemainingLabel, productAmountRemainingTextField); + + Label productAmountSoldLabel = new Label(GUIStringTool.getProductAmountSoldLabel()); + productAmountSoldTextField = getNumberOnlyTextField(intFormat); + productAmountSoldTextField.textProperty().addListener((obs, oldVal, newVal)->{ + try{ + int oldInt = oldVal.isEmpty()?0:Integer.parseInt(oldVal); + int newInt = newVal.isEmpty()?0:Integer.parseInt(newVal); + ctrl.onAmountSoldChanged(oldInt, newInt); + }catch(NumberFormatException e){ + e.printStackTrace(); + } + }); + addLineToGrid(mainPaneCenterContent, productAmountSoldLabel, productAmountSoldTextField); + + Label productSellableLabel = new Label(GUIStringTool.getProductSellableLabel()); + productSellableCheckBox = new CheckBox(); + productSellableCheckBox.selectedProperty().addListener((obs, oldVal, newVal)->ctrl.onSellableStateChanged(oldVal,newVal)); + addLineToGrid(mainPaneCenterContent, productSellableLabel, productSellableCheckBox); + + Label productPriceLabel = new Label(GUIStringTool.getProductPriceLabel()); + productPriceTextField = getNumberOnlyTextField(priceFormat); + productPriceTextField.textProperty().addListener((obs, oldVal, newVal)->{ + try{ + ctrl.onPriceChanged((oldVal.isEmpty()?-1:Double.parseDouble(oldVal)), (newVal.isEmpty()?-1:Double.parseDouble(newVal))); + }catch(NumberFormatException e){ + e.printStackTrace(); + } + }); + addLineToGrid(mainPaneCenterContent, productPriceLabel, productPriceTextField); + + mainPaneContent.setCenter(mainPaneCenterContent); + + VBox mainPaneRightContent = new VBox(); + mainPaneRightContent.getStyleClass().add(GUICssTool.getContainerStyleClass()); + mainPaneRightContent.setAlignment(Pos.CENTER); + Label title = new Label(GUIStringTool.getComponentListTitleLabel()); + title.setAlignment(Pos.CENTER); + title.getStyleClass().add(GUICssTool.getTitleTextStyleClass()); + productComponentsListView = new ListView<>(); + productComponentsListView.setCellFactory(listView->new HighlightListCell(){ + @Override + protected void updateItem(Product item, boolean empty) { + super.updateItem(item, empty); + if(item==null || empty){ + setText(null); + setGraphic(null); + }else{ + setText(GUIStringTool.getSimpleProductStringRenderer().render(item)); + if(ctrl.isProductHighlighted(item)){ + if(!isHightlighted()) { + setHighLight(true); + applyCss(); + } + }else { + if (isHightlighted()) { + setHighLight(false); + applyCss(); + } + } + } + } + }); + productComponentsListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); + productComponentsListView.getSelectionModel().selectedItemProperty().addListener((obs, oldValue, newValue)->{ + this.ctrl.getProductComponentSelectionListener().changed(obs, oldValue, newValue); + if(newValue!=null) + Platform.runLater(()->productComponentsListView.getSelectionModel().clearSelection(productComponentsListView.getSelectionModel().getSelectedIndex())); + }); + + mainPaneRightContent.getChildren().addAll(title, productComponentsListView); + mainPaneContent.setRight(mainPaneRightContent); + + HBox mainPaneBottomContent = new HBox(); + HBox separator = new HBox(); + SimpleValidator validator = new SimpleValidator(); + validator.addListener(ctrl.getValidatorListener()); + mainPaneBottomContent.getChildren().addAll(separator, validator.getPane()); + HBox.setHgrow(separator, Priority.ALWAYS); + + mainPaneContent.setBottom(mainPaneBottomContent); + mainPane.getChildren().add(mainPaneContent); + } + + private void addLineToGrid(GridPane grid, Node... nodes){ + gridLines++; + int columnIndex = 0; + for(Node node : nodes){ + grid.add(node, columnIndex, gridLines); + columnIndex++; + } + } + + private TextField getNumberOnlyTextField(NumberFormat format){ + TextField textField = new TextField(); + textField.textProperty().addListener((obs, oldValue, newValue)->{ + if(!newValue.matches("^[-+]?[0-9]+[.,]?[0-9]*$")) + Platform.runLater(()->textField.setText(oldValue)); + }); + return textField; + } + + @Override + public Pane getPane() { + return mainPane; + } + + void setProduct(Product product){ + if(product!=null){ + Platform.runLater(()->{ + productNameTextField.setText(product.getName()); + productCategoryComboBox.setValue(product.getCategory()); + productAmountRemainingTextField.setText(Integer.toString(product.getAmountRemaining())); + productAmountRemainingTextField.setEditable(product.getComponents().isEmpty()); + productAmountSoldTextField.setText(Integer.toString(product.getAmountSold())); + productComponentsListView.getItems().clear(); + productComponentsListView.getItems().addAll(product.getComponents()); + productSellableCheckBox.setSelected(product.isSellable()); + productPriceTextField.setText(Double.toString(product.getPrice())); + }); + } + + } + + void setCategoryCollection(Collection categoryCollection){ + Platform.runLater(()->{ + productCategoryComboBox.getItems().clear(); + productCategoryComboBox.getItems().addAll(categoryCollection); + }); + } + + void setProductCollection(Collection productCollection){ + Platform.runLater(()->{ + productComponentsListView.getItems().clear(); + productComponentsListView.getItems().addAll(productCollection); + }); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleBuilder.java b/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleBuilder.java index 4c550960..a70bac00 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleBuilder.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleBuilder.java @@ -1,5 +1,6 @@ package com.pqt.client.module.sale; +import com.pqt.client.module.stock.StockDao; import com.pqt.core.entities.members.Client; import com.pqt.core.entities.product.Product; import com.pqt.core.entities.sale.Sale; @@ -7,9 +8,7 @@ import com.pqt.core.entities.sale.SaleStatus; import com.pqt.core.entities.sale.SaleType; import com.pqt.core.entities.user_account.Account; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.util.*; //TODO écrire javadoc public class SaleBuilder { @@ -26,18 +25,40 @@ public class SaleBuilder { } public SaleBuilder addProduct(Product product) { - if(products.containsKey(product)){ - //Check for sufficient stock - if(product.getAmountRemaining() rank0Products = new HashMap<>(); + collectRank0Products(newProduct, requiredAmount, rank0Products); + products.keySet().forEach(oldProduct->collectRank0Products(oldProduct, products.get(oldProduct), rank0Products)); + + return rank0Products.keySet() + .stream() + .filter(rank0Product->rank0Product.getAmountRemaining() collector){ + if(rootProduct.getComponents().isEmpty()){ + if(collector.containsKey(rootProduct)) + collector.replace(rootProduct, collector.get(rootProduct)+rootProductAmount); + else + collector.put(rootProduct, rootProductAmount); + }else{ + rootProduct.getComponents().forEach(product->collectRank0Products(product, rootProductAmount, collector)); + } + } + public SaleBuilder removeProduct(Product product) { if(products.containsKey(product)) { if (products.get(product) == 1) 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 d682f84f..08439d66 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 @@ -33,12 +33,8 @@ public class StockDao { } public synchronized Product getProduct(final int id) { - Optional match = products.stream().filter((product->product.getId()==id)).findFirst(); - if(match.isPresent()) - return match.get(); - - return null; - } + return products.stream().filter((product->product.getId()==id)).findFirst().orElse(null); + } public void refreshProductList() { QueryExecutor.INSTANCE.execute(QueryFactory.newStockQuery(), new IStockQueryCallback() { diff --git a/Workspace/client/src/main/java/com/pqt/client/module/stock/StockService.java b/Workspace/client/src/main/java/com/pqt/client/module/stock/StockService.java index 559fa0ae..8c2e67aa 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/stock/StockService.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/stock/StockService.java @@ -39,7 +39,8 @@ public class StockService { /** * Accesseur de la liste des produits actuellement en vente. *

- * La liste peut être obsolète, voir {@link #getLastRefreshTimestamp()} pour la date du dernier refresh et {@link #refreshProductList()} pour la mettre à jour. + * La liste peut être obsolète, voir {@link #getLastRefreshTimestamp()} pour la date du dernier refresh et + * {@link #refreshProductList()} pour la mettre à jour. * * @return Liste des produits en vente. */ @@ -47,6 +48,35 @@ public class StockService { return dao.getProducts(); } + /** + * Récupère la liste des produits n'étant pas {@code product} et n'étant pas composé de {@code product}. + * Les composants sont récursivements vérifiés pour que ces derniers valident aussi ces deux conditions. + *

+ * La liste peut être obsolète, voir {@link #getLastRefreshTimestamp()} pour la date du dernier refresh et + * {@link #refreshProductList()} pour la mettre à jour. + * + * @param product produit à exclure des résultats. + * @return Liste de produit n'étant pas et ne contenant pas {@code product}. + */ + public List getProductsExcluding(Product product) { + return dao.getProducts(); + } + + private boolean contains(Product container, Product contained){ + if(container==null || contained==null) + return false; + if(container.equals(contained)) + return true; + + if(container.getComponents()!=null) + return container.getComponents() + .stream() + .filter(component->contains(component, contained)) + .count()>0; + + return false; + } + /** * Accesseur récupérant un unique produit présent dans les stocks en se basant sur son id. * @@ -100,5 +130,4 @@ public class StockService { public void removeListener(IStockListener listener) { dao.removeListener(listener); } - } diff --git a/Workspace/client/src/main/resources/dark-theme.css b/Workspace/client/src/main/resources/dark-theme.css index 273b47a2..b71e5642 100644 --- a/Workspace/client/src/main/resources/dark-theme.css +++ b/Workspace/client/src/main/resources/dark-theme.css @@ -43,6 +43,9 @@ .list-view:focused .list-cell:filled:focused:selected { -fx-background-color: -fx-focus-color; } +.list-cell-highlighted{ + -fx-background-color: #4d4d4d; +} .table-view { -fx-base: #1d1d1d; @@ -231,6 +234,7 @@ -fx-padding: 5 5 5 5; -fx-background-radius: 0; -fx-background-insets: 0 0 0 0, 0, 1, 2; +} .toast-text{ -fx-font: 50px "Impact"; @@ -245,4 +249,9 @@ -fx-border-radius: 6px; -fx-padding: 25px; } + +.pqt-container { + -fx-border-width: 2px; + -fx-border-color: whitesmoke; + -fx-padding: 5 5 5 5; } \ No newline at end of file From 1d0628ffe93c1743fd759b877014715b25d58dba Mon Sep 17 00:00:00 2001 From: Notmoo Date: Thu, 17 Aug 2017 23:52:46 +0200 Subject: [PATCH 21/36] =?UTF-8?q?Module=20Client=20:=20ajustements=20GUI?= =?UTF-8?q?=20(=C3=A9cran=20de=20vente)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sale_screen/SaleScreenController.java | 22 +++++++--- .../modules/sale_screen/SaleScreenView.java | 5 ++- .../SaleValidationScreen.java | 2 + .../modules/stat_screen/StatScreenView.java | 3 +- .../components/CategoryTabStockDisplayer.java | 12 +++-- .../CommandComposerSaleDisplayer.java | 8 +++- .../client/src/main/resources/dark-theme.css | 44 ++++++++++++++++--- 7 files changed, 75 insertions(+), 21 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java index 5a65ebc5..b3abd1e8 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java @@ -65,14 +65,20 @@ class SaleScreenController { return model.getCurrentSale(); } - void updateView(){ + private void updateSale(){ + view.setSale(getCurrentSale()); + view.setValidationButtonEnabled(model.checkValidity(getCurrentSale())); + } + + private void updateData(){ view.setProducts(fetchProductList()); view.setSaleTypes(fetchSaleTypeList()); view.setAccounts(fetchAccountList()); + } - view.setSale(getCurrentSale()); - - view.setValidationButtonEnabled(model.checkValidity(getCurrentSale())); + void updateView(){ + updateData(); + updateSale(); } private List fetchProductList(){ @@ -90,7 +96,7 @@ class SaleScreenController { @Override public void onComponentClickEvent(Event event, Product product) { model.removeProductFromSale(product); - SaleScreenController.this.updateView(); + SaleScreenController.this.updateSale(); } @Override @@ -117,8 +123,10 @@ class SaleScreenController { @Override public void onContentClickEvent(Event event, Product eventTarget) { - model.addProductToSale(eventTarget); - SaleScreenController.this.updateView(); + if(eventTarget!=null) { + model.addProductToSale(eventTarget); + SaleScreenController.this.updateSale(); + } } @Override diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java index 24adaa81..f3595839 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenView.java @@ -5,6 +5,7 @@ import com.pqt.client.gui.ressources.components.CommandComposerSaleDisplayer; import com.pqt.client.gui.ressources.components.SimpleValidator; import com.pqt.client.gui.ressources.components.generics.javafx_override.CssEnabledGridPane; import com.pqt.client.gui.ressources.components.generics.IFXComponent; +import com.pqt.client.gui.ressources.css.GUICssTool; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.client.gui.ressources.components.CategoryTabStockDisplayer; import com.pqt.core.entities.product.Product; @@ -45,7 +46,7 @@ class SaleScreenView implements IFXComponent { private void initGui() { mainPane = new StackPane(); - mainPane.getStyleClass().add("main-module-pane"); + mainPane.getStyleClass().add(GUICssTool.getMainModulePaneCssClass()); mainPaneContent = new BorderPane(); @@ -142,7 +143,7 @@ class SaleScreenView implements IFXComponent { Pane greyIntermediaryPane = new Pane(); greyIntermediaryPane.getStyleClass().clear(); - greyIntermediaryPane.getStyleClass().add("grey-intermediary-pane"); + greyIntermediaryPane.getStyleClass().add(GUICssTool.getIntermediaryPaneStyleClass()); saleValidationScreen = new SaleValidationScreen(saleId, sale); saleValidationScreen.addListener(ctrl.getSaleValidationScreenListener()); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/sale_validation_screen/SaleValidationScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/sale_validation_screen/SaleValidationScreen.java index 9153b679..93a4b7c8 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/sale_validation_screen/SaleValidationScreen.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/sale_validation_screen/SaleValidationScreen.java @@ -2,6 +2,7 @@ package com.pqt.client.gui.modules.sale_screen.sale_validation_screen; import com.pqt.client.gui.modules.sale_screen.sale_validation_screen.listeners.ISaleValidationScreenListener; import com.pqt.client.gui.ressources.components.generics.javafx_override.CssEnabledGridPane; +import com.pqt.client.gui.ressources.css.GUICssTool; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.core.entities.sale.Sale; import com.pqt.core.entities.sale.SaleStatus; @@ -32,6 +33,7 @@ public class SaleValidationScreen { public SaleValidationScreen(long saleId, Sale sale) { listeners = new EventListenerList(); mainPane = new Pane(); + mainPane.getStyleClass().add(GUICssTool.getMainModulePaneCssClass()); saleStatus = sale.getStatus(); 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 5fd5485d..ca13ed3d 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 @@ -1,6 +1,7 @@ package com.pqt.client.gui.modules.stat_screen; import com.pqt.client.gui.ressources.components.generics.IFXComponent; +import com.pqt.client.gui.ressources.css.GUICssTool; import com.sun.deploy.util.StringUtils; import javafx.application.Platform; import javafx.scene.control.TextArea; @@ -22,7 +23,7 @@ class StatScreenView implements IFXComponent { private void initGui() { mainPane = new Pane(); - mainPane.getStyleClass().add("main-module-pane"); + mainPane.getStyleClass().add(GUICssTool.getMainModulePaneCssClass()); statTextArea = new TextArea(); mainPane.getChildren().add(statTextArea); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java index d79b83c3..a8cf9df3 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java @@ -3,6 +3,7 @@ package com.pqt.client.gui.ressources.components; import com.pqt.client.gui.ressources.components.generics.displayers.IFXDisplayerComponent; import com.pqt.client.gui.ressources.components.specifics.products.listeners.IStockComponentListener; import com.pqt.client.gui.ressources.components.specifics.products.listeners.SimpleStockComponentFirerer; +import com.pqt.client.gui.ressources.css.GUICssTool; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.client.gui.ressources.strings.IObjectStringRenderer; import com.pqt.core.entities.product.Product; @@ -33,7 +34,7 @@ public class CategoryTabStockDisplayer implements IFXDisplayerComponent content) { - final ObservableList tabs = FXCollections.emptyObservableList(); + final ObservableList tabs = FXCollections.observableArrayList(); if(content!=null){ List categories = content.stream().map(product->product.getCategory().getName()).distinct().collect(Collectors.toList()); @@ -70,6 +71,7 @@ public class CategoryTabStockDisplayer implements IFXDisplayerComponentfirerer.fireContentClickEvent(event, listView.getSelectionModel().getSelectedItem())); + listView.setOnMouseClicked(event->{ + firerer.fireContentClickEvent(event, listView.getSelectionModel().getSelectedItem()); + Platform.runLater(()->listView.getSelectionModel().clearSelection(listView.getSelectionModel().getSelectedIndex())); + }); listView.setOnKeyTyped(event -> { if(event.getCode().equals(KeyCode.ENTER)){ firerer.fireContentClickEvent(event, listView.getSelectionModel().getSelectedItem()); + Platform.runLater(()->listView.getSelectionModel().clearSelection(listView.getSelectionModel().getSelectedIndex())); event.consume(); } }); @@ -119,6 +125,6 @@ public class CategoryTabStockDisplayer implements IFXDisplayerComponent getProductRenderer(){ - return GUIStringTool.getProductStringRenderer(); + return GUIStringTool.getDetailledProductStringRenderer(); } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CommandComposerSaleDisplayer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CommandComposerSaleDisplayer.java index 678b9ce2..5fec3ecf 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CommandComposerSaleDisplayer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CommandComposerSaleDisplayer.java @@ -3,6 +3,7 @@ package com.pqt.client.gui.ressources.components; import com.pqt.client.gui.ressources.components.specifics.sale.IFXSaleDisplayerComponent; import com.pqt.client.gui.ressources.components.specifics.sale.listeners.ISaleComponentListener; import com.pqt.client.gui.ressources.components.specifics.sale.listeners.SimpleSaleComponentFirerer; +import com.pqt.client.gui.ressources.css.GUICssTool; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.core.entities.product.Product; import com.pqt.core.entities.sale.Sale; @@ -35,6 +36,8 @@ public class CommandComposerSaleDisplayer implements IFXSaleDisplayerComponent { mainPane.getStyleClass().add("sale-displayer"); Label title = new Label(GUIStringTool.getCommandComposerTitleTitle()); + title.setAlignment(Pos.CENTER); + title.getStyleClass().add(GUICssTool.getTitleTextStyleClass()); HBox topPane = new HBox(); topPane.setFillHeight(true); @@ -74,7 +77,10 @@ public class CommandComposerSaleDisplayer implements IFXSaleDisplayerComponent { return; this.sale = content; - Platform.runLater(()->this.listView.setItems(FXCollections.observableList(new ArrayList<>(this.sale.getProducts().keySet())))); + Platform.runLater(()->{ + this.listView.getItems().clear(); + this.listView.getItems().addAll(this.sale.getProducts().keySet()); + }); } @Override diff --git a/Workspace/client/src/main/resources/dark-theme.css b/Workspace/client/src/main/resources/dark-theme.css index b71e5642..e8db18a7 100644 --- a/Workspace/client/src/main/resources/dark-theme.css +++ b/Workspace/client/src/main/resources/dark-theme.css @@ -6,7 +6,7 @@ -fx-font-size: 11pt; -fx-font-family: "Segoe UI Semibold"; -fx-text-fill: white; - -fx-opacity: 0.6; + -fx-opacity: 0.8; } .label-bright { @@ -17,12 +17,37 @@ } .label-header { - -fx-font-size: 32pt; - -fx-font-family: "Segoe UI Light"; + -fx-font-size: 25pt; + -fx-font-family: "Segoe UI"; -fx-text-fill: white; -fx-opacity: 1; } +.tab { + -fx-background-color: #3a3a3a; +} + +.tab-label { + -fx-text-fill: white; +} + +.tab:selected { + -fx-background-color: #4d4d4d; +} + +.tab-pane *.tab-header-background { + -fx-background-color: #1d1d1d; + -fx-border-width: 1px; + -fx-border-radius: 1px; + -fx-border-color: gray; +} + +.tab-pane { + -fx-border-width: 2px; + -fx-border-radius: 1px; + -fx-border-color: gray; +} + .list-view { -fx-base: #1d1d1d; -fx-control-inner-background: #1d1d1d; @@ -30,6 +55,9 @@ -fx-table-cell-border-color: transparent; -fx-table-header-border-color: transparent; -fx-padding: 5; + -fx-border-width: 2px; + -fx-border-radius: 1px; + -fx-border-color: gray; } .list-view .list-cell .label{ @@ -165,7 +193,7 @@ .button:focused { -fx-border-color: white, white; -fx-border-width: 1, 1; - -fx-border-style: solid, segments(1, 1); + -fx-border-style: solid; -fx-border-radius: 0, 0; -fx-border-insets: 1 1 1 1, 0; } @@ -202,11 +230,13 @@ .grey-intermediary-pane { -fx-background-color: #1d1d1d; - -fx-opacity: 60%; + -fx-opacity: 85%; } .main-module-pane { -fx-padding: 10 10 10 10; + -fx-border-width: 2px; + -fx-border-color: whitesmoke; } .validator { @@ -222,11 +252,11 @@ .sidebar { -fx-background-color: #2e2e2e; -fx-padding: 5 22 5 22; - -fx-border-color: #e2e2e2; + -fx-border-color: whitesmoke; -fx-border-width: 2; -fx-background-radius: 0; -fx-background-insets: 0 0 0 0, 0, 1, 2; - -pqt-expanded-width : 200px; + -pqt-expanded-width : 175px; } .tool-bar { From 312a5ce293b2202afd70efeb7df68b79ab4fb8c5 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sat, 19 Aug 2017 19:06:20 +0200 Subject: [PATCH 22/36] Module Core, clss Account : ajout constructeur de recopie --- .../main/java/com/pqt/core/entities/user_account/Account.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Workspace/core/src/main/java/com/pqt/core/entities/user_account/Account.java b/Workspace/core/src/main/java/com/pqt/core/entities/user_account/Account.java index a37517d1..f3d7ad34 100644 --- a/Workspace/core/src/main/java/com/pqt/core/entities/user_account/Account.java +++ b/Workspace/core/src/main/java/com/pqt/core/entities/user_account/Account.java @@ -23,6 +23,10 @@ public class Account implements ILoggable, Serializable { this.permissionLevel = permissionLevel; } + public Account(Account account) { + this(account.getUsername(), account.getPassword(), account.getPermissionLevel()); + } + public String getUsername() { return username; } From 41c59d31fee205ca24d2acd7e63a2e6ec3e78c3e Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sat, 19 Aug 2017 19:18:10 +0200 Subject: [PATCH 23/36] Module Client : utilisation des pseudo classes pour les variations de style css des cellules de tableview et de listview --- .../modules/stock_screen/StockScreenView.java | 15 ++++++++++ .../javafx_override/HighlightListCell.java | 21 +++++++++----- .../client/src/main/resources/dark-theme.css | 29 +++++++++++++++++-- 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java index c3a16606..5b2b3e26 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java @@ -13,6 +13,7 @@ import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.value.ObservableValue; +import javafx.css.PseudoClass; import javafx.scene.Node; import javafx.scene.control.*; import javafx.scene.input.KeyCode; @@ -68,10 +69,24 @@ class StockScreenView implements IFXComponent { HBox.setHgrow(separator, Priority.ALWAYS); mainPaneContent.setTop(mainPaneTopContent); + PseudoClass outOfStockPseudoClass = PseudoClass.getPseudoClass("stock-out"); + PseudoClass lowStockPseudoClass = PseudoClass.getPseudoClass("stock-low"); + PseudoClass highStockPseudoClass = PseudoClass.getPseudoClass("stock-high"); stockTableView = new TableView<>(); stockTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); stockTableView.setRowFactory(tableView->{ TableRow row = new TableRow<>(); + row.itemProperty().addListener((obs, oldVal, newVal)->{ + if(newVal!=null){ + row.pseudoClassStateChanged(outOfStockPseudoClass, newVal.getAmountRemaining()<=0); + row.pseudoClassStateChanged(lowStockPseudoClass, newVal.getAmountRemaining()>0 && newVal.getAmountRemaining()<30); + row.pseudoClassStateChanged(highStockPseudoClass, newVal.getAmountRemaining()>=30); + }else{ + row.pseudoClassStateChanged(outOfStockPseudoClass, false); + row.pseudoClassStateChanged(lowStockPseudoClass, false); + row.pseudoClassStateChanged(highStockPseudoClass, false); + } + }); row.setOnMouseClicked(event -> { if (event.getButton().equals(MouseButton.PRIMARY) && event.getClickCount() == 2) ctrl.getProductActivationListener().onProductActivated(row.getItem()); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/HighlightListCell.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/HighlightListCell.java index 7bab5db3..985b058c 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/HighlightListCell.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/HighlightListCell.java @@ -1,18 +1,25 @@ package com.pqt.client.gui.ressources.components.generics.javafx_override; +import javafx.css.PseudoClass; import javafx.scene.control.ListCell; public class HighlightListCell extends ListCell { + + private PseudoClass highlightPC; + private boolean highlighted; + + public HighlightListCell() { + super(); + highlighted = false; + highlightPC = PseudoClass.getPseudoClass("highlighted"); + } + public void setHighLight(boolean highLight){ - if(highLight){ - if(!getStyleClass().contains("list-cell-highlighted")) - getStyleClass().add("list-cell-highlighted"); - } - else - getStyleClass().remove("list-cell-highlighted"); + highlighted = highLight; + this.pseudoClassStateChanged(highlightPC, highLight); } public boolean isHightlighted(){ - return getStyleClass().contains("list-cell-highlighted"); + return highlighted; } } diff --git a/Workspace/client/src/main/resources/dark-theme.css b/Workspace/client/src/main/resources/dark-theme.css index e8db18a7..4d001188 100644 --- a/Workspace/client/src/main/resources/dark-theme.css +++ b/Workspace/client/src/main/resources/dark-theme.css @@ -51,6 +51,7 @@ .list-view { -fx-base: #1d1d1d; -fx-control-inner-background: #1d1d1d; + -fx-control-inner-background-alt: #333333; -fx-background-color: #1d1d1d; -fx-table-cell-border-color: transparent; -fx-table-header-border-color: transparent; @@ -71,8 +72,10 @@ .list-view:focused .list-cell:filled:focused:selected { -fx-background-color: -fx-focus-color; } -.list-cell-highlighted{ - -fx-background-color: #4d4d4d; +.list-cell:highlighted{ + -fx-text-fill: #cc7a00; + -fx-border-width: 1px; + -fx-border-color: white; } .table-view { @@ -108,6 +111,26 @@ -fx-opacity: 1; } +.table-view .table-row-cell { + -fx-control-inner-background: #1d1d1d; + -fx-control-inner-background-alt: #333333; +} + +.table-view .table-row-cell:stock-out { + -fx-control-inner-background: #4d0000; + -fx-control-inner-background-alt: #4d0000; +} + +.table-view .table-row-cell:stock-low { + -fx-control-inner-background: #4d2e00; + -fx-control-inner-background-alt: #4d2e00; +} + +.table-view .table-row-cell:stock-high { + -fx-control-inner-background: #1a3300; + -fx-control-inner-background-alt: #1a3300; +} + .table-view:focused .table-row-cell:filled:focused:selected { -fx-background-color: -fx-focus-color; } @@ -247,7 +270,7 @@ .validator .button{ -fx-pref-width: 150; -fx-pref-height: 50; - } +} .sidebar { -fx-background-color: #2e2e2e; From 41850fe2a137410ff7b38ae71f0e05c5ac8999cb Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sat, 19 Aug 2017 19:19:22 +0200 Subject: [PATCH 24/36] =?UTF-8?q?Module=20Client,=20clss=20SideBar=20:=20c?= =?UTF-8?q?orrection=20du=20bug=20de=20disparition=20de=20la=20sidebar=20a?= =?UTF-8?q?u=20d=C3=A9but=20de=20l'animation=20de=20collapse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/generics/others/SideBar.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/others/SideBar.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/others/SideBar.java index 94807320..d5c5351a 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/others/SideBar.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/others/SideBar.java @@ -42,6 +42,7 @@ public class SideBar extends VBox { setCycleDuration(Duration.millis(250)); } protected void interpolate(double frac) { + SideBar.this.setVisible(true); final double curWidth = expandedWidth.getValue().doubleValue() * frac; setPrefWidth(curWidth); setTranslateX(-expandedWidth.getValue().doubleValue() + curWidth); @@ -64,9 +65,11 @@ public class SideBar extends VBox { setTranslateX(-expandedWidth.getValue().doubleValue() + curWidth); } }; - collapseSideBar.onFinishedProperty().set(actionEvent -> - Arrays.stream(listenerList.getListeners(ISideBarListener.class)) - .forEach(ISideBarListener::onCollapsedFinished)); + collapseSideBar.onFinishedProperty().set(actionEvent ->{ + setVisible(false); + Arrays.stream(listenerList.getListeners(ISideBarListener.class)) + .forEach(ISideBarListener::onCollapsedFinished); + }); collapse(); } @@ -74,7 +77,6 @@ public class SideBar extends VBox { if (expandSideBar.statusProperty().get() == Animation.Status.STOPPED && collapseSideBar.statusProperty().get() == Animation.Status.STOPPED) { if (!isVisible()) { - setVisible(true); expandSideBar.play(); } } @@ -85,7 +87,6 @@ public class SideBar extends VBox { && collapseSideBar.statusProperty().get() == Animation.Status.STOPPED) { if (isVisible()) { collapseSideBar.play(); - setVisible(false); } } } From 0ec1f69bb53387e53ef1b723f775d48646808287 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sat, 19 Aug 2017 19:19:52 +0200 Subject: [PATCH 25/36] =?UTF-8?q?Module=20Client,=20clss=20GUICssTool=20:?= =?UTF-8?q?=20suppr=20de=20m=C3=A9thodes=20inutilis=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/pqt/client/gui/ressources/css/GUICssTool.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java index 69b4fdc2..c3f9c8bb 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/css/GUICssTool.java @@ -5,14 +5,6 @@ public class GUICssTool { return "/dark-theme.css"; } - public static String getCollapsedSideBarCssStyle() { - return "sidebar-collapsed"; - } - - public static String getExpandedSideBarCssStyle() { - return "sidebar-expanded"; - } - public static String getMainModulePaneCssClass() { return "main-module-pane"; } From d6c9e58519952fba98e7a8fe4eb20bf762696fef Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sat, 19 Aug 2017 19:20:39 +0200 Subject: [PATCH 26/36] Module Client, clss GUIStringTool : modification du renderer de produit --- .../gui/ressources/strings/GUIStringTool.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java index 22fe69f3..0b69d406 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java @@ -36,9 +36,17 @@ public class GUIStringTool { public static IObjectStringRenderer getDetailledProductStringRenderer(){ return product->{ - if(product!=null) - return String.format("%s - %.2f€ (%s)", product.getName(), product.getPrice(), (product.getAmountRemaining()>=30?"30+": Integer.toString(product.getAmountRemaining()))); - else + if(product!=null){ + String amountStr; + if(product.getAmountRemaining()<=0){ + amountStr = "OUT OF STOCK"; + }else if(product.getAmountRemaining()>=30){ + amountStr = "30+"; + }else{ + amountStr = Integer.toString(product.getAmountRemaining()); + } + return String.format("%s - %.2f€ (%s)", product.getName(), product.getPrice(), amountStr); + }else return "null"; }; } From 0ec6f12286c464d0ec93b2473d8b2afb7b716ba4 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sat, 19 Aug 2017 19:21:49 +0200 Subject: [PATCH 27/36] =?UTF-8?q?Module=20Client,=20clss=20GUIStringTool?= =?UTF-8?q?=20:=20modif=20nom=20m=C3=A9thd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ressources/components/CommandComposerSaleDisplayer.java | 5 +---- .../com/pqt/client/gui/ressources/strings/GUIStringTool.java | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CommandComposerSaleDisplayer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CommandComposerSaleDisplayer.java index 5fec3ecf..69da7a84 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CommandComposerSaleDisplayer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CommandComposerSaleDisplayer.java @@ -8,7 +8,6 @@ import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.core.entities.product.Product; import com.pqt.core.entities.sale.Sale; import javafx.application.Platform; -import javafx.collections.FXCollections; import javafx.geometry.Pos; import javafx.scene.control.*; import javafx.scene.input.KeyCode; @@ -16,8 +15,6 @@ import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; -import java.util.ArrayList; - public class CommandComposerSaleDisplayer implements IFXSaleDisplayerComponent { private SimpleSaleComponentFirerer firerer; @@ -35,7 +32,7 @@ public class CommandComposerSaleDisplayer implements IFXSaleDisplayerComponent { mainPane = new BorderPane(); mainPane.getStyleClass().add("sale-displayer"); - Label title = new Label(GUIStringTool.getCommandComposerTitleTitle()); + Label title = new Label(GUIStringTool.getCommandComposerTitleLabel()); title.setAlignment(Pos.CENTER); title.getStyleClass().add(GUICssTool.getTitleTextStyleClass()); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java index 0b69d406..6fb4a0a4 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java @@ -60,7 +60,7 @@ public class GUIStringTool { }; } - public static String getCommandComposerTitleTitle() { + public static String getCommandComposerTitleLabel() { return "Commande"; } From 90985fbc467ab7a5b8050eb0f56128ae8128a609 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sat, 19 Aug 2017 19:22:14 +0200 Subject: [PATCH 28/36] =?UTF-8?q?Module=20Client=20:=20ajout=20=C3=A9cran?= =?UTF-8?q?=20de=20gestion=20des=20comptes=20utilisateurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/pqt/client/Main.java | 3 +- .../modules/account_screen/AccountScreen.java | 30 +++ .../AccountScreenController.java | 83 ++++++++ .../account_screen/AccountScreenModel.java | 44 +++++ .../account_screen/AccountScreenView.java | 178 ++++++++++++++++++ .../AccountManagerScreen.java | 56 ++++++ .../AccountManagerScreenController.java | 58 ++++++ .../AccountManagerScreenModel.java | 61 ++++++ .../AccountManagerScreenView.java | 104 ++++++++++ .../gui/ressources/strings/GUIStringTool.java | 47 +++++ 10 files changed, 663 insertions(+), 1 deletion(-) create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreen.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenController.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenModel.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenView.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreen.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenController.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenModel.java create mode 100644 Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenView.java diff --git a/Workspace/client/src/main/java/com/pqt/client/Main.java b/Workspace/client/src/main/java/com/pqt/client/Main.java index 5e978bc4..c09ccd86 100644 --- a/Workspace/client/src/main/java/com/pqt/client/Main.java +++ b/Workspace/client/src/main/java/com/pqt/client/Main.java @@ -1,6 +1,7 @@ package com.pqt.client; import com.pqt.client.gui.main_frame.MainFrame; +import com.pqt.client.gui.modules.account_screen.AccountScreen; import com.pqt.client.gui.modules.sale_screen.SaleScreen; import com.pqt.client.gui.modules.stat_screen.StatScreen; import com.pqt.client.gui.modules.stock_screen.StockScreen; @@ -34,7 +35,7 @@ public class Main extends Application{ mainFrame.addModule(new SaleScreen(accountService, stockService, saleService), true); mainFrame.addModule(new StockScreen(stockService)); mainFrame.addModule(new StatScreen(statService)); - //TODO ajouter un module AccountScreen + mainFrame.addModule(new AccountScreen(accountService)); Scene scene = new Scene(mainFrame.getPane(), 800, 600); scene.getStylesheets().clear(); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreen.java new file mode 100644 index 00000000..2c5f4ea8 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreen.java @@ -0,0 +1,30 @@ +package com.pqt.client.gui.modules.account_screen; + +import com.pqt.client.gui.modules.IGuiModule; +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.client.module.account.AccountService; +import javafx.scene.layout.Pane; + +public class AccountScreen implements IGuiModule { + + private AccountScreenView view; + + public AccountScreen(AccountService accountService) { + AccountScreenModel model = new AccountScreenModel(accountService); + AccountScreenController ctrl = new AccountScreenController(model); + view = new AccountScreenView(ctrl); + + ctrl.setView(view); + ctrl.updateView(); + } + + @Override + public String getModuleName() { + return GUIStringTool.getAccountGuiModuleName(); + } + + @Override + public Pane getPane() { + return view.getPane(); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenController.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenController.java new file mode 100644 index 00000000..f27509ce --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenController.java @@ -0,0 +1,83 @@ +package com.pqt.client.gui.modules.account_screen; + +import com.pqt.client.gui.ressources.components.generics.validators.listeners.IValidatorComponentListener; +import com.pqt.core.entities.user_account.Account; +import com.pqt.core.entities.user_account.AccountLevel; + +class AccountScreenController { + + private AccountScreenModel model; + private AccountScreenView view; + + AccountScreenController(AccountScreenModel model) { + this.model = model; + } + + void setView(AccountScreenView view) { + this.view = view; + } + + void updateView() { + updateViewAccountCollection(); + updateViewActionLock(); + } + + private void updateViewAccountCollection(){ + view.setAccountCollection(model.getAccountCollection()); + } + + private void updateViewActionLock() { + if (model.getCurrentAccount() != null) { + view.setAddAccountActionLocked(model.getCurrentAccount().getPermissionLevel().compareTo(AccountLevel.MASTER) >= 0); + view.setDetailAccountActionLocked(view.isItemSelected() && model.getCurrentAccount().getPermissionLevel().compareTo(AccountLevel.MASTER) >= 0); + view.setRemoveAccountActionLocked(view.isItemSelected() && model.getCurrentAccount().getPermissionLevel().compareTo(AccountLevel.MASTER) >= 0); + }else{ + view.setAddAccountActionLocked(true); + view.setDetailAccountActionLocked(true); + view.setRemoveAccountActionLocked(true); + } + } + + IValidatorComponentListener getDetailScreenValidationListener(){ + return new IValidatorComponentListener() { + @Override + public void onValidationEvent() { + if(view.isDetailCreationPossible()){ + if(view.getDetailScreenInitialValue()!=null){ + model.modifyAccount(view.getDetailScreenInitialValue(), view.getDetailScreenCreatedValue()); + }else{ + model.addAccount(view.getDetailScreenCreatedValue()); + } + view.hideDetailScreen(); + } + } + + @Override + public void onCancelEvent() { + view.hideDetailScreen(); + } + }; + } + + void onAddAccountRequested() { + view.showDetailScreen(null, model.getLevels()); + } + + void onDetailAccountRequested() { + if(view.isItemSelected()) + view.showDetailScreen(view.getSelectedItem(), model.getLevels()); + } + + void onRemoveAccountRequested() { + if(view.isItemSelected()) + model.removeAccount(view.getSelectedItem()); + } + + void onRefreshAccountRequested() { + this.updateView(); + } + + void onSelectedAccountChanged(Account oldVal, Account newVal) { + updateViewActionLock(); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenModel.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenModel.java new file mode 100644 index 00000000..a1a129a0 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenModel.java @@ -0,0 +1,44 @@ +package com.pqt.client.gui.modules.account_screen; + +import com.pqt.client.module.account.AccountService; +import com.pqt.core.entities.user_account.Account; +import com.pqt.core.entities.user_account.AccountLevel; + +import java.util.Collection; +import java.util.EnumSet; + +//TODO MAJ les méthds modif, add et remove une fois que l'accountService prend en compte les modifs +class AccountScreenModel { + + private AccountService accountService; + + AccountScreenModel(AccountService accountService) { + this.accountService = accountService; + } + + void modifyAccount(Account oldVal, Account newVal) { + //accountService.submitAccountUpdate(oldVal, newVal); + } + + void addAccount(Account newVal) { + //accountService.submitAccountUpdate(null, newVal); + } + + void removeAccount(Account oldVal) { + //accountService.submitAccountUpdate(oldVal, null); + } + + Collection getAccountCollection() { + return accountService.getAllAccounts(); + } + + Account getCurrentAccount() { + return accountService.getCurrentAccount(); + } + + Collection getLevels() { + //TODO régler ça aussi + //return accountService.getAvailableLevels(); + return EnumSet.allOf(AccountLevel.class); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenView.java new file mode 100644 index 00000000..71a067fc --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenView.java @@ -0,0 +1,178 @@ +package com.pqt.client.gui.modules.account_screen; + +import com.pqt.client.gui.modules.account_screen.account_manager_screen.AccountManagerScreen; +import com.pqt.client.gui.ressources.components.generics.IFXComponent; +import com.pqt.client.gui.ressources.css.GUICssTool; +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.core.entities.user_account.Account; +import com.pqt.core.entities.user_account.AccountLevel; +import javafx.application.Platform; +import javafx.beans.property.SimpleStringProperty; +import javafx.scene.Node; +import javafx.scene.control.*; +import javafx.scene.input.MouseButton; +import javafx.scene.layout.*; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +class AccountScreenView implements IFXComponent{ + + private AccountScreenController ctrl; + private StackPane mainPane; + private BorderPane mainPaneContent; + private TableView tableView; + private AccountManagerScreen accountManagerScreen; + + private Button addAccountButton, detailAccountButton, removeAccountButton; + + + AccountScreenView(AccountScreenController ctrl) { + this.ctrl = ctrl; + initGui(); + } + + private void initGui() { + mainPane = new StackPane(); + mainPane.getStyleClass().add(GUICssTool.getMainModulePaneCssClass()); + + mainPaneContent = new BorderPane(); + + tableView = new TableView<>(); + + tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); + tableView.getSelectionModel().selectedItemProperty().addListener((obs, oldVal, newVal)-> ctrl.onSelectedAccountChanged(oldVal, newVal)); + TableColumn nameColumn = new TableColumn<>(GUIStringTool.getAccountNameColumnHeaderLabel()); + nameColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getUsername())); + tableView.getColumns().add(nameColumn); + + TableColumn levelColumn = new TableColumn<>(GUIStringTool.getAccountLevelColumnHeaderLabel()); + levelColumn.setCellValueFactory(param -> new SimpleStringProperty( + GUIStringTool.getAccountLevelStringRenderer().render(param.getValue().getPermissionLevel()) + )); + tableView.getColumns().add(levelColumn); + mainPaneContent.setCenter(tableView); + + HBox mainPaneTopContent = new HBox(); + mainPaneTopContent.setFillHeight(true); + + Label label = new Label(GUIStringTool.getAccountListTitleLabel()); + label.getStyleClass().add(GUICssTool.getTitleTextStyleClass()); + mainPaneTopContent.getChildren().add(label); + + HBox separator = new HBox(); + ToolBar buttonToolbar = new ToolBar(); + addAccountButton = new Button(GUIStringTool.getAddButtonLabel()); + addAccountButton.setOnMouseClicked(event->{ + if (event.getButton().equals(MouseButton.PRIMARY)) + ctrl.onAddAccountRequested(); + }); + buttonToolbar.getItems().add(addAccountButton); + detailAccountButton = new Button(GUIStringTool.getDetailButtonLabel()); + detailAccountButton.setOnMouseClicked(event->{ + if (event.getButton().equals(MouseButton.PRIMARY)) + ctrl.onDetailAccountRequested(); + }); + buttonToolbar.getItems().add(detailAccountButton); + removeAccountButton = new Button(GUIStringTool.getRemoveButtonLabel()); + removeAccountButton.setOnMouseClicked(event->{ + if (event.getButton().equals(MouseButton.PRIMARY)) + ctrl.onRemoveAccountRequested(); + }); + buttonToolbar.getItems().add(removeAccountButton); + Button refreshAccountButton = new Button(GUIStringTool.getRefreshButtonLabel()); + refreshAccountButton.setOnMouseClicked(event->{ + if (event.getButton().equals(MouseButton.PRIMARY)) + ctrl.onRefreshAccountRequested(); + }); + buttonToolbar.getItems().add(refreshAccountButton); + + mainPaneTopContent.getChildren().addAll(separator, buttonToolbar); + HBox.setHgrow(separator, Priority.ALWAYS); + + mainPaneContent.setTop(mainPaneTopContent); + mainPane.getChildren().add(mainPaneContent); + } + + boolean isItemSelected(){ + return tableView.getSelectionModel().getSelectedItem()!=null; + } + + Account getSelectedItem(){ + return tableView.getSelectionModel().getSelectedItem(); + } + + @Override + public Pane getPane() { + return mainPane; + } + + boolean isDetailCreationPossible() { + return accountManagerScreen!=null && accountManagerScreen.isCreationPossible(); + } + + Account getDetailScreenInitialValue() { + if(accountManagerScreen!=null) + return accountManagerScreen.getInitialValue(); + return null; + } + + Account getDetailScreenCreatedValue() { + if(accountManagerScreen!=null) + return accountManagerScreen.create(); + return null; + } + + boolean isDetailScreenShown(){ + return accountManagerScreen!=null; + } + + void showDetailScreen(Account initialValue, Collection availableLevels){ + if(!isDetailScreenShown()){ + Pane separator = new Pane(); + separator.getStyleClass().add(GUICssTool.getIntermediaryPaneStyleClass()); + accountManagerScreen = new AccountManagerScreen(initialValue, availableLevels); + accountManagerScreen.addListener(ctrl.getDetailScreenValidationListener()); + + Platform.runLater(()->{ + mainPane.getChildren().addAll(separator, accountManagerScreen.getPane()); + }); + } + } + + void hideDetailScreen(){ + if(isDetailScreenShown()){ + List toRemove = mainPane.getChildren() + .stream() + .filter(node->!node.equals(mainPaneContent)) + .collect(Collectors.toList()); + + Platform.runLater(()->{ + mainPane.getChildren().removeAll(toRemove); + accountManagerScreen = null; + }); + + } + } + + void setAccountCollection(Collection accountCollection) { + Platform.runLater(()->{ + tableView.getItems().clear(); + if(accountCollection!=null) + tableView.getItems().addAll(accountCollection); + }); + } + + void setAddAccountActionLocked(boolean locked) { + addAccountButton.setDisable(locked); + } + + void setDetailAccountActionLocked(boolean locked) { + detailAccountButton.setDisable(locked); + } + + void setRemoveAccountActionLocked(boolean locked) { + removeAccountButton.setDisable(locked); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreen.java new file mode 100644 index 00000000..26cd33e2 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreen.java @@ -0,0 +1,56 @@ +package com.pqt.client.gui.modules.account_screen.account_manager_screen; + +import com.pqt.client.gui.ressources.components.generics.creators.IFXCreatorComponent; +import com.pqt.client.gui.ressources.components.generics.validators.IFXValidatorComponent; +import com.pqt.client.gui.ressources.components.generics.validators.listeners.IValidatorComponentListener; +import com.pqt.core.entities.user_account.Account; +import com.pqt.core.entities.user_account.AccountLevel; +import javafx.scene.layout.Pane; + +import java.util.Collection; + +//TODO à faire +public class AccountManagerScreen implements IFXValidatorComponent, IFXCreatorComponent{ + + private AccountManagerScreenModel model; + private AccountManagerScreenView view; + private AccountManagerScreenController ctrl; + + public AccountManagerScreen(Account initialValue, Collection availableLevels) { + model = new AccountManagerScreenModel(initialValue, availableLevels); + ctrl = new AccountManagerScreenController(model); + view = new AccountManagerScreenView(ctrl); + + ctrl.setView(view); + ctrl.updateView(); + } + + public Account getInitialValue(){ + return model.getInitialValue(); + } + + @Override + public Account create() { + return model.getCurrentValue(); + } + + @Override + public boolean isCreationPossible() { + return model.isCurrentValueValid(); + } + + @Override + public void addListener(IValidatorComponentListener l) { + ctrl.addListener(l); + } + + @Override + public void removeListener(IValidatorComponentListener l) { + ctrl.removeListener(l); + } + + @Override + public Pane getPane() { + return view.getPane(); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenController.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenController.java new file mode 100644 index 00000000..e3b6e000 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenController.java @@ -0,0 +1,58 @@ +package com.pqt.client.gui.modules.account_screen.account_manager_screen; + +import com.pqt.client.gui.ressources.components.generics.validators.listeners.IValidatorComponentListener; +import com.pqt.core.entities.user_account.AccountLevel; + +import javax.swing.event.EventListenerList; +import java.util.Arrays; + +class AccountManagerScreenController { + + private EventListenerList listenerList; + private AccountManagerScreenView view; + private AccountManagerScreenModel model; + + AccountManagerScreenController(AccountManagerScreenModel model) { + listenerList = new EventListenerList(); + this.model = model; + } + + void setView(AccountManagerScreenView view) { + this.view = view; + } + + void updateView() { + view.setLevelCollection(model.getAccountLevelCollection()); + view.setData(model.getCurrentValue()); + } + + void addListener(IValidatorComponentListener l) { + listenerList.add(IValidatorComponentListener.class, l); + } + + void removeListener(IValidatorComponentListener l) { + listenerList.remove(IValidatorComponentListener.class, l); + } + + void onNameChanged(String oldVal, String newVal) { + model.changeName(newVal); + } + + void onPasswordChanged(String oldVal, String newVal) { + model.changePassword(newVal); + } + + void onLevelChanged(AccountLevel oldVal, AccountLevel newVal) { + model.changeLevel(newVal); + } + + void onValidationEvent() { + Arrays.stream(listenerList.getListeners(IValidatorComponentListener.class)) + .forEach(IValidatorComponentListener::onValidationEvent); + } + + void onCancelEvent() { + Arrays.stream(listenerList.getListeners(IValidatorComponentListener.class)) + .forEach(IValidatorComponentListener::onCancelEvent); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenModel.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenModel.java new file mode 100644 index 00000000..e0dd15d0 --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenModel.java @@ -0,0 +1,61 @@ +package com.pqt.client.gui.modules.account_screen.account_manager_screen; + +import com.pqt.core.entities.user_account.Account; +import com.pqt.core.entities.user_account.AccountLevel; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +class AccountManagerScreenModel { + private Account currentValue; + private Account initialValue; + private Set levels; + + AccountManagerScreenModel(Account initialValue, Collection availableLevels) { + levels = new HashSet<>(); + if(availableLevels!=null) + levels.addAll(availableLevels); + this.initialValue = initialValue; + this.currentValue = (initialValue!=null?new Account(initialValue):getNewAccount()); + } + + Account getCurrentValue() { + return currentValue; + } + + Account getInitialValue() { + return initialValue; + } + + boolean isCurrentValueValid() { + return !currentValue.equals(initialValue) + && currentValue.getUsername()!=null + && !currentValue.getUsername().isEmpty() + && currentValue.getPermissionLevel()!=null; + } + + Collection getAccountLevelCollection(){ + return levels; + } + + void changeName(String username) { + currentValue.setUsername(username); + } + + void changePassword(String password) { + currentValue.setPassword(password); + } + + void changeLevel(AccountLevel level) { + currentValue.setPermissionLevel(level); + } + + private Account getNewAccount() { + Account account = new Account(); + account.setUsername(""); + account.setPassword(""); + account.setPermissionLevel(levels.stream().min(Enum::compareTo).orElse(AccountLevel.getLowest())); + return account; + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenView.java new file mode 100644 index 00000000..722e54ef --- /dev/null +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenView.java @@ -0,0 +1,104 @@ +package com.pqt.client.gui.modules.account_screen.account_manager_screen; + +import com.pqt.client.gui.ressources.components.generics.IFXComponent; +import com.pqt.client.gui.ressources.strings.GUIStringTool; +import com.pqt.core.entities.user_account.Account; +import com.pqt.core.entities.user_account.AccountLevel; +import javafx.application.Platform; +import javafx.scene.control.*; +import javafx.scene.input.MouseButton; +import javafx.scene.layout.*; + +import java.util.Collection; + + +class AccountManagerScreenView implements IFXComponent{ + + private Pane mainPane; + private AccountManagerScreenController ctrl; + + private ChoiceBox levelChoiceBox; + private TextField nameTextField; + private PasswordField passwordField; + + AccountManagerScreenView(AccountManagerScreenController ctrl) { + this.ctrl = ctrl; + initGui(); + } + + private void initGui() { + mainPane = new Pane(); + + BorderPane mainPaneContent = new BorderPane(); + + GridPane mainPaneCenterContent = new GridPane(); + Label nameLabel = new Label(GUIStringTool.getUsernameLabel()); + nameTextField = new TextField(); + nameTextField.textProperty().addListener((obs, oldVal, newVal)->ctrl.onNameChanged(oldVal, newVal)); + mainPaneCenterContent.add(nameLabel, 0, 0); + mainPaneCenterContent.add(nameTextField, 1,0); + + Label passwordLabel = new Label(GUIStringTool.getPasswordLabel()); + passwordField = new PasswordField(); + passwordField.textProperty().addListener((obs, oldVal, newVal)->ctrl.onPasswordChanged(oldVal, newVal)); + mainPaneCenterContent.add(passwordLabel, 0, 1); + mainPaneCenterContent.add(passwordField, 1,1); + + Label levelLabel = new Label(GUIStringTool.getUserLevelLabel()); + levelChoiceBox = new ChoiceBox<>(); + levelChoiceBox.valueProperty().addListener((obs, oldVal, newVal)->ctrl.onLevelChanged(oldVal, newVal)); + mainPaneCenterContent.add(levelLabel, 0, 2); + mainPaneCenterContent.add(levelChoiceBox, 1,2); + + mainPaneContent.setCenter(mainPaneCenterContent); + + HBox mainPaneBottomContent = new HBox(); + mainPaneBottomContent.setFillHeight(true); + Button validationButton = new Button(GUIStringTool.getValidationButtonLabel()); + validationButton.setOnMouseClicked(event -> { + if (event.getButton().equals(MouseButton.PRIMARY)) + ctrl.onValidationEvent(); + }); + Button cancelButton = new Button(GUIStringTool.getValidationButtonLabel()); + cancelButton.setOnMouseClicked(event -> { + if (event.getButton().equals(MouseButton.PRIMARY)) + ctrl.onCancelEvent(); + }); + HBox separator = new HBox(); + + mainPaneBottomContent.getChildren().addAll(separator, validationButton, cancelButton); + HBox.setHgrow(separator, Priority.ALWAYS); + + mainPaneContent.setBottom(mainPaneBottomContent); + mainPane.getChildren().add(mainPaneContent); + } + + @Override + public Pane getPane() { + return mainPane; + } + + void setLevelCollection(Collection levelCollection) { + Platform.runLater(()->{ + levelChoiceBox.getItems().clear(); + levelChoiceBox.getItems().addAll(levelCollection); + }); + } + + void setData(Account data) { + Platform.runLater(()->{ + if(data!=null){ + nameTextField.setText(data.getUsername()); + passwordField.setText(data.getPassword()); + levelChoiceBox.setValue(data.getPermissionLevel()); + }else{ + nameTextField.setText(""); + passwordField.setText(""); + levelChoiceBox.setValue(levelChoiceBox.getItems() + .stream() + .min(Enum::compareTo) + .orElse(AccountLevel.getLowest())); + } + }); + } +} diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java index 6fb4a0a4..af5f1781 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/strings/GUIStringTool.java @@ -284,6 +284,53 @@ public class GUIStringTool { public static String getComponentListTitleLabel() { return "Composants"; } + + public static String getAccountGuiModuleName() { + return "Utilisateurs"; + } + + public static IObjectStringRenderer getAccountLevelStringRenderer() { + return level->{ + switch (level){ + case LOWEST: + return "autre"; + case GUEST: + return "Invité"; + case STAFF: + return "Staff"; + case WAITER: + return "Caissier"; + case MASTER: + return "Chef"; + default: + return "unknown"; + } + }; + } + + public static String getAccountListTitleLabel() { + return "Utilisateurs"; + } + + public static String getUsernameLabel() { + return "Nom :"; + } + + public static String getPasswordLabel() { + return "Mot de passe : "; + } + + public static String getUserLevelLabel() { + return "Niveau d'accréditation : "; + } + + public static String getAccountNameColumnHeaderLabel() { + return "Nom d'utilisateur"; + } + + public static String getAccountLevelColumnHeaderLabel() { + return "Niveau d'accréditation"; + } } From 2cbe949b03addfda64d1bc78cd01c8095d75a07c Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sat, 19 Aug 2017 20:54:35 +0200 Subject: [PATCH 29/36] =?UTF-8?q?Module=20Client=20:=20correction=20bug=20?= =?UTF-8?q?commit=20update=20StockScreenModel;=20Les=20m=C3=A9thds=20de=20?= =?UTF-8?q?la=20clss=20UpdateBuilder=20sont=20d=C3=A9sormais=20chainables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/modules/stock_screen/StockScreenModel.java | 6 +++--- .../java/com/pqt/client/module/stock/UpdateBuilder.java | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) 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 429120eb..cc5a39b1 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 @@ -35,15 +35,15 @@ class StockScreenModel { } void commitProductDeletion(Product product) { - + stockService.commitUpdate(stockService.getNewUpdateBuilder().removeProduct(product)); } void commitProductModification(Product oldProduct, Product newProduct) { - + stockService.commitUpdate(stockService.getNewUpdateBuilder().modifyProduct(oldProduct, newProduct)); } void commitProductAddition(Product product) { - + stockService.commitUpdate(stockService.getNewUpdateBuilder().addProduct(product)); } void addListener(IStockScreenModelListener l){ diff --git a/Workspace/client/src/main/java/com/pqt/client/module/stock/UpdateBuilder.java b/Workspace/client/src/main/java/com/pqt/client/module/stock/UpdateBuilder.java index 36826f26..f471916b 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/stock/UpdateBuilder.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/stock/UpdateBuilder.java @@ -16,20 +16,23 @@ public class UpdateBuilder { toModify = new HashMap<>(); } - public void addProduct(Product product) { + public UpdateBuilder addProduct(Product product) { if(!toAdd.contains(product)){ toAdd.add(product); } + return this; } - public void removeProduct(Product product) { + public UpdateBuilder removeProduct(Product product) { if(toRemove.contains(product)){ toRemove.remove(product); } + return this; } - public void modifyProduct(Product oldVersion, Product newVersion) { + public UpdateBuilder modifyProduct(Product oldVersion, Product newVersion) { toModify.put(oldVersion, newVersion); + return this; } public List build() { From b46eeec815620de3542fb4f38bc6143774e9b785 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sat, 19 Aug 2017 20:55:38 +0200 Subject: [PATCH 30/36] =?UTF-8?q?Module=20Client=20:=20ajout=20de=20restri?= =?UTF-8?q?ctions=20d'actions=20et=20de=20navigation=20en=20fonction=20du?= =?UTF-8?q?=20niveau=20de=20permission=20du=20compte=20actuellement=20conn?= =?UTF-8?q?ect=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/pqt/client/Main.java | 5 +-- .../pqt/client/gui/main_frame/MainFrame.java | 7 ++-- .../gui/main_frame/MainFrameController.java | 18 +++++++--- .../client/gui/main_frame/MainFrameView.java | 17 +++++++--- .../pqt/client/gui/modules/IGuiModule.java | 2 ++ .../modules/account_screen/AccountScreen.java | 6 ++++ .../AccountScreenController.java | 6 ++-- .../AccountManagerScreenView.java | 2 +- .../gui/modules/sale_screen/SaleScreen.java | 6 ++++ .../sale_screen/SaleScreenController.java | 18 ++++++++-- .../modules/sale_screen/SaleScreenModel.java | 19 ++++++++++- .../listeners/ISaleScreenModelListener.java | 1 + .../gui/modules/stat_screen/StatScreen.java | 6 ++++ .../gui/modules/stock_screen/StockScreen.java | 12 +++++-- .../stock_screen/StockScreenController.java | 22 ++++++++++++ .../stock_screen/StockScreenModel.java | 34 ++++++++++++++++++- .../modules/stock_screen/StockScreenView.java | 26 ++++++++++---- .../listeners/IStockScreenModelListener.java | 1 + 18 files changed, 176 insertions(+), 32 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/Main.java b/Workspace/client/src/main/java/com/pqt/client/Main.java index c09ccd86..4780949d 100644 --- a/Workspace/client/src/main/java/com/pqt/client/Main.java +++ b/Workspace/client/src/main/java/com/pqt/client/Main.java @@ -32,11 +32,12 @@ public class Main extends Application{ StatService statService = new StatService(); MainFrame mainFrame = new MainFrame(accountService); - mainFrame.addModule(new SaleScreen(accountService, stockService, saleService), true); - mainFrame.addModule(new StockScreen(stockService)); + mainFrame.addModule(new SaleScreen(accountService, stockService, saleService)); + mainFrame.addModule(new StockScreen(stockService, accountService)); mainFrame.addModule(new StatScreen(statService)); mainFrame.addModule(new AccountScreen(accountService)); + Scene scene = new Scene(mainFrame.getPane(), 800, 600); scene.getStylesheets().clear(); scene.getStylesheets().addAll(getClass().getResource(GUICssTool.getCssFilePath()).toExternalForm()); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java index bc1674a6..73d9c53f 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java @@ -17,14 +17,11 @@ public class MainFrame implements IFXComponent { view = new MainFrameView(ctrl); ctrl.setView(view); + ctrl.updateView(); } public void addModule(IGuiModule module){ - ctrl.addModule(module, false); - } - - public void addModule(IGuiModule module, boolean setActive){ - ctrl.addModule(module, setActive); + ctrl.addModule(module); } @Override diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java index 43686466..be3d474d 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java @@ -5,6 +5,7 @@ import com.pqt.client.gui.modules.IGuiModule; import com.pqt.client.gui.ressources.components.generics.validators.listeners.IValidatorComponentListener; import com.pqt.client.gui.ressources.components.specifics.account.listeners.IAccountComponentListener; import com.pqt.core.entities.user_account.Account; +import com.pqt.core.entities.user_account.AccountLevel; import javafx.event.Event; class MainFrameController implements IMainFrameModelListener { @@ -21,8 +22,17 @@ class MainFrameController implements IMainFrameModelListener { this.view = view; } - void addModule(IGuiModule module, boolean setActive) { - this.view.addGuiModule(module.getModuleName(),module.getPane(), setActive); + void updateView(){ + view.feedAccountCollectionToManager(model.getAccounts()); + view.setCurrentAccount(model.getCurrentAccount()); + if(model.getCurrentAccount()!=null) + view.updateModuleButtonLock(model.getCurrentAccount().getPermissionLevel()); + else + view.updateModuleButtonLock(AccountLevel.getLowest()); + } + + void addModule(IGuiModule module) { + this.view.addGuiModule(module.getModuleName(),module.getPane(), module.getLowestRequiredAccountLevel()); } IValidatorComponentListener getAccountManagerValidatorListener() { @@ -71,11 +81,11 @@ class MainFrameController implements IMainFrameModelListener { @Override public void onAccountStatusChangedEvent(boolean status) { - view.setCurrentAccount(model.getCurrentAccount()); + updateView(); } @Override public void onAccountCollectionChangedEvent() { - view.feedAccountCollectionToManager(model.getAccounts()); + updateView(); } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java index 5793fa3d..d76d2674 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java @@ -6,7 +6,11 @@ import com.pqt.client.gui.ressources.components.generics.others.SideBar; import com.pqt.client.gui.ressources.components.generics.others.listeners.ISideBarListener; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.core.entities.user_account.Account; +import com.pqt.core.entities.user_account.AccountLevel; import javafx.application.Platform; +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleObjectProperty; +import javafx.beans.value.ObservableValue; import javafx.geometry.Orientation; import javafx.scene.Node; import javafx.scene.control.Button; @@ -25,10 +29,11 @@ class MainFrameView implements IFXComponent{ private BorderPane mainPane; private AccountManager accountManager; private VBox buttonHolder; + private ObjectProperty currentAccountLevel; MainFrameView(MainFrameController ctrl) { - this.ctrl = ctrl; + currentAccountLevel = new SimpleObjectProperty<>(AccountLevel.getLowest()); initGui(); } @@ -82,7 +87,7 @@ class MainFrameView implements IFXComponent{ return mainPane; } - void addGuiModule(String moduleName, Pane moduleContent, boolean setActive){ + void addGuiModule(String moduleName, Pane moduleContent, AccountLevel requiredLevel){ Button button = new Button(moduleName); button.getStyleClass().add("menu-button"); button.setOnMouseClicked(event->{ @@ -97,8 +102,8 @@ class MainFrameView implements IFXComponent{ mainPane.setCenter(moduleContent); }); }); - if(setActive) - button.getOnMouseClicked().handle(null); + currentAccountLevel.addListener((obs, oldVal, newVal)->button.setDisable(requiredLevel.compareTo(newVal)>0)); + button.setDisable(requiredLevel.compareTo(currentAccountLevel.get())>0); buttonHolder.getChildren().add(button); } @@ -117,4 +122,8 @@ class MainFrameView implements IFXComponent{ void feedAccountCollectionToManager(Collection accounts){ accountManager.display(accounts); } + + void updateModuleButtonLock(AccountLevel level) { + currentAccountLevel.setValue(level); + } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/IGuiModule.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/IGuiModule.java index a6a06023..e4dfa3d2 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/IGuiModule.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/IGuiModule.java @@ -1,7 +1,9 @@ package com.pqt.client.gui.modules; import com.pqt.client.gui.ressources.components.generics.IFXComponent; +import com.pqt.core.entities.user_account.AccountLevel; public interface IGuiModule extends IFXComponent{ String getModuleName(); + AccountLevel getLowestRequiredAccountLevel(); } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreen.java index 2c5f4ea8..ceee3d9e 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreen.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreen.java @@ -3,6 +3,7 @@ package com.pqt.client.gui.modules.account_screen; import com.pqt.client.gui.modules.IGuiModule; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.client.module.account.AccountService; +import com.pqt.core.entities.user_account.AccountLevel; import javafx.scene.layout.Pane; public class AccountScreen implements IGuiModule { @@ -23,6 +24,11 @@ public class AccountScreen implements IGuiModule { return GUIStringTool.getAccountGuiModuleName(); } + @Override + public AccountLevel getLowestRequiredAccountLevel() { + return AccountLevel.WAITER; + } + @Override public Pane getPane() { return view.getPane(); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenController.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenController.java index f27509ce..4cb8f15f 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenController.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/AccountScreenController.java @@ -28,9 +28,9 @@ class AccountScreenController { private void updateViewActionLock() { if (model.getCurrentAccount() != null) { - view.setAddAccountActionLocked(model.getCurrentAccount().getPermissionLevel().compareTo(AccountLevel.MASTER) >= 0); - view.setDetailAccountActionLocked(view.isItemSelected() && model.getCurrentAccount().getPermissionLevel().compareTo(AccountLevel.MASTER) >= 0); - view.setRemoveAccountActionLocked(view.isItemSelected() && model.getCurrentAccount().getPermissionLevel().compareTo(AccountLevel.MASTER) >= 0); + view.setAddAccountActionLocked(AccountLevel.MASTER.compareTo(model.getCurrentAccount().getPermissionLevel()) > 0); + view.setDetailAccountActionLocked(!view.isItemSelected() || AccountLevel.MASTER.compareTo(model.getCurrentAccount().getPermissionLevel()) > 0); + view.setRemoveAccountActionLocked(!view.isItemSelected() || AccountLevel.MASTER.compareTo(model.getCurrentAccount().getPermissionLevel()) > 0); }else{ view.setAddAccountActionLocked(true); view.setDetailAccountActionLocked(true); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenView.java index 722e54ef..94b85c53 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenView.java @@ -59,7 +59,7 @@ class AccountManagerScreenView implements IFXComponent{ if (event.getButton().equals(MouseButton.PRIMARY)) ctrl.onValidationEvent(); }); - Button cancelButton = new Button(GUIStringTool.getValidationButtonLabel()); + Button cancelButton = new Button(GUIStringTool.getCancelButtonLabel()); cancelButton.setOnMouseClicked(event -> { if (event.getButton().equals(MouseButton.PRIMARY)) ctrl.onCancelEvent(); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java index d9007117..c1e72268 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreen.java @@ -6,6 +6,7 @@ import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.client.module.account.AccountService; import com.pqt.client.module.sale.SaleService; import com.pqt.client.module.stock.StockService; +import com.pqt.core.entities.user_account.AccountLevel; import javafx.scene.layout.Pane; public class SaleScreen implements IGuiModule { @@ -30,4 +31,9 @@ public class SaleScreen implements IGuiModule { public String getModuleName() { return GUIStringTool.getSaleGuiModuleName(); } + + @Override + public AccountLevel getLowestRequiredAccountLevel() { + return AccountLevel.WAITER; + } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java index b3abd1e8..6640d324 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/SaleScreenController.java @@ -30,7 +30,7 @@ class SaleScreenController { @Override public void onSaleNotValidatedEvent(SaleStatus status, Throwable cause) { - SaleScreenController.this.onSaleValidationError(status, cause); + onSaleValidationError(status, cause); } @Override @@ -38,10 +38,17 @@ class SaleScreenController { view.setProducts(model.getProductList()); } + @Override + public void onAccountConnectedStateUpdatedEvent() { + updateActionLock(); + } + @Override public void onAccountListUpdatedEvent() { view.setAccounts(model.getAccountList()); } + + }); } @@ -67,7 +74,14 @@ class SaleScreenController { private void updateSale(){ view.setSale(getCurrentSale()); - view.setValidationButtonEnabled(model.checkValidity(getCurrentSale())); + updateActionLock(); + } + + private void updateActionLock() { + boolean validationButtonEnabled = model.checkValidity(getCurrentSale()) + && model.isCurrentAccountConnected() + && model.getCurrentAccountLevel().compareTo(AccountLevel.WAITER)>=0; + view.setValidationButtonEnabled(validationButtonEnabled); } private void updateData(){ 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 94d59bf2..4cfc6d54 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 @@ -13,6 +13,7 @@ import com.pqt.core.entities.sale.Sale; import com.pqt.core.entities.sale.SaleStatus; import com.pqt.core.entities.sale.SaleType; import com.pqt.core.entities.user_account.Account; +import com.pqt.core.entities.user_account.AccountLevel; import javax.swing.event.EventListenerList; import java.util.Arrays; @@ -100,7 +101,7 @@ class SaleScreenModel { accountService.addListener(new IAccountListener() { @Override public void onAccountStatusChangedEvent(boolean status) { - + fireAccountConnectedStatusUpdateEvent(); } @Override @@ -132,6 +133,11 @@ class SaleScreenModel { .forEach(ISaleScreenModelListener::onAccountListUpdatedEvent); } + private void fireAccountConnectedStatusUpdateEvent() { + Arrays.stream(listeners.getListeners(ISaleScreenModelListener.class)) + .forEach(ISaleScreenModelListener::onAccountConnectedStateUpdatedEvent); + } + List getAccountList() { return accountService.getAllAccounts(); } @@ -205,4 +211,15 @@ class SaleScreenModel { void removeListener(ISaleScreenModelListener listener){ listeners.remove(ISaleScreenModelListener.class, listener); } + + boolean isCurrentAccountConnected() { + return accountService.isCurrentAccountLoggedIn(); + } + + AccountLevel getCurrentAccountLevel() { + if(accountService.getCurrentAccount()!=null) + return accountService.getCurrentAccount().getPermissionLevel(); + else + return AccountLevel.getLowest(); + } } \ No newline at end of file diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/listeners/ISaleScreenModelListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/listeners/ISaleScreenModelListener.java index bfec4762..02996c3e 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/listeners/ISaleScreenModelListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/sale_screen/listeners/ISaleScreenModelListener.java @@ -8,5 +8,6 @@ public interface ISaleScreenModelListener extends EventListener { void onSaleValidatedEvent(); void onSaleNotValidatedEvent(SaleStatus status, Throwable cause); void onStockUpdatedEvent(); + void onAccountConnectedStateUpdatedEvent(); void onAccountListUpdatedEvent(); } 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 3634cc8b..6ef1f98b 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 @@ -3,6 +3,7 @@ package com.pqt.client.gui.modules.stat_screen; import com.pqt.client.gui.modules.IGuiModule; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.client.module.stat.StatService; +import com.pqt.core.entities.user_account.AccountLevel; import javafx.scene.layout.Pane; public class StatScreen implements IGuiModule { @@ -22,6 +23,11 @@ public class StatScreen implements IGuiModule { return GUIStringTool.getStatGuiModuleName(); } + @Override + public AccountLevel getLowestRequiredAccountLevel() { + return AccountLevel.STAFF; + } + @Override public Pane getPane() { return view.getPane(); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreen.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreen.java index 64f4e145..4deb2d97 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreen.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreen.java @@ -3,18 +3,21 @@ package com.pqt.client.gui.modules.stock_screen; import com.pqt.client.gui.modules.IGuiModule; import com.pqt.client.gui.modules.stock_screen.product_manager_screen.ProductManagerScreen; import com.pqt.client.gui.modules.stock_screen.product_manager_screen.ProductManagerScreenFactory; +import com.pqt.client.module.account.AccountService; import com.pqt.client.module.stock.StockService; +import com.pqt.core.entities.user_account.AccountLevel; import javafx.scene.layout.Pane; public class StockScreen implements IGuiModule { private StockScreenView view; - public StockScreen(StockService stockService) { - StockScreenModel model = new StockScreenModel(stockService); + public StockScreen(StockService stockService, AccountService accountService) { + StockScreenModel model = new StockScreenModel(stockService, accountService); StockScreenController ctrl = new StockScreenController(model); view = new StockScreenView(ctrl, new ProductManagerScreenFactory(stockService)); + model.addListener(ctrl); ctrl.setView(view); ctrl.refreshView(); } @@ -24,6 +27,11 @@ public class StockScreen implements IGuiModule { return "Stock"; } + @Override + public AccountLevel getLowestRequiredAccountLevel() { + return AccountLevel.WAITER; + } + @Override public Pane getPane() { return view.getPane(); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenController.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenController.java index 2d85f01d..7418e94f 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenController.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenController.java @@ -7,6 +7,7 @@ import com.pqt.client.gui.modules.stock_screen.product_manager_screen.ProductMan import com.pqt.client.gui.ressources.components.generics.validators.listeners.IValidatorComponentListener; import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.core.entities.product.Product; +import com.pqt.core.entities.user_account.AccountLevel; class StockScreenController implements IStockScreenModelListener{ @@ -87,4 +88,25 @@ class StockScreenController implements IStockScreenModelListener{ public void onStockUpdatedEvent() { refreshView(); } + + @Override + public void onAcccountConnectedStatusUpdatedEvent() { + updateViewActionLock(); + } + + void updateViewActionLock(){ + if(model.isAccountConnected() && model.getConnectedAccountLevel().compareTo(AccountLevel.MASTER)>=0){ + view.setAddProductActionLocked(false); + view.setEditProductActionLocked(view.getSelectedProduct()==null); + view.setRemoveProductActionLocked(view.getSelectedProduct()==null); + }else{ + view.setAddProductActionLocked(true); + view.setEditProductActionLocked(true); + view.setRemoveProductActionLocked(true); + } + } + + void onProductSelectedChange(){ + updateViewActionLock(); + } } 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 cc5a39b1..365c0648 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 @@ -1,9 +1,12 @@ package com.pqt.client.gui.modules.stock_screen; import com.pqt.client.gui.modules.stock_screen.listeners.IStockScreenModelListener; +import com.pqt.client.module.account.AccountService; +import com.pqt.client.module.account.listeners.IAccountListener; import com.pqt.client.module.stock.Listeners.StockListenerAdapter; import com.pqt.client.module.stock.StockService; import com.pqt.core.entities.product.Product; +import com.pqt.core.entities.user_account.AccountLevel; import javax.swing.event.EventListenerList; import java.util.Arrays; @@ -12,9 +15,10 @@ import java.util.Collection; class StockScreenModel { private StockService stockService; + private AccountService accountService; private EventListenerList listenerList; - StockScreenModel(StockService stockService) { + StockScreenModel(StockService stockService, AccountService accountService) { listenerList = new EventListenerList(); this.stockService = stockService; this.stockService.addListener(new StockListenerAdapter(){ @@ -23,6 +27,23 @@ class StockScreenModel { StockScreenModel.this.fireProductCollectionChanged(); } }); + this.accountService = accountService; + this.accountService.addListener(new IAccountListener() { + @Override + public void onAccountStatusChangedEvent(boolean status) { + StockScreenModel.this.fireConnectedStatusChanged(); + } + + @Override + public void onAccountListChangedEvent() { + + } + }); + } + + private void fireConnectedStatusChanged() { + Arrays.stream(listenerList.getListeners(IStockScreenModelListener.class)) + .forEach(IStockScreenModelListener::onAcccountConnectedStatusUpdatedEvent); } private void fireProductCollectionChanged() { @@ -53,4 +74,15 @@ class StockScreenModel { void removeListener(IStockScreenModelListener l){ listenerList.remove(IStockScreenModelListener.class, l); } + + boolean isAccountConnected() { + return accountService.isCurrentAccountLoggedIn(); + } + + AccountLevel getConnectedAccountLevel() { + if(accountService.getCurrentAccount()!=null) + return accountService.getCurrentAccount().getPermissionLevel(); + else + return AccountLevel.getLowest(); + } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java index 5b2b3e26..83034d8d 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java @@ -34,6 +34,9 @@ class StockScreenView implements IFXComponent { private TableView stockTableView; private ProductManagerScreenFactory productManagerScreenFactory; private ProductManagerScreen currentDetailScreen; + private Button addProductButton; + private Button detailProductButton; + private Button removeProductButton; StockScreenView(StockScreenController ctrl, ProductManagerScreenFactory productManagerScreenFactory) { this.ctrl = ctrl; @@ -49,12 +52,12 @@ class StockScreenView implements IFXComponent { mainPaneContent.prefWidthProperty().bind(mainPane.widthProperty()); mainPaneContent.prefHeightProperty().bind(mainPane.heightProperty()); - Button addProductButton = new Button(GUIStringTool.getAddButtonLabel()); + addProductButton = new Button(GUIStringTool.getAddButtonLabel()); addProductButton.setOnMouseClicked(event -> ctrl.onAddProductRequest()); - Button detailProductButton = new Button(GUIStringTool.getDetailButtonLabel()); + detailProductButton = new Button(GUIStringTool.getDetailButtonLabel()); detailProductButton.setOnMouseClicked(event -> ctrl.onDetailProductRequest()); detailProductButton.setDisable(true); - Button removeProductButton = new Button(GUIStringTool.getRemoveButtonLabel()); + removeProductButton = new Button(GUIStringTool.getRemoveButtonLabel()); removeProductButton.setDisable(true); removeProductButton.setOnMouseClicked(event -> ctrl.onDeleteProductRequest()); Button refreshProductButton = new Button(GUIStringTool.getRefreshButtonLabel()); @@ -98,10 +101,7 @@ class StockScreenView implements IFXComponent { return row; }); stockTableView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); - stockTableView.getSelectionModel().selectedItemProperty().addListener((obs, oldVal, newVal)->{ - detailProductButton.setDisable(newVal==null); - removeProductButton.setDisable(newVal==null); - }); + stockTableView.getSelectionModel().selectedItemProperty().addListener((obs, oldVal, newVal)->ctrl.onProductSelectedChange()); List> columns = new ArrayList<>(); columns.add(createNewTableColumn(String.class, @@ -227,4 +227,16 @@ class StockScreenView implements IFXComponent { else return null; } + + void setAddProductActionLocked(boolean locked){ + addProductButton.setDisable(locked); + } + + void setRemoveProductActionLocked(boolean locked){ + removeProductButton.setDisable(locked); + } + + void setEditProductActionLocked(boolean locked){ + detailProductButton.setDisable(locked); + } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/listeners/IStockScreenModelListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/listeners/IStockScreenModelListener.java index b4035570..54604eec 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/listeners/IStockScreenModelListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/listeners/IStockScreenModelListener.java @@ -4,4 +4,5 @@ import java.util.EventListener; public interface IStockScreenModelListener extends EventListener { void onStockUpdatedEvent(); + void onAcccountConnectedStatusUpdatedEvent(); } From 827451d665a3c978baa92ad51745b3e695d68d42 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sat, 19 Aug 2017 21:20:59 +0200 Subject: [PATCH 31/36] =?UTF-8?q?Module=20Client,=20packg=20main=5Fframe?= =?UTF-8?q?=20:=20il=20est=20de=20nouveau=20possible=20de=20demander=20?= =?UTF-8?q?=C3=A0=20ce=20que=20un=20module=20donn=C3=A9=20soit=20actif=20l?= =?UTF-8?q?ors=20de=20son=20ajout=20=C3=A0=20la=20main=20frame?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/pqt/client/Main.java | 2 +- .../pqt/client/gui/main_frame/MainFrame.java | 6 +++++- .../gui/main_frame/MainFrameController.java | 7 +++++-- .../client/gui/main_frame/MainFrameView.java | 17 +++++++++++++++-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/Main.java b/Workspace/client/src/main/java/com/pqt/client/Main.java index 4780949d..c7240576 100644 --- a/Workspace/client/src/main/java/com/pqt/client/Main.java +++ b/Workspace/client/src/main/java/com/pqt/client/Main.java @@ -32,7 +32,7 @@ public class Main extends Application{ StatService statService = new StatService(); MainFrame mainFrame = new MainFrame(accountService); - mainFrame.addModule(new SaleScreen(accountService, stockService, saleService)); + mainFrame.addModule(new SaleScreen(accountService, stockService, saleService), true); mainFrame.addModule(new StockScreen(stockService, accountService)); mainFrame.addModule(new StatScreen(statService)); mainFrame.addModule(new AccountScreen(accountService)); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java index 73d9c53f..4ded52f6 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java @@ -20,8 +20,12 @@ public class MainFrame implements IFXComponent { ctrl.updateView(); } + public void addModule(IGuiModule module, boolean setActive){ + ctrl.addModule(module, setActive); + } + public void addModule(IGuiModule module){ - ctrl.addModule(module); + ctrl.addModule(module, false); } @Override diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java index be3d474d..180f7802 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java @@ -31,8 +31,11 @@ class MainFrameController implements IMainFrameModelListener { view.updateModuleButtonLock(AccountLevel.getLowest()); } - void addModule(IGuiModule module) { - this.view.addGuiModule(module.getModuleName(),module.getPane(), module.getLowestRequiredAccountLevel()); + void addModule(IGuiModule module, boolean activationRequired) { + boolean activate = activationRequired + && model.getCurrentAccount()!=null + && model.getCurrentAccount().getPermissionLevel().compareTo(module.getLowestRequiredAccountLevel())>=0; + this.view.addGuiModule(module.getModuleName(),module.getPane(), module.getLowestRequiredAccountLevel(), activate); } IValidatorComponentListener getAccountManagerValidatorListener() { diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java index d76d2674..7b951581 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java @@ -15,6 +15,8 @@ import javafx.geometry.Orientation; import javafx.scene.Node; import javafx.scene.control.Button; import javafx.scene.control.ToolBar; +import javafx.scene.input.KeyCode; +import javafx.scene.input.MouseButton; import javafx.scene.layout.BorderPane; import javafx.scene.layout.Pane; import javafx.scene.layout.Priority; @@ -87,10 +89,11 @@ class MainFrameView implements IFXComponent{ return mainPane; } - void addGuiModule(String moduleName, Pane moduleContent, AccountLevel requiredLevel){ + void addGuiModule(String moduleName, Pane moduleContent, AccountLevel requiredLevel, boolean setActive){ Button button = new Button(moduleName); button.getStyleClass().add("menu-button"); - button.setOnMouseClicked(event->{ + + Runnable buttonActivationCode = ()->{ buttonHolder.getChildren() .stream() .filter(Button.class::isInstance) @@ -101,9 +104,19 @@ class MainFrameView implements IFXComponent{ buttonHolder.getChildren().forEach(Node::applyCss); mainPane.setCenter(moduleContent); }); + }; + button.setOnMouseClicked(event-> { + if(event.getButton().equals(MouseButton.PRIMARY)) + buttonActivationCode.run(); + }); + button.setOnKeyTyped(event->{ + if (event.getCode().equals(KeyCode.ENTER)) + buttonActivationCode.run(); }); currentAccountLevel.addListener((obs, oldVal, newVal)->button.setDisable(requiredLevel.compareTo(newVal)>0)); button.setDisable(requiredLevel.compareTo(currentAccountLevel.get())>0); + if(setActive) + buttonActivationCode.run(); buttonHolder.getChildren().add(button); } From 367e6391501688cb794bee1746508de71ee44a64 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sun, 20 Aug 2017 16:16:34 +0200 Subject: [PATCH 32/36] Module Client : renommage fichier css ("dark-theme.css" -> "nightmode.css"); Correction bugs divers; Clear de code --- .../AccountManagerScreenView.java | 7 +- .../ProductManagerScreenView.java | 1 - .../components/CategoryTabStockDisplayer.java | 1 - .../CommandComposerSaleDisplayer.java | 1 - .../client/gui/ressources/css/GUICssTool.java | 7 +- .../{dark-theme.css => nightmode.css} | 97 +++---------------- 6 files changed, 18 insertions(+), 96 deletions(-) rename Workspace/client/src/main/resources/{dark-theme.css => nightmode.css} (70%) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenView.java index 94b85c53..3d9d6410 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/account_screen/account_manager_screen/AccountManagerScreenView.java @@ -5,6 +5,7 @@ import com.pqt.client.gui.ressources.strings.GUIStringTool; import com.pqt.core.entities.user_account.Account; import com.pqt.core.entities.user_account.AccountLevel; import javafx.application.Platform; +import javafx.geometry.Pos; import javafx.scene.control.*; import javafx.scene.input.MouseButton; import javafx.scene.layout.*; @@ -14,7 +15,7 @@ import java.util.Collection; class AccountManagerScreenView implements IFXComponent{ - private Pane mainPane; + private StackPane mainPane; private AccountManagerScreenController ctrl; private ChoiceBox levelChoiceBox; @@ -27,11 +28,13 @@ class AccountManagerScreenView implements IFXComponent{ } private void initGui() { - mainPane = new Pane(); + mainPane = new StackPane(); BorderPane mainPaneContent = new BorderPane(); + GridPane mainPaneCenterContent = new GridPane(); + mainPaneCenterContent.setAlignment(Pos.CENTER); Label nameLabel = new Label(GUIStringTool.getUsernameLabel()); nameTextField = new TextField(); nameTextField.textProperty().addListener((obs, oldVal, newVal)->ctrl.onNameChanged(oldVal, newVal)); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenView.java index 3ece4942..d9118917 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/product_manager_screen/ProductManagerScreenView.java @@ -107,7 +107,6 @@ class ProductManagerScreenView implements IFXComponent { mainPaneContent.setCenter(mainPaneCenterContent); VBox mainPaneRightContent = new VBox(); - mainPaneRightContent.getStyleClass().add(GUICssTool.getContainerStyleClass()); mainPaneRightContent.setAlignment(Pos.CENTER); Label title = new Label(GUIStringTool.getComponentListTitleLabel()); title.setAlignment(Pos.CENTER); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java index a8cf9df3..1e95f923 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/CategoryTabStockDisplayer.java @@ -67,7 +67,6 @@ public class CategoryTabStockDisplayer implements IFXDisplayerComponent .split-pane-divider { - -fx-border-color: transparent #1d1d1d transparent #1d1d1d; - -fx-background-color: transparent, derive(#1d1d1d,20%); -} - -.split-pane { - -fx-padding: 1 0 0 0; -} - .grid-pane { -fx-hgap: 10; -fx-vgap: 10; } -.menu-bar { - -fx-background-color: derive(#1d1d1d,20%); -} - .context-menu { - -fx-background-color: derive(#1d1d1d,50%); + -fx-background-color: derive(#1d1d1d,5%); } - -.menu-bar .label { - -fx-font-size: 14pt; - -fx-font-family: "Segoe UI Light"; - -fx-text-fill: white; - -fx-opacity: 0.9; -} - -.menu .left-container { - -fx-background-color: black; -} - -.text-field, .password-field, .choice-box, .text-area { +.text-field, .password-field, .choice-box, .text-area, .combo-box, .button { -fx-font-size: 12pt; -fx-font-family: "Segoe UI Semibold"; - -fx-pref-width: 125; + -fx-pref-width: 150; -fx-pref-height: 30; - -fx-background-radius: 0; -fx-background-color: #1d1d1d; - -fx-background-insets: 0 0 0 0, 0, 1, 2; -fx-border-color: #e2e2e2; -fx-border-width: 2; -fx-text-fill: #d8d8d8; } -.text-area .content { - -fx-background-color: #1d1d1d; - -fx-padding: 15 15 15 15; -} - -#stat-screen-text-area { - -fx-border-width: 0; -} - -.button { - -fx-padding: 5 22 5 22; - -fx-border-color: #e2e2e2; - -fx-border-width: 2; - -fx-background-radius: 0; - -fx-background-color: #1d1d1d; - -fx-font-family: "Segoe UI", Helvetica, Arial, sans-serif; - -fx-font-size: 11pt; - -fx-text-fill: #d8d8d8; - -fx-background-insets: 0 0 0 0, 0, 1, 2; - -fx-pref-width: 125; - -fx-pref-height: 30; -} - .button:hover { -fx-background-color: #3a3a3a; } @@ -236,14 +170,13 @@ -fx-background-color: derive(-fx-focus-color,30%); } -.menu-button-selected { - -fx-background-color: #d8d8d8; - -fx-text-fill: #1d1d1d; +.text-area .content { + -fx-background-color: #1d1d1d; + -fx-padding: 15 15 15 15; } -.menu-button-selected:hover { - -fx-background-color: white; - -fx-text-fill: #1d1d1d; +#stat-screen-text-area { + -fx-border-width: 0; } .progress-indicator { @@ -258,8 +191,6 @@ .main-module-pane { -fx-padding: 10 10 10 10; - -fx-border-width: 2px; - -fx-border-color: whitesmoke; } .validator { @@ -279,7 +210,7 @@ -fx-border-width: 2; -fx-background-radius: 0; -fx-background-insets: 0 0 0 0, 0, 1, 2; - -pqt-expanded-width : 175px; + -pqt-expanded-width : 195px; } .tool-bar { @@ -301,10 +232,4 @@ -fx-border-color: whitesmoke; -fx-border-radius: 6px; -fx-padding: 25px; -} - -.pqt-container { - -fx-border-width: 2px; - -fx-border-color: whitesmoke; - -fx-padding: 5 5 5 5; } \ No newline at end of file From 24066846d3bf1b0eb2d3c5442f27438987a05bc7 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Mon, 21 Aug 2017 22:40:46 +0200 Subject: [PATCH 33/36] =?UTF-8?q?.gitignore=20:=20suppr=20de=20la=20ligne?= =?UTF-8?q?=20d'ignore=20des=20fichiers=20.iml=20(parce=20que=20c'est=20tr?= =?UTF-8?q?=C3=A8s=20con,=20il=20ne=20faut=20pas)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - Workspace/client/client.iml | 16 ++++++++++++++++ Workspace/core/core.iml | 24 ++++++++++++++++++++++++ Workspace/server/server.iml | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 Workspace/client/client.iml create mode 100644 Workspace/core/core.iml create mode 100644 Workspace/server/server.iml diff --git a/.gitignore b/.gitignore index 687c4d1d..9777fe96 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ #Ignoring Intellij workspace specific folders and files /**/.idea/workspace.xml /**/tasks.xml -/**/*.iml /**/.idea/libraries diff --git a/Workspace/client/client.iml b/Workspace/client/client.iml new file mode 100644 index 00000000..e9425931 --- /dev/null +++ b/Workspace/client/client.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace/core/core.iml b/Workspace/core/core.iml new file mode 100644 index 00000000..a1df30e2 --- /dev/null +++ b/Workspace/core/core.iml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace/server/server.iml b/Workspace/server/server.iml new file mode 100644 index 00000000..3284aafa --- /dev/null +++ b/Workspace/server/server.iml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From ea4ccd66013b73f38c7b25347675bc9753e35d15 Mon Sep 17 00:00:00 2001 From: "Notmoo-PC\\Notmoo" Date: Wed, 23 Aug 2017 13:20:31 +0200 Subject: [PATCH 34/36] Update fichiers .iml --- Workspace/client/client.iml | 2 ++ Workspace/core/core.iml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Workspace/client/client.iml b/Workspace/client/client.iml index e9425931..b561a70c 100644 --- a/Workspace/client/client.iml +++ b/Workspace/client/client.iml @@ -6,10 +6,12 @@ + + diff --git a/Workspace/core/core.iml b/Workspace/core/core.iml index a1df30e2..192d284a 100644 --- a/Workspace/core/core.iml +++ b/Workspace/core/core.iml @@ -15,10 +15,12 @@ + + \ No newline at end of file From 03572139b71e42813092b9c19b9e2c15a16ee681 Mon Sep 17 00:00:00 2001 From: "Notmoo-PC\\Notmoo" Date: Wed, 23 Aug 2017 13:21:31 +0200 Subject: [PATCH 35/36] Module Client, clss StatScreenView : suppr de l'utilisation de la clss com.sun.deploy.util.StringUtils --- .../com/pqt/client/gui/modules/stat_screen/StatScreenView.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 ca13ed3d..a9a79644 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 @@ -2,7 +2,6 @@ package com.pqt.client.gui.modules.stat_screen; import com.pqt.client.gui.ressources.components.generics.IFXComponent; import com.pqt.client.gui.ressources.css.GUICssTool; -import com.sun.deploy.util.StringUtils; import javafx.application.Platform; import javafx.scene.control.TextArea; import javafx.scene.layout.Pane; @@ -43,7 +42,7 @@ class StatScreenView implements IFXComponent { .map(key->String.format(" * %s : %s", key, statistics.get(key))) .collect(Collectors.toList())); - Platform.runLater(()->statTextArea.setText(StringUtils.join(lines, "\n"))); + Platform.runLater(()->lines.forEach(line -> statTextArea.appendText(line+"\n"))); } @Override From 599ebae0192c01779346f977b2b3a57a964126d3 Mon Sep 17 00:00:00 2001 From: "Notmoo-PC\\Notmoo" Date: Wed, 23 Aug 2017 13:21:58 +0200 Subject: [PATCH 36/36] =?UTF-8?q?Module=20Core,=20clss=20GSonMEssageToolFa?= =?UTF-8?q?ctory=20:=20suppr=20des=20imports=20inutilis=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/pqt/core/communication/GSonMessageToolFactory.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Workspace/core/src/main/java/com/pqt/core/communication/GSonMessageToolFactory.java b/Workspace/core/src/main/java/com/pqt/core/communication/GSonMessageToolFactory.java index 9eac8abd..939c3bda 100644 --- a/Workspace/core/src/main/java/com/pqt/core/communication/GSonMessageToolFactory.java +++ b/Workspace/core/src/main/java/com/pqt/core/communication/GSonMessageToolFactory.java @@ -3,13 +3,6 @@ package com.pqt.core.communication; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; -import com.pqt.core.entities.members.PqtMember; -import com.pqt.core.entities.members.PqtMemberType; -import com.pqt.core.entities.messages.Message; -import com.pqt.core.entities.messages.MessageType; -import com.pqt.core.entities.product.Product; -import com.pqt.core.entities.product.ProductUpdate; -import com.pqt.core.entities.sale.Sale; import java.lang.reflect.Type; import java.util.ArrayList;