1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
import Database.MongoUtils;
import Entities.Produit;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.DepthTest;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.Stage;
public class Catalogue extends Application {
private static Catalogue catalogue;
private Stage stage;
private Scene scene;
private BorderPane root;
public static Catalogue getCatalogue(){
return catalogue;
}
@Override
public void start(final Stage stage){
this.stage=stage;
catalogue = this;
stage.setTitle("Catalogue de produit");
root = new BorderPane();
root.getStyleClass().add("application");
root.setId("root");
StackPane layerPane = new StackPane();
layerPane.setDepthTest(DepthTest.DISABLE);
layerPane.getChildren().add(root);
scene = new Scene(layerPane, 1020, 700);
root.getChildren().add(getPrimayContainer());
stage.setScene(scene);
stage.show();
}
public BorderPane getPrimayContainer(){
BorderPane borderPane = new BorderPane();
borderPane.prefHeightProperty().bind(scene.heightProperty());
borderPane.prefWidthProperty().bind(scene.widthProperty());
//Top content
MenuBar menuBar = new MenuBar();
menuBar.getMenus().add(getMenu());
borderPane.setTop(menuBar);
//Left content
VBox topLeftMenu = getTopLeftMenu();
FlowPane leftMenu = getLeftMenu();
VBox leftVbox = new VBox();
leftVbox.getChildren().addAll(topLeftMenu, leftMenu);
borderPane.setLeft(leftVbox);
// Center content
TableView tableView = getCenterTable();
borderPane.setCenter(tableView);
return borderPane;
}
public Menu getMenu(){
MenuItem menu111 = MenuItemBuilder.create().text("Ajouter un produit").build();
MenuItem menu112 = MenuItemBuilder.create().text("Ajouter une variante de produit").build();
MenuItem menu121 = MenuItemBuilder.create().text("Ajouter une catégorie").build();
Menu menu11 = MenuBuilder.create()
.text("Ajouter")
.items(menu111, menu112)
.build();
Menu menu1 = MenuBuilder.create()
.text("Ajouter")
.items(menu11, menu121)
.build();
return menu1;
}
public TableView getCenterTable() {
// colonne produit
TableColumn nomProduit = new TableColumn();
nomProduit.setText("produit");
nomProduit.setMinWidth(30);
// colonne nom
TableColumn nomVarianteProduit = new TableColumn();
nomVarianteProduit.setText("variante");
nomVarianteProduit.setMinWidth(30);
// colonne prix
TableColumn prixVarianteProduit = new TableColumn();
prixVarianteProduit.setText("prix");
prixVarianteProduit.setMinWidth(15);
// colonne pourcentage promotion
TableColumn pourcVarianteProduit = new TableColumn();
pourcVarianteProduit.setText("prix");
pourcVarianteProduit.setMinWidth(15);
// colonne pourcentage promotion
TableColumn buttonEdit = new TableColumn();
buttonEdit.setText("prix");
buttonEdit.setMinWidth(15);
TableView tableView = new TableView();
tableView.getColumns().addAll(nomProduit, nomVarianteProduit, prixVarianteProduit, pourcVarianteProduit, buttonEdit);
return tableView;
}
public VBox getTopLeftMenu() {
//ToggleButton toggleEdit = new ToggleButton("Edition");
Label labelMinimum = new Label("Minimum");
Label labelMaximum = new Label("Maximum");
Slider slideMinimum = new Slider();
Slider slideMaximum = new Slider();
slideMinimum.setMin(0);
slideMinimum.setMax(500);
slideMinimum.setShowTickLabels(true);
slideMaximum.setMin(0);
slideMaximum.setMax(500);
slideMaximum.setShowTickLabels(true);
VBox vb1 = new VBox(5);
vb1.getChildren().addAll(labelMinimum, slideMinimum);
VBox vb2 = new VBox(5);
vb1.getChildren().addAll(labelMaximum,slideMaximum);
VBox topLeftMenu = new VBox(30);
topLeftMenu.setAlignment(Pos.CENTER_LEFT);
topLeftMenu.getChildren().addAll(vb1,vb2);
return topLeftMenu;
}
public FlowPane getLeftMenu() {
FlowPane flowPane = new FlowPane(2, 4);
flowPane.setPrefWrapLength(150);
Label[] labelCategories = new Label[5];
CheckBox[] checkboxCategories = new CheckBox[5];
for (int i = 0; i < 5; i++) {
labelCategories[i] = new Label("Catégories"+i);
checkboxCategories[i] = new CheckBox();
flowPane.getChildren().addAll(labelCategories[i], checkboxCategories[i]);
}
root.getChildren().add(flowPane);
return flowPane;
}
public static void main(String[] args) {
launch(args);
}
} |
Partager