Search in sources :

Example 1 with StateComponent

use of org.eclipse.che.ide.api.component.StateComponent in project che by eclipse.

the class AppStateManager method restoreState.

private void restoreState(JsonObject settings) {
    try {
        if (settings.hasKey(WORKSPACE)) {
            JsonObject workspace = settings.getObject(WORKSPACE);
            for (String key : workspace.keys()) {
                if (persistenceComponents.containsKey(key)) {
                    StateComponent component = persistenceComponents.get(key);
                    component.loadState(workspace.getObject(key));
                }
            }
        }
    } catch (JsonException e) {
        Log.error(getClass(), e);
    }
}
Also used : JsonException(elemental.json.JsonException) JsonObject(elemental.json.JsonObject) StateComponent(org.eclipse.che.ide.api.component.StateComponent)

Example 2 with StateComponent

use of org.eclipse.che.ide.api.component.StateComponent in project che by eclipse.

the class AppStateManager method persistWorkspaceState.

public Promise<Void> persistWorkspaceState(String wsId) {
    final JsonObject settings = Json.createObject();
    JsonObject workspace = Json.createObject();
    settings.put(WORKSPACE, workspace);
    for (Map.Entry<String, StateComponent> entry : persistenceComponents.entrySet()) {
        try {
            String key = entry.getKey();
            workspace.put(key, entry.getValue().getState());
        } catch (Exception e) {
            Log.error(getClass(), e);
        }
    }
    allWsState.put(wsId, settings);
    return writeStateToPreferences(allWsState);
}
Also used : JsonObject(elemental.json.JsonObject) Map(java.util.Map) StateComponent(org.eclipse.che.ide.api.component.StateComponent) OperationException(org.eclipse.che.api.promises.client.OperationException) JsonException(elemental.json.JsonException)

Aggregations

JsonException (elemental.json.JsonException)2 JsonObject (elemental.json.JsonObject)2 StateComponent (org.eclipse.che.ide.api.component.StateComponent)2 Map (java.util.Map)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1