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