2 * Copyright (C) 2015 Roland Haeder
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.
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.
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/>.
17 package org.mxchange.addressbook.client.gui;
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.BadTokenException;
30 import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException;
31 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
32 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
36 * @author Roland Haeder
38 public class SwingClient extends BaseAddressbookClient implements AddressbookClient {
41 * Swing frame instance
43 private final ClientFrame frame;
46 * Constructor with an Application instance.
48 * @param application Application instance
50 public SwingClient (final Application application) {
52 this.getLogger().trace("CALLED!"); //NOI18N
54 // Set application instance
55 this.setApplication(application);
57 // Init frame instance
58 this.frame = AddressbookFrame.getSelfInstance(this);
61 this.getLogger().trace("EXIT!"); //NOI18N
65 public void displayAddressBox (final Contact contact) {
66 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
70 public void displayNameBox (final Contact contact) {
71 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
75 public void displayOtherDataBox (final Contact contact) {
76 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
80 public void doChangeOwnAddressData (Contact contact) {
81 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
85 public void doChangeOwnNameData (Contact contact) {
86 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
90 public void doChangeOwnOtherData (Contact contact) {
91 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
95 * Shows dialog to enter new contact
97 * @return Returns finished Contact instance
100 public Contact doEnterOwnData () {
102 this.getLogger().trace("CALLED!"); //NOI18N
104 // Deligate this call to the frame
105 return this.frame.doEnterOwnData();
109 * Shuts down this client
112 public void doShutdown () throws SQLException, IOException {
114 this.getLogger().trace("CALLED!"); //NOI18N
120 this.frame.doShutdown();
122 // @TODO Add other shutdown stuff
124 this.getLogger().trace("EXIT!"); //NOI18N
128 public void doUserMenuChoice () throws UnhandledUserChoiceException {
130 //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
132 // Not implemented here
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
141 public Gender enterGender (final String message) {
142 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
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
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
156 public Menu getMenu (final String menuType) {
157 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
161 * Returns a Swing menu item
163 * @param accessKey Key to access the menu
164 * @param text Text to show to user
165 * @return A SelectableMenuItem
168 public SelectableMenuItem getMenuItem (final char accessKey, final String text) {
170 this.getLogger().trace("CALLED!"); //NOI18N
172 // Returns null as the menu is now no longer controlled here.
177 * Inizializes this client
180 public void init () {
182 this.getLogger().trace("CALLED!"); //NOI18N
185 // Init contact manager here
186 this.initContactManager();
191 // Now start the frame
192 this.frame.setupFrame(this);
193 } catch (final FrameAlreadyInitializedException | UnsupportedDatabaseBackendException | IOException | BadTokenException | SQLException ex) {
195 this.abortProgramWithException(ex);
199 this.getLogger().trace("EXIT!"); //NOI18N
203 public void outputMessage (final String message) {
204 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
208 public void showCurrentMenu () {
210 //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
212 // Not implemented here
216 public void showEntry (final SelectableMenuItem item) {
217 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
221 public void showWelcome () {
223 this.getLogger().trace("CALLED!"); //NOI18N
225 // Not implemented here
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
234 * Fills menu map with swing menus
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