public void update(final AnActionEvent e) {
   super.update(e);
   final PatternDialectProvider provider =
       PatternDialectProvider.getInstance(DependencyUISettings.getInstance().SCOPE_TYPE);
   e.getPresentation().setText(provider.getDisplayName());
   e.getPresentation().setIcon(provider.getIcon());
 }
 public void actionPerformed(AnActionEvent e) {
   final PackageDependenciesNode leftNode = myLeftTree.getSelectedNode();
   final PackageDependenciesNode rightNode = myRightTree.getSelectedNode();
   if (leftNode != null && rightNode != null) {
     boolean hasDirectDependencies = myTransitiveBorder == 0;
     if (myTransitiveBorder > 0) {
       final Set<PsiFile> searchIn = getSelectedScope(myLeftTree);
       final Set<PsiFile> searchFor = getSelectedScope(myRightTree);
       for (DependenciesBuilder builder : myBuilders) {
         if (hasDirectDependencies) break;
         for (PsiFile from : searchIn) {
           if (hasDirectDependencies) break;
           for (PsiFile to : searchFor) {
             if (hasDirectDependencies) break;
             final List<List<PsiFile>> paths = builder.findPaths(from, to);
             for (List<PsiFile> path : paths) {
               if (path.isEmpty()) {
                 hasDirectDependencies = true;
                 break;
               }
             }
           }
         }
       }
     }
     final PatternDialectProvider provider =
         PatternDialectProvider.getInstance(mySettings.SCOPE_TYPE);
     PackageSet leftPackageSet = provider.createPackageSet(leftNode, true);
     if (leftPackageSet == null) {
       leftPackageSet = provider.createPackageSet(leftNode, false);
     }
     LOG.assertTrue(leftPackageSet != null);
     PackageSet rightPackageSet = provider.createPackageSet(rightNode, true);
     if (rightPackageSet == null) {
       rightPackageSet = provider.createPackageSet(rightNode, false);
     }
     LOG.assertTrue(rightPackageSet != null);
     if (hasDirectDependencies) {
       DependencyValidationManager.getInstance(myProject)
           .addRule(
               new DependencyRule(
                   new NamedScope.UnnamedScope(leftPackageSet),
                   new NamedScope.UnnamedScope(rightPackageSet),
                   true));
       rebuild();
     } else {
       Messages.showErrorDialog(
           DependenciesPanel.this,
           "Rule was not added.\n There is no direct dependency between \'"
               + leftPackageSet.getText()
               + "\' and \'"
               + rightPackageSet.getText()
               + "\'",
           AnalysisScopeBundle.message("mark.dependency.illegal.text"));
     }
   }
 }
 boolean isButtonEnabled(boolean rec) {
   final TreePath[] paths = myPackageTree.getSelectionPaths();
   if (paths != null) {
     for (TreePath path : paths) {
       final PackageDependenciesNode node = (PackageDependenciesNode) path.getLastPathComponent();
       if (PatternDialectProvider.getInstance(DependencyUISettings.getInstance().SCOPE_TYPE)
               .createPackageSet(node, rec)
           != null) {
         return true;
       }
     }
   }
   return false;
 }
 static boolean isButtonEnabled(boolean rec, TreePath[] paths, TreeSelectionEvent e) {
   if (paths != null) {
     for (TreePath path : paths) {
       if (!e.isAddedPath(path)) continue;
       final PackageDependenciesNode node = (PackageDependenciesNode) path.getLastPathComponent();
       if (PatternDialectProvider.getInstance(DependencyUISettings.getInstance().SCOPE_TYPE)
               .createPackageSet(node, rec)
           != null) {
         return true;
       }
     }
   }
   return false;
 }
 public void update(final AnActionEvent e) {
   final Presentation presentation = e.getPresentation();
   presentation.setEnabled(false);
   final PackageDependenciesNode leftNode = myLeftTree.getSelectedNode();
   final PackageDependenciesNode rightNode = myRightTree.getSelectedNode();
   if (leftNode != null && rightNode != null) {
     final PatternDialectProvider provider =
         PatternDialectProvider.getInstance(mySettings.SCOPE_TYPE);
     presentation.setEnabled(
         (provider.createPackageSet(leftNode, true) != null
                 || provider.createPackageSet(leftNode, false) != null)
             && (provider.createPackageSet(rightNode, true) != null
                 || provider.createPackageSet(rightNode, false) != null));
   }
 }
 @Nullable
 private ArrayList<PackageSet> getSelectedSets(boolean recursively) {
   int[] rows = myPackageTree.getSelectionRows();
   if (rows == null) return null;
   final ArrayList<PackageSet> result = new ArrayList<PackageSet>();
   for (int row : rows) {
     final PackageDependenciesNode node =
         (PackageDependenciesNode) myPackageTree.getPathForRow(row).getLastPathComponent();
     final PackageSet set =
         PatternDialectProvider.getInstance(DependencyUISettings.getInstance().SCOPE_TYPE)
             .createPackageSet(node, recursively);
     if (set != null) {
       result.add(set);
     }
   }
   return result;
 }
 private TreeModel buildTreeModel(Set<PsiFile> deps, Marker marker) {
   return PatternDialectProvider.getInstance(mySettings.SCOPE_TYPE)
       .createTreeModel(myProject, deps, marker, mySettings);
 }