mirror of
				https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
				synced 2025-10-31 00:53:10 +00:00 
			
		
		
		
	Module Client : ajout de restrictions d'actions et de navigation en fonction du niveau de permission du compte actuellement connecté
This commit is contained in:
		| @@ -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()); | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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(); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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<AccountLevel> 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<Account> accounts){ | ||||
|         accountManager.display(accounts); | ||||
|     } | ||||
|  | ||||
|     void updateModuleButtonLock(AccountLevel level) { | ||||
|         currentAccountLevel.setValue(level); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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(); | ||||
| } | ||||
|   | ||||
| @@ -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(); | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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(); | ||||
|   | ||||
| @@ -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; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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(){ | ||||
|   | ||||
| @@ -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<Account> 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(); | ||||
|     } | ||||
| } | ||||
| @@ -8,5 +8,6 @@ public interface ISaleScreenModelListener extends EventListener { | ||||
|     void onSaleValidatedEvent(); | ||||
|     void onSaleNotValidatedEvent(SaleStatus status, Throwable cause); | ||||
|     void onStockUpdatedEvent(); | ||||
|     void onAccountConnectedStateUpdatedEvent(); | ||||
|     void onAccountListUpdatedEvent(); | ||||
| } | ||||
|   | ||||
| @@ -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(); | ||||
|   | ||||
| @@ -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(); | ||||
|   | ||||
| @@ -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(); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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(); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -34,6 +34,9 @@ class StockScreenView implements IFXComponent { | ||||
|     private TableView<Product> 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<TableColumn<Product, ?>> 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); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -4,4 +4,5 @@ import java.util.EventListener; | ||||
|  | ||||
| public interface IStockScreenModelListener extends EventListener { | ||||
|     void onStockUpdatedEvent(); | ||||
|     void onAcccountConnectedStatusUpdatedEvent(); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user