Search in sources :

Example 6 with VUpload

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

the class CubaPopupButtonConnector method handleKeyDown.

protected void handleKeyDown(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) {
            Widget widgetParent = widget.getParent();
            if (widgetParent.getParent() instanceof VUpload) {
                VUpload upload = (VUpload) widgetParent.getParent();
                widgetParent = upload.getParent();
            } else if (widgetParent.getParent() instanceof CubaFileUploadWidget) {
                CubaFileUploadWidget upload = (CubaFileUploadWidget) widgetParent.getParent();
                widgetParent = upload.getParent();
            }
            FlowPanel layout = (FlowPanel) widgetParent;
            Widget focusWidget = null;
            int widgetIndex = layout.getWidgetIndex(widget);
            int keyCode = event.getNativeEvent().getKeyCode();
            if (keyCode == KeyCodes.KEY_DOWN) {
                focusWidget = Tools.findNextWidget(layout, widgetIndex);
            } else if (keyCode == 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);
            }
        }
    }
}
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) 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