2 * Copyright (C) 2015 Roland Haeder
\r
4 * This program is free software: you can redistribute it and/or modify
\r
5 * it under the terms of the GNU General Public License as published by
\r
6 * the Free Software Foundation, either version 3 of the License, or
\r
7 * (at your option) any later version.
\r
9 * This program is distributed in the hope that it will be useful,
\r
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 * GNU General Public License for more details.
\r
14 * You should have received a copy of the GNU General Public License
\r
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
17 package org.mxchange.addressbook.client.gui;
\r
19 import java.text.MessageFormat;
\r
20 import javax.swing.JFrame;
\r
21 import org.mxchange.addressbook.BaseFrameworkSystem;
\r
22 import org.mxchange.addressbook.FrameAlreadyInitializedException;
\r
23 import org.mxchange.addressbook.application.AddressbookApplication;
\r
24 import org.mxchange.addressbook.client.Client;
\r
28 * @author Roland Haeder
\r
30 public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame {
\r
35 private static ClientFrame self;
\r
38 * Singelton getter for this frame instance.
\r
40 * @param client Client instance
\r
41 * @return Returns a singelton instance of this frame
\r
43 public static final ClientFrame getSelfInstance (final Client client) {
\r
45 if (!(self instanceof ClientFrame)) {
\r
46 // Create new instance
\r
47 self = new AddressbookFrame(client);
\r
57 private final JFrame frame;
\r
60 * Whether this frame has been initialized
\r
62 private boolean isInitialized;
\r
65 * Creates an instance of this frame with a client instance
\r
69 private AddressbookFrame (final Client client) {
\r
71 this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client));
\r
73 // Set frame instance
\r
74 this.frame = new JFrame(AddressbookApplication.printableTitle());
\r
77 this.setClient(client);
\r
81 * Setups the frame, do not set isInitialized here
\r
83 * @param client Client instance
\r
86 public void setupFrame (final Client client) {
\r
88 this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client));
\r
90 // Has the user entered own data?
\r
91 if (this.getClient().getContactManager().isOwnContactAdded()) {
\r
93 this.getLogger().debug("Disabling menus: isOwnContactAdded()=false");
\r
95 // Not entered yet, so enable menu
\r
96 //addOwnData.setEnabled(false);
\r
100 //statusLabel.setText(bundle.getString("AddressbookFrame.status.done.text"));
\r
104 * Initalizes this frame. Having initComponents() exposed (publicly
\r
105 * accessible) means that any other object can initialize components which
\r
106 * you may not want.
\r
108 * @throws org.mxchange.addressbook.FrameAlreadyInitializedException If this method has been called twice
\r
111 public void initFrame () throws FrameAlreadyInitializedException {
\r
113 this.getLogger().trace("CALLED!");
\r
115 // Has this frame been initialized?
\r
116 if (this.isInitialized()) {
\r
118 throw new FrameAlreadyInitializedException();
\r
122 this.initComponents();
\r
125 this.isInitialized = true;
\r
129 * Returns field isInitialized. This flag indicates whether this frame has been initialized or not.
\r
131 * @return Field isInitialized
\r
134 public final boolean isInitialized () {
\r
135 return this.isInitialized;
\r
139 * Initialize components
\r
141 private void initComponents () {
\r
143 this.getLogger().trace("CALLED!");
\r