private void traverseToLeaves( final PackageDependenciesNode treeNode, final StringBuffer denyRules, final StringBuffer allowRules) { final Enumeration enumeration = treeNode.breadthFirstEnumeration(); while (enumeration.hasMoreElements()) { PsiElement childPsiElement = ((PackageDependenciesNode) enumeration.nextElement()).getPsiElement(); if (myIllegalDependencies.containsKey(childPsiElement)) { final Map<DependencyRule, Set<PsiFile>> illegalDeps = myIllegalDependencies.get(childPsiElement); for (final DependencyRule rule : illegalDeps.keySet()) { if (rule.isDenyRule()) { if (denyRules.indexOf(rule.getDisplayText()) == -1) { denyRules.append(rule.getDisplayText()); denyRules.append("\n"); } } else { if (allowRules.indexOf(rule.getDisplayText()) == -1) { allowRules.append(rule.getDisplayText()); allowRules.append("\n"); } } } } } }
public void actionPerformed(final AnActionEvent e) { @NonNls final String delim = " -> "; final StringBuffer buf = new StringBuffer(); processDependencies( getSelectedScope(myLeftTree), getSelectedScope(myRightTree), new Processor<List<PsiFile>>() { public boolean process(final List<PsiFile> path) { if (buf.length() > 0) buf.append("<br>"); buf.append( StringUtil.join( path, new Function<PsiFile, String>() { public String fun(final PsiFile psiFile) { return psiFile.getName(); } }, delim)); return true; } }); final JEditorPane pane = new JEditorPane(UIUtil.HTML_MIME, "<html>" + buf.toString() + "</html>"); pane.setForeground(Color.black); pane.setBackground(HintUtil.INFORMATION_COLOR); pane.setOpaque(true); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(pane); final Dimension dimension = pane.getPreferredSize(); scrollPane.setMinimumSize(new Dimension(dimension.width, dimension.height + 20)); scrollPane.setPreferredSize(new Dimension(dimension.width, dimension.height + 20)); JBPopupFactory.getInstance() .createComponentPopupBuilder(scrollPane, pane) .setTitle("Dependencies") .setMovable(true) .createPopup() .showInBestPositionFor(e.getDataContext()); }