Module Client : test de l'écran de composition des ventes; correction bugs; ajout fichier css; réorganisation packages

This commit is contained in:
Notmoo 2017-08-14 16:38:03 +02:00
parent 0eef751c41
commit d1fdc64cad
46 changed files with 522 additions and 205 deletions

View File

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

View File

@ -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

View File

@ -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<Product> 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

View File

@ -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<Product> 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){

View File

@ -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<Account> saleBeneficiaryAccountDisplayer;
private ChoiceBox<SaleType> 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<SaleType> 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 <T> void selectElement(ChoiceBox<T> 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);
}
}

View File

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

View File

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

View File

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

View File

@ -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<Collecti
private void init(){
mainPane = new BorderPane();
mainPane.getStyleClass().add("stock-displayer");
Label title = new Label(GUIStringTool.getCategorytabStockDisplayerTitle());
mainPane.setTop(title);
title.setAlignment(Pos.CENTER);
HBox topPane = new HBox();
topPane.setFillHeight(true);
topPane.setAlignment(Pos.CENTER);
topPane.getChildren().add(title);
mainPane.setTop(topPane);
tabPane = new TabPane();
mainPane.setCenter(tabPane);

View File

@ -1,16 +1,18 @@
package com.pqt.client.gui.ressources.components;
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.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.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;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import java.util.ArrayList;
@ -30,8 +32,16 @@ public class CommandComposerSaleDisplayer implements IFXSaleDisplayerComponent {
private void init() {
mainPane = new BorderPane();
mainPane.getStyleClass().add("sale-displayer");
Label title = new Label(GUIStringTool.getCommandComposerTitleTitle());
mainPane.setTop(title);
HBox topPane = new HBox();
topPane.setFillHeight(true);
topPane.setAlignment(Pos.CENTER);
topPane.getChildren().add(title);
mainPane.setTop(topPane);
listView = new ListView<>();
listView.setCellFactory(list->new ListCell<Product>(){

View File

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

View File

@ -1,4 +1,4 @@
package com.pqt.client.gui.ressources.generics;
package com.pqt.client.gui.ressources.components.generics;
import javafx.scene.layout.Pane;

View File

@ -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<T> extends IFXComponent{
T create();
boolean isCreationPossible();
}

View File

@ -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<T, U extends IDisplayerComponentListener> extends IFXComponent{
void display(T content);
void addListener(U l);
void removeListener(U l);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<Collection<Account>, IAccountComponentListener> {
}

View File

@ -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<Account>{
}

View File

@ -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<Account, IAccountComponentListener> {

View File

@ -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<Collection<Product>, IStockComponentListener> {
}

View File

@ -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<Product> {
}

View File

@ -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<Product, IStockComponentListener> {

View File

@ -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<Sale, ISaleComponentListener> {
}

View File

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

View File

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

View File

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

View File

@ -1,8 +0,0 @@
package com.pqt.client.gui.ressources.generics.creators;
import com.pqt.client.gui.ressources.generics.IFXComponent;
public interface IFXCreatorComponent<T> extends IFXComponent{
T create();
boolean isCreationPossible();
}

View File

@ -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<T, U extends IDisplayerComponentListener> extends IFXComponent{
void display(T content);
void addListener(U l);
void removeListener(U l);
}

View File

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

View File

@ -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<Collection<Account>, IAccountComponentListener> {
}

View File

@ -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<Account>{
}

View File

@ -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<Collection<Product>, IStockComponentListener> {
}

View File

@ -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<Product> {
}

View File

@ -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<Sale, ISaleComponentListener> {
}

View File

@ -55,7 +55,10 @@ public class GUIStringTool {
return new StringConverter<Account>() {
@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

View File

@ -12,4 +12,11 @@ public class AccountListenerAdapter implements IAccountListener {
}
/**
* @see com.pqt.client.module.account.listeners.IAccountListener#onAccountListChangedEvent()
*/
public void onAccountListChangedEvent() {
}
}

View File

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

View File

@ -13,7 +13,7 @@ public class StockService {
private StockDao dao;
private StockService() {
public StockService() {
dao = new StockDao();
}

View File

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

View File

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