]> git.mxchange.org Git - jfinancials-lib.git/blob - Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java
Added a lot trace messages + sanity checks for null references and such things
[jfinancials-lib.git] / Addressbook / src / org / mxchange / addressbook / client / gui / AddressbookFrame.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.addressbook.client.gui;
18
19 import java.awt.BorderLayout;
20 import java.awt.GridLayout;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.awt.event.MouseAdapter;
24 import java.awt.event.MouseEvent;
25 import java.awt.event.WindowAdapter;
26 import java.awt.event.WindowEvent;
27 import java.text.MessageFormat;
28 import javax.swing.BorderFactory;
29 import javax.swing.BoxLayout;
30 import javax.swing.DefaultComboBoxModel;
31 import javax.swing.InputVerifier;
32 import javax.swing.JComboBox;
33 import javax.swing.JComponent;
34 import javax.swing.JDialog;
35 import javax.swing.JFrame;
36 import javax.swing.JLabel;
37 import javax.swing.JMenu;
38 import javax.swing.JMenuBar;
39 import javax.swing.JMenuItem;
40 import javax.swing.JPanel;
41 import javax.swing.JScrollPane;
42 import javax.swing.JTable;
43 import javax.swing.JTextField;
44 import javax.swing.border.TitledBorder;
45 import javax.swing.table.TableModel;
46 import org.mxchange.addressbook.BaseFrameworkSystem;
47 import org.mxchange.addressbook.application.AddressbookApplication;
48 import org.mxchange.addressbook.client.Client;
49 import org.mxchange.addressbook.contact.Contact;
50 import org.mxchange.addressbook.contact.Gender;
51 import org.mxchange.addressbook.exceptions.FrameAlreadyInitializedException;
52 import org.mxchange.addressbook.model.contact.ContactTableModel;
53
54 /**
55  *
56  * @author Roland Haeder
57  */
58 public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame {
59
60         /**
61          * Own instance
62          */
63         private static ClientFrame self;
64
65         /**
66          * Singelton getter for this frame instance.
67          *
68          * @param client Client instance
69          * @return Returns a singelton instance of this frame
70          */
71         public static final ClientFrame getSelfInstance (final Client client) {
72                 // Is it set?
73                 if (!(self instanceof ClientFrame)) {
74                         // Create new instance
75                         self = new AddressbookFrame(client);
76                 }
77
78                 // Return instance
79                 return self;
80         }
81
82         /**
83          * Dialog box "add contact"
84          */
85         private JDialog addContact;
86
87         /**
88          * Frame instance for "add own data"
89          */
90         private JMenuItem addOwnItem;
91
92         /**
93          * Instance to table model
94          */
95         private TableModel dataModel;
96
97         /**
98          * Table instance
99          */
100         private JTable dataTable;
101
102         /**
103          * Frame instance for "edit own data"
104          */
105         private JMenuItem editOwnItem;
106
107         /**
108          * Frame instance
109          */
110         private final JFrame frame;
111
112         /**
113          * Whether this frame has been initialized
114          */
115         private boolean isInitialized;
116
117         /**
118          * Layout instance
119          */
120         private GridLayout layout;
121
122         /**
123          * Status label needs to be updated
124          */
125         private JLabel statusLabel;
126
127         /**
128          * Creates an instance of this frame with a client instance
129          *
130          * @param client
131          */
132         private AddressbookFrame (final Client client) {
133                 // Debug line
134                 this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client)); //NOI18N
135
136                 // Set frame instance
137                 this.frame = new JFrame();
138                 this.frame.setTitle(this.generateFrameTitle("main")); //NOI18N
139
140                 // Set client here
141                 this.setClient(client);
142
143                 // Trace message
144                 this.getLogger().trace("EXIT!"); //NOI18N
145         }
146
147         @Override
148         public Contact doEnterOwnData () {
149                 // Trace message
150                 this.getLogger().trace("CALLED!"); //NOI18N
151
152                 // Is the "add contact" window visible?
153                 if (this.addContact.isVisible()) {
154                         // Something bad happened
155                         throw new IllegalStateException("Window addContact is already visible.");
156                 }
157
158                 // Disable main window
159                 this.frame.setEnabled(false);
160
161                 // Make other window visible
162                 this.addContact.setVisible(true);
163
164                 // Trace message
165                 this.getLogger().trace("Returning null : EXIT!"); //NOI18N
166
167                 // Return value is not supported
168                 return null;
169         }
170
171         /**
172          * Shutdown this frame
173          */
174         @Override
175         public void doShutdown () {
176                 // Trace message
177                 this.getLogger().trace("CALLED!"); //NOI18N
178
179                 // First only show shutdown status
180                 this.updateStatus("shutdown"); //NOI18N
181
182                 // Trace message
183                 this.getLogger().trace("EXIT!"); //NOI18N
184         }
185
186
187         /**
188          * Enables main window (frame)
189          */
190         @Override
191         public void enableMainWindow () {
192                 // Trace message
193                 this.getLogger().trace("CALLED!"); //NOI18N
194
195                 // Enable it again
196                 this.frame.setEnabled(true);
197
198                 // Request focus for this window
199                 this.frame.requestFocus();
200
201                 // Trace message
202                 this.getLogger().trace("EXIT!"); //NOI18N
203         }
204
205         /**
206          * Setups the frame, do not set isInitialized here
207          *
208          * @param client Client instance
209          */
210         @Override
211         public void setupFrame (final Client client) {
212                 // Debug line
213                 this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client)); //NOI18N
214
215                 // Has the user entered own data?
216                 if (this.getClient().getContactManager().isOwnContactAdded()) {
217                         // Debug message
218                         this.getLogger().debug("Disabling menus: isOwnContactAdded()=false"); //NOI18N
219
220                         // Not entered yet, so disable "add" menu
221                         this.addOwnItem.setEnabled(false);
222                 } else {
223                         // Disable "edit"
224                         this.editOwnItem.setEnabled(false);
225                 }
226
227                 // Make the frame visible
228                 this.frame.setVisible(true);
229
230                 // All done here
231                 this.updateStatus("done"); //NOI18N
232
233                 // Trace message
234                 this.getLogger().trace("EXIT!"); //NOI18N
235         }
236
237         /**
238          * Initalizes this frame. Having initComponents() exposed (publicly
239          * accessible) means that any other object can initialize components which
240          * you may not want.
241          *
242          * @throws
243          * org.mxchange.addressbook.exceptions.FrameAlreadyInitializedException If
244          * this method has been called twice
245          */
246         @Override
247         public void init () throws FrameAlreadyInitializedException {
248                 // Debug line
249                 this.getLogger().trace("CALLED!"); //NOI18N
250
251                 // Has this frame been initialized?
252                 if (this.isInitialized()) {
253                         // Throw exception
254                         throw new FrameAlreadyInitializedException();
255                 }
256
257                 // Init components
258                 this.initComponents();
259
260                 // Set flag
261                 this.isInitialized = true;
262
263                 // Trace message
264                 this.getLogger().trace("EXIT!"); //NOI18N
265         }
266
267         /**
268          * Returns field isInitialized. This flag indicates whether this frame has
269          * been initialized or not.
270          *
271          * @return Field isInitialized
272          */
273         @Override
274         public final boolean isInitialized () {
275                 return this.isInitialized;
276         }
277
278         /**
279          * Shuts down the application.
280          */
281         @Override
282         public void shutdownApplication () {
283                 // Trace message
284                 this.getLogger().trace("CALLED!"); //NOI18N
285
286                 // To do this, the frame must be initialized
287                 if (!this.isInitialized()) {
288                         // Not initalized, so bad call
289                         this.getLogger().fatal("Bad call of shutdownApplication(). Please report this."); //NOI18N
290                         return;
291                 }
292
293                 // Call shutdown method
294                 this.getClient().getApplication().doShutdown();
295
296                 // Trace message
297                 this.getLogger().trace("EXIT!"); //NOI18N
298         }
299
300         /**
301          * Generates a title for borders
302          *
303          * @param key Key part to look for
304          * @return Human-readable title
305          */
306         private String generateBorderTitle (final String key) {
307                 // Call bundle instance
308                 return this.getBundle().getString(String.format("AddressbookFrame.border.%s.title.text", key)); //NOI18N
309         }
310
311         /**
312          * Generates a title for all frames based on given sub title key. If null is
313          * given, the sub title is not generated.
314          *
315          * @param subKey Key for sub title resource
316          * @return A full application title
317          */
318         private String generateFrameTitle (final String subKey) {
319                 // Base title
320                 String title = AddressbookApplication.printableTitle();
321
322                 // Is key given?
323                 if (subKey != null) {
324                         // Add sub title
325                         title = String.format("%s - %s", title, this.getBundle().getString(String.format("AddressbookFrame.%s.title.text", subKey))); //NOI18N
326                 }
327
328                 // Return it
329                 return title;
330         }
331
332         /**
333          * Initializes "add" and "cancel" buttons
334          */
335         private void initAddCancelButtons () {
336         }
337
338         /**
339          * Initializes "add contact" dialog
340          */
341         private void initAddContactDialog () {
342                 // Trace message
343                 this.getLogger().trace("EXIT!"); //NOI18N
344
345                 // Instance dialog and set title
346                 this.addContact = new JDialog();
347                 this.addContact.setTitle(this.generateFrameTitle("dialog.addContact")); //NOI18N
348
349                 // Set layout
350                 this.addContact.setLayout(new GridLayout(0, 1, 2, 2));
351
352                 // Only hide it on close and make it appear in middle of screen
353                 this.addContact.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
354                 this.addContact.setLocationRelativeTo(null);
355
356                 // Set always on top and auto-focus
357                 this.addContact.setAlwaysOnTop(true);
358                 this.addContact.setAutoRequestFocus(true);
359
360                 // Initial dimension
361                 this.addContact.setSize(500, 500);
362
363                 // And it is not resizeable
364                 this.addContact.setResizable(false);
365
366                 /*
367                  * Add listener which asks for confirmation, if data has been entered
368                  * but not saved yet. The user may appriciate this ... ;-)
369                  *
370                  * @TODO Unfinished
371                  */
372                 this.addContact.addWindowListener(new WindowAdapter() {
373                         /**
374                          * Invoked when a window has been closed.
375                          */
376                         @Override
377                         public void windowClosed (final WindowEvent e) {
378                                 // Enable main window again
379                                 AddressbookFrame.getSelfInstance(null).enableMainWindow();
380                         }
381
382                         /**
383                          * Invoked when a window is in the process of being closed. The
384                          * close operation can be overridden at this point.
385                          */
386                         @Override
387                         public void windowClosing (final WindowEvent e) {
388                                 e.getWindow().dispose();
389                         }
390                 });
391
392                 // Init 3 panels:
393                 // 1) "name" panel
394                 initNameDataPanel(this.addContact);
395
396                 // 2) "address" panel
397                 initAddressDataPanel(this.addContact);
398
399                 // 3) "other" panel
400                 initOtherDataPanel(this.addContact);
401
402                 // 4) "Add" and "Cancel" buttons
403                 initAddCancelButtons();
404
405                 // x)Only for developing:
406                 /* DEBUG: */ this.addContact.setVisible(true);
407
408                 // Trace message
409                 this.getLogger().trace("EXIT!"); //NOI18N
410         }
411
412         /**
413          * Initializes address panel
414          *
415          * @param dialog A JDialog instance to this components to
416          */
417         private void initAddressDataPanel (final JDialog dialog) {
418                 // Trace message
419                 this.getLogger().trace("CALLED!"); //NOI18N
420
421                 // Panel "address" input boxes
422                 JPanel addressPanel = new JPanel();
423                 addressPanel.setLayout(new BoxLayout(addressPanel, BoxLayout.Y_AXIS));
424
425                 // Set border to titled version
426                 addressPanel.setBorder(new TitledBorder(this.generateBorderTitle("address"))); //NOI18N
427
428                 // Init all elements:
429                 // 1) Street and number together
430                 JPanel streetNumberPanel = new JPanel();
431                 streetNumberPanel.setLayout(new GridLayout(1, 4, 5, 5));
432
433                 // Label for street
434                 JLabel streetLabel = new JLabel(this.getBundle().getString("AddressbookFrame.street.text"));
435
436                 // Init text field with label
437                 JTextField street = new JTextField(20);
438                 street.setToolTipText(this.getBundle().getString("AddressbookFrame.street.tooltipText"));
439
440                 // Add both to street panel
441                 streetNumberPanel.add(streetLabel);
442                 streetNumberPanel.add(street);
443
444                 // Number label
445                 JLabel numberLabel = new JLabel(this.getBundle().getString("AddressbookFrame.number.text"));
446
447                 // And text field, but only accept numbers
448                 JTextField number = new JTextField(4);
449                 number.setToolTipText(this.getBundle().getString("AddressbookFrame.number.tooltipText"));
450
451                 // Add number verifier
452                 number.setInputVerifier(new InputVerifier() {
453
454                         /**
455                          * Method to verify that the entered data is a number.
456                          *
457                          * @param input Input to verify
458                          * @return Whether the data is a number
459                          */
460                         @Override
461                         public boolean verify (final JComponent input) {
462                                 // Cast on text field
463                                 JTextField text = (JTextField) input;
464
465                                 // Default is passed
466                                 boolean isValid = true;
467
468                                 // Try to convert input text to a number
469                                 try {
470                                         int num = Integer.valueOf(text.getText());
471                                 } catch (final NumberFormatException ex) {
472                                         // Didn't work
473                                         isValid = false;
474                                 }
475
476                                 // Return status
477                                 return isValid;
478                         }
479                 });
480
481                 // Add both to street panel
482                 streetNumberPanel.add(numberLabel);
483                 streetNumberPanel.add(number);
484
485                 // Add panel to address panel
486                 addressPanel.add(streetNumberPanel);
487
488                 // 2) ZIP code and ccity name
489                 JPanel zipCityPanel = new JPanel();
490                 zipCityPanel.setLayout(new GridLayout(1, 4, 5, 5));
491
492                 // Label for ZIP code, again numbers only
493                 JLabel zipLabel = new JLabel(this.getBundle().getString("AddressbookFrame.zip.text"));
494
495                 // Init text field with label
496                 JTextField zip = new JTextField(20);
497                 zip.setToolTipText(this.getBundle().getString("AddressbookFrame.zip.tooltipText"));
498
499                 // Add number verifier
500                 zip.setInputVerifier(new InputVerifier() {
501
502                         /**
503                          * Method to verify that the entered data is a number.
504                          *
505                          * @param input Input to verify
506                          * @return Whether the data is a number
507                          */
508                         @Override
509                         public boolean verify (final JComponent input) {
510                                 // Cast on text field
511                                 JTextField text = (JTextField) input;
512
513                                 // Default is passed
514                                 boolean isValid = true;
515
516                                 // Try to convert input text to a number
517                                 try {
518                                         int num = Integer.valueOf(text.getText());
519                                 } catch (final NumberFormatException ex) {
520                                         // Didn't work
521                                         isValid = false;
522                                 }
523
524                                 // Return status
525                                 return isValid;
526                         }
527                 });
528
529                 // Add both to street panel
530                 zipCityPanel.add(zipLabel);
531                 zipCityPanel.add(zip);
532
533                 // Label for street
534                 JLabel cityLabel = new JLabel(this.getBundle().getString("AddressbookFrame.city.text"));
535
536                 // Init text field with label
537                 JTextField city = new JTextField(20);
538                 city.setToolTipText(this.getBundle().getString("AddressbookFrame.city.tooltipText"));
539
540                 // Add both to street panel
541                 zipCityPanel.add(cityLabel);
542                 zipCityPanel.add(city);
543
544                 // Add panel to address panel
545                 addressPanel.add(zipCityPanel);
546
547                 // Add panel to dialog
548                 dialog.add(addressPanel);
549
550                 // Trace message
551                 this.getLogger().trace("EXIT!"); //NOI18N
552         }
553
554         /**
555          * Initialize components
556          */
557         private void initComponents () {
558                 // Debug line
559                 this.getLogger().trace("CALLED!"); //NOI18N
560
561                 // Set default close operation
562                 this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
563
564                 // Register shutdown listener
565                 this.frame.addWindowListener(new WindowAdapter() {
566                         /**
567                          * Invoked when a window has been closed.
568                          */
569                         @Override
570                         public void windowClosed (final WindowEvent e) {
571                                 // Shutdown application cleanly
572                                 self.shutdownApplication();
573                         }
574
575                         /**
576                          * Invoked when a window is in the process of being closed. The
577                          * close operation can be overridden at this point.
578                          */
579                         @Override
580                         public void windowClosing (final WindowEvent e) {
581                                 // Also shutdown cleanly here
582                                 self.shutdownApplication();
583                         }
584                 });
585
586                 // Setup layout manager
587                 this.frame.setLayout(new BorderLayout(2, 2));
588
589                 // Set window size
590                 this.frame.setSize(700, 400);
591
592                 // Center window in middle of screen, instead of top-left corner
593                 this.frame.setLocationRelativeTo(null);
594
595                 // Init menu system
596                 initMenuSystem();
597
598                 // Init table
599                 initTable();
600
601                 // Init status panel
602                 initStatusPanel();
603
604                 // Init other windows
605                 initOtherDialogs();
606
607                 // Trace message
608                 this.getLogger().trace("EXIT!"); //NOI18N
609         }
610
611         /**
612          * Initializes the menu system
613          */
614         private void initMenuSystem () {
615                 // Trace message
616                 this.getLogger().trace("CALLED!"); //NOI18N
617
618                 // Init menu bar, menu and item instances
619                 JMenuBar menuBar = new JMenuBar();
620                 JMenu menu;
621                 JMenuItem item;
622
623                 // Init some menus:
624                 // 1) File menu
625                 menu = new JMenu(this.getBundle().getString("AddressbookFrame.menu.file.text"));
626
627                 // Add menu items:
628                 // 1.x) Exit program (should be last)
629                 item = new JMenuItem(this.getBundle().getString("AddressbookFrame.menuItem.exitProgram.text"));
630                 item.setToolTipText(this.getBundle().getString("AddressbookFrame.menuItem.exitProgram.toolTipText"));
631
632                 // Add listener to exit menu
633                 item.addActionListener(new ActionListener() {
634                         /**
635                          * If the user has performed this action
636                          *
637                          * @param e An instance of an ActionEvent class
638                          */
639                         @Override
640                         public void actionPerformed (final ActionEvent e) {
641                                 self.shutdownApplication();
642                         }
643                 });
644
645                 // Add item -> menu
646                 menu.add(item);
647
648                 // Add menu -> menu bar
649                 menuBar.add(menu);
650
651                 // Init some menus:
652                 // 2) Addressbook menu
653                 menu = new JMenu(this.getBundle().getString("AddressbookFrame.menu.addressbook.text"));
654
655                 // 2.1) Add own data
656                 this.addOwnItem = new JMenuItem(this.getBundle().getString("AddressbookFrame.menuItem.addOwnData.text"));
657                 this.addOwnItem.setToolTipText(this.getBundle().getString("AddressbookFrame.menuItem.addOwnData.toolTipText"));
658
659                 // Add listener to exit menu
660                 this.addOwnItem.addActionListener(new ActionListener() {
661                         /**
662                          * If the user has performed this action
663                          *
664                          * @param e An instance of an ActionEvent class
665                          */
666                         @Override
667                         public void actionPerformed (final ActionEvent e) {
668                                 self.getClient().getContactManager().doEnterOwnData();
669                         }
670                 });
671
672                 // Add item -> menu
673                 menu.add(this.addOwnItem);
674
675                 // 2.2) Edit own data
676                 this.editOwnItem = new JMenuItem(this.getBundle().getString("AddressbookFrame.menuItem.editOwnData.text"));
677                 this.editOwnItem.setToolTipText(this.getBundle().getString("AddressbookFrame.menuItem.editOwnData.toolTipText"));
678
679                 // Add listener to exit menu
680                 this.editOwnItem.addActionListener(new ActionListener() {
681                         /**
682                          * If the user has performed this action
683                          *
684                          * @param e An instance of an ActionEvent class
685                          */
686                         @Override
687                         public void actionPerformed (final ActionEvent e) {
688                                 self.getClient().getContactManager().doChangeOwnData();
689                         }
690                 });
691
692                 // Add item -> menu
693                 menu.add(this.editOwnItem);
694
695                 // Add menu -> menu bar
696                 menuBar.add(menu);
697
698                 // Add menu bar -> frame
699                 this.frame.add(menuBar, BorderLayout.NORTH);
700
701                 // Trace message
702                 this.getLogger().trace("EXIT!"); //NOI18N
703         }
704
705         /**
706          * Initializes name panel
707          *
708          * @param dialog A JDialog instance to this components to
709          */
710         private void initNameDataPanel (final JDialog dialog) {
711                 // Trace message
712                 this.getLogger().trace("CALLED!"); //NOI18N
713
714                 // Panel "name" input boxes
715                 JPanel namePanel = new JPanel();
716                 namePanel.setLayout(new BoxLayout(namePanel, BoxLayout.Y_AXIS));
717
718                 // Set border to titled version
719                 namePanel.setBorder(new TitledBorder(this.generateBorderTitle("name"))); //NOI18N
720
721                 // Panel for gender
722                 JPanel gPanel = new JPanel();
723                 gPanel.setLayout(new GridLayout(1, 2, 5, 5));
724
725                 // Gender text field
726                 JLabel gLabel = new JLabel(this.getBundle().getString("AddressbookFrame.gender.text"));
727
728                 // Get all genders
729                 Gender[] genders = Gender.values();
730
731                 // Init gender combo box with tool tip
732                 JComboBox<Gender> gender = new JComboBox<>(new DefaultComboBoxModel<>(genders));
733                 gender.setToolTipText(this.getBundle().getString("AddressbookFrame.gender.tooltipText"));
734
735                 // Add both to gender panel
736                 gPanel.add(gLabel);
737                 gPanel.add(gender);
738
739                 // Add gender panel to "name" panel
740                 namePanel.add(gPanel);
741
742                 // Panel for surname
743                 JPanel sPanel = new JPanel();
744                 sPanel.setLayout(new GridLayout(1, 2, 5, 5));
745
746                 // New label for surname is not needed
747                 JLabel sLabel = new JLabel(this.getBundle().getString("AddressbookFrame.surname.text"));
748
749                 // And input box wih tool tip
750                 JTextField surname = new JTextField(20);
751                 surname.setToolTipText(this.getBundle().getString("AddressbookFrame.surname.tooltipText"));
752
753                 // Add both to surname panel
754                 sPanel.add(sLabel);
755                 sPanel.add(surname);
756
757                 // Add surname panel to "name" panel
758                 namePanel.add(sPanel);
759
760                 // Panel for surname
761                 JPanel fPanel = new JPanel();
762                 fPanel.setLayout(new GridLayout(1, 2));
763
764                 // New label for surname is not needed
765                 JLabel fLabel = new JLabel(this.getBundle().getString("AddressbookFrame.familyName.text"));
766
767                 // And input box wih tool tip
768                 JTextField familyName = new JTextField(20);
769                 familyName.setToolTipText(this.getBundle().getString("AddressbookFrame.familyName.tooltipText"));
770
771                 // Add both to surname panel
772                 fPanel.add(fLabel);
773                 fPanel.add(familyName);
774
775                 // Add family namepanel to "name" panel
776                 namePanel.add(fPanel);
777
778                 // Finally add panel to dialog
779                 dialog.add(namePanel);
780
781                 // Trace message
782                 this.getLogger().trace("EXIT!"); //NOI18N
783         }
784
785         /**
786          * Initializes "other" data panel
787          *
788          * @param dialog A JDialog instance to this components to
789          * @todo Fill this with life
790          */
791         private void initOtherDataPanel (final JDialog dialog) {
792                 // Trace message
793                 this.getLogger().trace("CALLED!"); //NOI18N
794
795                 // Panel "other" input boxes
796                 JPanel otherPanel = new JPanel();
797                 otherPanel.setLayout(new BoxLayout(otherPanel, BoxLayout.Y_AXIS));
798
799                 // Set border to titled version
800                 otherPanel.setBorder(new TitledBorder(this.generateBorderTitle("other"))); //NOI18N
801
802                 // Finally add panel to dialog
803                 dialog.add(otherPanel);
804
805                 // Trace message
806                 this.getLogger().trace("EXIT!"); //NOI18N
807         }
808
809         /**
810          * Initialize other dialogs (e.g. "Add contact")
811          */
812         private void initOtherDialogs () {
813                 // Trace message
814                 this.getLogger().trace("CALLED!"); //NOI18N
815
816                 // Init other windows:
817                 // 1) Add contact
818                 initAddContactDialog();
819
820                 // Trace message
821                 this.getLogger().trace("EXIT!"); //NOI18N
822         }
823
824         /**
825          * Initializes status panel
826          */
827         private void initStatusPanel () {
828                 // Trace message
829                 this.getLogger().trace("CALLED!"); //NOI18N
830
831                 // Init status label (which needs to be updated
832                 this.statusLabel = new JLabel();
833                 this.updateStatus("initializing"); //NOI18N
834
835                 // Init status bar in south
836                 JPanel panel = new JPanel();
837                 panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
838                 panel.add(this.statusLabel);
839                 panel.setBorder(BorderFactory.createEtchedBorder());
840
841                 // Add panel to frame
842                 this.frame.add(panel, BorderLayout.SOUTH);
843
844                 // Trace message
845                 this.getLogger().trace("EXIT!"); //NOI18N
846         }
847
848         /**
849          * Initializes the table which will show all contacts
850          */
851         private void initTable () {
852                 // Trace message
853                 this.getLogger().trace("CALLED!"); //NOI18N
854
855                 // Instance table model
856                 this.dataModel = new ContactTableModel(this.getClient());
857
858                 // Instance table
859                 this.dataTable = new JTable(this.dataModel);
860
861                 // Add mouse listener
862                 this.dataTable.addMouseListener(new MouseAdapter() {
863                         /**
864                          * If the user peformed a click on a cell
865                          *
866                          * @param e Mouse event instance
867                          */
868                         @Override
869                         public void mouseClicked (final MouseEvent e) {
870                                 throw new UnsupportedOperationException("Unfinished."); //NOI18N
871                         }
872                 });
873
874                 // Instance scroll pane
875                 JScrollPane scroller = new JScrollPane();
876
877                 // Add table to scroll pane
878                 scroller.setViewportView(this.dataTable);
879                 scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
880                 scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
881
882                 // Add pane to frame
883                 this.frame.add(scroller, BorderLayout.CENTER);
884
885                 // Trace message
886                 this.getLogger().trace("EXIT!"); //NOI18N
887         }
888
889         /**
890          * Updates status to given type
891          *
892          * @param type Status type
893          */
894         private void updateStatus (final String type) {
895                 // Trace message
896                 this.getLogger().trace(MessageFormat.format("type={0} - CALLED!", type)); //NOI18N
897
898                 // Set status message
899                 this.statusLabel.setText(this.getBundle().getString(String.format("AddressbookFrame.statusLabel.%s.text", type))); //NOI18N
900
901                 // Trace message
902                 this.getLogger().trace("EXIT!"); //NOI18N
903         }
904 }