com.intellij.ui.treeStructure.SimpleNode Java Examples
The following examples show how to use
com.intellij.ui.treeStructure.SimpleNode.
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: GraphQLSchemasRootNode.java From js-graphql-intellij-plugin with MIT License | 6 votes |
@NotNull @Override public SimpleNode[] getChildren() { try { if (DumbService.getInstance(myProject).isDumb() || !configManager.isInitialized()) { // empty the tree view during indexing and until the config has been initialized return SimpleNode.NO_CHILDREN; } final List<SimpleNode> children = Lists.newArrayList(); for (Map.Entry<VirtualFile, GraphQLConfigData> entry : configManager.getConfigurationsByPath().entrySet()) { children.add(new GraphQLConfigSchemaNode(myProject, this, configManager, entry.getValue(), entry.getKey())); } if (children.isEmpty()) { children.add(new GraphQLDefaultSchemaNode(myProject, this)); } children.sort(Comparator.comparing(PresentableNodeDescriptor::getName)); return children.toArray(SimpleNode.NO_CHILDREN); } catch (IndexNotReadyException e) { return SimpleNode.NO_CHILDREN; } }
Example #2
Source File: TfsTreeNode.java From azure-devops-intellij with MIT License | 6 votes |
@Override public SimpleNode[] getChildren() { if (!isDirectory) { return NO_CHILDREN; } List<TfvcItem> children; try { children = treeContext.getChildItems(path); } catch (TfsException e) { return new SimpleNode[]{new TfsErrorTreeNode(this, e.getMessage())}; } final List<TfsTreeNode> result = new ArrayList<TfsTreeNode>(virtualChildren); for (final TfvcItem childItem : children) { result.add(new TfsTreeNode(this, childItem.getPath(), childItem.isFolder(), false)); } return result.toArray(new SimpleNode[result.size()]); }
Example #3
Source File: GraphQLConfigSchemaNode.java From js-graphql-intellij-plugin with MIT License | 6 votes |
@Override public SimpleNode[] buildChildren() { final List<SimpleNode> children = Lists.newArrayList(); if (performSchemaDiscovery) { children.add(new GraphQLSchemaContentNode(this, schemaWithErrors)); if (schemaWithErrors.getRegistry().isProcessedGraphQL()) { children.add(new GraphQLSchemaErrorsListNode(this, schemaWithErrors)); } } if (projectsConfigData != null && !projectsConfigData.isEmpty()) { children.add(new GraphQLConfigProjectsNode(this)); } if (endpoints != null) { final String projectKey = this.configData instanceof GraphQLConfigData ? null : this.configData.name; children.add(new GraphQLSchemaEndpointsListNode(this, projectKey, endpoints)); } return children.toArray(SimpleNode.NO_CHILDREN); }
Example #4
Source File: LayoutTreeSelection.java From consulo with Apache License 2.0 | 6 votes |
public LayoutTreeSelection(@Nonnull LayoutTree tree) { final TreePath[] paths = tree.getSelectionPaths(); if (paths == null) { return; } for (TreePath path : paths) { final SimpleNode node = tree.getNodeFor(path); if (node instanceof PackagingElementNode) { final PackagingElementNode<?> elementNode = (PackagingElementNode<?>)node; mySelectedNodes.add(elementNode); myNode2Path.put(elementNode, path); for (PackagingElement<?> element : elementNode.getPackagingElements()) { mySelectedElements.add(element); myElement2Node.put(element, elementNode); } } } }
Example #5
Source File: LayoutTreeComponent.java From consulo with Apache License 2.0 | 6 votes |
public void selectNode(@Nonnull String parentPath, @Nonnull PackagingElement<?> element) { final PackagingElementNode<?> parent = myTree.findCompositeNodeByPath(parentPath); if (parent == null) return; for (SimpleNode node : parent.getChildren()) { if (node instanceof PackagingElementNode) { final List<? extends PackagingElement<?>> elements = ((PackagingElementNode<?>)node).getPackagingElements(); for (PackagingElement<?> packagingElement : elements) { if (packagingElement.isEqualTo(element)) { myBuilder.select(node); return; } } } } }
Example #6
Source File: LayoutTree.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public PackagingElement<?> getElementByPath(TreePath path) { final SimpleNode node = getNodeFor(path); if (node instanceof PackagingElementNode) { final List<? extends PackagingElement<?>> elements = ((PackagingElementNode<?>)node).getPackagingElements(); if (!elements.isEmpty()) { return elements.get(0); } } return null; }
Example #7
Source File: GraphQLSchemaContentNode.java From js-graphql-intellij-plugin with MIT License | 5 votes |
public GraphQLSchemaContentNode(SimpleNode parent, GraphQLSchemaWithErrors schemaWithErrors) { super(parent); this.schemaWithErrors = schemaWithErrors; final List<String> parts = Lists.newArrayList(); TypeDefinitionRegistry registry = schemaWithErrors.getRegistry().getRegistry(); parts.add(registry.getTypes(ObjectTypeDefinition.class).size() + " types"); parts.add(registry.getTypes(InterfaceTypeDefinition.class).size() + " interfaces"); parts.add(registry.getTypes(InputObjectTypeDefinition.class).size() + " inputs"); parts.add(registry.getTypes(EnumTypeDefinition.class).size() + " enums"); parts.add(registry.getTypes(UnionTypeDefinition.class).size() + " unions"); parts.add(registry.scalars().size() - ScalarInfo.GRAPHQL_SPECIFICATION_SCALARS.size() + " scalars"); parts.add(registry.getDirectiveDefinitions().size() + " directives"); myName = "Schema discovery summary"; final Object[] nonEmptyParts = parts.stream().filter(p -> p.charAt(0) != '0').toArray(); if (nonEmptyParts.length > 0) { getTemplatePresentation().setLocationString("- " + StringUtils.join(nonEmptyParts, ", ")); } else { final String message = schemaWithErrors.getRegistry().isProcessedGraphQL() ? "- schema is empty" : "- no schema definitions were found"; getTemplatePresentation().setLocationString(message); } getTemplatePresentation().setTooltip("Double click or press enter to search the schema registry"); setIcon(AllIcons.Nodes.ModuleGroup); }
Example #8
Source File: CrucibleRootNode.java From Crucible4IDEA with MIT License | 5 votes |
@Override public SimpleNode[] getChildren() { if (myChildren.isEmpty()) { addChildren(); } return myChildren.toArray(new SimpleNode[myChildren.size()]); }
Example #9
Source File: CompositePackagingElementNode.java From consulo with Apache License 2.0 | 5 votes |
@Override protected SimpleNode[] buildChildren() { List<PackagingElementNode<?>> children = new ArrayList<PackagingElementNode<?>>(); for (CompositePackagingElement<?> element : getPackagingElements()) { PackagingTreeNodeFactory.addNodes(element.getChildren(), this, element, myContext, mySubstitutionParameters, getNodeSource(element), children, myArtifactType, new HashSet<PackagingElement<?>>()); } return children.isEmpty() ? NO_CHILDREN : children.toArray(new SimpleNode[children.size()]); }
Example #10
Source File: LayoutNodesDraggingObject.java From consulo with Apache License 2.0 | 5 votes |
private static boolean pathContains(TreePath path, PackagingElementNode<?> node, LayoutTree tree) { while (path != null) { final SimpleNode pathNode = tree.getNodeFor(path); if (pathNode == node) { return true; } path = path.getParentPath(); } return false; }
Example #11
Source File: LayoutTreeComponent.java From consulo with Apache License 2.0 | 5 votes |
@TestOnly public void selectNode(@Nonnull String parentPath, @Nonnull String nodeName) { final PackagingElementNode<?> parent = myTree.findCompositeNodeByPath(parentPath); if (parent == null) return; for (SimpleNode node : parent.getChildren()) { if (node instanceof PackagingElementNode) { if (nodeName.equals(((PackagingElementNode)node).getElementPresentation().getSearchName())) { myBuilder.select(node); return; } } } }
Example #12
Source File: PackagingElementNode.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public CompositePackagingElementNode findCompositeChild(@Nonnull String name) { final SimpleNode[] children = getChildren(); for (SimpleNode child : children) { if (child instanceof CompositePackagingElementNode) { final CompositePackagingElementNode composite = (CompositePackagingElementNode)child; if (name.equals(composite.getFirstElement().getName())) { return composite; } } } return null; }
Example #13
Source File: FilteringTreeStructure.java From consulo with Apache License 2.0 | 5 votes |
@Override public int getWeight() { if (getDelegate() instanceof SimpleNode) { return ((SimpleNode)getDelegate()).getWeight(); } return super.getWeight(); }
Example #14
Source File: FilteringTreeStructure.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean isAlwaysShowPlus() { if (myDelegate instanceof SimpleNode) { return ((SimpleNode)myDelegate).isAlwaysShowPlus(); } return super.isAlwaysShowPlus(); }
Example #15
Source File: FilteringTreeStructure.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean isAlwaysLeaf() { if (myDelegate instanceof SimpleNode) { return ((SimpleNode)myDelegate).isAlwaysLeaf(); } return super.isAlwaysLeaf(); }
Example #16
Source File: LayoutTree.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void configureUiHelper(TreeUIHelper helper) { final Convertor<TreePath, String> convertor = new Convertor<TreePath, String>() { @Override public String convert(final TreePath path) { final SimpleNode node = getNodeFor(path); if (node instanceof PackagingElementNode) { return ((PackagingElementNode<?>)node).getElementPresentation().getSearchName(); } return ""; } }; new TreeSpeedSearch(this, convertor, true); }
Example #17
Source File: OptionsEditor.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean shouldBeShowing(final SimpleNode value) { if (myFiltered == null) return true; if (value instanceof OptionsTree.ConfigurableNode) { final OptionsTree.ConfigurableNode node = (OptionsTree.ConfigurableNode)value; return myFiltered.contains(node.getConfigurable()) || isChildOfNameHit(node); } return true; }
Example #18
Source File: PackagingElementNode.java From consulo with Apache License 2.0 | 5 votes |
public List<PackagingElementNode<?>> getNodesByPath(List<PackagingElement<?>> pathToPlace) { List<PackagingElementNode<?>> result = new ArrayList<PackagingElementNode<?>>(); PackagingElementNode<?> current = this; int i = 0; result.add(current); while (current != null && i < pathToPlace.size()) { final SimpleNode[] children = current.getCached(); if (children == null) { break; } PackagingElementNode<?> next = null; final PackagingElement<?> element = pathToPlace.get(i); search: for (SimpleNode child : children) { if (child instanceof PackagingElementNode<?>) { PackagingElementNode<?> childNode = (PackagingElementNode<?>)child; for (PackagingElement<?> childElement : childNode.getPackagingElements()) { if (childElement.isEqualTo(element)) { next = childNode; break search; } } for (PackagingNodeSource nodeSource : childNode.getNodeSources()) { if (nodeSource.getSourceElement().isEqualTo(element)) { next = current; break search; } } } } current = next; if (current != null) { result.add(current); } i++; } return result; }
Example #19
Source File: GraphQLSchemaEndpointsListNode.java From js-graphql-intellij-plugin with MIT License | 5 votes |
public ConfigurableEndpointNode(SimpleNode parent, String projectKey, GraphQLConfigEndpoint endpoint) { super(parent); this.projectKey = projectKey; this.endpoint = endpoint; myName = endpoint.name; getTemplatePresentation().setTooltip("Endpoints allow you to perform GraphQL introspection, queries and mutations"); getTemplatePresentation().setLocationString(endpoint.url); setIcon(JSGraphQLIcons.UI.GraphQLNode); }
Example #20
Source File: GraphQLSchemaEndpointsListNode.java From js-graphql-intellij-plugin with MIT License | 5 votes |
@Override public SimpleNode[] buildChildren() { if (endpoints == null) { return new SimpleNode[]{new DefaultEndpointNode(myProject)}; } else { return endpoints.stream().map(endpoint -> new ConfigurableEndpointNode(this, projectKey, endpoint)).toArray(SimpleNode[]::new); } }
Example #21
Source File: GraphQLSchemaEndpointsListNode.java From js-graphql-intellij-plugin with MIT License | 5 votes |
public GraphQLSchemaEndpointsListNode(SimpleNode parent, String projectKey, List<GraphQLConfigEndpoint> endpoints) { super(parent); this.projectKey = projectKey; this.endpoints = endpoints; myName = "Endpoints"; setIcon(AllIcons.Nodes.WebFolder); }
Example #22
Source File: GraphQLSchemaErrorsListNode.java From js-graphql-intellij-plugin with MIT License | 5 votes |
@Override public SimpleNode[] buildChildren() { if (!schemaWithErrors.getRegistry().isProcessedGraphQL()) { // no GraphQL PSI files parse yet, so no need to show the "no query defined" error for a non-existing schema return SimpleNode.NO_CHILDREN; } final List<SimpleNode> children = Lists.newArrayList(); for (GraphQLError error : schemaWithErrors.getErrors()) { children.add(new GraphQLSchemaErrorNode(this, error)); } if (children.isEmpty()) { SimpleNode noErrors = new SimpleNode(this) { @Override public SimpleNode[] getChildren() { return NO_CHILDREN; } @Override public String getName() { return "No errors found"; } }; noErrors.setIcon(AllIcons.General.InspectionsOK); children.add(noErrors); } return children.toArray(SimpleNode.NO_CHILDREN); }
Example #23
Source File: GraphQLConfigSchemaNode.java From js-graphql-intellij-plugin with MIT License | 5 votes |
@Override public SimpleNode[] buildChildren() { if (parent.projectsConfigData != null) { try { return parent.projectsConfigData.values().stream().map(config -> { return new GraphQLConfigSchemaNode(myProject, this, parent.configManager, config, parent.configBaseDir); }).toArray(SimpleNode[]::new); } catch (IndexNotReadyException ignored) { // entered "dumb" mode, so just return no children as the tree view will be rebuilt as empty shortly (GraphQLSchemasRootNode) } } return SimpleNode.NO_CHILDREN; }
Example #24
Source File: GraphQLConfigSchemaNode.java From js-graphql-intellij-plugin with MIT License | 5 votes |
protected GraphQLConfigSchemaNode(Project project, SimpleNode parent, GraphQLConfigManager configManager, GraphQLResolvedConfigData configData, VirtualFile configBaseDir) { super(project, parent); this.configManager = configManager; this.configData = configData; this.configBaseDir = configBaseDir; this.configFile = configManager.getClosestConfigFile(configBaseDir); if (configData.name != null && !configData.name.isEmpty()) { myName = configData.name; } else { // use the last part of the folder as name myName = StringUtils.substringAfterLast(configBaseDir.getPath(), "/"); } getPresentation().setIcon(JSGraphQLIcons.Files.GraphQLSchema); if (configData instanceof GraphQLConfigData) { getPresentation().setLocationString(configBaseDir.getPresentableUrl()); projectsConfigData = ((GraphQLConfigData) configData).projects; // this node is only considered a "real" schema that should be discovered if the config file doesn't use projects // if the config uses projects we can't do discovery at the root level as that's likely to consider multiple distinct schemas // as one with resulting re-declaration errors during validation performSchemaDiscovery = projectsConfigData == null || projectsConfigData.isEmpty(); } if (performSchemaDiscovery) { final GraphQLTypeDefinitionRegistryServiceImpl registry = GraphQLTypeDefinitionRegistryServiceImpl.getService(myProject); configurationEntryFile = configManager.getConfigurationEntryFile(configData); endpoints = configManager.getEndpoints(configurationEntryFile.getVirtualFile()); schemaWithErrors = registry.getSchemaWithErrors(configurationEntryFile); } else { schemaWithErrors = null; endpoints = null; configurationEntryFile = null; } }
Example #25
Source File: SourceItemNodeBase.java From consulo with Apache License 2.0 | 5 votes |
@Override protected SimpleNode[] buildChildren() { final PackagingSourceItemsProvider[] providers = Extensions.getExtensions(PackagingSourceItemsProvider.EP_NAME); List<SimpleNode> children = new ArrayList<SimpleNode>(); for (PackagingSourceItemsProvider provider : providers) { final Collection<? extends PackagingSourceItem> items = provider.getSourceItems(myContext, myArtifact, getSourceItem()); for (PackagingSourceItem item : items) { if (myArtifact.getArtifactType().isSuitableItem(item)) { children.add(new SourceItemNode(myContext, this, item, myArtifactEditor)); } } } return children.isEmpty() ? NO_CHILDREN : children.toArray(new SimpleNode[children.size()]); }
Example #26
Source File: GraphQLSchemaErrorNode.java From js-graphql-intellij-plugin with MIT License | 5 votes |
public GraphQLSchemaErrorNode(SimpleNode parent, GraphQLError error) { super(parent); this.error = error; myName = error.getMessage(); setIcon(AllIcons.Ide.FatalError); SourceLocation location = getLocation(); if (location != null) { getTemplatePresentation().setTooltip(location.getSourceName() + ":" + location.getLine() + ":" + location.getColumn()); } else if (error instanceof GraphQLInternalSchemaError) { getTemplatePresentation().setLocationString(" - double click to open stack trace"); } }
Example #27
Source File: GraphQLDefaultSchemaNode.java From js-graphql-intellij-plugin with MIT License | 5 votes |
@Override public SimpleNode[] buildChildren() { final List<SimpleNode> children = Lists.newArrayList(new GraphQLSchemaContentNode(this, schemaWithErrors)); if (schemaWithErrors.getRegistry().isProcessedGraphQL()) { children.add(new GraphQLSchemaErrorsListNode(this, schemaWithErrors)); } children.add(new GraphQLSchemaEndpointsListNode(this, null, null)); return children.toArray(SimpleNode.NO_CHILDREN); }
Example #28
Source File: CrucibleTreeStructure.java From Crucible4IDEA with MIT License | 4 votes |
public SimpleNode getRootElement() { return myRootElement; }
Example #29
Source File: PackagingElementNode.java From consulo with Apache License 2.0 | 4 votes |
@Override protected SimpleNode[] buildChildren() { return SimpleNode.NO_CHILDREN; }
Example #30
Source File: LayoutTree.java From consulo with Apache License 2.0 | 4 votes |
public PackagingElementNode<?> getRootPackagingNode() { final SimpleNode node = getNodeFor(new TreePath(getRootNode())); return node instanceof PackagingElementNode ? (PackagingElementNode<?>)node : null; }