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;
}
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;
}
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;
}
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());
}
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;
}
Aggregations