Kaynağa Gözat

++ gestion reponses

PCYoshi 9 yıl önce
ebeveyn
işleme
39c24a177e

+ 61
- 56
java/.idea/workspace.xml Dosyayı Görüntüle

@@ -7,11 +7,17 @@
7 7
   </component>
8 8
   <component name="ChangeListManager">
9 9
     <list default="true" id="a647cb6a-4230-4101-a652-d7cfd0c21e24" name="Default" comment="">
10
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/out/production/java/InterfacePrincipale$PanCategoriesListener.class" afterPath="$PROJECT_DIR$/out/production/java/InterfacePrincipale$PanCategoriesListener.class" />
10
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/out/production/java/ConnexionBDD.class" afterPath="$PROJECT_DIR$/out/production/java/ConnexionBDD.class" />
11
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/out/production/java/GestionCategories.class" afterPath="$PROJECT_DIR$/out/production/java/GestionCategories.class" />
12
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/out/production/java/GestionReponses.class" afterPath="$PROJECT_DIR$/out/production/java/GestionReponses.class" />
11 13
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/out/production/java/InterfacePrincipale$PanQuestionsListener.class" afterPath="$PROJECT_DIR$/out/production/java/InterfacePrincipale$PanQuestionsListener.class" />
12 14
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/out/production/java/InterfacePrincipale$PanReponsesListener.class" afterPath="$PROJECT_DIR$/out/production/java/InterfacePrincipale$PanReponsesListener.class" />
15
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/ConnexionBDD.java" afterPath="$PROJECT_DIR$/src/ConnexionBDD.java" />
16
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/GestionCategories.java" afterPath="$PROJECT_DIR$/src/GestionCategories.java" />
17
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/GestionReponses.java" afterPath="$PROJECT_DIR$/src/GestionReponses.java" />
13 18
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/InterfacePrincipale.java" afterPath="$PROJECT_DIR$/src/InterfacePrincipale.java" />
14 19
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/META-INF/MANIFEST.MF" afterPath="$PROJECT_DIR$/src/META-INF/MANIFEST.MF" />
20
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/NouvelleReponseDialog.java" afterPath="$PROJECT_DIR$/src/NouvelleReponseDialog.java" />
15 21
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
16 22
     </list>
17 23
     <ignored path="java.iws" />
@@ -34,11 +40,11 @@
34 40
   </component>
35 41
   <component name="FileEditorManager">
36 42
     <leaf>
37
-      <file leaf-file-name="InterfacePrincipale.java" pinned="false" current-in-tab="false">
43
+      <file leaf-file-name="InterfacePrincipale.java" pinned="false" current-in-tab="true">
38 44
         <entry file="file://$PROJECT_DIR$/src/InterfacePrincipale.java">
39 45
           <provider selected="true" editor-type-id="text-editor">
40
-            <state vertical-scroll-proportion="0.0">
41
-              <caret line="374" column="16" selection-start-line="374" selection-start-column="16" selection-end-line="374" selection-end-column="16" />
46
+            <state vertical-scroll-proportion="3.2033582">
47
+              <caret line="472" column="13" selection-start-line="472" selection-start-column="13" selection-end-line="472" selection-end-column="13" />
42 48
               <folding>
43 49
                 <element signature="imports" expanded="true" />
44 50
               </folding>
@@ -50,13 +56,15 @@
50 56
         <entry file="file://$PROJECT_DIR$/src/ConnexionBDD.java">
51 57
           <provider selected="true" editor-type-id="text-editor">
52 58
             <state vertical-scroll-proportion="0.0">
53
-              <caret line="69" column="44" selection-start-line="69" selection-start-column="44" selection-end-line="69" selection-end-column="44" />
59
+              <caret line="88" column="94" selection-start-line="88" selection-start-column="94" selection-end-line="88" selection-end-column="94" />
54 60
               <folding>
55 61
                 <element signature="imports" expanded="true" />
56 62
                 <element signature="e#1239#1240#0" expanded="true" />
57 63
                 <element signature="e#1294#1295#0" expanded="true" />
58 64
                 <element signature="e#1349#1350#0" expanded="true" />
59 65
                 <element signature="e#1404#1405#0" expanded="true" />
66
+                <element signature="e#1960#1961#0" expanded="true" />
67
+                <element signature="e#2017#2018#0" expanded="true" />
60 68
               </folding>
61 69
             </state>
62 70
           </provider>
@@ -66,7 +74,7 @@
66 74
         <entry file="file://$PROJECT_DIR$/src/GestionCategories.java">
67 75
           <provider selected="true" editor-type-id="text-editor">
68 76
             <state vertical-scroll-proportion="0.0">
69
-              <caret line="15" column="52" selection-start-line="15" selection-start-column="52" selection-end-line="15" selection-end-column="52" />
77
+              <caret line="82" column="11" selection-start-line="82" selection-start-column="11" selection-end-line="82" selection-end-column="11" />
70 78
               <folding>
71 79
                 <element signature="imports" expanded="true" />
72 80
                 <element signature="e#2067#2068#0" expanded="true" />
@@ -80,11 +88,11 @@
80 88
         <entry file="file://$PROJECT_DIR$/src/GestionReponses.java">
81 89
           <provider selected="true" editor-type-id="text-editor">
82 90
             <state vertical-scroll-proportion="0.0">
83
-              <caret line="28" column="30" selection-start-line="28" selection-start-column="30" selection-end-line="28" selection-end-column="30" />
91
+              <caret line="102" column="33" selection-start-line="102" selection-start-column="33" selection-end-line="102" selection-end-column="33" />
84 92
               <folding>
85 93
                 <element signature="imports" expanded="true" />
86
-                <element signature="e#996#997#0" expanded="true" />
87
-                <element signature="e#1022#1023#0" expanded="true" />
94
+                <element signature="e#2963#2964#0" expanded="true" />
95
+                <element signature="e#2989#2990#0" expanded="true" />
88 96
               </folding>
89 97
             </state>
90 98
           </provider>
@@ -111,7 +119,7 @@
111 119
           </provider>
112 120
         </entry>
113 121
       </file>
114
-      <file leaf-file-name="mcd.png" pinned="false" current-in-tab="true">
122
+      <file leaf-file-name="mcd.png" pinned="false" current-in-tab="false">
115 123
         <entry file="file://$PROJECT_DIR$/mcd.png">
116 124
           <provider selected="true" editor-type-id="images">
117 125
             <state />
@@ -150,9 +158,9 @@
150 158
         <option value="$PROJECT_DIR$/src/MainAdminBddBurgerQuizz.java" />
151 159
         <option value="$PROJECT_DIR$/src/GestionQuestions.java" />
152 160
         <option value="$PROJECT_DIR$/src/GestionCategories.java" />
153
-        <option value="$PROJECT_DIR$/src/NouvelleReponseDialog.java" />
154
-        <option value="$PROJECT_DIR$/src/ConnexionBDD.java" />
155 161
         <option value="$PROJECT_DIR$/src/GestionReponses.java" />
162
+        <option value="$PROJECT_DIR$/src/ConnexionBDD.java" />
163
+        <option value="$PROJECT_DIR$/src/NouvelleReponseDialog.java" />
156 164
         <option value="$PROJECT_DIR$/src/InterfacePrincipale.java" />
157 165
       </list>
158 166
     </option>
@@ -272,8 +280,8 @@
272 280
       <sortByType />
273 281
     </navigator>
274 282
     <panes>
275
-      <pane id="Scope" />
276 283
       <pane id="PackagesPane" />
284
+      <pane id="Scratches" />
277 285
       <pane id="ProjectPane">
278 286
         <subPane>
279 287
           <PATH>
@@ -308,7 +316,7 @@
308 316
           </PATH>
309 317
         </subPane>
310 318
       </pane>
311
-      <pane id="Scratches" />
319
+      <pane id="Scope" />
312 320
     </panes>
313 321
   </component>
314 322
   <component name="PropertiesComponent">
@@ -585,7 +593,13 @@
585 593
       <option name="project" value="LOCAL" />
586 594
       <updated>1432912975055</updated>
587 595
     </task>
588
-    <option name="localTasksCounter" value="15" />
596
+    <task id="LOCAL-00015" summary="correction de bug">
597
+      <created>1432923249468</created>
598
+      <option name="number" value="00015" />
599
+      <option name="project" value="LOCAL" />
600
+      <updated>1432923249468</updated>
601
+    </task>
602
+    <option name="localTasksCounter" value="16" />
589 603
     <servers />
590 604
   </component>
591 605
   <component name="TodoView">
@@ -599,7 +613,7 @@
599 613
   </component>
600 614
   <component name="ToolWindowManager">
601 615
     <frame x="-1" y="27" width="1368" height="712" extended-state="6" />
602
-    <editor active="false" />
616
+    <editor active="true" />
603 617
     <layout>
604 618
       <window_info id="Palette&#9;" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
605 619
       <window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
@@ -622,8 +636,8 @@
622 636
       <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
623 637
       <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
624 638
       <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
625
-      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
626 639
       <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
640
+      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
627 641
     </layout>
628 642
   </component>
629 643
   <component name="Vcs.Log.UiProperties">
@@ -651,19 +665,12 @@
651 665
     <MESSAGE value="java: gestion categorie operationelle" />
652 666
     <MESSAGE value="java: gestion categorie operationelle et ergonomique" />
653 667
     <MESSAGE value="++" />
654
-    <option name="LAST_COMMIT_MESSAGE" value="++" />
668
+    <MESSAGE value="correction de bug" />
669
+    <option name="LAST_COMMIT_MESSAGE" value="correction de bug" />
655 670
   </component>
656 671
   <component name="XDebuggerManager">
657 672
     <breakpoint-manager>
658
-      <breakpoints>
659
-        <line-breakpoint enabled="true" type="java-line">
660
-          <url>file://$PROJECT_DIR$/src/InterfacePrincipale.java</url>
661
-          <line>283</line>
662
-          <properties />
663
-          <option name="timeStamp" value="3" />
664
-        </line-breakpoint>
665
-      </breakpoints>
666
-      <option name="time" value="4" />
673
+      <option name="time" value="5" />
667 674
     </breakpoint-manager>
668 675
     <watches-manager />
669 676
   </component>
@@ -972,20 +979,6 @@
972 979
         </state>
973 980
       </provider>
974 981
     </entry>
975
-    <entry file="file://$PROJECT_DIR$/src/NouvelleReponseDialog.java">
976
-      <provider selected="true" editor-type-id="text-editor">
977
-        <state vertical-scroll-proportion="0.12686567">
978
-          <caret line="8" column="28" selection-start-line="8" selection-start-column="28" selection-end-line="8" selection-end-column="28" />
979
-          <folding>
980
-            <element signature="imports" expanded="true" />
981
-            <element signature="e#1535#1536#0" expanded="true" />
982
-            <element signature="e#1563#1564#0" expanded="true" />
983
-            <element signature="e#1591#1592#0" expanded="true" />
984
-            <element signature="e#1619#1620#0" expanded="true" />
985
-          </folding>
986
-        </state>
987
-      </provider>
988
-    </entry>
989 982
     <entry file="file://$PROJECT_DIR$/src/Reponses.java">
990 983
       <provider selected="true" editor-type-id="text-editor">
991 984
         <state vertical-scroll-proportion="0.0">
@@ -1005,10 +998,27 @@
1005 998
         </state>
1006 999
       </provider>
1007 1000
     </entry>
1001
+    <entry file="file://$PROJECT_DIR$/mcd.png">
1002
+      <provider selected="true" editor-type-id="images">
1003
+        <state />
1004
+      </provider>
1005
+    </entry>
1006
+    <entry file="file://$PROJECT_DIR$/src/GestionReponses.java">
1007
+      <provider selected="true" editor-type-id="text-editor">
1008
+        <state vertical-scroll-proportion="0.0">
1009
+          <caret line="102" column="33" selection-start-line="102" selection-start-column="33" selection-end-line="102" selection-end-column="33" />
1010
+          <folding>
1011
+            <element signature="imports" expanded="true" />
1012
+            <element signature="e#2963#2964#0" expanded="true" />
1013
+            <element signature="e#2989#2990#0" expanded="true" />
1014
+          </folding>
1015
+        </state>
1016
+      </provider>
1017
+    </entry>
1008 1018
     <entry file="file://$PROJECT_DIR$/src/GestionCategories.java">
1009 1019
       <provider selected="true" editor-type-id="text-editor">
1010 1020
         <state vertical-scroll-proportion="0.0">
1011
-          <caret line="15" column="52" selection-start-line="15" selection-start-column="52" selection-end-line="15" selection-end-column="52" />
1021
+          <caret line="82" column="11" selection-start-line="82" selection-start-column="11" selection-end-line="82" selection-end-column="11" />
1012 1022
           <folding>
1013 1023
             <element signature="imports" expanded="true" />
1014 1024
             <element signature="e#2067#2068#0" expanded="true" />
@@ -1020,44 +1030,39 @@
1020 1030
     <entry file="file://$PROJECT_DIR$/src/ConnexionBDD.java">
1021 1031
       <provider selected="true" editor-type-id="text-editor">
1022 1032
         <state vertical-scroll-proportion="0.0">
1023
-          <caret line="69" column="44" selection-start-line="69" selection-start-column="44" selection-end-line="69" selection-end-column="44" />
1033
+          <caret line="88" column="94" selection-start-line="88" selection-start-column="94" selection-end-line="88" selection-end-column="94" />
1024 1034
           <folding>
1025 1035
             <element signature="imports" expanded="true" />
1026 1036
             <element signature="e#1239#1240#0" expanded="true" />
1027 1037
             <element signature="e#1294#1295#0" expanded="true" />
1028 1038
             <element signature="e#1349#1350#0" expanded="true" />
1029 1039
             <element signature="e#1404#1405#0" expanded="true" />
1040
+            <element signature="e#1960#1961#0" expanded="true" />
1041
+            <element signature="e#2017#2018#0" expanded="true" />
1030 1042
           </folding>
1031 1043
         </state>
1032 1044
       </provider>
1033 1045
     </entry>
1034
-    <entry file="file://$PROJECT_DIR$/src/InterfacePrincipale.java">
1046
+    <entry file="file://$PROJECT_DIR$/src/NouvelleReponseDialog.java">
1035 1047
       <provider selected="true" editor-type-id="text-editor">
1036
-        <state vertical-scroll-proportion="0.0">
1037
-          <caret line="374" column="16" selection-start-line="374" selection-start-column="16" selection-end-line="374" selection-end-column="16" />
1048
+        <state vertical-scroll-proportion="-0.6325967">
1049
+          <caret line="30" column="12" selection-start-line="30" selection-start-column="12" selection-end-line="30" selection-end-column="12" />
1038 1050
           <folding>
1039 1051
             <element signature="imports" expanded="true" />
1040 1052
           </folding>
1041 1053
         </state>
1042 1054
       </provider>
1043 1055
     </entry>
1044
-    <entry file="file://$PROJECT_DIR$/src/GestionReponses.java">
1056
+    <entry file="file://$PROJECT_DIR$/src/InterfacePrincipale.java">
1045 1057
       <provider selected="true" editor-type-id="text-editor">
1046
-        <state vertical-scroll-proportion="0.0">
1047
-          <caret line="28" column="30" selection-start-line="28" selection-start-column="30" selection-end-line="28" selection-end-column="30" />
1058
+        <state vertical-scroll-proportion="3.2033582">
1059
+          <caret line="472" column="13" selection-start-line="472" selection-start-column="13" selection-end-line="472" selection-end-column="13" />
1048 1060
           <folding>
1049 1061
             <element signature="imports" expanded="true" />
1050
-            <element signature="e#996#997#0" expanded="true" />
1051
-            <element signature="e#1022#1023#0" expanded="true" />
1052 1062
           </folding>
1053 1063
         </state>
1054 1064
       </provider>
1055 1065
     </entry>
1056
-    <entry file="file://$PROJECT_DIR$/mcd.png">
1057
-      <provider selected="true" editor-type-id="images">
1058
-        <state />
1059
-      </provider>
1060
-    </entry>
1061 1066
   </component>
1062 1067
   <component name="masterDetails">
1063 1068
     <states>

BIN
java/out/production/java/ConnexionBDD.class Dosyayı Görüntüle


BIN
java/out/production/java/GestionCategories.class Dosyayı Görüntüle


BIN
java/out/production/java/GestionReponses.class Dosyayı Görüntüle


BIN
java/out/production/java/InterfacePrincipale$PanQuestionsListener.class Dosyayı Görüntüle


BIN
java/out/production/java/InterfacePrincipale$PanReponsesListener.class Dosyayı Görüntüle


+ 21
- 1
java/src/ConnexionBDD.java Dosyayı Görüntüle

@@ -51,7 +51,7 @@ public class ConnexionBDD
51 51
 
52 52
 	public void createCategorie(String categorieName)
53 53
 	{
54
-		gestionCategories.insertCategorie(categorieName);
54
+		gestionCategories.createCategorie(categorieName);
55 55
 	}
56 56
 
57 57
 	public void deleteCategorie(String categorieName)
@@ -70,4 +70,24 @@ public class ConnexionBDD
70 70
 		gestionReponses.readReponses(catName);
71 71
 		return gestionReponses.getListReponses();
72 72
 	}
73
+
74
+	public void createReponses(String nomCategorie, String reponse1, String reponse2)
75
+	{
76
+		gestionReponses.createReponses(nomCategorie, reponse1, reponse2);
77
+	}
78
+
79
+	public void deleteReponses(String reponse1, String reponse2)
80
+	{
81
+		gestionReponses.deleteReponses(reponse1, reponse2);
82
+	}
83
+
84
+	public void modifyReponsesReponses(String oldRep1, String oldRep2, String newRep1, String newRep2)
85
+	{
86
+		gestionReponses.updateReponsesReponses(oldRep1, oldRep2, newRep1, newRep2);
87
+	}
88
+
89
+	public void modifyReponsesCategorie(String reponse1, String reponses2, String newCategorie)
90
+	{
91
+		gestionReponses.updateReponsesCategorie(reponse1, reponses2, newCategorie);
92
+	}
73 93
 }

+ 1
- 1
java/src/GestionCategories.java Dosyayı Görüntüle

@@ -42,7 +42,7 @@ public class GestionCategories
42 42
 		}
43 43
 	}
44 44
 
45
-	public void insertCategorie(String categorieName)
45
+	public void createCategorie(String categorieName)
46 46
 	{
47 47
 		String rq ="INSERT INTO categorie(nom_cat)" +
48 48
 				" VALUES(?)";

+ 73
- 0
java/src/GestionReponses.java Dosyayı Görüntüle

@@ -20,6 +20,7 @@ public class GestionReponses
20 20
 		String rq = "SELECT *" +
21 21
 				" FROM reponses" +
22 22
 				" WHERE nom_cat = ?";
23
+
23 24
 		try
24 25
 		{
25 26
 			PreparedStatement preparedStatement = bdd.prepareStatement(rq);
@@ -43,6 +44,78 @@ public class GestionReponses
43 44
 		}
44 45
 	}
45 46
 
47
+	public void createReponses(String nomCategorie, String reponse1, String reponse2)
48
+	{
49
+		String rq = "INSERT INTO reponses(nom_cat,reponse1,reponse2)" +
50
+				" VALUES(?,?,?)";
51
+		try
52
+		{
53
+			PreparedStatement preparedStatement = bdd.prepareStatement(rq);
54
+			preparedStatement.setString(1, nomCategorie);
55
+			preparedStatement.setString(2, reponse1);
56
+			preparedStatement.setString(3, reponse2);
57
+			preparedStatement.executeUpdate();
58
+		} catch (SQLException e) {
59
+			e.printStackTrace();
60
+		}
61
+	}
62
+
63
+	public void deleteReponses(String rep1, String rep2)
64
+	{
65
+		String rq ="DELETE FROM reponses" +
66
+				" WHERE reponse1 = ? AND reponse2 = ?";
67
+		try
68
+		{
69
+			PreparedStatement preparedStatement = bdd.prepareStatement(rq);
70
+			preparedStatement.setString(1, rep1);
71
+			preparedStatement.setString(2, rep2);
72
+			preparedStatement.executeUpdate();
73
+		}
74
+		catch (SQLException e)
75
+		{
76
+			e.printStackTrace();
77
+		}
78
+	}
79
+
80
+	public void updateReponsesReponses(String oldRep1, String oldRep2, String newRep1, String newRep2)
81
+	{
82
+		String rq ="UPDATE reponses" +
83
+				" SET reponse1 = ?, reponse2 = ?" +
84
+				" WHERE reponse1 = ? AND reponse2 = ?";
85
+		try
86
+		{
87
+			PreparedStatement preparedStatement = bdd.prepareStatement(rq);
88
+			preparedStatement.setString(1, newRep1);
89
+			preparedStatement.setString(2, newRep2);
90
+			preparedStatement.setString(3, oldRep1);
91
+			preparedStatement.setString(4, oldRep2);
92
+			preparedStatement.executeUpdate();
93
+		}
94
+		catch (SQLException e)
95
+		{
96
+			e.printStackTrace();
97
+		}
98
+	}
99
+
100
+	public void updateReponsesCategorie(String rep1, String rep2, String newCategorie)
101
+	{
102
+		String rq ="UPDATE reponses" +
103
+				" SET nom_cat = ?" +
104
+				" WHERE reponse1 = ? AND reponse2 = ?";
105
+		try
106
+		{
107
+			PreparedStatement preparedStatement = bdd.prepareStatement(rq);
108
+			preparedStatement.setString(1, newCategorie);
109
+			preparedStatement.setString(2, rep1);
110
+			preparedStatement.setString(3, rep2);
111
+			preparedStatement.executeUpdate();
112
+		}
113
+		catch (SQLException e)
114
+		{
115
+			e.printStackTrace();
116
+		}
117
+	}
118
+
46 119
 	public ArrayList<Reponses> getListReponses()
47 120
 	{
48 121
 		return listReponses;

+ 122
- 24
java/src/InterfacePrincipale.java Dosyayı Görüntüle

@@ -1,15 +1,13 @@
1 1
 import javax.swing.*;
2
-import javax.swing.border.BevelBorder;
3 2
 import javax.swing.border.Border;
4 3
 import javax.swing.event.ListSelectionEvent;
5 4
 import javax.swing.event.ListSelectionListener;
6 5
 import java.awt.*;
7 6
 import java.awt.event.ActionEvent;
8 7
 import java.awt.event.ActionListener;
9
-import java.lang.reflect.Array;
10 8
 import java.util.Arrays;
9
+import java.util.Vector;
11 10
 
12
-import static java.lang.Thread.currentThread;
13 11
 import static java.lang.Thread.sleep;
14 12
 import static javax.swing.BoxLayout.*;
15 13
 
@@ -175,8 +173,8 @@ public class InterfacePrincipale extends JFrame
175 173
 		addR.setAlignmentX(CENTER_ALIGNMENT);
176 174
 		delR.setAlignmentX(CENTER_ALIGNMENT);
177 175
 		editR.setAlignmentX(CENTER_ALIGNMENT);
176
+		comboRepCat.setOpaque(false);
178 177
 
179
-		comboRepCat.setAlignmentX(CENTER_ALIGNMENT);
180 178
 		addR.setMaximumSize(new Dimension(300,34));
181 179
 		delR.setMaximumSize(new Dimension(300,34));
182 180
 		editR.setMaximumSize(new Dimension(300,34));
@@ -202,6 +200,8 @@ public class InterfacePrincipale extends JFrame
202 200
 		addR.addActionListener(prl);
203 201
 		delR.addActionListener(prl);
204 202
 		editR.addActionListener(prl);
203
+		listR.addListSelectionListener(prl);
204
+		comboRepCat.addActionListener(prl);
205 205
 	}
206 206
 
207 207
 	private void createPanelQuestion()
@@ -224,6 +224,8 @@ public class InterfacePrincipale extends JFrame
224 224
 		addQ.setAlignmentX(CENTER_ALIGNMENT);
225 225
 		delQ.setAlignmentX(CENTER_ALIGNMENT);
226 226
 		editQ.setAlignmentX(CENTER_ALIGNMENT);
227
+		comboQueRep.setOpaque(false);
228
+
227 229
 		addQ.setMaximumSize(new Dimension(208,34));
228 230
 		delQ.setMaximumSize(new Dimension(208,34));
229 231
 		editQ.setMaximumSize(new Dimension(208,34));
@@ -276,10 +278,40 @@ public class InterfacePrincipale extends JFrame
276 278
 		pack();
277 279
 	}
278 280
 
281
+	private void reSelectCategorie(String newCatName)
282
+	{
283
+		Object[] tabObject = bdd.getListeCategorie().toArray();
284
+		Categorie[] tabCategorie = Arrays.copyOf(tabObject, tabObject.length, Categorie[].class);
285
+		listC.setListData(tabCategorie);
286
+
287
+		for(int i=0; i<tabCategorie.length; i++)
288
+		{
289
+			if(tabCategorie[i].getNom().equals(newCatName))
290
+			{
291
+				listC.setSelectedValue(tabCategorie[i], true);
292
+				break;
293
+			}
294
+		}
295
+	}
296
+
297
+	private void reSelectReponses(String rep1, String rep2)
298
+	{
299
+		Object[] tabObject = bdd.getListeReponses(listC.getSelectedValue().toString()).toArray();
300
+		Reponses[] tabReponses = Arrays.copyOf(tabObject, tabObject.length, Reponses[].class);
301
+		listR.setListData(tabReponses);
302
+
303
+		for(int i=0; i<tabReponses.length; i++)
304
+		{
305
+			if(tabReponses[i].getReponse1().equals(rep1) && tabReponses[i].getReponse2().equals(rep2))
306
+			{
307
+				listR.setSelectedValue(tabReponses[i], true);
308
+				break;
309
+			}
310
+		}
311
+	}
279 312
 
280 313
 	private class PanCategoriesListener implements ActionListener, ListSelectionListener
281 314
 	{
282
-		private boolean b;
283 315
 		public void actionPerformed(ActionEvent e)
284 316
 		{
285 317
 			if(e.getSource() == addC)
@@ -303,6 +335,7 @@ public class InterfacePrincipale extends JFrame
303 335
 
304 336
 				bdd.createCategorie(catName);
305 337
 				listC.setListData(bdd.getListeCategorie().toArray());
338
+				reSelectCategorie(catName);
306 339
 			}
307 340
 			else if(e.getSource() == delC)
308 341
 			{
@@ -322,6 +355,7 @@ public class InterfacePrincipale extends JFrame
322 355
 				{
323 356
 					bdd.deleteCategorie(categorieName);
324 357
 					listC.setListData(bdd.getListeCategorie().toArray());
358
+					listR.setListData(new Vector(0));
325 359
 				}
326 360
 			}
327 361
 			else if(e.getSource() == editC)
@@ -354,19 +388,7 @@ public class InterfacePrincipale extends JFrame
354 388
 				}
355 389
 
356 390
 				bdd.renameCategorie(oldCatName, newCatName);
357
-
358
-				Object[] tabObject = bdd.getListeCategorie().toArray();
359
-				Categorie[] tabCategorie = Arrays.copyOf(tabObject, tabObject.length, Categorie[].class);
360
-				listC.setListData(tabCategorie);
361
-
362
-				for(int i=0; i<tabCategorie.length; i++)
363
-				{
364
-					if(tabCategorie[i].getNom().equals(newCatName))
365
-					{
366
-						listC.setSelectedValue(tabCategorie[i], true);
367
-						break;
368
-					}
369
-				}
391
+				reSelectCategorie(newCatName);
370 392
 			}
371 393
 		}
372 394
 
@@ -375,27 +397,97 @@ public class InterfacePrincipale extends JFrame
375 397
 			if(!listC.isSelectionEmpty())
376 398
 			{
377 399
 				listR.setListData(bdd.getListeReponses(listC.getSelectedValue().toString()).toArray());
400
+				comboRepCat.removeAllItems();
378 401
 			}
379 402
 		}
380 403
 	}
381 404
 
382
-	private class PanReponsesListener implements ActionListener
405
+	private class PanReponsesListener implements ActionListener, ListSelectionListener
383 406
 	{
384 407
 		public void actionPerformed(ActionEvent e)
385 408
 		{
409
+			if(listC.isSelectionEmpty())
410
+			{
411
+				statusText.setText("Veuillez selectioner une catégorie.");
412
+				return;
413
+			}
414
+
386 415
 			if(e.getSource() == addR)
387 416
 			{
388
-				statusText.setText("Création de réponses");
389
-				NouvelleReponseDialog n = new NouvelleReponseDialog("rr","r","uuu",null);
390
-				n.afficher();
417
+				NouvelleReponseDialog nrd = new NouvelleReponseDialog("Nouveau jeu de réponses","","",null);
418
+				if(nrd.afficher() == true)
419
+				{
420
+					String catName = listC.getSelectedValue().toString();
421
+					bdd.createReponses(catName, nrd.getRep1(), nrd.getRep2());
422
+					listR.setListData(bdd.getListeReponses(catName).toArray());
423
+					reSelectReponses(nrd.getRep1(), nrd.getRep2());
424
+				}
391 425
 			}
392 426
 			else if(e.getSource() == delR)
393 427
 			{
394
-				statusText.setText("Supression de réponses");
428
+				JOptionPane jop = new JOptionPane();
429
+
430
+				Reponses r = (Reponses) listR.getSelectedValue();
431
+
432
+				if(r == null)
433
+				{
434
+					statusText.setText("Veuiller d'abord selectionner un jeu de réponses.");
435
+					return;
436
+				}
437
+
438
+				String reponse1 = r.getReponse1();
439
+				String reponse2 = r.getReponse2();
440
+
441
+				if(jop.showConfirmDialog(null,"Voulez vous vraiment supprimer le jeu de réponses " + reponse1 + ", " + reponse2 + " ?\nCela supprimera aussi toutes les questions associé à cette catégorie.", "Supression de réponses", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION)
442
+				{
443
+					bdd.deleteReponses(reponse1, reponse2);
444
+					listR.setListData(bdd.getListeReponses(listC.getSelectedValue().toString()).toArray());
445
+					listQ.setListData(new Vector(0));
446
+				}
395 447
 			}
396 448
 			else if(e.getSource() == editR)
397 449
 			{
398
-				statusText.setText("Modification de réponses");
450
+				Reponses r = (Reponses) listR.getSelectedValue();
451
+
452
+				if(r == null)
453
+				{
454
+					statusText.setText("Veuiller d'abord selectionner un jeu de réponses.");
455
+					return;
456
+				}
457
+
458
+				String reponse1 = r.getReponse1();
459
+				String reponse2 = r.getReponse2();
460
+
461
+				NouvelleReponseDialog nrd = new NouvelleReponseDialog("Modification jeu de réponses", reponse1, reponse2, null);
462
+				if(nrd.afficher() == true)
463
+				{
464
+					String catName = listC.getSelectedValue().toString();
465
+					bdd.modifyReponsesReponses(reponse1, reponse2, nrd.getRep1(), nrd.getRep2());
466
+					listR.setListData(bdd.getListeReponses(catName).toArray());
467
+					reSelectReponses(nrd.getRep1(), nrd.getRep2());
468
+				}
469
+			}
470
+			else if(e.getSource() == comboRepCat)
471
+			{
472
+				System.out.println("éLOL");
473
+			}
474
+		}
475
+
476
+		public void valueChanged(ListSelectionEvent listSelectionEvent)
477
+		{
478
+			ListModel model = listC.getModel();
479
+			comboRepCat.removeAllItems();
480
+
481
+			String cat = listC.getSelectedValue().toString();
482
+
483
+			for(int i=0; i < model.getSize(); i++)
484
+			{
485
+				Categorie c =  (Categorie)model.getElementAt(i);
486
+				comboRepCat.addItem(c.getNom());
487
+				if(cat.equals(c.getNom()))
488
+				{
489
+					comboRepCat.setSelectedItem(c.getNom());
490
+				}
399 491
 			}
400 492
 		}
401 493
 	}
@@ -404,6 +496,12 @@ public class InterfacePrincipale extends JFrame
404 496
 	{
405 497
 		public void actionPerformed(ActionEvent e)
406 498
 		{
499
+			if(listR.isSelectionEmpty())
500
+			{
501
+				statusText.setText("Veuillez selectioner une catégorie.");
502
+				return;
503
+			}
504
+
407 505
 			if(e.getSource() == addQ)
408 506
 			{
409 507
 				statusText.setText("Création de question");

+ 9
- 2
java/src/NouvelleReponseDialog.java Dosyayı Görüntüle

@@ -27,6 +27,9 @@ public class NouvelleReponseDialog extends JDialog implements ActionListener
27 27
 		rep1 = new JTextField(defRep1,15);
28 28
 		rep2 = new JTextField(defRep2,15);
29 29
 
30
+		rep1.setBackground(Color.WHITE);
31
+		rep2.setBackground(Color.WHITE);
32
+
30 33
 		ok = new JButton("OK");
31 34
 		annuler = new JButton("Annuler");
32 35
 		ok.addActionListener(this);
@@ -56,12 +59,16 @@ public class NouvelleReponseDialog extends JDialog implements ActionListener
56 59
 		if(e.getSource() == annuler)
57 60
 		{
58 61
 			mofidEffectues = false;
62
+			setVisible(false);
59 63
 		}
60 64
 		else if(e.getSource() == ok) {
65
+			if(rep1.getText().isEmpty() || rep2.getText().isEmpty())
66
+			{
67
+				return;
68
+			}
61 69
 			mofidEffectues = true;
70
+			setVisible(false);
62 71
 		}
63
-
64
-		setVisible(false);
65 72
 	}
66 73
 
67 74
 	public String getRep2() {