use of com.intellij.ui.AnActionButton in project intellij-community by JetBrains.
the class CertificateConfigurable method initializeUI.
private void initializeUI() {
myTree = new Tree();
myTreeBuilder = new CertificateTreeBuilder(myTree);
myTrustManager = CertificateManager.getInstance().getCustomTrustManager();
// show newly added certificates
myTrustManager.addListener(this);
myTree.getEmptyText().setText("No certificates");
myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
myTree.setRootVisible(false);
//myTree.setShowsRootHandles(false);
ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree).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, "Malformed X509 server certificate", "Not Imported");
} else if (myCertificates.contains(certificate)) {
Messages.showWarningDialog(myRootPanel, "Certificate already exists", "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();
}
}
});
myTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
X509Certificate certificate = myTreeBuilder.getFirstSelectedCertificate(true);
if (certificate != null) {
showCard(getCardName(certificate));
}
}
});
myCertificatesListPanel.add(decorator.createPanel(), BorderLayout.CENTER);
}
use of com.intellij.ui.AnActionButton in project android by JetBrains.
the class CreateXmlResourceSubdirPanel method setupDirectoriesPanel.
protected void setupDirectoriesPanel() {
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myDirectoriesList);
decorator.setEditAction(null);
decorator.disableUpDownActions();
decorator.setAddAction(button -> doAddNewDirectory());
decorator.setRemoveAction(button -> doDeleteDirectory());
final AnActionButton selectAll = new AnActionButton("Select All", null, PlatformIcons.SELECT_ALL_ICON) {
@Override
public void actionPerformed(AnActionEvent e) {
doSelectAllDirs();
}
};
decorator.addExtraAction(selectAll);
final AnActionButton unselectAll = new AnActionButton("Unselect All", null, PlatformIcons.UNSELECT_ALL_ICON) {
@Override
public void actionPerformed(AnActionEvent e) {
doUnselectAllDirs();
}
};
decorator.addExtraAction(unselectAll);
myDirectoriesPanel.add(decorator.createPanel());
updateDirectories(true, myParent.getResourceDirectory());
}
use of com.intellij.ui.AnActionButton in project intellij-plugins by JetBrains.
the class FilesToPackageForm method initTableButtons.
private void initTableButtons() {
ToolbarDecorator d = ToolbarDecorator.createDecorator(myFilesToPackageTable);
d.setAddAction(new AnActionButtonRunnable() {
public void run(AnActionButton button) {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, true, false, true);
final VirtualFile[] files = FileChooser.chooseFiles(descriptor, myProject, null);
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
for (final VirtualFile file : files) {
final VirtualFile sourceRoot = fileIndex.getSourceRootForFile(file);
String relativePath = sourceRoot == null ? null : sourceRoot.equals(file) ? "." : VfsUtilCore.getRelativePath(file, sourceRoot, '/');
myFilesToPackage.add(new FilePathAndPathInPackage(file.getPath(), StringUtil.notNullize(relativePath, file.getName())));
}
if (files.length > 0) {
fireDataChanged();
IdeFocusManager.getInstance(myProject).requestFocus(myFilesToPackageTable, true);
final int rowCount = myFilesToPackageTable.getRowCount();
myFilesToPackageTable.setRowSelectionInterval(rowCount - files.length, rowCount - 1);
}
}
});
d.setRemoveAction(new AnActionButtonRunnable() {
public void run(AnActionButton anActionButton) {
TableUtil.stopEditing(myFilesToPackageTable);
final int[] selectedRows = myFilesToPackageTable.getSelectedRows();
Arrays.sort(selectedRows);
for (int i = selectedRows.length - 1; i >= 0; i--) {
myFilesToPackage.remove(selectedRows[i]);
}
fireDataChanged();
}
});
myMainPanel.add(d.createPanel(), BorderLayout.CENTER);
}
Aggregations