Search in sources :

Example 1 with VAbstractOrderedLayout

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

the class Tools method createContextMenu.

protected static VOverlay createContextMenu() {
    return new TableOverlay() {

        @Override
        protected void onDetach() {
            super.onDetach();
        }

        @Override
        protected void onPreviewNativeEvent(Event.NativePreviewEvent event) {
            super.onPreviewNativeEvent(event);
            NativeEvent nativeEvent = event.getNativeEvent();
            Element target = Element.as(nativeEvent.getEventTarget());
            if (Event.ONKEYDOWN == event.getTypeInt()) {
                if (KeyCodes.KEY_ESCAPE == event.getNativeEvent().getKeyCode()) {
                    event.cancel();
                    event.getNativeEvent().stopPropagation();
                    event.getNativeEvent().preventDefault();
                    hide();
                } else {
                    VAbstractOrderedLayout verticalLayout = ((VVerticalLayout) getWidget());
                    Widget widget = WidgetUtil.findWidget(target, null);
                    if (isLayoutChild(verticalLayout, widget)) {
                        Widget widgetParent = widget.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) {
                            VButton button = (VButton) focusWidget;
                            focusSelectedItem(widgetParent.getParent(), button);
                            button.setFocus(true);
                        }
                    }
                }
            } else if (Event.ONMOUSEOVER == event.getTypeInt()) {
                VAbstractOrderedLayout verticalLayout = ((VAbstractOrderedLayout) getWidget());
                Widget widget = WidgetUtil.findWidget(target, null);
                if (isLayoutChild(verticalLayout, widget)) {
                    if (widget instanceof VButton) {
                        VButton button = (VButton) widget;
                        Widget widgetParent = button.getParent();
                        if (!button.getStyleName().contains(SELECTED_ITEM_STYLE)) {
                            focusSelectedItem(widgetParent.getParent(), button);
                            button.setFocus(true);
                        }
                    }
                }
            }
        }
    };
}
Also used : VButton(com.vaadin.client.ui.VButton) Element(com.google.gwt.dom.client.Element) VAbstractOrderedLayout(com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout) CubaButtonWidget(com.haulmont.cuba.web.toolkit.ui.client.button.CubaButtonWidget) CubaFileUploadWidget(com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadWidget) Widget(com.google.gwt.user.client.ui.Widget) FocusWidget(com.google.gwt.user.client.ui.FocusWidget) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 2 with VAbstractOrderedLayout

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

the class CubaPopupButtonConnector method isLastChild.

private boolean isLastChild(Element target) {
    Widget widget = WidgetUtil.findWidget(target, null);
    Widget widgetParent = widget.getParent();
    VAbstractOrderedLayout layout = (VAbstractOrderedLayout) widgetParent.getParent();
    int widgetIndex = layout.getWidgetIndex(widgetParent);
    return widgetIndex == layout.getWidgetCount() - 1;
}
Also used : 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)

Example 3 with VAbstractOrderedLayout

use of com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout 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 4 with VAbstractOrderedLayout

use of com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout 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 5 with VAbstractOrderedLayout

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

the class VDDHorizontalLayoutDropHandler method getSlot.

@Override
protected Slot getSlot(Element e, NativeEvent event) {
    Slot slot = null;
    if (getLayout().getElement() == e) {
        // Most likely between components, use the closes one in that case
        slot = findSlotHorizontally(12, event);
    } else {
        slot = WidgetUtil.findWidget(e, Slot.class);
        if (slot == null) {
            return null;
        }
        VAbstractOrderedLayout layout = VDragDropUtil.getSlotLayout(slot);
        while (layout != getLayout() && getLayout().getElement().isOrHasChild(e.getParentElement())) {
            e = e.getParentElement();
            slot = WidgetUtil.findWidget(e, Slot.class);
            if (slot == null) {
                return null;
            }
            layout = VDragDropUtil.getSlotLayout(slot);
        }
    }
    return slot;
}
Also used : VAbstractOrderedLayout(com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout) Slot(com.vaadin.client.ui.orderedlayout.Slot)

Aggregations

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