public boolean hasChildComponent(Widget component) { if (popup.getWidget() != null) { return popup.getWidget() == component; } else { return false; } }
/** * Calculate extra space taken by the popup decorations * * @return */ protected Size calculatePopupExtra() { Element pe = popup.getElement(); Element ipe = popup.getContainerElement(); // border + padding int width = Util.getRequiredWidth(pe) - Util.getRequiredWidth(ipe); int height = Util.getRequiredHeight(pe) - Util.getRequiredHeight(ipe); return new Size(width, height); }
/** Called whenever an update is received from the server */ @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { super.updateFromUIDL(uidl, client); if (client.updateComponent(this, uidl, false)) { hidePopup(); return; } addStyleName(CLASSNAME); position = uidl.getStringAttribute("position"); xOffset = uidl.getIntAttribute("xoffset"); yOffset = uidl.getIntAttribute("yoffset"); popupVisible = uidl.getBooleanVariable("popupVisible"); if (popupVisible) { if (uidl.hasAttribute("popupPositionPaintable")) { popupPositionPaintable = uidl.getPaintableAttribute("popupPositionPaintable", client); } else { popupPositionPaintable = null; } if (uidl.hasAttribute("style")) { final String[] styles = uidl.getStringAttribute("style").split(" "); final StringBuffer styleBuf = new StringBuffer(); final String primaryName = popup.getStylePrimaryName(); styleBuf.append(primaryName); styleBuf.append(" "); styleBuf.append(VPopupView.CLASSNAME + "-popup"); for (int i = 0; i < styles.length; i++) { styleBuf.append(" "); styleBuf.append(primaryName); styleBuf.append("-"); styleBuf.append(styles[i]); } popup.setStyleName(styleBuf.toString()); } else { popup.setStyleName(popup.getStylePrimaryName() + " " + VPopupView.CLASSNAME + "-popup"); } UIDL popupUIDL = uidl.getChildUIDL(0); popup.setVisible(false); popup.show(); popup.updateFromUIDL(popupUIDL); showPopup(); } else { hidePopup(); } }
public void updateCaption(Paintable component, UIDL uidl) { if (VCaption.isNeeded(uidl)) { if (popup.getCaptionWrapper() != null) { popup.getCaptionWrapper().updateCaption(uidl); } else { VCaptionWrapper captionWrapper = new VCaptionWrapper(component, client); popup.setWidget(captionWrapper); captionWrapper.updateCaption(uidl); } } else { if (popup.getCaptionWrapper() != null) { popup.setWidget((Widget) popup.getCaptionWrapper().getPaintable()); } } }
public boolean requestLayout(Set<Paintable> children) { popup.updateShadowSizeAndPosition(); return true; }
public void replaceChildComponent(Widget oldComponent, Widget newComponent) { if (!hasChildComponent(oldComponent)) { throw new IllegalArgumentException(); } popup.setWidget(newComponent); }
private void hidePopup() { popup.setVisible(false); popup.hide(); }
private void showPopup() { if (position.equals("auto")) { int extra = 20; int left = getPopupPositionWidget().getAbsoluteLeft(); int top = getPopupPositionWidget().getAbsoluteTop() + getPopupPositionWidget().getOffsetHeight(); int browserWindowWidth = Window.getClientWidth() + Window.getScrollLeft(); int browserWindowHeight = Window.getClientHeight() + Window.getScrollTop(); if (left + popup.getOffsetWidth() > browserWindowWidth - extra) { left = getPopupPositionWidget().getAbsoluteLeft() - (popup.getOffsetWidth() - getPopupPositionWidget().getOffsetWidth()); } if (top + popup.getOffsetHeight() > browserWindowHeight - extra) { top = getPopupPositionWidget().getAbsoluteTop() - popup.getOffsetHeight() - 2; } left = left + xOffset; if (left < 0) { left = 0; } popup.setPopupPosition(left, top + yOffset); popup.setVisible(true); } else if (position.equals("fixed")) { int extra = 20; int left = getPopupPositionWidget().getAbsoluteLeft(); int top = getPopupPositionWidget().getAbsoluteTop() + getPopupPositionWidget().getOffsetHeight() - Window.getScrollTop(); int browserWindowWidth = Window.getClientWidth() + Window.getScrollLeft(); int clientHeight = Window.getClientHeight(); if (left + popup.getOffsetWidth() > browserWindowWidth - extra) { left = getPopupPositionWidget().getAbsoluteLeft() - (popup.getOffsetWidth() - getPopupPositionWidget().getOffsetWidth()); } if (top + popup.getOffsetHeight() > clientHeight - extra) { top = (getPopupPositionWidget().getAbsoluteTop() - Window.getScrollTop()) - popup.getOffsetHeight() - 2; } left = left + xOffset; if (left < 0) { left = 0; } popup.setPopupPosition(left, top + yOffset); popup.addStyleName("fixed"); popup.setShadowStyle("fixed"); popup.setVisible(true); } }