code: public static <T extends PopupPanel> T centerOn (T popup, int ypos)
      {
          boolean wasHidden = !popup.isShowing();
          boolean wasVisible = popup.isVisible();
          if (wasVisible) {
              popup.setVisible(false);
          }
          if (wasHidden) {
              popup.show();
          }
          int left = (Window.getClientWidth() - popup.getOffsetWidth()) >> 1;
          int top = ypos - popup.getOffsetHeight()/2;
          // bound the popup into the visible browser area if possible
          if (popup.getOffsetHeight() < Window.getClientHeight()) {
              top = Math.min(Math.max(0, top), Window.getClientHeight() - popup.getOffsetHeight());
          }
          popup.setPopupPosition(left, top);
          if (wasHidden) {
              popup.hide();
          }
          if (wasVisible) {
              popup.setVisible(true);
          }
          return popup;
      }
docs: Centers the supplied vertically on the supplied trigger widget. The popup's showing state
  will be preserved.
  
  @return the supplied popup.