From 44ecaae3c51a14e106ba1b32b31a0e4fc460a5ad Mon Sep 17 00:00:00 2001 From: sehl Date: Sat, 25 Oct 2025 19:37:15 +0200 Subject: [PATCH] Ajout de la vue du rappel par l'utilisateur + supression de 'papillon.sql --- papillon.sql | 21 ----- src/fr/iutfbleau/papillon/FenetreRappel.java | 90 ++++++++++++++++++++ 2 files changed, 90 insertions(+), 21 deletions(-) delete mode 100644 papillon.sql create mode 100644 src/fr/iutfbleau/papillon/FenetreRappel.java diff --git a/papillon.sql b/papillon.sql deleted file mode 100644 index 1c96354..0000000 --- a/papillon.sql +++ /dev/null @@ -1,21 +0,0 @@ --- Table principale : les rappels -CREATE TABLE rappel ( - id INT AUTO_INCREMENT PRIMARY KEY, - titre VARCHAR(50) NOT NULL, - contenu TEXT, - theme VARCHAR(30), - rang INT -); - --- Table utilisateur -CREATE TABLE utilisateur ( - id INT AUTO_INCREMENT PRIMARY KEY, - nom VARCHAR(50), - cle_unique CHAR(36) UNIQUE -); - --- Ajouter la FK côté rappel -ALTER TABLE rappel - ADD COLUMN utilisateur_id INT, - ADD CONSTRAINT fk_rappel_user FOREIGN KEY (utilisateur_id) - REFERENCES utilisateur(id) ON DELETE CASCADE; diff --git a/src/fr/iutfbleau/papillon/FenetreRappel.java b/src/fr/iutfbleau/papillon/FenetreRappel.java new file mode 100644 index 0000000..e27b88c --- /dev/null +++ b/src/fr/iutfbleau/papillon/FenetreRappel.java @@ -0,0 +1,90 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public class FenetreRappel extends JFrame implements ActionListener{ + + private final JButton btnFermer = new JButton("Fermer"); + private final JButton btnModifier = new JButton("Modifier"); + private final Main main; + private Rappel rappel; + + public FenetreRappel(Rappel r, Main main) { + super("Rappel : " + r.getTitre()); + ImageIcon logo = new ImageIcon("logo.png"); + setIconImage(logo.getImage()); + + this.main = main; + this.rappel = r; + + setSize(350, 250); + setLocationRelativeTo(null); + setResizable(false); + setAlwaysOnTop(true); + setLocation(main.getLocation()); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JPanel panel = new JPanel(new GridBagLayout()); + panel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); + + JLabel titre = new JLabel("

" + r.getTitre() + "

"); + JTextArea contenu = new JTextArea(r.getContenu()); + contenu.setLineWrap(true); + contenu.setWrapStyleWord(true); + contenu.setEditable(false); + + JLabel infos = new JLabel("Thème : " + r.getTheme() + "
Rang : " + r.getRang() + "
"); + + GridBagConstraints c = new GridBagConstraints(); + c.insets = new Insets(4, 4, 4, 4); + c.fill = GridBagConstraints.HORIZONTAL; + + panel.add(titre, c); + c.gridy = 1; + c.weightx = 1.0; + c.weighty = 1.0; + c.gridwidth = 2; + c.fill = GridBagConstraints.BOTH; + panel.add(new JScrollPane(contenu), c); + c.gridx = 0; + c.gridy = 2; + c.weightx = 0; + c.weighty = 0; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.WEST; + panel.add(infos, c); + btnModifier.addActionListener(this); + btnFermer.addActionListener(this); + JPanel btnPanel = new JPanel(); + + c.gridx = 1; + c.gridy = 2; + c.weightx = 0; + c.weighty = 0; + c.anchor = GridBagConstraints.EAST; + + + btnPanel.add(btnModifier); + btnPanel.add(btnFermer); + panel.add(btnPanel, c); + + setContentPane(panel); + setVisible(true); + main.dispose(); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource() == btnFermer) { + Main reParent = new Main(); + reParent.setLocation(this.getLocation()); + reParent.setVisible(true); + this.dispose(); + } + else if (e.getSource() == btnModifier) { + FenetreModif f = new FenetreModif(main,rappel); + f.setVisible(true); + this.dispose(); + } + } +}