public void show ( PopupPanel popup , Widget onCenter ) { // determine the ypos of our onCenter target in case it's in the currently popped up popup, // because after we hide that popup we won't be able to compute it int ypos = ( onCenter == null ) ? 0 : ( onCenter . getAbsoluteTop ( ) + onCenter . getOffsetHeight ( ) / 2 ) ; PopupPanel showing = _showingPopup . get ( ) ; if ( showing != null ) { // null _showingPopup before hiding to avoid triggering the close handler logic _popups . add ( showing ) ; _showingPopup . update ( null ) ; showing . hide ( true ) ; } if ( onCenter == null ) { popup . center ( ) ; // this will show the popup } else { Popups . centerOn ( popup , ypos ) . show ( ) ; } // now that we've centered and shown our popup (which may have involved showing, hiding and // showing it again), we can add a close handler and listen for it to actually close popup . addCloseHandler ( new CloseHandler < PopupPanel > ( ) { public void onClose ( CloseEvent < PopupPanel > event ) { if ( _showingPopup . get ( ) == event . getTarget ( ) ) { if ( _popups . size ( ) > 0 ) { _showingPopup . update ( _popups . remove ( _popups . size ( ) - 1 ) ) ; _showingPopup . get ( ) . show ( ) ; } else { _showingPopup . update ( null ) ; } } } } ) ; _showingPopup . update ( popup ) ; }
Pushes any currently showing popup onto the stack and displays the supplied popup . The popup will centered horizontally in the page and centered vertically around the supplied widget .