95c8f9046b178c1cafc99a6e05bd3a6a62b45e0f
[jkeytool.git] / src / net / pterodactylus / jkeytool / gui / swing / SwingInterface.java
1 /*
2  * jkeytool - SwingInterface.java -
3  * Copyright © 2009 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 package net.pterodactylus.jkeytool.gui.swing;
21
22 import java.io.File;
23 import java.security.KeyStore;
24 import java.util.HashMap;
25 import java.util.Map;
26
27 import javax.swing.JFrame;
28
29 import net.pterodactylus.jkeytool.core.Core;
30 import net.pterodactylus.jkeytool.gui.Interface;
31 import net.pterodactylus.jkeytool.main.Main;
32
33 /**
34  * TODO
35  *
36  * @author David Roden <droden@gmail.com>
37  */
38 public class SwingInterface implements Interface {
39
40         /** The core to control. */
41         private Core core;
42
43         /** The main frame. */
44         private JFrame mainFrame = new JFrame("jkeytool " + Main.getVersion());
45
46         /** Loaded key stores and their panels. */
47         private final Map<KeyStore, KeyStorePanel> keyStores = new HashMap<KeyStore, KeyStorePanel>();
48
49         //
50         // INTERFACE Interface
51         //
52
53         /**
54          * Sets the core to control.
55          *
56          * @param core
57          *            The core to control
58          */
59         public void setCore(Core core) {
60                 this.core = core;
61         }
62
63         /**
64          * {@inheritDoc}
65          */
66         public void start() {
67                 mainFrame.setVisible(true);
68                 core.loadKeyStore(new File("client.p12"));
69         }
70
71         /**
72          * {@inheritDoc}
73          */
74         public void stop() {
75                 /* TODO */
76         }
77
78         //
79         // INTERFACE CoreListener
80         //
81
82         /**
83          * {@inheritDoc}
84          */
85         public void keyStoreCreated(KeyStore keyStore) {
86                 /* TODO */
87         }
88
89         /**
90          * {@inheritDoc}
91          */
92         public void keyStoreLoaded(File keyStoreFile, KeyStore keyStore) {
93                 KeyStorePanel keyStorePanel = new KeyStorePanel(keyStore);
94                 keyStores.put(keyStore, keyStorePanel);
95                 mainFrame.getContentPane().add(keyStorePanel);
96         }
97
98         /**
99          * {@inheritDoc}
100          */
101         public void keyStoreNotCreated(String keyStoreType, Throwable reason) {
102                 /* TODO */
103         }
104
105         /**
106          * {@inheritDoc}
107          */
108         public void keyStoreNotLoaded(File keyStoreFile) {
109                 /* TODO */
110         }
111
112 }