Search in sources :

Example 71 with Element

use of com.google.gwt.dom.client.Element in project rstudio by rstudio.

the class DiagnosticsBackgroundPopup method start.

public void start() {
    isRunning_ = true;
    stopRequested_ = false;
    if (handler_ != null) {
        handler_.removeHandler();
        handler_ = null;
    }
    handler_ = Event.addNativePreviewHandler(new NativePreviewHandler() {

        @Override
        public void onPreviewNativeEvent(NativePreviewEvent event) {
            if (event.getTypeInt() == Event.ONMOUSEMOVE) {
                movedMouseMostRecently_ = true;
                Element target = Element.as(event.getNativeEvent().getEventTarget());
                if (target.hasClassName("ace_gutter-cell")) {
                    lastMouseCoords_ = null;
                    hidePopup();
                    return;
                }
                lastMouseCoords_ = ScreenCoordinates.create(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY());
                if (activeMarker_ != null && !activeMarker_.getRange().containsRightExclusive(editor_.toDocumentPosition(lastMouseCoords_))) {
                    hidePopup();
                }
            } else {
                movedMouseMostRecently_ = false;
            }
        }
    });
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override
        public boolean execute() {
            if (stopRequested_)
                return stopExecution();
            // restarted later)
            if (!docDisplay_.isFocused())
                return stopExecution();
            long currentTime = System.currentTimeMillis();
            long lastModifiedTime = docDisplay_.getLastModifiedTime();
            long lastCursorChangedTime = docDisplay_.getLastCursorChangedTime();
            // cursor was moved recently, then bail
            if ((currentTime - lastModifiedTime) < 500)
                return completeExecution();
            if ((currentTime - lastCursorChangedTime) < 500)
                return completeExecution();
            Markers markers = editor_.getSession().getMarkers(true);
            Position currentPos;
            if (movedMouseMostRecently_) {
                if (lastMouseCoords_ == null)
                    return completeExecution();
                currentPos = editor_.toDocumentPosition(lastMouseCoords_);
            } else {
                currentPos = docDisplay_.getCursorPosition();
            }
            int[] keys = markers.getIds();
            for (int i = 0; i < keys.length; i++) {
                Marker marker = markers.get(keys[i]);
                if (marker.getRange().containsRightExclusive(currentPos)) {
                    displayMarkerDiagnostics(marker);
                    return completeExecution();
                }
            }
            return completeExecution();
        }
    }, 500);
}
Also used : NativePreviewHandler(com.google.gwt.user.client.Event.NativePreviewHandler) NativePreviewEvent(com.google.gwt.user.client.Event.NativePreviewEvent) Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position) Element(com.google.gwt.dom.client.Element) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) Markers(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Markers) Marker(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Marker)

Example 72 with Element

use of com.google.gwt.dom.client.Element in project gwt-test-utils by gwt-test-utils.

the class Browser method prepareEvents.

private static void prepareEvents(IsWidget target, Event... events) {
    for (Event event : events) {
        Element effectiveTarget = JavaScriptObjects.getObject(event, JsoProperties.EVENT_TARGET);
        if (effectiveTarget == null) {
            effectiveTarget = target.asWidget().getElement();
            JavaScriptObjects.setProperty(event, JsoProperties.EVENT_TARGET, effectiveTarget);
        }
    }
}
Also used : Element(com.google.gwt.dom.client.Element) Event(com.google.gwt.user.client.Event) ColumnSortEvent(com.google.gwt.user.cellview.client.ColumnSortEvent)

Example 73 with Element

use of com.google.gwt.dom.client.Element 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 74 with Element

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

the class TableAggregationRow method updateFromUIDL.

public void updateFromUIDL(UIDL uidl) {
    if (getElement().hasChildNodes()) {
        getElement().removeAllChildren();
    }
    aligns = tableWidget.getHead().getColumnAlignments();
    if (uidl.getChildCount() > 0) {
        final Element table = DOM.createTable();
        table.setAttribute("cellpadding", "0");
        table.setAttribute("cellspacing", "0");
        final Element tBody = DOM.createTBody();
        tr = DOM.createTR();
        tr.setClassName(tableWidget.getStylePrimaryName() + "-arow-row");
        addCellsFromUIDL(uidl);
        tBody.appendChild(tr);
        table.appendChild(tBody);
        getElement().appendChild(table);
    }
    initialized = getElement().hasChildNodes();
}
Also used : TableCellElement(com.google.gwt.dom.client.TableCellElement) Element(com.google.gwt.dom.client.Element)

Example 75 with Element

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

the class CubaCheckBoxConnector method onClick.

@Override
public void onClick(ClickEvent event) {
    super.onClick(event);
    Element target = Element.as(event.getNativeEvent().getEventTarget());
    if (target == getWidget().contextHelpIcon) {
        if (hasContextHelpIconListeners()) {
            contextHelpIconClick(event);
        }
    }
}
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