X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=Addressbook%2Fsrc%2Forg%2Fmxchange%2Faddressbook%2Fclient%2Fgui%2FSwingClient.java;h=2ad4ae2d7e663d9dc103402ce49ac1ded43fa870;hb=91cb2af9da0780bc179059728c4aef2b8b5949b0;hp=87686e9ecbbbd5d5f7532d9be766b7c9699cb88c;hpb=e92fd10e2b96699c4421caf64d1db53cfd5e3524;p=jaddressbook-lib.git diff --git a/Addressbook/src/org/mxchange/addressbook/client/gui/SwingClient.java b/Addressbook/src/org/mxchange/addressbook/client/gui/SwingClient.java index 87686e9e..2ad4ae2d 100644 --- a/Addressbook/src/org/mxchange/addressbook/client/gui/SwingClient.java +++ b/Addressbook/src/org/mxchange/addressbook/client/gui/SwingClient.java @@ -1,133 +1,240 @@ -/* - * Copyright (C) 2015 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.addressbook.client.gui; - -import org.mxchange.addressbook.UnhandledUserChoiceException; -import org.mxchange.addressbook.application.AddressbookApplication; -import org.mxchange.addressbook.client.BaseClient; -import org.mxchange.addressbook.client.Client; -import org.mxchange.addressbook.contact.Contact; -import org.mxchange.addressbook.menu.Menu; -import org.mxchange.addressbook.menu.item.SelectableMenuItem; - -/** - * - * @author Roland Haeder - */ -public class SwingClient extends BaseClient implements Client { - /** - * Constructor with application instance - * @param application - */ - public SwingClient (final AddressbookApplication application) { - super(); - - // Set application instance - this.setApplication(application); - - // Init contact manager here - this.initContactManager(this); - } - - @Override - public void displayAddressBox (final Contact contact) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public void displayNameBox (final Contact contact) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public void displayOtherDataBox (final Contact contact) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public void doUserMenuChoice () throws UnhandledUserChoiceException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public char enterChar (final char[] validChars, String message) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int enterInt (final int minimum, final int maximum, final String message) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Menu getMenu (final String menuType) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - /** - * Returns a Swing menu item - * - * @param accessKey Key to access the menu - * @param text Text to show to user - * @return A SelectableMenuItem - * @todo Make sure the access key is unique - */ - @Override - public SelectableMenuItem getMenuItem (final char accessKey, final String text) { - // Returns null as the menu is now no longer controlled here. - return null; - } - - @Override - public void outputMessage (final String message) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public void showCurrentMenu () { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public void showEntry (final SelectableMenuItem item) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public void showWelcome () { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - /** - * Fills menu map with swing menus - */ - @Override - protected final void fillMenuMap () { - // Nothing to fill here as the Swing frame is handling this all - throw new UnsupportedOperationException("Not implemented."); - } -} +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.addressbook.client.gui; + +import java.io.IOException; +import java.sql.SQLException; +import org.mxchange.addressbook.client.AddressbookClient; +import org.mxchange.addressbook.client.BaseAddressbookClient; +import org.mxchange.addressbook.menu.Menu; +import org.mxchange.addressbook.menu.item.SelectableMenuItem; +import org.mxchange.jcore.application.Application; +import org.mxchange.jcore.client.gui.ClientFrame; +import org.mxchange.jcore.contact.Contact; +import org.mxchange.jcore.contact.Gender; +import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException; +import org.mxchange.jcore.exceptions.UnhandledUserChoiceException; +import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException; + +/** + * + * @author Roland Haeder + */ +public class SwingClient extends BaseAddressbookClient implements AddressbookClient { + + /** + * Swing frame instance + */ + private final ClientFrame frame; + + /** + * Constructor with an Application instance. + * + * @param application Application instance + */ + public SwingClient (final Application application) { + // Debug message + this.getLogger().trace("CALLED!"); //NOI18N + + // Set application instance + this.setApplication(application); + + // Init frame instance + this.frame = AddressbookFrame.getSelfInstance(this); + + // Trace message + this.getLogger().trace("EXIT!"); //NOI18N + } + + @Override + public void displayAddressBox (final Contact contact) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N + } + + @Override + public void displayNameBox (final Contact contact) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N + } + + @Override + public void displayOtherDataBox (final Contact contact) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N + } + + @Override + public void doChangeOwnAddressData (Contact contact) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N + } + + @Override + public void doChangeOwnNameData (Contact contact) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N + } + + @Override + public void doChangeOwnOtherData (Contact contact) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N + } + + /** + * Shows dialog to enter new contact + * + * @return Returns finished Contact instance + */ + @Override + public Contact doEnterOwnData () { + // Trace message + this.getLogger().trace("CALLED!"); //NOI18N + + // Deligate this call to the frame + return this.frame.doEnterOwnData(); + } + + /** + * Shuts down this client + */ + @Override + public void doShutdown () throws SQLException, IOException { + // Debug message + this.getLogger().trace("CALLED!"); //NOI18N + + // Parent call + super.doShutdown(); + + // Shutdown frame + this.frame.doShutdown(); + + // @TODO Add other shutdown stuff + // Debug message + this.getLogger().trace("EXIT!"); //NOI18N + } + + @Override + public void doUserMenuChoice () throws UnhandledUserChoiceException { + // Debug message + //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!"); + + // Not implemented here + } + + @Override + public char enterChar (final char[] validChars, String message) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N + } + + @Override + public Gender enterGender (final String message) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N + } + + @Override + public int enterInt (final int minimum, final int maximum, final String message) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N + } + + @Override + public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N + } + + @Override + public Menu getMenu (final String menuType) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N + } + + /** + * Returns a Swing menu item + * + * @param accessKey Key to access the menu + * @param text Text to show to user + * @return A SelectableMenuItem + */ + @Override + public SelectableMenuItem getMenuItem (final char accessKey, final String text) { + // Debug message + this.getLogger().trace("CALLED!"); //NOI18N + + // Returns null as the menu is now no longer controlled here. + return null; + } + + /** + * Inizializes this client + */ + @Override + public void init () { + // Debug message + this.getLogger().trace("CALLED!"); //NOI18N + + try { + // Init contact manager here + this.initContactManager(); + + // Init frame + this.frame.init(); + } catch (final FrameAlreadyInitializedException | UnsupportedDatabaseBackendException | SQLException ex) { + // Abort program + this.abortProgramWithException(ex); + } + + // Now start the frame + this.frame.setupFrame(this); + + // Debug message + this.getLogger().trace("EXIT!"); //NOI18N + } + + @Override + public void outputMessage (final String message) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N + } + + @Override + public void showCurrentMenu () { + // Debug message + //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!"); + + // Not implemented here + } + + @Override + public void showEntry (final SelectableMenuItem item) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N + } + + @Override + public void showWelcome () { + // Debug message + this.getLogger().trace("CALLED!"); //NOI18N + + // Not implemented here + } + + @Override + public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N + } + + /** + * Fills menu map with swing menus + */ + @Override + protected final void fillMenuMap () { + // Nothing to fill here as the Swing frame is handling this all + throw new UnsupportedOperationException("Not implemented."); //NOI18N + } +}