From c40366e4e2862274bb3e1b2a294bda67e8abeb00 Mon Sep 17 00:00:00 2001 From: besson Date: Thu, 1 Dec 2022 12:16:30 +0100 Subject: [PATCH] =?UTF-8?q?Transf=C3=A9rer=20les=20fichiers=20vers=20'src/?= =?UTF-8?q?Test'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Test/Controller.java | 21 +++++++++------------ src/Test/MainMenu.java | 25 ++++++++++++++++++------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/Test/Controller.java b/src/Test/Controller.java index bb42cd9..febd14e 100644 --- a/src/Test/Controller.java +++ b/src/Test/Controller.java @@ -22,6 +22,8 @@ public class Controller implements ActionListener, ListSelectionListener { private AdminView av = null; private BFrame currentModal; + private MainMenu parent; + private ArrayList e; private ArrayList g; @@ -30,10 +32,11 @@ public class Controller implements ActionListener, ListSelectionListener { private ArrayList tmpStud; - public Controller(BDatabase db) { + public Controller(BDatabase db, MainMenu frame) { this.db = db; this.e = this.db.getEtuList(); this.g = this.db.getGroupeList(); + parent = frame; // Les 3 fenetres s'ouvriront en meme temps (Pour le contexte du projet) //this.pv = new ProfView(this.e, this.g, this); @@ -67,7 +70,7 @@ public class Controller implements ActionListener, ListSelectionListener { * @param loca_y Localisation en y * @param liste La JTable * */ - private void Display(BFrame parent, String frameTitle, int size_x, int size_y, int loca_x, int loca_y, JTable liste) { + private void Display(String frameTitle, int size_x, int size_y, int loca_x, int loca_y, JTable liste) { JPanel forModal = new JPanel(); ListSelectionModel lsm = liste.getSelectionModel(); @@ -92,7 +95,7 @@ public class Controller implements ActionListener, ListSelectionListener { * @param loca_y Localisation en y * @param liste La JTable * */ - private void DisplayWithListner(BFrame parent, String frameTitle, int size_x, int size_y, int loca_x, int loca_y, JTable liste) { + private void DisplayWithListner(String frameTitle, int size_x, int size_y, int loca_x, int loca_y, JTable liste) { JPanel forModal = new JPanel(); ListSelectionModel lsm = liste.getSelectionModel(); @@ -104,7 +107,7 @@ public class Controller implements ActionListener, ListSelectionListener { forModal.add(liste); - BFrame frame = new BFrame(frameTitle, loca_x, loca_y, size_x, size_y, parent, forModal); + BFrame frame = new BFrame(frameTitle, loca_x, loca_y, size_x, size_y, this.parent, forModal); } /** @@ -118,8 +121,8 @@ public class Controller implements ActionListener, ListSelectionListener { * @param loca_y Localisation en y * @param forModal Le panel a mettre dans la fenetre (libre) * */ - private void DisplayModal(BFrame parent, String frameTitle, int size_x, int size_y, int loca_x, int loca_y, JPanel forModal) { - this.currentModal = new BFrame(frameTitle, loca_x, loca_y, size_x, size_y, parent, forModal); + private void DisplayModal(String frameTitle, int size_x, int size_y, int loca_x, int loca_y, JPanel forModal) { + this.currentModal = new BFrame(frameTitle, loca_x, loca_y, size_x, size_y, this.parent, forModal); } @Override @@ -152,7 +155,6 @@ public class Controller implements ActionListener, ListSelectionListener { } Display( - this.pv, "Liste des etudiants", 350, 400, @@ -190,7 +192,6 @@ public class Controller implements ActionListener, ListSelectionListener { } Display( - this.pv, "Liste d'eleve du " + groupeOption, 350, 400, @@ -242,7 +243,6 @@ public class Controller implements ActionListener, ListSelectionListener { } Display( - this.pv, "Recherche", 350, 400, @@ -276,7 +276,6 @@ public class Controller implements ActionListener, ListSelectionListener { } DisplayWithListner( - this.av, "Deplacer un etudiant", 350, 400, @@ -313,7 +312,6 @@ public class Controller implements ActionListener, ListSelectionListener { String[][] stringArray = data.stream().map(u -> u.toArray(new String[0])).toArray(String[][]::new); DisplayWithListner( - this.av, "Attribuer un groupe a un etudiant", 350, 400, @@ -420,7 +418,6 @@ public class Controller implements ActionListener, ListSelectionListener { forModal.add(moveBtn, settings); DisplayModal( - this.av, "Deplacer l'eleve : " + tm.getValueAt(cell[0], 0) + " " + tm.getValueAt(cell[0], 1), 500, diff --git a/src/Test/MainMenu.java b/src/Test/MainMenu.java index 48f0e2f..f4469cf 100644 --- a/src/Test/MainMenu.java +++ b/src/Test/MainMenu.java @@ -30,14 +30,20 @@ public class MainMenu extends JFrame { private void init() { BDatabase db = new BDatabase(); - Controller listener = new Controller(db); + Controller listener = new Controller(db, this); + av = new AdminView(listener.getEtudiants(), listener.getGroupes(), listener); pv = new ProfView(listener.getEtudiants(), listener.getGroupes(), listener); + + listener.setAv(av); + listener.setPv(pv); this.setLayout(cards); + this.add(first()); this.add(adminView()); this.add(profView()); + cards.first(this.getContentPane()); } @@ -69,12 +75,16 @@ public class MainMenu extends JFrame { private JPanel adminView() { - JPanel mainPanel = new JPanel + JPanel mainPanel = new JPanel(); + mainPanel.add(av); + return mainPanel; } private JPanel profView() { - + JPanel mainPanel = new JPanel(); + mainPanel.add(pv); + return mainPanel; } @@ -82,12 +92,13 @@ public class MainMenu extends JFrame { JButton origin = (JButton) e.getSource(); System.out.println(origin.getText()); - - if (origin.getText() == "Admin") { - listener.createAdminView(); + cards.next(this.getContentPane()); + } else if (origin.getText() == "Prof") { - listener.createProfView(); + cards.next(this.getContentPane()); + cards.next(this.getContentPane()); + } else { JOptionPane.showMessageDialog(null, "En travaux"); }