mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-12-22 15:31:08 +00:00
Module Client, packg gui.main_frame : ajout possibilité de passer un module en actif à l'ajout; ajout TODO
This commit is contained in:
parent
11be8f0889
commit
bf089d325c
@ -31,9 +31,10 @@ 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));
|
||||
mainFrame.addModule(new StatScreen(statService));
|
||||
//TODO ajouter un module AccountScreen
|
||||
|
||||
Scene scene = new Scene(mainFrame.getPane(), 800, 600);
|
||||
scene.getStylesheets().clear();
|
||||
|
@ -20,7 +20,11 @@ public class MainFrame implements IFXComponent {
|
||||
}
|
||||
|
||||
public void addModule(IGuiModule module){
|
||||
ctrl.addModule(module);
|
||||
ctrl.addModule(module, false);
|
||||
}
|
||||
|
||||
public void addModule(IGuiModule module, boolean setActive){
|
||||
ctrl.addModule(module, setActive);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,8 +21,8 @@ class MainFrameController implements IMainFrameModelListener {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
void addModule(IGuiModule module) {
|
||||
this.view.addGuiModule(module.getModuleName(),module.getPane());
|
||||
void addModule(IGuiModule module, boolean setActive) {
|
||||
this.view.addGuiModule(module.getModuleName(),module.getPane(), setActive);
|
||||
}
|
||||
|
||||
IValidatorComponentListener getAccountManagerValidatorListener() {
|
||||
|
@ -14,6 +14,7 @@ import javafx.scene.control.ToolBar;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -22,8 +23,8 @@ class MainFrameView implements IFXComponent{
|
||||
private final MainFrameController ctrl;
|
||||
|
||||
private BorderPane mainPane;
|
||||
private ToolBar moduleListToolbar;
|
||||
private AccountManager accountManager;
|
||||
private VBox buttonHolder;
|
||||
|
||||
MainFrameView(MainFrameController ctrl) {
|
||||
|
||||
@ -35,17 +36,18 @@ class MainFrameView implements IFXComponent{
|
||||
mainPane = new BorderPane();
|
||||
mainPane.getStyleClass().addAll("main-module-pane", "main-frame");
|
||||
|
||||
moduleListToolbar = new ToolBar();
|
||||
moduleListToolbar.setOrientation(Orientation.VERTICAL);
|
||||
buttonHolder = new VBox();
|
||||
|
||||
SideBar sidebar = new SideBar();
|
||||
sidebar.setFillWidth(true);
|
||||
SideBar.setVgrow(moduleListToolbar, Priority.ALWAYS);
|
||||
sidebar.getChildren().add(moduleListToolbar);
|
||||
SideBar.setVgrow(buttonHolder, Priority.ALWAYS);
|
||||
buttonHolder.prefWidthProperty().bind(sidebar.widthProperty());
|
||||
sidebar.getChildren().add(buttonHolder);
|
||||
|
||||
accountManager = new AccountManager();
|
||||
accountManager.addListener(ctrl.getAccountManagerValidatorListener());
|
||||
accountManager.addListener(ctrl.getAccountManagerAccountListener());
|
||||
accountManager.getPane().prefWidthProperty().bind(sidebar.widthProperty());
|
||||
sidebar.getChildren().add(accountManager.getPane());
|
||||
|
||||
mainPane.setLeft(sidebar);
|
||||
@ -80,22 +82,24 @@ class MainFrameView implements IFXComponent{
|
||||
return mainPane;
|
||||
}
|
||||
|
||||
void addGuiModule(String moduleName, Pane moduleContent){
|
||||
void addGuiModule(String moduleName, Pane moduleContent, boolean setActive){
|
||||
Button button = new Button(moduleName);
|
||||
button.getStyleClass().add("menu-button");
|
||||
button.setOnMouseClicked(event->{
|
||||
moduleListToolbar.getItems()
|
||||
buttonHolder.getChildren()
|
||||
.stream()
|
||||
.filter(Button.class::isInstance)
|
||||
.map(Button.class::cast)
|
||||
.forEach(b-> b.getStyleClass().remove("menu-button-selected"));
|
||||
button.getStyleClass().add("menu-button-selected");
|
||||
Platform.runLater(()->{
|
||||
moduleListToolbar.getItems().forEach(Node::applyCss);
|
||||
buttonHolder.getChildren().forEach(Node::applyCss);
|
||||
mainPane.setCenter(moduleContent);
|
||||
});
|
||||
});
|
||||
moduleListToolbar.getItems().add(button);
|
||||
if(setActive)
|
||||
button.getOnMouseClicked().handle(null);
|
||||
buttonHolder.getChildren().add(button);
|
||||
}
|
||||
|
||||
boolean isAccountCreationPossible(){
|
||||
|
Loading…
Reference in New Issue
Block a user