コード例 #1
0
  @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;
  }
コード例 #2
0
    @Override
    public Object getData(String dataId) {
      if (PlatformDataKeys.DIFF_VIEWER.is(dataId)) {
        return myDiffPanel;
      }
      if (FocusDiffSide.DATA_KEY.is(dataId)) {
        return myDiffPanel.myCurrentSide == null ? null : myFocusDiffSide;
      }
      if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
        final DiffSideView currentSide = myDiffPanel.myCurrentSide;
        if (currentSide != null) {
          return new DiffNavigatable(currentSide);
        }
      }

      return super.getData(dataId);
    }
コード例 #3
0
 @Override
 @Nullable
 public Object getData(String dataId) {
   if (DATA_KEY.is(dataId)) {
     return this;
   }
   final SimpleNode simpleNode = getTree().getSelectedNode();
   if (simpleNode instanceof AbstractDomElementNode) {
     final DomElement domElement = ((AbstractDomElementNode) simpleNode).getDomElement();
     if (domElement != null && domElement.isValid()) {
       if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
         final XmlElement tag = domElement.getXmlElement();
         if (tag instanceof Navigatable) {
           return tag;
         }
       }
     }
   }
   return null;
 }
コード例 #4
0
 @Nullable
 public Object getData(String dataId) {
   if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
     MessageNode item = getSelectedItem();
     if (item == null) return null;
     if (isValid(item.getFile())) {
       return new OpenFileDescriptor(myProject, item.getFile(), item.getOffset());
     }
     if (item.getType() == AntBuildMessageView.MessageType.TARGET) {
       final OpenFileDescriptor descriptor = getDescriptorForTargetNode(item);
       if (descriptor != null && isValid(descriptor.getFile())) {
         return descriptor;
       }
     }
     if (item.getType() == AntBuildMessageView.MessageType.TASK) {
       final OpenFileDescriptor descriptor = getDescriptorForTaskNode(item);
       if (descriptor != null && isValid(descriptor.getFile())) {
         return descriptor;
       }
     }
   }
   return null;
 }