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
|
package vue;
import controlleur.ControllerTopMenu;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import modele.User;
public class AfficheTopMenu extends HBox
{
private Label pseudo;
public AfficheTopMenu(Stage primaryStage, User session)
{
this.setStyle("-fx-background-color: gray; -fx-padding: 5px;");
//-fx-spacing: 10px;
//Label title = new Label("Simulation"); // moche, à améliorer ou retirer
Button btn_account = new Button("Mon compte");
Button btn_logout = new Button();
Button btn_home = new Button("Accueil");
Button btn_gerer_liste = new Button("Gerer liste");
Button btn_creer_liste = new Button("Création liste");
Button btn_admin = new Button("Admin");
Button btn_simu = new Button("Simulation");
HBox h1 = new HBox();
h1.getChildren().addAll(btn_home, btn_account,btn_gerer_liste,btn_creer_liste,btn_simu);
//Image icons_deco = new Image("/images/deco.png");
Image icons_deco = new Image(getClass().getResource("/images/deco.png").toExternalForm());
ImageView icons_deco_box = new ImageView(icons_deco);
btn_logout.setGraphic(icons_deco_box);
icons_deco_box.setPreserveRatio(true);
icons_deco_box.fitHeightProperty().bind(btn_account.heightProperty());
//this.getChildren().add(h1);
//this.setAlignment(javafx.geometry.Pos.CENTER_RIGHT);
//h1.setLeft(null);
//h2.setAlignment(javafx.geometry.Pos.TOP_RIGHT);
//this.setSpacing(getMaxWidth());
//h1.setSpacing(10);// Ajoute un espace de 10 pixels entre les composants
//h2.setPadding(new Insets(1, 1, 20, 1));
if(session.getRole().equals("Admin") ) {
h1.getChildren().add(btn_admin);
}
pseudo = new Label(session.getNom());
//pseudo.setStyle("-fx-text-fill: white");
pseudo.setTextFill(Color.WHITE);
pseudo.setStyle("-fx-font-weight: bold;");
//barre.getChildren().addAll( pseudo, btn_logout);
//this.setAlignment(javafx.geometry.Pos.CENTER_RIGHT);
HBox h2 = new HBox();
h2.getChildren().addAll( pseudo, btn_logout);
h1.setSpacing(10);
h2.setSpacing(10);
Pane p = new Pane();
HBox.setHgrow(p, Priority.ALWAYS);
this.getChildren().addAll( h1,p, h2);
this.setAlignment(javafx.geometry.Pos.TOP_CENTER);
h1.setAlignment(javafx.geometry.Pos.CENTER_LEFT);
h2.setAlignment(javafx.geometry.Pos.CENTER_RIGHT);
// menu principal
btn_home.setOnAction(e -> {
ControllerTopMenu.go_accueil(primaryStage,session);
});
// gestion de son compte
btn_account.setOnAction(e -> {
ControllerTopMenu.go_gestion_compte(primaryStage,session);
});
// gestion des listes
btn_gerer_liste.setOnAction(e -> {
ControllerTopMenu.go_gestion_listes(primaryStage,session);
});
// page de connexion
btn_logout.setOnAction(e -> {
ControllerTopMenu.go_deco(primaryStage, session);
});
// simulation
btn_simu.setOnAction(e -> {
ControllerTopMenu.go_simulation(primaryStage,session);
});
// options réservées à l'admin
btn_admin.setOnAction(e -> {
ControllerTopMenu.go_admin(primaryStage, session);
});
//vers creer liste
btn_creer_liste.setOnAction(e->{
ControllerTopMenu.go_creer_liste(primaryStage,session);
});
}
public void setLogin(String login)
{
pseudo.setText(login);
}
}
|