use of org.eclipse.che.ide.util.storage.LocalStorage in project che by eclipse.
the class AbstractDebugger method restoreDebuggerState.
/**
* Loads debugger information from the local storage.
*/
protected void restoreDebuggerState() {
invalidateDebugSession();
LocalStorage localStorage = localStorageProvider.get();
if (localStorage == null) {
return;
}
String data = localStorage.getItem(LOCAL_STORAGE_DEBUGGER_SESSION_KEY);
if (data != null && !data.isEmpty()) {
DebugSessionDto debugSessionDto = dtoFactory.createDtoFromJson(data, DebugSessionDto.class);
if (!debugSessionDto.getType().equals(getDebuggerType())) {
return;
}
setDebugSession(debugSessionDto);
}
data = localStorage.getItem(LOCAL_STORAGE_DEBUGGER_STATE_KEY);
if (data != null && !data.isEmpty()) {
currentLocation = dtoFactory.createDtoFromJson(data, LocationDto.class);
}
}
use of org.eclipse.che.ide.util.storage.LocalStorage in project che by eclipse.
the class AbstractDebugger method preserveDebuggerState.
/**
* 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, "");
} else {
localStorage.setItem(LOCAL_STORAGE_DEBUGGER_SESSION_KEY, dtoFactory.toJson(debugSessionDto));
if (currentLocation == null) {
localStorage.setItem(LOCAL_STORAGE_DEBUGGER_STATE_KEY, "");
} else {
localStorage.setItem(LOCAL_STORAGE_DEBUGGER_STATE_KEY, dtoFactory.toJson(currentLocation));
}
}
}
use of org.eclipse.che.ide.util.storage.LocalStorage in project che by eclipse.
the class DebugConfigurationsManagerImpl method retrieveConfigurations.
private List<DebugConfigurationDto> retrieveConfigurations() {
List<DebugConfigurationDto> configurationsList;
if (localStorageOptional.isPresent()) {
final LocalStorage localStorage = localStorageOptional.get();
final Optional<String> data = Optional.fromNullable(localStorage.getItem(LOCAL_STORAGE_DEBUG_CONF_KEY));
if (data.isPresent() && !data.get().isEmpty()) {
configurationsList = dtoFactory.createListDtoFromJson(data.get(), DebugConfigurationDto.class);
} else {
configurationsList = emptyList();
}
} else {
configurationsList = emptyList();
}
return configurationsList;
}
Aggregations