Bläddra i källkod

Merge branch 'master' of https://github.com/babolivier/burger-quizz

Brendan Abolivier 9 år sedan
förälder
incheckning
1d9ff864c0

Binär
java/rsc/burgerquizz.png Visa fil


+ 8
- 0
java/src/Bouton.java Visa fil

@@ -1,9 +1,17 @@
1 1
 import javax.swing.*;
2
+import javax.swing.border.Border;
3
+import java.awt.*;
2 4
 
3 5
 public class Bouton extends JButton
4 6
 {
5 7
 	public Bouton(String text, Icon icon)
6 8
 	{
7 9
 		super(text, icon);
10
+		setBackground(Color.WHITE);
11
+		setFocusPainted(false);
12
+		Border border = BorderFactory.createLineBorder(Color.BLACK, 2);
13
+		//http://stackoverflow.com/questions/10274750/java-swing-setting-margins-on-textarea-with-line-border
14
+		setBorder(BorderFactory.createCompoundBorder(border, BorderFactory.createEmptyBorder(5, 5, 5, 5)));
15
+		setIconTextGap(10);
8 16
 	}
9 17
 }

+ 106
- 5
java/src/InterfacePrincipale.java Visa fil

@@ -1,6 +1,8 @@
1 1
 import javax.swing.*;
2 2
 import java.awt.*;
3 3
 
4
+import static javax.swing.BoxLayout.*;
5
+
4 6
 public class InterfacePrincipale extends JFrame
5 7
 {
6 8
 	//Panel des catégories
@@ -24,16 +26,115 @@ public class InterfacePrincipale extends JFrame
24 26
 	private Bouton delQ;
25 27
 	private Bouton editQ;
26 28
 	private JComboBox comboQueRep;
27
-	private JList list;
29
+	private JList listQ;
30
+
31
+	//image pour les boutons
32
+	private ImageIcon plusImg;
33
+	private ImageIcon delImg;
34
+	private ImageIcon editImg;
28 35
 
29 36
 	public InterfacePrincipale()
30 37
 	{
38
+		setTitle("Administration base de données de l'aplication BurgerQuizz");
39
+		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
40
+
41
+		loadImgBouton();
42
+		createPanelCategories();
43
+		createPanelReponses();
44
+		createPanelQuestion();
45
+
46
+		getContentPane().add(new JLabel(new ImageIcon("rsc/burgerquizz.png")), BorderLayout.NORTH);
47
+		pack();
31 48
 		setLocationRelativeTo(null);
32
-		setTitle("Administration base de données de l'aplication BurgerQuizz ce titre est trop long");
33 49
 		setVisible(true);
34 50
 	}
35 51
 
36
-	private void createPanelCategories(){}
37
-	private void createPanelReponses(){}
38
-	private void createPanelQuestion(){}
52
+	private void loadImgBouton()
53
+	{
54
+		plusImg = new ImageIcon("rsc/plus.png");
55
+		delImg = new ImageIcon("rsc/del.png");
56
+		editImg = new ImageIcon("rsc/edit.png");
57
+	}
58
+
59
+	private void createPanelCategories()
60
+	{
61
+		panCategories = new JPanel();
62
+		addC = new Bouton("Ajouter une catégorie", plusImg);
63
+		delC = new Bouton("Supprimer la catégorie", delImg);
64
+		editC = new Bouton("Modifier la catégorie", editImg);
65
+
66
+		String tab[] = {"a","b","c","d","e","f"};
67
+		listC = new JList(tab);
68
+		JScrollPane sp = new JScrollPane(listC,
69
+				JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
70
+				JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
71
+
72
+
73
+		panCategories.setLayout(new BoxLayout(panCategories,Y_AXIS));
74
+		addC.setAlignmentX(CENTER_ALIGNMENT);
75
+		delC.setAlignmentX(CENTER_ALIGNMENT);
76
+		editC.setAlignmentX(CENTER_ALIGNMENT);
77
+
78
+		panCategories.add(addC);
79
+		panCategories.add(delC);
80
+		panCategories.add(sp);
81
+		panCategories.add(editC);
82
+		getContentPane().add(panCategories, BorderLayout.WEST);
83
+	}
84
+
85
+	private void createPanelReponses()
86
+	{
87
+		panReponses = new JPanel();
88
+		addR = new Bouton("Ajouter un jeu de réponses", plusImg);
89
+		delR = new Bouton("Supprimer le jeu de réponses", delImg);
90
+		editR = new Bouton("Modifier le jeu de réponse", editImg);
91
+		comboRepCat = new JComboBox();
92
+
93
+		String tab[] = {"a","b","c","d","e","f"};
94
+		listR = new JList(tab);
95
+		JScrollPane sp = new JScrollPane(listR,
96
+				JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
97
+				JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
98
+
99
+
100
+		panReponses.setLayout(new BoxLayout(panReponses,Y_AXIS));
101
+		addR.setAlignmentX(CENTER_ALIGNMENT);
102
+		delR.setAlignmentX(CENTER_ALIGNMENT);
103
+		editR.setAlignmentX(CENTER_ALIGNMENT);
104
+
105
+		panReponses.add(addR);
106
+		panReponses.add(delR);
107
+		panReponses.add(sp);
108
+		panReponses.add(editR);
109
+		panReponses.add(comboRepCat);
110
+		getContentPane().add(panReponses, BorderLayout.CENTER);
111
+	}
112
+
113
+	private void createPanelQuestion()
114
+	{
115
+		panQuestions = new JPanel();
116
+		addQ = new Bouton("Ajouter une question", plusImg);
117
+		delQ = new Bouton("Supprimer la question", delImg);
118
+		editQ = new Bouton("Modifier la question", editImg);
119
+		comboQueRep = new JComboBox();
120
+
121
+		String tab[] = {"a","b","c","d","e","f"};
122
+		listQ = new JList(tab);
123
+		JScrollPane sp = new JScrollPane(listQ,
124
+				JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
125
+				JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
126
+
127
+
128
+		panQuestions.setLayout(new BoxLayout(panQuestions,Y_AXIS));
129
+		addQ.setAlignmentX(CENTER_ALIGNMENT);
130
+		delQ.setAlignmentX(CENTER_ALIGNMENT);
131
+		editQ.setAlignmentX(CENTER_ALIGNMENT);
132
+
133
+		panQuestions.add(addQ);
134
+		panQuestions.add(delQ);
135
+		panQuestions.add(sp);
136
+		panQuestions.add(editQ);
137
+		panQuestions.add(comboQueRep);
138
+		getContentPane().add(panQuestions, BorderLayout.EAST);
139
+	}
39 140
 }

+ 1
- 1
web/model/class.connector.php Visa fil

@@ -11,7 +11,7 @@ class Connector {
11 11
 		$pass = "chabat";
12 12
 
13 13
 		$this->bdd = new PDO("mysql:host=$host;dbname=$db", $user, $pass);
14
-		$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
14
+		$this->bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
15 15
 	}
16 16
 
17 17
 	/*

+ 1
- 1
web/model/class.question.php Visa fil

@@ -8,7 +8,7 @@ class Question {
8 8
 
9 9
 	function __construct($intitule) {
10 10
 		try{
11
-			$this->intitule;
11
+			$this->intitule = $intitule;
12 12
 
13 13
 			$bdd = new Connector();
14 14
 

+ 7
- 6
web/model/class.questset.php Visa fil

@@ -8,16 +8,16 @@ class Questset {
8 8
 
9 9
 	function __construct($reponses) {
10 10
 		if(is_array($reponses)) {
11
-			$this->intitules = array();
12
-			$this->reponse1 = $reponse[0];
13
-			$this->reponse2 = $reponse[1];
11
+			$this->questions = array();
12
+			$this->reponse1 = $reponses[0];
13
+			$this->reponse2 = $reponses[1];
14 14
 			try {
15 15
 				$bdd = new Connector();
16 16
 
17 17
 				$options = array(
18 18
 					"where" => array(
19
-						array("reponse1", "=", $reponse1),
20
-						array("reponse2", "=", $reponse2)
19
+						array("reponse1", "=", $this->reponse1),
20
+						array("reponse2", "=", $this->reponse2)
21 21
 					)
22 22
 				);
23 23
 
@@ -27,10 +27,11 @@ class Questset {
27 27
 					array_push($this->questions, new Question($question['intitule']));
28 28
 				}
29 29
 
30
-				$this->categorie = $bdd->Select('*', 'reponses', $options)['nom_cat'];
30
+				$this->categorie = $bdd->Select('*', 'reponses', $options)[0]['nom_cat'];
31 31
 			} catch(Exception $e) {
32 32
 				throw $e;
33 33
 			}
34
+			echo "Initialized\n";
34 35
 		} else {
35 36
 			throw new Exception('Un tableau de réponses est attendu dans le constructeur.');
36 37
 		}

+ 1
- 1
web/model/classes.php Visa fil

@@ -2,5 +2,5 @@
2 2
 
3 3
 // Call this file from the root folder
4 4
 require_once('model/class.connector.php');
5
-require_once('model/class.questions.php');
5
+require_once('model/class.question.php');
6 6
 require_once('model/class.questset.php');