Ajout de la vue du rappel par l'utilisateur + supression de 'papillon.sql
This commit is contained in:
@@ -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;
|
|
||||||
@@ -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("<html><h2>" + r.getTitre() + "</h2></html>");
|
||||||
|
JTextArea contenu = new JTextArea(r.getContenu());
|
||||||
|
contenu.setLineWrap(true);
|
||||||
|
contenu.setWrapStyleWord(true);
|
||||||
|
contenu.setEditable(false);
|
||||||
|
|
||||||
|
JLabel infos = new JLabel("<html><i>Thème : " + r.getTheme() + " <br>Rang : " + r.getRang() + "</i></html>");
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user