This commit is contained in:
Bilou 2022-12-07 14:59:22 +01:00
parent 5e727b4745
commit e4ac30b549
4 changed files with 114 additions and 12 deletions

Binary file not shown.

View File

@ -54,6 +54,18 @@ public class AdminView extends JPanel {
addStudGrup.setActionCommand("av::AddStudGrup"); addStudGrup.setActionCommand("av::AddStudGrup");
this.add(addStudGrup, settings); this.add(addStudGrup, settings);
settings.setPositionY(5);
this.add(new JLabel(" "), settings);
settings.setPositionY(6);
this.add(new JLabel(" "), settings);
settings.setPositionY(7);
CustomJButton createGrup = new CustomJButton("Créer un groupe");
createGrup.addActionListener(this.listener);
createGrup.setActionCommand("av::CreateGrup");
this.add(createGrup, settings);
this.repaint(); this.repaint();
} }
} }

View File

@ -38,10 +38,11 @@ public class Controller implements ActionListener, ListSelectionListener {
private JComboBox<String> requestTypeSelector; private JComboBox<String> requestTypeSelector;
private JTextArea content; private JTextArea content;
private ArrayList<String> tmpStud; private ArrayList<String> tmpStud;
private int x; private JTextField l1;
private JTextField l2;
private JTextField l3;
public Controller(BDatabase db) { public Controller(BDatabase db) {
this.db = db; this.db = db;
@ -156,7 +157,7 @@ public class Controller implements ActionListener, ListSelectionListener {
String[] info = { String[] info = {
this.e.get(i).getNom(), this.e.get(i).getNom(),
this.e.get(i).getPrenom(), this.e.get(i).getPrenom(),
String.valueOf(this.e.get(i).getGroupe()) this.getGroupeById(this.e.get(i).getGroupe())
}; };
data[i] = info; data[i] = info;
@ -470,6 +471,87 @@ public class Controller implements ActionListener, ListSelectionListener {
Display(this.createJTable(data, title)); Display(this.createJTable(data, title));
} }
else if(Objects.equals(command, "av::CreateGrup")) {
JPanel forModal = new JPanel(new GridBagLayout());
BLayout settings = new BLayout();
settings.setPositionX(0);
settings.setPositionY(1);
forModal.add(new JLabel("Nom du groupe (EXEMPLE: Groupe du soleil)"), settings);
settings.setPositionY(2);
this.l1 = new JTextField();
this.l1.setPreferredSize(new Dimension(130, 30));
forModal.add(this.l1, settings);
settings.setPositionY(3);
forModal.add(new JLabel(" "), settings);
settings.setPositionY(4);
forModal.add(new JLabel("Taille maximum (uniquement des chiffres)"), settings);
settings.setPositionY(5);
this.l2 = new JTextField();
this.l2.setPreferredSize(new Dimension(30, 30));
forModal.add(this.l2, settings);
settings.setPositionY(6);
forModal.add(new JLabel(" "), settings);
settings.setPositionY(7);
forModal.add(new JLabel("Taille minimum (uniquement des chiffres)"), settings);
settings.setPositionY(8);
this.l3 = new JTextField();
this.l3.setPreferredSize(new Dimension(30, 30));
forModal.add(this.l3, settings);
settings.setPositionY(9);
forModal.add(new JLabel(" "), settings);
settings.setPositionY(10);
forModal.add(new JLabel(" "), settings);
settings.setPositionY(11);
CustomJButton create = new CustomJButton("Créer");
create.addActionListener(this);
create.setActionCommand("av::CreateGrupOnDatabase");
forModal.add(create, settings);
DisplayModal(
"Creation de groupe",
750,
500,
this.parent.getLocation().x + (this.parent.getSize().width - 750) / 2,
this.parent.getLocation().y + (this.parent.getSize().height - 500) / 2,
forModal
);
}
else if(Objects.equals(command, "av::CreateGrupOnDatabase")) {
String nom = this.l1.getText();
String max = this.l2.getText();
String min = this.l3.getText();
if(this.db.insertRow("fi_groupes", new String[]{"nom", "min", "max"}, new String[]{nom, min, max})) {
JOptionPane.showMessageDialog(
this.parent,
"Groupe" + nom + "creer !",
"Succes",
JOptionPane.INFORMATION_MESSAGE
);
this.g = this.db.getGroupeList();
} else {
JOptionPane.showMessageDialog(
this.parent,
"La creation du groupe : " + nom + " à échoué.",
"Erreur",
JOptionPane.ERROR_MESSAGE
);
}
}
} }
@Override @Override
@ -589,13 +671,17 @@ public class Controller implements ActionListener, ListSelectionListener {
Object[] info = { Object[] info = {
this.e.get(i).getNom(), this.e.get(i).getNom(),
this.e.get(i).getPrenom(), this.e.get(i).getPrenom(),
String.valueOf(this.e.get(i).getGroupe()) this.getGroupeById(this.e.get(i).getGroupe())
}; };
data[i] = info; data[i] = info;
} }
return createJTable(data, title); return createJTable(data, title);
} }
public String getGroupeById(int id) {
return this.db.fetchAll("SELECT nom FROM fi_groupe WHERE id = " + id).get(0);
}
public ProfView getProfView() { public ProfView getProfView() {
return this.pv; return this.pv;
} }

View File

@ -9,8 +9,8 @@ import java.awt.Font;
* Bouton personnalisé avec des bords arrondis et un fond transparent * Bouton personnalisé avec des bords arrondis et un fond transparent
*/ */
public class CustomJButton extends JButton { public class CustomJButton extends JButton {
private Font font = new Font("Arial", Font.PLAIN, 12); private Font font;
private Color color = Color.BLACK; private Color color;
//private final int radius = 20; //private final int radius = 20;
/** /**
@ -19,8 +19,9 @@ public class CustomJButton extends JButton {
*/ */
public CustomJButton(String text, Color c) { public CustomJButton(String text, Color c) {
super(text); super(text);
this.font = new Font("Arial", Font.PLAIN, 12);
this.color = c; this.color = c;
init(); this.init();
} }
/** /**
@ -31,7 +32,7 @@ public class CustomJButton extends JButton {
super(text); super(text);
this.color = c; this.color = c;
this.font = font; this.font = font;
init(); this.init();
} }
/** /**
@ -40,8 +41,9 @@ public class CustomJButton extends JButton {
*/ */
public CustomJButton(String text, Font font) { public CustomJButton(String text, Font font) {
super(text); super(text);
this.color = Color.BLACK;
this.font = font; this.font = font;
init(); this.init();
} }
/** /**
@ -49,14 +51,16 @@ public class CustomJButton extends JButton {
*/ */
public CustomJButton(String text) { public CustomJButton(String text) {
super(text); super(text);
init(); this.font = new Font("Arial", Font.PLAIN, 12);
this.color = Color.BLACK;
this.init();
} }
private void init() { private void init() {
this.setForeground(Color.WHITE); this.setForeground(Color.WHITE);
this.setBackground(color); this.setBackground(this.color);
this.setFont(font); this.setFont(this.font);
this.setFocusPainted(false); this.setFocusPainted(false);
this.setContentAreaFilled(true); this.setContentAreaFilled(true);
//this.setBorderPainted(false); //this.setBorderPainted(false);