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