List of usage examples for com.vaadin.client WidgetUtil getRequiredHeight
public static int getRequiredHeight(Widget widget)
From source file:org.vaadin.overlay.widgetset.client.CustomOverlayWidget.java
License:Apache License
protected void updateOverlayPosition() { if (refCompEl != null) { // Calculate the position based on reference component size and the // align point. refY = refCompEl.getAbsoluteTop(); refX = refCompEl.getAbsoluteLeft(); if (align.isBottom()) { refY += refCompEl.getOffsetHeight(); } else if (align.isVerticalCenter()) { refY += refCompEl.getOffsetHeight() / 2; }//from ww w. ja v a 2 s. c o m if (align.isRight()) { refX += refCompEl.getOffsetWidth(); } else if (align.isHorizontalCenter()) { refX += refCompEl.getOffsetWidth() / 2; } // Show popup overlay.setPopupPositionAndShow(new PopupPanel.PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { // Calculate the position based on over component size and // the alignment point. Widget wgt = getOverlayWidget(); int w = WidgetUtil.getRequiredWidth(wgt); int h = WidgetUtil.getRequiredHeight(wgt); log.info("POSITION: w=" + w + "h=" + h); int top = refY + y; int left = refX + x; if (overlayAlign.isBottom()) { top -= h; } else if (overlayAlign.isVerticalCenter()) { top -= h / 2; } if (overlayAlign.isRight()) { left -= w; } else if (overlayAlign.isHorizontalCenter()) { left -= w / 2; } log.info("top=" + top + "left=" + left); overlay.setPopupPosition(left, top); } }); } }