Search in sources :

Example 1 with VUpload

use of com.vaadin.client.ui.VUpload in project cuba by cuba-platform.

the class CubaPopupButtonWidget method resetSelectedItem.

protected void resetSelectedItem() {
    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 VButton) {
                    button = (VButton) contentChild;
                } else if (contentChild instanceof VUpload) {
                    button = ((VUpload) contentChild).submitButton;
                }
                if (button != null && button.getStyleName().contains(SELECTED_ITEM_STYLE)) {
                    button.removeStyleName(SELECTED_ITEM_STYLE);
                }
            }
        }
    }
}
Also used : CubaFileUploadWidget(com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadWidget) VButton(com.vaadin.client.ui.VButton) VAbstractOrderedLayout(com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout) VUpload(com.vaadin.client.ui.VUpload) Widget(com.google.gwt.user.client.ui.Widget) CubaFileUploadWidget(com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadWidget) Slot(com.vaadin.client.ui.orderedlayout.Slot)

Example 2 with VUpload

use of com.vaadin.client.ui.VUpload in project cuba by cuba-platform.

the class CubaPopupButtonWidget method onPopupOpened.

@Override
protected void onPopupOpened() {
    super.onPopupOpened();
    if (customLayout) {
        return;
    }
    // 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()));
                }
            }
        }
    }
}
Also used : CubaFileUploadWidget(com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadWidget) VButton(com.vaadin.client.ui.VButton) VAbstractOrderedLayout(com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout) VUpload(com.vaadin.client.ui.VUpload) FocusHandler(com.google.gwt.event.dom.client.FocusHandler) Widget(com.google.gwt.user.client.ui.Widget) CubaFileUploadWidget(com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadWidget) Slot(com.vaadin.client.ui.orderedlayout.Slot) FocusEvent(com.google.gwt.event.dom.client.FocusEvent)

Example 3 with VUpload

use of com.vaadin.client.ui.VUpload in project cuba by cuba-platform.

the class CubaPopupButtonConnector method handleMouseOver.

protected void handleMouseOver(@SuppressWarnings("unused") Event.NativePreviewEvent event, Element target) {
    if (!getState().customLayout && getWidget().popupHasChild(target)) {
        Widget widget = WidgetUtil.findWidget(target, null);
        if ((widget instanceof VButton || widget instanceof VUpload || widget instanceof CubaFileUploadWidget)) {
            VButton button;
            if (widget instanceof VButton) {
                button = (VButton) widget;
            } else if (widget instanceof CubaFileUploadWidget) {
                button = ((CubaFileUploadWidget) widget).getSubmitButton();
            } else {
                button = ((VUpload) widget).submitButton;
            }
            if (!button.getStyleName().contains(SELECTED_ITEM_STYLE)) {
                getWidget().childWidgetFocused(button);
                button.setFocus(true);
            }
        }
    }
}
Also used : CubaFileUploadWidget(com.haulmont.cuba.web.widgets.client.jqueryfileupload.CubaFileUploadWidget) VButton(com.vaadin.client.ui.VButton) VUpload(com.vaadin.client.ui.VUpload) CubaFileUploadWidget(com.haulmont.cuba.web.widgets.client.jqueryfileupload.CubaFileUploadWidget) Widget(com.google.gwt.user.client.ui.Widget)

Example 4 with VUpload

use of com.vaadin.client.ui.VUpload in project cuba by cuba-platform.

the class CubaPopupButtonConnector method onPreviewNativeEvent.

@Override
public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
    NativeEvent nativeEvent = event.getNativeEvent();
    if (getWidget().getPopup().isVisible()) {
        Element target = Element.as(nativeEvent.getEventTarget());
        if (getWidget().popupHasChild(target)) {
            if (event.getTypeInt() == Event.ONKEYDOWN && (nativeEvent.getKeyCode() == KeyCodes.KEY_ESCAPE || nativeEvent.getKeyCode() == KeyCodes.KEY_TAB && isLastChild(target)) && !nativeEvent.getAltKey() && !nativeEvent.getCtrlKey() && !nativeEvent.getShiftKey() && !nativeEvent.getMetaKey()) {
                event.cancel();
                event.getNativeEvent().stopPropagation();
                event.getNativeEvent().preventDefault();
                Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

                    @Override
                    public void execute() {
                        getWidget().hidePopup();
                        rpc.setPopupVisible(false);
                        getWidget().setFocus(true);
                    }
                });
                return;
            }
        }
    }
    super.onPreviewNativeEvent(event);
    if (isEnabled()) {
        Element target = Element.as(nativeEvent.getEventTarget());
        switch(event.getTypeInt()) {
            case Event.ONCLICK:
                if (getState().autoClose && getWidget().popupHasChild(target)) {
                    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

                        @Override
                        public void execute() {
                            getWidget().hidePopup();
                            // update state on server
                            rpc.setPopupVisible(false);
                        }
                    });
                }
                break;
            case Event.ONKEYDOWN:
                if (!getState().customLayout && getWidget().popupHasChild(target)) {
                    Widget widget = WidgetUtil.findWidget(target, null);
                    if (widget instanceof VButton || widget instanceof VUpload || widget instanceof CubaFileUploadWidget) {
                        Widget widgetParent = widget.getParent();
                        if (widgetParent.getParent() instanceof VUpload) {
                            VUpload upload = (VUpload) widgetParent.getParent();
                            // upload parent is Slot
                            widgetParent = upload.getParent();
                        } else if (widgetParent.getParent() instanceof CubaFileUploadWidget) {
                            CubaFileUploadWidget upload = (CubaFileUploadWidget) widgetParent.getParent();
                            // upload parent is Slot
                            widgetParent = upload.getParent();
                        }
                        VAbstractOrderedLayout layout = (VAbstractOrderedLayout) widgetParent.getParent();
                        Widget focusWidget = null;
                        int widgetIndex = layout.getWidgetIndex(widgetParent);
                        if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_DOWN) {
                            focusWidget = Tools.findNextWidget(layout, widgetIndex);
                        } else if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_UP) {
                            focusWidget = Tools.findPrevWidget(layout, widgetIndex);
                        }
                        if (focusWidget instanceof VButton || focusWidget instanceof CubaFileUploadWidget || focusWidget instanceof VUpload) {
                            VButton button;
                            if (focusWidget instanceof VButton) {
                                button = (VButton) focusWidget;
                            } else if (focusWidget instanceof CubaFileUploadWidget) {
                                button = ((CubaFileUploadWidget) focusWidget).getSubmitButton();
                            } else {
                                button = ((VUpload) focusWidget).submitButton;
                            }
                            getWidget().childWidgetFocused(button);
                            button.setFocus(true);
                        }
                    }
                }
                break;
            case Event.ONMOUSEOVER:
                if (!getState().customLayout && getWidget().popupHasChild(target)) {
                    Widget widget = WidgetUtil.findWidget(target, null);
                    if ((widget instanceof VButton || widget instanceof VUpload || widget instanceof CubaFileUploadWidget)) {
                        VButton button;
                        if (widget instanceof VButton) {
                            button = (VButton) widget;
                        } else if (widget instanceof CubaFileUploadWidget) {
                            button = ((CubaFileUploadWidget) widget).getSubmitButton();
                        } else {
                            button = ((VUpload) widget).submitButton;
                        }
                        if (!button.getStyleName().contains(SELECTED_ITEM_STYLE)) {
                            getWidget().childWidgetFocused(button);
                            button.setFocus(true);
                        }
                    }
                }
                break;
        }
    }
}
Also used : CubaFileUploadWidget(com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadWidget) Scheduler(com.google.gwt.core.client.Scheduler) VButton(com.vaadin.client.ui.VButton) Element(com.google.gwt.dom.client.Element) VUpload(com.vaadin.client.ui.VUpload) VAbstractOrderedLayout(com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout) CubaFileUploadWidget(com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadWidget) Widget(com.google.gwt.user.client.ui.Widget) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 5 with VUpload

use of com.vaadin.client.ui.VUpload in project cuba by cuba-platform.

the class CubaPopupButtonWidget method onPopupOpened.

@Override
protected void onPopupOpened() {
    super.onPopupOpened();
    if (customLayout) {
        return;
    }
    // find button, assign .v-selected style
    for (Widget popupChild : getPopup()) {
        if (popupChild instanceof FlowPanel) {
            FlowPanel content = (FlowPanel) popupChild;
            for (Widget contentChild : content) {
                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 FlowPanel) {
            FlowPanel content = (FlowPanel) popupChild;
            for (Widget contentChild : content) {
                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) {
                    VButton finalButton = button;
                    button.addFocusHandler(event -> childWidgetFocused(finalButton));
                    // sink mouse over
                    DOM.sinkEvents(button.getElement(), Event.ONMOUSEOVER | DOM.getEventsSunk(button.getElement()));
                }
            }
        }
    }
}
Also used : CubaFileUploadWidget(com.haulmont.cuba.web.widgets.client.jqueryfileupload.CubaFileUploadWidget) VButton(com.vaadin.client.ui.VButton) VUpload(com.vaadin.client.ui.VUpload) Widget(com.google.gwt.user.client.ui.Widget) CubaFileUploadWidget(com.haulmont.cuba.web.widgets.client.jqueryfileupload.CubaFileUploadWidget) FlowPanel(com.google.gwt.user.client.ui.FlowPanel)

Aggregations

Widget (com.google.gwt.user.client.ui.Widget)6 VButton (com.vaadin.client.ui.VButton)6 VUpload (com.vaadin.client.ui.VUpload)6 CubaFileUploadWidget (com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadWidget)3 CubaFileUploadWidget (com.haulmont.cuba.web.widgets.client.jqueryfileupload.CubaFileUploadWidget)3 VAbstractOrderedLayout (com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout)3 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)2 Slot (com.vaadin.client.ui.orderedlayout.Slot)2 Scheduler (com.google.gwt.core.client.Scheduler)1 Element (com.google.gwt.dom.client.Element)1 NativeEvent (com.google.gwt.dom.client.NativeEvent)1 FocusEvent (com.google.gwt.event.dom.client.FocusEvent)1 FocusHandler (com.google.gwt.event.dom.client.FocusHandler)1