• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

marcopaglio / BookingApp / #253

17 Sep 2023 12:53PM UTC coverage: 88.482% (-10.8%) from 99.286%
#253

push

marcopaglio
Runnable mutation testing on GUI tests

991 of 1120 relevant lines covered (88.48%)

0.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.27
/booking-ui-module/src/main/java/io/github/marcopaglio/booking/view/swing/BookingSwingView.java
1
package io.github.marcopaglio.booking.view.swing;
2

3
import java.awt.EventQueue;
4
import java.util.List;
5

6
import javax.swing.JFrame;
7
import javax.swing.JPanel;
8
import javax.swing.border.EmptyBorder;
9

10
import io.github.marcopaglio.booking.annotation.Generated;
11
import io.github.marcopaglio.booking.model.Client;
12
import io.github.marcopaglio.booking.model.Reservation;
13
import io.github.marcopaglio.booking.presenter.BookingPresenter;
14
import io.github.marcopaglio.booking.view.BookingView;
15
import java.awt.GridBagLayout;
16
import java.awt.GridBagConstraints;
17
import javax.swing.JTextField;
18
import javax.swing.JLabel;
19
import java.awt.Insets;
20

21
import javax.swing.DefaultListModel;
22
import javax.swing.JButton;
23
import javax.swing.JList;
24
import javax.swing.JScrollPane;
25
import java.awt.event.KeyAdapter;
26
import java.awt.event.KeyEvent;
27
import javax.swing.SwingConstants;
28
import javax.swing.ListSelectionModel;
29
import javax.swing.event.ListSelectionListener;
30
import javax.swing.event.ListSelectionEvent;
31
import java.awt.event.ActionListener;
32
import java.awt.event.ActionEvent;
33

34
public class BookingSwingView extends JFrame implements BookingView {
35
        /**
36
         * 
37
         */
38
        private static final long serialVersionUID = 1L;
39

40
        private BookingPresenter bookingPresenter;
41

42
        private JPanel contentPane;
43
        private JTextField nameFormTxt;
44
        private JButton addClientBtn;
45
        private JLabel dateLbl;
46
        private JTextField yearFormTxt;
47
        private JButton addReservationBtn;
48
        private JLabel lastNameLbl;
49
        private JTextField surnameFormTxt;
50
        private JButton renameBtn;
51
        private JButton rescheduleBtn;
52
        private JLabel formErrorMsgLbl;
53
        private JButton removeClientBtn;
54
        private JButton removeReservationBtn;
55
        private JLabel clientErrorMsgLbl;
56
        private JLabel reservationErrorMsgLbl;
57
        private JScrollPane clientScrollPane;
58
        private JList<Client> clientList;
59
        private DefaultListModel<Client> clientListModel;
60
        private JScrollPane reservationScrollPane;
61
        private JList<Reservation> reservationList;
62
        private DefaultListModel<Reservation> reservationListModel;
63
        private JLabel dash1Lbl;
64
        private JTextField dayFormTxt;
65
        private JLabel dash2Lbl;
66
        private JTextField monthFormTxt;
67

68
        // EVENT HANDLERS
69

70
        private final KeyAdapter clientBtnEnabler = new KeyAdapter() {
1✔
71
                @Override
72
                public void keyReleased(KeyEvent e) {
73
                        addClientBtn.setEnabled(
×
74
                                !nameFormTxt.getText().trim().isEmpty() &&
×
75
                                !surnameFormTxt.getText().trim().isEmpty()
×
76
                        );
77
                        
78
                        renameBtn.setEnabled(
×
79
                                !nameFormTxt.getText().trim().isEmpty() &&
×
80
                                !surnameFormTxt.getText().trim().isEmpty() &&
×
81
                                clientList.getSelectedIndex() != -1
×
82
                        );
83
                }
×
84
        };
85

86
        private final KeyAdapter reservationBtnEnabler = new KeyAdapter() {
1✔
87
                @Override
88
                public void keyReleased(KeyEvent e) {
89
                        addReservationBtn.setEnabled(
×
90
                                !yearFormTxt.getText().trim().isEmpty() &&
×
91
                                !monthFormTxt.getText().trim().isEmpty() &&
×
92
                                !dayFormTxt.getText().trim().isEmpty() &&
×
93
                                clientList.getSelectedIndex() != -1
×
94
                        );
95
                        
96
                        rescheduleBtn.setEnabled(
×
97
                                !yearFormTxt.getText().trim().isEmpty() &&
×
98
                                !monthFormTxt.getText().trim().isEmpty() &&
×
99
                                !dayFormTxt.getText().trim().isEmpty() &&
×
100
                                reservationList.getSelectedIndex() != -1
×
101
                        );
102
                }
×
103
        };
104

105
        private final ListSelectionListener clientListListener = new ListSelectionListener() {
1✔
106
                @Override
107
                public void valueChanged(ListSelectionEvent e) {
108
                        renameBtn.setEnabled(
×
109
                                !nameFormTxt.getText().trim().isEmpty() &&
×
110
                                !surnameFormTxt.getText().trim().isEmpty() &&
×
111
                                clientList.getSelectedIndex() != -1
×
112
                        );
113
                        
114
                        removeClientBtn.setEnabled(clientList.getSelectedIndex() != -1);
×
115
                        
116
                        addReservationBtn.setEnabled(
×
117
                                !yearFormTxt.getText().trim().isEmpty() &&
×
118
                                !monthFormTxt.getText().trim().isEmpty() &&
×
119
                                !dayFormTxt.getText().trim().isEmpty() &&
×
120
                                clientList.getSelectedIndex() != -1
×
121
                        );
122
                }
×
123
        };
124

125
        private final ListSelectionListener reservationListListener = new ListSelectionListener() {
1✔
126
                @Override
127
                public void valueChanged(ListSelectionEvent e) {
128
                        rescheduleBtn.setEnabled(
×
129
                                !yearFormTxt.getText().trim().isEmpty() &&
×
130
                                !monthFormTxt.getText().trim().isEmpty() &&
×
131
                                !dayFormTxt.getText().trim().isEmpty() &&
×
132
                                reservationList.getSelectedIndex() != -1
×
133
                        );
134
                        
135
                        removeReservationBtn.setEnabled(reservationList.getSelectedIndex() != -1);
×
136
                }
×
137
        };
138

139
        // METHODS
140

141
        public void setBookingPresenter(BookingPresenter bookingPresenter) {
142
                this.bookingPresenter = bookingPresenter;
1✔
143
        }
1✔
144

145
        /**
146
         * @return the addClientBtn
147
         */
148
        @Generated
149
        JButton getAddClientBtn() {
150
                return addClientBtn;
151
        }
152

153
        /**
154
         * @return the rescheduleBtn
155
         */
156
        @Generated
157
        JButton getRescheduleBtn() {
158
                return rescheduleBtn;
159
        }
160

161
        /**
162
         * @return the removeReservationBtn
163
         */
164
        @Generated
165
        JButton getRemoveReservationBtn() {
166
                return removeReservationBtn;
167
        }
168

169
        /**
170
         * @return the addReservationBtn
171
         */
172
        @Generated
173
        JButton getAddReservationBtn() {
174
                return addReservationBtn;
175
        }
176

177
        /**
178
         * @return the renameBtn
179
         */
180
        @Generated
181
        JButton getRenameBtn() {
182
                return renameBtn;
183
        }
184

185
        /**
186
         * @return the removeClientBtn
187
         */
188
        @Generated
189
        JButton getRemoveClientBtn() {
190
                return removeClientBtn;
191
        }
192

193
        /**
194
         * @return the clientListModel
195
         */
196
        @Generated
197
        DefaultListModel<Client> getClientListModel() {
198
                return clientListModel;
199
        }
200

201
        /**
202
         * @return the reservationListModel
203
         */
204
        @Generated
205
        DefaultListModel<Reservation> getReservationListModel() {
206
                return reservationListModel;
207
        }
208

209
        /**
210
         * @return the formErrorMsgLbl
211
         */
212
        @Generated
213
        JLabel getFormErrorMsgLbl() {
214
                return formErrorMsgLbl;
215
        }
216

217
        /**
218
         * @return the clientErrorMsgLbl
219
         */
220
        @Generated
221
        JLabel getClientErrorMsgLbl() {
222
                return clientErrorMsgLbl;
223
        }
224

225
        /**
226
         * @return the reservationErrorMsgLbl
227
         */
228
        @Generated
229
        JLabel getReservationErrorMsgLbl() {
230
                return reservationErrorMsgLbl;
231
        }
232

233
        /**
234
         * Displays the clients of the given list on the graphical user interface through Swing.
235
         * Additionally, this method resets the client list selection and disables all buttons
236
         * that fire when a client is selected in the list.
237
         * 
238
         * @param clients        the {@code List} of clients to show.
239
         */
240
        @Override
241
        public void showAllClients(List<Client> clients) {
242
                clientListModel.removeAllElements();
×
243
                clients.stream().forEach(clientListModel::addElement);
×
244
                
245
                clientList.clearSelection();
×
246
                addReservationBtn.setEnabled(false);
×
247
                renameBtn.setEnabled(false);
×
248
                removeClientBtn.setEnabled(false);
×
249
        }
×
250

251
        /**
252
         * Displays the reservations of the given list on the user interface through Swing.
253
         * Additionally, this method resets the reservation list selection and disables all buttons
254
         * that fire when a reservation is selected in the list.
255
         * 
256
         * @param reservations        the {@code List} of reservations to show.
257
         */
258
        @Override
259
        public void showAllReservations(List<Reservation> reservations) {
260
                reservationListModel.removeAllElements();
×
261
                reservations.stream().forEach(reservationListModel::addElement);
×
262
                
263
                reservationList.clearSelection();
×
264
                rescheduleBtn.setEnabled(false);
×
265
                removeReservationBtn.setEnabled(false);
×
266
        }
×
267

268
        /**
269
         * Displays the reservation just inserted into the repository on the user interface
270
         * through Swing.
271
         * 
272
         * @param reservation        the {@code Reservation} to show.
273
         */
274
        @Override
275
        public void reservationAdded(Reservation reservation) {
276
                reservationListModel.addElement(reservation);
×
277
        }
×
278

279
        /**
280
         * Displays the client just inserted into the repository on the user interface through Swing.
281
         * 
282
         * @param client        the {@code Client} to show.
283
         */
284
        @Override
285
        public void clientAdded(Client client) {
286
                clientListModel.addElement(client);
×
287
        }
×
288

289
        /**
290
         * Makes the just deleted reservation disappear from the user interface through Swing.
291
         * 
292
         * @param reservation        the {@code Reservation} to remove from the view.
293
         */
294
        @Override
295
        public void reservationRemoved(Reservation reservation) {
296
                reservationListModel.removeElement(reservation);
×
297
        }
×
298

299
        /**
300
         * Makes the just deleted client disappear from the user interface through Swing.
301
         * 
302
         * @param client        the {@code Client} to remove from the view.
303
         */
304
        @Override
305
        public void clientRemoved(Client client) {
306
                clientListModel.removeElement(client);
×
307
        }
×
308

309
        /**
310
         * Displays the changes of the client just renamed on the user interface through Swing.
311
         * 
312
         * @param oldClient                the {@code Client} to replace from the view.
313
         * @param renamedClient        the {@code Client} that replaces the old one.
314
         */
315
        @Override
316
        public void clientRenamed(Client oldClient, Client renamedClient) {
317
                clientListModel.addElement(renamedClient);
×
318
                if (clientList.getSelectedIndex() == clientListModel.indexOf(oldClient))
×
319
                        clientList.setSelectedValue(renamedClient, true);
×
320
                clientListModel.removeElement(oldClient);
×
321
        }
×
322

323
        /**
324
         * Displays the changes of the reservation just rescheduled on the user interface through Swing.
325
         * 
326
         * @param oldReservation                        the {@code Reservation} to replace from the view.
327
         * @param rescheduledReservation        the {@code Reservation} that replaces the old one.
328
         */
329
        @Override
330
        public void reservationRescheduled(Reservation oldReservation, Reservation rescheduledReservation) {
331
                reservationListModel.addElement(rescheduledReservation);
×
332
                if (reservationList.getSelectedIndex() == reservationListModel.indexOf(oldReservation))
×
333
                        reservationList.setSelectedValue(rescheduledReservation, true);
×
334
                reservationListModel.removeElement(oldReservation);
×
335
        }
×
336

337
        /**
338
         * Displays an error message that involves reservation objects through Swing.
339
         * 
340
         * @param message        the message to show.
341
         */
342
        @Override
343
        public void showReservationError(String message) {
344
                reservationErrorMsgLbl.setText(message);
×
345
        }
×
346

347
        /**
348
         * Displays an error message that involves client objects through Swing.
349
         * 
350
         * @param message        the message to show.
351
         */
352
        @Override
353
        public void showClientError(String message) {
354
                clientErrorMsgLbl.setText(message);
×
355
        }
×
356

357
        /**
358
         * Displays an error message that involves form inputs through Swing.
359
         * 
360
         * @param message        the message to show.
361
         */
362
        @Override
363
        public void showFormError(String message) {
364
                formErrorMsgLbl.setText(message);
×
365
        }
×
366

367
        /**
368
         * Launch the application.
369
         */
370
        public static void main(String[] args) {
371
                EventQueue.invokeLater(new Runnable() {
×
372
                        public void run() {
373
                                try {
374
                                        BookingSwingView frame = new BookingSwingView();
×
375
                                        frame.setVisible(true);
×
376
                                } catch (Exception e) {
×
377
                                        e.printStackTrace();
×
378
                                }
×
379
                        }
×
380
                });
381
        }
×
382

383
        /**
384
         * Create the frame.
385
         */
386
        public BookingSwingView() {
1✔
387
                setTitle("BookingApp");
1✔
388
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
1✔
389
                setBounds(100, 100, 450, 300);
1✔
390
                contentPane = new JPanel();
1✔
391
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
1✔
392

393
                setContentPane(contentPane);
1✔
394
                GridBagLayout gbl_contentPane = new GridBagLayout();
1✔
395
                gbl_contentPane.columnWidths = new int[] {60, 40, 60, 40, 40, 40, 0, 20, 0, 20, 0};
1✔
396
                gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0};
1✔
397
                gbl_contentPane.columnWeights = new double[]{1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
1✔
398
                gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
1✔
399
                contentPane.setLayout(gbl_contentPane);
1✔
400
                
401
                // First row
402
                JLabel firstNameLbl = new JLabel("First Name");
1✔
403
                firstNameLbl.setName("firstNameLbl");
1✔
404
                GridBagConstraints gbc_firstNameLbl = new GridBagConstraints();
1✔
405
                gbc_firstNameLbl.anchor = GridBagConstraints.EAST;
1✔
406
                gbc_firstNameLbl.insets = new Insets(0, 0, 5, 5);
1✔
407
                gbc_firstNameLbl.gridx = 0;
1✔
408
                gbc_firstNameLbl.gridy = 0;
1✔
409
                contentPane.add(firstNameLbl, gbc_firstNameLbl);
1✔
410
                
411
                nameFormTxt = new JTextField();
1✔
412
                nameFormTxt.addKeyListener(clientBtnEnabler);
1✔
413
                nameFormTxt.setName("nameFormTxt");
1✔
414
                nameFormTxt.setToolTipText("Names must not contain numbers (e.g. 0-9) or any type of symbol or special character (e.g. ~`! @#$%^&*()_-+={[}]|\\:;\"'<,>.?/)");
1✔
415
                GridBagConstraints gbc_nameFormTxt = new GridBagConstraints();
1✔
416
                gbc_nameFormTxt.fill = GridBagConstraints.HORIZONTAL;
1✔
417
                gbc_nameFormTxt.insets = new Insets(0, 0, 5, 5);
1✔
418
                gbc_nameFormTxt.gridx = 1;
1✔
419
                gbc_nameFormTxt.gridy = 0;
1✔
420
                contentPane.add(nameFormTxt, gbc_nameFormTxt);
1✔
421
                nameFormTxt.setColumns(10);
1✔
422
                
423
                lastNameLbl = new JLabel("Last Name");
1✔
424
                lastNameLbl.setVerticalAlignment(SwingConstants.BOTTOM);
1✔
425
                lastNameLbl.setName("lastNameLbl");
1✔
426
                GridBagConstraints gbc_lastNameLbl = new GridBagConstraints();
1✔
427
                gbc_lastNameLbl.anchor = GridBagConstraints.EAST;
1✔
428
                gbc_lastNameLbl.insets = new Insets(0, 0, 5, 5);
1✔
429
                gbc_lastNameLbl.gridx = 2;
1✔
430
                gbc_lastNameLbl.gridy = 0;
1✔
431
                contentPane.add(lastNameLbl, gbc_lastNameLbl);
1✔
432
                
433
                surnameFormTxt = new JTextField();
1✔
434
                surnameFormTxt.addKeyListener(clientBtnEnabler);
1✔
435
                surnameFormTxt.setToolTipText("Surnames must not contain numbers (e.g. 0-9) or any type of symbol or special character (e.g. ~`! @#$%^&*()_-+={[}]|\\:;\"'<,>.?/)");
1✔
436
                surnameFormTxt.setName("surnameFormTxt");
1✔
437
                GridBagConstraints gbc_surnameFormTxt = new GridBagConstraints();
1✔
438
                gbc_surnameFormTxt.insets = new Insets(0, 0, 5, 5);
1✔
439
                gbc_surnameFormTxt.fill = GridBagConstraints.HORIZONTAL;
1✔
440
                gbc_surnameFormTxt.gridx = 3;
1✔
441
                gbc_surnameFormTxt.gridy = 0;
1✔
442
                contentPane.add(surnameFormTxt, gbc_surnameFormTxt);
1✔
443
                surnameFormTxt.setColumns(10);
1✔
444
                
445
                dateLbl = new JLabel("Date");
1✔
446
                dateLbl.setName("dateLbl");
1✔
447
                GridBagConstraints gbc_dateLbl = new GridBagConstraints();
1✔
448
                gbc_dateLbl.anchor = GridBagConstraints.EAST;
1✔
449
                gbc_dateLbl.insets = new Insets(0, 0, 5, 5);
1✔
450
                gbc_dateLbl.gridx = 4;
1✔
451
                gbc_dateLbl.gridy = 0;
1✔
452
                contentPane.add(dateLbl, gbc_dateLbl);
1✔
453
                
454
                yearFormTxt = new JTextField();
1✔
455
                yearFormTxt.addKeyListener(reservationBtnEnabler);
1✔
456
                yearFormTxt.setToolTipText("yyyy");
1✔
457
                yearFormTxt.setName("yearFormTxt");
1✔
458
                GridBagConstraints gbc_yearFormTxt = new GridBagConstraints();
1✔
459
                gbc_yearFormTxt.insets = new Insets(0, 0, 5, 5);
1✔
460
                gbc_yearFormTxt.fill = GridBagConstraints.HORIZONTAL;
1✔
461
                gbc_yearFormTxt.gridx = 5;
1✔
462
                gbc_yearFormTxt.gridy = 0;
1✔
463
                contentPane.add(yearFormTxt, gbc_yearFormTxt);
1✔
464
                yearFormTxt.setColumns(10);
1✔
465
                
466
                dash1Lbl = new JLabel("-");
1✔
467
                dash1Lbl.setName("dash1Lbl");
1✔
468
                dash1Lbl.setToolTipText("");
1✔
469
                GridBagConstraints gbc_dash1Lbl = new GridBagConstraints();
1✔
470
                gbc_dash1Lbl.anchor = GridBagConstraints.EAST;
1✔
471
                gbc_dash1Lbl.insets = new Insets(0, 0, 5, 5);
1✔
472
                gbc_dash1Lbl.gridx = 6;
1✔
473
                gbc_dash1Lbl.gridy = 0;
1✔
474
                contentPane.add(dash1Lbl, gbc_dash1Lbl);
1✔
475
                
476
                monthFormTxt = new JTextField();
1✔
477
                monthFormTxt.addKeyListener(reservationBtnEnabler);
1✔
478
                monthFormTxt.setName("monthFormTxt");
1✔
479
                monthFormTxt.setToolTipText("mm");
1✔
480
                GridBagConstraints gbc_monthFormTxt = new GridBagConstraints();
1✔
481
                gbc_monthFormTxt.insets = new Insets(0, 0, 5, 0);
1✔
482
                gbc_monthFormTxt.fill = GridBagConstraints.HORIZONTAL;
1✔
483
                gbc_monthFormTxt.gridx = 7;
1✔
484
                gbc_monthFormTxt.gridy = 0;
1✔
485
                contentPane.add(monthFormTxt, gbc_monthFormTxt);
1✔
486
                monthFormTxt.setColumns(10);
1✔
487
                
488
                dash2Lbl = new JLabel("-");
1✔
489
                dash2Lbl.setName("dash2Lbl");
1✔
490
                GridBagConstraints gbc_dash2Lbl = new GridBagConstraints();
1✔
491
                gbc_dash2Lbl.anchor = GridBagConstraints.EAST;
1✔
492
                gbc_dash2Lbl.insets = new Insets(0, 0, 5, 5);
1✔
493
                gbc_dash2Lbl.gridx = 8;
1✔
494
                gbc_dash2Lbl.gridy = 0;
1✔
495
                contentPane.add(dash2Lbl, gbc_dash2Lbl);
1✔
496
                
497
                dayFormTxt = new JTextField();
1✔
498
                dayFormTxt.addKeyListener(reservationBtnEnabler);
1✔
499
                dayFormTxt.setName("dayFormTxt");
1✔
500
                dayFormTxt.setToolTipText("dd");
1✔
501
                GridBagConstraints gbc_dayFormTxt = new GridBagConstraints();
1✔
502
                gbc_dayFormTxt.insets = new Insets(0, 0, 5, 5);
1✔
503
                gbc_dayFormTxt.fill = GridBagConstraints.HORIZONTAL;
1✔
504
                gbc_dayFormTxt.gridx = 9;
1✔
505
                gbc_dayFormTxt.gridy = 0;
1✔
506
                contentPane.add(dayFormTxt, gbc_dayFormTxt);
1✔
507
                dayFormTxt.setColumns(10);
1✔
508
                
509
                // Second row
510
                formErrorMsgLbl = new JLabel(" ");
1✔
511
                formErrorMsgLbl.setName("formErrorMsgLbl");
1✔
512
                GridBagConstraints gbc_formErrorMsgLbl = new GridBagConstraints();
1✔
513
                gbc_formErrorMsgLbl.insets = new Insets(0, 0, 5, 5);
1✔
514
                gbc_formErrorMsgLbl.gridwidth = 10;
1✔
515
                gbc_formErrorMsgLbl.gridx = 0;
1✔
516
                gbc_formErrorMsgLbl.gridy = 1;
1✔
517
                contentPane.add(formErrorMsgLbl, gbc_formErrorMsgLbl);
1✔
518
                
519
                // Third row
520
                addClientBtn = new JButton("Add Client");
1✔
521
                addClientBtn.addActionListener(e -> {
1✔
522
                        bookingPresenter.addClient(nameFormTxt.getText(), surnameFormTxt.getText());
×
523
                        nameFormTxt.setText("");
×
524
                        surnameFormTxt.setText("");
×
525
                        addClientBtn.setEnabled(false);
×
526
                        formErrorMsgLbl.setText(" ");
×
527
                        clientErrorMsgLbl.setText(" ");
×
528
                });
×
529
                addClientBtn.setEnabled(false);
1✔
530
                addClientBtn.setName("addClientBtn");
1✔
531
                addClientBtn.setToolTipText("");
1✔
532
                GridBagConstraints gbc_addClientBtn = new GridBagConstraints();
1✔
533
                gbc_addClientBtn.gridwidth = 2;
1✔
534
                gbc_addClientBtn.insets = new Insets(0, 0, 5, 5);
1✔
535
                gbc_addClientBtn.gridx = 0;
1✔
536
                gbc_addClientBtn.gridy = 2;
1✔
537
                contentPane.add(addClientBtn, gbc_addClientBtn);
1✔
538
                
539
                renameBtn = new JButton("Rename");
1✔
540
                renameBtn.addActionListener(e -> {
1✔
541
                        bookingPresenter.renameClient(
×
542
                                        clientListModel.get(clientList.getSelectedIndex()),
×
543
                                        nameFormTxt.getText(),
×
544
                                        surnameFormTxt.getText());
×
545
                        nameFormTxt.setText("");
×
546
                        surnameFormTxt.setText("");
×
547
                        renameBtn.setEnabled(false);
×
548
                        formErrorMsgLbl.setText(" ");
×
549
                        clientErrorMsgLbl.setText(" ");
×
550
                });
×
551
                renameBtn.setEnabled(false);
1✔
552
                renameBtn.setName("renameBtn");
1✔
553
                GridBagConstraints gbc_renameBtn = new GridBagConstraints();
1✔
554
                gbc_renameBtn.gridwidth = 2;
1✔
555
                gbc_renameBtn.insets = new Insets(0, 0, 5, 5);
1✔
556
                gbc_renameBtn.gridx = 2;
1✔
557
                gbc_renameBtn.gridy = 2;
1✔
558
                contentPane.add(renameBtn, gbc_renameBtn);
1✔
559
                
560
                addReservationBtn = new JButton("Add Reservation");
1✔
561
                addReservationBtn.addActionListener(e -> {
1✔
562
                        bookingPresenter.addReservation(
×
563
                                        clientListModel.get(clientList.getSelectedIndex()),
×
564
                                        yearFormTxt.getText() + "-" + monthFormTxt.getText() + "-" + dayFormTxt.getText());
×
565
                        addReservationBtn.setEnabled(false);
×
566
                        yearFormTxt.setText("");
×
567
                        monthFormTxt.setText("");
×
568
                        dayFormTxt.setText("");
×
569
                        formErrorMsgLbl.setText(" ");
×
570
                        reservationErrorMsgLbl.setText(" ");
×
571
                });
×
572
                addReservationBtn.setEnabled(false);
1✔
573
                addReservationBtn.setName("addReservationBtn");
1✔
574
                GridBagConstraints gbc_addReservationBtn = new GridBagConstraints();
1✔
575
                gbc_addReservationBtn.gridwidth = 2;
1✔
576
                gbc_addReservationBtn.insets = new Insets(0, 0, 5, 5);
1✔
577
                gbc_addReservationBtn.gridx = 4;
1✔
578
                gbc_addReservationBtn.gridy = 2;
1✔
579
                contentPane.add(addReservationBtn, gbc_addReservationBtn);
1✔
580
                
581
                rescheduleBtn = new JButton("Reschedule");
1✔
582
                rescheduleBtn.addActionListener(e -> {
1✔
583
                        bookingPresenter.rescheduleReservation(
×
584
                                        reservationListModel.get(reservationList.getSelectedIndex()),
×
585
                                        yearFormTxt.getText() + "-" + monthFormTxt.getText() + "-" + dayFormTxt.getText());
×
586
                        rescheduleBtn.setEnabled(false);
×
587
                        yearFormTxt.setText("");
×
588
                        monthFormTxt.setText("");
×
589
                        dayFormTxt.setText("");
×
590
                        formErrorMsgLbl.setText(" ");
×
591
                        reservationErrorMsgLbl.setText(" ");
×
592
                });
×
593
                rescheduleBtn.setName("rescheduleBtn");
1✔
594
                rescheduleBtn.setEnabled(false);
1✔
595
                GridBagConstraints gbc_rescheduleBtn = new GridBagConstraints();
1✔
596
                gbc_rescheduleBtn.gridwidth = 4;
1✔
597
                gbc_rescheduleBtn.insets = new Insets(0, 0, 5, 0);
1✔
598
                gbc_rescheduleBtn.gridx = 6;
1✔
599
                gbc_rescheduleBtn.gridy = 2;
1✔
600
                contentPane.add(rescheduleBtn, gbc_rescheduleBtn);
1✔
601
                
602
                // Fourth row
603
                clientScrollPane = new JScrollPane();
1✔
604
                clientScrollPane.setName("clientScrollPane");
1✔
605
                GridBagConstraints gbc_clientScrollPane = new GridBagConstraints();
1✔
606
                gbc_clientScrollPane.gridwidth = 4;
1✔
607
                gbc_clientScrollPane.insets = new Insets(0, 0, 5, 5);
1✔
608
                gbc_clientScrollPane.fill = GridBagConstraints.BOTH;
1✔
609
                gbc_clientScrollPane.gridx = 0;
1✔
610
                gbc_clientScrollPane.gridy = 3;
1✔
611
                contentPane.add(clientScrollPane, gbc_clientScrollPane);
1✔
612
                
613
                clientListModel = new DefaultListModel<>();
1✔
614
                clientList = new JList<>(clientListModel);
1✔
615
                clientList.addListSelectionListener(clientListListener);
1✔
616
                clientList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1✔
617
                clientList.setName("clientList");
1✔
618
                clientScrollPane.setViewportView(clientList);
1✔
619
                
620
                reservationScrollPane = new JScrollPane();
1✔
621
                reservationScrollPane.setName("reservationScrollPane");
1✔
622
                GridBagConstraints gbc_reservationScrollPane = new GridBagConstraints();
1✔
623
                gbc_reservationScrollPane.gridwidth = 6;
1✔
624
                gbc_reservationScrollPane.insets = new Insets(0, 0, 5, 0);
1✔
625
                gbc_reservationScrollPane.fill = GridBagConstraints.BOTH;
1✔
626
                gbc_reservationScrollPane.gridx = 4;
1✔
627
                gbc_reservationScrollPane.gridy = 3;
1✔
628
                contentPane.add(reservationScrollPane, gbc_reservationScrollPane);
1✔
629
                
630
                reservationListModel = new DefaultListModel<>();
1✔
631
                reservationList = new JList<>(reservationListModel);
1✔
632
                reservationList.addListSelectionListener(reservationListListener);
1✔
633
                reservationList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1✔
634
                reservationList.setName("reservationList");
1✔
635
                reservationScrollPane.setViewportView(reservationList);
1✔
636
                
637
                // Fifth row
638
                removeClientBtn = new JButton("Remove Client");
1✔
639
                removeClientBtn.addActionListener(e -> {
1✔
640
                        bookingPresenter.deleteClient(clientListModel.get(clientList.getSelectedIndex()));
×
641
                        removeClientBtn.setEnabled(false);
×
642
                        formErrorMsgLbl.setText(" ");
×
643
                        clientErrorMsgLbl.setText(" ");
×
644
                });
×
645
                removeClientBtn.setEnabled(false);
1✔
646
                removeClientBtn.setName("removeClientBtn");
1✔
647
                GridBagConstraints gbc_removeClientBtn = new GridBagConstraints();
1✔
648
                gbc_removeClientBtn.gridwidth = 4;
1✔
649
                gbc_removeClientBtn.insets = new Insets(0, 0, 5, 5);
1✔
650
                gbc_removeClientBtn.gridx = 0;
1✔
651
                gbc_removeClientBtn.gridy = 4;
1✔
652
                contentPane.add(removeClientBtn, gbc_removeClientBtn);
1✔
653
                
654
                removeReservationBtn = new JButton("Remove Reservation");
1✔
655
                removeReservationBtn.addActionListener(e -> {
1✔
656
                        bookingPresenter.deleteReservation(reservationListModel.get(reservationList.getSelectedIndex()));
×
657
                        removeReservationBtn.setEnabled(false);
×
658
                        formErrorMsgLbl.setText(" ");
×
659
                        reservationErrorMsgLbl.setText(" ");
×
660
                });
×
661
                removeReservationBtn.setName("removeReservationBtn");
1✔
662
                removeReservationBtn.setEnabled(false);
1✔
663
                GridBagConstraints gbc_removeReservationBtn = new GridBagConstraints();
1✔
664
                gbc_removeReservationBtn.gridwidth = 6;
1✔
665
                gbc_removeReservationBtn.insets = new Insets(0, 0, 5, 0);
1✔
666
                gbc_removeReservationBtn.gridx = 4;
1✔
667
                gbc_removeReservationBtn.gridy = 4;
1✔
668
                contentPane.add(removeReservationBtn, gbc_removeReservationBtn);
1✔
669
                
670
                // Sixth row
671
                clientErrorMsgLbl = new JLabel(" ");
1✔
672
                clientErrorMsgLbl.setName("clientErrorMsgLbl");
1✔
673
                GridBagConstraints gbc_clientErrorMsgLbl = new GridBagConstraints();
1✔
674
                gbc_clientErrorMsgLbl.gridwidth = 4;
1✔
675
                gbc_clientErrorMsgLbl.insets = new Insets(0, 0, 0, 5);
1✔
676
                gbc_clientErrorMsgLbl.gridx = 0;
1✔
677
                gbc_clientErrorMsgLbl.gridy = 5;
1✔
678
                contentPane.add(clientErrorMsgLbl, gbc_clientErrorMsgLbl);
1✔
679
                
680
                reservationErrorMsgLbl = new JLabel(" ");
1✔
681
                reservationErrorMsgLbl.setName("reservationErrorMsgLbl");
1✔
682
                GridBagConstraints gbc_reservationErrorMsgLbl = new GridBagConstraints();
1✔
683
                gbc_reservationErrorMsgLbl.insets = new Insets(0, 0, 0, 5);
1✔
684
                gbc_reservationErrorMsgLbl.gridwidth = 6;
1✔
685
                gbc_reservationErrorMsgLbl.gridx = 4;
1✔
686
                gbc_reservationErrorMsgLbl.gridy = 5;
1✔
687
                contentPane.add(reservationErrorMsgLbl, gbc_reservationErrorMsgLbl);
1✔
688
        }
1✔
689
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc