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);
}
}
use of elemental.json.JsonArray in project che by eclipse.
the class AbstractPerspectivePersistenceTest method shouldRestoreOpenedParts.
@Test
//TODO
@Ignore
public void shouldRestoreOpenedParts() throws Exception {
JsonObject state = Json.createObject();
JsonObject parts = Json.createObject();
state.put("PART_STACKS", parts);
JsonObject partStack = Json.createObject();
parts.put("INFORMATION", partStack);
JsonArray partsArray = Json.createArray();
partStack.put("PARTS", partsArray);
JsonObject part = Json.createObject();
partsArray.set(0, part);
part.put("CLASS", "foo.Bar");
when(dynaProvider.<PartPresenter>getProvider(anyString())).thenReturn(partProvider);
when(partProvider.get()).thenReturn(partPresenter);
perspective.loadState(state);
verify(dynaProvider).getProvider("foo.Bar");
verify(partProvider).get();
verify(partStackPresenter).addPart(partPresenter);
}
use of elemental.json.JsonArray in project che by eclipse.
the class ProjectExplorerStateComponent method getState.
@Override
public JsonObject getState() {
final List<Path> paths = new ArrayList<>();
outer: for (Node node : projectExplorer.getTree().getNodeStorage().getAll()) {
if (projectExplorer.getTree().isExpanded(node) && node instanceof ResourceNode) {
final List<Node> childrenToStore = projectExplorer.getTree().getNodeStorage().getChildren(node);
for (Node children : childrenToStore) {
if (children instanceof ResourceNode) {
paths.add(((ResourceNode) children).getData().getLocation());
continue outer;
}
}
}
}
JsonObject state = Json.createObject();
JsonArray array = Json.createArray();
state.put(PATH_PARAM_ID, array);
int i = 0;
for (Path path : paths) {
array.set(i++, path.toString());
}
state.put(SHOW_HIDDEN_FILES, projectExplorer.isShowHiddenFiles());
return state;
}
Aggregations