]> git.mxchange.org Git - addressbook-swing.git/blob - src/org/mxchange/addressbook/client/gui/SwingClient.java
0582aa8f5fbdec47ad6c9095c95a38a4be815741
[addressbook-swing.git] / src / org / mxchange / addressbook / client / gui / SwingClient.java
1 /*
2  * Copyright (C) 2016, 2017 Roland Häder
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.jcontacts.contact.Contact;
25 import org.mxchange.jcontacts.contact.title.PersonalTitle;
26 import org.mxchange.jcore.application.Application;
27 import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException;
28 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
29 import org.mxchange.jcoreswing.client.gui.ClientFrame;
30
31 /**
32  * A swing client
33  * <p>
34  * @author Roland Häder<roland@mxchange.org>
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          * <p>
46          * @param application Application instance
47          */
48         public SwingClient (final Application application) {
49                 // Debug message
50                 this.getLoggerBeanLocal().logTrace("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.getLoggerBeanLocal().logTrace("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 (final 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 (final 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 (final 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          * <p>
95          * @return Returns finished Contact instance
96          */
97         @Override
98         public Contact doEnterOwnData () {
99                 // Trace message
100                 this.getLoggerBeanLocal().logTrace("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.getLoggerBeanLocal().logTrace("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.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
123         }
124
125         @Override
126         public void doUserMenuChoice () throws UnhandledUserChoiceException {
127                 // Debug message
128                 //* NOISY-DEBUG: */ this.getLogger().logTrace("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 PersonalTitle enterPersonalTitle (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         /**
154          * Returns a Swing menu item
155          * <p>
156          * @param accessKey Key to access the menu
157          * @param text Text to show to user
158          * <p>
159          * @return A SelectableMenuItem
160          */
161         @Override
162         public SelectableMenuItem getMenuItem (final char accessKey, final String text) {
163                 // Debug message
164                 this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
165
166                 // Returns null as the menu is now no longer controlled here.
167                 return null;
168         }
169
170         /**
171          * Inizializes this client
172          */
173         @Override
174         public void init () {
175                 // Debug message
176                 this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
177
178                 try {
179                         // Init contact manager here
180                         this.initContactManager();
181
182                         // Init frame
183                         this.frame.init();
184
185                         // Now start the frame
186                         this.frame.setupFrame(this);
187                 } catch (final FrameAlreadyInitializedException | IOException | SQLException ex) {
188                         // Abort program
189                         this.abortProgramWithException(ex);
190                 }
191
192                 // Debug message
193                 this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
194         }
195
196         @Override
197         public void outputMessage (final String message) {
198                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
199         }
200
201         @Override
202         public void show (final Contact contact) {
203                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
204         }
205
206         @Override
207         public void showCurrentMenu () {
208                 // Debug message
209                 //* NOISY-DEBUG: */ this.getLogger().logTrace("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.getLoggerBeanLocal().logTrace("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 void fillMenuMap () {
237                 // Nothing to fill here as the Swing frame is handling this all
238                 throw new UnsupportedOperationException("Not implemented."); //NOI18N
239         }
240 }