List of usage examples for com.google.gwt.requestfactory.shared Receiver Receiver
Receiver
From source file:com.google.gwt.sample.expenses.client.place.AbstractProxyListActivity.java
License:Apache License
/** * Called by the table as it needs data. *//*from www . j a v a2 s . c o m*/ public void onRangeChanged(HasData<P> listView) { final Range range = listView.getVisibleRange(); final Receiver<List<P>> callback = new Receiver<List<P>>() { @Override public void onSuccess(List<P> values) { if (view == null) { // This activity is dead return; } idToRow.clear(); idToProxy.clear(); for (int i = 0, row = range.getStart(); i < values.size(); i++, row++) { P proxy = values.get(i); @SuppressWarnings("unchecked") // Why is this cast needed? EntityProxyId<P> proxyId = (EntityProxyId<P>) proxy.stableId(); idToRow.put(proxyId, row); idToProxy.put(proxyId, proxy); } getView().asHasData().setRowData(range.getStart(), values); if (display != null) { display.setWidget(getView()); } } }; fireRangeRequest(range, callback); }
From source file:com.google.gwt.sample.expenses.client.place.AbstractProxyListActivity.java
License:Apache License
private void getLastPage() { fireCountRequest(new Receiver<Long>() { @Override//ww w.j a v a2 s.co m public void onSuccess(Long response) { if (view == null) { // This activity is dead return; } HasData<P> table = getView().asHasData(); int rows = response.intValue(); table.setRowCount(rows, true); if (rows > 0) { int pageSize = table.getVisibleRange().getLength(); int remnant = rows % pageSize; if (remnant == 0) { table.setVisibleRange(rows - pageSize, pageSize); } else { table.setVisibleRange(rows - remnant, pageSize); } } onRangeChanged(table); } }); }
From source file:com.google.gwt.sample.expenses.client.place.AbstractProxyListActivity.java
License:Apache License
private void init() { fireCountRequest(new Receiver<Long>() { @Override//ww w . jav a 2 s. co m public void onSuccess(Long response) { if (view == null) { // This activity is dead return; } getView().asHasData().setRowCount(response.intValue(), true); onRangeChanged(view.asHasData()); } }); }
From source file:com.google.gwt.sample.expenses.client.place.AbstractProxyListActivity.java
License:Apache License
private void update(EntityProxyId<P> proxyId) { final Integer row = idToRow.get(proxyId); if (row == null) { return;// w w w . j av a 2 s . co m } fireRangeRequest(new Range(row, 1), new Receiver<List<P>>() { @Override public void onSuccess(List<P> response) { getView().asHasData().setRowData(row, Collections.singletonList(response.get(0))); } }); }
From source file:com.google.gwt.sample.expenses.client.place.FindAndEditProxy.java
License:Apache License
@Override public void start(final AcceptsOneWidget display, final EventBus eventBus) { factory.find(proxyId).fire(new Receiver<P>() { @Override/* w w w.java2 s . c o m*/ public void onSuccess(P response) { proxy = response; FindAndEditProxy.super.start(display, eventBus); } }); }
From source file:com.googlecode.gwtgae2011.client.main.SketchPresenter.java
License:Apache License
@Override protected void onReset() { super.onReset(); sketchProxy = null;// w w w .j ava 2 s. c om getView().setTitle("Untitled"); getView().clear(); fetching = false; if (id != null) { fetching = true; sketchRequestProvider.get().fetch(id).with("strokes").fire(new Receiver<SketchProxy>() { @Override public void onSuccess(SketchProxy sketchProxy) { SketchPresenter.this.sketchProxy = sketchProxy; draw(sketchProxy); fetching = false; } }); } }
From source file:com.googlecode.gwtgae2011.client.main.SketchPresenter.java
License:Apache License
public void addNewStroke(Stroke stroke) { if (fetching) { return;/*from ww w . jav a 2 s . c om*/ } getView().addStroke(stroke); SketchRequest request = sketchRequestProvider.get(); SketchProxy editable = getEditableProxy(request); request.addStroke(editable, stroke.toProxy(request)).fire(new Receiver<SketchProxy>() { @Override public void onSuccess(SketchProxy sketchProxy) { SketchPresenter.this.sketchProxy = sketchProxy; } }); }
From source file:com.googlecode.gwtgae2011.client.main.SketchPresenter.java
License:Apache License
public void setTitle(final String title) { if (title == null || fetching) { return;//from ww w . j a va 2 s .co m } if (sketchProxy == null || !title.equals(sketchProxy.getTitle())) { SketchRequest request = sketchRequestProvider.get(); SketchProxy editable = getEditableProxy(request); editable.setTitle(title); request.save(editable).fire(new Receiver<SketchProxy>() { @Override public void onSuccess(SketchProxy sketchProxy) { SketchPresenter.this.sketchProxy = sketchProxy; getView().setTitle(title); } }); } }