void () { Tree tree = new Tree(); myTreeBuilder = new CertificateTreeBuilder(tree); myTrustManager = CertificateManager.getInstance().getCustomTrustManager(); // show newly added certificates myTrustManager.addListener(this); tree.getEmptyText().setText(IdeBundle.message("settings.certificate.no.certificates")); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setRootVisible(false); //myTree.setShowsRootHandles(false); ToolbarDecorator decorator = ToolbarDecorator.createDecorator(tree).disableUpDownActions(); decorator.setAddAction(new AnActionButtonRunnable() { @Override public void run(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); } }); } }).setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { // allow to delete several certificates at once for (X509Certificate certificate : myTreeBuilder.getSelectedCertificates(true)) { myCertificates.remove(certificate); myTreeBuilder.removeCertificate(certificate); } if (myCertificates.isEmpty()) { showCard(EMPTY_PANEL); } else { myTreeBuilder.selectFirstCertificate(); } } }); tree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { X509Certificate certificate = myTreeBuilder.getFirstSelectedCertificate(true); if (certificate != null) { showCard(getCardName(certificate)); } } }); myCertificatesListPanel.setBorder( IdeBorderFactory.createTitledBorder(IdeBundle.message("settings.certificate.accepted.certificates"), false, JBUI.insetsTop(8)) .setShowLine(false)); myCertificatesListPanel.add(decorator.createPanel(), BorderLayout.CENTER); TreeUtil.expandAll(tree); }