use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class PublishDiagnosticsProcessor method processDiagnostics.
public void processDiagnostics(PublishDiagnosticsParamsDTO diagnosticsMessage) {
EditorPartPresenter openedEditor = editorAgent.getOpenedEditor(new Path(diagnosticsMessage.getUri()));
//TODO add markers
if (openedEditor == null) {
return;
}
if (openedEditor instanceof TextEditor) {
TextEditorConfiguration editorConfiguration = ((TextEditor) openedEditor).getConfiguration();
AnnotationModel annotationModel = editorConfiguration.getAnnotationModel();
if (annotationModel != null && annotationModel instanceof DiagnosticCollector) {
DiagnosticCollector collector = (DiagnosticCollector) annotationModel;
collector.beginReporting();
try {
for (DiagnosticDTO diagnostic : diagnosticsMessage.getDiagnostics()) {
collector.acceptDiagnostic(diagnostic);
}
} finally {
collector.endReporting();
}
}
}
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class CommitPresenter method showDiff.
/** {@inheritDoc} */
@Override
public void showDiff(final String path) {
final Project project = appContext.getRootProject();
checkState(project != null);
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {
@Override
public Promise<CLIOutputResponse> perform(Credentials credentials) {
return service.showDiff(project.getLocation(), new Path[] { valueOf(path) }, "HEAD", credentials);
}
}, null).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
String content = Joiner.on('\n').join(response.getOutput());
diffViewerPresenter.showDiff(content);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class SubversionActionPresenter method toRelative.
protected Path[] toRelative(Container project, Resource[] paths) {
if (paths == null || paths.length == 0) {
return new Path[0];
}
Path[] rel = new Path[0];
for (Resource resource : paths) {
if (project.getLocation().isPrefixOf(resource.getLocation())) {
Path temp = resource.getLocation().removeFirstSegments(project.getLocation().segmentCount());
if (temp.segmentCount() == 0) {
temp = Path.valueOf(".");
}
rel = Arrays.add(rel, temp);
}
}
return rel;
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class ResourceManager method importProject.
protected Promise<Project> importProject(final Project.ProjectRequest importRequest) {
checkArgument(checkProjectName(importRequest.getBody().getName()), "Invalid project name");
checkNotNull(importRequest.getBody().getSource(), "Null source configuration occurred");
final Path path = Path.valueOf(importRequest.getBody().getPath());
return findResource(path, true).thenPromise(new Function<Optional<Resource>, Promise<Project>>() {
@Override
public Promise<Project> apply(final Optional<Resource> resource) throws FunctionException {
final SourceStorage sourceStorage = importRequest.getBody().getSource();
final SourceStorageDto sourceStorageDto = dtoFactory.createDto(SourceStorageDto.class).withType(sourceStorage.getType()).withLocation(sourceStorage.getLocation()).withParameters(sourceStorage.getParameters());
return ps.importProject(path, sourceStorageDto).thenPromise(new Function<Void, Promise<Project>>() {
@Override
public Promise<Project> apply(Void ignored) throws FunctionException {
return ps.getProject(path).then(new Function<ProjectConfigDto, Project>() {
@Override
public Project apply(ProjectConfigDto config) throws FunctionException {
cachedConfigs = add(cachedConfigs, config);
Resource project = resourceFactory.newProjectImpl(config, ResourceManager.this);
checkState(project != null, "Failed to locate imported project's configuration");
store.register(project);
eventBus.fireEvent(new ResourceChangedEvent(new ResourceDeltaImpl(project, (resource.isPresent() ? UPDATED : ADDED) | DERIVED)));
return (Project) project;
}
});
}
});
}
});
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class ResourceManager method search.
protected Promise<Resource[]> search(final Container container, String fileMask, String contentMask) {
QueryExpression queryExpression = new QueryExpression();
if (!isNullOrEmpty(contentMask)) {
queryExpression.setText(contentMask);
}
if (!isNullOrEmpty(fileMask)) {
queryExpression.setName(fileMask);
}
if (!container.getLocation().isRoot()) {
queryExpression.setPath(container.getLocation().toString());
}
return ps.search(queryExpression).thenPromise(new Function<List<ItemReference>, Promise<Resource[]>>() {
@Override
public Promise<Resource[]> apply(final List<ItemReference> references) throws FunctionException {
if (references.isEmpty()) {
return promises.resolve(NO_RESOURCES);
}
int maxDepth = 0;
final Path[] paths = new Path[references.size()];
for (int i = 0; i < paths.length; i++) {
final Path path = Path.valueOf(references.get(i).getPath());
paths[i] = path;
if (path.segmentCount() > maxDepth) {
maxDepth = path.segmentCount();
}
}
return getRemoteResources(container, maxDepth, true).then(new Function<Resource[], Resource[]>() {
@Override
public Resource[] apply(Resource[] resources) throws FunctionException {
Resource[] filtered = NO_RESOURCES;
Path[] mutablePaths = paths;
outer: for (Resource resource : resources) {
if (resource.getResourceType() != FILE) {
continue;
}
for (int i = 0; i < mutablePaths.length; i++) {
Path path = mutablePaths[i];
if (path.segmentCount() == resource.getLocation().segmentCount() && path.equals(resource.getLocation())) {
Resource[] tmpFiltered = copyOf(filtered, filtered.length + 1);
tmpFiltered[filtered.length] = resource;
filtered = tmpFiltered;
//reduce the size of mutablePaths by removing already checked item
int size = mutablePaths.length;
int numMoved = mutablePaths.length - i - 1;
if (numMoved > 0) {
arraycopy(mutablePaths, i + 1, mutablePaths, i, numMoved);
}
mutablePaths = copyOf(mutablePaths, --size);
continue outer;
}
}
}
return filtered;
}
});
}
});
}
Aggregations