Search in sources :

Example 1 with LocalStorage

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);
    }
}
Also used : LocalStorage(org.eclipse.che.ide.util.storage.LocalStorage) DebugSessionDto(org.eclipse.che.api.debug.shared.dto.DebugSessionDto) LocationDto(org.eclipse.che.api.debug.shared.dto.LocationDto)

Example 2 with LocalStorage

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));
        }
    }
}
Also used : LocalStorage(org.eclipse.che.ide.util.storage.LocalStorage)

Example 3 with LocalStorage

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;
}
Also used : LocalStorage(org.eclipse.che.ide.util.storage.LocalStorage) DebugConfigurationDto(org.eclipse.che.plugin.debugger.ide.configuration.dto.DebugConfigurationDto)

Aggregations

LocalStorage (org.eclipse.che.ide.util.storage.LocalStorage)3 DebugSessionDto (org.eclipse.che.api.debug.shared.dto.DebugSessionDto)1 LocationDto (org.eclipse.che.api.debug.shared.dto.LocationDto)1 DebugConfigurationDto (org.eclipse.che.plugin.debugger.ide.configuration.dto.DebugConfigurationDto)1