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.sql.SQLException;
20 import org.mxchange.addressbook.client.AddressbookClient;
21 import org.mxchange.addressbook.client.BaseAddressbookClient;
22 import org.mxchange.addressbook.menu.Menu;
23 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
24 import org.mxchange.jcore.application.Application;
25 import org.mxchange.jcore.client.gui.ClientFrame;
26 import org.mxchange.jcore.contact.Contact;
27 import org.mxchange.jcore.contact.Gender;
28 import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException;
29 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
30 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
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.getLogger().trace("CALLED!"); //NOI18N
52 // Set application instance
53 this.setApplication(application);
55 // Init frame instance
56 this.frame = AddressbookFrame.getSelfInstance(this);
59 this.getLogger().trace("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 (Contact contact) {
79 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
83 public void doChangeOwnNameData (Contact contact) {
84 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
88 public void doChangeOwnOtherData (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.getLogger().trace("CALLED!"); //NOI18N
102 // Deligate this call to the frame
103 return this.frame.doEnterOwnData();
107 * Shuts down this client
110 public void doShutdown () {
112 this.getLogger().trace("CALLED!"); //NOI18N
118 this.frame.doShutdown();
120 // @TODO Add other shutdown stuff
122 this.getLogger().trace("EXIT!"); //NOI18N
126 public void doUserMenuChoice () throws UnhandledUserChoiceException {
128 //* NOISY-DEBUG: */ this.getLogger().trace("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 public Menu getMenu (final String menuType) {
155 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
159 * Returns a Swing menu item
161 * @param accessKey Key to access the menu
162 * @param text Text to show to user
163 * @return A SelectableMenuItem
166 public SelectableMenuItem getMenuItem (final char accessKey, final String text) {
168 this.getLogger().trace("CALLED!"); //NOI18N
170 // Returns null as the menu is now no longer controlled here.
175 * Inizializes this client
178 public void init () {
180 this.getLogger().trace("CALLED!"); //NOI18N
183 // Init contact manager here
184 this.initContactManager();
188 } catch (final FrameAlreadyInitializedException | UnsupportedDatabaseBackendException | SQLException ex) {
190 this.abortProgramWithException(ex);
193 // Now start the frame
194 this.frame.setupFrame(this);
197 this.getLogger().trace("EXIT!"); //NOI18N
201 public void outputMessage (final String message) {
202 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
206 public void showCurrentMenu () {
208 //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
210 // Not implemented here
214 public void showEntry (final SelectableMenuItem item) {
215 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
219 public void showWelcome () {
221 this.getLogger().trace("CALLED!"); //NOI18N
223 // Not implemented here
227 public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException {
228 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
232 * Fills menu map with swing menus
235 protected final void fillMenuMap () {
236 // Nothing to fill here as the Swing frame is handling this all
237 throw new UnsupportedOperationException("Not implemented."); //NOI18N