Search in sources :

Example 1 with JSONObject

use of com.google.gwt.json.client.JSONObject in project gwtphonegap by dankurka.

the class ContactBrowserImpl method createOrganisation.

private JSONArray createOrganisation(LightArray<ContactOrganisation> organisations) {
    JSONArray jsonArray = new JSONArray();
    for (int i = 0; i < organisations.length(); i++) {
        ContactOrganisation co = organisations.get(i);
        JSONObject orga = new JSONObject();
        orga.put(ORGANISATION_NAME, getAsJSONString(co.getName()));
        orga.put(ORGANISATION_DEPARTMENT, getAsJSONString(co.getDepartment()));
        orga.put(ORGANISATION_TITLE, getAsJSONString(co.getTitle()));
        orga.put(ORGANISATION_TYPE, getAsJSONString(co.getType()));
        orga.put(ORGANISATION_PREF, JSONBoolean.getInstance(co.isPref()));
        jsonArray.set(i, orga);
    }
    return jsonArray;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) JSONArray(com.google.gwt.json.client.JSONArray) ContactOrganisation(com.googlecode.gwtphonegap.client.contacts.ContactOrganisation)

Example 2 with JSONObject

use of com.google.gwt.json.client.JSONObject in project gwtphonegap by dankurka.

the class ContactBrowserImpl method serializeContact.

public JSONObject serializeContact() {
    JSONObject root = new JSONObject();
    // simple values
    root.put(FIELD_ID, getAsJSONString(this.getId()));
    root.put(CONTACT_DISPLAY_NAME, getAsJSONString(this.getDisplayName()));
    root.put(CONTACT_NICK_NAME, getAsJSONString(this.getNickName()));
    if (this.getBirthDay() != null) {
        double value = this.getBirthDay().getTime();
        root.put(CONTACT_BIRTHDAY, new JSONNumber(value));
    }
    root.put(CONTACT_PHONE_NUMBERS, toJSONArray(this.getPhoneNumbers()));
    root.put(CONTACT_EMAILS, toJSONArray(this.getEmails()));
    root.put(CONTACT_IMS, toJSONArray(this.getIms()));
    root.put(CONTACT_PHOTOS, toJSONArray(this.getPhotos()));
    root.put(CONTACT_CATEGORIES, toJSONArray(this.getCategories()));
    root.put(CONTACT_URLS, toJSONArray(this.getUrls()));
    root.put(CONTACT_NAME, createContact(this.getName()));
    root.put(CONTACT_ADDRESSES, createAddresses(this.getContactAddresses()));
    root.put(CONTACT_ORGANISATION, createOrganisation(this.getOrganisations()));
    return root;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) JSONNumber(com.google.gwt.json.client.JSONNumber)

Example 3 with JSONObject

use of com.google.gwt.json.client.JSONObject in project gwtphonegap by dankurka.

the class ContactsBrowserImpl method loadContactsFromStorage.

protected LightMap<Contact> loadContactsFromStorage() {
    LightMap<Contact> map = CollectionFactory.constructMap();
    String item = storage.getItem("gwtphonegap-contact-emulation");
    if (item == null) {
        return map;
    }
    JSONValue parsed = JSONParser.parseStrict(item);
    JSONObject root = parsed.isObject();
    if (root == null) {
        return map;
    } else {
        Set<String> set = root.keySet();
        for (String key : set) {
            JSONObject jsonContact = root.get(key).isObject();
            Contact contact = parseContact(jsonContact);
            map.put(contact.getId(), contact);
        }
    }
    return map;
}
Also used : JSONValue(com.google.gwt.json.client.JSONValue) JSONObject(com.google.gwt.json.client.JSONObject) Contact(com.googlecode.gwtphonegap.client.contacts.Contact)

Example 4 with JSONObject

use of com.google.gwt.json.client.JSONObject in project che by eclipse.

the class OrionEditorWidget method setReadOnly.

@Override
public void setReadOnly(final boolean isReadOnly) {
    editorViewOverlay.setReadonly(isReadOnly);
    final JSONObject properties = editorPropertiesManager.getJsonEditorProperties();
    editorViewOverlay.updateSettings(properties.getJavaScriptObject());
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject)

Example 5 with JSONObject

use of com.google.gwt.json.client.JSONObject in project che by eclipse.

the class EditorPropertiesManager method getJsonEditorProperties.

/** Returns saved settings for editor in json format if they exist or default settings otherwise. */
public JSONObject getJsonEditorProperties() {
    JSONObject jsonProperties = new JSONObject();
    Map<String, JSONValue> editorProperties = getEditorProperties();
    for (String property : editorProperties.keySet()) {
        jsonProperties.put(property, editorProperties.get(property));
    }
    return jsonProperties;
}
Also used : JSONValue(com.google.gwt.json.client.JSONValue) JSONObject(com.google.gwt.json.client.JSONObject)

Aggregations

JSONObject (com.google.gwt.json.client.JSONObject)227 JSONNumber (com.google.gwt.json.client.JSONNumber)109 JSONString (com.google.gwt.json.client.JSONString)74 JSONArray (com.google.gwt.json.client.JSONArray)62 PerunError (cz.metacentrum.perun.webgui.model.PerunError)55 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)54 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)54 JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)50 JSONValue (com.google.gwt.json.client.JSONValue)13 HashMap (java.util.HashMap)12 Map (java.util.Map)8 ArrayList (java.util.ArrayList)6 JsArrayString (com.google.gwt.core.client.JsArrayString)3 User (cz.metacentrum.perun.webgui.model.User)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 Command (com.google.gwt.user.client.Command)2 Contact (com.googlecode.gwtphonegap.client.contacts.Contact)2 ContactField (com.googlecode.gwtphonegap.client.contacts.ContactField)2 StringCallback (com.gwtmobile.phonegap.client.plugins.Bluetooth.StringCallback)2