mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-11-16 21:33:21 +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();
|
StatService statService = new StatService();
|
||||||
|
|
||||||
MainFrame mainFrame = new MainFrame(accountService);
|
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 StockScreen(stockService, accountService));
|
||||||
mainFrame.addModule(new StatScreen(statService));
|
mainFrame.addModule(new StatScreen(statService));
|
||||||
mainFrame.addModule(new AccountScreen(accountService));
|
mainFrame.addModule(new AccountScreen(accountService));
|
||||||
|
@ -20,8 +20,12 @@ public class MainFrame implements IFXComponent {
|
|||||||
ctrl.updateView();
|
ctrl.updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addModule(IGuiModule module, boolean setActive){
|
||||||
|
ctrl.addModule(module, setActive);
|
||||||
|
}
|
||||||
|
|
||||||
public void addModule(IGuiModule module){
|
public void addModule(IGuiModule module){
|
||||||
ctrl.addModule(module);
|
ctrl.addModule(module, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,8 +31,11 @@ class MainFrameController implements IMainFrameModelListener {
|
|||||||
view.updateModuleButtonLock(AccountLevel.getLowest());
|
view.updateModuleButtonLock(AccountLevel.getLowest());
|
||||||
}
|
}
|
||||||
|
|
||||||
void addModule(IGuiModule module) {
|
void addModule(IGuiModule module, boolean activationRequired) {
|
||||||
this.view.addGuiModule(module.getModuleName(),module.getPane(), module.getLowestRequiredAccountLevel());
|
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() {
|
IValidatorComponentListener getAccountManagerValidatorListener() {
|
||||||
|
@ -15,6 +15,8 @@ import javafx.geometry.Orientation;
|
|||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.ToolBar;
|
import javafx.scene.control.ToolBar;
|
||||||
|
import javafx.scene.input.KeyCode;
|
||||||
|
import javafx.scene.input.MouseButton;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.layout.Priority;
|
import javafx.scene.layout.Priority;
|
||||||
@ -87,10 +89,11 @@ class MainFrameView implements IFXComponent{
|
|||||||
return mainPane;
|
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 button = new Button(moduleName);
|
||||||
button.getStyleClass().add("menu-button");
|
button.getStyleClass().add("menu-button");
|
||||||
button.setOnMouseClicked(event->{
|
|
||||||
|
Runnable buttonActivationCode = ()->{
|
||||||
buttonHolder.getChildren()
|
buttonHolder.getChildren()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(Button.class::isInstance)
|
.filter(Button.class::isInstance)
|
||||||
@ -101,9 +104,19 @@ class MainFrameView implements IFXComponent{
|
|||||||
buttonHolder.getChildren().forEach(Node::applyCss);
|
buttonHolder.getChildren().forEach(Node::applyCss);
|
||||||
mainPane.setCenter(moduleContent);
|
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));
|
currentAccountLevel.addListener((obs, oldVal, newVal)->button.setDisable(requiredLevel.compareTo(newVal)>0));
|
||||||
button.setDisable(requiredLevel.compareTo(currentAccountLevel.get())>0);
|
button.setDisable(requiredLevel.compareTo(currentAccountLevel.get())>0);
|
||||||
|
if(setActive)
|
||||||
|
buttonActivationCode.run();
|
||||||
buttonHolder.getChildren().add(button);
|
buttonHolder.getChildren().add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user