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

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

Introduction

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

Prototype

public void setOwner(Widget owner) 

Source Link

Document

Set owner (Widget that made this Overlay, not the layout parent) of Overlay.

Usage

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

License:Apache License

public void showSortMenu(final Element target, final String columnId) {
    final VOverlay sortDirectionPopup = GWT.create(VOverlay.class);
    sortDirectionPopup.setOwner(tableWidget.getOwner());

    FlowPanel sortDirectionMenu = new FlowPanel();
    Label sortByDescendingButton = new Label(tableWidget.getSortDescendingLabel());
    Label sortByAscendingButton = new Label(tableWidget.getSortAscendingLabel());
    Label sortClearSortButton = new Label(tableWidget.getSortResetLabel());

    sortByDescendingButton.addStyleName(TABLE_SORT_CONTEXTMENU_ITEM);
    sortByAscendingButton.addStyleName(TABLE_SORT_CONTEXTMENU_ITEM);
    sortClearSortButton.addStyleName(TABLE_SORT_CONTEXTMENU_ITEM);

    sortDirectionMenu.add(sortByAscendingButton);
    sortDirectionMenu.add(sortByDescendingButton);
    sortDirectionMenu.add(sortClearSortButton);

    sortByDescendingButton.addClickHandler(event -> {
        updateVariable("sortcolumn", columnId, false);
        updateVariable("sortascending", false, false);

        tableWidget.getRowRequestHandler().deferRowFetch(); // some validation +
        // defer 250ms
        tableWidget.getRowRequestHandler().cancel(); // instead of waiting
        tableWidget.getRowRequestHandler().run(); // run immediately
        sortDirectionPopup.hide();/*from   w  w  w . ja v a  2s .  c  o  m*/
    });

    sortByAscendingButton.addClickHandler(event -> {
        updateVariable("sortcolumn", columnId, false);
        updateVariable("sortascending", true, false);

        tableWidget.getRowRequestHandler().deferRowFetch(); // some validation +
        // defer 250ms
        tableWidget.getRowRequestHandler().cancel(); // instead of waiting
        tableWidget.getRowRequestHandler().run(); // run immediately
        sortDirectionPopup.hide();
    });

    sortClearSortButton.addClickHandler(event -> {
        updateVariable("resetsortorder", columnId, true);
        sortDirectionPopup.hide();
    });

    sortDirectionMenu.addStyleName("c-table-contextmenu");
    sortDirectionPopup.setWidget(sortDirectionMenu);

    sortDirectionPopup.setAutoHideEnabled(true);
    ComputedStyle sortIndicatorStyle = new ComputedStyle(target);

    Tools.showPopup(sortDirectionPopup, target.getAbsoluteLeft(),
            target.getAbsoluteTop() + ((int) sortIndicatorStyle.getHeight()));
}

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

License:Apache License

public void showSortMenu(final Element sortIndicator, final String columnId) {
    final VOverlay sortDirectionPopup = new VOverlay();
    sortDirectionPopup.setOwner(tableWidget.getOwner());

    FlowPanel sortDirectionMenu = new FlowPanel();
    Label sortByDescendingButton = new Label(tableWidget.getSortDescendingLabel());
    Label sortByAscendingButton = new Label(tableWidget.getSortAscendingLabel());
    Label sortClearSortButton = new Label(tableWidget.getSortResetLabel());

    sortByDescendingButton.addStyleName("cuba-table-contextmenu-item");
    sortByAscendingButton.addStyleName("cuba-table-contextmenu-item");
    sortClearSortButton.addStyleName("cuba-table-contextmenu-item");

    sortDirectionMenu.add(sortByAscendingButton);
    sortDirectionMenu.add(sortByDescendingButton);
    sortDirectionMenu.add(sortClearSortButton);

    sortByDescendingButton.addClickHandler(new ClickHandler() {
        @Override// ww  w.  j a  v  a  2  s. co  m
        public void onClick(ClickEvent event) {
            tableWidget.getClient().updateVariable(tableWidget.getPaintableId(), "sortcolumn", columnId, false);
            tableWidget.getClient().updateVariable(tableWidget.getPaintableId(), "sortascending", false, false);

            tableWidget.getRowRequestHandler().deferRowFetch(); // some validation +
            // defer 250ms
            tableWidget.getRowRequestHandler().cancel(); // instead of waiting
            tableWidget.getRowRequestHandler().run(); // run immediately
            sortDirectionPopup.hide();
        }
    });

    sortByAscendingButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            tableWidget.getClient().updateVariable(tableWidget.getPaintableId(), "sortcolumn", columnId, false);
            tableWidget.getClient().updateVariable(tableWidget.getPaintableId(), "sortascending", true, false);

            tableWidget.getRowRequestHandler().deferRowFetch(); // some validation +
            // defer 250ms
            tableWidget.getRowRequestHandler().cancel(); // instead of waiting
            tableWidget.getRowRequestHandler().run(); // run immediately
            sortDirectionPopup.hide();
        }
    });

    sortClearSortButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            tableWidget.getClient().updateVariable(tableWidget.getPaintableId(), "resetsortorder", columnId,
                    true);
            sortIndicator.addClassName("cuba-sort-indicator-visible");
            sortDirectionPopup.hide();
        }
    });

    sortDirectionMenu.addStyleName("cuba-table-contextmenu");
    sortDirectionPopup.setWidget(sortDirectionMenu);

    sortDirectionPopup.addCloseHandler(new CloseHandler<PopupPanel>() {
        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            sortIndicator.removeClassName("cuba-sort-indicator-visible");
        }
    });

    sortDirectionPopup.setAutoHideEnabled(true);
    ComputedStyle sortIndicatorStyle = new ComputedStyle(sortIndicator);
    Tools.showPopup(sortDirectionPopup, sortIndicator.getAbsoluteLeft(),
            sortIndicator.getAbsoluteTop() + ((int) sortIndicatorStyle.getHeight()));
    sortIndicator.addClassName("cuba-sort-indicator-visible");
}