List of usage examples for com.google.gwt.core.client JavaScriptObject createObject
public static native JavaScriptObject createObject() ;
From source file:com.google.gerrit.client.api.DefaultActions.java
License:Apache License
private static void invoke(ActionInfo action, RestApi api, AsyncCallback<JavaScriptObject> cb) { if ("GET".equalsIgnoreCase(action.method())) { api.get(cb);/* w w w . ja va 2 s. c o m*/ } else if ("PUT".equalsIgnoreCase(action.method())) { api.put(JavaScriptObject.createObject(), cb); } else if ("DELETE".equalsIgnoreCase(action.method())) { api.delete(cb); } else { api.post(JavaScriptObject.createObject(), cb); } }
From source file:com.google.gerrit.client.changes.PatchSetComplexDisclosurePanel.java
License:Apache License
private void populateCommands(final PatchSetDetail detail) { for (final UiCommandDetail cmd : detail.getCommands()) { final Button b = new Button(cmd.label); b.setEnabled(cmd.enabled);/*from w w w . ja v a 2s.c om*/ b.setTitle(cmd.title); b.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { if (cmd.confirmationMessage != null && !cmd.confirmationMessage.isEmpty()) { ConfirmationDialog confirmationDialog = new ConfirmationDialog(cmd.title, new SafeHtmlBuilder().append(cmd.confirmationMessage), new ConfirmationCallback() { @Override public void onOk() { postProcessCommand(cmd, b); } }); confirmationDialog.center(); } else { postProcessCommand(cmd, b); } } private void postProcessCommand(final UiCommandDetail cmd, final Button b) { b.setEnabled(false); AsyncCallback<NativeString> cb = new AsyncCallback<NativeString>() { @Override public void onFailure(Throwable caught) { b.setEnabled(true); new ErrorDialog(caught).center(); } @Override public void onSuccess(NativeString msg) { b.setEnabled(true); if (msg != null && !msg.asString().isEmpty()) { Window.alert(msg.asString()); } } }; RestApi api = ChangeApi.revision(patchSet.getId()).view(cmd.id); if ("PUT".equalsIgnoreCase(cmd.method)) { api.put(JavaScriptObject.createObject(), cb); } else if ("DELETE".equalsIgnoreCase(cmd.method)) { api.delete(cb); } else { api.post(JavaScriptObject.createObject(), cb); } } }); actionsPanel.add(b); } }
From source file:com.google.gerrit.client.groups.GroupApi.java
License:Apache License
/** Create a new group */ public static void createGroup(String groupName, AsyncCallback<GroupInfo> cb) { JavaScriptObject in = JavaScriptObject.createObject(); new RestApi("/groups/").id(groupName).ifNoneMatch().put(in, cb); }
From source file:com.google.gwt.gadgets.sample.traveler.client.Location.java
License:Apache License
public static Location newInstance() { return JavaScriptObject.createObject().cast(); }
From source file:com.google.gwt.reflect.test.annotations.AbstractAnnotation.java
public AbstractAnnotation() { this(JavaScriptObject.createObject()); }
From source file:com.google.mobile.trippy.web.client.db.JsoTrip.java
License:Apache License
@SuppressWarnings("unchecked") public final void setTripItemIds(final IdDayDateTupleList idDateTupleList) { JsArray<JsoIdDayDateTuple> idArr = (JsArray<JsoIdDayDateTuple>) JavaScriptObject.createArray(); for (IdDayDateTuple s : idDateTupleList.getTuples()) { JsoIdDayDateTuple idTup = (JsoIdDayDateTuple) JavaScriptObject.createObject(); idTup.setId(s.getId());/*from w w w . ja va2 s.co m*/ idTup.setDay(s.getDay() + ""); idTup.setDate(s.getLastModified().getTime() + ""); idArr.push(idTup); } setTripItemIds_(idArr); }
From source file:com.google.mobile.trippy.web.client.db.JsoTrip.java
License:Apache License
@SuppressWarnings("unchecked") public final void setCommentIds(final IdDateTupleList idDateTupleList) { JsArray<JsoIdDateTuple> idArr = (JsArray<JsoIdDateTuple>) JavaScriptObject.createArray(); for (IdDateTuple s : idDateTupleList.getTuples()) { JsoIdDateTuple idTup = (JsoIdDateTuple) JavaScriptObject.createObject(); idTup.setId(s.getId());//from ww w .j av a2s . c om idTup.setDate(s.getLastModified().getTime() + ""); idArr.push(idTup); } setCommentIds_(idArr); }
From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java
License:Apache License
public void addTrip(final Trip trip) { JsoTrip jsoTrip = (JsoTrip) JavaScriptObject.createObject(); jsoTrip.setTrip(trip);/* w w w .j a v a2 s . co m*/ final String tripKey = KEY_LOCAL_STORE_TRIP_PREFIX + trip.getKey(); LocalDbService.makePersistent(tripKey, new JSONObject(jsoTrip).toString()); final JsArrayString tripKeys = getIndexKeys(KEY_LOCAL_STORE_TRIPS); for (int i = 0; i < tripKeys.length(); ++i) { if (tripKeys.get(i).equals(tripKey)) { return; } } tripKeys.push(tripKey); setIndexKeys(KEY_LOCAL_STORE_TRIPS, tripKeys); eventBus.fireEvent(new TripAddedEvent(trip)); }
From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java
License:Apache License
public void updateTrip(final Trip trip) { JsoTrip jsoTrip = (JsoTrip) JavaScriptObject.createObject(); jsoTrip.setTrip(trip);/*from ww w .j av a2 s . c o m*/ final String tripKey = KEY_LOCAL_STORE_TRIP_PREFIX + trip.getKey(); LocalDbService.makePersistent(tripKey, new JSONObject(jsoTrip).toString()); eventBus.fireEvent(new TripUpdatedEvent(trip)); }
From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java
License:Apache License
public void addTripItem(final TripItem tripItem) { JsoTripItem jsoTripItem = (JsoTripItem) JavaScriptObject.createObject(); jsoTripItem.setTripItem(tripItem);/* ww w . j a va2s. c om*/ final String tripItemKey = KEY_LOCAL_STORE_TI_PREFIX + tripItem.getKey(); LocalDbService.makePersistent(tripItemKey, new JSONObject(jsoTripItem).toString()); final JsArrayString tripItemKeys = getIndexKeys(KEY_LOCAL_STORE_TIS_PREFIX + tripItem.getTripId()); for (int i = 0; i < tripItemKeys.length(); ++i) { if (tripItemKeys.get(i).equals(tripItemKey)) { return; } } tripItemKeys.push(tripItemKey); setIndexKeys(KEY_LOCAL_STORE_TIS_PREFIX + tripItem.getTripId(), tripItemKeys); eventBus.fireEvent(new TripItemAddedEvent(tripItem)); final Trip trip = getTrip(tripItem.getTripId()); final String tripItemStartDate = "Day " + tripItem.getStartDay(); final String latlng = tripItem.getLatitude() + "," + tripItem.getLongitude(); utils.addTripItem(tripItemStartDate, tripItem.getTripId(), tripItem.getKey(), tripItem.getName(), tripItem.getAddress() + ", " + trip.getLocation(), latlng, utils.getTripItemPosition(tripItem.getTripId(), tripItem.getKey(), tripItem.getStartDay())); }