use of elemental.json.JsonObject 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 elemental.json.JsonObject 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);
}
use of elemental.json.JsonObject in project che by eclipse.
the class AbstractPerspective method loadState.
@Override
public void loadState(@NotNull JsonObject state) {
if (state.hasKey("PART_STACKS")) {
JsonObject part_stacks = state.getObject("PART_STACKS");
for (String partStackType : part_stacks.keys()) {
JsonObject partStack = part_stacks.getObject(partStackType);
switch(PartStackType.valueOf(partStackType)) {
case INFORMATION:
restorePartController(partStacks.get(INFORMATION), belowPartController, partStack);
break;
case NAVIGATION:
restorePartController(partStacks.get(NAVIGATION), leftPartController, partStack);
break;
case TOOLING:
restorePartController(partStacks.get(TOOLING), rightPartController, partStack);
break;
}
}
}
if (state.hasKey("ACTIVE_PART")) {
String activePart = state.getString("ACTIVE_PART");
Provider<PartPresenter> provider = dynaProvider.getProvider(activePart);
if (provider != null) {
setActivePart(provider.get());
}
}
}
use of elemental.json.JsonObject in project che by eclipse.
the class JsonRpcResultTest method shouldToStringWhenParsingStringWithResultAsASingleVoid.
@Test
public void shouldToStringWhenParsingStringWithResultAsASingleVoid() throws Exception {
JsonObject value = jsonFactory.createObject();
String expected = value.toString();
JsonRpcResult jsonRpcResult = new JsonRpcResult(value.toJson(), jsonFactory, dtoFactory);
String actual = jsonRpcResult.toString();
assertEquals(expected, actual);
}
use of elemental.json.JsonObject in project che by eclipse.
the class JsonRpcResultTest method shouldToStringWhenPassingParametersWithResultAsASingleVoid.
@Test
public void shouldToStringWhenPassingParametersWithResultAsASingleVoid() throws Exception {
JsonObject value = jsonFactory.createObject();
String expected = value.toString();
JsonRpcResult jsonRpcResult = new JsonRpcResult(null, dtoFactory, jsonFactory);
String actual = jsonRpcResult.toString();
assertEquals(expected, actual);
}
Aggregations