Transférer les fichiers vers 'src/Test' #1
@ -18,11 +18,11 @@ import java.util.Objects;
|
||||
public class Controller implements ActionListener, ListSelectionListener {
|
||||
private final BDatabase db;
|
||||
|
||||
private ProfView pv;
|
||||
private AdminView av;
|
||||
private StudentView sv;
|
||||
private ProfView pv = null;
|
||||
private AdminView av = null;
|
||||
private BFrame currentModal;
|
||||
private JFrame parent;
|
||||
|
||||
private MainMenu parent;
|
||||
|
||||
private ArrayList<Etudiant> e;
|
||||
private ArrayList<Groupe> g;
|
||||
@ -32,15 +32,17 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
|
||||
private ArrayList<String> 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;
|
||||
|
||||
this.sv = new StudentView(this.e, this.g, this);
|
||||
this.pv = new ProfView(this.e, this.g, this);
|
||||
this.av = new AdminView(this.e, this.g, this);
|
||||
this.parent = new MainMenu(this);
|
||||
// Les 3 fenetres s'ouvriront en meme temps (Pour le contexte du projet)
|
||||
//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);
|
||||
//System.out.println("[+] Demarrage de la vue Administrateur -> " + this.av);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,6 +58,7 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pour afficher une JTable sans listener
|
||||
*
|
||||
@ -75,9 +78,12 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,9 +106,10 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -280,7 +287,7 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
}
|
||||
|
||||
else if(Objects.equals(command, "av::AddStudGrup")) {
|
||||
ArrayList<ArrayList<String>> data = new ArrayList<>();
|
||||
ArrayList<ArrayList<String>> data = new ArrayList();
|
||||
|
||||
String[] titre = {
|
||||
"Nom",
|
||||
@ -430,16 +437,41 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
}
|
||||
}
|
||||
|
||||
public ProfView getProfView() {
|
||||
return this.pv;
|
||||
|
||||
public JTable initTable() {
|
||||
Object[][] data = new Object[this.e.size()][3];
|
||||
String[] title = {
|
||||
"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 StudentView getStudentView() {
|
||||
return this.sv;
|
||||
|
||||
public void setAv (AdminView av) {
|
||||
if (this.av == null) {
|
||||
this.av = av;
|
||||
}
|
||||
}
|
||||
|
||||
public AdminView getAdminView() {
|
||||
return this.av;
|
||||
|
||||
public void setPv (ProfView pv) {
|
||||
if (this.pv == null) {
|
||||
this.pv = pv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,58 +6,88 @@ import java.awt.event.ActionEvent;
|
||||
|
||||
public class MainMenu extends JFrame {
|
||||
private final static Dimension MINIMUM_SIZE = new Dimension(960, 540);
|
||||
private CardLayout cards;
|
||||
|
||||
private CardLayout cards = new CardLayout(), adminCards = new CardLayout();
|
||||
private JPanel adminPanel = new JPanel(), profPanel = new JPanel();
|
||||
private AdminView av;
|
||||
private StudentView sv;
|
||||
private ProfView pv;
|
||||
private JTable table;
|
||||
private int cardIndex = 0;
|
||||
|
||||
private BLayout settings;
|
||||
|
||||
private final Controller listener;
|
||||
private JButton[] buttonTab = {
|
||||
new JButton("Admin"),
|
||||
new JButton("Prof"),
|
||||
new JButton("Student")
|
||||
};
|
||||
|
||||
private JButton[] buttonTab;
|
||||
|
||||
public MainMenu(Controller listener) {
|
||||
public MainMenu() {
|
||||
super();
|
||||
|
||||
this.av = listener.getAdminView();
|
||||
this.pv = listener.getProfView();
|
||||
this.sv = listener.getStudentView();
|
||||
|
||||
this.cards = new CardLayout();
|
||||
|
||||
this.listener = listener;
|
||||
|
||||
this.buttonTab = new JButton[] {
|
||||
new JButton("Admin"),
|
||||
new JButton("Prof"),
|
||||
new JButton("Student")
|
||||
};
|
||||
|
||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
this.setExtendedState(MAXIMIZED_BOTH);
|
||||
this.setMinimumSize(MINIMUM_SIZE);
|
||||
this.init();
|
||||
init();
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
private void init() {
|
||||
this.setLayout(this.cards);
|
||||
BDatabase db = new BDatabase();
|
||||
Controller listener = new Controller(db, this);
|
||||
|
||||
this.av = new AdminView(listener.getEtudiants(), listener.getGroupes(), listener);
|
||||
this.pv = new ProfView(listener.getEtudiants(), listener.getGroupes(), listener);
|
||||
|
||||
listener.setAv(av);
|
||||
listener.setPv(pv);
|
||||
|
||||
this.table = listener.initTable();
|
||||
|
||||
adminPanel.setLayout(adminCards);
|
||||
adminPanel.add(cardWithTable(adminView()));
|
||||
|
||||
this.setLayout(cards);
|
||||
|
||||
this.add(first());
|
||||
this.add(adminView());
|
||||
this.add(profView());
|
||||
this.add(studentView());
|
||||
this.add(adminPanel);
|
||||
//this.add(cardWithTable(profView()));
|
||||
|
||||
this.cards.first(this.getContentPane());
|
||||
cards.first(this.getContentPane());
|
||||
}
|
||||
|
||||
|
||||
private JPanel cardWithTable(JPanel sidePanel) {
|
||||
JPanel panel = new JPanel();
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
|
||||
panel.setLayout(new GridLayout(1, 2));
|
||||
|
||||
panel.add(sidePanel);
|
||||
panel.add(this.table);
|
||||
panel.add(scrollPane);
|
||||
scrollPane.setViewportView(this.table);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
adminPanel.add(cardWithTable(profView()));
|
||||
adminCards.next(profPanel);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private JPanel first() {
|
||||
JPanel mainPanel = new JPanel();
|
||||
JPanel centerPanel = new JPanel();
|
||||
JPanel mainPanel = new JPanel(), centerPanel = new JPanel();
|
||||
Dimension buttonDimension = new Dimension(300, 50);
|
||||
|
||||
mainPanel.setLayout(new BorderLayout());
|
||||
@ -83,22 +113,18 @@ public class MainMenu extends JFrame {
|
||||
|
||||
|
||||
private JPanel adminView() {
|
||||
JPanel mainPanel = new JPanel(new GridBagLayout());
|
||||
mainPanel.add(this.av, this.settings);
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.add(av);
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
|
||||
private JPanel profView() {
|
||||
JPanel mainPanel = new JPanel(new GridBagLayout());
|
||||
mainPanel.add(this.pv, this.settings);
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.add(pv);
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
private JPanel studentView() {
|
||||
JPanel mainPanel = new JPanel(new GridBagLayout());
|
||||
mainPanel.add(this.sv, this.settings);
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
private void action(ActionEvent e) {
|
||||
JButton origin = (JButton) e.getSource();
|
||||
@ -106,18 +132,16 @@ public class MainMenu extends JFrame {
|
||||
|
||||
if (origin.getText() == "Admin") {
|
||||
cards.next(this.getContentPane());
|
||||
cardIndex = 1;
|
||||
|
||||
} else if (origin.getText() == "Prof") {
|
||||
cards.next(this.getContentPane());
|
||||
cards.next(this.getContentPane());
|
||||
} else if (origin.getText() == "Student") {
|
||||
cards.next(this.getContentPane());
|
||||
cards.next(this.getContentPane());
|
||||
cards.next(this.getContentPane());
|
||||
}
|
||||
cardIndex = 2;
|
||||
|
||||
else {
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "En travaux");
|
||||
cardIndex = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user