use of org.eclipse.che.api.promises.client.FunctionException in project che by eclipse.
the class BreakpointManagerImpl method restoreBreakpoints.
private void restoreBreakpoints() {
Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage == null) {
return;
}
String data = localStorage.getItem(LOCAL_STORAGE_BREAKPOINTS_KEY);
if (data == null || data.isEmpty()) {
return;
}
List<StorableBreakpointDto> allDtoBreakpoints = dtoFactory.createListDtoFromJson(data, StorableBreakpointDto.class);
Promise<Void> bpPromise = promises.resolve(null);
for (final StorableBreakpointDto dto : allDtoBreakpoints) {
bpPromise.thenPromise(new Function<Void, Promise<Void>>() {
@Override
public Promise<Void> apply(Void ignored) throws FunctionException {
return appContext.getWorkspaceRoot().getFile(dto.getPath()).then(new Function<Optional<File>, Void>() {
@Override
public Void apply(Optional<File> file) throws FunctionException {
if (!file.isPresent()) {
return null;
}
if (dto.getType() == Type.CURRENT) {
doSetCurrentBreakpoint(file.get(), dto.getLineNumber());
} else {
addBreakpoint(new Breakpoint(dto.getType(), dto.getLineNumber(), dto.getPath(), file.get(), dto.isActive()));
}
return null;
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
Log.error(getClass(), "Failed to restore breakpoint. ", arg.getCause());
}
});
}
});
}
}
use of org.eclipse.che.api.promises.client.FunctionException in project che by eclipse.
the class CommandManagerImpl method update.
@Override
public Promise<CommandImpl> update(final String commandName, final CommandImpl command) {
final String name;
if (commandName.equals(command.getName())) {
name = commandName;
} else {
name = getUniqueCommandName(command.getType(), command.getName());
}
final CommandDto commandDto = dtoFactory.createDto(CommandDto.class).withName(name).withCommandLine(command.getCommandLine()).withType(command.getType()).withAttributes(command.getAttributes());
return workspaceServiceClient.updateCommand(appContext.getWorkspaceId(), commandName, commandDto).then(new Function<WorkspaceDto, CommandImpl>() {
@Override
public CommandImpl apply(WorkspaceDto arg) throws FunctionException {
final CommandImpl updatedCommand = new CommandImpl(commandDto.getName(), command.getCommandLine(), command.getType(), command.getAttributes());
commands.remove(commandName);
commands.put(updatedCommand.getName(), updatedCommand);
fireCommandUpdated(updatedCommand);
return updatedCommand;
}
});
}
use of org.eclipse.che.api.promises.client.FunctionException in project che by eclipse.
the class FindSymbolAction method searchSymbols.
private Promise<List<SymbolEntry>> searchSymbols(final String value) {
WorkspaceSymbolParamsDTO params = dtoFactory.createDto(WorkspaceSymbolParamsDTO.class);
params.setQuery(value);
params.setFileUri(editorAgent.getActiveEditor().getEditorInput().getFile().getLocation().toString());
return workspaceServiceClient.symbol(params).then(new Function<List<SymbolInformationDTO>, List<SymbolEntry>>() {
@Override
public List<SymbolEntry> apply(List<SymbolInformationDTO> types) throws FunctionException {
return toSymbolEntries(types, value);
}
});
}
use of org.eclipse.che.api.promises.client.FunctionException in project che by eclipse.
the class LanguageServerEditorProvider method createEditor.
@Override
public Promise<EditorPartPresenter> createEditor(VirtualFile file) {
if (file instanceof File) {
File resource = (File) file;
Promise<InitializeResult> promise = registry.getOrInitializeServer(resource.getRelatedProject().get().getPath(), resource.getExtension(), resource.getLocation().toString());
final MessageLoader loader = loaderFactory.newLoader("Initializing Language Server for " + resource.getExtension());
loader.show();
return promise.thenPromise(new Function<InitializeResult, Promise<EditorPartPresenter>>() {
@Override
public Promise<EditorPartPresenter> apply(InitializeResult arg) throws FunctionException {
loader.hide();
return Promises.<EditorPartPresenter>resolve(createEditor(editorConfigurationFactory.build(arg.getCapabilities())));
}
});
}
return null;
}
use of org.eclipse.che.api.promises.client.FunctionException 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;
}
});
}
});
}
});
}
Aggregations