use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class ImageViewer method onFileOperation.
/** {@inheritDoc} */
@Override
public void onFileOperation(FileEvent event) {
if (event.getOperationType() != FileEvent.FileOperation.CLOSE) {
return;
}
final Path eventFilePath = event.getFile().getLocation();
final Path filePath = input.getFile().getLocation();
if (filePath.equals(eventFilePath)) {
workspaceAgent.removePart(this);
}
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class ResourceManager method findResource.
private Promise<Optional<Resource>> findResource(final Path absolutePath, boolean quiet) {
//search resource in local cache
final Optional<Resource> optionalCachedResource = store.getResource(absolutePath);
if (optionalCachedResource.isPresent()) {
return promises.resolve(optionalCachedResource);
}
//request from server
final Path projectPath = Path.valueOf(absolutePath.segment(0)).makeAbsolute();
final Optional<Resource> optProject = store.getResource(projectPath);
final boolean isPresent = optProject.isPresent();
checkState(isPresent || quiet, "Resource with path '" + projectPath + "' doesn't exists");
if (!isPresent) {
return promises.resolve(Optional.<Resource>absent());
}
final Resource project = optProject.get();
checkState(project.getResourceType() == PROJECT, "Resource with path '" + projectPath + "' isn't a project");
final int seekDepth = absolutePath.segmentCount() - 1;
return getRemoteResources((Container) project, seekDepth, true).then(new Function<Resource[], Optional<Resource>>() {
@Override
public Optional<Resource> apply(Resource[] resources) throws FunctionException {
for (Resource resource : resources) {
if (absolutePath.equals(resource.getLocation())) {
return of(resource);
}
}
return absent();
}
});
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class FullTextSearchPresenter method search.
@Override
public void search(final String text) {
final Path startPoint = isNullOrEmpty(view.getPathToSearch()) ? defaultStartPoint : Path.valueOf(view.getPathToSearch());
appContext.getWorkspaceRoot().getContainer(startPoint).then(new Operation<Optional<Container>>() {
@Override
public void apply(Optional<Container> optionalContainer) throws OperationException {
if (!optionalContainer.isPresent()) {
view.showErrorMessage("Path '" + startPoint + "' doesn't exists");
return;
}
final Container container = optionalContainer.get();
container.search(view.getFileMask(), prepareQuery(text)).then(new Operation<Resource[]>() {
@Override
public void apply(Resource[] result) throws OperationException {
view.close();
findResultPresenter.handleResponse(result, text);
}
});
}
});
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class EditorTabWidget method onResourceChanged.
@Override
public void onResourceChanged(ResourceChangedEvent event) {
final ResourceDelta delta = event.getDelta();
if (delta.getKind() == ADDED) {
if (!delta.getResource().isFile() || (delta.getFlags() & (MOVED_FROM | MOVED_TO)) == 0) {
return;
}
final Resource resource = delta.getResource();
final Path movedFrom = delta.getFromPath();
if (file.getLocation().equals(movedFrom)) {
file = (VirtualFile) resource;
title.setText(file.getDisplayName());
}
} else if (delta.getKind() == UPDATED) {
if (!delta.getResource().isFile()) {
return;
}
final Resource resource = delta.getResource();
if (file.getLocation().equals(resource.getLocation())) {
file = (VirtualFile) resource;
title.setText(file.getDisplayName());
}
}
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class InMemoryResourceStore method getResource.
/** {@inheritDoc} */
@Override
public Optional<Resource> getResource(Path path) {
checkArgument(path != null, "Null path occurred");
final Path parent = path.parent();
if (!memoryCache.containsKey(parent)) {
return absent();
}
final Resource[] container = memoryCache.get(parent);
if (container == null) {
return absent();
}
for (Resource resource : container) {
if (resource.getLocation().equals(path)) {
return Optional.of(resource);
}
}
return absent();
}
Aggregations