|
15 | 15 | import java.awt.event.MouseEvent;
|
16 | 16 |
|
17 | 17 |
|
18 |
| -public class KeyStoreCredentials extends JFrame { |
| 18 | +public class KeyStoreManager extends JFrame { |
19 | 19 | static final String GUIDE_URL =
|
20 | 20 | "http://developer.android.com/tools/publishing/app-signing.html#cert";
|
21 | 21 |
|
22 | 22 | Sketch sketch;
|
23 | 23 |
|
24 |
| - public KeyStoreCredentials(Sketch sketch) { |
| 24 | + public KeyStoreManager(Sketch sketch) { |
| 25 | + super("Android keystore manager"); |
25 | 26 | this.sketch = sketch;
|
26 | 27 |
|
27 | 28 | Container outer = getContentPane();
|
28 | 29 | Box pain = Box.createVerticalBox();
|
29 | 30 | pain.setBorder(new EmptyBorder(13, 13, 13, 13));
|
30 | 31 | outer.add(pain);
|
31 | 32 |
|
| 33 | + showKeystorePasswordLayout(pain); |
| 34 | + |
| 35 | + // buttons |
| 36 | + JPanel buttons = new JPanel(); |
| 37 | + buttons.setAlignmentX(LEFT_ALIGNMENT); |
| 38 | + JButton okButton = new JButton("OK"); |
| 39 | + Dimension dim = new Dimension(Preferences.BUTTON_WIDTH, |
| 40 | + okButton.getPreferredSize().height); |
| 41 | + okButton.setPreferredSize(dim); |
| 42 | + okButton.addActionListener(new ActionListener() { |
| 43 | + public void actionPerformed(ActionEvent e) { |
| 44 | + setVisible(false); |
| 45 | + } |
| 46 | + }); |
| 47 | + okButton.setEnabled(true); |
| 48 | + |
| 49 | + JButton cancelButton = new JButton("Cancel"); |
| 50 | + cancelButton.setPreferredSize(dim); |
| 51 | + cancelButton.addActionListener(new ActionListener() { |
| 52 | + public void actionPerformed(ActionEvent e) { |
| 53 | + setVisible(false); |
| 54 | + } |
| 55 | + }); |
| 56 | + cancelButton.setEnabled(true); |
| 57 | + |
| 58 | + // think different, biznatchios! |
| 59 | + if (Base.isMacOS()) { |
| 60 | + buttons.add(cancelButton); |
| 61 | +// buttons.add(Box.createHorizontalStrut(8)); |
| 62 | + buttons.add(okButton); |
| 63 | + } else { |
| 64 | + buttons.add(okButton); |
| 65 | +// buttons.add(Box.createHorizontalStrut(8)); |
| 66 | + buttons.add(cancelButton); |
| 67 | + } |
| 68 | +// buttons.setMaximumSize(new Dimension(300, buttons.getPreferredSize().height)); |
| 69 | + pain.add(buttons); |
| 70 | + |
| 71 | + JRootPane root = getRootPane(); |
| 72 | + root.setDefaultButton(okButton); |
| 73 | + ActionListener disposer = new ActionListener() { |
| 74 | + public void actionPerformed(ActionEvent actionEvent) { |
| 75 | + setVisible(false); |
| 76 | + } |
| 77 | + }; |
| 78 | + processing.app.Toolkit.registerWindowCloseKeys(root, disposer); |
| 79 | + processing.app.Toolkit.setIcon(this); |
| 80 | + |
| 81 | + pack(); |
| 82 | + |
| 83 | + Dimension screen = processing.app.Toolkit.getScreenSize(); |
| 84 | + Dimension windowSize = getSize(); |
| 85 | + |
| 86 | + setLocation((screen.width - windowSize.width) / 2, |
| 87 | + (screen.height - windowSize.height) / 2); |
| 88 | + |
| 89 | + setVisible(true); |
| 90 | + } |
| 91 | + |
| 92 | + private void showKeystorePasswordLayout(Box pain) { |
| 93 | + JPasswordField passwordField = new JPasswordField(15); |
| 94 | + JLabel passwordLabel = new JLabel("<html><body><b>Keystore password: </b></body></html>"); |
| 95 | + passwordLabel.setLabelFor(passwordField); |
| 96 | + |
| 97 | + JPanel textPane = new JPanel(new FlowLayout(FlowLayout.TRAILING)); |
| 98 | + textPane.add(passwordLabel); |
| 99 | + textPane.add(passwordField); |
| 100 | + textPane.setAlignmentX(LEFT_ALIGNMENT); |
| 101 | + pain.add(textPane); |
| 102 | + } |
| 103 | + |
| 104 | + private void showKeystoreCredentialsLayout(Box pain) { |
32 | 105 | String labelText =
|
33 | 106 | "<html>" +
|
34 | 107 | "Please enter the information below so we can generate a private key for you.<br/>" +
|
@@ -140,61 +213,5 @@ public void mouseClicked(MouseEvent e) {
|
140 | 213 | textPane.add(country);
|
141 | 214 | textPane.setAlignmentX(LEFT_ALIGNMENT);
|
142 | 215 | pain.add(textPane);
|
143 |
| - |
144 |
| - // buttons |
145 |
| - JPanel buttons = new JPanel(); |
146 |
| - buttons.setAlignmentX(LEFT_ALIGNMENT); |
147 |
| - JButton okButton = new JButton("OK"); |
148 |
| - Dimension dim = new Dimension(Preferences.BUTTON_WIDTH, |
149 |
| - okButton.getPreferredSize().height); |
150 |
| - okButton.setPreferredSize(dim); |
151 |
| - okButton.addActionListener(new ActionListener() { |
152 |
| - public void actionPerformed(ActionEvent e) { |
153 |
| - setVisible(false); |
154 |
| - } |
155 |
| - }); |
156 |
| - okButton.setEnabled(true); |
157 |
| - |
158 |
| - JButton cancelButton = new JButton("Cancel"); |
159 |
| - cancelButton.setPreferredSize(dim); |
160 |
| - cancelButton.addActionListener(new ActionListener() { |
161 |
| - public void actionPerformed(ActionEvent e) { |
162 |
| - setVisible(false); |
163 |
| - } |
164 |
| - }); |
165 |
| - cancelButton.setEnabled(true); |
166 |
| - |
167 |
| - // think different, biznatchios! |
168 |
| - if (Base.isMacOS()) { |
169 |
| - buttons.add(cancelButton); |
170 |
| -// buttons.add(Box.createHorizontalStrut(8)); |
171 |
| - buttons.add(okButton); |
172 |
| - } else { |
173 |
| - buttons.add(okButton); |
174 |
| -// buttons.add(Box.createHorizontalStrut(8)); |
175 |
| - buttons.add(cancelButton); |
176 |
| - } |
177 |
| -// buttons.setMaximumSize(new Dimension(300, buttons.getPreferredSize().height)); |
178 |
| - pain.add(buttons); |
179 |
| - |
180 |
| - JRootPane root = getRootPane(); |
181 |
| - root.setDefaultButton(okButton); |
182 |
| - ActionListener disposer = new ActionListener() { |
183 |
| - public void actionPerformed(ActionEvent actionEvent) { |
184 |
| - setVisible(false); |
185 |
| - } |
186 |
| - }; |
187 |
| - processing.app.Toolkit.registerWindowCloseKeys(root, disposer); |
188 |
| - processing.app.Toolkit.setIcon(this); |
189 |
| - |
190 |
| - pack(); |
191 |
| - |
192 |
| - Dimension screen = processing.app.Toolkit.getScreenSize(); |
193 |
| - Dimension windowSize = getSize(); |
194 |
| - |
195 |
| - setLocation((screen.width - windowSize.width) / 2, |
196 |
| - (screen.height - windowSize.height) / 2); |
197 |
| - |
198 |
| - setVisible(true); |
199 | 216 | }
|
200 | 217 | }
|
0 commit comments