Show key store type in key store panel.
[jkeytool.git] / src / net / pterodactylus / jkeytool / gui / swing / KeyStorePanel.java
1 /*
2  * jkeytool - KeyStorePanel.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.awt.GridBagConstraints;
23 import java.awt.GridBagLayout;
24 import java.awt.Insets;
25 import java.security.KeyStore;
26
27 import javax.swing.BorderFactory;
28 import javax.swing.JPanel;
29 import javax.swing.JTextField;
30
31 import net.pterodactylus.util.i18n.I18n;
32 import net.pterodactylus.util.i18n.gui.I18nLabel;
33
34 /**
35  * TODO
36  *
37  * @author David Roden <droden@gmail.com>
38  */
39 public class KeyStorePanel extends JPanel {
40
41         /** The I18n container. */
42         private final I18n i18n;
43
44         /** The displayed key store. */
45         private final KeyStore keyStore;
46
47         /**
48          * Creates a new key store panel that displays and controls the given key
49          * store.
50          *
51          * @param i18n
52          *            The I18n container
53          * @param keyStore
54          *            The key store to display
55          */
56         public KeyStorePanel(I18n i18n, KeyStore keyStore) {
57                 super(new GridBagLayout());
58                 this.i18n = i18n;
59                 this.keyStore = keyStore;
60                 constructPanel();
61         }
62
63         //
64         // PRIVATE ACTIONS
65         //
66
67         //
68         // PRIVATE METHODS
69         //
70
71         /**
72          * Constructs the main panel.
73          */
74         private void constructPanel() {
75                 setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
76                 I18nLabel keyStoreTypeLabel = new I18nLabel(i18n, "jkeytool.keyStorePanel.keyStoreTypeLabel");
77                 JTextField keyStoreTypeTextField = new JTextField(keyStore.getType());
78                 keyStoreTypeTextField.setEditable(false);
79
80                 i18n.registerI18nable(keyStoreTypeLabel);
81
82                 add(keyStoreTypeLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
83                 add(keyStoreTypeTextField, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL, new Insets(0, 12, 0, 0), 0, 0));
84         }
85
86 }