public void onWindowResized(int width, int height) { counter = 4; this.width = width; this.height = height; if (timer==null) { timer = new Timer() { public void run() { if (counter>0) { counter--; return; } //resize this.cancel(); timer = null; for (int i=0;i<list.size();i++) { WindowResizeListener listener = (WindowResizeListener)list.get(i); listener.onWindowResized(WindowResizeCacheListener.this.width,WindowResizeCacheListener.this.height); } } }; timer.scheduleRepeating(150); } }
/** * Initializes the ErrorPopup. */ ErrorPopup() { super(true); //constructor for PopupPanel class. "True" initializes the "auto-hide" variable // I'm leaving this setSTyleName line here as a comment, to show the typical way to define // the style. // I would have preferred to use this method rather than constructing the HTML by hand, // but it seems that GWT doesn't let the StyleName to be switched dynamically. // setStyleName("ode-ErrorMessage"); messageLabel = new HTML(); setWidget(messageLabel); // Recenter the message when the window is resized. // TODO(halabelson): replace the deprecated methods Window.addWindowResizeListener(new WindowResizeListener() { @Override public void onWindowResized(int width, int height) { centerTopPopup(); } }); // Reposition the message to the top of the screen when the // window is scrolled // TODO(halabelson): get rid of the flashing on vertical scrolling Window.addWindowScrollListener(new WindowScrollListener() { @Override public void onWindowScrolled(int scrollLeft, int scrollTop) { centerTopPopup(); } }); }
/** * Initializes the LoadingPopup. */ public RpcStatusPopup() { super(/* autoHide = */ false); setStyleName("ode-RpcStatusMessage"); setWidget(label); // Re-center the loading message when the window is resized. // TODO(halabelson): Replace the deprecated methods Window.addWindowResizeListener(new WindowResizeListener() { @Override public void onWindowResized(int width, int height) { positionPopup(getOffsetWidth()); } }); // Reposition the message to the top of the screen when the // window is scrolled // TODO(halabelson): get rid of the flashing on vertical scrolling Window.addWindowScrollListener(new WindowScrollListener() { @Override public void onWindowScrolled(int scrollLeft, int scrollTop) { positionPopup(getOffsetWidth()); } }); // Position the popup before showing it to prevent flashing. setPopupPositionAndShow(new PopupPanel.PositionCallback() { @Override public void setPosition(int offsetWidth, int offsetHeight) { positionPopup(offsetWidth); } }); }
public void remove(WindowResizeListener listener) { for (int i=0;i<list.size();i++) { if (list.get(i)==listener) { list.remove(i); return; } } }
public static void addResizeListener(WindowResizeListener listener) { instance.add(listener); }
public static void removeResizeListener(WindowResizeListener listener) { instance.remove(listener); }
private WindowResizeCacheListener(){ list = new ArrayList<WindowResizeListener>(); height = Window.getClientHeight(); width = Window.getClientWidth(); Window.addWindowResizeListener(this); }
public void add(WindowResizeListener listener) { list.add(listener); }