use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToJsonArrayParsedBooleanArray.
@Test
public void shouldToJsonArrayParsedBooleanArray() throws Exception {
Boolean expected = false;
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
String message = array.toJson();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
JsonArray actual = jsonRpcList.toJsonArray();
assertTrue(array.jsEquals(actual));
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToStringifiedListParsedBooleanArray.
@Test
public void shouldToStringifiedListParsedBooleanArray() throws Exception {
Boolean expected = false;
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
String message = array.toJson();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
List<String> actual = jsonRpcList.toStringifiedList();
assertEquals(expected, Boolean.valueOf(actual.iterator().next()));
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToJsonArrayParsedNumberArray.
@Test
public void shouldToJsonArrayParsedNumberArray() throws Exception {
Double expected = 0D;
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
String message = array.toJson();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
JsonArray actual = jsonRpcList.toJsonArray();
assertTrue(array.jsEquals(actual));
}
use of elemental.json.JsonArray in project che by eclipse.
the class EditorAgentImpl method storeEditors.
private JsonArray storeEditors(EditorPartStack partStack) {
JsonArray result = Json.createArray();
int i = 0;
List<EditorPartPresenter> parts = partStack.getParts();
for (EditorPartPresenter part : parts) {
JsonObject file = Json.createObject();
file.put("PATH", part.getEditorInput().getFile().getLocation().toString());
file.put("EDITOR_PROVIDER", openedEditorsToProviders.get(part));
if (part instanceof TextEditor) {
file.put("CURSOR_OFFSET", ((TextEditor) part).getCursorOffset());
file.put("TOP_VISIBLE_LINE", ((TextEditor) part).getTopVisibleLine());
}
if (partStack.getActivePart().equals(part)) {
file.put("ACTIVE", true);
}
result.set(i++, file);
}
return result;
}
use of elemental.json.JsonArray in project che by eclipse.
the class EditorAgentImpl method restore.
private List<Promise<Void>> restore(JsonObject files, EditorPartStack editorPartStack, Map<EditorPartPresenter, EditorPartStack> activeEditors) {
if (files.hasKey("FILES")) {
//plain
JsonArray filesArray = files.getArray("FILES");
List<Promise<Void>> promises = new ArrayList<>();
for (int i = 0; i < filesArray.length(); i++) {
JsonObject file = filesArray.getObject(i);
Promise<Void> openFile = openFile(file, editorPartStack, activeEditors);
promises.add(openFile);
}
return promises;
} else {
//split
return restoreSplit(files, editorPartStack, activeEditors);
}
}
Aggregations