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.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.jswingcore.client.gui.ClientFrame;
33 * @author Roland Haeder
35 public class SwingClient extends BaseAddressbookClient implements AddressbookClient {
38 * Swing frame instance
40 private final ClientFrame frame;
43 * Constructor with an Application instance.
45 * @param application Application instance
47 public SwingClient (final Application application) {
49 this.getLogger().trace("CALLED!"); //NOI18N
51 // Set application instance
52 this.setApplication(application);
54 // Init frame instance
55 this.frame = AddressbookFrame.getSelfInstance(this);
58 this.getLogger().trace("EXIT!"); //NOI18N
62 public void displayAddressBox (final Contact contact) {
63 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
67 public void displayNameBox (final Contact contact) {
68 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
72 public void displayOtherDataBox (final Contact contact) {
73 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
77 public void doChangeOwnAddressData (final Contact contact) {
78 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
82 public void doChangeOwnNameData (final Contact contact) {
83 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
87 public void doChangeOwnOtherData (final Contact contact) {
88 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
92 * Shows dialog to enter new contact
94 * @return Returns finished Contact instance
97 public Contact doEnterOwnData () {
99 this.getLogger().trace("CALLED!"); //NOI18N
101 // Deligate this call to the frame
102 return this.frame.doEnterOwnData();
106 * Shuts down this client
109 public void doShutdown () throws SQLException, IOException {
111 this.getLogger().trace("CALLED!"); //NOI18N
117 this.frame.doShutdown();
119 // TODO Add other shutdown stuff
121 this.getLogger().trace("EXIT!"); //NOI18N
125 public void doUserMenuChoice () throws UnhandledUserChoiceException {
127 //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
129 // Not implemented here
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
138 public Gender enterGender (final String message) {
139 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
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
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
153 * Returns a Swing menu item
155 * @param accessKey Key to access the menu
156 * @param text Text to show to user
157 * @return A SelectableMenuItem
160 public SelectableMenuItem getMenuItem (final char accessKey, final String text) {
162 this.getLogger().trace("CALLED!"); //NOI18N
164 // Returns null as the menu is now no longer controlled here.
169 * Inizializes this client
172 public void init () {
174 this.getLogger().trace("CALLED!"); //NOI18N
177 // Init contact manager here
178 this.initContactManager();
183 // Now start the frame
184 this.frame.setupFrame(this);
185 } catch (final FrameAlreadyInitializedException | IOException | SQLException ex) {
187 this.abortProgramWithException(ex);
191 this.getLogger().trace("EXIT!"); //NOI18N
195 public void outputMessage (final String message) {
196 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
200 public void showCurrentMenu () {
202 //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
204 // Not implemented here
208 public void showEntry (final SelectableMenuItem item) {
209 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
213 public void showWelcome () {
215 this.getLogger().trace("CALLED!"); //NOI18N
217 // Not implemented here
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
226 * Fills menu map with swing menus
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