void (AnActionButton button) { // show choose file dialog, add certificate FileChooser.chooseFile(CERTIFICATE_DESCRIPTOR, null, null, file -> { String path = file.getPath(); X509Certificate certificate = CertificateUtil.loadX509Certificate(path); if (certificate == null) { Messages.showErrorDialog(myRootPanel, IdeBundle.message("settings.certificate.malformed.x509.server.certificate"), IdeBundle.message("settings.certificate.not.imported")); } else if (myCertificates.contains(certificate)) { Messages.showWarningDialog(myRootPanel, IdeBundle.message("settings.certificate.certificate.already.exists"), IdeBundle.message("settings.certificate.not.imported")); } else { myCertificates.add(certificate); myTreeBuilder.addCertificate(certificate); addCertificatePanel(certificate); myTreeBuilder.selectCertificate(certificate); } }); }