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"));
     }
   }
 }
    @Override
    public void actionPerformed(@NotNull AnActionEvent e) {
      final OrderEntry selectedEntry = getSelectedEntry();
      GlobalSearchScope targetScope;
      if (selectedEntry instanceof ModuleOrderEntry) {
        final Module module = ((ModuleOrderEntry) selectedEntry).getModule();
        LOG.assertTrue(module != null);
        targetScope = GlobalSearchScope.moduleScope(module);
      } else {
        Library library = ((LibraryOrderEntry) selectedEntry).getLibrary();
        LOG.assertTrue(library != null);
        targetScope = new LibraryScope(getProject(), library);
      }
      new AnalyzeDependenciesOnSpecifiedTargetHandler(
          getProject(), new AnalysisScope(myState.getRootModel().getModule()), targetScope) {
        @Override
        protected boolean shouldShowDependenciesPanel(List<DependenciesBuilder> builders) {
          for (DependenciesBuilder builder : builders) {
            for (Set<PsiFile> files : builder.getDependencies().values()) {
              if (!files.isEmpty()) {
                Messages.showInfoMessage(
                    myProject,
                    "Dependencies were successfully collected in \""
                        + ToolWindowId.DEPENDENCIES
                        + "\" toolwindow",
                    FindBundle.message("find.pointcut.applications.not.found.title"));
                return true;
              }
            }
          }
          String message = "No code dependencies were found.";
          if (DependencyVisitorFactory.VisitorOptions.fromSettings(myProject).skipImports()) {
            message += " ";
            message += AnalysisScopeBundle.message("dependencies.in.imports.message");
          }
          message += " Would you like to remove the dependency?";
          if (Messages.showOkCancelDialog(
                  myProject, message, CommonBundle.getWarningTitle(), Messages.getWarningIcon())
              == Messages.OK) {
            removeSelectedItems(TableUtil.removeSelectedItems(myEntryTable));
          }
          return false;
        }

        @Override
        protected boolean canStartInBackground() {
          return false;
        }
      }.analyze();
    }
 public void actionPerformed(final AnActionEvent e) {
   final AnalysisScope scope = getScope();
   LOG.assertTrue(scope != null);
   final DependenciesBuilder builder;
   if (!myForward) {
     builder = new BackwardDependenciesBuilder(myProject, scope, myScopeOfInterest);
   } else {
     builder = new ForwardDependenciesBuilder(myProject, scope, myTransitiveBorder);
   }
   ProgressManager.getInstance()
       .runProcessWithProgressAsynchronously(
           myProject,
           AnalysisScopeBundle.message("package.dependencies.progress.title"),
           new Runnable() {
             public void run() {
               builder.analyze();
             }
           },
           new Runnable() {
             public void run() {
               myBuilders.add(builder);
               myDependencies.putAll(builder.getDependencies());
               myIllegalDependencies.putAll(builder.getIllegalDependencies());
               exclude(myExcluded);
               rebuild();
             }
           },
           null,
           new PerformAnalysisInBackgroundOption(myProject));
 }
Beispiel #4
0
      @Override
      public void setGlassPane(final Component glass) {
        if (myGlassPaneIsSet) {
          LOG.warn("Setting of glass pane for DialogWrapper is prohibited", new Exception());
          return;
        }

        super.setGlassPane(glass);
      }
Beispiel #5
0
 private void moveMousePointerOnButton(final JButton button) {
   Application application = ApplicationManager.getApplication();
   if (application != null && application.hasComponent(UISettings.class)) {
     if (button != null && UISettings.getInstance().MOVE_MOUSE_ON_DEFAULT_BUTTON) {
       Point p = button.getLocationOnScreen();
       Rectangle r = button.getBounds();
       try {
         Robot robot = new Robot();
         robot.mouseMove(p.x + r.width / 2, p.y + r.height / 2);
       } catch (AWTException e) {
         LOG.warn(e);
       }
     }
   }
 }
    @Override
    protected VirtualFile[] doAddItems() {
      Project project =
          CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myPanel));
      try {
        String[] files =
            PythonRemoteInterpreterManager.getInstance()
                .chooseRemoteFiles(
                    project, (PyRemoteSdkAdditionalDataBase) mySdk.getSdkAdditionalData(), false);

        final String sourcesLocalPath = PySdkUtil.getRemoteSourcesLocalPath(mySdk.getHomePath());

        VirtualFile[] vFiles = new VirtualFile[files.length];

        int i = 0;
        for (String file : files) {
          String localRoot = PyRemoteSourceItem.localPathForRemoteRoot(sourcesLocalPath, file);

          myNewMappings.add(new PathMappingSettings.PathMapping(localRoot, file));
          myRemoteSdkData.getPathMappings().addMappingCheckUnique(localRoot, file);

          if (!new File(localRoot).exists()) {
            new File(localRoot).mkdirs();
          }
          vFiles[i++] =
              LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(localRoot));
        }

        vFiles = adjustAddedFileSet(myPanel, vFiles);
        List<VirtualFile> added = new ArrayList<VirtualFile>(vFiles.length);
        for (VirtualFile vFile : vFiles) {
          if (addElement(vFile)) {
            added.add(vFile);
          }
        }
        return VfsUtilCore.toVirtualFileArray(added);
      } catch (Exception e) {
        LOG.error(e);
      }
      return new VirtualFile[0];
    }
 @Nullable
 private AnalysisScope getScope() {
   final Set<PsiFile> selectedScope = getSelectedScope(myRightTree);
   Set<PsiFile> result = new HashSet<PsiFile>();
   ((PackageDependenciesNode) myLeftTree.getModel().getRoot())
       .fillFiles(result, !mySettings.UI_FLATTEN_PACKAGES);
   selectedScope.removeAll(result);
   if (selectedScope.isEmpty()) return null;
   List<VirtualFile> files = new ArrayList<VirtualFile>();
   final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
   for (PsiFile psiFile : selectedScope) {
     final VirtualFile file = psiFile.getVirtualFile();
     LOG.assertTrue(file != null);
     if (fileIndex.isInContent(file)) {
       files.add(file);
     }
   }
   if (!files.isEmpty()) {
     return new AnalysisScope(myProject, files);
   }
   return null;
 }