@Override public boolean supportGoInto() { return getData() instanceof Container; }
@Override public int compare(Node o1, Node o2) { if (o1 instanceof ResourceNode && o2 instanceof ResourceNode) { return ((ResourceNode) o1).compareTo((ResourceNode) o2); } return 0; } },
@Override protected Promise<List<Node>> getChildrenImpl() { checkState(getData() instanceof Container, "Not a container"); return ((Container) getData()) .getChildren() .then( (Function<Resource[], List<Node>>) children -> { if (children == null || children.length == 0) { return NO_CHILDREN; } final List<Node> nodes = newArrayListWithExpectedSize(children.length); for (Resource child : children) { nodes.add(createNode(child)); } return unmodifiableList(nodes); }); }
protected Node transform(ResourceNode resourceNode) { final Optional<Resource> srcFolder = resourceNode.getData().getParentWithMarker(SourceFolderMarker.ID); if (!srcFolder.isPresent()) { return resourceNode; } final Optional<Marker> marker = srcFolder.get().getMarker(SourceFolderMarker.ID); final ContentRoot contentRoot = ((SourceFolderMarker) marker.get()).getContentRoot(); if (contentRoot == ContentRoot.TEST_SOURCE && !resourceNode.getData().getLocation().equals(srcFolder.get().getLocation())) { resourceNode .getAttributes() .put( CUSTOM_BACKGROUND_FILL, singletonList(Style.theme.projectExplorerTestItemBackground())); } return resourceNode; } }
if (node != null) { String oldId = tree.getNodeStorage().getKeyProvider().getKey(node); ((ResourceNode) node).setData(delta.getResource()); tree.getNodeStorage().reIndexNode(oldId, node); tree.refresh(node); if (node instanceof ResourceNode && ((ResourceNode) node) .getData() .getLocation() .equals(delta.getResource().getLocation())) { final String oldId = tree.getNodeStorage().getKeyProvider().getKey(node); ((ResourceNode) node).setData(delta.getResource()); tree.getNodeStorage().reIndexNode(oldId, node); tree.refresh(node); int srcResourceType = ((ResourceNode) node).getData().getResourceType(); if (srcResourceType != resource.getResourceType()) { // resource changed own type String oldId = tree.getNodeStorage().getKeyProvider().getKey(node); ((ResourceNode) node).setData(delta.getResource()); tree.getNodeStorage().reIndexNode(oldId, node); } else { ((ResourceNode) node).setData(delta.getResource());
@Override public final NodePresentation getPresentation(boolean update) { if (nodePresentation == null) { nodePresentation = new NodePresentation(); } // need to force update presentation to correct display node in project explorer after restart // workspace details https://github.com/eclipse/che/issues/6314 // problem reproduce randomly updatePresentation(nodePresentation); return nodePresentation; }
protected Node createNode(Resource resource) { checkArgument(resource != null, "Not a resource"); switch (resource.getResourceType()) { case PROJECT: case FOLDER: return nodeFactory.newContainerNode((Container) resource, getSettings()); case FILE: return nodeFactory.newFileNode((File) resource, getSettings()); default: throw new IllegalArgumentException("Resource type was not recognized"); } } }
@Nullable @Override public Resource apply(@Nullable Node input) { checkNotNull(input); checkState(input instanceof ResourceNode); return ((ResourceNode) input).getData(); } };
@Nullable @Override public Resource apply(@Nullable Node input) { checkNotNull(input); checkState(input instanceof ResourceNode); return ((ResourceNode) input).getData(); } };
@Nullable @Override public Resource apply(@Nullable Node input) { checkNotNull(input); checkState(input instanceof ResourceNode); return ((ResourceNode) input).getData(); } };
@Nullable @Override public Resource apply(@Nullable Node input) { checkNotNull(input); checkState(input instanceof ResourceNode); return ((ResourceNode) input).getData(); } };
@Nullable @Override public Resource apply(@Nullable Node input) { checkNotNull(input); checkState(input instanceof ResourceNode); return ((ResourceNode) input).getData(); } };
@Override public String getName() { return getData().getName(); }
@Override public boolean isLeaf() { return getData().getResourceType() == Resource.FILE; }
protected boolean isSourceOrPackage(ResourceNode node) { return node.getData().getParentWithMarker(SourceFolderMarker.ID).isPresent(); }
private int getClassIndex(Node node) { if (node instanceof ResourceNode && (((ResourceNode) node).getData().getResourceType() == FOLDER || ((ResourceNode) node).getData().getResourceType() == PROJECT)) { return 1; } if (node instanceof ResourceNode && ((ResourceNode) node).getData().getResourceType() == FILE) { return 2; } if (node instanceof SyntheticNode<?>) { return 3; } return 0; }
private ResourceNode getRootResourceNode(Path path) { return (ResourceNode) tree.getRootNodes() .stream() .filter(node -> node instanceof ResourceNode) .filter(node -> ((ResourceNode) node).getData().getLocation().isPrefixOf(path)) .findFirst() .orElse(null); } }
private ResourceNode getNodeByPath(Path path) { return (ResourceNode) tree.getNodeStorage() .getAll() .stream() .filter(node -> node instanceof ResourceNode) .filter(node -> ((ResourceNode) node).getData().getLocation().equals(path)) .findFirst() .orElse(null); }
private boolean isNodeServesLocation(Node node, Path location) { return node instanceof ResourceNode && ((ResourceNode) node).getData().getLocation().equals(location); }