本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
}
示例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());
}
}
示例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;
}
}
}
);
}
示例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;
}
示例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;
}
示例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;
}