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