Mise a jour des 3 boutons(ajout,modifier,supprimer)
This commit is contained in:
@@ -1,30 +1,33 @@
|
||||
// package fr.iutfbleau.papillon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class BtnAjouter extends JButton implements ActionListener{
|
||||
private GestionRappel ges;
|
||||
private Main main;
|
||||
|
||||
|
||||
public BtnAjouter(Main main){
|
||||
super("Ajouter");
|
||||
this.main = main;
|
||||
setPreferredSize(new Dimension(120,25));
|
||||
|
||||
setFocusPainted(false);
|
||||
addActionListener(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent e){
|
||||
if(e.getSource()==this){
|
||||
|
||||
FenetreAjout f = new FenetreAjout(main);
|
||||
// cacher la fenetre actuelle et montrer celle d ajout
|
||||
f.setLocation(main.getLocation()); // récupère la position actuelle de Main,place FenetreAjout au même endroit
|
||||
f.setLocation(main.getLocation());
|
||||
f.setVisible(true);
|
||||
main.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,28 +1,29 @@
|
||||
// package fr.iutfbleau.papillon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BtnModifier extends JButton implements ActionListener {
|
||||
|
||||
private GestionRappel ges;
|
||||
private Rappel rappel;
|
||||
private Main main;
|
||||
private final Main main;
|
||||
|
||||
public BtnModifier(Main main) {
|
||||
super("Modifier");
|
||||
this.main = main;
|
||||
setPreferredSize(new Dimension(120, 25));
|
||||
addActionListener(this);
|
||||
|
||||
setFocusPainted(false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e){
|
||||
|
||||
if (e.getSource() == this) {
|
||||
ges = new GestionRappel();
|
||||
|
||||
int count = 0;
|
||||
List<PanelRappel> listRpl = new ArrayList<>();
|
||||
PanelRappel pr;
|
||||
@@ -41,10 +42,9 @@ public class BtnModifier extends JButton implements ActionListener{
|
||||
return;
|
||||
}
|
||||
if(count==1){
|
||||
|
||||
FenetreModif f = new FenetreModif(main,rappel,rappel.getTitre(),rappel.getContenu());
|
||||
FenetreModif f = new FenetreModif(main,rappel);
|
||||
f.setVisible(true);
|
||||
main.setVisible(false);
|
||||
main.dispose();
|
||||
}
|
||||
|
||||
if(count>1){
|
||||
@@ -54,4 +54,8 @@ public class BtnModifier extends JButton implements ActionListener{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class BtnSupprimer extends JButton implements ActionListener{
|
||||
|
||||
private GestionRappel ges;
|
||||
private Main main;
|
||||
|
||||
@@ -15,6 +16,8 @@ public class BtnSupprimer extends JButton implements ActionListener{
|
||||
this.main = main;
|
||||
setPreferredSize(new Dimension(120,25));
|
||||
addActionListener(this);
|
||||
|
||||
setFocusPainted(false);
|
||||
}
|
||||
public void actionPerformed(ActionEvent e){
|
||||
|
||||
@@ -30,6 +33,23 @@ public class BtnSupprimer extends JButton implements ActionListener{
|
||||
pr = listRpl.get(i);
|
||||
if(pr.getSelection()==true){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if(count==0){
|
||||
JOptionPane.showMessageDialog(main, "Sélectionnez les rappels que vous souhaiter supprimer !");
|
||||
}else{
|
||||
int choix = JOptionPane.showConfirmDialog(
|
||||
main,
|
||||
"Êtes-vous sûr de vouloir supprimer ce(s) rappel(s) ?",
|
||||
"Confirmation",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.WARNING_MESSAGE
|
||||
);
|
||||
|
||||
if (choix == JOptionPane.YES_OPTION) {
|
||||
for(int i = 0; i<listRpl.size();i++){
|
||||
pr = listRpl.get(i);
|
||||
if(pr.getSelection()==true){
|
||||
try{
|
||||
ges.supprimerParId(pr.getId());
|
||||
} catch (Exception ex) {
|
||||
@@ -37,12 +57,11 @@ public class BtnSupprimer extends JButton implements ActionListener{
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count==0){
|
||||
JOptionPane.showMessageDialog(main, "Sélectionnez les rappels que vous souhaiter supprimer !");
|
||||
}else{
|
||||
JOptionPane.showMessageDialog(main, "Les rappels on bien étaient supprimé.");
|
||||
new Main().setVisible(true);
|
||||
main.dispose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user