diff --git a/Workspace/client/src/main/java/com/pqt/client/Main.java b/Workspace/client/src/main/java/com/pqt/client/Main.java index f65aa47c..5e978bc4 100644 --- a/Workspace/client/src/main/java/com/pqt/client/Main.java +++ b/Workspace/client/src/main/java/com/pqt/client/Main.java @@ -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(); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java index ea60287c..bc1674a6 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrame.java @@ -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 diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java index c432978e..43686466 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameController.java @@ -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() { diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java index a802ac71..5793fa3d 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/main_frame/MainFrameView.java @@ -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(){