private void syncBrowser() {
   if (myTree.getSelectionModel().getSelectionCount() != 1) {
     myBrowser.showEmpty();
   } else {
     TreePath pathSelected = myTree.getSelectionModel().getLeadSelectionPath();
     if (pathSelected != null) {
       final InspectionTreeNode node = (InspectionTreeNode) pathSelected.getLastPathComponent();
       if (node instanceof RefElementNode) {
         final RefElementNode refElementNode = (RefElementNode) node;
         final CommonProblemDescriptor problem = refElementNode.getProblem();
         final RefEntity refSelected = refElementNode.getElement();
         if (problem != null) {
           showInBrowser(refSelected, problem);
         } else {
           showInBrowser(refSelected);
         }
       } else if (node instanceof ProblemDescriptionNode) {
         final ProblemDescriptionNode problemNode = (ProblemDescriptionNode) node;
         showInBrowser(problemNode.getElement(), problemNode.getDescriptor());
       } else if (node instanceof InspectionNode) {
         showInBrowser(((InspectionNode) node).getToolWrapper());
       } else {
         myBrowser.showEmpty();
       }
     }
   }
 }
  @Override
  public Object getData(String dataId) {
    if (PlatformDataKeys.HELP_ID.is(dataId)) return HELP_ID;
    if (DATA_KEY.is(dataId)) return this;
    if (myTree == null) return null;
    TreePath[] paths = myTree.getSelectionPaths();

    if (paths == null || paths.length == 0) return null;

    if (paths.length > 1) {
      if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
        return collectPsiElements();
      }
      return null;
    }

    TreePath path = paths[0];

    InspectionTreeNode selectedNode = (InspectionTreeNode) path.getLastPathComponent();

    if (selectedNode instanceof RefElementNode) {
      final RefElementNode refElementNode = (RefElementNode) selectedNode;
      RefEntity refElement = refElementNode.getElement();
      if (refElement == null) return null;
      final RefEntity item = refElement.getRefManager().getRefinedElement(refElement);

      if (!item.isValid()) return null;

      PsiElement psiElement = item instanceof RefElement ? ((RefElement) item).getElement() : null;
      if (psiElement == null) return null;

      final CommonProblemDescriptor problem = refElementNode.getProblem();
      if (problem != null) {
        if (problem instanceof ProblemDescriptor) {
          psiElement = ((ProblemDescriptor) problem).getPsiElement();
          if (psiElement == null) return null;
        } else {
          return null;
        }
      }

      if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
        return getSelectedNavigatable(problem, psiElement);
      } else if (CommonDataKeys.PSI_ELEMENT.is(dataId)) {
        return psiElement.isValid() ? psiElement : null;
      }
    } else if (selectedNode instanceof ProblemDescriptionNode
        && CommonDataKeys.NAVIGATABLE.is(dataId)) {
      return getSelectedNavigatable(((ProblemDescriptionNode) selectedNode).getDescriptor());
    }

    return null;
  }
 public void invokeLocalFix(int idx) {
   if (myView.getTree().getSelectionCount() != 1) return;
   final InspectionTreeNode node =
       (InspectionTreeNode) myView.getTree().getSelectionPath().getLastPathComponent();
   if (node instanceof ProblemDescriptionNode) {
     final ProblemDescriptionNode problemNode = (ProblemDescriptionNode) node;
     final CommonProblemDescriptor descriptor = problemNode.getDescriptor();
     final RefEntity element = problemNode.getElement();
     invokeFix(element, descriptor, idx);
   } else if (node instanceof RefElementNode) {
     RefElementNode elementNode = (RefElementNode) node;
     RefEntity element = elementNode.getElement();
     CommonProblemDescriptor descriptor = elementNode.getProblem();
     if (descriptor != null) {
       invokeFix(element, descriptor, idx);
     }
   }
 }
 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);
   }
 }