Transférer les fichiers vers 'src/Test' #1
@ -2,6 +2,8 @@ package Test;
|
|||||||
|
|
||||||
import API.Etudiant;
|
import API.Etudiant;
|
||||||
import API.Groupe;
|
import API.Groupe;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
@ -15,6 +17,8 @@ public class AdminView extends JPanel {
|
|||||||
public AdminView(ArrayList<Etudiant> e, ArrayList<Groupe> g, Controller listener) {
|
public AdminView(ArrayList<Etudiant> e, ArrayList<Groupe> g, Controller listener) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
this.setLayout(new GridBagLayout());
|
||||||
|
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.g = g;
|
this.g = g;
|
||||||
this.e = e;
|
this.e = e;
|
||||||
|
@ -219,6 +219,19 @@ public class BDatabase {
|
|||||||
return listGroupe;
|
return listGroupe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Recuperer le nombre de membre d'un groupe
|
||||||
|
*
|
||||||
|
* @param groupe_id le groupes
|
||||||
|
* @return le nombre de membre
|
||||||
|
* */
|
||||||
|
public int getMemberCount(int groupe_id) {
|
||||||
|
ArrayList<String> forCount = this.fetchAll(
|
||||||
|
"SELECT nom FROM fi_eleves WHERE groupe=" + groupe_id);
|
||||||
|
|
||||||
|
return forCount.size();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recuperer l'hote courant.
|
* Recuperer l'hote courant.
|
||||||
@ -251,16 +264,4 @@ public class BDatabase {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return this.db_host + "\n" + this.db_name + "\n" + this.db_user + "\n";
|
return this.db_host + "\n" + this.db_name + "\n" + this.db_user + "\n";
|
||||||
}
|
}
|
||||||
/***
|
|
||||||
* Recupere le nombre d'etudiant par groupe
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public ArrayList<NBGroupe> getNbrEtuGroupes() {
|
|
||||||
ArrayList<NBGroupe> NGroupe = new ArrayList<>();
|
|
||||||
ArrayList<String> groupeNB = this.fetchAll("SELECT COUNT(DISTINCT groupe) FROM fi_eleves;");
|
|
||||||
for(int i = 0; i <= NGroupe.Goupe(groupeNB); i++) {
|
|
||||||
ArrayList<String> grpnb = this.fetchAll("Select count(id) from fi_eleves where groupe="+i+";");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -108,7 +108,7 @@ public class BFrame extends JFrame {
|
|||||||
* @param daron La fenetre qui va etre bloquer
|
* @param daron La fenetre qui va etre bloquer
|
||||||
* @param content Contenu de la fenetre
|
* @param content Contenu de la fenetre
|
||||||
* */
|
* */
|
||||||
public BFrame(String title, int loca_x, int loca_y, int size_x, int size_y, BFrame daron, JPanel content) {
|
public BFrame(String title, int loca_x, int loca_y, int size_x, int size_y, JFrame daron, JPanel content) {
|
||||||
JDialog frame = new JDialog(daron, title, true);
|
JDialog frame = new JDialog(daron, title, true);
|
||||||
frame.setLocation(loca_x, loca_y);
|
frame.setLocation(loca_x, loca_y);
|
||||||
frame.setSize(size_x, size_y);
|
frame.setSize(size_x, size_y);
|
||||||
|
@ -18,10 +18,10 @@ 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 ProfView pv = null;
|
private ProfView pv;
|
||||||
private AdminView av = null;
|
private AdminView av;
|
||||||
|
private StudentView sv;
|
||||||
private BFrame currentModal;
|
private BFrame currentModal;
|
||||||
|
|
||||||
private MainMenu parent;
|
private MainMenu parent;
|
||||||
|
|
||||||
private ArrayList<Etudiant> e;
|
private ArrayList<Etudiant> e;
|
||||||
@ -32,17 +32,15 @@ public class Controller implements ActionListener, ListSelectionListener {
|
|||||||
|
|
||||||
private ArrayList<String> tmpStud;
|
private ArrayList<String> tmpStud;
|
||||||
|
|
||||||
public Controller(BDatabase db, MainMenu frame) {
|
public Controller(BDatabase db) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.e = this.db.getEtuList();
|
this.e = this.db.getEtuList();
|
||||||
this.g = this.db.getGroupeList();
|
this.g = this.db.getGroupeList();
|
||||||
parent = frame;
|
|
||||||
|
|
||||||
// Les 3 fenetres s'ouvriront en meme temps (Pour le contexte du projet)
|
this.sv = new StudentView(this.e, this.g, this);
|
||||||
//this.pv = new ProfView(this.e, this.g, this);
|
this.pv = new ProfView(this.e, this.g, this);
|
||||||
//System.out.println("[+] Demarrage de la vue professeur -> " + this.pv);
|
this.av = new AdminView(this.e, this.g, this);
|
||||||
//this.av = new AdminView(this.e, this.g, this);
|
this.parent = new MainMenu(this);
|
||||||
//System.out.println("[+] Demarrage de la vue Administrateur -> " + this.av);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,11 +56,10 @@ public class Controller implements ActionListener, ListSelectionListener {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: mettre a jour les parametres de la methode la pluplart sont inutiles
|
||||||
/**
|
/**
|
||||||
* Pour afficher une JTable sans listener
|
* Pour afficher une JTable sans listener
|
||||||
*
|
*
|
||||||
* @param parent La fenetre qui sera bloque
|
|
||||||
* @param frameTitle Le titre de la fenetre
|
* @param frameTitle Le titre de la fenetre
|
||||||
* @param size_x Taille en x
|
* @param size_x Taille en x
|
||||||
* @param size_y Taille en y
|
* @param size_y Taille en y
|
||||||
@ -79,15 +76,17 @@ public class Controller implements ActionListener, ListSelectionListener {
|
|||||||
|
|
||||||
this.currentJTableUse = liste;
|
this.currentJTableUse = liste;
|
||||||
|
|
||||||
forModal.add(liste);
|
this.parent.updateTable(liste);
|
||||||
|
|
||||||
BFrame frame = new BFrame(frameTitle, loca_x, loca_y, size_x, size_y, parent, forModal);
|
|
||||||
|
//forModal.add(liste);
|
||||||
|
//BFrame frame = new BFrame(frameTitle, loca_x, loca_y, size_x, size_y, this.parent, forModal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: mettre a jour les parametres de la methode la pluplart sont inutiles
|
||||||
/**
|
/**
|
||||||
* Pour afficher une JTable contenant un listener
|
* Pour afficher une JTable contenant un listener
|
||||||
*
|
*
|
||||||
* @param parent La fenetre qui sera bloque
|
|
||||||
* @param frameTitle Le titre de la fenetre
|
* @param frameTitle Le titre de la fenetre
|
||||||
* @param size_x Taille en x
|
* @param size_x Taille en x
|
||||||
* @param size_y Taille en y
|
* @param size_y Taille en y
|
||||||
@ -105,15 +104,15 @@ public class Controller implements ActionListener, ListSelectionListener {
|
|||||||
|
|
||||||
this.currentJTableUse = liste;
|
this.currentJTableUse = liste;
|
||||||
|
|
||||||
forModal.add(liste);
|
this.parent.updateTable(liste);
|
||||||
|
|
||||||
BFrame frame = new BFrame(frameTitle, loca_x, loca_y, size_x, size_y, this.parent, forModal);
|
//forModal.add(liste);
|
||||||
|
//BFrame frame = new BFrame(frameTitle, loca_x, loca_y, size_x, size_y, this.parent, forModal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pour afficher une modale classique pour plus de liberte (panel a creer au prealable)
|
* Pour afficher une modale classique pour plus de liberte (panel a creer au prealable)
|
||||||
*
|
*
|
||||||
* @param parent La fenetre qui sera bloque
|
|
||||||
* @param frameTitle Le titre de la fenetre
|
* @param frameTitle Le titre de la fenetre
|
||||||
* @param size_x Taille en x
|
* @param size_x Taille en x
|
||||||
* @param size_y Taille en y
|
* @param size_y Taille en y
|
||||||
@ -286,7 +285,7 @@ public class Controller implements ActionListener, ListSelectionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if(Objects.equals(command, "av::AddStudGrup")) {
|
else if(Objects.equals(command, "av::AddStudGrup")) {
|
||||||
ArrayList<ArrayList<String>> data = new ArrayList();
|
ArrayList<ArrayList<String>> data = new ArrayList<>();
|
||||||
|
|
||||||
String[] titre = {
|
String[] titre = {
|
||||||
"Nom",
|
"Nom",
|
||||||
@ -379,7 +378,7 @@ public class Controller implements ActionListener, ListSelectionListener {
|
|||||||
JLabel intro = new JLabel(
|
JLabel intro = new JLabel(
|
||||||
"Deplacer " + tm.getValueAt(cell[0], 0) + " " +
|
"Deplacer " + tm.getValueAt(cell[0], 0) + " " +
|
||||||
tm.getValueAt(cell[0], 1) +
|
tm.getValueAt(cell[0], 1) +
|
||||||
" dans le groupe : "
|
" dans le groupe : "
|
||||||
);
|
);
|
||||||
forModal.add(intro, settings);
|
forModal.add(intro, settings);
|
||||||
|
|
||||||
@ -436,18 +435,35 @@ public class Controller implements ActionListener, ListSelectionListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JTable initTable() {
|
||||||
public void setAv (AdminView av) {
|
Object[][] data = new Object[this.e.size()][3];
|
||||||
if (this.av == null) {
|
String[] title = {
|
||||||
this.av = av;
|
"Nom",
|
||||||
|
"Prenom",
|
||||||
|
"Groupe",
|
||||||
|
};
|
||||||
|
for(int i = 0; i <= this.e.size()-1; i++) {
|
||||||
|
Object[] info = {
|
||||||
|
this.e.get(i).getNom(),
|
||||||
|
this.e.get(i).getPrenom(),
|
||||||
|
String.valueOf(this.e.get(i).getGroupe()),
|
||||||
|
"[DEPLACER]"
|
||||||
|
};
|
||||||
|
data[i] = info;
|
||||||
}
|
}
|
||||||
|
return createJTable(data, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProfView getProfView() {
|
||||||
|
return this.pv;
|
||||||
|
}
|
||||||
|
|
||||||
public void setPv (ProfView pv) {
|
public StudentView getStudentView() {
|
||||||
if (this.pv == null) {
|
return this.sv;
|
||||||
this.pv = pv;
|
}
|
||||||
}
|
|
||||||
|
public AdminView getAdminView() {
|
||||||
|
return this.av;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,106 +1,240 @@
|
|||||||
package Test;
|
package Test;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
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();
|
private final CardLayout cards = new CardLayout(), adminCards = new CardLayout(), profCards = new CardLayout(), studentCards = new CardLayout();
|
||||||
private AdminView av;
|
private final JPanel adminPanel = new JPanel(), profPanel = new JPanel(), studentPanel = new JPanel();
|
||||||
private ProfView pv;
|
private final JMenuBar menuBar = new JMenuBar();
|
||||||
|
private Controller listener;
|
||||||
|
private AdminView av;
|
||||||
private JButton[] buttonTab = {
|
private ProfView pv;
|
||||||
new JButton("Admin"),
|
private StudentView sv;
|
||||||
new JButton("Prof"),
|
private JTable table;
|
||||||
new JButton("Student")
|
private int cardIndex = 0;
|
||||||
};
|
private String[] viewName = {"Administrateur", "Professeur", "Etudiant"};
|
||||||
|
|
||||||
|
private final JButton[] buttonTab = {
|
||||||
public MainMenu() {
|
new JButton(viewName[0]),
|
||||||
super();
|
new JButton(viewName[1]),
|
||||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
new JButton(viewName[2])
|
||||||
this.setExtendedState(MAXIMIZED_BOTH);
|
};
|
||||||
this.setMinimumSize(MINIMUM_SIZE);
|
|
||||||
init();
|
|
||||||
this.setVisible(true);
|
public MainMenu(Controller listener) {
|
||||||
}
|
super();
|
||||||
|
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||||
|
this.setExtendedState(MAXIMIZED_BOTH);
|
||||||
private void init() {
|
this.setMinimumSize(MINIMUM_SIZE);
|
||||||
BDatabase db = new BDatabase();
|
init(listener);
|
||||||
Controller listener = new Controller(db, this);
|
this.setVisible(true);
|
||||||
|
}
|
||||||
av = new AdminView(listener.getEtudiants(), listener.getGroupes(), listener);
|
|
||||||
pv = new ProfView(listener.getEtudiants(), listener.getGroupes(), listener);
|
|
||||||
|
private void init(Controller listener) {
|
||||||
listener.setAv(av);
|
this.listener = listener;
|
||||||
listener.setPv(pv);
|
|
||||||
|
this.av = this.listener.getAdminView();
|
||||||
this.setLayout(cards);
|
this.pv = this.listener.getProfView();
|
||||||
|
this.sv = this.listener.getStudentView();
|
||||||
this.add(first());
|
|
||||||
this.add(adminView());
|
this.table = this.listener.initTable();
|
||||||
this.add(profView());
|
|
||||||
|
this.setLayout(cards);
|
||||||
cards.first(this.getContentPane());
|
|
||||||
}
|
this.add(firstCard());
|
||||||
|
this.add(adminPanel);
|
||||||
|
this.add(profPanel);
|
||||||
private JPanel first() {
|
this.add(studentView());
|
||||||
JPanel mainPanel = new JPanel(), centerPanel = new JPanel();
|
|
||||||
Dimension buttonDimension = new Dimension(300, 50);
|
cards.first(this.getContentPane());
|
||||||
|
}
|
||||||
mainPanel.setLayout(new BorderLayout());
|
|
||||||
centerPanel.setLayout(new GridBagLayout());
|
|
||||||
|
private void createJMenuBar() {
|
||||||
Insets insets = new Insets(10, 10, 10, 10);
|
JMenu menu = new JMenu("Menu"), file = new JMenu("File"), edit = new JMenu("Edit"), view = new JMenu("View");
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
|
||||||
gbc.insets = insets;
|
JMenuItem adminMenuItem = new JMenuItem("Vu "+viewName[0]);
|
||||||
gbc.gridwidth = 1;
|
adminMenuItem.addActionListener((event) -> changeView(1));
|
||||||
gbc.gridx = 0;
|
|
||||||
|
JMenuItem profMenuItem = new JMenuItem("Vu "+viewName[1]);
|
||||||
for (int i = 0; i < buttonTab.length; i++) {
|
profMenuItem.addActionListener((event) -> changeView(2));
|
||||||
gbc.gridy = i;
|
|
||||||
buttonTab[i].setPreferredSize(buttonDimension);
|
JMenuItem studentMenuItem = new JMenuItem("Vu "+viewName[2]);
|
||||||
buttonTab[i].addActionListener(this::action);
|
studentMenuItem.addActionListener((event) -> changeView(3));
|
||||||
centerPanel.add(buttonTab[i], gbc);
|
|
||||||
}
|
JMenuItem quitMenuItem = new JMenuItem("Quitter");
|
||||||
|
quitMenuItem.addActionListener((event) -> System.exit(0));
|
||||||
mainPanel.add(centerPanel, BorderLayout.CENTER);
|
|
||||||
|
menu.add(adminMenuItem);
|
||||||
return mainPanel;
|
menu.add(profMenuItem);
|
||||||
}
|
menu.add(studentMenuItem);
|
||||||
|
menu.add(quitMenuItem);
|
||||||
|
|
||||||
private JPanel adminView() {
|
file.add(new JMenuItem("Ca c'est juste du style"));
|
||||||
JPanel mainPanel = new JPanel();
|
edit.add(new JMenuItem("Ca aussi c'est du style"));
|
||||||
mainPanel.add(av);
|
view.add(new JMenuItem("Encore du style"));
|
||||||
return mainPanel;
|
|
||||||
}
|
menuBar.add(menu);
|
||||||
|
menuBar.add(file);
|
||||||
|
menuBar.add(edit);
|
||||||
private JPanel profView() {
|
menuBar.add(view);
|
||||||
JPanel mainPanel = new JPanel();
|
|
||||||
mainPanel.add(pv);
|
this.setJMenuBar(menuBar);
|
||||||
return mainPanel;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
private JPanel cardWithTable(JPanel sidePanel) {
|
||||||
private void action(ActionEvent e) {
|
JPanel panel = new JPanel();
|
||||||
JButton origin = (JButton) e.getSource();
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
System.out.println(origin.getText());
|
|
||||||
|
panel.setLayout(new GridLayout(1, 2));
|
||||||
if (origin.getText() == "Admin") {
|
|
||||||
cards.next(this.getContentPane());
|
panel.add(sidePanel);
|
||||||
|
panel.add(this.table);
|
||||||
} else if (origin.getText() == "Prof") {
|
panel.add(scrollPane);
|
||||||
cards.next(this.getContentPane());
|
scrollPane.setViewportView(this.table);
|
||||||
cards.next(this.getContentPane());
|
|
||||||
|
return panel;
|
||||||
} else {
|
}
|
||||||
JOptionPane.showMessageDialog(null, "En travaux");
|
|
||||||
}
|
|
||||||
}
|
private void changeView(int index) {
|
||||||
}
|
table = this.listener.initTable();
|
||||||
|
|
||||||
|
if (index == 1) {
|
||||||
|
cardIndex = index;
|
||||||
|
this.setTitle(viewName[0]);
|
||||||
|
adminPanel.setLayout(adminCards);
|
||||||
|
adminPanel.add(cardWithTable(adminView()));
|
||||||
|
adminCards.next(adminPanel);
|
||||||
|
menuBar.setBackground(Color.RED);
|
||||||
|
|
||||||
|
} else if (index == 2) {
|
||||||
|
cardIndex = index;
|
||||||
|
this.setTitle(viewName[1]);
|
||||||
|
profPanel.setLayout(profCards);
|
||||||
|
profPanel.add(cardWithTable(profView()));
|
||||||
|
profCards.next(profPanel);
|
||||||
|
menuBar.setBackground(Color.MAGENTA);
|
||||||
|
|
||||||
|
} else if (index == 3){
|
||||||
|
cardIndex = index;
|
||||||
|
this.setTitle(viewName[2]);
|
||||||
|
studentPanel.setLayout(studentCards);
|
||||||
|
studentPanel.add(cardWithTable(studentView()));
|
||||||
|
studentCards.next(studentPanel);
|
||||||
|
menuBar.setBackground(Color.BLUE);
|
||||||
|
}
|
||||||
|
travelThroughCards(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void updateTable(JTable table) {
|
||||||
|
if (cardIndex == 1) {
|
||||||
|
this.table = table;
|
||||||
|
adminPanel.add(cardWithTable(adminView()));
|
||||||
|
adminCards.next(adminPanel);
|
||||||
|
} else if (cardIndex == 2) {
|
||||||
|
this.table = table;
|
||||||
|
profPanel.add(cardWithTable(profView()));
|
||||||
|
profCards.next(profPanel);
|
||||||
|
} else {
|
||||||
|
this.table = table;
|
||||||
|
studentPanel.add(cardWithTable(profView()));
|
||||||
|
studentCards.next(studentPanel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private JPanel firstCard() {
|
||||||
|
JPanel mainPanel = new JPanel(), centerPanel = new JPanel();
|
||||||
|
Dimension buttonDimension = new Dimension(300, 50);
|
||||||
|
|
||||||
|
mainPanel.setLayout(new BorderLayout());
|
||||||
|
centerPanel.setLayout(new GridBagLayout());
|
||||||
|
|
||||||
|
Insets insets = new Insets(10, 10, 10, 10);
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.insets = insets;
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < buttonTab.length; i++) {
|
||||||
|
gbc.gridy = i;
|
||||||
|
buttonTab[i].setPreferredSize(buttonDimension);
|
||||||
|
buttonTab[i].addActionListener(this::action);
|
||||||
|
centerPanel.add(buttonTab[i], gbc);
|
||||||
|
}
|
||||||
|
|
||||||
|
mainPanel.add(centerPanel, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
return mainPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private JPanel adminView() {
|
||||||
|
JPanel mainPanel = new JPanel();
|
||||||
|
mainPanel.setLayout(new BorderLayout());
|
||||||
|
mainPanel.add(this.av, BorderLayout.CENTER);
|
||||||
|
return mainPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private JPanel profView() {
|
||||||
|
JPanel mainPanel = new JPanel();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void action(ActionEvent e) {
|
||||||
|
JButton origin = (JButton) e.getSource();
|
||||||
|
createJMenuBar();
|
||||||
|
|
||||||
|
if (origin.getText().equals(viewName[0])) {
|
||||||
|
this.setTitle(viewName[0]);
|
||||||
|
menuBar.setBackground(Color.RED);
|
||||||
|
adminPanel.setLayout(adminCards);
|
||||||
|
adminPanel.add(cardWithTable(adminView()));
|
||||||
|
cardIndex = 1;
|
||||||
|
|
||||||
|
} else if (origin.getText().equals(viewName[1])) {
|
||||||
|
this.setTitle(viewName[1]);
|
||||||
|
menuBar.setBackground(Color.MAGENTA);
|
||||||
|
profPanel.setLayout(profCards);
|
||||||
|
profPanel.add(cardWithTable(profView()));
|
||||||
|
cardIndex = 2;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.setTitle(viewName[2]);
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -8,9 +8,7 @@ import javax.swing.JButton;
|
|||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.*;
|
||||||
import java.awt.Insets;
|
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -25,6 +23,8 @@ public class ProfView extends JPanel {
|
|||||||
public ProfView(ArrayList<Etudiant> e, ArrayList<Groupe> g, Controller listener) {
|
public ProfView(ArrayList<Etudiant> e, ArrayList<Groupe> g, Controller listener) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
this.setLayout(new GridBagLayout());
|
||||||
|
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.e = e;
|
this.e = e;
|
||||||
this.g = g;
|
this.g = g;
|
||||||
|
125
src/Test/StudentView.java
Normal file
125
src/Test/StudentView.java
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
package Test;
|
||||||
|
|
||||||
|
import API.Etudiant;
|
||||||
|
import API.Groupe;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.KeyAdapter;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class StudentView extends JPanel {
|
||||||
|
private final ArrayList<Etudiant> e;
|
||||||
|
private final ArrayList<Groupe> g;
|
||||||
|
private final Controller listener;
|
||||||
|
private JComboBox<String> groupeOption;
|
||||||
|
private JTextField text;
|
||||||
|
|
||||||
|
public StudentView(ArrayList<Etudiant> e, ArrayList<Groupe> g, Controller listener) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.setLayout(new GridBagLayout());
|
||||||
|
|
||||||
|
this.listener = listener;
|
||||||
|
this.e = e;
|
||||||
|
this.g = g;
|
||||||
|
|
||||||
|
this.Display();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComboSelection() {
|
||||||
|
return (String) this.groupeOption.getSelectedItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSearchStud() {
|
||||||
|
return this.text.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getComboSelectionIndex() {
|
||||||
|
return this.groupeOption.getSelectedIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Display() {
|
||||||
|
BLayout settings = new BLayout();
|
||||||
|
settings.setPositionX(0);
|
||||||
|
settings.setPositionY(6);
|
||||||
|
|
||||||
|
settings.setPositionY(0);
|
||||||
|
JButton studList = new JButton("Voir la liste des etudiants");
|
||||||
|
studList.setActionCommand("pv::GetStudList");
|
||||||
|
studList.addActionListener(this.listener);
|
||||||
|
this.add(studList, settings);
|
||||||
|
|
||||||
|
settings.setPositionY(1);
|
||||||
|
this.add(new JLabel(" "), settings);
|
||||||
|
|
||||||
|
settings.setPositionY(2);
|
||||||
|
JLabel gs = new JLabel("Afficher les etudiants se trouvant dans le groupe :");
|
||||||
|
this.add(gs, settings);
|
||||||
|
|
||||||
|
settings.setPositionY(3);
|
||||||
|
settings.setPadding(new Insets(0, 0, 0, 50));
|
||||||
|
String[] groupeList = new String[this.g.size()];
|
||||||
|
|
||||||
|
for(int i = 0; i <= this.g.size()-1; i++) {
|
||||||
|
groupeList[i] = this.g.get(i).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.groupeOption = new JComboBox<>(groupeList);
|
||||||
|
this.groupeOption.setPreferredSize(new Dimension(110, 30));
|
||||||
|
this.add(groupeOption, settings);
|
||||||
|
|
||||||
|
settings.setPositionY(3);
|
||||||
|
settings.setPadding(new Insets(0, 0, 0, 0));
|
||||||
|
settings.setAnchor(GridBagConstraints.EAST);
|
||||||
|
JButton confirm = new JButton("Rechercher");
|
||||||
|
confirm.setActionCommand("pv::GetListFiltered");
|
||||||
|
confirm.addActionListener(this.listener);
|
||||||
|
this.add(confirm, settings);
|
||||||
|
|
||||||
|
settings.setAnchor(GridBagConstraints.CENTER);
|
||||||
|
|
||||||
|
settings.setPositionY(4);
|
||||||
|
this.add(new JLabel(" "), settings);
|
||||||
|
|
||||||
|
settings.setPositionY(5);
|
||||||
|
JLabel pf = new JLabel("Rechercher un etudiant : ");
|
||||||
|
this.add(pf, settings);
|
||||||
|
|
||||||
|
settings.setPositionY(6);
|
||||||
|
settings.setPadding(new Insets(0, 0, 0, 50));
|
||||||
|
this.text = new JTextField();
|
||||||
|
this.text.setPreferredSize(new Dimension(110, 30));
|
||||||
|
text.addKeyListener(new KeyAdapter() {
|
||||||
|
public void keyTyped(KeyEvent e) {
|
||||||
|
if (text.getText().length() >= 3 )
|
||||||
|
e.consume();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.add(this.text, settings);
|
||||||
|
|
||||||
|
settings.setPositionY(6);
|
||||||
|
settings.setPadding(new Insets(0, 0, 0, 0));
|
||||||
|
settings.setAnchor(GridBagConstraints.EAST);
|
||||||
|
JButton searchTLetters = new JButton("Rechercher");
|
||||||
|
searchTLetters.addActionListener(this.listener);
|
||||||
|
searchTLetters.setActionCommand("pv::SearchStudentPer3Letters");
|
||||||
|
this.add(searchTLetters, settings);
|
||||||
|
settings.setAnchor(GridBagConstraints.CENTER);
|
||||||
|
|
||||||
|
settings.setPositionY(7);
|
||||||
|
this.add(new JLabel(" "), settings);
|
||||||
|
|
||||||
|
settings.setPositionY(8);
|
||||||
|
JButton changGrp = new JButton("Changer de groupe");
|
||||||
|
changGrp.addActionListener(this.listener);
|
||||||
|
this.add(changGrp, settings);
|
||||||
|
|
||||||
|
this.repaint();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user