import org.apache.logging.log4j.Logger;\r
import org.mxchange.addressbook.application.Application;\r
import org.mxchange.addressbook.client.Client;\r
-import org.mxchange.addressbook.manager.contact.ContactManager;\r
import org.mxchange.addressbook.manager.contact.ManageableContact;\r
\r
/**\r
* @return the application\r
*/\r
@Override\r
- public Application getApplication () {\r
+ public final Application getApplication () {\r
return this.application;\r
}\r
\r
* @return the client\r
*/\r
@Override\r
- public Client getClient () {\r
+ public final Client getClient () {\r
return this.client;\r
}\r
\r
* @return the contactManager\r
*/\r
@Override\r
- public ManageableContact getContactManager () {\r
+ public final ManageableContact getContactManager () {\r
return this.contactManager;\r
}\r
\r
* Contact manager instance\r
* @param contactManager the contactManager to set\r
*/\r
- protected void setContactManager (final ManageableContact contactManager) {\r
+ protected final void setContactManager (final ManageableContact contactManager) {\r
this.contactManager = contactManager;\r
}\r
\r
* Client instance\r
* @param client the client to set\r
*/\r
- protected void setClient (final Client client) {\r
+ protected final void setClient (final Client client) {\r
this.client = client;\r
}\r
\r
*\r
* @param application the application to set\r
*/\r
- protected void setApplication(final Application application) {\r
+ protected final void setApplication(final Application application) {\r
this.application = application;\r
}\r
\r
*\r
* @return Logger\r
*/\r
- protected Logger getLogger () {\r
+ protected final Logger getLogger () {\r
return this.LOG;\r
}\r
\r
* \r
* @return the tableName\r
*/\r
- protected String getTableName () {\r
+ protected final String getTableName () {\r
return this.tableName;\r
}\r
\r
* \r
* @param tableName the tableName to set\r
*/\r
- protected void setTableName (final String tableName) {\r
+ protected final void setTableName (final String tableName) {\r
this.tableName = tableName;\r
}\r
-\r
- /**\r
- * Initializes contact manager\r
- * \r
- * @param client Client instance\r
- */\r
- protected void initContactManager (final Client client) {\r
- // Debug message\r
- this.getLogger().debug("Initializing contact manager ...");\r
- \r
- // Init contact manager with console client\r
- // @TODO Static initial amount of contacts\r
- ManageableContact manager = new ContactManager (100, client);\r
- \r
- // Set it here\r
- this.setContactManager(manager);\r
- \r
- // Debug message\r
- this.getLogger().debug("Contact manager has been initialized.");\r
- }\r
}\r
this.getLogger().error("No client choosen. Cannot launch.");\r
System.exit(1);\r
}\r
- \r
+\r
+ // Init client\r
+ client.initClient();\r
+\r
// Set client instance\r
this.setClient(client);\r
\r
import java.util.HashMap;\r
import java.util.Map;\r
import org.mxchange.addressbook.BaseFrameworkSystem;\r
+import org.mxchange.addressbook.manager.contact.ContactManager;\r
+import org.mxchange.addressbook.manager.contact.ManageableContact;\r
import org.mxchange.addressbook.menu.Menu;\r
\r
/**\r
// Show menu\r
menu.show((Client) this);\r
}\r
+\r
+ /**\r
+ * Initializes contact manager\r
+ */\r
+ protected void initContactManager () {\r
+ // Debug message\r
+ this.getLogger().debug("Initializing contact manager ...");\r
+ \r
+ // Init contact manager with console client\r
+ // @TODO Static initial amount of contacts\r
+ ManageableContact manager = new ContactManager (100, (Client) this);\r
+ \r
+ // Set it here\r
+ this.setContactManager(manager);\r
+ \r
+ // Debug message\r
+ this.getLogger().debug("Contact manager has been initialized.");\r
+ }\r
}\r
* Shows current menu selection to the user\r
*/\r
public void showCurrentMenu();\r
+\r
+ /**\r
+ * Inizializes this client\r
+ */\r
+ public void initClient ();\r
}\r
// Set application instance\r
this.setApplication(application);\r
\r
- // Init contact manager here\r
- this.initContactManager(this);\r
-\r
// Init scanner instance\r
this.scanner = new Scanner(System.in);\r
-\r
- // Fill menu map\r
- this.fillMenuMap();\r
}\r
\r
/**\r
@Override\r
public void displayAddressBox (final Contact contact) {\r
// Simple display ...\r
- // @todo Use mask\r
+ // @todo Use mask\r
this.outputMessage("Strasse, PLZ Ort, Land: " + contact.getStreet() + "\n" + contact.getZipCode() + " " + contact.getCity() + "\n" + contact.getCountryCode());\r
}\r
\r
return new ConsoleMenuItem(accessKey,text);\r
}\r
\r
+ /**\r
+ * Inizializes this client\r
+ */\r
+ @Override\r
+ public void initClient () {\r
+ // Init contact manager here\r
+ this.initContactManager();\r
+ \r
+ // Fill menu map\r
+ this.fillMenuMap();\r
+ }\r
+\r
/**\r
* Displays textural message to the user\r
* @param message\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="3"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <EmptySpace min="0" pref="400" max="32767" attributes="0"/>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <EmptySpace min="0" pref="300" max="32767" attributes="0"/>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+</Form>
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.client.gui;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.mxchange.addressbook.application.Application;
+import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.manager.contact.ManageableContact;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public class AddressbookFrame extends javax.swing.JFrame implements ClientFrame {
+ /**
+ * Class' logger
+ */
+ private final Logger LOG;
+
+ /**
+ * Client instance
+ */
+ private final Client client;
+
+ /**
+ * Initialize object
+ */
+ {
+ LOG = LogManager.getLogger(this);
+ }
+
+ /**
+ * Creates an instance of this frame with a client instance
+ * @param client
+ */
+ public AddressbookFrame (final Client client) {
+ // Debug line
+ this.getLogger().debug("Initializing Swing frame ...");
+
+ // Init components
+ initComponents();
+
+ // Set client here
+ this.client = client;
+ }
+
+ @Override
+ public Application getApplication () {
+ throw new UnsupportedOperationException("Not implemented.");
+ }
+
+ @Override
+ public final Client getClient () {
+ return this.client;
+ }
+
+ @Override
+ public ManageableContact getContactManager () {
+ throw new UnsupportedOperationException("Not implemented.");
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ @SuppressWarnings ("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 400, Short.MAX_VALUE)
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 300, Short.MAX_VALUE)
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ /**
+ * Initializes the frame
+ */
+ @Override
+ public void initFrame (final Client client) {
+ /*
+ * Set the Nimbus look and feel
+ */
+ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
+ /*
+ * If Nimbus (introduced in Java SE 6) is not available, stay with the
+ * default look and feel. For details see
+ * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
+ */
+ try {
+ for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ javax.swing.UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (final ClassNotFoundException ex) {
+ this.getLogger().catching(ex);
+ } catch (final InstantiationException ex) {
+ this.getLogger().catching(ex);
+ } catch (final IllegalAccessException ex) {
+ this.getLogger().catching(ex);
+ } catch (final javax.swing.UnsupportedLookAndFeelException ex) {
+ this.getLogger().catching(ex);
+ }
+ //</editor-fold>
+
+ // Debug line
+ this.getLogger().debug("Displaying form ...");
+
+ /*
+ * Create and display the form
+ */
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ @Override
+ public void run () {
+ new AddressbookFrame(client).setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Getter for logger
+ *
+ * @return Logger
+ */
+ protected final Logger getLogger () {
+ return this.LOG;
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ // End of variables declaration//GEN-END:variables
+}
--- /dev/null
+/*\r
+ * Copyright (C) 2015 Roland Haeder\r
+ *\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+ */\r
+package org.mxchange.addressbook.client.gui;\r
+\r
+import org.mxchange.addressbook.FrameworkInterface;\r
+import org.mxchange.addressbook.client.Client;\r
+\r
+/**\r
+ *\r
+ * @author Roland Haeder\r
+ */\r
+public interface ClientFrame extends FrameworkInterface {\r
+ /**\r
+ * Initializes the frame\r
+ * \r
+ * @param client Client instance\r
+ */\r
+ public void initFrame (final Client client);\r
+}\r
* @author Roland Haeder\r
*/\r
public class SwingClient extends BaseClient implements Client {\r
+ /**\r
+ * Swing frame instance\r
+ */\r
+ private final ClientFrame frame;\r
+\r
/**\r
* Constructor with application instance\r
* @param application \r
// Set application instance\r
this.setApplication(application);\r
\r
- // Init contact manager here\r
- this.initContactManager(this);\r
+ // Init frame instance\r
+ this.frame = new AddressbookFrame(this);\r
}\r
\r
@Override\r
return null;\r
}\r
\r
+ /**\r
+ * Inizializes this client\r
+ */\r
+ @Override\r
+ public void initClient () {\r
+ // Init contact manager here\r
+ this.initContactManager();\r
+ \r
+ // Now start the frame\r
+ this.frame.initFrame(this);\r
+ }\r
+\r
@Override\r
public void outputMessage (final String message) {\r
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r