Search in sources :

Example 1 with NewKeyStoreDialog

use of org.jetbrains.android.compiler.artifact.NewKeyStoreDialog in project android by JetBrains.

the class AndroidUiUtil method initSigningSettingsForm.

public static void initSigningSettingsForm(@NotNull final Project project, @NotNull final ApkSigningSettingsForm form) {
    form.getLoadKeyStoreButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final String defaultPath = form.getKeyStorePathField().getText().trim();
            final VirtualFile defaultFile = LocalFileSystem.getInstance().findFileByPath(defaultPath);
            final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
            final VirtualFile file = FileChooser.chooseFile(descriptor, form.getPanel(), project, defaultFile);
            if (file != null) {
                form.getKeyStorePathField().setText(FileUtil.toSystemDependentName(file.getPath()));
            }
        }
    });
    form.getCreateKeyStoreButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final NewKeyStoreDialog dialog = new NewKeyStoreDialog(project, form.getKeyStorePathField().getText());
            dialog.show();
            if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
                form.getKeyStorePathField().setText(dialog.getKeyStorePath());
                form.getKeyStorePasswordField().setText(String.valueOf(dialog.getKeyStorePassword()));
                form.getKeyAliasField().setText(dialog.getKeyAlias());
                form.getKeyPasswordField().setText(String.valueOf(dialog.getKeyPassword()));
            }
        }
    });
    form.getKeyAliasField().getButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final List<String> keys = loadExistingKeys(form);
            if (keys == null) {
                return;
            }
            final ChooseKeyDialog dialog = new ChooseKeyDialog(project, form.getKeyStorePathField().getText().trim(), form.getKeyStorePasswordField().getPassword(), keys, form.getKeyAliasField().getText().trim());
            dialog.show();
            if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
                final String chosenKey = dialog.getChosenKey();
                if (chosenKey != null) {
                    form.getKeyAliasField().setText(chosenKey);
                }
                final char[] password = dialog.getChosenKeyPassword();
                if (password != null) {
                    form.getKeyPasswordField().setText(String.valueOf(password));
                }
            }
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ChooseKeyDialog(org.jetbrains.android.compiler.artifact.ChooseKeyDialog) NewKeyStoreDialog(org.jetbrains.android.compiler.artifact.NewKeyStoreDialog) List(java.util.List)

Aggregations

FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 List (java.util.List)1 ChooseKeyDialog (org.jetbrains.android.compiler.artifact.ChooseKeyDialog)1 NewKeyStoreDialog (org.jetbrains.android.compiler.artifact.NewKeyStoreDialog)1