Example usage for com.vaadin.client.ui VOverlay show

List of usage examples for com.vaadin.client.ui VOverlay show

Introduction

In this page you can find the example usage for com.vaadin.client.ui VOverlay show.

Prototype

@Override
    public void show() 

Source Link

Usage

From source file:com.haulmont.cuba.web.toolkit.ui.client.Tools.java

License:Apache License

public static void showPopup(VOverlay overlay, int left, int top) {
    overlay.setAutoHideEnabled(true);/* ww w.  ja va  2  s.  c  o  m*/
    overlay.setVisible(false);
    overlay.show();

    Widget widget = overlay.getWidget();
    if (widget instanceof VVerticalLayout) {
        resetItemSelection(widget);

        VVerticalLayout verticalLayout = (VVerticalLayout) widget;
        if (verticalLayout.getStyleName().contains(CUBA_CONTEXT_MENU_CONTAINER)) {
            int widgetCount = verticalLayout.getWidgetCount();
            if (widgetCount > 1) {
                Widget verticalSlot = verticalLayout.getWidget(0);
                Widget buttonWidget = ((Slot) verticalSlot).getWidget();
                buttonWidget.addStyleName(SELECTED_ITEM_STYLE);
                if (buttonWidget instanceof FocusWidget) {
                    ((FocusWidget) buttonWidget).setFocus(true);
                }
            }
        }
    }

    // mac FF gets bad width due GWT popups overflow hacks,
    // re-determine width
    int offsetWidth = overlay.getOffsetWidth();
    int offsetHeight = overlay.getOffsetHeight();
    if (offsetWidth + left > Window.getClientWidth()) {
        left = left - offsetWidth;
        if (left < 0) {
            left = 0;
        }
    }
    if (offsetHeight + top > Window.getClientHeight()) {
        top = top - offsetHeight;
        if (top < 0) {
            top = 0;
        }
    }

    overlay.setPopupPosition(left, top);
    overlay.setVisible(true);
}