import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
import java.io.File;
import java.security.KeyStore;
import java.util.HashMap;
/** Loaded key stores and their panels. */
private final Map<KeyStore, KeyStorePanel> keyStores = new HashMap<KeyStore, KeyStorePanel>();
+ /**
+ * Creates a new Swing interface.
+ */
public SwingInterface() {
createActions();
createFrame();
// ACTIONS
//
+ /**
+ * Creates a new key store.
+ */
private void createKeyStore() {
+ /* TODO */
}
+ /**
+ * Exits the application.
+ */
private void quit() {
System.exit(0);
}
// PRIVATE METHODS
//
+ /**
+ * Creates all used actions.
+ */
private void createActions() {
createKeyStoreAction = new I18nAction(i18n, "jkeytool.action.createKeyStore") {
};
}
+ /**
+ * Creates the application main frame.
+ */
private void createFrame() {
mainFrame.setJMenuBar(createMenubar());
mainFrame.getContentPane().add(createToolbar(), BorderLayout.PAGE_START);
mainFrame.getContentPane().add(createCenterPanel(), BorderLayout.CENTER);
mainFrame.getContentPane().add(statusBar, BorderLayout.PAGE_END);
mainFrame.pack();
+ mainFrame.addWindowListener(new WindowAdapter() {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @SuppressWarnings("synthetic-access")
+ public void windowClosing(WindowEvent windowEvent) {
+ quit();
+ }
+ });
}
+ /**
+ * Creates the central panel of the frame.
+ *
+ * @return The central panel of the frame
+ */
private JComponent createCenterPanel() {
JPanel centerPanel = new JPanel(new BorderLayout());
centerPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
return centerPanel;
}
+ /**
+ * Creates the menu bar of the frame.
+ *
+ * @return The menu bar of the frame
+ */
private JMenuBar createMenubar() {
JMenuBar menubar = new JMenuBar();
return menubar;
}
+ /**
+ * Creates the tool bar of the frame.
+ *
+ * @return The tool bar of the frame
+ */
private JToolBar createToolbar() {
JToolBar toolbar = new JToolBar();
* {@inheritDoc}
*/
public void keyStoreLoaded(File keyStoreFile, KeyStore keyStore) {
- KeyStorePanel keyStorePanel = new KeyStorePanel(keyStore);
+ KeyStorePanel keyStorePanel = new KeyStorePanel(i18n, keyStore);
keyStores.put(keyStore, keyStorePanel);
tabPane.addTab(keyStoreFile.getName(), keyStorePanel);
}