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.jcontacts.contact.Contact;
25 import org.mxchange.jcontacts.contact.gender.Gender;
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;
34 * @author Roland Haeder
36 public class SwingClient extends BaseAddressbookClient implements AddressbookClient {
39 * Swing frame instance
41 private final ClientFrame frame;
44 * Constructor with an Application instance.
46 * @param application Application instance
48 public SwingClient (final Application application) {
50 this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
52 // Set application instance
53 this.setApplication(application);
55 // Init frame instance
56 this.frame = AddressbookFrame.getSelfInstance(this);
59 this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
63 public void displayAddressBox (final Contact contact) {
64 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
68 public void displayNameBox (final Contact contact) {
69 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
73 public void displayOtherDataBox (final Contact contact) {
74 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
78 public void doChangeOwnAddressData (final Contact contact) {
79 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
83 public void doChangeOwnNameData (final Contact contact) {
84 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
88 public void doChangeOwnOtherData (final Contact contact) {
89 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
93 * Shows dialog to enter new contact
95 * @return Returns finished Contact instance
98 public Contact doEnterOwnData () {
100 this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
102 // Deligate this call to the frame
103 return this.frame.doEnterOwnData();
107 * Shuts down this client
110 public void doShutdown () throws SQLException, IOException {
112 this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
118 this.frame.doShutdown();
120 // TODO Add other shutdown stuff
122 this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
126 public void doUserMenuChoice () throws UnhandledUserChoiceException {
128 //* NOISY-DEBUG: */ this.getLogger().logTrace("CALLED!");
130 // Not implemented here
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
139 public Gender enterGender (final String message) {
140 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
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
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
154 * Returns a Swing menu item
156 * @param accessKey Key to access the menu
157 * @param text Text to show to user
159 * @return A SelectableMenuItem
162 public SelectableMenuItem getMenuItem (final char accessKey, final String text) {
164 this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
166 // Returns null as the menu is now no longer controlled here.
171 * Inizializes this client
174 public void init () {
176 this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
179 // Init contact manager here
180 this.initContactManager();
185 // Now start the frame
186 this.frame.setupFrame(this);
187 } catch (final FrameAlreadyInitializedException | IOException | SQLException ex) {
189 this.abortProgramWithException(ex);
193 this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
197 public void outputMessage (final String message) {
198 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
202 public void show (final Contact contact) {
203 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
207 public void showCurrentMenu () {
209 //* NOISY-DEBUG: */ this.getLogger().logTrace("CALLED!");
211 // Not implemented here
215 public void showEntry (final SelectableMenuItem item) {
216 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
220 public void showWelcome () {
222 this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
224 // Not implemented here
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
233 * Fills menu map with swing menus
236 protected void fillMenuMap () {
237 // Nothing to fill here as the Swing frame is handling this all
238 throw new UnsupportedOperationException("Not implemented."); //NOI18N