/** {@inheritDoc} */ @Override public Path getFromPath() { if ((status & MOVED_FROM) != 0 || (status & COPIED_FROM) != 0) { return oldResource.getLocation(); } return null; }
/** {@inheritDoc} */ @Override public Path getToPath() { if ((status & MOVED_TO) != 0) { return newResource.getLocation(); } return null; }
/** {@inheritDoc} */ @Override public int compare(Resource o1, Resource o2) { return o1.getLocation().toString().compareTo(o2.getLocation().toString()); } }
@Nullable @Override public String apply(@Nullable Resource input) { checkNotNull(input); return input.getLocation().toString(); } };
protected String getUrl(Resource resource) { checkArgument(!resource.getLocation().isRoot(), "Workspace root doesn't have export URL"); final String baseUrl = appContext.getWsAgentServerApiEndpoint() + "/project/export"; if (resource.getResourceType() == FILE) { return baseUrl + "/file" + resource.getLocation(); } return urlModifier.modify(baseUrl + resource.getLocation()); }
private boolean containsResourcesToExcludes(Resource[] resources) { if (resources == null || resources.length <= 0) { return false; } List<Resource> resourcesToExclude = asList(resources); return resourcesToExclude .stream() .map(resource -> resource.getLocation().toString()) .anyMatch(pathToExclude -> !fileWatcherExcludesOperation.isExcluded(pathToExclude)); } }
private boolean containsResourcesToRemoveFromExcludes(Resource[] resources) { if (resources == null || resources.length <= 0) { return false; } List<Resource> resourcesToExclude = asList(resources); return resourcesToExclude .stream() .map(resource -> resource.getLocation().toString()) .anyMatch(pathToExclude -> fileWatcherExcludesOperation.isExcluded(pathToExclude)); } }
public static String resolveFQN(Resource resource) { final Optional<Resource> srcFolder = resource.getParentWithMarker(SourceFolderMarker.ID); if (!srcFolder.isPresent()) { throw new IllegalStateException( "Fully qualified name can not be resolved for '" + resource.getLocation() + "'"); } return resolveFQN((Container) srcFolder.get(), resource); }
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); } }
@Nullable @Override public String apply(@Nullable Resource input) { checkNotNull(input); return appContext.getProjectsRoot().append(input.getLocation()).toString(); } };
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); }
/** {@inheritDoc} */ @Override public int compareTo(Resource o) { return getLocation().toString().compareTo(o.getLocation().toString()); }
@Override public void actionPerformed(ActionEvent e) { final Resource[] resources = appContext.getResources(); Set<String> pathsToRemove = stream(resources).map(resource -> resource.getLocation().toString()).collect(toSet()); fileWatcherExcludesOperation .removeFromFileWatcherExcludes(pathsToRemove) .catchError( error -> { notificationManager.notify(error.getMessage(), FAIL, EMERGE_MODE); }); }
private void acceptButtonClicked() { List<Node> nodes = tree.getSelectionModel().getSelectedNodes(); if (nodes.isEmpty()) { return; } Node selectedNode = nodes.get(0); delegate.setSelectedNode(((ResourceNode) selectedNode).getData().getLocation().toString()); hide(); } }
private void acceptButtonClicked() { List<Node> nodes = tree.getSelectionModel().getSelectedNodes(); if (nodes.isEmpty()) { return; } Node selectedNode = nodes.get(0); if (selectedNode instanceof ResourceNode) { delegate.setSelectedPath(((ResourceNode) selectedNode).getData().getLocation().toString()); } hide(); } }
@Override public Promise<String> expand() { final Resource[] resources = appContext.getResources(); if (resources != null && resources.length == 1) { return promises.resolve(resources[0].getLocation().toString()); } return promises.resolve(""); } }
private Promise<Void> onExternalDeltaRemoved(final ResourceDelta delta) { final Optional<Resource> resourceOptional = store.getResource(delta.getFromPath()); if (resourceOptional.isPresent()) { final Resource resource = resourceOptional.get(); store.dispose(resource.getLocation(), true); eventBus.fireEvent( new ResourceChangedEvent(new ResourceDeltaImpl(resource, REMOVED | DERIVED))); } return promises.resolve(null); }
@Override public void actionPerformed(ActionEvent event) { Resource resource = appContext.get().getResource(); if (resource.isFile()) { final Container parent = resource.getParent(); resource = parent; } Path path = appContext.get().getProjectsRoot().append(resource.getLocation()); Command cmdTmpl = GWT.create(Command.class); String command = cmdTmpl.openInTerminalCommand(path.toString()).asString(); processesPanelPresenter.newTerminal(TerminalOptionsJso.create().withCommand(command), true); } }
@Override public void onResourceChanged(ResourceChangedEvent event) { final ResourceDelta delta = event.getDelta(); if (delta.getKind() == UPDATED && delta.getResource().getLocation().equals(getData())) { eventBus.fireEvent(new SyntheticNodeUpdateEvent(LibrariesNode.this)); } }