Search in sources :

Example 21 with JSONValue

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);
}
Also used : JSONValue(com.google.gwt.json.client.JSONValue) JSONString(com.google.gwt.json.client.JSONString) JSONString(com.google.gwt.json.client.JSONString)

Example 22 with JSONValue

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;
}
Also used : JSONValue(com.google.gwt.json.client.JSONValue) JSONObject(com.google.gwt.json.client.JSONObject) JSONNumber(com.google.gwt.json.client.JSONNumber) HashMap(java.util.HashMap) Map(java.util.Map)

Example 23 with JSONValue

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);
        }
    });
}
Also used : JSONValue(com.google.gwt.json.client.JSONValue) JSONObject(com.google.gwt.json.client.JSONObject) StringCallback(com.gwtmobile.phonegap.client.plugins.Bluetooth.StringCallback) JSONArray(com.google.gwt.json.client.JSONArray)

Aggregations

JSONValue (com.google.gwt.json.client.JSONValue)23 JSONObject (com.google.gwt.json.client.JSONObject)13 JSONArray (com.google.gwt.json.client.JSONArray)10 JSONString (com.google.gwt.json.client.JSONString)8 HashMap (java.util.HashMap)5 Date (java.util.Date)4 JSONNumber (com.google.gwt.json.client.JSONNumber)3 EntryPoint (com.google.gwt.core.client.EntryPoint)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 RequestBuilder (com.google.gwt.http.client.RequestBuilder)2 RequestCallback (com.google.gwt.http.client.RequestCallback)2 RequestException (com.google.gwt.http.client.RequestException)2 InlineLabel (com.google.gwt.user.client.ui.InlineLabel)2 StringCallback (com.gwtmobile.phonegap.client.plugins.Bluetooth.StringCallback)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 JsArrayString (com.google.gwt.core.client.JsArrayString)1 Style (com.google.gwt.dom.client.Style)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1