From: David ‘Bombe’ Roden Date: Mon, 26 Jan 2009 23:50:21 +0000 (+0100) Subject: Add key store panel when a key store is loaded. X-Git-Url: https://git.pterodactylus.net/?p=jkeytool.git;a=commitdiff_plain;h=e5e4a88c5a229c289d3b43f0d0b1d4b4df91c9fb Add key store panel when a key store is loaded. --- diff --git a/src/net/pterodactylus/jkeytool/gui/swing/KeyStorePanel.java b/src/net/pterodactylus/jkeytool/gui/swing/KeyStorePanel.java new file mode 100644 index 0000000..4496318 --- /dev/null +++ b/src/net/pterodactylus/jkeytool/gui/swing/KeyStorePanel.java @@ -0,0 +1,92 @@ +/* + * jkeytool - KeyStorePanel.java - + * Copyright © 2009 David Roden + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package net.pterodactylus.jkeytool.gui.swing; + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.security.KeyStore; + +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.JPanel; +import javax.swing.JToolBar; + +/** + * TODO + * + * @author David Roden <droden@gmail.com> + */ +public class KeyStorePanel extends JPanel { + + /** The displayed key store. */ + private final KeyStore keyStore; + + /** The tool bar. */ + private final JToolBar toolBar = new JToolBar(); + + /** The action to create a new key. */ + private Action createKeyAction; + + /** + * Creates a new key store panel that displays and controls the given key + * store. + * + * @param keyStore + * The key store to display + */ + public KeyStorePanel(KeyStore keyStore) { + super(new BorderLayout()); + this.keyStore = keyStore; + constructActions(); + constructPanel(); + } + + // + // PRIVATE ACTIONS + // + + private void createKey() { + + } + + // + // PRIVATE METHODS + // + + private void constructActions() { + createKeyAction = new AbstractAction("Create Key") { + + /** + * {@inheritDoc} + */ + @SuppressWarnings("synthetic-access") + public void actionPerformed(ActionEvent actionEvent) { + createKey(); + } + }; + } + + private void constructPanel() { + toolBar.add(createKeyAction); + + add(toolBar, BorderLayout.PAGE_START); + } + +} diff --git a/src/net/pterodactylus/jkeytool/gui/swing/SwingInterface.java b/src/net/pterodactylus/jkeytool/gui/swing/SwingInterface.java index 39506e1..95c8f90 100644 --- a/src/net/pterodactylus/jkeytool/gui/swing/SwingInterface.java +++ b/src/net/pterodactylus/jkeytool/gui/swing/SwingInterface.java @@ -21,9 +21,14 @@ 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; /** * TODO @@ -35,6 +40,12 @@ public class SwingInterface implements Interface { /** The core to control. */ private Core core; + /** The main frame. */ + private JFrame mainFrame = new JFrame("jkeytool " + Main.getVersion()); + + /** Loaded key stores and their panels. */ + private final Map keyStores = new HashMap(); + // // INTERFACE Interface // @@ -53,7 +64,8 @@ public class SwingInterface implements Interface { * {@inheritDoc} */ public void start() { - /* TODO */ + mainFrame.setVisible(true); + core.loadKeyStore(new File("client.p12")); } /** @@ -78,7 +90,9 @@ public class SwingInterface implements Interface { * {@inheritDoc} */ public void keyStoreLoaded(File keyStoreFile, KeyStore keyStore) { - /* TODO */ + KeyStorePanel keyStorePanel = new KeyStorePanel(keyStore); + keyStores.put(keyStore, keyStorePanel); + mainFrame.getContentPane().add(keyStorePanel); } /**