use of org.eclipse.che.ide.api.debug.dto.StorableBreakpointDto 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.ide.api.debug.dto.StorableBreakpointDto in project che by eclipse.
the class BreakpointManagerImpl method preserveBreakpoints.
private void preserveBreakpoints() {
Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage != null) {
List<StorableBreakpointDto> allDtoBreakpoints = new LinkedList<StorableBreakpointDto>();
List<Breakpoint> allBreakpoints = getBreakpointList();
if (currentBreakpoint != null) {
allBreakpoints.add(currentBreakpoint);
}
for (Breakpoint breakpoint : allBreakpoints) {
StorableBreakpointDto dto = dtoFactory.createDto(StorableBreakpointDto.class);
dto.setType(breakpoint.getType());
dto.setPath(breakpoint.getPath());
dto.setLineNumber(breakpoint.getLineNumber());
if (breakpoint.getFile() instanceof Resource) {
final Optional<Project> project = ((Resource) breakpoint.getFile()).getRelatedProject();
if (project.isPresent()) {
final ProjectConfigDto projectDto = dtoFactory.createDto(ProjectConfigDto.class).withName(project.get().getName()).withPath(project.get().getPath()).withType(project.get().getType()).withDescription(project.get().getDescription()).withAttributes(project.get().getAttributes()).withMixins(project.get().getMixins());
//TODO need to think to change argument type from dto to model interface
dto.setFileProjectConfig(projectDto);
}
}
dto.setActive(breakpoint.isActive());
allDtoBreakpoints.add(dto);
}
String data = dtoFactory.toJson(allDtoBreakpoints);
localStorage.setItem(LOCAL_STORAGE_BREAKPOINTS_KEY, data);
}
}
Aggregations