use of elemental.json.JsonObject in project che by eclipse.
the class EditorAgentImpl method restoreSplit.
private List<Promise<Void>> restoreSplit(JsonObject files, EditorPartStack editorPartStack, Map<EditorPartPresenter, EditorPartStack> activeEditors) {
JsonObject splitFirst = files.getObject("SPLIT_FIRST");
String direction = files.getString("DIRECTION");
double size = files.getNumber("SIZE");
EditorPartStack split = editorMultiPartStack.split(editorPartStack, new Constraints(Direction.valueOf(direction), null), size);
List<Promise<Void>> restoreFirst = restore(splitFirst, editorPartStack, activeEditors);
JsonObject splitSecond = files.getObject("SPLIT_SECOND");
List<Promise<Void>> restoreSecond = restore(splitSecond, split, activeEditors);
List<Promise<Void>> result = new ArrayList<>();
result.addAll(restoreFirst);
result.addAll(restoreSecond);
return result;
}
use of elemental.json.JsonObject in project che by eclipse.
the class WorkspacePresenter method loadState.
@Override
public void loadState(JsonObject state) {
if (state.hasKey("perspectives")) {
JsonObject perspectives = state.getObject("perspectives");
Map<String, Perspective> perspectiveMap = perspectiveManagerProvider.get().getPerspectives();
for (String key : perspectives.keys()) {
if (perspectiveMap.containsKey(key)) {
perspectiveMap.get(key).loadState(perspectives.getObject(key));
}
}
}
}
use of elemental.json.JsonObject in project che by eclipse.
the class WorkspacePresenter method getState.
@Override
public JsonObject getState() {
JsonObject state = Json.createObject();
JsonObject perspectivesJs = Json.createObject();
state.put("perspectives", perspectivesJs);
Map<String, Perspective> perspectives = perspectiveManagerProvider.get().getPerspectives();
for (Map.Entry<String, Perspective> entry : perspectives.entrySet()) {
//store only default perspective
if (entry.getKey().equals(defaultPerspectiveId)) {
perspectivesJs.put(entry.getKey(), entry.getValue().getState());
}
}
return state;
}
use of elemental.json.JsonObject in project che by eclipse.
the class AppStateManagerTest method shouldSaveStateInFile.
@Test
public void shouldSaveStateInFile() throws Exception {
JsonObject object = Json.createObject();
object.put("key1", "value1");
when(component1.getState()).thenReturn(object);
appStateManager.persistWorkspaceState(WS_ID);
verify(component1).getState();
verify(preferencesManager).setValue(anyString(), jsonArgumentCaptor.capture());
assertThat(jsonArgumentCaptor.getValue()).isNotNull().isNotEmpty();
String value = jsonArgumentCaptor.getValue();
JsonObject jsonObject = Json.parse(value).getObject(WS_ID);
JsonObject workspace = jsonObject.getObject("workspace");
assertThat(workspace).isNotNull();
JsonObject jsonObject1 = workspace.getObject("component1");
assertThat(jsonObject1.jsEquals(object)).isTrue();
}
use of elemental.json.JsonObject in project che by eclipse.
the class AppStateManagerTest method restoreShouldCallLoadState.
@Test
public void restoreShouldCallLoadState() throws Exception {
JsonObject ws = Json.createObject();
pref.put(WS_ID, ws);
JsonObject workspace = Json.createObject();
ws.put("workspace", workspace);
JsonObject comp1 = Json.createObject();
workspace.put("component1", comp1);
comp1.put("key1", "value1");
appStateManager.restoreWorkspaceState(WS_ID);
ArgumentCaptor<JsonObject> stateCaptor = ArgumentCaptor.forClass(JsonObject.class);
verify(component1).loadState(stateCaptor.capture());
JsonObject jsonObject = stateCaptor.getValue();
assertThat(jsonObject.hasKey("key1")).isTrue();
assertThat(jsonObject.getString("key1")).isEqualTo("value1");
}
Aggregations