private void preserve() { if (storage == null) { return; } List<BreakpointDto> breakpoints2save = new LinkedList<>(); for (Breakpoint breakpoint : breakpoints) { breakpoints2save.add(toDto(breakpoint)); } storage.setItem(storageKey, dtoFactory.toJson(breakpoints2save)); }
/** Preserves debugger information into the local storage. */ protected void preserveDebuggerState() { LocalStorage localStorage = localStorageProvider.get(); if (localStorage == null) { return; } if (!isConnected()) { localStorage.setItem(LOCAL_STORAGE_DEBUGGER_SESSION_KEY, ""); localStorage.setItem(LOCAL_STORAGE_DEBUGGER_STATE_KEY, ""); localStorage.setItem(LOCAL_STORAGE_DEBUGGER_DISPOSABLE_BREAKPOINT_KEY, ""); } else { localStorage.setItem(LOCAL_STORAGE_DEBUGGER_SESSION_KEY, dtoFactory.toJson(debugSessionDto)); if (suspendEventDto == null) { localStorage.setItem(LOCAL_STORAGE_DEBUGGER_STATE_KEY, ""); } else { localStorage.setItem(LOCAL_STORAGE_DEBUGGER_STATE_KEY, dtoFactory.toJson(suspendEventDto)); } if (disposableBreakpoint == null) { localStorage.setItem(LOCAL_STORAGE_DEBUGGER_DISPOSABLE_BREAKPOINT_KEY, ""); } else { localStorage.setItem( LOCAL_STORAGE_DEBUGGER_DISPOSABLE_BREAKPOINT_KEY, dtoFactory.toJson(disposableBreakpoint)); } } }
private void saveConfigurations() { if (localStorageOptional.isPresent()) { List<DebugConfigurationDto> configurationDtos = new ArrayList<>(); for (DebugConfiguration configuration : configurations) { configurationDtos.add( dtoFactory .createDto(DebugConfigurationDto.class) .withType(configuration.getType().getId()) .withName(configuration.getName()) .withHost(configuration.getHost()) .withPort(configuration.getPort()) .withConnectionProperties(configuration.getConnectionProperties())); } localStorageOptional .get() .setItem(LOCAL_STORAGE_DEBUG_CONF_KEY, dtoFactory.toJson(configurationDtos)); } }
/** Updates the specified {@code project} with the given {@code commands}. */ private Promise<Void> updateProject(Project project, List<CommandImpl> commands) { MutableProjectConfig config = new MutableProjectConfig(project); Map<String, List<String>> attributes = config.getAttributes(); List<String> attrValue = new ArrayList<>(attributes.size()); for (CommandImpl command : commands) { CommandDto commandDto = dtoFactory .createDto(CommandDto.class) .withName(command.getName()) .withType(command.getType()) .withCommandLine(command.getCommandLine()) .withAttributes(command.getAttributes()); attrValue.add(dtoFactory.toJson(commandDto)); } attributes.put(COMMANDS_ATTRIBUTE_NAME, attrValue); return project.update().withBody(config).send().then((Function<Project, Void>) arg -> null); }