2022-11-26 18:09:08 +01:00
|
|
|
package fr.iutfbleau.projetIHM2022FI2.ROOT.View;
|
2022-11-13 04:01:11 +01:00
|
|
|
|
|
|
|
import javax.swing.JButton;
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
import javax.swing.JPanel;
|
2022-11-14 22:57:17 +01:00
|
|
|
import javax.swing.JScrollPane;
|
|
|
|
import java.awt.Font;
|
2022-11-13 04:01:11 +01:00
|
|
|
import java.awt.GridLayout;
|
|
|
|
import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
|
2022-11-13 19:50:53 +01:00
|
|
|
import fr.iutfbleau.projetIHM2022FI2.API.TypeGroupe;
|
2022-11-26 18:09:08 +01:00
|
|
|
import fr.iutfbleau.projetIHM2022FI2.ROOT.Controller.ObservateurChangeGroupe;
|
|
|
|
import fr.iutfbleau.projetIHM2022FI2.ROOT.Controller.ObservateurModifGroupe;
|
|
|
|
import fr.iutfbleau.projetIHM2022FI2.ROOT.Model.Model;
|
2022-11-13 04:01:11 +01:00
|
|
|
|
|
|
|
|
2022-11-26 18:09:08 +01:00
|
|
|
public class FenetreGroupe{
|
2022-11-13 04:01:11 +01:00
|
|
|
private Groupe g;
|
2022-11-26 18:09:08 +01:00
|
|
|
private JPanel pan;
|
2022-11-14 12:26:45 +01:00
|
|
|
private Model m;
|
2022-11-13 04:01:11 +01:00
|
|
|
public FenetreGroupe(Groupe g, Model m){
|
2022-11-13 15:46:15 +01:00
|
|
|
super();
|
2022-11-13 04:01:11 +01:00
|
|
|
this.g=g;
|
2022-11-14 12:26:45 +01:00
|
|
|
this.m=m;
|
2022-11-26 18:09:08 +01:00
|
|
|
this.pan=new JPanel();
|
2022-11-14 12:26:45 +01:00
|
|
|
this.draw();
|
|
|
|
}
|
|
|
|
public Groupe getG() {
|
|
|
|
return this.g;
|
|
|
|
}
|
|
|
|
public void refresh(){
|
2022-11-26 18:09:08 +01:00
|
|
|
this.pan.removeAll();
|
2022-11-14 12:26:45 +01:00
|
|
|
this.draw();
|
2022-11-26 18:09:08 +01:00
|
|
|
this.pan.revalidate();
|
2022-11-14 12:26:45 +01:00
|
|
|
}
|
|
|
|
private void draw(){
|
2022-11-13 15:46:15 +01:00
|
|
|
if(g!=null){
|
2022-11-14 22:57:17 +01:00
|
|
|
int taille=5;
|
|
|
|
if(g.getType()==TypeGroupe.PARTITION || g.getType()==TypeGroupe.ROOT)
|
|
|
|
taille--;
|
|
|
|
if(g.getSousGroupes().size()>0)
|
2022-11-26 18:09:08 +01:00
|
|
|
this.pan.setLayout(new GridLayout(8, 1));
|
|
|
|
else{this.pan.setLayout(new GridLayout(7, 1));}
|
2022-11-14 22:57:17 +01:00
|
|
|
JPanel tache=new JPanel(new GridLayout(1,taille));
|
|
|
|
if(g.getType()!=TypeGroupe.ROOT){
|
2022-11-16 14:59:56 +01:00
|
|
|
JButton bout=new JButton(g.getPointPoint().getName());
|
2022-11-14 22:57:17 +01:00
|
|
|
bout.addActionListener(new ObservateurChangeGroupe(m, this.g.getPointPoint()));
|
|
|
|
tache.add(bout);
|
2022-11-13 15:46:15 +01:00
|
|
|
}
|
2022-11-14 22:57:17 +01:00
|
|
|
JButton renomer=new JButton("rename");
|
|
|
|
renomer.addActionListener(new ObservateurModifGroupe(m, g));
|
|
|
|
tache.add(renomer);
|
|
|
|
JButton ajouter=new JButton("add");
|
|
|
|
ajouter.addActionListener(new ObservateurModifGroupe(m, g));
|
|
|
|
tache.add(ajouter);
|
|
|
|
JButton supprimer=new JButton("supr");
|
2022-11-13 19:50:53 +01:00
|
|
|
supprimer.addActionListener(new ObservateurModifGroupe(m, g));
|
2022-11-14 22:57:17 +01:00
|
|
|
tache.add(supprimer);
|
2022-11-13 19:50:53 +01:00
|
|
|
if(g.getType()!=TypeGroupe.PARTITION){
|
2022-11-14 22:57:17 +01:00
|
|
|
JButton creer=new JButton("new Groupe");
|
2022-11-13 19:50:53 +01:00
|
|
|
creer.addActionListener(new ObservateurModifGroupe(m, g));
|
2022-11-14 22:57:17 +01:00
|
|
|
tache.add(creer);
|
2022-11-13 19:50:53 +01:00
|
|
|
}
|
2022-11-26 18:09:08 +01:00
|
|
|
this.pan.add(tache);
|
2022-11-14 22:57:17 +01:00
|
|
|
JLabel titre=new JLabel("Group : "+g.getName(), JLabel.CENTER);
|
|
|
|
titre.setFont(new Font(Font.SERIF, Font.BOLD, titre.getFont().getSize()+10));
|
2022-11-26 18:09:08 +01:00
|
|
|
this.pan.add(titre);
|
|
|
|
this.pan.add(new JLabel("id= "+String.valueOf(g.getId()),JLabel.CENTER));
|
|
|
|
this.pan.add(new JLabel("min= "+String.valueOf(g.getMin()),JLabel.CENTER));
|
|
|
|
this.pan.add(new JLabel("max= "+String.valueOf(g.getMax()),JLabel.CENTER));
|
|
|
|
this.pan.add(new JLabel(g.getType().name(), JLabel.CENTER));
|
|
|
|
this.pan.add(new JLabel("Sous groupe:",JLabel.CENTER));
|
2022-11-14 22:57:17 +01:00
|
|
|
if(g.getSousGroupes().size()>0){
|
|
|
|
JPanel sous=new JPanel(new GridLayout(g.getSousGroupes().size(), 1));
|
|
|
|
for(Groupe gr: g.getSousGroupes()){
|
|
|
|
JButton b=new JButton(gr.getName());
|
|
|
|
b.addActionListener(new ObservateurChangeGroupe(m, gr));
|
|
|
|
sous.add(b);
|
|
|
|
}
|
2022-11-26 18:09:08 +01:00
|
|
|
this.pan.add(new JScrollPane(sous));
|
2022-11-13 20:02:46 +01:00
|
|
|
}
|
2022-11-13 15:46:15 +01:00
|
|
|
}else{
|
2022-11-15 15:08:13 +01:00
|
|
|
JButton creer=new JButton("créer une promo");
|
|
|
|
creer.addActionListener(new ObservateurModifGroupe(m, g));
|
2022-11-26 18:09:08 +01:00
|
|
|
this.pan.add(creer);
|
2022-11-13 04:01:11 +01:00
|
|
|
}
|
|
|
|
}
|
2022-11-15 15:08:13 +01:00
|
|
|
|
|
|
|
public void setG(Groupe g) {
|
|
|
|
this.g = g;
|
|
|
|
}
|
2022-11-26 18:09:08 +01:00
|
|
|
|
|
|
|
public JPanel getPan() {
|
|
|
|
return pan;
|
|
|
|
}
|
2022-11-13 04:01:11 +01:00
|
|
|
}
|