mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-11-22 08:13:20 +00:00
Revert "[CLIENT] #16 : ProductManagerScreen : modification de l'update des données; certains champs et boutons sont désormais bloqué dans certaines conditions; Correction potentielle NPE durant le check de faisabilité du produit"
This reverts commit c8832f6f35
.
This commit is contained in:
parent
c8832f6f35
commit
32d0f40145
@ -21,7 +21,6 @@ class ProductManagerScreenController {
|
|||||||
|
|
||||||
void setView(ProductManagerScreenView view){
|
void setView(ProductManagerScreenView view){
|
||||||
this.view = view;
|
this.view = view;
|
||||||
view.setCategoryCollection(model.getCategoryCollection());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeListener<? super Product> getProductComponentSelectionListener() {
|
ChangeListener<? super Product> getProductComponentSelectionListener() {
|
||||||
@ -37,10 +36,9 @@ class ProductManagerScreenController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateView() {
|
void updateView() {
|
||||||
//view.setCategoryCollection(model.getCategoryCollection());
|
|
||||||
view.setProduct(model.getActualProductState());
|
view.setProduct(model.getActualProductState());
|
||||||
|
view.setCategoryCollection(model.getCategoryCollection());
|
||||||
view.setProductCollection(model.getEligibleComponentList());
|
view.setProductCollection(model.getEligibleComponentList());
|
||||||
view.updateGuiLocks();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IValidatorComponentListener getValidatorListener() {
|
IValidatorComponentListener getValidatorListener() {
|
||||||
@ -65,46 +63,32 @@ class ProductManagerScreenController {
|
|||||||
listenerList.remove(IValidatorComponentListener.class, l);
|
listenerList.remove(IValidatorComponentListener.class, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean lockAmountRemainingfield(){
|
|
||||||
return !model.getActualProductState().getComponents().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean lockValidationButton(){
|
|
||||||
return !model.isProductCreationPossible();
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isProductHighlighted(Product product) {
|
boolean isProductHighlighted(Product product) {
|
||||||
return model.getActualProductState().getComponents().contains(product);
|
return model.getActualProductState().getComponents().contains(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onNameChanged(String newVal) {
|
void onNameChanged(String oldVal, String newVal) {
|
||||||
model.changeName(newVal);
|
model.changeName(newVal);
|
||||||
updateView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onPriceChanged(double newVal) {
|
void onPriceChanged(double oldVal, double newVal) {
|
||||||
model.changePrice(newVal);
|
model.changePrice(newVal);
|
||||||
updateView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onCategoryChanged(Category newVal) {
|
void onCategoryChanged(Category oldVal, Category newVal) {
|
||||||
model.changeCategory(newVal);
|
model.changeCategory(newVal);
|
||||||
view.updateGuiLocks();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAmountRemainingChanged(int newVal) {
|
void onAmountRemainingChanged(int oldVal, int newVal) {
|
||||||
model.changeAmountRemaining(newVal);
|
model.changeAmountRemaining(newVal);
|
||||||
updateView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAmountSoldChanged(int newVal) {
|
void onAmountSoldChanged(int oldVal, int newVal) {
|
||||||
model.changeAmountSold(newVal);
|
model.changeAmountSold(newVal);
|
||||||
updateView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onSellableStateChanged(boolean newVal) {
|
void onSellableStateChanged(boolean oldVal, boolean newVal) {
|
||||||
model.setSellable(newVal);
|
model.setSellable(newVal);
|
||||||
updateView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
|
@ -39,7 +39,6 @@ class ProductManagerScreenModel {
|
|||||||
|
|
||||||
boolean isProductCreationPossible() {
|
boolean isProductCreationPossible() {
|
||||||
return (initialData==null || !areProductsEqual(initialData, currentData))
|
return (initialData==null || !areProductsEqual(initialData, currentData))
|
||||||
&& currentData.getName() != null
|
|
||||||
&& !currentData.getName().isEmpty()
|
&& !currentData.getName().isEmpty()
|
||||||
&& currentData.getCategory()!=null
|
&& currentData.getCategory()!=null
|
||||||
&& currentData.getPrice()>=0;
|
&& currentData.getPrice()>=0;
|
||||||
|
@ -32,7 +32,6 @@ class ProductManagerScreenView implements IFXComponent {
|
|||||||
private ComboBox<Category> productCategoryComboBox;
|
private ComboBox<Category> productCategoryComboBox;
|
||||||
private CheckBox productSellableCheckBox;
|
private CheckBox productSellableCheckBox;
|
||||||
private ListView<Product> productComponentsListView;
|
private ListView<Product> productComponentsListView;
|
||||||
private SimpleValidator validator;
|
|
||||||
|
|
||||||
ProductManagerScreenView(ProductManagerScreenController ctrl) {
|
ProductManagerScreenView(ProductManagerScreenController ctrl) {
|
||||||
this.ctrl = ctrl;
|
this.ctrl = ctrl;
|
||||||
@ -53,69 +52,54 @@ class ProductManagerScreenView implements IFXComponent {
|
|||||||
|
|
||||||
Label productNameLabel = new Label(GUIStringTool.getProductNameLabel());
|
Label productNameLabel = new Label(GUIStringTool.getProductNameLabel());
|
||||||
productNameTextField = new TextField();
|
productNameTextField = new TextField();
|
||||||
productNameTextField.focusedProperty().addListener((obs, oldVal, newVal)->{
|
productNameTextField.textProperty().addListener((obs, oldVal, newVal)->ctrl.onNameChanged(oldVal,newVal));
|
||||||
if(!newVal)
|
|
||||||
ctrl.onNameChanged(productNameTextField.getText());
|
|
||||||
});
|
|
||||||
addLineToGrid(mainPaneCenterContent, productNameLabel, productNameTextField);
|
addLineToGrid(mainPaneCenterContent, productNameLabel, productNameTextField);
|
||||||
|
|
||||||
Label productCategoryLabel = new Label(GUIStringTool.getProductCategoryLabel());
|
Label productCategoryLabel = new Label(GUIStringTool.getProductCategoryLabel());
|
||||||
productCategoryComboBox = new ComboBox<>();
|
productCategoryComboBox = new ComboBox<>();
|
||||||
productCategoryComboBox.setEditable(true);
|
productCategoryComboBox.setEditable(true);
|
||||||
productCategoryComboBox.setConverter(GUIStringTool.getCategoryStringConverter());
|
productCategoryComboBox.setConverter(GUIStringTool.getCategoryStringConverter());
|
||||||
productCategoryComboBox.valueProperty().addListener((obs, oldVal, newVal)->{
|
productCategoryComboBox.valueProperty().addListener((obs, oldVal, newVal)->ctrl.onCategoryChanged(oldVal, newVal));
|
||||||
ctrl.onCategoryChanged(newVal);
|
|
||||||
});
|
|
||||||
addLineToGrid(mainPaneCenterContent, productCategoryLabel, productCategoryComboBox);
|
addLineToGrid(mainPaneCenterContent, productCategoryLabel, productCategoryComboBox);
|
||||||
|
|
||||||
Label productAmountRemainingLabel = new Label(GUIStringTool.getProductAmountRemainingLabel());
|
Label productAmountRemainingLabel = new Label(GUIStringTool.getProductAmountRemainingLabel());
|
||||||
productAmountRemainingTextField = getNumberOnlyTextField(intFormat);
|
productAmountRemainingTextField = getNumberOnlyTextField(intFormat);
|
||||||
productAmountRemainingTextField.focusedProperty().addListener((obs, oldVal, newVal)->{
|
productAmountRemainingTextField.textProperty().addListener((obs, oldVal, newVal)->{
|
||||||
if(!newVal) {
|
try{
|
||||||
try {
|
int oldInt = oldVal.isEmpty()?0:Integer.parseInt(oldVal);
|
||||||
int newInt = productAmountRemainingTextField.getText().isEmpty() ?
|
int newInt = newVal.isEmpty()?0:Integer.parseInt(newVal);
|
||||||
0 :
|
ctrl.onAmountRemainingChanged(oldInt, newInt);
|
||||||
Integer.parseInt(productAmountRemainingTextField.getText());
|
}catch(NumberFormatException e){
|
||||||
ctrl.onAmountRemainingChanged(newInt);
|
e.printStackTrace();
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addLineToGrid(mainPaneCenterContent, productAmountRemainingLabel, productAmountRemainingTextField);
|
addLineToGrid(mainPaneCenterContent, productAmountRemainingLabel, productAmountRemainingTextField);
|
||||||
|
|
||||||
Label productAmountSoldLabel = new Label(GUIStringTool.getProductAmountSoldLabel());
|
Label productAmountSoldLabel = new Label(GUIStringTool.getProductAmountSoldLabel());
|
||||||
productAmountSoldTextField = getNumberOnlyTextField(intFormat);
|
productAmountSoldTextField = getNumberOnlyTextField(intFormat);
|
||||||
productAmountSoldTextField.focusedProperty().addListener((obs, oldVal, newVal)->{
|
productAmountSoldTextField.textProperty().addListener((obs, oldVal, newVal)->{
|
||||||
if(!newVal) {
|
try{
|
||||||
try {
|
int oldInt = oldVal.isEmpty()?0:Integer.parseInt(oldVal);
|
||||||
int newInt = productAmountSoldTextField.getText().isEmpty() ?
|
int newInt = newVal.isEmpty()?0:Integer.parseInt(newVal);
|
||||||
0 :
|
ctrl.onAmountSoldChanged(oldInt, newInt);
|
||||||
Integer.parseInt(productAmountSoldTextField.getText());
|
}catch(NumberFormatException e){
|
||||||
ctrl.onAmountSoldChanged(newInt);
|
e.printStackTrace();
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addLineToGrid(mainPaneCenterContent, productAmountSoldLabel, productAmountSoldTextField);
|
addLineToGrid(mainPaneCenterContent, productAmountSoldLabel, productAmountSoldTextField);
|
||||||
|
|
||||||
Label productSellableLabel = new Label(GUIStringTool.getProductSellableLabel());
|
Label productSellableLabel = new Label(GUIStringTool.getProductSellableLabel());
|
||||||
productSellableCheckBox = new CheckBox();
|
productSellableCheckBox = new CheckBox();
|
||||||
productSellableCheckBox.selectedProperty().addListener((obs, oldVal, newVal)->ctrl.onSellableStateChanged(newVal));
|
productSellableCheckBox.selectedProperty().addListener((obs, oldVal, newVal)->ctrl.onSellableStateChanged(oldVal,newVal));
|
||||||
addLineToGrid(mainPaneCenterContent, productSellableLabel, productSellableCheckBox);
|
addLineToGrid(mainPaneCenterContent, productSellableLabel, productSellableCheckBox);
|
||||||
|
|
||||||
Label productPriceLabel = new Label(GUIStringTool.getProductPriceLabel());
|
Label productPriceLabel = new Label(GUIStringTool.getProductPriceLabel());
|
||||||
productPriceTextField = getNumberOnlyTextField(priceFormat);
|
productPriceTextField = getNumberOnlyTextField(priceFormat);
|
||||||
productPriceTextField.focusedProperty().addListener((obs, oldVal, newVal)->{
|
productPriceTextField.textProperty().addListener((obs, oldVal, newVal)->{
|
||||||
if(!newVal) {
|
try{
|
||||||
try {
|
ctrl.onPriceChanged((oldVal.isEmpty()?-1:Double.parseDouble(oldVal)), (newVal.isEmpty()?-1:Double.parseDouble(newVal)));
|
||||||
ctrl.onPriceChanged((productPriceTextField.getText().isEmpty() ?
|
}catch(NumberFormatException e){
|
||||||
-1 :
|
e.printStackTrace();
|
||||||
Double.parseDouble(productPriceTextField.getText())));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addLineToGrid(mainPaneCenterContent, productPriceLabel, productPriceTextField);
|
addLineToGrid(mainPaneCenterContent, productPriceLabel, productPriceTextField);
|
||||||
@ -163,7 +147,7 @@ class ProductManagerScreenView implements IFXComponent {
|
|||||||
|
|
||||||
HBox mainPaneBottomContent = new HBox();
|
HBox mainPaneBottomContent = new HBox();
|
||||||
HBox separator = new HBox();
|
HBox separator = new HBox();
|
||||||
validator = new SimpleValidator();
|
SimpleValidator validator = new SimpleValidator();
|
||||||
validator.addListener(ctrl.getValidatorListener());
|
validator.addListener(ctrl.getValidatorListener());
|
||||||
mainPaneBottomContent.getChildren().addAll(separator, validator.getPane());
|
mainPaneBottomContent.getChildren().addAll(separator, validator.getPane());
|
||||||
HBox.setHgrow(separator, Priority.ALWAYS);
|
HBox.setHgrow(separator, Priority.ALWAYS);
|
||||||
@ -225,14 +209,6 @@ class ProductManagerScreenView implements IFXComponent {
|
|||||||
productComponentsListView.getItems().addAll(productCollection);
|
productComponentsListView.getItems().addAll(productCollection);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateGuiLocks(){
|
|
||||||
Platform.runLater(()->{
|
|
||||||
productAmountRemainingTextField.setDisable(ctrl.lockAmountRemainingfield());
|
|
||||||
validator.setValidationButtonEnable(!ctrl.lockValidationButton());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
ctrl = null;
|
ctrl = null;
|
||||||
}
|
}
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
package com.pqt.server;
|
|
||||||
|
|
||||||
import com.pqt.core.communication.GSonMessageToolFactory;
|
|
||||||
import com.pqt.core.communication.IMessageToolFactory;
|
|
||||||
import com.pqt.core.communication.IObjectFormatter;
|
|
||||||
import com.pqt.core.entities.messages.Message;
|
|
||||||
import com.pqt.core.entities.messages.MessageType;
|
|
||||||
import com.pqt.core.entities.product.Category;
|
|
||||||
import com.pqt.core.entities.product.Product;
|
|
||||||
import com.pqt.core.entities.user_account.Account;
|
|
||||||
import com.pqt.core.entities.user_account.AccountLevel;
|
|
||||||
import com.pqt.server.module.account.FileAccountDao;
|
|
||||||
import com.pqt.server.module.account.IAccountDao;
|
|
||||||
import com.pqt.server.module.stock.FileStockDao;
|
|
||||||
import com.pqt.server.module.stock.IStockDao;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TestMain {
|
|
||||||
|
|
||||||
public static void main(String[] args){
|
|
||||||
|
|
||||||
IMessageToolFactory messageToolFactory = new GSonMessageToolFactory();
|
|
||||||
IObjectFormatter<Message> messageFormater = messageToolFactory.getObjectFormatter(Message.class);
|
|
||||||
System.out.println(messageFormater.format(new Message(MessageType.QUERY_PING, null, null, null, null)));
|
|
||||||
|
|
||||||
//generateAccountFile();
|
|
||||||
//generateProductFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void generateProductFile(){
|
|
||||||
System.out.println("PRODUCTS");
|
|
||||||
List<Product> products = new ArrayList<>();
|
|
||||||
|
|
||||||
Category mealsCat = new Category(0, "Meals");
|
|
||||||
Category drinksCat = new Category(1, "Drinks");
|
|
||||||
Category sidesCat = new Category(2, "Sides");
|
|
||||||
|
|
||||||
//long id, String name, int amountRemaining, int amountSold, boolean sellable, double price, List<Long> components, Category category
|
|
||||||
products.add(new Product(0, "Meal 1", 10, 0, true, 1d, null, mealsCat));
|
|
||||||
products.add(new Product(0, "Meal 2", 20, 10, true, 1.5d, null, mealsCat));
|
|
||||||
products.add(new Product(0, "Drink 1", 30, 20, true, 2d, null, drinksCat));
|
|
||||||
products.add(new Product(0, "Side 1", 40, 30, true, 2.5d, null, sidesCat));
|
|
||||||
|
|
||||||
IStockDao stockDao = new FileStockDao("G:\\temp");
|
|
||||||
products.forEach(stockDao::addProduct);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void generateAccountFile(){
|
|
||||||
System.out.println("ACCOUNTS");
|
|
||||||
List<Account> accounts = new ArrayList<>();
|
|
||||||
|
|
||||||
accounts.add(new Account("Master", "Master", AccountLevel.MASTER));
|
|
||||||
accounts.add(new Account("Waiter", "Waiter", AccountLevel.WAITER));
|
|
||||||
accounts.add(new Account("Guest", "Guest", AccountLevel.GUEST));
|
|
||||||
accounts.add(new Account("Staff", "Staff", AccountLevel.STAFF));
|
|
||||||
accounts.add(new Account("Lowest", "Lowest", AccountLevel.LOWEST));
|
|
||||||
|
|
||||||
IAccountDao accountDao = new FileAccountDao("G:\\temp");
|
|
||||||
accounts.forEach(accountDao::addAccount);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user