GWT Loading....
import java.util.ArrayList; import java.util.List; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Grid; import com.google.gwt.user.client.ui.PopupPanel; import com.smartgwt.client.widgets.Img; import com.smartgwt.client.widgets.Label; /** * * @author ldsjdy * */ public class Loading extends PopupPanel { private static Loading me; private List workingObjects = new ArrayList(); private boolean shown; private Loading() { // super(false, true); Img img = new Img("loading_smartgwt.gif",30,30); Grid grid = new Grid(1,2); grid.setWidget(0, 0, img); Label label = new Label("Loading........"); label.setHeight(30); grid.setWidget(0, 1, label); // grid.setWidget(0, 1, label); setWidget(grid); } public static Loading get() { if (me == null) { me = new Loading(); } return me; } public AsyncCallback startWorking(AsyncCallback callback) { AsyncCallbackWrapper wrapper = new AsyncCallbackWrapper(callback); this.workingObjects.add(wrapper); if (!this.shown) { this.shown = true; this.center(); } return wrapper; } private void endWorking(AsyncCallbackWrapper wrapper) { this.workingObjects.remove(wrapper); if (this.shown && (this.workingObjects.size() <= 0)) { this.shown = false; this.setModal(false); this.hide(); } } private class AsyncCallbackWrapper implements AsyncCallback { private AsyncCallback callback; private AsyncCallbackWrapper(AsyncCallback callback) { this.callback = callback; } public void onFailure(Throwable t) { Loading.get().endWorking(this); this.callback.onFailure(t); } public void onSuccess(Object obj) { this.callback.onSuccess(obj); Loading.get().endWorking(this); } } }
相关推荐
杉林的HelloWord 2013-09-13
mjx00 2017-08-09
icewizardry 2016-12-20
87433764 2017-09-28
dykun 2019-07-01
81427605 2019-06-28
87443561 2017-09-28
87453169 2017-04-18
icewizardry 2016-12-20
momode 2019-06-27
88261841 2015-06-20
aganliang 2014-05-15
MegatronKings 2014-03-19
卧斋 2013-09-13
publicTIM 2013-06-18
Haoroid 2013-01-23
Chydar 2013-01-17
nicepainkiller 2019-06-20