public boolean updateView(boolean strict) {
   if (!strict && !myGlobalInspectionContext.getUIOptions().FILTER_RESOLVED_ITEMS) {
     myTree.repaint();
     return false;
   }
   clearTree();
   boolean resultsFound = buildTree();
   myTree.restoreExpansionAndSelection();
   return resultsFound;
 }
 protected void appendDescriptor(
     final InspectionTool tool,
     final UserObjectContainer container,
     final InspectionPackageNode pNode,
     final boolean canPackageRepeat) {
   final GlobalInspectionContextImpl context = tool.getContext();
   final RefElementContainer refElementDescriptor = ((RefElementContainer) container);
   final RefEntity refElement = refElementDescriptor.getUserObject();
   if (context.getUIOptions().SHOW_ONLY_DIFF
       && tool.getElementStatus(refElement) == FileStatus.NOT_CHANGED) return;
   if (tool instanceof DescriptorProviderInspection) {
     final DescriptorProviderInspection descriptorProviderInspection =
         (DescriptorProviderInspection) tool;
     final CommonProblemDescriptor[] problems = refElementDescriptor.getProblemDescriptors();
     if (problems != null) {
       final RefElementNode elemNode = addNodeToParent(container, tool, pNode);
       for (CommonProblemDescriptor problem : problems) {
         if (context.getUIOptions().SHOW_ONLY_DIFF
             && descriptorProviderInspection.getProblemStatus(problem) == FileStatus.NOT_CHANGED) {
           continue;
         }
         elemNode.add(
             new ProblemDescriptionNode(refElement, problem, descriptorProviderInspection));
         if (problems.length == 1) {
           elemNode.setProblem(problems[0]);
         }
       }
     }
   } else {
     if (canPackageRepeat) {
       final Set<RefEntity> currentElements = tool.getContent().get(pNode.getPackageName());
       if (currentElements != null) {
         final Set<RefEntity> currentEntities = new HashSet<RefEntity>(currentElements);
         if (InspectionTool.contains(refElement, currentEntities)) return;
       }
     }
     addNodeToParent(container, tool, pNode);
   }
 }
 @NotNull
 @Override
 public FileStatus getElementStatus(final RefEntity element) {
   final GlobalInspectionContextImpl context = getContext();
   if (!isDisposed() && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN) {
     if (myOldProblemElements != null) {
       final boolean old = RefUtil.contains(element, myOldProblemElements.keySet());
       final boolean current = RefUtil.contains(element, getProblemElements().keySet());
       return calcStatus(old, current);
     }
   }
   return FileStatus.NOT_CHANGED;
 }
 @Override
 public boolean hasReportedProblems() {
   final GlobalInspectionContextImpl context = getContext();
   if (!isDisposed() && context.getUIOptions().SHOW_ONLY_DIFF) {
     for (CommonProblemDescriptor descriptor : getProblemToElements().keySet()) {
       if (getProblemStatus(descriptor) != FileStatus.NOT_CHANGED) {
         return true;
       }
     }
     if (myOldProblemElements != null) {
       for (RefEntity entity : myOldProblemElements.keySet()) {
         if (getElementStatus(entity) != FileStatus.NOT_CHANGED) {
           return true;
         }
       }
     }
     return false;
   }
   if (!getProblemElements().isEmpty()) return true;
   return !isDisposed()
       && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN
       && myOldProblemElements != null
       && !myOldProblemElements.isEmpty();
 }
 public FileStatus getProblemStatus(final CommonProblemDescriptor descriptor) {
   final GlobalInspectionContextImpl context = getContext();
   if (context != null && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN) {
     if (myOldProblemElements != null) {
       final Set<CommonProblemDescriptor> allAvailable = new HashSet<CommonProblemDescriptor>();
       for (CommonProblemDescriptor[] descriptors : myOldProblemElements.values()) {
         if (descriptors != null) {
           ContainerUtil.addAll(allAvailable, descriptors);
         }
       }
       final boolean old = contains(descriptor, allAvailable);
       final boolean current = contains(descriptor, getProblemToElements().keySet());
       return calcStatus(old, current);
     }
   }
   return FileStatus.NOT_CHANGED;
 }
 private boolean buildTree() {
   InspectionProfile profile = myInspectionProfile;
   boolean isGroupedBySeverity = myGlobalInspectionContext.getUIOptions().GROUP_BY_SEVERITY;
   myGroups.clear();
   final Map<String, Tools> tools = myGlobalInspectionContext.getTools();
   boolean resultsFound = false;
   for (Tools currentTools : tools.values()) {
     InspectionToolWrapper defaultToolWrapper = currentTools.getDefaultState().getTool();
     final HighlightDisplayKey key = HighlightDisplayKey.find(defaultToolWrapper.getShortName());
     for (ScopeToolState state : myProvider.getTools(currentTools)) {
       InspectionToolWrapper toolWrapper = state.getTool();
       if (myProvider.checkReportedProblems(myGlobalInspectionContext, toolWrapper)) {
         addTool(
             toolWrapper,
             ((InspectionProfileImpl) profile)
                 .getErrorLevel(key, state.getScope(myProject), myProject),
             isGroupedBySeverity);
         resultsFound = true;
       }
     }
   }
   return resultsFound;
 }
  @NotNull
  public InspectionNode addTool(
      @NotNull final InspectionToolWrapper toolWrapper,
      HighlightDisplayLevel errorLevel,
      boolean groupedBySeverity) {
    String groupName =
        toolWrapper.getGroupDisplayName().isEmpty()
            ? InspectionProfileEntry.GENERAL_GROUP_NAME
            : toolWrapper.getGroupDisplayName();
    InspectionTreeNode parentNode = getToolParentNode(groupName, errorLevel, groupedBySeverity);
    InspectionNode toolNode = new InspectionNode(toolWrapper);
    boolean showStructure = myGlobalInspectionContext.getUIOptions().SHOW_STRUCTURE;
    myProvider.appendToolNodeContent(
        myGlobalInspectionContext, toolNode, parentNode, showStructure);
    InspectionToolPresentation presentation =
        myGlobalInspectionContext.getPresentation(toolWrapper);
    toolNode =
        presentation.createToolNode(
            myGlobalInspectionContext, toolNode, myProvider, parentNode, showStructure);
    ((DefaultInspectionToolPresentation) presentation).setToolNode(toolNode);

    registerActionShortcuts(presentation);
    return toolNode;
  }
 private boolean isAutoScrollMode() {
   String activeToolWindowId = ToolWindowManager.getInstance(myProject).getActiveToolWindowId();
   return myGlobalInspectionContext.getUIOptions().AUTOSCROLL_TO_SOURCE
       && (activeToolWindowId == null || activeToolWindowId.equals(ToolWindowId.INSPECTION));
 }
  @SuppressWarnings({"NonStaticInitializer"})
  private JComponent createRightActionsToolbar() {
    myIncludeAction =
        new AnAction(InspectionsBundle.message("inspections.result.view.include.action.text")) {
          {
            registerCustomShortcutSet(CommonShortcuts.INSERT, myTree);
          }

          @Override
          public void actionPerformed(AnActionEvent e) {
            final TreePath[] paths = myTree.getSelectionPaths();
            if (paths != null) {
              for (TreePath path : paths) {
                ((InspectionTreeNode) path.getLastPathComponent()).amnesty();
              }
            }
            updateView(false);
          }

          @Override
          public void update(final AnActionEvent e) {
            final TreePath[] paths = myTree.getSelectionPaths();
            e.getPresentation()
                .setEnabled(
                    paths != null
                        && paths.length > 0
                        && !myGlobalInspectionContext.getUIOptions().FILTER_RESOLVED_ITEMS);
          }
        };

    myExcludeAction =
        new AnAction(InspectionsBundle.message("inspections.result.view.exclude.action.text")) {
          {
            registerCustomShortcutSet(CommonShortcuts.getDelete(), myTree);
          }

          @Override
          public void actionPerformed(final AnActionEvent e) {
            final TreePath[] paths = myTree.getSelectionPaths();
            if (paths != null) {
              for (TreePath path : paths) {
                ((InspectionTreeNode) path.getLastPathComponent()).ignoreElement();
              }
            }
            updateView(false);
          }

          @Override
          public void update(final AnActionEvent e) {
            final TreePath[] path = myTree.getSelectionPaths();
            e.getPresentation().setEnabled(path != null && path.length > 0);
          }
        };

    DefaultActionGroup specialGroup = new DefaultActionGroup();
    specialGroup.add(myGlobalInspectionContext.getUIOptions().createGroupBySeverityAction(this));
    specialGroup.add(myGlobalInspectionContext.getUIOptions().createGroupByDirectoryAction(this));
    specialGroup.add(
        myGlobalInspectionContext.getUIOptions().createFilterResolvedItemsAction(this));
    specialGroup.add(
        myGlobalInspectionContext.getUIOptions().createShowOutdatedProblemsAction(this));
    specialGroup.add(myGlobalInspectionContext.getUIOptions().createShowDiffOnlyAction(this));
    specialGroup.add(new EditSettingsAction());
    specialGroup.add(new InvokeQuickFixAction(this));
    specialGroup.add(new InspectionsOptionsToolbarAction(this));
    return createToolbar(specialGroup);
  }
 @Override
 public boolean isOldProblemsIncluded() {
   final GlobalInspectionContextImpl context = getContext();
   return context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN && getOldContent() != null;
 }