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);
}
}
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);
}
Aggregations