IteraciĆ³n 3(VersiĆ³n sin idiomas)
[ISBets21MAUBRY] / eclipse-workspace / ISBets21MAUBRY / src / main / java / gui / MainAdminGUI.java
1 package gui;
2
3 import java.awt.Color;
4 import java.awt.Font;
5 import java.awt.event.ActionEvent;
6 import java.awt.event.ActionListener;
7 import java.awt.event.MouseAdapter;
8 import java.awt.event.MouseEvent;
9 import java.awt.event.WindowAdapter;
10 import java.awt.event.WindowEvent;
11 import java.util.Locale;
12 import java.util.Vector;
13
14 /**
15  * @author Software Engineering teachers
16  */
17 import javax.swing.ButtonGroup;
18 import javax.swing.ImageIcon;
19 import javax.swing.JButton;
20 import javax.swing.JFrame;
21 import javax.swing.JLabel;
22 import javax.swing.JPanel;
23 import javax.swing.JRadioButton;
24 import javax.swing.SwingConstants;
25
26 import businessLogic.BLFacade;
27 import domain.AdminUser;
28 import domain.Event;
29
30 public class MainAdminGUI extends JFrame {
31
32         private static final long serialVersionUID = 1L;
33
34         private JPanel jContentPane = null;
35         private JButton jButtonCreateQuestion = null;
36         private JButton jButtonCreateEvent = null;
37
38         private static BLFacade appFacadeInterface = LoginGUI.getBusinessLogic();
39
40         protected JLabel jLabelSelectOption;
41         private JRadioButton rdbtnNewRadioButton;
42         private JRadioButton rdbtnNewRadioButton_1;
43         private JRadioButton rdbtnNewRadioButton_2;
44         private JPanel panel;
45         private final ButtonGroup buttonGroup = new ButtonGroup();
46         private JButton jButtonCreateForecast;
47         private JButton buttonAdmin;
48         private AdminUser userlog = null;
49         private JButton buttonCloseEvent;
50         private JButton jButtonQueryQueries;
51
52         private JLabel lblFotoCrearEvento;
53         private JLabel lblFotoCrearQuestion;
54         private JLabel lblFotoCrearForecast;
55         private JLabel lblFotoSeeQuestions;
56         private JLabel lblFotoAdministration;
57         private JLabel lblFotoCloseEvent;
58
59         /**
60          * This is the default constructor
61          */
62         public MainAdminGUI(AdminUser au) {
63                 super();
64
65                 userlog = au;
66
67                 addWindowListener(new WindowAdapter() {
68                         @Override
69                         public void windowClosing(WindowEvent e) {
70                                 try {
71                                         // if (ConfigXML.getInstance().isBusinessLogicLocal()) facade.close();
72                                 } catch (Exception e1) {
73                                         // TODO Auto-generated catch block
74                                         System.out.println(
75                                                         "Error: " + e1.toString() + " , probably problems with Business Logic or Database");
76                                 }
77                                 // System.exit(1);
78                         }
79                 });
80
81                 initialize();
82                 // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
83         }
84
85         /**
86          * This method initializes this
87          * 
88          * @return void
89          */
90         private void initialize() {
91                 // this.setSize(271, 295);
92                 setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
93
94                 this.setSize(630, 421);
95                 this.setContentPane(getJContentPane());
96 //              this.setTitle(ResourceBundle.getBundle("Etiquetas").getString("MainTitle"));
97                 this.setTitle("MainTitle");
98
99         }
100
101         /**
102          * This method initializes jContentPane
103          * 
104          * @return javax.swing.JPanel
105          */
106         private JPanel getJContentPane() {
107                 if (jContentPane == null) {
108                         jContentPane = new JPanel();
109                         jContentPane.setBackground(Color.WHITE);
110                         jContentPane.setLayout(null);
111                         jContentPane.add(getLblNewLabel());
112                         jContentPane.add(getBoton3());
113                         jContentPane.add(getBoton2());
114                         jContentPane.add(getJButtonCreateForecast());
115                         jContentPane.add(getPanel());
116                         jContentPane.add(getJButtonAdministration());
117                         jContentPane.add(getbuttonCloseEvent());
118
119                         jButtonQueryQueries = new JButton();
120                         jButtonQueryQueries.addMouseListener(new MouseAdapter() {
121                                 @Override
122                                 public void mouseEntered(MouseEvent e) {
123                                         lblFotoSeeQuestions.setVisible(true);
124                                 }
125
126                                 @Override
127                                 public void mouseExited(MouseEvent e) {
128                                         lblFotoSeeQuestions.setVisible(false);
129
130                                 }
131                         });
132                         jButtonQueryQueries.addActionListener(new ActionListener() {
133                                 @Override
134                                 public void actionPerformed(ActionEvent e) {
135                                         JFrame a = new FindQuestionsGUI(userlog);
136                                         a.setAlwaysOnTop(true);
137                                         a.setVisible(true);
138                                         dispose();
139                                 }
140                         });
141 //                      jButtonQueryQueries.setText(
142 //                                      ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.jButtonQueryQuestions.text")); //$NON-NLS-1$ //$NON-NLS-2$
143                         jButtonQueryQueries.setText("QueryQuestions"); //$NON-NLS-1$ //$NON-NLS-2$
144                         jButtonQueryQueries.setBounds(34, 191, 267, 38);
145                         jContentPane.add(jButtonQueryQueries);
146
147                         ImageIcon icon = new ImageIcon("imagenes/fotoCrearEvento.png");
148                         lblFotoCrearEvento = new JLabel(icon);
149                         lblFotoCrearEvento.setBounds(320, 108, 265, 192);
150                         lblFotoCrearEvento.setVisible(false);
151                         jContentPane.add(lblFotoCrearEvento);
152
153                         ImageIcon icon2 = new ImageIcon("imagenes/fotoCrearQuestion.png");
154                         lblFotoCrearQuestion = new JLabel(icon2);
155                         lblFotoCrearQuestion.setBounds(320, 108, 265, 192);
156                         lblFotoCrearQuestion.setVisible(false);
157                         jContentPane.add(lblFotoCrearQuestion);
158
159                         ImageIcon icon3 = new ImageIcon("imagenes/fotoCrearForecast.png");
160                         lblFotoCrearForecast = new JLabel(icon3);
161                         lblFotoCrearForecast.setBounds(320, 108, 265, 192);
162                         lblFotoCrearForecast.setVisible(false);
163                         jContentPane.add(lblFotoCrearForecast);
164
165                         ImageIcon icon4 = new ImageIcon("imagenes/fotoSeeQuestions.png");
166                         lblFotoSeeQuestions = new JLabel(icon4);
167                         lblFotoSeeQuestions.setBounds(320, 108, 265, 192);
168                         lblFotoSeeQuestions.setVisible(false);
169                         jContentPane.add(lblFotoSeeQuestions);
170
171                         ImageIcon icon5 = new ImageIcon("imagenes/fotoAdministration.png");
172                         lblFotoAdministration = new JLabel(icon5);
173                         lblFotoAdministration.setBounds(320, 108, 265, 192);
174                         lblFotoAdministration.setVisible(false);
175                         jContentPane.add(lblFotoAdministration);
176
177                         ImageIcon icon6 = new ImageIcon("imagenes/fotoCloseEvent.png");
178                         lblFotoCloseEvent = new JLabel(icon6);
179                         lblFotoCloseEvent.setBounds(320, 108, 265, 192);
180                         lblFotoCloseEvent.setVisible(false);
181                         jContentPane.add(lblFotoCloseEvent);
182
183                 }
184                 return jContentPane;
185         }
186
187         /**
188          * This method initializes boton1
189          * 
190          * @return javax.swing.JButton
191          */
192         private JButton getBoton2() {
193                 if (jButtonCreateQuestion == null) {
194                         jButtonCreateQuestion = new JButton();
195                         jButtonCreateQuestion.addMouseListener(new MouseAdapter() {
196                                 @Override
197                                 public void mouseEntered(MouseEvent e) {
198                                         lblFotoCrearQuestion.setVisible(true);
199                                 }
200
201                                 @Override
202                                 public void mouseExited(MouseEvent e) {
203                                         lblFotoCrearQuestion.setVisible(false);
204
205                                 }
206                         });
207                         jButtonCreateQuestion.setBounds(34, 108, 267, 38);
208 //                      jButtonCreateQuestion.setText(ResourceBundle.getBundle("Etiquetas").getString("CreateQuestion"));
209                         jButtonCreateQuestion.setText("CreateQuestion");
210                         jButtonCreateQuestion.addActionListener(new java.awt.event.ActionListener() {
211                                 @Override
212                                 public void actionPerformed(java.awt.event.ActionEvent e) {
213                                         JFrame a = new CreateQuestionGUI(new Vector<Event>(), userlog);
214                                         a.setAlwaysOnTop(true);
215                                         a.setVisible(true);
216                                         close();
217                                 }
218                         });
219                 }
220                 return jButtonCreateQuestion;
221         }
222
223         /**
224          * This method initializes boton2
225          * 
226          * @return javax.swing.JButton
227          */
228         private JButton getBoton3() {
229                 if (jButtonCreateEvent == null) {
230                         jButtonCreateEvent = new JButton();
231                         jButtonCreateEvent.addMouseListener(new MouseAdapter() {
232                                 @Override
233                                 public void mouseEntered(MouseEvent arg0) {
234                                         lblFotoCrearEvento.setVisible(true);
235                                 }
236
237                                 @Override
238                                 public void mouseExited(MouseEvent e) {
239                                         lblFotoCrearEvento.setVisible(false);
240
241                                 }
242                         });
243                         jButtonCreateEvent.setBounds(34, 67, 267, 38);
244 //                      jButtonCreateEvent.setText(ResourceBundle.getBundle("Etiquetas").getString("CreateEvent"));
245                         jButtonCreateEvent.setText("CreateEvent");
246                         jButtonCreateEvent.addActionListener(new java.awt.event.ActionListener() {
247                                 @Override
248                                 public void actionPerformed(java.awt.event.ActionEvent e) {
249                                         JFrame a = new CreateEventGUI(userlog);
250                                         a.setAlwaysOnTop(true);
251                                         a.setVisible(true);
252                                         a.setVisible(true);
253                                         dispose();
254                                 }
255                         });
256                 }
257                 return jButtonCreateEvent;
258         }
259
260         private JLabel getLblNewLabel() {
261                 if (jLabelSelectOption == null) {
262 //                      jLabelSelectOption = new JLabel(ResourceBundle.getBundle("Etiquetas").getString("SelectOption"));
263                         jLabelSelectOption = new JLabel("SelectOption");
264                         jLabelSelectOption.setBounds(39, 8, 262, 76);
265                         jLabelSelectOption.setFont(new Font("Tahoma", Font.BOLD, 13));
266                         jLabelSelectOption.setForeground(Color.BLACK);
267                         jLabelSelectOption.setHorizontalAlignment(SwingConstants.CENTER);
268
269                 }
270                 return jLabelSelectOption;
271         }
272
273         private JRadioButton getRdbtnNewRadioButton() {
274                 if (rdbtnNewRadioButton == null) {
275                         rdbtnNewRadioButton = new JRadioButton("English");
276                         rdbtnNewRadioButton.setBackground(Color.WHITE);
277                         rdbtnNewRadioButton.addActionListener(new ActionListener() {
278                                 @Override
279                                 public void actionPerformed(ActionEvent e) {
280                                         Locale.setDefault(new Locale("en"));
281                                         System.out.println("Locale: " + Locale.getDefault());
282                                         redibujar();
283                                 }
284                         });
285                         buttonGroup.add(rdbtnNewRadioButton);
286                 }
287                 return rdbtnNewRadioButton;
288         }
289
290         private JRadioButton getRdbtnNewRadioButton_1() {
291                 if (rdbtnNewRadioButton_1 == null) {
292                         rdbtnNewRadioButton_1 = new JRadioButton("Euskara");
293                         rdbtnNewRadioButton_1.setBackground(Color.WHITE);
294                         rdbtnNewRadioButton_1.addActionListener(new ActionListener() {
295                                 @Override
296                                 public void actionPerformed(ActionEvent arg0) {
297                                         Locale.setDefault(new Locale("eus"));
298                                         System.out.println("Locale: " + Locale.getDefault());
299                                         redibujar();
300                                 }
301                         });
302                         buttonGroup.add(rdbtnNewRadioButton_1);
303                 }
304                 return rdbtnNewRadioButton_1;
305         }
306
307         private JRadioButton getRdbtnNewRadioButton_2() {
308                 if (rdbtnNewRadioButton_2 == null) {
309                         rdbtnNewRadioButton_2 = new JRadioButton("Castellano");
310                         rdbtnNewRadioButton_2.setBackground(Color.WHITE);
311                         rdbtnNewRadioButton_2.addActionListener(new ActionListener() {
312                                 @Override
313                                 public void actionPerformed(ActionEvent e) {
314                                         Locale.setDefault(new Locale("es"));
315                                         System.out.println("Locale: " + Locale.getDefault());
316                                         redibujar();
317                                 }
318                         });
319                         buttonGroup.add(rdbtnNewRadioButton_2);
320                 }
321                 return rdbtnNewRadioButton_2;
322         }
323
324         private JPanel getPanel() {
325                 if (panel == null) {
326                         panel = new JPanel();
327                         panel.setBackground(Color.WHITE);
328                         panel.setBounds(38, 318, 262, 38);
329                         panel.add(getRdbtnNewRadioButton_1());
330                         panel.add(getRdbtnNewRadioButton_2());
331                         panel.add(getRdbtnNewRadioButton());
332                 }
333                 return panel;
334         }
335
336         private void redibujar() {
337 //              jLabelSelectOption.setText(ResourceBundle.getBundle("Etiquetas").getString("SelectOption"));
338 //              jButtonCreateEvent.setText(ResourceBundle.getBundle("Etiquetas").getString("CreateEvent"));
339 //              jButtonCreateQuestion.setText(ResourceBundle.getBundle("Etiquetas").getString("CreateQuestion"));
340 //              jButtonCreateForecast
341 //                              .setText(ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.jButtonCreateForecast.text"));
342 //              jButtonQueryQueries
343 //                              .setText(ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.jButtonQueryQuestions.text"));
344 //              buttonAdmin.setText(ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.buttonAdmin.text"));
345 //              buttonCloseEvent.setText(ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.buttonCloseEvent.text"));
346 //
347 //              this.setTitle(ResourceBundle.getBundle("Etiquetas").getString("MainTitle"));
348                 jLabelSelectOption.setText("SelectOption");
349                 jButtonCreateEvent.setText("CreateEvent");
350                 jButtonCreateQuestion.setText("CreateQuestion");
351                 jButtonCreateForecast.setText("CreateForecast");
352                 jButtonQueryQueries.setText("QueryQuestions");
353                 buttonAdmin.setText("SeeStoredData");
354                 buttonCloseEvent.setText("CloseEvent");
355
356                 this.setTitle("MainTitle");
357         }
358
359         public void close() {
360                 this.setVisible(false);
361         }
362
363         private JButton getJButtonCreateForecast() {
364                 if (jButtonCreateForecast == null) {
365                         jButtonCreateForecast = new JButton();
366                         jButtonCreateForecast.addMouseListener(new MouseAdapter() {
367                                 @Override
368                                 public void mouseEntered(MouseEvent e) {
369                                         lblFotoCrearForecast.setVisible(true);
370                                 }
371
372                                 @Override
373                                 public void mouseExited(MouseEvent e) {
374                                         lblFotoCrearForecast.setVisible(false);
375
376                                 }
377                         });
378                         jButtonCreateForecast.addActionListener(new ActionListener() {
379                                 @Override
380                                 public void actionPerformed(ActionEvent e) {
381                                         JFrame a = new CreateForecastGUI(userlog);
382                                         a.setAlwaysOnTop(true);
383                                         a.setVisible(true);
384                                         close();
385                                 }
386                         });
387                         jButtonCreateForecast.setBounds(34, 150, 267, 38);
388 //                      jButtonCreateForecast.setText(
389 //                                      ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.jButtonCreateForecast.text")); //$NON-NLS-1$ //$NON-NLS-2$
390                         jButtonCreateForecast.setText("CreateForecast"); //$NON-NLS-1$ //$NON-NLS-2$
391                 }
392                 return jButtonCreateForecast;
393         }
394
395         private JButton getJButtonAdministration() {
396                 if (buttonAdmin == null) {
397                         buttonAdmin = new JButton();
398                         buttonAdmin.addMouseListener(new MouseAdapter() {
399                                 @Override
400                                 public void mouseEntered(MouseEvent e) {
401                                         lblFotoAdministration.setVisible(true);
402                                 }
403
404                                 @Override
405                                 public void mouseExited(MouseEvent e) {
406                                         lblFotoAdministration.setVisible(false);
407
408                                 }
409                         });
410                         buttonAdmin.addActionListener(new ActionListener() {
411                                 @Override
412                                 public void actionPerformed(ActionEvent e) {
413                                         JFrame a = new AdministrationGUI(userlog);
414                                         a.setAlwaysOnTop(true);
415                                         a.setVisible(true);
416                                         close();
417                                 }
418                         });
419                         buttonAdmin.setBounds(34, 232, 267, 38);
420 //                      buttonAdmin.setText(ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.buttonAdmin.text")); //$NON-NLS-1$ //$NON-NLS-2$
421                         buttonAdmin.setText("buttonAdmin"); //$NON-NLS-1$ //$NON-NLS-2$
422                 }
423                 return buttonAdmin;
424         }
425
426         private JButton getbuttonCloseEvent() {
427                 if (buttonCloseEvent == null) {
428                         buttonCloseEvent = new JButton();
429                         buttonCloseEvent.addMouseListener(new MouseAdapter() {
430                                 @Override
431                                 public void mouseEntered(MouseEvent e) {
432                                         lblFotoCloseEvent.setVisible(true);
433                                 }
434
435                                 @Override
436                                 public void mouseExited(MouseEvent e) {
437                                         lblFotoCloseEvent.setVisible(false);
438
439                                 }
440                         });
441                         buttonCloseEvent.addActionListener(new ActionListener() {
442                                 @Override
443                                 public void actionPerformed(ActionEvent e) {
444
445                                         JFrame a = new CloseEventGUI(userlog);
446                                         a.setAlwaysOnTop(true);
447                                         a.setVisible(true);
448                                         dispose();
449                                 }
450                         });
451                         buttonCloseEvent.setBounds(34, 273, 267, 38);
452 //                      buttonCloseEvent
453 //                                      .setText(ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.buttonCloseEvent.text")); //$NON-NLS-1$ //$NON-NLS-2$
454                         buttonCloseEvent.setText("CloseEvent"); //$NON-NLS-1$ //$NON-NLS-2$
455                         jContentPane.add(buttonCloseEvent);
456
457                 }
458                 return buttonCloseEvent;
459         }
460 } // @jve:decl-index=0:visual-constraint="0,0"