]> git.mxchange.org Git - jaddressbook-lib.git/blob - Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java
Added 'final' keyword to getters/setters as it makes no sense overwriting them.
[jaddressbook-lib.git] / Addressbook / src / org / mxchange / addressbook / client / gui / AddressbookFrame.java
1 /*\r
2  * Copyright (C) 2015 Roland Haeder\r
3  *\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
8  *\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
13  *\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
16  */\r
17 package org.mxchange.addressbook.client.gui;\r
18 \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
25 \r
26 /**\r
27  *\r
28  * @author Roland Haeder\r
29  */\r
30 public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame {\r
31 \r
32     /**\r
33      * Own instance\r
34      */\r
35     private static ClientFrame self;\r
36 \r
37     /**\r
38      * Singelton getter for this frame instance.\r
39      *\r
40      * @param client Client instance\r
41      * @return Returns a singelton instance of this frame\r
42      */\r
43     public static final ClientFrame getSelfInstance (final Client client) {\r
44         // Is it set?\r
45         if (!(self instanceof ClientFrame)) {\r
46             // Create new instance\r
47             self = new AddressbookFrame(client);\r
48         }\r
49         \r
50         // Return instance\r
51         return self;\r
52     }\r
53 \r
54     /**\r
55      * Frame instance\r
56      */\r
57     private final JFrame frame;\r
58 \r
59     /**\r
60      * Whether this frame has been initialized\r
61      */\r
62     private boolean isInitialized;\r
63 \r
64     /**\r
65      * Creates an instance of this frame with a client instance\r
66      * \r
67      * @param client\r
68      */\r
69     private AddressbookFrame (final Client client) {\r
70         // Debug line\r
71         this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client));\r
72 \r
73         // Set frame instance\r
74         this.frame = new JFrame(AddressbookApplication.printableTitle());\r
75 \r
76         // Set client here\r
77         this.setClient(client);\r
78     }\r
79 \r
80     /**\r
81      * Setups the frame, do not set isInitialized here\r
82      * \r
83      * @param client Client instance\r
84      */\r
85     @Override\r
86     public void setupFrame (final Client client) {\r
87         // Debug line\r
88         this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client));\r
89 \r
90         // Has the user entered own data?\r
91         if (this.getClient().getContactManager().isOwnContactAdded()) {\r
92             // Debug message\r
93             this.getLogger().debug("Disabling menus: isOwnContactAdded()=false");\r
94 \r
95             // Not entered yet, so enable menu\r
96             //addOwnData.setEnabled(false);\r
97         }\r
98 \r
99         // All done here\r
100         //statusLabel.setText(bundle.getString("AddressbookFrame.status.done.text"));\r
101     }\r
102 \r
103     /**\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
107      * \r
108      * @throws org.mxchange.addressbook.FrameAlreadyInitializedException If this method has been called twice\r
109      */\r
110     @Override\r
111     public void initFrame () throws FrameAlreadyInitializedException {\r
112         // Debug line\r
113         this.getLogger().trace("CALLED!");\r
114 \r
115         // Has this frame been initialized?\r
116         if (this.isInitialized()) {\r
117             // Throw exception\r
118             throw new FrameAlreadyInitializedException();\r
119         }\r
120 \r
121         // Init components\r
122         this.initComponents();\r
123 \r
124         // Set flag\r
125         this.isInitialized = true;\r
126     }\r
127 \r
128     /**\r
129      * Returns field isInitialized. This flag indicates whether this frame has been initialized or not.\r
130      * \r
131      * @return Field isInitialized\r
132      */\r
133     @Override\r
134     public final boolean isInitialized () {\r
135         return this.isInitialized;\r
136     }\r
137 \r
138     /**\r
139      * Initialize components\r
140      */\r
141     private void initComponents () {\r
142         // Debug line\r
143         this.getLogger().trace("CALLED!");\r
144     }\r
145 \r
146 }\r