当前位置: 首页>>代码示例>>Java>>正文


Java PsiFileNode类代码示例

本文整理汇总了Java中com.intellij.ide.projectView.impl.nodes.PsiFileNode的典型用法代码示例。如果您正苦于以下问题:Java PsiFileNode类的具体用法?Java PsiFileNode怎么用?Java PsiFileNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PsiFileNode类属于com.intellij.ide.projectView.impl.nodes包,在下文中一共展示了PsiFileNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: modifyChildNode

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
@Nullable
@Override
public AbstractTreeNode modifyChildNode(AbstractTreeNode childNode) {
  AbstractTreeNode node = super.modifyChildNode(childNode);
  if (node != null) {
    return node;
  }
  if (childNode instanceof PsiFileNode) {
    VirtualFile virtualFile = ((PsiFileNode)childNode).getVirtualFile();
    if (virtualFile == null) {
      return null;
    }
    if (FileUtilRt.getExtension(virtualFile.getName()).equals("iml")) {
      return null;
    }
    return new CCStudentInvisibleFileNode(myProject, ((PsiFileNode)childNode).getValue(), myViewSettings);
  }
  return null;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:20,代码来源:CCCourseDirectoryNode.java

示例2: modify

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
    ArrayList<AbstractTreeNode> nodes = new ArrayList<AbstractTreeNode>();

    if (isLanguageFolder(parent)) {
        if (children.size() > 0 && parent.getValue() instanceof PsiDirectory) {
            Collection<PsiFileNode> childrenPsi2 = new ArrayList<>();
            for (AbstractTreeNode eachChild : children) {
                if (!(eachChild.getValue() instanceof PsiFile)) continue;
                PsiFile psiFile = (PsiFile) eachChild.getValue();
                LanguageNodeFile nodeFile = new LanguageNodeFile(parent.getProject(), psiFile, settings);
                childrenPsi2.add(nodeFile);
            }
            LanguageNestingNode languageFormNode = new LanguageNestingNode(childrenPsi2.iterator().next(), childrenPsi2);
            nodes.add(languageFormNode);
        }
    } else {
        nodes.addAll(children);
    }
    return nodes;
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:23,代码来源:LanguageTreeStructureProvider.java

示例3: compare

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
@Override
public int compare(NodeDescriptor nodeDescriptor1, NodeDescriptor nodeDescriptor2) {
  int weight1 = getWeight(nodeDescriptor1);
  int weight2 = getWeight(nodeDescriptor2);
  if (weight1 != weight2) {
    return weight1 - weight2;
  }
  if (!(nodeDescriptor1.getParentDescriptor() instanceof ProjectViewProjectNode)){
    if (nodeDescriptor1 instanceof PsiDirectoryNode || nodeDescriptor1 instanceof PsiFileNode){
      return nodeDescriptor1.toString().compareToIgnoreCase(nodeDescriptor2.toString());
    }
    if (nodeDescriptor1 instanceof ClassTreeNode && nodeDescriptor2 instanceof ClassTreeNode){
      if (((ClassTreeNode)nodeDescriptor1).isTopLevel()){
        return nodeDescriptor1.toString().compareToIgnoreCase(nodeDescriptor2.toString());
      }
    }
  }
  int index1 = nodeDescriptor1.getIndex();
  int index2 = nodeDescriptor2.getIndex();
  if (index1 == index2) return 0;
  return index1 < index2 ? -1 : +1;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:SourceComparator.java

示例4: annotateWithSourceProvider

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
private Collection<AbstractTreeNode> annotateWithSourceProvider(Collection<AbstractTreeNode> directoryChildren) {
  List<AbstractTreeNode> children = Lists.newArrayListWithExpectedSize(directoryChildren.size());

  for (AbstractTreeNode child : directoryChildren) {
    if (child instanceof PsiDirectoryNode) {
      PsiDirectory directory = ((PsiDirectoryNode)child).getValue();
      children.add(new AndroidPsiDirectoryNode(myProject, directory, getSettings(), findSourceProvider(directory.getVirtualFile())));
    } else if (child instanceof PsiFileNode) {
      PsiFile file = ((PsiFileNode)child).getValue();
      children.add(new AndroidPsiFileNode(myProject, file, getSettings(), findSourceProvider(file.getVirtualFile())));
    } else {
      children.add(child);
    }
  }

  return children;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AndroidSourceTypeNode.java

示例5: customizeCellRenderer

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
public void customizeCellRenderer(JTree tree,
                                  Object value,
                                  boolean selected,
                                  boolean expanded,
                                  boolean leaf,
                                  int row,
                                  boolean hasFocus) {
  final Object object = getObject(value);
  if (object instanceof PsiFile) {
    final PsiFile file = (PsiFile)object;
    final Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
    if (myManager.getAssociationsFor(file).length > 0) {
      //noinspection unchecked
      myTemp.setUserObject(new MyNodeDescriptor((NodeDescriptor<PsiFileNode>)userObject));
      super.customizeCellRenderer(tree, myTemp, selected, expanded, leaf, row, hasFocus);
      return;
    }
  }
  super.customizeCellRenderer(tree, value, selected, expanded, leaf, row, hasFocus);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:AssociationsEditor.java

示例6: decorate

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
@Override
public void decorate(ProjectViewNode node, PresentationData data) {
  if (!(node instanceof PsiFileNode)) {
    return;
  }
  PsiFile psiFile = ((PsiFileNode) node).getValue();
  if (!(psiFile instanceof OCFile)) {
    return;
  }
  VirtualFile virtualFile = psiFile.getVirtualFile();
  if (virtualFile == null) {
    return;
  }
  Project project = node.getProject();
  if (SyncStatusHelper.isUnsynced(project, virtualFile)) {
    data.clearText();
    data.addText(psiFile.getName(), SimpleTextAttributes.GRAY_ATTRIBUTES);
    data.addText(" (unsynced)", SimpleTextAttributes.GRAY_ATTRIBUTES);
  }
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:21,代码来源:BlazeCppSyncStatusFileNodeDecorator.java

示例7: testGetChildrenWithViewNode

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
@Test
public void testGetChildrenWithViewNode() throws Exception {
    //given
    SharedViewTreeNode sharedViewTreeNodeRoot = getSharedViewTreeNodeViewNode();

    //and
    SharedViewGroupNode sharedViewGroupNode = new SharedViewGroupNode(mockProject, sharedViewTreeNodeRoot, ViewSettings.DEFAULT);

    //and
    MockVirtualFile mockVirtualFile = new MockVirtualFile(false, "any_file.anything");
    mockVirtualFileManager.addFileByUrl("file://" + getClass().getClassLoader().getResource(".").getPath() + File.separator + "any_file.anything", mockVirtualFile);

    //and
    MockPsiFile mockPsiFile = new MockPsiFile(mockVirtualFile);
    mockPsiManager.addFile(mockVirtualFile, mockPsiFile);

    //when
    Collection<? extends AbstractTreeNode> children = sharedViewGroupNode.getChildren();

    //then
    assertThat(children.size(), is(1));
    assertThat(((ArrayList) children).get(0) instanceof PsiFileNode, is(true));
    assertThat(((PsiFileNode) ((ArrayList) children).get(0)).getValue().getVirtualFile(), is((VirtualFile) mockVirtualFile));
}
 
开发者ID:HotelsDotCom,项目名称:shared-views,代码行数:25,代码来源:SharedViewGroupNodeTest.java

示例8: getGitVcs

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
/**
 * Returns the GitVcs that backs a file, if any, else null
 *
 * @param fileNode the file
 * @return the branch name, else null
 */
public static
@Nullable
GitVcs getGitVcs(PsiFileNode fileNode) {
    VirtualFile virtualFile = fileNode.getVirtualFile();
    if (virtualFile != null) {
        Project currentProject = IntellijUtilities.getCurrentProject();
        if (currentProject != null) {
            AbstractVcs vcs = VcsUtil.getVcsFor(currentProject, virtualFile);
            if (vcs instanceof GitVcs) {
                return (GitVcs) vcs;
            }
        }
    }
    return null;
}
 
开发者ID:Biomatters,项目名称:IntelliComment,代码行数:22,代码来源:IntellijUtilities.java

示例9: modify

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
@NotNull
@Override
public Collection<AbstractTreeNode> modify(AbstractTreeNode parent, Collection<AbstractTreeNode> children, ViewSettings settings) {

    ArrayList<AbstractTreeNode> nodes = new ArrayList<AbstractTreeNode>();
    children.stream().filter(child -> child instanceof PsiFileNode).forEach(child -> {

        BucketNode psiFileNode = new BucketNode(child.getProject(), ((PsiFileNode) child).getValue(), settings);
        psiFileNode.setHasComment(true);
        nodes.add(psiFileNode);
    });

    children.stream().filter(child -> child instanceof PsiDirectoryNode).forEach(child -> {
        BucketDirectoryNode bucketDirectoryNode = new BucketDirectoryNode(child.getProject(), ((PsiDirectoryNode) child).getValue(), settings);
        child = bucketDirectoryNode;
    });


    return children;
}
 
开发者ID:Biomatters,项目名称:IntelliComment,代码行数:21,代码来源:IntelliBucketTreeStructureProvider.java

示例10: getChildren

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
@NotNull
@Override
public List<AbstractTreeNode> getChildren() {
    if (PropertiesComponent.getInstance().getBoolean(SettingConfigurable.PREFIX_HIDE, false)) {
        final ArrayList<AbstractTreeNode> abstractTreeNodes = new ArrayList<>();
        for (AbstractTreeNode fileNode : mChildNodeList) {
            PsiFile psiFile = (PsiFile) fileNode.getValue();
            final ViewSettings settings = ((PsiFileNode) fileNode).getSettings();
            String shortName = psiFile.getName().substring(mName.length());
            final int beginIndex = shortName.indexOf(ProjectStructureProvider.COMPOSE_BY_CHAR);
            if (beginIndex != -1) {
                shortName = shortName.substring(beginIndex + 1);
            }
            abstractTreeNodes.add(new FoldingNode(fileNode.getProject(), psiFile, settings, shortName));
        }
        return abstractTreeNodes;
    } else {
        return mChildNodeList;
    }
}
 
开发者ID:dmytrodanylyk,项目名称:folding-plugin,代码行数:21,代码来源:DirectoryNode.java

示例11: update

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
@Override
protected void update(PresentationData presentation) {
  final PsiManager psiManager = PsiManager.getInstance(myProject);
  final VirtualFile virtualFile = getValue();
  final PsiFile psiElement = virtualFile.isValid() ? psiManager.findFile(virtualFile) : null;
  if (psiElement instanceof PsiDirectory) {
    new PsiDirectoryNode(myProject, (PsiDirectory)psiElement, getSettings()).update(presentation);
  }
  else if (psiElement != null) {
    new PsiFileNode(myProject, psiElement, getSettings()).update(presentation);
  }
  else {
    presentation.setPresentableText(virtualFile.getName());
    presentation.setIcon(virtualFile.isDirectory() ? AllIcons.Nodes.Folder : virtualFile.getFileType().getIcon());
  }
}
 
开发者ID:pantsbuild,项目名称:intellij-pants-plugin,代码行数:17,代码来源:VirtualFileTreeNode.java

示例12: getChildren

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
@NotNull
@Override
public Collection<? extends AbstractTreeNode> getChildren() {
  final PsiManager psiManager = PsiManager.getInstance(myProject);
  final VirtualFile virtualFile = getValue();
  return ContainerUtil.mapNotNull(
    virtualFile.isValid() && virtualFile.isDirectory() ? virtualFile.getChildren() : VirtualFile.EMPTY_ARRAY,
    new Function<VirtualFile, AbstractTreeNode>() {
      @Override
      public AbstractTreeNode fun(VirtualFile file) {
        final PsiElement psiElement = file.isDirectory() ? psiManager.findDirectory(file) : psiManager.findFile(file);
        if (psiElement instanceof PsiDirectory && ModuleUtil.findModuleForPsiElement(psiElement) != null) {
          // PsiDirectoryNode doesn't render files outside of a project
          // let's use PsiDirectoryNode only for folders in a modules
          return new PsiDirectoryNode(myProject, (PsiDirectory)psiElement, getSettings());
        }
        else if (psiElement instanceof PsiFile) {
          return new PsiFileNode(myProject, (PsiFile)psiElement, getSettings());
        }
        else {
          return shouldShow(file) ? new VirtualFileTreeNode(myProject, file, getSettings()) : null;
        }
      }
    }
  );
}
 
开发者ID:pantsbuild,项目名称:intellij-pants-plugin,代码行数:27,代码来源:VirtualFileTreeNode.java

示例13: modify

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent,
                                           @NotNull Collection<AbstractTreeNode> children,
                                           ViewSettings settings) {
  ArrayList<AbstractTreeNode> nodes = new ArrayList<AbstractTreeNode>();
  for (AbstractTreeNode child : children) {
    if (child instanceof PsiFileNode) {
      VirtualFile file = ((PsiFileNode) child).getVirtualFile();
      if (file != null && !file.isDirectory() && !(file.getFileType() instanceof PlainTextFileType)) {
        continue;
      }
    }
    nodes.add(child);
  }
  return nodes;
}
 
开发者ID:JetBrains,项目名称:intellij-sdk-docs,代码行数:18,代码来源:TextOnlyTreeStructureProvider.java

示例14: compare

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
public int compare(NodeDescriptor nodeDescriptor1, NodeDescriptor nodeDescriptor2) {
  int weight1 = getWeight(nodeDescriptor1);
  int weight2 = getWeight(nodeDescriptor2);
  if (weight1 != weight2) {
    return weight1 - weight2;
  }
  if (!(nodeDescriptor1.getParentDescriptor() instanceof ProjectViewProjectNode)){
    if (nodeDescriptor1 instanceof PsiDirectoryNode || nodeDescriptor1 instanceof PsiFileNode){
      return nodeDescriptor1.toString().compareToIgnoreCase(nodeDescriptor2.toString());
    }
    if (nodeDescriptor1 instanceof ClassTreeNode && nodeDescriptor2 instanceof ClassTreeNode){
      if (((ClassTreeNode)nodeDescriptor1).isTopLevel()){
        return nodeDescriptor1.toString().compareToIgnoreCase(nodeDescriptor2.toString());
      }
    }
  }
  int index1 = nodeDescriptor1.getIndex();
  int index2 = nodeDescriptor2.getIndex();
  if (index1 == index2) return 0;
  return index1 < index2 ? -1 : +1;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:SourceComparator.java

示例15: getChildrenImpl

import com.intellij.ide.projectView.impl.nodes.PsiFileNode; //导入依赖的package包/类
@Override
public Collection<AbstractTreeNode> getChildrenImpl() {
  VirtualFile ourVirtualFile = getVirtualFile();
  if(ourVirtualFile == null) {
    return super.getChildrenImpl();
  }
  BackgroundTaskByVfsChangeManager vfsChangeManager = BackgroundTaskByVfsChangeManager.getInstance(getProject());
  List<BackgroundTaskByVfsChangeTask> tasks = vfsChangeManager.findTasks(ourVirtualFile);
  if(tasks.isEmpty()) {
    return super.getChildrenImpl();
  }
  List<VirtualFile> generatedFiles = new ArrayList<VirtualFile>();
  for (BackgroundTaskByVfsChangeTask task : tasks) {
    Collections.addAll(generatedFiles, task.getGeneratedFiles());
  }
  if(generatedFiles.isEmpty()) {
    return super.getChildrenImpl();
  }
  PsiFile[] psiFiles = PsiUtilBase.virtualToPsiFiles(generatedFiles, myProject);
  List<AbstractTreeNode> newChildren = new ArrayList<AbstractTreeNode>(psiFiles.length);
  for (PsiFile psiFile : psiFiles) {
    newChildren.add(new PsiFileNode(getProject(), psiFile, getSettings()));
  }
  return newChildren;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:BackgroundTaskPsiFileTreeNode.java


注:本文中的com.intellij.ide.projectView.impl.nodes.PsiFileNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。