Add status bar.
[jkeytool.git] / src / net / pterodactylus / jkeytool / gui / swing / SwingInterface.java
index 388846d..3190c2a 100644 (file)
@@ -21,8 +21,15 @@ package net.pterodactylus.jkeytool.gui.swing;
 
 import java.io.File;
 import java.security.KeyStore;
+import java.util.HashMap;
+import java.util.Map;
 
+import javax.swing.JFrame;
+
+import net.pterodactylus.jkeytool.core.Core;
 import net.pterodactylus.jkeytool.gui.Interface;
+import net.pterodactylus.jkeytool.main.Main;
+import net.pterodactylus.util.swing.StatusBar;
 
 /**
  * TODO
@@ -31,14 +38,58 @@ import net.pterodactylus.jkeytool.gui.Interface;
  */
 public class SwingInterface implements Interface {
 
+       /** The core to control. */
+       private Core core;
+
+       /** The main frame. */
+       private JFrame mainFrame = new JFrame("jkeytool " + Main.getVersion());
+
+       /** The status bar. */
+       private StatusBar statusBar = new StatusBar();
+
+       /** Loaded key stores and their panels. */
+       private final Map<KeyStore, KeyStorePanel> keyStores = new HashMap<KeyStore, KeyStorePanel>();
+
+       public SwingInterface() {
+               createFrame();
+       }
+
+       //
+       // PRIVATE METHODS
+       //
+
+       private void createFrame() {
+               mainFrame.getContentPane().add(statusBar, BorderLayout.PAGE_END);
+               mainFrame.pack();
+       }
+
        //
        // INTERFACE Interface
        //
 
        /**
+        * Sets the core to control.
+        *
+        * @param core
+        *            The core to control
+        */
+       public void setCore(Core core) {
+               this.core = core;
+       }
+
+       /**
         * {@inheritDoc}
         */
        public void start() {
+               mainFrame.setVisible(true);
+               statusBar.setText("jkeytool startup complete.");
+               core.loadKeyStore(new File("client.p12"));
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void stop() {
                /* TODO */
        }
 
@@ -57,7 +108,8 @@ public class SwingInterface implements Interface {
         * {@inheritDoc}
         */
        public void keyStoreLoaded(File keyStoreFile, KeyStore keyStore) {
-               /* TODO */
+               KeyStorePanel keyStorePanel = new KeyStorePanel(keyStore);
+               keyStores.put(keyStore, keyStorePanel);
        }
 
        /**