void (@NotNull AnActionEvent e) { final Project project = e.getProject(); if (project == null) { return; } final VirtualFile[] contextFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY); if (contextFiles == null || contextFiles.length == 0) { return; } final AntConfiguration antConfiguration = AntConfiguration.getInstance(project); final Set<VirtualFile> files = new HashSet<>(List.of(contextFiles)); for (AntBuildFile buildFile : antConfiguration.getBuildFileList()) { VirtualFile virtualFile = buildFile.getVirtualFile(); if (virtualFile != null) { files.remove(virtualFile); } } int filesAdded = 0; @Nls final StringBuilder errors = new StringBuilder(); for (VirtualFile file : files) { try { if (antConfiguration.addBuildFile(file) != null) { filesAdded++; } } catch (AntNoFileException ex) { String message = ex.getMessage(); if (message == null || message.length() == 0) { message = AntBundle.message("cannot.add.build.files.from.excluded.directories.error.message", ex.getFile().getPresentableUrl()); } if (errors.length() > 0) { errors.append("\n"); } errors.append(message); } } if (errors.length() > 0) { Messages.showWarningDialog(project, errors.toString(), AntBundle.message("cannot.add.build.file.dialog.title")); } if (filesAdded > 0) { ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.ANT_BUILD); if (window == null) { window = ActivateAntToolWindowAction.Manager.createToolWindow(project); } window.activate(null); } }