private AntBuildFileBase findBuildFile(final File dir) { final File buildxml = new File(dir, HybrisConstants.ANT_BUILD_XML); if (!buildxml.exists()) { return null; } final VirtualFile buildFile = VfsUtil.findFileByIoFile(buildxml, true); if (buildFile == null) { return null; } final AntBuildFile antBuildFile; try { antBuildFile = antConfiguration.addBuildFile(buildFile); } catch (AntNoFileException e) { return null; } if (antBuildFile instanceof AntBuildFileBase) { return (AntBuildFileBase) antBuildFile; } return null; }
public void actionPerformed(AnActionEvent event) { DataContext dataContext = event.getDataContext(); Project project = PlatformDataKeys.PROJECT.getData(dataContext); VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext); AntConfiguration antConfiguration = AntConfiguration.getInstance(project); try { antConfiguration.addBuildFile(file); ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.ANT_BUILD).activate(null); } catch (AntNoFileException e) { String message = e.getMessage(); if (message == null || message.length() == 0) { message = AntBundle.message("cannot.add.build.files.from.excluded.directories.error.message", e.getFile().getPresentableUrl()); } Messages.showWarningDialog(project, message, AntBundle.message("cannot.add.build.file.dialog.title")); } }
public void actionPerformed(AnActionEvent e) { Project project = e.getProject(); VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE); AntConfiguration antConfiguration = AntConfiguration.getInstance(project); try { antConfiguration.addBuildFile(file); ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.ANT_BUILD).activate(null); } 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()); } Messages.showWarningDialog(project, message, AntBundle.message("cannot.add.build.file.dialog.title")); } }
private void addBuildFile(final VirtualFile[] files) { if (files.length == 0) { return; } ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { final AntConfiguration antConfiguration = myConfig; if (antConfiguration == null) { return; } final List<VirtualFile> ignoredFiles = new ArrayList<VirtualFile>(); for (VirtualFile file : files) { try { antConfiguration.addBuildFile(file); } catch (AntNoFileException e) { ignoredFiles.add(e.getFile()); } } if (ignoredFiles.size() != 0) { String messageText; final StringBuilder message = StringBuilderSpinAllocator.alloc(); try { String separator = ""; for (final VirtualFile virtualFile : ignoredFiles) { message.append(separator); message.append(virtualFile.getPresentableUrl()); separator = "\n"; } messageText = message.toString(); } finally { StringBuilderSpinAllocator.dispose(message); } Messages.showWarningDialog(myProject, messageText, AntBundle.message("cannot.add.ant.files.dialog.title")); } } }); }
public void actionPerformed(@NotNull AnActionEvent event) { final DataContext dataContext = event.getDataContext(); final Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) { return; } final VirtualFile[] contextFiles = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext); if (contextFiles == null || contextFiles.length == 0) { return; } final AntConfiguration antConfiguration = AntConfiguration.getInstance(project); final Set<VirtualFile> files = new HashSet<VirtualFile>(); files.addAll(Arrays.asList(contextFiles)); for (AntBuildFile buildFile : antConfiguration.getBuildFiles()) { files.remove(buildFile.getVirtualFile()); } int filesAdded = 0; final StringBuilder errors = new StringBuilder(); for (VirtualFile file : files) { try { antConfiguration.addBuildFile(file); filesAdded++; } catch (AntNoFileException e) { String message = e.getMessage(); if (message == null || message.length() == 0) { message = AntBundle.message("cannot.add.build.files.from.excluded.directories.error.message", e.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) { ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.ANT_BUILD).activate(null); } }