mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-12-22 15:31:08 +00:00
Module Client, packg main_frame : il est de nouveau possible de demander à ce que un module donné soit actif lors de son ajout à la main frame
This commit is contained in:
parent
b46eeec815
commit
827451d665
@ -32,7 +32,7 @@ public class Main extends Application{
|
||||
StatService statService = new StatService();
|
||||
|
||||
MainFrame mainFrame = new MainFrame(accountService);
|
||||
mainFrame.addModule(new SaleScreen(accountService, stockService, saleService));
|
||||
mainFrame.addModule(new SaleScreen(accountService, stockService, saleService), true);
|
||||
mainFrame.addModule(new StockScreen(stockService, accountService));
|
||||
mainFrame.addModule(new StatScreen(statService));
|
||||
mainFrame.addModule(new AccountScreen(accountService));
|
||||
|
@ -20,8 +20,12 @@ public class MainFrame implements IFXComponent {
|
||||
ctrl.updateView();
|
||||
}
|
||||
|
||||
public void addModule(IGuiModule module, boolean setActive){
|
||||
ctrl.addModule(module, setActive);
|
||||
}
|
||||
|
||||
public void addModule(IGuiModule module){
|
||||
ctrl.addModule(module);
|
||||
ctrl.addModule(module, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,8 +31,11 @@ class MainFrameController implements IMainFrameModelListener {
|
||||
view.updateModuleButtonLock(AccountLevel.getLowest());
|
||||
}
|
||||
|
||||
void addModule(IGuiModule module) {
|
||||
this.view.addGuiModule(module.getModuleName(),module.getPane(), module.getLowestRequiredAccountLevel());
|
||||
void addModule(IGuiModule module, boolean activationRequired) {
|
||||
boolean activate = activationRequired
|
||||
&& model.getCurrentAccount()!=null
|
||||
&& model.getCurrentAccount().getPermissionLevel().compareTo(module.getLowestRequiredAccountLevel())>=0;
|
||||
this.view.addGuiModule(module.getModuleName(),module.getPane(), module.getLowestRequiredAccountLevel(), activate);
|
||||
}
|
||||
|
||||
IValidatorComponentListener getAccountManagerValidatorListener() {
|
||||
|
@ -15,6 +15,8 @@ import javafx.geometry.Orientation;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToolBar;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.Priority;
|
||||
@ -87,10 +89,11 @@ class MainFrameView implements IFXComponent{
|
||||
return mainPane;
|
||||
}
|
||||
|
||||
void addGuiModule(String moduleName, Pane moduleContent, AccountLevel requiredLevel){
|
||||
void addGuiModule(String moduleName, Pane moduleContent, AccountLevel requiredLevel, boolean setActive){
|
||||
Button button = new Button(moduleName);
|
||||
button.getStyleClass().add("menu-button");
|
||||
button.setOnMouseClicked(event->{
|
||||
|
||||
Runnable buttonActivationCode = ()->{
|
||||
buttonHolder.getChildren()
|
||||
.stream()
|
||||
.filter(Button.class::isInstance)
|
||||
@ -101,9 +104,19 @@ class MainFrameView implements IFXComponent{
|
||||
buttonHolder.getChildren().forEach(Node::applyCss);
|
||||
mainPane.setCenter(moduleContent);
|
||||
});
|
||||
};
|
||||
button.setOnMouseClicked(event-> {
|
||||
if(event.getButton().equals(MouseButton.PRIMARY))
|
||||
buttonActivationCode.run();
|
||||
});
|
||||
button.setOnKeyTyped(event->{
|
||||
if (event.getCode().equals(KeyCode.ENTER))
|
||||
buttonActivationCode.run();
|
||||
});
|
||||
currentAccountLevel.addListener((obs, oldVal, newVal)->button.setDisable(requiredLevel.compareTo(newVal)>0));
|
||||
button.setDisable(requiredLevel.compareTo(currentAccountLevel.get())>0);
|
||||
if(setActive)
|
||||
buttonActivationCode.run();
|
||||
buttonHolder.getChildren().add(button);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user