Transférer les fichiers vers 'src/Test'
This commit is contained in:
parent
20b60e2e76
commit
8b68a2a163
@ -5,51 +5,49 @@ import java.awt.*;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
public class MainMenu extends JFrame {
|
public class MainMenu extends JFrame {
|
||||||
private final static Dimension MINIMUM_SIZE = new Dimension(960, 540);
|
private final static Dimension MINIMUM_SIZE = new Dimension(960, 600);
|
||||||
private CardLayout cards = new CardLayout(), adminCards = new CardLayout(), profCards = new CardLayout();
|
private final CardLayout cards = new CardLayout(), adminCards = new CardLayout(), profCards = new CardLayout(), studentCards = new CardLayout();
|
||||||
private JPanel adminPanel = new JPanel(), profPanel = new JPanel();
|
private final JPanel adminPanel = new JPanel(), profPanel = new JPanel(), studentPanel = new JPanel();
|
||||||
private JMenuBar menuBar = new JMenuBar();
|
private final JMenuBar menuBar = new JMenuBar();
|
||||||
|
private Controller listener;
|
||||||
private AdminView av;
|
private AdminView av;
|
||||||
private ProfView pv;
|
private ProfView pv;
|
||||||
|
private StudentView sv;
|
||||||
private JTable table;
|
private JTable table;
|
||||||
private int cardIndex = 0;
|
private int cardIndex = 0;
|
||||||
|
|
||||||
private JButton[] buttonTab = {
|
private final JButton[] buttonTab = {
|
||||||
new JButton("Admin"),
|
new JButton("Admin"),
|
||||||
new JButton("Prof"),
|
new JButton("Prof"),
|
||||||
new JButton("Student")
|
new JButton("Student")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public MainMenu() {
|
public MainMenu(Controller listener) {
|
||||||
super();
|
super();
|
||||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||||
this.setExtendedState(MAXIMIZED_BOTH);
|
this.setExtendedState(MAXIMIZED_BOTH);
|
||||||
this.setMinimumSize(MINIMUM_SIZE);
|
this.setMinimumSize(MINIMUM_SIZE);
|
||||||
init();
|
init(listener);
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void init() {
|
private void init(Controller listener) {
|
||||||
BDatabase db = new BDatabase();
|
this.listener = listener;
|
||||||
Controller listener = new Controller(db, this);
|
|
||||||
|
|
||||||
this.av = new AdminView(listener.getEtudiants(), listener.getGroupes(), listener);
|
this.av = this.listener.getAdminView();
|
||||||
this.pv = new ProfView(listener.getEtudiants(), listener.getGroupes(), listener);
|
this.pv = this.listener.getProfView();
|
||||||
|
this.sv = this.listener.getStudentView();
|
||||||
|
|
||||||
listener.setAv(av);
|
this.table = this.listener.initTable();
|
||||||
listener.setPv(pv);
|
|
||||||
|
|
||||||
this.table = listener.initTable();
|
|
||||||
|
|
||||||
createJMenuBar();
|
|
||||||
|
|
||||||
this.setLayout(cards);
|
this.setLayout(cards);
|
||||||
|
|
||||||
this.add(first());
|
this.add(firstCard());
|
||||||
this.add(adminPanel);
|
this.add(adminPanel);
|
||||||
this.add(profPanel);
|
this.add(profPanel);
|
||||||
|
this.add(studentView());
|
||||||
|
|
||||||
cards.first(this.getContentPane());
|
cards.first(this.getContentPane());
|
||||||
}
|
}
|
||||||
@ -57,7 +55,7 @@ public class MainMenu extends JFrame {
|
|||||||
|
|
||||||
private void createJMenuBar() {
|
private void createJMenuBar() {
|
||||||
JMenu menu = new JMenu("Menu"), file = new JMenu("File"), edit = new JMenu("Edit"), view = new JMenu("View");
|
JMenu menu = new JMenu("Menu"), file = new JMenu("File"), edit = new JMenu("Edit"), view = new JMenu("View");
|
||||||
|
|
||||||
JMenuItem adminMenuItem = new JMenuItem("Admin View");
|
JMenuItem adminMenuItem = new JMenuItem("Admin View");
|
||||||
adminMenuItem.addActionListener((event) -> changeView(1));
|
adminMenuItem.addActionListener((event) -> changeView(1));
|
||||||
|
|
||||||
@ -83,6 +81,7 @@ public class MainMenu extends JFrame {
|
|||||||
menuBar.add(file);
|
menuBar.add(file);
|
||||||
menuBar.add(edit);
|
menuBar.add(edit);
|
||||||
menuBar.add(view);
|
menuBar.add(view);
|
||||||
|
|
||||||
this.setJMenuBar(menuBar);
|
this.setJMenuBar(menuBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,24 +102,33 @@ public class MainMenu extends JFrame {
|
|||||||
|
|
||||||
|
|
||||||
private void changeView(int index) {
|
private void changeView(int index) {
|
||||||
|
table = this.listener.initTable();
|
||||||
|
|
||||||
if (index == 1) {
|
if (index == 1) {
|
||||||
cardIndex = index;
|
cardIndex = index;
|
||||||
cards.first(this.getContentPane());
|
this.setTitle("Administrator");
|
||||||
cards.next(this.getContentPane());
|
adminPanel.setLayout(adminCards);
|
||||||
adminPanel.add(cardWithTable(adminView()));
|
adminPanel.add(cardWithTable(adminView()));
|
||||||
adminCards.next(adminPanel);
|
adminCards.next(adminPanel);
|
||||||
|
menuBar.setBackground(Color.RED);
|
||||||
|
|
||||||
} else if (index == 2) {
|
} else if (index == 2) {
|
||||||
cardIndex = index;
|
cardIndex = index;
|
||||||
cards.first(this.getContentPane());
|
this.setTitle("Professor");
|
||||||
cards.next(this.getContentPane());
|
profPanel.setLayout(profCards);
|
||||||
cards.next(this.getContentPane());
|
|
||||||
profPanel.add(cardWithTable(profView()));
|
profPanel.add(cardWithTable(profView()));
|
||||||
profCards.next(profPanel);
|
profCards.next(profPanel);
|
||||||
|
menuBar.setBackground(Color.MAGENTA);
|
||||||
|
|
||||||
} else if (index == 3){
|
} else if (index == 3){
|
||||||
JOptionPane.showMessageDialog(null, "En travaux");
|
cardIndex = index;
|
||||||
|
this.setTitle("Student");
|
||||||
|
studentPanel.setLayout(studentCards);
|
||||||
|
studentPanel.add(cardWithTable(studentView()));
|
||||||
|
studentCards.next(studentPanel);
|
||||||
|
menuBar.setBackground(Color.BLUE);
|
||||||
}
|
}
|
||||||
|
travelThroughCards(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -134,12 +142,14 @@ public class MainMenu extends JFrame {
|
|||||||
profPanel.add(cardWithTable(profView()));
|
profPanel.add(cardWithTable(profView()));
|
||||||
profCards.next(profPanel);
|
profCards.next(profPanel);
|
||||||
} else {
|
} else {
|
||||||
|
this.table = table;
|
||||||
|
studentPanel.add(cardWithTable(profView()));
|
||||||
|
studentCards.next(studentPanel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private JPanel first() {
|
private JPanel firstCard() {
|
||||||
JPanel mainPanel = new JPanel(), centerPanel = new JPanel();
|
JPanel mainPanel = new JPanel(), centerPanel = new JPanel();
|
||||||
Dimension buttonDimension = new Dimension(300, 50);
|
Dimension buttonDimension = new Dimension(300, 50);
|
||||||
|
|
||||||
@ -167,38 +177,63 @@ public class MainMenu extends JFrame {
|
|||||||
|
|
||||||
private JPanel adminView() {
|
private JPanel adminView() {
|
||||||
JPanel mainPanel = new JPanel();
|
JPanel mainPanel = new JPanel();
|
||||||
mainPanel.add(av);
|
mainPanel.setLayout(new BorderLayout());
|
||||||
|
mainPanel.add(this.av, BorderLayout.CENTER);
|
||||||
return mainPanel;
|
return mainPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private JPanel profView() {
|
private JPanel profView() {
|
||||||
JPanel mainPanel = new JPanel();
|
JPanel mainPanel = new JPanel();
|
||||||
mainPanel.add(pv);
|
mainPanel.setLayout(new BorderLayout());
|
||||||
|
mainPanel.add(this.pv, BorderLayout.CENTER);
|
||||||
|
return mainPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private JPanel studentView() {
|
||||||
|
JPanel mainPanel = new JPanel();
|
||||||
|
mainPanel.setLayout(new BorderLayout());
|
||||||
|
mainPanel.add(this.sv, BorderLayout.CENTER);
|
||||||
return mainPanel;
|
return mainPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void action(ActionEvent e) {
|
private void action(ActionEvent e) {
|
||||||
JButton origin = (JButton) e.getSource();
|
JButton origin = (JButton) e.getSource();
|
||||||
System.out.println(origin.getText());
|
createJMenuBar();
|
||||||
|
|
||||||
if (origin.getText() == "Admin") {
|
if (origin.getText().equals("Admin")) {
|
||||||
|
this.setTitle("Administrator");
|
||||||
|
menuBar.setBackground(Color.RED);
|
||||||
adminPanel.setLayout(adminCards);
|
adminPanel.setLayout(adminCards);
|
||||||
adminPanel.add(cardWithTable(adminView()));
|
adminPanel.add(cardWithTable(adminView()));
|
||||||
cards.next(this.getContentPane());
|
|
||||||
cardIndex = 1;
|
cardIndex = 1;
|
||||||
|
|
||||||
} else if (origin.getText() == "Prof") {
|
} else if (origin.getText().equals("Prof")) {
|
||||||
|
this.setTitle("Professor");
|
||||||
|
menuBar.setBackground(Color.MAGENTA);
|
||||||
profPanel.setLayout(profCards);
|
profPanel.setLayout(profCards);
|
||||||
profPanel.add(cardWithTable(profView()));
|
profPanel.add(cardWithTable(profView()));
|
||||||
cards.next(this.getContentPane());
|
|
||||||
cards.next(this.getContentPane());
|
|
||||||
cardIndex = 2;
|
cardIndex = 2;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, "En travaux");
|
this.setTitle("Student");
|
||||||
//cardIndex = 3;
|
menuBar.setBackground(Color.BLUE);
|
||||||
|
studentPanel.setLayout(studentCards);
|
||||||
|
studentPanel.add(cardWithTable(studentView()));
|
||||||
|
cardIndex = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
travelThroughCards(cardIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void travelThroughCards(int index) {
|
||||||
|
cards.first(this.getContentPane());
|
||||||
|
|
||||||
|
for (int i = 0; i < index; i++) {
|
||||||
|
cards.next(this.getContentPane());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user