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