use of elemental.json.JsonObject 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;
}
use of elemental.json.JsonObject in project che by eclipse.
the class AbstractPerspectivePersistenceTest method shouldStoreParts.
@Test
public void shouldStoreParts() throws Exception {
JsonObject state = perspective.getState();
JsonObject partStacks = state.getObject("PART_STACKS");
assertThat(partStacks).isNotNull();
}
use of elemental.json.JsonObject 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.JsonObject in project che by eclipse.
the class JsonRpcEntityQualifier method qualify.
public JsonRpcEntityType qualify(String message) {
checkNotNull(message, "Message must not be null");
checkArgument(!message.isEmpty(), "Message must not be empty");
Log.debug(getClass(), "Qualifying message: " + message);
JsonObject jsonObject = jsonFactory.parse(message);
List<String> keys = asList(jsonObject.keys());
Log.debug(getClass(), "Json keys: " + keys);
if (keys.contains("method")) {
Log.debug(getClass(), "Qualified to request");
return JsonRpcEntityType.REQUEST;
} else if (keys.contains("error") != keys.contains("result")) {
Log.debug(getClass(), "Qualified to response");
return JsonRpcEntityType.RESPONSE;
} else {
Log.debug(getClass(), "Qualified to undefined");
return JsonRpcEntityType.UNDEFINED;
}
}
use of elemental.json.JsonObject in project che by eclipse.
the class JsonRpcError method toJsonObject.
public JsonObject toJsonObject() {
JsonObject error = jsonFactory.createObject();
error.put("code", code);
error.put("message", message);
return error;
}
Aggregations