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