]> git.mxchange.org Git - addressbook-lib.git/blob - Addressbook/src/org/mxchange/addressbook/client/gui/SwingClient.java
Introduced more methods + added first dialog call (yes, it is still visible by startu...
[addressbook-lib.git] / Addressbook / src / org / mxchange / addressbook / client / gui / SwingClient.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 org.mxchange.addressbook.application.Application;
20 import org.mxchange.addressbook.client.BaseClient;
21 import org.mxchange.addressbook.client.Client;
22 import org.mxchange.addressbook.contact.Contact;
23 import org.mxchange.addressbook.contact.Gender;
24 import org.mxchange.addressbook.exceptions.FrameAlreadyInitializedException;
25 import org.mxchange.addressbook.exceptions.UnhandledUserChoiceException;
26 import org.mxchange.addressbook.menu.Menu;
27 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
28
29 /**
30  *
31  * @author Roland Haeder
32  */
33 public class SwingClient extends BaseClient implements Client {
34
35         /**
36          * Swing frame instance
37          */
38         private final ClientFrame frame;
39
40         /**
41          * Constructor with an Application instance.
42          *
43          * @param application Application instance
44          */
45         public SwingClient (final Application application) {
46                 super();
47
48                 // Debug message
49                 this.getLogger().trace("CALLED!"); //NOI18N
50
51                 // Set application instance
52                 this.setApplication(application);
53
54                 // Init frame instance
55                 this.frame = AddressbookFrame.getSelfInstance(this);
56         }
57
58         @Override
59         public void displayAddressBox (final Contact contact) {
60                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
61         }
62
63         @Override
64         public void displayNameBox (final Contact contact) {
65                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
66         }
67
68         @Override
69         public void displayOtherDataBox (final Contact contact) {
70                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
71         }
72
73         @Override
74         public void doChangeOwnAddressData (Contact contact) {
75                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
76         }
77
78         @Override
79         public void doChangeOwnNameData (Contact contact) {
80                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
81         }
82
83         @Override
84         public void doChangeOwnOtherData (Contact contact) {
85                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
86         }
87
88         /**
89          * Shows dialog to enter new contact
90          *
91          * @return Returns finished Contact instance
92          */
93         @Override
94         public Contact doEnterOwnData () {
95                 // Deligate this call to the frame
96                 return this.frame.doEnterOwnData();
97         }
98
99         /**
100          * Shuts down this client
101          */
102         @Override
103         public void doShutdown () {
104                 // Debug message
105                 this.getLogger().trace("CALLED!"); //NOI18N
106
107                 // Parent call
108                 super.doShutdown();
109
110                 // Shutdown frame
111                 this.frame.doShutdown();
112
113                 // @TODO Add other shutdown stuff
114                 // Debug message
115                 this.getLogger().trace("EXIT!"); //NOI18N
116         }
117
118         @Override
119         public void doUserMenuChoice () throws UnhandledUserChoiceException {
120                 // Debug message
121                 //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
122
123                 // Not implemented here
124         }
125
126         @Override
127         public char enterChar (final char[] validChars, String message) {
128                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
129         }
130
131         @Override
132         public Gender enterGender (final String message) {
133                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
134         }
135
136         @Override
137         public int enterInt (final int minimum, final int maximum, final String message) {
138                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
139         }
140
141         @Override
142         public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty) {
143                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
144         }
145
146         @Override
147         public Menu getMenu (final String menuType) {
148                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
149         }
150
151         /**
152          * Returns a Swing menu item
153          *
154          * @param accessKey Key to access the menu
155          * @param text Text to show to user
156          * @return A SelectableMenuItem
157          */
158         @Override
159         public SelectableMenuItem getMenuItem (final char accessKey, final String text) {
160                 // Debug message
161                 this.getLogger().trace("CALLED!"); //NOI18N
162
163                 // Returns null as the menu is now no longer controlled here.
164                 return null;
165         }
166
167         /**
168          * Inizializes this client
169          */
170         @Override
171         public void init () {
172                 // Debug message
173                 this.getLogger().trace("CALLED!"); //NOI18N
174
175                 // Init contact manager here
176                 this.initContactManager();
177
178                 try {
179                         // Init frame
180                         this.frame.init();
181                 } catch (final FrameAlreadyInitializedException ex) {
182                         this.getLogger().catching(ex);
183                         System.exit(1);
184                 }
185
186                 // Now start the frame
187                 this.frame.setupFrame(this);
188
189                 // Debug message
190                 this.getLogger().trace("EXIT!"); //NOI18N
191         }
192
193         @Override
194         public void outputMessage (final String message) {
195                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
196         }
197
198         @Override
199         public void showCurrentMenu () {
200         // Debug message
201                 //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
202
203                 // Not implemented here
204         }
205
206         @Override
207         public void showEntry (final SelectableMenuItem item) {
208                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
209         }
210
211         @Override
212         public void showWelcome () {
213                 // Debug message
214                 this.getLogger().trace("CALLED!"); //NOI18N
215
216                 // Not implemented here
217         }
218
219         @Override
220         public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException {
221                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
222         }
223
224         /**
225          * Fills menu map with swing menus
226          */
227         @Override
228         protected final void fillMenuMap () {
229                 // Nothing to fill here as the Swing frame is handling this all
230                 throw new UnsupportedOperationException("Not implemented."); //NOI18N
231         }
232 }