From 85da03783fdc493181158c6f4e976b4646be0d95 Mon Sep 17 00:00:00 2001 From: Clement Date: Fri, 20 Sep 2024 08:36:41 +0200 Subject: [PATCH 1/2] =?UTF-8?q?version=20ok=20avec=20les=203=20activit?= =?UTF-8?q?=C3=A9s=20int=C3=A9gr=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nbactions.xml | 55 ------------------- pom.xml | 9 ++- src/main/java/Calcul/Main.java | 5 -- .../com/mycompany/groupe_05/ContentFrame.java | 7 ++- src/main/java/gui/NewQuestion.java | 43 +++++++++++++++ 5 files changed, 52 insertions(+), 67 deletions(-) delete mode 100644 nbactions.xml create mode 100644 src/main/java/gui/NewQuestion.java diff --git a/nbactions.xml b/nbactions.xml deleted file mode 100644 index 15f91b5..0000000 --- a/nbactions.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - run - - jar - - - process-classes - org.codehaus.mojo:exec-maven-plugin:3.1.0:exec - - - - ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} - - Calcul.Main - java - - - - debug - - jar - - - process-classes - org.codehaus.mojo:exec-maven-plugin:3.1.0:exec - - - -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} - ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} - - Calcul.Main - java - true - - - - profile - - jar - - - process-classes - org.codehaus.mojo:exec-maven-plugin:3.1.0:exec - - - - ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} - Calcul.Main - java - - - - diff --git a/pom.xml b/pom.xml index 583b65a..ffdd7d6 100644 --- a/pom.xml +++ b/pom.xml @@ -1,9 +1,9 @@ 4.0.0 - activite - Activite_calcul - 01 + com.mycompany + Groupe_05 + 1.0-SNAPSHOT jar @@ -23,7 +23,6 @@ UTF-8 17 17 - activité_calcul.Activite_calcul + com.mycompany.groupe_05.Groupe_05 - Activite_calcul \ No newline at end of file diff --git a/src/main/java/Calcul/Main.java b/src/main/java/Calcul/Main.java index 62ab47b..bc69e69 100644 --- a/src/main/java/Calcul/Main.java +++ b/src/main/java/Calcul/Main.java @@ -5,9 +5,4 @@ package Calcul; * @author stag */ public class Main { - - public static void main(String[] args) { - Calcul test = new Calcul(); - } - } diff --git a/src/main/java/com/mycompany/groupe_05/ContentFrame.java b/src/main/java/com/mycompany/groupe_05/ContentFrame.java index 49d6fd7..31b1208 100644 --- a/src/main/java/com/mycompany/groupe_05/ContentFrame.java +++ b/src/main/java/com/mycompany/groupe_05/ContentFrame.java @@ -4,6 +4,7 @@ */ package com.mycompany.groupe_05; +import Calcul.Calcul; import beans.Drawing; import gui.MainMenu; import gui.QuestionsGui; @@ -14,6 +15,7 @@ import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; +import javax.swing.JOptionPane; import javax.swing.JPanel; /** @@ -27,7 +29,7 @@ public class ContentFrame extends JFrame { private final JPanel content; private final MainMenu menuPanel; private final Drawing drawingPane; - private final Container mathPane; + private final Calcul mathPane; private final QuestionsGui questionsPane; private final JMenuBar menuBar; @@ -35,7 +37,7 @@ public class ContentFrame extends JFrame { content = new JPanel(new BorderLayout()); drawingPane = new Drawing(); questionsPane = new QuestionsGui(); - mathPane = new JPanel(); + mathPane = new Calcul(); menuPanel = new MainMenu(); menuBar = new JMenuBar(); @@ -125,6 +127,7 @@ public class ContentFrame extends JFrame { content.add(menuPanel, BorderLayout.WEST); revalidate(); }); + helpI.addActionListener(ae -> JOptionPane.showMessageDialog(content, "Mdr gl")); exitI.addActionListener(ae -> System.exit(0)); } diff --git a/src/main/java/gui/NewQuestion.java b/src/main/java/gui/NewQuestion.java new file mode 100644 index 0000000..6740b8e --- /dev/null +++ b/src/main/java/gui/NewQuestion.java @@ -0,0 +1,43 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package gui; + +import java.awt.GridLayout; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextArea; + +/** + * + * @author stag + */ +public class NewQuestion { + + private JPanel contentPan, confirmPan; + private JLabel lvlLab, staLab, ansLab; + private JTextArea staTxt, ansTxt; + private JButton confirmBtn, cancelBtn; + private JComboBox lvlCb; + + public NewQuestion() { + initGui(); + initEvent(); + } + + private void initGui() { + contentPan = new JPanel(); + confirmPan = new JPanel(new GridLayout(0, 1)); + lvlLab = new JLabel("Niveau: "); + staLab = new JLabel("Question :"); + ansLab = new JLabel("Réponse :"); + } + + private void initEvent() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + +} -- GitLab From 5a5f662f1caf0113873e27c6eb920f6ffdcbf1ac Mon Sep 17 00:00:00 2001 From: Clement Date: Fri, 20 Sep 2024 09:15:26 +0200 Subject: [PATCH 2/2] page ajout question, fichier sql maj --- .../com/mycompany/groupe_05/ContentFrame.java | 4 ++ src/main/java/gui/NewQuestion.java | 50 ++++++++++++++++++- src/main/resources/db.sql | 7 ++- 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/mycompany/groupe_05/ContentFrame.java b/src/main/java/com/mycompany/groupe_05/ContentFrame.java index 31b1208..c1f4285 100644 --- a/src/main/java/com/mycompany/groupe_05/ContentFrame.java +++ b/src/main/java/com/mycompany/groupe_05/ContentFrame.java @@ -7,6 +7,7 @@ package com.mycompany.groupe_05; import Calcul.Calcul; import beans.Drawing; import gui.MainMenu; +import gui.NewQuestion; import gui.QuestionsGui; import java.awt.BorderLayout; import java.awt.Container; @@ -30,6 +31,7 @@ public class ContentFrame extends JFrame { private final MainMenu menuPanel; private final Drawing drawingPane; private final Calcul mathPane; + private final NewQuestion newQuest; private final QuestionsGui questionsPane; private final JMenuBar menuBar; @@ -38,6 +40,7 @@ public class ContentFrame extends JFrame { drawingPane = new Drawing(); questionsPane = new QuestionsGui(); mathPane = new Calcul(); + newQuest = new NewQuestion(); menuPanel = new MainMenu(); menuBar = new JMenuBar(); @@ -127,6 +130,7 @@ public class ContentFrame extends JFrame { content.add(menuPanel, BorderLayout.WEST); revalidate(); }); + newQuestI.addActionListener(ae -> switchActivities(newQuest)); helpI.addActionListener(ae -> JOptionPane.showMessageDialog(content, "Mdr gl")); exitI.addActionListener(ae -> System.exit(0)); diff --git a/src/main/java/gui/NewQuestion.java b/src/main/java/gui/NewQuestion.java index 6740b8e..3c7e070 100644 --- a/src/main/java/gui/NewQuestion.java +++ b/src/main/java/gui/NewQuestion.java @@ -4,10 +4,17 @@ */ package gui; +import beans.Question; +import dao.DaoQuestion; +import java.awt.Container; import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.util.ArrayList; +import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextArea; @@ -15,7 +22,7 @@ import javax.swing.JTextArea; * * @author stag */ -public class NewQuestion { +public class NewQuestion extends JPanel { private JPanel contentPan, confirmPan; private JLabel lvlLab, staLab, ansLab; @@ -34,10 +41,49 @@ public class NewQuestion { lvlLab = new JLabel("Niveau: "); staLab = new JLabel("Question :"); ansLab = new JLabel("Réponse :"); + staTxt = new JTextArea(5, 30); + ansTxt = new JTextArea(5, 30); + confirmBtn = new JButton("Valider"); + cancelBtn = new JButton("Annuler"); + ArrayList values = new ArrayList<>(); + values.add(1); + values.add(2); + lvlCb = new JComboBox<>(values.toArray(new Integer[0])); + + addToContent(lvlLab); + addToContent(lvlCb); + addToContent(staLab); + addToContent(staTxt); + addToContent(ansLab); + addToContent(ansTxt); + confirmPan.add(confirmBtn); + confirmPan.add(cancelBtn); + + addToContent(confirmPan); + contentPan.setLayout(new BoxLayout(contentPan, BoxLayout.Y_AXIS)); + add(contentPan); + } + + private void addToContent(Container c) { + contentPan.add(c); } private void initEvent() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + confirmBtn.addActionListener((ActionEvent ae) -> { + DaoQuestion daoq = new DaoQuestion(); + Question q = new Question(); + q.setLevel((int)lvlCb.getSelectedIndex()); + q.setStatement(staTxt.getText()); + q.setAnswer(ansTxt.getText()); + daoq.create(q); + JOptionPane.showMessageDialog(contentPan, "Nouvelle question ajoutée a la base de donnée"); + staTxt.setText(""); + ansTxt.setText(""); + }); + cancelBtn.addActionListener((ActionEvent ae) -> { + staTxt.setText(""); + ansTxt.setText(""); + }); } } diff --git a/src/main/resources/db.sql b/src/main/resources/db.sql index a7ad42b..938802d 100644 --- a/src/main/resources/db.sql +++ b/src/main/resources/db.sql @@ -3,7 +3,7 @@ -- https://www.phpmyadmin.net/ -- -- Hôte : localhost --- Généré le : jeu. 19 sep. 2024 à 12:14 +-- Généré le : ven. 20 sep. 2024 à 09:12 -- Version du serveur : 10.1.48-MariaDB-0+deb9u2 -- Version de PHP : 7.4.33 @@ -48,8 +48,7 @@ INSERT INTO `questions` (`id`, `level`, `statement`, `answer`) VALUES (6, 1, 'Combien y a-t-il de saisons dans une année?', 'Quatre'), (7, 1, 'Combien de côtés a un carré?', 'Quatre'), (8, 1, 'Quelle est la couleur de l\'herbe?', 'Verte'), -(13, 1, 'Quel est le meilleur formateur?', 'Herbert'), -(15, 1, 'Quel est le meilleur formateur?', 'Herbert'); +(9, 1, 'Quel est le meilleur formateur?', 'Herbert'); -- -- Index pour les tables déchargées @@ -69,7 +68,7 @@ ALTER TABLE `questions` -- AUTO_INCREMENT pour la table `questions` -- ALTER TABLE `questions` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -- GitLab