diff --git a/src/fr/iutfbleau/papillon/BtnAjouter.java b/src/fr/iutfbleau/papillon/BtnAjouter.java index ca2ea46..f06805b 100644 --- a/src/fr/iutfbleau/papillon/BtnAjouter.java +++ b/src/fr/iutfbleau/papillon/BtnAjouter.java @@ -5,9 +5,9 @@ import java.awt.*; import java.awt.event.*; public class BtnAjouter extends JButton implements ActionListener{ + private Main main; - public BtnAjouter(Main main){ super("Ajouter"); this.main = main; @@ -18,8 +18,6 @@ public class BtnAjouter extends JButton implements ActionListener{ } - - public void actionPerformed(ActionEvent e){ if(e.getSource()==this){ FenetreAjout f = new FenetreAjout(main); diff --git a/src/fr/iutfbleau/papillon/CouleurList.java b/src/fr/iutfbleau/papillon/CouleurList.java index d63114b..5999737 100644 --- a/src/fr/iutfbleau/papillon/CouleurList.java +++ b/src/fr/iutfbleau/papillon/CouleurList.java @@ -1,5 +1,4 @@ import javax.swing.*; -import javax.swing.Icon; import java.awt.*; /** @@ -12,11 +11,11 @@ public class CouleurList extends DefaultListCellRenderer { /** renvoie la couleur correspondant au nom affiché dans le menu */ public static Color couleurDe(String nom) { switch (nom) { - case "Bleu": return Color.CYAN; // ou Color.BLUE si tu veux un bleu plus foncé + case "Bleu": return Color.CYAN; case "Rouge": return Color.RED; case "Vert": return Color.GREEN; case "Jaune": return Color.YELLOW; - case "Gris": return Color.LIGHT_GRAY; + case "Rose": return Color.PINK; default: return Color.WHITE; } } diff --git a/src/fr/iutfbleau/papillon/Crud.java b/src/fr/iutfbleau/papillon/Crud.java index b69dd9e..4949e15 100644 --- a/src/fr/iutfbleau/papillon/Crud.java +++ b/src/fr/iutfbleau/papillon/Crud.java @@ -1,21 +1,16 @@ // package fr.iutfbleau.papillon; import java.util.ArrayList; -import java.util.List; import javax.swing.*; -import java.awt.*; -import java.awt.event.*; public class Crud extends ArrayList{ - private Main main; - private BtnAjouter btnAjt; private BtnSupprimer btnSpr; private BtnModifier btnMdf; public Crud(Main main){ - this.main = main; + btnAjt = new BtnAjouter(main); btnSpr = new BtnSupprimer(main); btnMdf = new BtnModifier(main); @@ -25,5 +20,4 @@ add(btnMdf); } - } \ No newline at end of file diff --git a/src/fr/iutfbleau/papillon/GestionAjout.java b/src/fr/iutfbleau/papillon/GestionAjout.java index 0ce17a2..edef2e5 100644 --- a/src/fr/iutfbleau/papillon/GestionAjout.java +++ b/src/fr/iutfbleau/papillon/GestionAjout.java @@ -1,8 +1,6 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; -import java.util.*; -import java.util.List; import java.util.ArrayList; public class GestionAjout extends ArrayList implements ActionListener{ @@ -65,7 +63,7 @@ public class GestionAjout extends ArrayList implements ActionListener{ }else{ try{ - g.ajouter(new Rappel(titre,contenu,cTheme,Nrang)); + g.ajouter(titre, contenu, cTheme, Nrang); } catch (Exception ex) { ex.printStackTrace(); // affiche l'erreur dans le terminal } diff --git a/src/fr/iutfbleau/papillon/GestionModif.java b/src/fr/iutfbleau/papillon/GestionModif.java index f0d2119..7134547 100644 --- a/src/fr/iutfbleau/papillon/GestionModif.java +++ b/src/fr/iutfbleau/papillon/GestionModif.java @@ -1,8 +1,5 @@ import javax.swing.*; -import java.awt.*; import java.awt.event.*; -import java.util.*; -import java.util.List; import java.util.ArrayList; public class GestionModif extends ArrayList implements ActionListener{ @@ -16,7 +13,7 @@ public class GestionModif extends ArrayList implements ActionListener{ private final JComboBox comboTheme; private Rappel rappel; - private GestionRappel ges = new GestionRappel(); + private final GestionRappel ges = new GestionRappel(); private final Main parent; private final JFrame f; diff --git a/src/fr/iutfbleau/papillon/PanelRappel.java b/src/fr/iutfbleau/papillon/PanelRappel.java index c597dfa..dc28efb 100644 --- a/src/fr/iutfbleau/papillon/PanelRappel.java +++ b/src/fr/iutfbleau/papillon/PanelRappel.java @@ -1,51 +1,62 @@ -// package fr.iutfbleau.papillon; - import javax.swing.*; import java.awt.*; import java.awt.event.*; -public class PanelRappel extends JPanel implements ActionListener, MouseListener{ +public class PanelRappel extends JPanel implements ActionListener, MouseListener { + private boolean estSelectionne = false; - private final JLabel lbtitre; - private final JLabel lbcontenu; + private JLabel lbtitre; + private JLabel lbcontenu; + private Rappel r; - private final Rappel r; - - private final JPopupMenu menu; - private final JMenuItem itemOuvrir; + private JPopupMenu menu; + private JMenuItem itemOuvrir; + private Main main; private static CouleurList couleur = new CouleurList(); - private boolean estSelectionne = false; + public PanelRappel(Rappel r, Main main) { + super(new BorderLayout(2, 0)); + this.main = main; + createPanel(r); + } -public PanelRappel(Rappel r){ - super(new BorderLayout(2,0)); - this.r = r; - lbtitre = new JLabel("["+r.getRang()+"] "+r.getTitre()); - lbcontenu = new JLabel(r.getContenu()); + public PanelRappel(Rappel r) { + super(new BorderLayout(2, 0)); + createPanel(r); + } - this.setPreferredSize(new Dimension(70, 50)); - this.setBackground(couleur.couleurDe(r.getTheme())); - this.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 2)); + public void createPanel(Rappel r){ + this.r = r; - setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - c.anchor = GridBagConstraints.NORTHWEST; + // --- Titre et contenu raccourci --- + lbtitre = new JLabel("[" + r.getRang() + "] " + r.getTitre()); + lbcontenu = new JLabel( + "" + (r.getContenu().length() > 40 ? r.getContenu().substring(0, 40) + "..." : r.getContenu()) + "" + ); - // --- Position du titre (en haut) -c.gridx = 0; -c.gridy = 0; -c.weightx = 1; // prend l'espace -c.fill = GridBagConstraints.NONE; -add(lbtitre, c); + // --- Apparence de base --- + this.setPreferredSize(new Dimension(70, 50)); + this.setBackground(couleur.couleurDe(r.getTheme())); + this.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 2)); + setLayout(new GridBagLayout()); + GridBagConstraints c = new GridBagConstraints(); + c.anchor = GridBagConstraints.NORTHWEST; - // --- Position du contenu (en dessous) -c.gridx = 0; -c.gridy = 1; -c.weightx = 1; -c.fill = GridBagConstraints.NONE; -add(lbcontenu, c); + // --- Position du titre --- + c.gridx = 0; + c.gridy = 0; + c.weightx = 1; + c.fill = GridBagConstraints.NONE; + add(lbtitre, c); + + // --- Position du contenu --- + c.gridx = 0; + c.gridy = 1; + c.weightx = 1; + c.fill = GridBagConstraints.NONE; + add(lbcontenu, c); // --- Menu contextuel (clic droit) --- menu = new JPopupMenu(); @@ -53,54 +64,43 @@ add(lbcontenu, c); itemOuvrir.addActionListener(this); menu.add(itemOuvrir); - // a améliorer + // --- Activation des clics --- addMouseListener(this); -} + } -public boolean getSelection(){ - return estSelectionne; -} + // === GETTERS === + public boolean getSelection() { + return estSelectionne; + } -public int getId(){ - return r.getId(); -} + public int getId() { + return r.getId(); + } -public Rappel getRappel(){ - return r; -} -// ACTIONS + public Rappel getRappel() { + return r; + } + + // === ACTIONS === @Override public void actionPerformed(ActionEvent e) { Object src = e.getSource(); if (src == itemOuvrir) { - JOptionPane.showMessageDialog( - this, - "Ouverture du rappel : " + lbtitre.getText(), - "Ouvrir", - JOptionPane.INFORMATION_MESSAGE - ); + // ouverture complète depuis le menu clic droit + new FenetreRappel(r, main); } } + // === GESTION DES CLICS SOURIS === @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { menu.show(e.getComponent(), e.getX(), e.getY()); - }else { - // clic gauche = sélection + } else { + // clic gauche = sélection / désélection estSelectionne = !estSelectionne; - - if (estSelectionne) { - setBackground(Color.LIGHT_GRAY); - setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); - } else { - setBackground(couleur.couleurDe(r.getTheme())); - setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1)); - - } - - repaint(); + majApparence(); } } @@ -108,21 +108,36 @@ public Rappel getRappel(){ public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { menu.show(e.getComponent(), e.getX(), e.getY()); - } } - - @Override public void mouseClicked(MouseEvent e) {} - @Override public void mouseEntered(MouseEvent e) { - setBackground(Color.LIGHT_GRAY); - setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); - } - @Override public void mouseExited(MouseEvent e) { - if(!estSelectionne){ - setBackground(couleur.couleurDe(r.getTheme())); - setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1)); - } + @Override + public void mouseClicked(MouseEvent e) { + // === Double clic pour ouvrir la vue complète === + if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) { + new FenetreRappel(r, main); + + } } -} \ No newline at end of file + @Override + public void mouseEntered(MouseEvent e) { + setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); + } + + @Override + public void mouseExited(MouseEvent e) { + setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1)); + + } + + private void majApparence() { + if (estSelectionne) { + setBackground(Color.LIGHT_GRAY); + setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); + } else { + setBackground(couleur.couleurDe(r.getTheme())); + } + + } +} diff --git a/src/fr/iutfbleau/papillon/logo.png b/src/fr/iutfbleau/papillon/logo.png new file mode 100644 index 0000000..60280aa Binary files /dev/null and b/src/fr/iutfbleau/papillon/logo.png differ