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

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

Introduction

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

Prototype

@Override
    public void hide() 

Source Link

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  a2s.  co  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//w ww .  ja va2  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");
}