Java Code Examples for com.intellij.ide.util.treeView.AbstractTreeNode#getValue()
The following examples show how to use
com.intellij.ide.util.treeView.AbstractTreeNode#getValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RTMergerTreeStructureProvider.java From react-templates-plugin with MIT License | 6 votes |
private static PsiElement[] collectFormPsiElements(Collection<AbstractTreeNode> selected) { Set<PsiElement> result = new HashSet<PsiElement>(); for (AbstractTreeNode node : selected) { if (node.getValue() instanceof RTFile) { RTFile form = (RTFile) node.getValue(); result.add(form.getRtjsFile()); if (form.getController() != null) { result.add(form.getController()); } ContainerUtil.addAll(result, form.getRtFile()); } else if (node.getValue() instanceof PsiElement) { result.add((PsiElement) node.getValue()); } } return PsiUtilCore.toPsiElementArray(result); }
Example 2
Source File: RTMergerTreeStructureProvider.java From react-templates-plugin with MIT License | 6 votes |
private static PsiElement[] collectFormPsiElements(Collection<AbstractTreeNode> selected) { Set<PsiElement> result = new HashSet<PsiElement>(); for (AbstractTreeNode node : selected) { if (node.getValue() instanceof RTFile) { RTFile form = (RTFile) node.getValue(); result.add(form.getRtjsFile()); if (form.getController() != null) { result.add(form.getController()); } ContainerUtil.addAll(result, form.getRtFile()); } else if (node.getValue() instanceof PsiElement) { result.add((PsiElement) node.getValue()); } } return PsiUtilCore.toPsiElementArray(result); }
Example 3
Source File: RTMergerTreeStructureProvider.java From react-templates-plugin with MIT License | 6 votes |
private static PsiElement[] collectFormPsiElements(Collection<AbstractTreeNode> selected) { Set<PsiElement> result = new HashSet<PsiElement>(); for (AbstractTreeNode node : selected) { if (node.getValue() instanceof RTFile) { RTFile form = (RTFile) node.getValue(); result.add(form.getRtjsFile()); if (form.getController() != null) { result.add(form.getController()); } ContainerUtil.addAll(result, form.getRtFile()); } else if (node.getValue() instanceof PsiElement) { result.add((PsiElement) node.getValue()); } } return PsiUtilCore.toPsiElementArray(result); }
Example 4
Source File: RTMergerTreeStructureProvider.java From react-templates-plugin with MIT License | 6 votes |
private static PsiElement[] collectFormPsiElements(Collection<AbstractTreeNode> selected) { Set<PsiElement> result = new HashSet<PsiElement>(); for (AbstractTreeNode node : selected) { if (node.getValue() instanceof RTFile) { RTFile form = (RTFile) node.getValue(); result.add(form.getRtjsFile()); if (form.getController() != null) { result.add(form.getController()); } ContainerUtil.addAll(result, form.getRtFile()); } else if (node.getValue() instanceof PsiElement) { result.add((PsiElement) node.getValue()); } } return PsiUtilCore.toPsiElementArray(result); }
Example 5
Source File: BlazeCoverageProjectViewClassDecorator.java From intellij with Apache License 2.0 | 5 votes |
@Nullable private static PsiElement getPsiElement(@SuppressWarnings("rawtypes") AbstractTreeNode node) { Object value = node.getValue(); if (value instanceof PsiElement) { return (PsiElement) value; } if (value instanceof SmartPsiElementPointer) { return ((SmartPsiElementPointer) value).getElement(); } return null; }
Example 6
Source File: CommanderPanel.java From consulo with Apache License 2.0 | 5 votes |
private PsiDirectory getDirectory() { if (myBuilder == null) return null; final Object parentElement = myBuilder.getParentNode(); if (parentElement instanceof AbstractTreeNode) { final AbstractTreeNode parentNode = (AbstractTreeNode)parentElement; if (!(parentNode.getValue() instanceof PsiDirectory)) return null; return (PsiDirectory)parentNode.getValue(); } else { return null; } }
Example 7
Source File: CommanderPanel.java From consulo with Apache License 2.0 | 5 votes |
private static Object getValueAtIndex(AbstractTreeNode node) { if (node == null) return null; Object value = node.getValue(); if (value instanceof StructureViewTreeElement) { return ((StructureViewTreeElement)value).getValue(); } return value; }
Example 8
Source File: BackgroundTaskByVfsProjectViewProvider.java From consulo with Apache License 2.0 | 5 votes |
@Override public Collection<AbstractTreeNode> modify(AbstractTreeNode parent, Collection<AbstractTreeNode> children, ViewSettings settings) { if (parent instanceof BackgroundTaskPsiFileTreeNode) { return children; } List<VirtualFile> allGeneratedFiles = new ArrayList<VirtualFile>(); BackgroundTaskByVfsChangeManager vfsChangeManager = BackgroundTaskByVfsChangeManager.getInstance(myProject); for (BackgroundTaskByVfsChangeTask o : vfsChangeManager.getTasks()) { Collections.addAll(allGeneratedFiles, o.getGeneratedFiles()); } List<AbstractTreeNode> list = new ArrayList<AbstractTreeNode>(children); for (ListIterator<AbstractTreeNode> iterator = list.listIterator(); iterator.hasNext(); ) { AbstractTreeNode next = iterator.next(); Object value = next.getValue(); if (value instanceof PsiFile) { VirtualFile virtualFile = ((PsiFile)value).getVirtualFile(); if (virtualFile == null) { continue; } if (allGeneratedFiles.contains(virtualFile)) { iterator.remove(); } else if (!vfsChangeManager.findTasks(virtualFile).isEmpty()) { iterator.set(new BackgroundTaskPsiFileTreeNode(myProject, (PsiFile)value, settings)); } } } return list; }
Example 9
Source File: BreakpointsFavoriteListProvider.java From consulo with Apache License 2.0 | 5 votes |
private static boolean checkNavigatable(AbstractTreeNode<?> node) { if (node.getValue() instanceof Navigatable && ((Navigatable)node.getValue()).canNavigate()) { return true; } Collection<? extends AbstractTreeNode> children = node.getChildren(); for (AbstractTreeNode child : children) { if (checkNavigatable(child)) { return true; } } return false; }
Example 10
Source File: FavoritesManager.java From consulo with Apache License 2.0 | 5 votes |
private Pair<AbstractUrl, String> createPairForNode(AbstractTreeNode node) { final String className = node.getClass().getName(); final Object value = node.getValue(); final AbstractUrl url = createUrlByElement(value, myProject); if (url == null) return null; return Pair.create(url, className); }
Example 11
Source File: DirectoryCoverageViewExtension.java From consulo with Apache License 2.0 | 5 votes |
@Override public List<AbstractTreeNode> getChildrenNodes(AbstractTreeNode node) { List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>(); if (node instanceof CoverageListNode) { final Object val = node.getValue(); if (val instanceof PsiFile) return Collections.emptyList(); final PsiDirectory psiDirectory = (PsiDirectory)val; final PsiDirectory[] subdirectories = ApplicationManager.getApplication().runReadAction(new Computable<PsiDirectory[]>() { @Override public PsiDirectory[] compute() { return psiDirectory.getSubdirectories(); } }); for (PsiDirectory subdirectory : subdirectories) { children.add(new CoverageListNode(getProject(), subdirectory, getSuitesBundle(), getStateBean())); } final PsiFile[] psiFiles = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile[]>() { @Override public PsiFile[] compute() { return psiDirectory.getFiles(); } }); for (PsiFile psiFile : psiFiles) { children.add(new CoverageListNode(getProject(), psiFile, getSuitesBundle(), getStateBean())); } for (AbstractTreeNode childNode : children) { childNode.setParent(node); } } return children; }
Example 12
Source File: DirectoryCoverageViewExtension.java From consulo with Apache License 2.0 | 5 votes |
@Override public String getPercentage(int columnIdx, AbstractTreeNode node) { final Object value = node.getValue(); if (value instanceof PsiFile) { return myAnnotator.getFileCoverageInformationString((PsiFile)value, getSuitesBundle(), getCoverageDataManager()); } return value != null ? myAnnotator.getDirCoverageInformationString((PsiDirectory)value, getSuitesBundle(), getCoverageDataManager()) : null; }
Example 13
Source File: DirectoryCoverageViewExtension.java From consulo with Apache License 2.0 | 5 votes |
@Override public String getSummaryForRootNode(AbstractTreeNode childNode) { final Object value = childNode.getValue(); String coverageInformationString = myAnnotator.getDirCoverageInformationString(((PsiDirectory)value), getSuitesBundle(), getCoverageDataManager()); return "Coverage Summary: " + coverageInformationString; }
Example 14
Source File: AsyncProjectViewSupport.java From consulo with Apache License 2.0 | 5 votes |
public void select(JTree tree, Object object, VirtualFile file) { if (object instanceof AbstractTreeNode) { AbstractTreeNode node = (AbstractTreeNode)object; object = node.getValue(); LOG.debug("select AbstractTreeNode"); } PsiElement element = object instanceof PsiElement ? (PsiElement)object : null; LOG.debug("select object: ", object, " in file: ", file); SmartList<TreePath> pathsToSelect = new SmartList<>(); TreeVisitor visitor = AbstractProjectViewPane.createVisitor(element, file, pathsToSelect); if (visitor != null) { //noinspection CodeBlock2Expr myNodeUpdater.updateImmediately(() -> expand(tree, promise -> { myAsyncTreeModel.accept(visitor).onProcessed(path -> { if (selectPaths(tree, pathsToSelect, visitor) || element == null || file == null || Registry.is("async.project.view.support.extra.select.disabled")) { promise.setResult(null); } else { // try to search the specified file instead of element, // because Kotlin files cannot represent containing functions pathsToSelect.clear(); TreeVisitor fileVisitor = AbstractProjectViewPane.createVisitor(null, file, pathsToSelect); myAsyncTreeModel.accept(fileVisitor).onProcessed(path2 -> { selectPaths(tree, pathsToSelect, fileVisitor); promise.setResult(null); }); } }); })); } }
Example 15
Source File: UnityScriptFileProjectViewProvider.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@RequiredReadAction @Nonnull private Collection<AbstractTreeNode> doModify(Collection<AbstractTreeNode> children, ViewSettings settings) { Unity3dRootModuleExtension rootModuleExtension = Unity3dModuleExtensionUtil.getRootModuleExtension(myProject); if(rootModuleExtension == null) { return children; } List<AbstractTreeNode> nodes = new ArrayList<>(children.size()); for(AbstractTreeNode child : children) { ProgressManager.checkCanceled(); Object value = child.getValue(); if(value instanceof JSFile && ((JSFile) value).getFileType() == JavaScriptFileType.INSTANCE) { Module moduleForPsiElement = ModuleUtilCore.findModuleForPsiElement((PsiElement) value); if(moduleForPsiElement != null) { nodes.add(new UnityScriptFileNode(myProject, (PsiFile) value, settings)); continue; } } nodes.add(child); } return nodes; }
Example 16
Source File: RTMergerTreeStructureProvider.java From react-templates-plugin with MIT License | 5 votes |
private static boolean hasRTFiles(@NotNull Collection<AbstractTreeNode> children) { for (AbstractTreeNode node : children) { if (node.getValue() instanceof PsiFile) { PsiFile file = (PsiFile) node.getValue(); if (file.getName().endsWith(".rt")) { // if (file.getFileType().equals(RTFileType.INSTANCE)) { return true; } } } return false; }
Example 17
Source File: FavoritesTreeStructure.java From consulo with Apache License 2.0 | 4 votes |
@Override public Object[] getChildElements(Object element) { if (!(element instanceof AbstractTreeNode)) { return ArrayUtil.EMPTY_OBJECT_ARRAY; } final AbstractTreeNode favTreeElement = (AbstractTreeNode)element; try { if (!(element instanceof FavoritesListNode)) { return super.getChildElements(favTreeElement); } final List<AbstractTreeNode> result = new ArrayList<AbstractTreeNode>(); final FavoritesListNode listNode = (FavoritesListNode)element; if (listNode.getProvider() != null) { return ArrayUtil.toObjectArray(listNode.getChildren()); } final Collection<AbstractTreeNode> roots = FavoritesListNode.getFavoritesRoots(myProject, listNode.getName(), listNode); for (AbstractTreeNode<?> abstractTreeNode : roots) { final Object value = abstractTreeNode.getValue(); if (value == null) continue; if (value instanceof PsiElement && !((PsiElement)value).isValid()) continue; if (value instanceof SmartPsiElementPointer && ((SmartPsiElementPointer)value).getElement() == null) continue; boolean invalid = false; for (FavoriteNodeProvider nodeProvider : Extensions.getExtensions(FavoriteNodeProvider.EP_NAME, myProject)) { if (nodeProvider.isInvalidElement(value)) { invalid = true; break; } } if (invalid) continue; result.add(abstractTreeNode); } //myFavoritesRoots = result; //if (result.isEmpty()) { // result.add(getEmptyScreen()); //} return ArrayUtil.toObjectArray(result); } catch (Exception e) { } return ArrayUtil.EMPTY_OBJECT_ARRAY; }
Example 18
Source File: CommanderPanel.java From consulo with Apache License 2.0 | 4 votes |
public final Object getDataImpl(final Key<?> dataId) { if (myBuilder == null) return null; final Object selectedValue = getSelectedValue(); if (LangDataKeys.PSI_ELEMENT == dataId) { final PsiElement selectedElement = getSelectedElement(); return selectedElement != null && selectedElement.isValid() ? selectedElement : null; } if (LangDataKeys.PSI_ELEMENT_ARRAY == dataId) { return filterInvalidElements(getSelectedElements()); } if (LangDataKeys.PASTE_TARGET_PSI_ELEMENT == dataId) { final AbstractTreeNode parentNode = myBuilder.getParentNode(); final Object element = parentNode != null ? parentNode.getValue() : null; return element instanceof PsiElement && ((PsiElement)element).isValid() ? element : null; } if (PlatformDataKeys.NAVIGATABLE_ARRAY == dataId) { return getNavigatables(); } if (PlatformDataKeys.COPY_PROVIDER == dataId) { return myCopyPasteDelegator != null ? myCopyPasteDelegator.getCopyProvider() : null; } if (PlatformDataKeys.CUT_PROVIDER == dataId) { return myCopyPasteDelegator != null ? myCopyPasteDelegator.getCutProvider() : null; } if (PlatformDataKeys.PASTE_PROVIDER == dataId) { return myCopyPasteDelegator != null ? myCopyPasteDelegator.getPasteProvider() : null; } if (LangDataKeys.IDE_VIEW == dataId) { return myIdeView; } if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER == dataId) { return myDeleteElementProvider; } if (LangDataKeys.MODULE == dataId) { return selectedValue instanceof Module ? selectedValue : null; } if (ModuleGroup.ARRAY_DATA_KEY == dataId) { return selectedValue instanceof ModuleGroup ? new ModuleGroup[]{(ModuleGroup)selectedValue} : null; } if (LibraryGroupElement.ARRAY_DATA_KEY == dataId) { return selectedValue instanceof LibraryGroupElement ? new LibraryGroupElement[]{(LibraryGroupElement)selectedValue} : null; } if (NamedLibraryElement.ARRAY_DATA_KEY == dataId) { return selectedValue instanceof NamedLibraryElement ? new NamedLibraryElement[]{(NamedLibraryElement)selectedValue} : null; } if (myProjectTreeStructure != null) { return myProjectTreeStructure.getDataFromProviders(getSelectedNodes(), dataId); } return null; }
Example 19
Source File: BlazeCoverageEngine.java From intellij with Apache License 2.0 | 4 votes |
private static boolean isLeaf(AbstractTreeNode node) { return node.getValue() instanceof PsiFile; }
Example 20
Source File: ProjectViewFileVisitor.java From consulo with Apache License 2.0 | 4 votes |
@Override protected VirtualFile getContent(@Nonnull AbstractTreeNode node) { Object value = node.getValue(); return value instanceof PsiElement ? getVirtualFile((PsiElement)value) : null; }