This commit is contained in:
pro.boooooo 2022-11-27 18:27:50 +01:00
parent 3df45f3f87
commit 8c76e54ea9
5 changed files with 79 additions and 14 deletions

View File

@ -116,7 +116,6 @@ public class BFrame extends JFrame {
JScrollPane scrollPane = new JScrollPane(); JScrollPane scrollPane = new JScrollPane();
frame.getContentPane().add(scrollPane); frame.getContentPane().add(scrollPane);
scrollPane.setViewportView(content); scrollPane.setViewportView(content);
frame.setResizable(false); frame.setResizable(false);
frame.setVisible(true); frame.setVisible(true);
} }
@ -174,6 +173,13 @@ public class BFrame extends JFrame {
this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING)); this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
} }
/**
* Fermer une fenetre modal
* */
public void closeMBframe() {
this.setVisible(false);
}
/** /**
* Rafraichir la fenetre * Rafraichir la fenetre
*/ */

View File

@ -17,11 +17,20 @@ import java.util.Objects;
public class Controller implements ActionListener, ListSelectionListener { public class Controller implements ActionListener, ListSelectionListener {
private final BDatabase db; private final BDatabase db;
private final ProfView pv; private final ProfView pv;
private final AdminView av; private final AdminView av;
private BFrame lastModal;
private BFrame currentModal;
private final ArrayList<Etudiant> e; private final ArrayList<Etudiant> e;
private final ArrayList<Groupe> g; private final ArrayList<Groupe> g;
private JTable currentJTableUse; private JTable currentJTableUse;
private JComboBox<String> list;
private String[] tmpStud;
public Controller(ArrayList<Etudiant> e, ArrayList<Groupe> g) { public Controller(ArrayList<Etudiant> e, ArrayList<Groupe> g) {
this.e = e; this.e = e;
@ -108,8 +117,8 @@ public class Controller implements ActionListener, ListSelectionListener {
* @param loca_y Localisation en y * @param loca_y Localisation en y
* @param forModal Le panel a mettre dans la fenetre (libre) * @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, Object... data) { private void DisplayModal(BFrame parent, String frameTitle, int size_x, int size_y, int loca_x, int loca_y, JPanel forModal) {
BFrame frame = new BFrame(frameTitle, loca_x, loca_y, size_x, size_y, parent, forModal); this.currentModal = new BFrame(frameTitle, loca_x, loca_y, size_x, size_y, parent, forModal);
} }
@Override @Override
@ -273,6 +282,18 @@ public class Controller implements ActionListener, ListSelectionListener {
this.createJTable(data, titre) this.createJTable(data, titre)
); );
} }
else if(Objects.equals(command, "crtll::ActionMoveGrup")) {
// TODO: CHANGE GROUPE
db.updateRow("UPDATE fi_eleves SET ");
JOptionPane.showMessageDialog(
this.currentModal,
this.tmpStud[0] + " " + this.tmpStud[1] + " a bien ete deplace dans le " + this.list.getSelectedItem(),
"Deplacement effectue",
JOptionPane.INFORMATION_MESSAGE
);
}
} }
@Override @Override
@ -291,25 +312,63 @@ public class Controller implements ActionListener, ListSelectionListener {
if(Objects.equals(value, "[DEPLACER]")) { if(Objects.equals(value, "[DEPLACER]")) {
JPanel forModal = new JPanel(new GridBagLayout()); JPanel forModal = new JPanel(new GridBagLayout());
BLayout settings = new BLayout(); BLayout settings = new BLayout();
this.tmpStud = new String[] {
(String) tm.getValueAt(cell[0], 0),
(String) tm.getValueAt(cell[0], 1)
};
JLabel l = new JLabel("test"); settings.setPositionX(0);
forModal.add(l); settings.setPositionY(0);
JLabel intro = new JLabel(
"Deplacer " + tm.getValueAt(cell[0], 0) + " " +
tm.getValueAt(cell[0], 1) +
" dans le groupe : "
);
forModal.add(intro, settings);
settings.setPositionX(1);
settings.setPositionY(0);
forModal.add(new JLabel(" "), settings);
settings.setPositionX(2);
settings.setPositionY(0);
forModal.add(new JLabel(" "), settings);
settings.setPositionX(3);
settings.setPositionY(0);
this.list = new JComboBox<>();
for (Groupe groupe : this.g) {
this.list.addItem(groupe.getName());
}
forModal.add(list, settings);
settings.setPositionX(4);
settings.setPositionY(0);
forModal.add(new JLabel(" "), settings);
settings.setPositionX(5);
settings.setPositionY(0);
forModal.add(new JLabel(" "), settings);
settings.setPositionX(6);
settings.setPositionY(0);
JButton moveBtn = new JButton("Deplacer");
moveBtn.setActionCommand("crtll::ActionMoveGrup");
moveBtn.addActionListener(this);
forModal.add(moveBtn, settings);
DisplayModal( DisplayModal(
this.av, this.av,
"Deplacer l'eleve : " + tm.getValueAt(cell[0], 0) + " " + tm.getValueAt(cell[0], 1), "Deplacer l'eleve : "
+ tm.getValueAt(cell[0], 0) + " " + tm.getValueAt(cell[0], 1),
500, 500,
250, 250,
this.av.getX(), this.av.getX(),
this.av.getY(), this.av.getY(),
forModal, forModal
/**
* Position toujours similaire { cell[0] = Nom (String), cell[1] = Prenom (String), cell[2] = Groupe (String) }
*/
tm.getValueAt(cell[0], 0),
tm.getValueAt(cell[0], 1),
tm.getValueAt(cell[0], 2)
); );
} }
} }