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.FrameAlreadyInitializedException;
30 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
31 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
35 * @author Roland Haeder
37 public class SwingClient extends BaseAddressbookClient implements AddressbookClient {
40 * Swing frame instance
42 private final ClientFrame frame;
45 * Constructor with an Application instance.
47 * @param application Application instance
49 public SwingClient (final Application application) {
51 this.getLogger().trace("CALLED!"); //NOI18N
53 // Set application instance
54 this.setApplication(application);
56 // Init frame instance
57 this.frame = AddressbookFrame.getSelfInstance(this);
60 this.getLogger().trace("EXIT!"); //NOI18N
64 public void displayAddressBox (final Contact contact) {
65 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
69 public void displayNameBox (final Contact contact) {
70 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
74 public void displayOtherDataBox (final Contact contact) {
75 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
79 public void doChangeOwnAddressData (Contact contact) {
80 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
84 public void doChangeOwnNameData (Contact contact) {
85 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
89 public void doChangeOwnOtherData (Contact contact) {
90 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
94 * Shows dialog to enter new contact
96 * @return Returns finished Contact instance
99 public Contact doEnterOwnData () {
101 this.getLogger().trace("CALLED!"); //NOI18N
103 // Deligate this call to the frame
104 return this.frame.doEnterOwnData();
108 * Shuts down this client
111 public void doShutdown () throws SQLException, IOException {
113 this.getLogger().trace("CALLED!"); //NOI18N
119 this.frame.doShutdown();
121 // @TODO Add other shutdown stuff
123 this.getLogger().trace("EXIT!"); //NOI18N
127 public void doUserMenuChoice () throws UnhandledUserChoiceException {
129 //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
131 // Not implemented here
135 public char enterChar (final char[] validChars, String message) {
136 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
140 public Gender enterGender (final String message) {
141 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
145 public int enterInt (final int minimum, final int maximum, final String message) {
146 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
150 public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty) {
151 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
155 public Menu getMenu (final String menuType) {
156 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
160 * Returns a Swing menu item
162 * @param accessKey Key to access the menu
163 * @param text Text to show to user
164 * @return A SelectableMenuItem
167 public SelectableMenuItem getMenuItem (final char accessKey, final String text) {
169 this.getLogger().trace("CALLED!"); //NOI18N
171 // Returns null as the menu is now no longer controlled here.
176 * Inizializes this client
179 public void init () {
181 this.getLogger().trace("CALLED!"); //NOI18N
184 // Init contact manager here
185 this.initContactManager();
189 } catch (final FrameAlreadyInitializedException | UnsupportedDatabaseBackendException | SQLException ex) {
191 this.abortProgramWithException(ex);
194 // Now start the frame
195 this.frame.setupFrame(this);
198 this.getLogger().trace("EXIT!"); //NOI18N
202 public void outputMessage (final String message) {
203 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
207 public void showCurrentMenu () {
209 //* NOISY-DEBUG: */ this.getLogger().trace("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.getLogger().trace("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 final void fillMenuMap () {
237 // Nothing to fill here as the Swing frame is handling this all
238 throw new UnsupportedOperationException("Not implemented."); //NOI18N