-/*
- * 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
-}
+/*\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 javax.swing.JFrame;\r
+import org.mxchange.addressbook.BaseFrameworkSystem;\r
+import org.mxchange.addressbook.FrameAlreadyInitializedException;\r
+import org.mxchange.addressbook.application.AddressbookApplication;\r
+import org.mxchange.addressbook.client.Client;\r
+\r
+/**\r
+ *\r
+ * @author Roland Haeder\r
+ */\r
+public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame {\r
+\r
+ /**\r
+ * Own instance\r
+ */\r
+ private static ClientFrame self;\r
+\r
+ /**\r
+ * Singelton getter for this frame instance.\r
+ *\r
+ * @param client Client instance\r
+ * @return Returns a singelton instance of this frame\r
+ */\r
+ public static final ClientFrame getSelfInstance (final Client client) {\r
+ // Is it set?\r
+ if (!(self instanceof ClientFrame)) {\r
+ // Create new instance\r
+ self = new AddressbookFrame(client);\r
+ }\r
+ \r
+ // Return instance\r
+ return self;\r
+ }\r
+\r
+ /**\r
+ * Frame instance\r
+ */\r
+ private final JFrame frame;\r
+\r
+ /**\r
+ * Whether this frame has been initialized\r
+ */\r
+ private boolean isInitialized;\r
+\r
+ /**\r
+ * Creates an instance of this frame with a client instance\r
+ * @param client\r
+ */\r
+ private AddressbookFrame (final Client client) {\r
+ // Debug line\r
+ this.getLogger().debug("Initializing Swing frame ...");\r
+\r
+ // Set frame instance\r
+ this.frame = new JFrame(AddressbookApplication.printableTitle());\r
+\r
+ // Set client here\r
+ this.setClient(client);\r
+ }\r
+\r
+ @Override\r
+ public void setVisible (final boolean visible) {\r
+ throw new UnsupportedOperationException("Not supported yet.");\r
+ }\r
+\r
+ /**\r
+ * Setups the frame\r
+ * \r
+ * @param client Client instance\r
+ */\r
+ @Override\r
+ public void setupFrame (final Client client) {\r
+ // Has the user entered own data?\r
+ if (this.getClient().getContactManager().isOwnContactAdded()) {\r
+ // Debug message\r
+ this.getLogger().debug("Disabling menus: isOwnContactAdded()=false");\r
+\r
+ // Not entered yet, so enable menu\r
+ //addOwnData.setEnabled(false);\r
+ }\r
+\r
+ // All done here\r
+ //statusLabel.setText(bundle.getString("AddressbookFrame.status.done.text"));\r
+ }\r
+\r
+ /**\r
+ * Initalizes this frame. Having initComponents() exposed (publicly\r
+ * accessible) means that any other object can initialize components which\r
+ * you may not want.\r
+ * \r
+ * @throws org.mxchange.addressbook.FrameAlreadyInitializedException If this method has been called twice\r
+ */\r
+ @Override\r
+ public void initFrame () throws FrameAlreadyInitializedException {\r
+ // Has this frame been initialized?\r
+ if (this.isInitialized) {\r
+ // Throw exception\r
+ throw new FrameAlreadyInitializedException();\r
+ }\r
+\r
+ // Init components\r
+ this.initComponents();\r
+\r
+ // Set flag\r
+ this.isInitialized = true;\r
+ }\r
+\r
+ /**\r
+ * Initialize components\r
+ */\r
+ private void initComponents () {\r
+ }\r
+\r
+}\r