use of com.google.gwt.json.client.JSONValue in project rstudio by rstudio.
the class SimpleRequestCallback method onError.
@Override
public void onError(ServerError error) {
Debug.logError(error);
String message = error.getUserMessage();
// see if a special message was provided
if (useClientInfoMsg_) {
JSONValue errValue = error.getClientInfo();
if (errValue != null) {
JSONString errMsg = errValue.isString();
if (errMsg != null)
message = errMsg.stringValue();
}
}
RStudioGinjector.INSTANCE.getGlobalDisplay().showErrorMessage(caption_, message);
}
use of com.google.gwt.json.client.JSONValue in project perun by CESNET.
the class SetAttribute method prepareJSONObject.
/**
* Prepares a JSON object
*
* @return JSONObject the whole query
*/
private JSONObject prepareJSONObject() {
// create Json object from attribute
JSONObject attr = new JSONObject(attribute);
// get only interested in properties
JSONValue id = attr.get("id");
JSONValue friendlyName = attr.get("friendlyName");
JSONValue namespace = attr.get("namespace");
JSONValue type = attr.get("type");
JSONValue description = attr.get("description");
JSONValue value = attr.get("value");
// create new Attribute jsonObject
JSONObject newAttr = new JSONObject();
newAttr.put("value", value);
newAttr.put("id", id);
newAttr.put("type", type);
newAttr.put("description", description);
newAttr.put("namespace", namespace);
newAttr.put("friendlyName", friendlyName);
newAttr.put("displayName", attr.get("displayName"));
// create whole JSON query
JSONObject jsonQuery = new JSONObject();
for (Map.Entry<String, Integer> attrIds : this.ids.entrySet()) {
jsonQuery.put(attrIds.getKey(), new JSONNumber(attrIds.getValue()));
}
jsonQuery.put("attribute", newAttr);
return jsonQuery;
}
use of com.google.gwt.json.client.JSONValue in project GwtMobile by dennisjzh.
the class BluetoothUi method listBoundDevices.
public void listBoundDevices() {
Bluetooth.listBoundDevices(new StringCallback() {
@Override
public void onSuccess(String result) {
try {
String textHTML = "";
JSONValue value = JSONParser.parseLenient(result);
JSONArray devicesArray = value.isArray();
if (devicesArray != null) {
textHTML = "Result:";
for (int i = 0; i < devicesArray.size(); i++) {
JSONObject deviceObj = devicesArray.get(i).isObject();
textHTML = textHTML + "<br/>" + deviceObj.get("name");
}
text.setHTML(textHTML);
}
} catch (Exception e) {
e.printStackTrace();
text.setHTML("Error: " + e.getMessage());
}
}
@Override
public void onError(String message) {
text.setHTML("Error: " + message);
}
});
}
Aggregations