$
This commit is contained in:
parent
7dd1cbbf33
commit
24fda790b0
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -8,8 +8,7 @@ package Test;
|
||||
* */
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.*;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
/**
|
||||
@ -114,7 +113,6 @@ public class BFrame extends JFrame {
|
||||
frame.setLocation(loca_x, loca_y);
|
||||
frame.setSize(size_x, size_y);
|
||||
frame.getContentPane().add(content);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
frame.getContentPane().add(scrollPane);
|
||||
scrollPane.setViewportView(content);
|
||||
|
@ -16,9 +16,8 @@ import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
//test
|
||||
import javax.swing.JDialog;
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.JPanel;
|
||||
import java.awt.GridLayout;
|
||||
|
||||
public class Controller implements ActionListener, ListSelectionListener {
|
||||
private final BDatabase db;
|
||||
@ -52,28 +51,42 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Pour afficher une JTable
|
||||
* @param frame La fenetre
|
||||
* Pour afficher une JTable sans listener
|
||||
*
|
||||
* @param parent La fenetre qui sera bloque
|
||||
* @param frameTitle Le titre de la fenetre
|
||||
* @param size_x Taille en x
|
||||
* @param size_y Taille en y
|
||||
* @param loca_x Localisation en x
|
||||
* @param loca_y Localisation en y
|
||||
* @param liste La JTable
|
||||
* */
|
||||
private void Display(BFrame frame, JTable liste) {
|
||||
private void Display(BFrame parent, String frameTitle, int size_x, int size_y, int loca_x, int loca_y, JTable liste) {
|
||||
JPanel forModal = new JPanel();
|
||||
|
||||
ListSelectionModel lsm = liste.getSelectionModel();
|
||||
liste.getTableHeader().setReorderingAllowed(false);
|
||||
liste.setFillsViewportHeight(true);
|
||||
|
||||
this.currentJTableUse = liste;
|
||||
|
||||
JScrollPane scroll = new JScrollPane(liste);
|
||||
frame.getContentPane().add(scroll);
|
||||
forModal.add(liste);
|
||||
|
||||
frame.openBFrame();
|
||||
BFrame frame = new BFrame(frameTitle, loca_x, loca_y, size_x, size_y, parent, forModal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pour afficher une JTable contenant un listener
|
||||
* @param frameTitle La fenetre
|
||||
*
|
||||
* @param parent La fenetre qui sera bloque
|
||||
* @param frameTitle Le titre de la fenetre
|
||||
* @param size_x Taille en x
|
||||
* @param size_y Taille en y
|
||||
* @param loca_x Localisation en x
|
||||
* @param loca_y Localisation en y
|
||||
* @param liste La JTable
|
||||
* */
|
||||
private void DisplayWithListner(BFrame parent, String frameTitle, JTable liste) {
|
||||
private void DisplayWithListner(BFrame parent, String frameTitle, int size_x, int size_y, int loca_x, int loca_y, JTable liste) {
|
||||
JPanel forModal = new JPanel();
|
||||
|
||||
ListSelectionModel lsm = liste.getSelectionModel();
|
||||
@ -85,9 +98,7 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
|
||||
forModal.add(liste);
|
||||
|
||||
// BETA
|
||||
// TODO: Manque les colonnes et prends toute la surface
|
||||
BFrame frame = new BFrame(frameTitle, 1, 1, 500, 500, parent, forModal);
|
||||
BFrame frame = new BFrame(frameTitle, loca_x, loca_y, size_x, size_y, parent, forModal);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -99,18 +110,6 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
String text = this.pv.getSearchStud();
|
||||
|
||||
if(Objects.equals(command, "pv::GetStudList")) {
|
||||
BFrame frame = new BFrame(
|
||||
"Liste des eleves",
|
||||
1,
|
||||
1,
|
||||
500,
|
||||
500,
|
||||
"GridLayout",
|
||||
1,
|
||||
1,
|
||||
2
|
||||
);
|
||||
|
||||
String[][] data = new String[this.e.size()][2];
|
||||
|
||||
String[] titre = {
|
||||
@ -129,22 +128,18 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
data[i] = info;
|
||||
}
|
||||
|
||||
Display(frame, this.createJTable(data, titre));
|
||||
Display(
|
||||
this.pv,
|
||||
"Liste des etudiants",
|
||||
350,
|
||||
400,
|
||||
this.pv.getX(),
|
||||
this.pv.getY(),
|
||||
this.createJTable(data, titre)
|
||||
);
|
||||
}
|
||||
|
||||
else if(Objects.equals(command, "pv::GetListFiltered")) {
|
||||
BFrame frame = new BFrame(
|
||||
"Liste des eleves du " + groupeOption,
|
||||
1,
|
||||
1,
|
||||
500,
|
||||
500,
|
||||
"GridLayout",
|
||||
1,
|
||||
1,
|
||||
2
|
||||
);
|
||||
|
||||
String[][] data = new String[this.e.size()][1];
|
||||
|
||||
String[] titre = {
|
||||
@ -171,7 +166,15 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
data_final[x] = data[x];
|
||||
}
|
||||
|
||||
Display(frame, this.createJTable(data, titre));
|
||||
Display(
|
||||
this.pv,
|
||||
"Liste d'eleve du " + groupeOption,
|
||||
350,
|
||||
400,
|
||||
this.pv.getX(),
|
||||
this.pv.getY(),
|
||||
this.createJTable(data_final, titre)
|
||||
);
|
||||
}
|
||||
|
||||
else if(Objects.equals(command, "pv::SearchStudentPer3Letters")) {
|
||||
@ -185,18 +188,6 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
} else {
|
||||
char[] beg = text.toCharArray();
|
||||
|
||||
BFrame frame = new BFrame(
|
||||
"Liste d'eleves d'ou les noms commence par " + beg[0] + beg[1] + beg[2],
|
||||
1,
|
||||
1,
|
||||
500,
|
||||
500,
|
||||
"GridLayout",
|
||||
1,
|
||||
1,
|
||||
2
|
||||
);
|
||||
|
||||
ArrayList<String> filtreEleveNom = db.fetchAll("SELECT nom FROM fi_eleves WHERE nom LIKE '" + beg[0] + beg[1] + beg[2] + "%'");
|
||||
ArrayList<String> filtreElevePrenom = db.fetchAll("SELECT prenom FROM fi_eleves WHERE nom LIKE '" + beg[0] + beg[1] + beg[2] + "%'");
|
||||
ArrayList<String> filtreEleveGroupe = db.fetchAll("SELECT groupe FROM fi_eleves WHERE nom LIKE '" + beg[0] + beg[1] + beg[2] + "%'");
|
||||
@ -210,8 +201,6 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
"Erreur.",
|
||||
JOptionPane.ERROR_MESSAGE
|
||||
);
|
||||
|
||||
frame.closeBFrame();
|
||||
} else {
|
||||
String[] titre = {
|
||||
"Nom",
|
||||
@ -229,18 +218,27 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
};
|
||||
}
|
||||
|
||||
Display(frame, this.createJTable(data, titre));
|
||||
Display(
|
||||
this.pv,
|
||||
"Recherche",
|
||||
350,
|
||||
400,
|
||||
this.pv.getX(),
|
||||
this.pv.getY(),
|
||||
this.createJTable(data, titre)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if(Objects.equals(command, "av::MoveStudGrup")) {
|
||||
Object[][] data = new Object[this.e.size()][2];
|
||||
Object[][] data = new Object[this.e.size()][3];
|
||||
|
||||
String[] titre = {
|
||||
"Nom",
|
||||
"Prenom",
|
||||
"Groupe"
|
||||
"Groupe",
|
||||
"Action"
|
||||
};
|
||||
|
||||
for(int i = 0; i <= this.e.size()-1; i++) {
|
||||
@ -248,12 +246,21 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
this.e.get(i).getNom(),
|
||||
this.e.get(i).getPrenom(),
|
||||
String.valueOf(this.e.get(i).getGroupe()),
|
||||
"[DEPLACER]"
|
||||
};
|
||||
|
||||
data[i] = info;
|
||||
}
|
||||
|
||||
DisplayWithListner(this.av, "Deplacer un etudiant", this.createJTable(data, titre));
|
||||
DisplayWithListner(
|
||||
this.av,
|
||||
"Deplacer un etudiant",
|
||||
350,
|
||||
400,
|
||||
this.av.getX(),
|
||||
this.av.getY(),
|
||||
this.createJTable(data, titre)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,11 +268,10 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
int[] cell;
|
||||
Object value;
|
||||
if (!e.getValueIsAdjusting())
|
||||
{
|
||||
|
||||
if (!e.getValueIsAdjusting()) {
|
||||
cell = this.currentJTableUse.getSelectedRows();
|
||||
if (cell.length > 0)
|
||||
{
|
||||
if (cell.length > 0) {
|
||||
for (int i=0; i < 3; i++) {
|
||||
TableModel tm = this.currentJTableUse.getModel();
|
||||
value = tm.getValueAt(cell[0], i);
|
||||
|
Loading…
Reference in New Issue
Block a user