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