/** * Retrieves this view as a {@link PopupPanel}. See {@link #asWidget()}. * * @return This view as a {@link PopupPanel} object. */ protected PopupPanel asPopupPanel() { return (PopupPanel) asWidget(); }
/** * @param eventBus The {@link EventBus}. * @param positioner The {@link PopupPositioner} used to position the popup onReveal(); * * @see com.gwtplatform.mvp.client.view.CenterPopupPositioner * @see com.gwtplatform.mvp.client.view.RelativeToWidgetPopupPositioner * @see com.gwtplatform.mvp.client.view.TopLeftPopupPositioner */ protected PopupViewImpl( EventBus eventBus, PopupPositioner positioner) { this.eventBus = eventBus; setPopupPositioner(positioner); if (repositionOnWindowResize()) { Window.addResizeHandler(event -> { if (asPopupPanel().isShowing()) { showAndReposition(); } }); } }
@Override public void showAndReposition() { onReposition(); asPopupPanel().setPopupPositionAndShow((offsetWidth, offsetHeight) -> { PopupPosition popupPosition = positioner.getPopupPosition(offsetWidth, offsetHeight); asPopupPanel().setPopupPosition(popupPosition.getLeft(), popupPosition.getTop()); }); }
@Override public void show() { asPopupPanel().show(); }
@Override public void setAutoHideOnNavigationEventEnabled(boolean autoHide) { if (autoHide) { if (autoHideHandler != null) { return; } autoHideHandler = eventBus.addHandler(NavigationEvent.getType(), navigationEvent -> hide()); } else { if (autoHideHandler != null) { autoHideHandler.removeHandler(); } } }
protected void initWidget(T widget) { super.initWidget(widget); // All popups are modal by default widget.setModal(true); // Enable background glass by default widget.setGlassEnabled(true); // Add popup widget style widget.addStyleName(POPUP_CONTENT_STYLE_NAME); widget.removeStyleName(GWT_POPUPPANEL); widget.getElement().getStyle().setZIndex(PatternflyConstants.ZINDEX_MODAL); }
@Override public void hide() { asPopupPanel().hide(); // events will not fire call closeHandler manually. if (popupViewCloseHandler != null) { popupViewCloseHandler.onClose(); } }
@SuppressWarnings("unchecked") @Override public T asWidget() { return (T) super.asWidget(); }
@Override public void setCloseHandler(final PopupViewCloseHandler popupViewCloseHandler) { this.popupViewCloseHandler = popupViewCloseHandler; if (closeHandlerRegistration == null) { closeHandlerRegistration = asPopupPanel().addCloseHandler(event -> { if (PopupViewImpl.this.popupViewCloseHandler != null) { PopupViewImpl.this.popupViewCloseHandler.onClose(); } }); } }