mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-12-22 23:41:09 +00:00
Module client, packg GUI : ajout interfaces générales des composants GUI (part 2/2)
This commit is contained in:
parent
5183b47330
commit
6e0f3f625c
@ -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<Product> products);
|
||||
void addListener(IStockComponentListener l);
|
||||
void removeListener(IStockComponentListener l);
|
||||
}
|
@ -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();
|
||||
}
|
@ -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();
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
@ -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);
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package com.pqt.client.module.gui.ressources.components.sale.listeners;
|
||||
|
||||
public interface ISaleComponentFirerer {
|
||||
//TODO faire ça
|
||||
}
|
@ -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
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package com.pqt.client.module.gui.ressources.components.sale.listeners;
|
||||
|
||||
public class SimpleSaleComponentFirerer implements ISaleComponentFirerer {
|
||||
//TODO faire ça
|
||||
}
|
@ -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);
|
||||
}
|
@ -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;
|
||||
|
@ -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<T> extends IFXComponent{
|
||||
T create();
|
||||
boolean isCreationPossible();
|
||||
}
|
@ -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<T, U extends IDisplayerComponentListener> extends IFXComponent{
|
||||
void display(T content);
|
||||
void addListener(U l);
|
||||
void removeListener(U l);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.pqt.client.module.gui.ressources.generics.displayers.listeners;
|
||||
|
||||
import javafx.event.Event;
|
||||
|
||||
public interface IDisplayerComponentFirerer<T> {
|
||||
void fireRefreshContentRequestEvent();
|
||||
void fireContentClickEvent(Event event, T eventTarget);
|
||||
void fireAddContentRequestEvent();
|
||||
void fireRemoveContentRequestEvent(T content);
|
||||
void fireDetailContentRequestEvent(T content);
|
||||
void addListener(IDisplayerComponentListener<T> l);
|
||||
void removeListener(IDisplayerComponentListener<T> l);
|
||||
}
|
@ -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<T> extends EventListener {
|
||||
void onRefreshContentRequestEvent();
|
||||
void onContentClickEvent(Event event, T eventTarget);
|
||||
void onAddContentRequestEvent();
|
||||
void onRemoveContentRequestEvent(T content);
|
||||
void onDetailContentRequestEvent(T content);
|
||||
}
|
@ -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<T, U extends IDisplayerComponentListener<T>> implements IDisplayerComponentFirerer<T> {
|
||||
|
||||
protected EventListenerList listenerList;
|
||||
protected Class<U> clazz;
|
||||
|
||||
public SimpleDisplayerComponentFirerer(Class<U> 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<T> 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<T> l) {
|
||||
if (clazz.isInstance(l)) {
|
||||
listenerList.remove(clazz, clazz.cast(l));
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
@ -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);
|
@ -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;
|
||||
|
@ -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;
|
@ -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<Collection<Account>, IAccountComponentListener>{
|
||||
|
||||
}
|
@ -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<Account>{
|
||||
}
|
@ -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<Account, IAccountComponentListener>{
|
||||
public SimpleAccountComponentFirerer() {
|
||||
super(IAccountComponentListener.class);
|
||||
}
|
||||
}
|
@ -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<Collection<Product>, IStockComponentListener> {
|
||||
}
|
@ -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<Product> {
|
||||
}
|
@ -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<Product, IStockComponentListener> {
|
||||
|
||||
public SimpleStockComponentFirerer() {
|
||||
super(IStockComponentListener.class);
|
||||
}
|
||||
}
|
@ -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<Sale, ISaleComponentListener> {
|
||||
}
|
@ -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<Sale> {
|
||||
void onComponentClickEvent(Event event, Product product);
|
||||
}
|
@ -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<Sale, ISaleComponentListener> {
|
||||
|
||||
public SimpleSaleComponentFirerer() {
|
||||
super(ISaleComponentListener.class);
|
||||
}
|
||||
|
||||
public void fireComponentClickEvent(Event event, Product product) {
|
||||
Arrays.stream(listenerList.getListeners(ISaleComponentListener.class)).forEach(l->l.onComponentClickEvent(event, product));
|
||||
}
|
||||
}
|
@ -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<Product> 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<Product> getSaleItemStringRenderer(){
|
||||
return (product, qté)->String.format("%s - %.2f€ (%s)", product.getName(), product.getPrice(), (product.getAmountRemaining()>=30?"30+": Integer.toString(product.getAmountRemaining())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
package com.pqt.client.module.gui.ressources.strings;
|
||||
|
||||
public interface IObjectStringRenderer<T> {
|
||||
String render(T obj);
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.pqt.client.module.gui.ressources.strings;
|
||||
|
||||
public interface IObjectWithQuantityStringRenderer<T> {
|
||||
String render(T obj, int quantity);
|
||||
}
|
Loading…
Reference in New Issue
Block a user