debut MPD
This commit is contained in:
parent
fcf32a2ec0
commit
6c20bfcdf2
@ -1,7 +1,7 @@
|
||||
# COMMANDES #
|
||||
JAVAC = javac
|
||||
# note $$ to get a single shell $
|
||||
JAVAC_OPTIONS = -d build -cp build:$$CLASSPATH -implicit:none
|
||||
JAVAC_OPTIONS = -implicit:none -d build -classpath "res/mariadb-client.jar:build" -sourcepath src
|
||||
JAVA = java
|
||||
JAR = jar
|
||||
EXEC_JAR = ${JAVA} -jar
|
||||
@ -98,10 +98,10 @@ ${BUILD}/MNP/AbstractChangementFactoryNP.class : ${SRC}/MNP/AbstractChangementFa
|
||||
${BUILD}/Graphic/View/PaintGroupe.class : ${SRC}/Graphic/View/PaintGroupe.java
|
||||
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/View/PaintGroupe.java
|
||||
|
||||
${BUILD}/Graphic/View/Mafenetre.class : ${SRC}/Graphic/View/MaFenetre.java \
|
||||
${BUILD}/Graphic/Graphic.class : ${SRC}/Graphic/Graphic.java \
|
||||
${BUILD}/Graphic/Controller/ObservateurFenetre.class \
|
||||
${BUILD}/Graphic/View/PaintGroupe.class
|
||||
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/View/MaFenetre.java
|
||||
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/Graphic.java
|
||||
|
||||
## Controller ##
|
||||
${BUILD}/Graphic/Controller/ObservateurFenetre.class : ${SRC}/Graphic/Controller/ObservateurFenetre.java
|
||||
@ -118,11 +118,10 @@ ${BUILD}/Graphic/Controller/ObservateurFenetre.class : ${SRC}/Graphic/Controller
|
||||
${BUILD}/MNP/ChangementNP.class \
|
||||
${BUILD}/MNP/AbstractGroupeFactoryNP.class \
|
||||
${BUILD}/MNP/AbstractChangementFactoryNP.class \
|
||||
${BUILD}/Graphic/View/Mafenetre.class
|
||||
${BUILD}/Graphic/Graphic.class
|
||||
${JAVAC} -Xlint:deprecation ${JAVAC_OPTIONS} ${SRC}/Test/TestTexteMNP.java
|
||||
|
||||
# ## JARS ##
|
||||
|
||||
${JAR_MNP} : ${BUILD}/Test/TestTexteMNP.class
|
||||
${JAR} cvfe ${JAR_MNP} fr.iutfbleau.projetIHM2022FI2.Test.TestTexteMNP -C build fr
|
||||
|
||||
${JAR} cfme ${JAR_MNP} Manifest.txt fr/iutfbleau/projetIHM2022FI2/Test/TestTexteMNP res/ -C build fr
|
||||
|
3
java/APIGroupe/Manifest.txt
Normal file
3
java/APIGroupe/Manifest.txt
Normal file
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path: res/mariadb-client.jar
|
||||
Created-By: 1.7.0_06 (Oracle Corporation)
|
@ -7,4 +7,15 @@ public enum TypeGroupe {
|
||||
private TypeGroupe(String s) {
|
||||
name = s;
|
||||
}
|
||||
public static TypeGroupe getType(String s){
|
||||
switch(s){
|
||||
case("Tous les étudiants"):
|
||||
return TypeGroupe.ROOT;
|
||||
case("partition"):
|
||||
return TypeGroupe.PARTITION;
|
||||
case("libre"):
|
||||
return TypeGroupe.FREE;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,74 @@
|
||||
package fr.iutfbleau.projetIHM2022FI2.Graphic;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Objects;
|
||||
import java.sql.Connection;
|
||||
import org.mariadb.jdbc.*;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.TypeGroupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.PaintGroupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.MNP.GroupeNP;
|
||||
|
||||
public class Graphic{
|
||||
private PaintGroupe paint;
|
||||
private JFrame fenetre;
|
||||
LinkedList<Groupe> groupe;
|
||||
public Graphic(){
|
||||
this.fenetre=new JFrame("Gestion des étudiants");
|
||||
this.fenetre.setSize(1000, 720);
|
||||
this.fenetre.setLocation(200,200);
|
||||
this.fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.groupe=this.getGroupe();
|
||||
this.fenetre.setVisible(true);
|
||||
}
|
||||
|
||||
private LinkedList<Groupe> getGroupe(){
|
||||
LinkedList<Groupe> ll= new LinkedList<Groupe>();
|
||||
try{
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
try{
|
||||
Connection cnx = DriverManager.getConnection(
|
||||
"jdbc:mariadb://dwarves.iut-fbleau.fr/chaignea",
|
||||
"chaignea", "Chaigneauphpmyadmin");
|
||||
try{
|
||||
PreparedStatement pst = cnx.prepareStatement(
|
||||
"SELECT * FROM `Groupe` GROUP BY `id` ORDER BY `id` ASC;");
|
||||
try{
|
||||
ResultSet rs = pst.executeQuery();
|
||||
try{
|
||||
while(rs.next()){
|
||||
//valeur sentinel pour pas de groupe parent : -1
|
||||
if(rs.getInt(6)!=-1){
|
||||
ll.add(new GroupeNP(rs.getInt(0), rs.getString(1), rs.getInt(2), rs.getInt(3), TypeGroupe.getType(rs.getString(4)), ll.get(rs.getInt(6))));
|
||||
}else{
|
||||
ll.add(new GroupeNP(rs.getInt(0), rs.getString(1), rs.getInt(2), rs.getInt(3), TypeGroupe.getType(rs.getString(4)), null));
|
||||
}
|
||||
}
|
||||
}catch(SQLException e){
|
||||
System.out.println("erreur dans la prise de resultat");
|
||||
}
|
||||
rs.close();
|
||||
}catch(SQLException e){
|
||||
System.out.println("erreur dans le resultat");
|
||||
}
|
||||
pst.close();
|
||||
}catch(SQLException e){
|
||||
System.out.println("erreur dans la preparation");
|
||||
}
|
||||
cnx.close();
|
||||
}catch(SQLException e){
|
||||
System.out.println("Erreur dans la connexion!");
|
||||
}
|
||||
}catch(ClassNotFoundException e){
|
||||
System.out.println("pilote non disponible");
|
||||
}
|
||||
return ll;
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package fr.iutfbleau.projetIHM2022FI2.Graphic.View;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.ObservateurFenetre;
|
||||
|
||||
public class MaFenetre extends JFrame{
|
||||
private JPanel Left;
|
||||
private JPanel Right;
|
||||
private PaintGroupe paint;
|
||||
|
||||
public MaFenetre(){
|
||||
super();
|
||||
this.setSize(1000,720);
|
||||
this.setLocation(200,200);
|
||||
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||
this.addWindowListener(new ObservateurFenetre());
|
||||
this.setLayout(new GridLayout(1,2));
|
||||
|
||||
this.Left=new JPanel(new GridLayout(2,1));
|
||||
this.Right=new JPanel();
|
||||
|
||||
this.paint=new PaintGroupe();
|
||||
|
||||
this.Left.setBackground(Color.RED);
|
||||
this.Left.add(this.paint);
|
||||
this.add(this.Left);
|
||||
|
||||
this.Right.setBackground(Color.BLUE);
|
||||
this.add(this.Right);
|
||||
}
|
||||
|
||||
public void addGroupe(Groupe g){
|
||||
this.paint.addGroupe(g);
|
||||
}
|
||||
}
|
@ -26,10 +26,11 @@ public class PaintGroupe extends JComponent {
|
||||
int y=100;
|
||||
for(Groupe g: this.tabGroupe){
|
||||
secondPinceau.setColor(Color.BLACK);
|
||||
secondPinceau.setFont(new Font(Font.SANS_SERIF, Font.BOLD, this.getWidth()/10));
|
||||
secondPinceau.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 40));
|
||||
FontMetrics metrics = secondPinceau.getFontMetrics(secondPinceau.getFont());
|
||||
secondPinceau.drawString(g.getName().toUpperCase(), (this.getWidth()/2-metrics.stringWidth(g.getName().toUpperCase())/2), (y-metrics.getAscent()));
|
||||
g.getName();
|
||||
y+=100;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,22 @@ public class GroupeNP implements Groupe {
|
||||
this.sousGroupes=new LinkedHashSet<Groupe>();
|
||||
this.membresDuGroupe=new LinkedHashSet<Etudiant>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Nouveau groupe complet (pour le modèle persisant de donnée)
|
||||
*/
|
||||
public GroupeNP(int id, String name, int min, int max, TypeGroupe type, Groupe parent){
|
||||
Objects.requireNonNull(name,"On ne peut pas créer un groupe dont le nom est null");
|
||||
this.id=id;
|
||||
this.nextId++;
|
||||
this.name=name;
|
||||
this.min=min;
|
||||
this.max=max;
|
||||
this.type=type;
|
||||
this.pointPoint=parent;
|
||||
this.sousGroupes=new LinkedHashSet<Groupe>();
|
||||
this.membresDuGroupe=new LinkedHashSet<Etudiant>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Nouveau groupe vide de type FREE sans étudiants, sans sous-Groupe
|
||||
|
@ -1,9 +1,16 @@
|
||||
package fr.iutfbleau.projetIHM2022FI2.Test;
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.*;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.*;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.MaFenetre;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.Graphic;
|
||||
import fr.iutfbleau.projetIHM2022FI2.MNP.*;
|
||||
import java.util.*;
|
||||
import org.mariadb.jdbc.*;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Objects;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
public class TestTexteMNP{
|
||||
|
||||
@ -19,8 +26,8 @@ public class TestTexteMNP{
|
||||
|
||||
////System.out.println("Test de l\'API");
|
||||
//System.out.print("Création des étudiants");
|
||||
MaFenetre fenetre=new MaFenetre();
|
||||
fenetre.setVisible(true);
|
||||
Graphic ga=new Graphic();
|
||||
|
||||
Etudiant e1=new EtudiantNP("césar","lycurgus");
|
||||
Etudiant e2=new EtudiantNP("denis","uranus");
|
||||
Etudiant e3=new EtudiantNP("marcel","castor");
|
||||
@ -198,8 +205,6 @@ public class TestTexteMNP{
|
||||
Iterator<Groupe> itgr = racineDeLaPartition.getSousGroupes().iterator();
|
||||
Groupe A = itgr.next(); // premier sous-groupe
|
||||
Groupe B = itgr.next(); // second sous-groupe
|
||||
fenetre.addGroupe(B);
|
||||
System.out.println(B.getName());
|
||||
B = itgr.next(); // troisième sous-groupe
|
||||
Etudiant e = A.getEtudiants().iterator().next();// premier étudiant du premier sous-groupe.
|
||||
acf.createChangement(A,e,B);
|
||||
@ -235,6 +240,29 @@ public class TestTexteMNP{
|
||||
for (Changement cgt : acf.getAllChangements()){
|
||||
////System.out.println(cgt.monPrint());
|
||||
}
|
||||
try{
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
try{
|
||||
Connection cnx = DriverManager.getConnection(
|
||||
"jdbc:mariadb://dwarves.iut-fbleau.fr/chaignea",
|
||||
"chaignea", "Chaigneauphpmyadmin");
|
||||
try{
|
||||
PreparedStatement pst = cnx.prepareStatement(
|
||||
"INSERT INTO `Groupe` (`id`, `nom`, `min`, `max`, `Type`, `etudiant`, `id-parent`, `id-sous-groupe`) VALUES (;");
|
||||
for(Etudiant et: agf.getPromotion().getEtudiants()){
|
||||
|
||||
}
|
||||
pst.close();
|
||||
}catch(SQLException ef){
|
||||
System.out.println("erreur dans la preparation");
|
||||
}
|
||||
cnx.close();
|
||||
}catch(SQLException ef){
|
||||
System.out.println("Erreur dans la connexion!");
|
||||
}
|
||||
}catch(ClassNotFoundException ef){
|
||||
System.out.println("pilote non disponible");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user