Example usage for com.vaadin.client.ui VButton isEnabled

List of usage examples for com.vaadin.client.ui VButton isEnabled

Introduction

In this page you can find the example usage for com.vaadin.client.ui VButton isEnabled.

Prototype

@Override
    public final boolean isEnabled() 

Source Link

Usage

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

License:Apache License

@Override
protected void onPopupOpened() {
    super.onPopupOpened();

    if (customLayout) {
        return;/*from   www .  j  a  v a  2s .c  o  m*/
    }

    // find button, assign .v-selected style
    for (Widget popupChild : getPopup()) {
        if (popupChild instanceof VAbstractOrderedLayout) {
            VAbstractOrderedLayout content = (VAbstractOrderedLayout) popupChild;
            for (Widget slot : content) {
                Widget contentChild = ((Slot) slot).getWidget();

                if (contentChild instanceof VButton) {
                    VButton button = (VButton) contentChild;

                    if (button.isEnabled() && !button.getStyleName().contains(SELECTED_ITEM_STYLE)) {
                        button.addStyleName(SELECTED_ITEM_STYLE);
                        button.setFocus(true);
                        break;
                    }
                }
            }
        }
    }

    // add focus handler
    for (Widget popupChild : getPopup()) {
        if (popupChild instanceof VAbstractOrderedLayout) {
            VAbstractOrderedLayout content = (VAbstractOrderedLayout) popupChild;
            for (Widget slot : content) {
                Widget contentChild = ((Slot) slot).getWidget();

                VButton button = null;
                if (contentChild instanceof CubaFileUploadWidget) {
                    button = ((CubaFileUploadWidget) contentChild).getSubmitButton();
                } else if (contentChild instanceof VUpload) {
                    button = ((VUpload) contentChild).submitButton;
                } else if (contentChild instanceof VButton) {
                    button = (VButton) contentChild;
                }

                if (button != null) {
                    final VButton finalButton = button;
                    button.addFocusHandler(new FocusHandler() {
                        @Override
                        public void onFocus(FocusEvent event) {
                            childWidgetFocused(finalButton);
                        }
                    });

                    // sink mouse over
                    DOM.sinkEvents(button.getElement(),
                            Event.ONMOUSEOVER | DOM.getEventsSunk(button.getElement()));
                }
            }
        }
    }
}

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

License:Apache License

public static boolean isSuitableWidget(Widget slotWidget) {
    if (slotWidget instanceof VButton) {
        VButton button = (VButton) slotWidget;

        if (button.isEnabled()) {
            return true;
        }/*from w ww  .  j a va2s.  c o  m*/
    } else if (slotWidget instanceof CubaFileUploadWidget) {
        return true;
    } else if (slotWidget instanceof VUpload) {
        return true;
    }

    return false;
}