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 org.mxchange.jcore.client.gui.ClientFrame;
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.contact.Contact;
26 import org.mxchange.jcore.contact.Gender;
27 import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException;
28 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
32 * @author Roland Haeder
34 public class SwingClient extends BaseAddressbookClient implements AddressbookClient {
37 * Swing frame instance
39 private final ClientFrame frame;
42 * Constructor with an Application instance.
44 * @param application Application instance
46 public SwingClient (final Application application) {
48 this.getLogger().trace("CALLED!"); //NOI18N
50 // Set application instance
51 this.setApplication(application);
53 // Init frame instance
54 this.frame = AddressbookFrame.getSelfInstance(this);
57 this.getLogger().trace("EXIT!"); //NOI18N
61 public void displayAddressBox (final Contact contact) {
62 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
66 public void displayNameBox (final Contact contact) {
67 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
71 public void displayOtherDataBox (final Contact contact) {
72 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
76 public void doChangeOwnAddressData (Contact contact) {
77 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
81 public void doChangeOwnNameData (Contact contact) {
82 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
86 public void doChangeOwnOtherData (Contact contact) {
87 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
91 * Shows dialog to enter new contact
93 * @return Returns finished Contact instance
96 public Contact doEnterOwnData () {
98 this.getLogger().trace("CALLED!"); //NOI18N
100 // Deligate this call to the frame
101 return this.frame.doEnterOwnData();
105 * Shuts down this client
108 public void doShutdown () {
110 this.getLogger().trace("CALLED!"); //NOI18N
116 this.frame.doShutdown();
118 // @TODO Add other shutdown stuff
120 this.getLogger().trace("EXIT!"); //NOI18N
124 public void doUserMenuChoice () throws UnhandledUserChoiceException {
126 //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
128 // Not implemented here
132 public char enterChar (final char[] validChars, String message) {
133 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
137 public Gender enterGender (final String message) {
138 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
142 public int enterInt (final int minimum, final int maximum, final String message) {
143 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
147 public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty) {
148 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
152 public Menu getMenu (final String menuType) {
153 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
157 * Returns a Swing menu item
159 * @param accessKey Key to access the menu
160 * @param text Text to show to user
161 * @return A SelectableMenuItem
164 public SelectableMenuItem getMenuItem (final char accessKey, final String text) {
166 this.getLogger().trace("CALLED!"); //NOI18N
168 // Returns null as the menu is now no longer controlled here.
173 * Inizializes this client
176 public void init () {
178 this.getLogger().trace("CALLED!"); //NOI18N
180 // Init contact manager here
181 this.initContactManager();
186 } catch (final FrameAlreadyInitializedException ex) {
188 this.abortProgramWithException(ex);
191 // Now start the frame
192 this.frame.setupFrame(this);
195 this.getLogger().trace("EXIT!"); //NOI18N
199 public void outputMessage (final String message) {
200 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
204 public void showCurrentMenu () {
206 //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
208 // Not implemented here
212 public void showEntry (final SelectableMenuItem item) {
213 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
217 public void showWelcome () {
219 this.getLogger().trace("CALLED!"); //NOI18N
221 // Not implemented here
225 public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException {
226 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
230 * Fills menu map with swing menus
233 protected final void fillMenuMap () {
234 // Nothing to fill here as the Swing frame is handling this all
235 throw new UnsupportedOperationException("Not implemented."); //NOI18N