Search in sources :

Example 91 with Element

use of com.google.gwt.dom.client.Element in project cuba by cuba-platform.

the class CubaScrollTableConnector method init.

@Override
protected void init() {
    super.init();
    getWidget()._delegate.cellClickListener = new TableCellClickListener() {

        @Override
        public void onClick(String columnKey, int rowKey) {
            getRpcProxy(CubaTableServerRpc.class).onClick(columnKey, String.valueOf(rowKey));
        }
    };
    tooltipHandlerRegistration = Event.addNativePreviewHandler(new Event.NativePreviewHandler() {

        @Override
        public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
            if (event.getTypeInt() != Event.ONMOUSEMOVE || !Element.is(event.getNativeEvent().getEventTarget())) {
                return;
            }
            Element element = Element.as(event.getNativeEvent().getEventTarget());
            if ("div".equalsIgnoreCase(element.getTagName())) {
                String className = element.getClassName();
                if (className != null && (className.contains("v-table-caption-container") || className.contains("v-table-footer-container"))) {
                    DomEvent.fireNativeEvent(event.getNativeEvent(), getWidget());
                }
            }
        }
    });
}
Also used : TableCellClickListener(com.haulmont.cuba.web.toolkit.ui.client.tableshared.TableCellClickListener) Element(com.google.gwt.dom.client.Element)

Example 92 with Element

use of com.google.gwt.dom.client.Element in project cuba by cuba-platform.

the class TableWidgetDelegate method showPresentationEditorPopup.

public void showPresentationEditorPopup(Event event, Widget presentationsEditIcon) {
    if (event.getEventTarget().cast() == presentationsEditIcon.getElement() && tableWidget.isEnabled()) {
        this.presentationsEditorPopup = new VOverlay();
        this.presentationsEditorPopup.setStyleName("c-table-prefs-editor");
        this.presentationsEditorPopup.setOwner(table);
        this.presentationsEditorPopup.setWidget(this.presentationsMenu);
        // Store the currently focused element, which will be re-focused when
        // context menu is closed
        Element focusedElement = WidgetUtil.getFocusedElement();
        this.presentationsEditorPopup.addCloseHandler(e -> {
            Element currentFocus = WidgetUtil.getFocusedElement();
            if (focusedElement != null && (currentFocus == null || presentationsEditorPopup.getElement().isOrHasChild(currentFocus) || RootPanel.getBodyElement().equals(currentFocus))) {
                focusedElement.focus();
            }
            presentationsEditorPopup = null;
        });
        this.presentationsEditorPopup.setAutoHideEnabled(true);
        this.presentationsEditorPopup.showRelativeTo(presentationsEditIcon);
    }
}
Also used : Element(com.google.gwt.dom.client.Element)

Example 93 with Element

use of com.google.gwt.dom.client.Element in project cuba by cuba-platform.

the class TableWidgetDelegate method setFocus.

public void setFocus(String itemKey, String columnKey) {
    HasWidgets row = tableWidget.getRenderedRowByKey(itemKey);
    int columnIndex = Arrays.asList(tableWidget.getVisibleColOrder()).indexOf(columnKey);
    for (Widget childWidget : row) {
        Element element = ((Widget) row).getElement();
        if (element.getChild(columnIndex).getFirstChild() == childWidget.getElement().getParentNode()) {
            this.focusWidget(childWidget);
            break;
        }
    }
}
Also used : Element(com.google.gwt.dom.client.Element)

Example 94 with Element

use of com.google.gwt.dom.client.Element in project cuba by cuba-platform.

the class TableWidgetDelegate method showCustomPopup.

public void showCustomPopup() {
    if (this.customPopupWidget != null) {
        if (this.customPopupWidget instanceof HasWidgets) {
            if (!((HasWidgets) this.customPopupWidget).iterator().hasNext()) {
                // there are no component to show
                return;
            }
        }
        // Store the currently focused element, which will be re-focused when
        // context menu is closed
        Element focusedElement = WidgetUtil.getFocusedElement();
        this.customPopupOverlay = Tools.createCubaTablePopup(this.customPopupAutoClose);
        this.customPopupOverlay.setOwner(table);
        this.customPopupOverlay.setWidget(this.customPopupWidget);
        this.customPopupOverlay.addCloseHandler(e -> {
            Element currentFocus = WidgetUtil.getFocusedElement();
            if (focusedElement != null && (currentFocus == null || customPopupOverlay.getElement().isOrHasChild(currentFocus) || RootPanel.getBodyElement().equals(currentFocus))) {
                focusedElement.focus();
            }
            customPopupOverlay = null;
        });
        Tools.showPopup(this.customPopupOverlay, this.lastClickClientX, this.lastClickClientY);
    }
}
Also used : Element(com.google.gwt.dom.client.Element)

Example 95 with Element

use of com.google.gwt.dom.client.Element in project cuba by cuba-platform.

the class TableWidgetDelegate method showContextMenuPopup.

public void showContextMenuPopup(int left, int top) {
    if (this.customContextMenu instanceof HasWidgets) {
        if (!((HasWidgets) this.customContextMenu).iterator().hasNext()) {
            // there are no actions to show
            return;
        }
    }
    // Store the currently focused element, which will be re-focused when
    // context menu is closed
    Element focusedElement = WidgetUtil.getFocusedElement();
    this.customContextMenuPopup = Tools.createCubaTableContextMenu();
    this.customContextMenuPopup.setOwner(table);
    this.customContextMenuPopup.setWidget(this.customContextMenu);
    this.customContextMenuPopup.addCloseHandler(e -> {
        Element currentFocus = WidgetUtil.getFocusedElement();
        if (focusedElement != null && (currentFocus == null || customContextMenuPopup.getElement().isOrHasChild(currentFocus) || RootPanel.getBodyElement().equals(currentFocus))) {
            focusedElement.focus();
        }
        customContextMenuPopup = null;
    });
    Tools.showPopup(this.customContextMenuPopup, left, top);
}
Also used : Element(com.google.gwt.dom.client.Element)

Aggregations

Element (com.google.gwt.dom.client.Element)340 DivElement (com.google.gwt.dom.client.DivElement)19 TableRowElement (com.google.gwt.dom.client.TableRowElement)19 NativeEvent (com.google.gwt.dom.client.NativeEvent)16 Test (org.junit.Test)14 EventTarget (com.google.gwt.dom.client.EventTarget)11 SVGSVGElement (elemental.svg.SVGSVGElement)11 InputElement (com.google.gwt.dom.client.InputElement)10 Node (com.google.gwt.dom.client.Node)9 TableCellElement (com.google.gwt.dom.client.TableCellElement)9 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)8 AnchorElement (com.google.gwt.dom.client.AnchorElement)8 ImageElement (com.google.gwt.dom.client.ImageElement)8 LabelElement (com.google.gwt.dom.client.LabelElement)8 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)8 Image (com.google.gwt.user.client.ui.Image)8 SpanElement (com.google.gwt.dom.client.SpanElement)7 Style (com.google.gwt.dom.client.Style)7 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)7 Widget (com.google.gwt.user.client.ui.Widget)7