use of com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout in project cuba by cuba-platform.
the class VDDVerticalLayoutDropHandler method getSlot.
@Override
protected Slot getSlot(Element e, NativeEvent event) {
Slot slot = null;
if (getLayout().getElement() == e) {
// Most likely between components, use the closest one in that case
slot = findSlotVertically(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;
}
use of com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout 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;
}
}
}
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;
}
use of com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout in project cuba by cuba-platform.
the class VDDVerticalLayoutDropHandler method getSlot.
@Override
protected Slot getSlot(Element e, NativeEvent event) {
Slot slot = null;
if (getLayout().getElement() == e) {
// Most likely between components, use the closest one in that case
slot = findSlotVertically(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;
}
Aggregations