Example usage for com.google.gwt.user.client DOM getEventsSunk

List of usage examples for com.google.gwt.user.client DOM getEventsSunk

Introduction

In this page you can find the example usage for com.google.gwt.user.client DOM getEventsSunk.

Prototype

public static int getEventsSunk(Element elem) 

Source Link

Document

Gets the current set of events sunk by a given element.

Usage

From source file:asquare.gwt.tk.client.ui.behavior.ControllerSupportDelegate.java

License:Apache License

/**
 * Widget.onAttach() must be called before this. 
 *//*from w w  w . j av  a 2 s.  c  om*/
public void onAttach() {
    assert m_widget.isAttached();
    if (!isOrWasAttached()) {
        m_isOrWasAttached = true;
        /**
        * The widget may have sunk events internally, so read from the DOM to
        * ensure we get all bits. This is why widget must first be attached. 
        */
        m_bitsForOnBrowserEvent |= DOM.getEventsSunk(m_widget.getElement());
        m_bitsForControllers = calculateControllerBits();
        DOM.sinkEvents(m_widget.getElement(), m_bitsForOnBrowserEvent | m_bitsForControllers);
    }
    plugInControllers();
}

From source file:client.net.sf.saxon.ce.Xslt20ProcessorImpl.java

License:Mozilla Public License

private void registerEventHandlers(Controller controller) throws XPathException {
    // add an event listener to capture registered event modes
    if (registeredEventModes != null) {
        return;/*  www .  j ava  2s  .c  om*/
    }
    Element docElement = (com.google.gwt.user.client.Element) (Object) Document.get();
    registeredEventModes = controller.getRuleManager().getModesInNamespace(NamespaceConstant.IXSL);
    // Restriction: only one event listener per element
    if (registeredEventModes.size() > 0 && !registeredForEvents) {
        registeredForEvents = true;
        registerNonDOMevents(controller);
        if (DOM.getEventListener((com.google.gwt.user.client.Element) docElement) == null) {
            principleEventListener = true;
            DOM.setEventListener((com.google.gwt.user.client.Element) docElement, new EventListener() {
                public void onBrowserEvent(Event event) {

                    EventTarget eTarget = event.getEventTarget();
                    Node eventNode;
                    if (Node.is(eTarget)) {
                        eventNode = Node.as(eTarget);
                    } else {
                        eventNode = Node.as(getCorrespondingSVGElement(eTarget));
                        if (eventNode == null) {
                            return;
                        }
                    }
                    bubbleApplyTemplates(eventNode, event);
                }
            });
        } else {
            // can't register for event so register for relayEvent
            Controller.addEventProcessor(this);
        }
    }
    // Events for all processor instances may register 1 or more event types
    for (Mode eventMode : registeredEventModes) {
        String eventName = eventMode.getModeName().getLocalName();
        if (!eventName.startsWith("on")) {
            logger.warning("Event name: '" + eventName + "' is invalid - names should begin with 'on'");
        } else {
            eventName = eventName.substring(2);
        }
        int eventNo = Event.getTypeInt(eventName);
        DOM.sinkEvents((com.google.gwt.user.client.Element) docElement,
                eventNo | DOM.getEventsSunk((com.google.gwt.user.client.Element) docElement));

    }

}

From source file:com.cgxlib.xq.client.plugins.events.EventsListener.java

License:Apache License

private void sink(int eventbits, String eventName) {
    // ensure that the gwtQuery's event listener is set as event listener of the element
    DOM.setEventListener((com.google.gwt.user.client.Element) element, this);

    if (eventbits != BITLESS) {
        eventBits |= eventbits;// w  ww  .  jav a 2  s .c o  m

        if ((eventBits | Event.FOCUSEVENTS) == Event.FOCUSEVENTS && JsUtils.isElement(element)
                && element.getAttribute("tabIndex").length() == 0) {
            element.setAttribute("tabIndex", "0");
        }
        DOM.sinkEvents((com.google.gwt.user.client.Element) element,
                eventBits | DOM.getEventsSunk((com.google.gwt.user.client.Element) element));
    } else {
        sinkBitlessEvent(element, eventName);
    }
}

From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java

License:Apache License

/** preserves event handlers on element to be wrapped */
public static Widget elementToWidget(Element e, String typ) {
    Widget result = null;//from   w ww . j av  a2  s  .  c  om
    if (e != null) {
        int eventsSunk = DOM.getEventsSunk(e);
        EventListener el = DOM.getEventListener(e);
        if (typ == TEXT)
            result = TextBox.wrap(e);
        else if (typ == TEXT_AREA)
            result = TextArea.wrap(e);
        else if (typ == PASSWORD)
            result = PasswordTextBox.wrap(e);
        else if (typ == LABEL)
            result = Label.wrap(e);
        else if (typ == A)
            result = Anchor.wrap(e);
        else if (typ == IMAGE)
            result = Image.wrap(e);
        else if (typ == SELECT)
            result = ListBox.wrap(e);
        else if (typ == HIDDEN)
            result = Hidden.wrap(e);
        else if (typ == FILE)
            result = FileUpload.wrap(e);
        else if (typ == FORM)
            result = FormPanel.wrap(e, true);
        else if (typ == FRAME)
            result = Frame.wrap(e);
        else if (typ == SUBMIT)
            result = SubmitButton.wrap(e);
        else if (typ == BUTTON)
            result = Button.wrap(e);
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
        DOM.sinkEvents(e, eventsSunk);
        DOM.setEventListener(e, el);
    } else {
        if (typ == TEXT)
            result = new TextBox();
        else if (typ == TEXT_AREA)
            result = new TextArea();
        else if (typ == PASSWORD)
            result = new PasswordTextBox();
        else if (typ == LABEL)
            result = new Label();
        else if (typ == A)
            result = new Anchor();
        else if (typ == SELECT)
            result = new ListBox();
        else if (typ == IMAGE)
            result = new Image();
        else if (typ == HIDDEN)
            result = new Hidden();
        else if (typ == FILE)
            result = new FileUpload();
        else if (typ == FORM)
            result = new FormPanel();
        else if (typ == FRAME)
            result = new Frame();
        else if (typ == SUBMIT)
            result = new SubmitButton();
        else if (typ == BUTTON)
            result = new Button();
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
    }
    return result;
}

From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java

License:Apache License

/** preserves event handlers on element to be wrapped  */
public static Widget elementToWidget(String elementName, String typ) {
    Widget result = null;// w w  w  .ja  v  a2  s  .  co m
    Element e = DOM.getElementById(elementName);
    if (e != null) {
        int eventsSunk = DOM.getEventsSunk(e);
        EventListener el = DOM.getEventListener(e);
        if (typ == TEXT)
            result = TextBox.wrap(e);
        else if (typ == TEXT_AREA)
            result = TextArea.wrap(e);
        else if (typ == PASSWORD)
            result = PasswordTextBox.wrap(e);
        else if (typ == LABEL)
            result = Label.wrap(e);
        else if (typ == A)
            result = Anchor.wrap(e);
        else if (typ == SELECT)
            result = ListBox.wrap(e);
        else if (typ == IMAGE)
            result = Image.wrap(e);
        else if (typ == HIDDEN)
            result = Hidden.wrap(e);
        else if (typ == FILE)
            result = FileUpload.wrap(e);
        else if (typ == FORM)
            result = FormPanel.wrap(e, true);
        else if (typ == FRAME)
            result = Frame.wrap(e);
        else if (typ == SUBMIT)
            result = SubmitButton.wrap(e);
        else if (typ == BUTTON)
            result = Button.wrap(e);
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
        DOM.sinkEvents(e, eventsSunk);
        DOM.setEventListener(e, el);
    } else {
        if (typ == TEXT)
            result = new TextBox();
        else if (typ == TEXT_AREA)
            result = new TextArea();
        else if (typ == PASSWORD)
            result = new PasswordTextBox();
        else if (typ == LABEL)
            result = new Label();
        else if (typ == A)
            result = new Anchor();
        else if (typ == IMAGE)
            result = new Image();
        else if (typ == SELECT)
            result = new ListBox();
        else if (typ == HIDDEN)
            result = new Hidden();
        else if (typ == FILE)
            result = new FileUpload();
        else if (typ == FORM)
            result = new FormPanel();
        else if (typ == FRAME)
            result = new Frame();
        else if (typ == SUBMIT)
            result = new SubmitButton();
        else if (typ == BUTTON)
            result = new Button();
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
    }
    return result;
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.menubar.CubaMenuBarWidget.java

License:Apache License

public CubaMenuBarWidget() {
    addBlurHandler(this);

    DOM.sinkEvents(getElement(), DOM.getEventsSunk(getElement()) | Event.ONMOUSEDOWN);
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.popupbutton.CubaPopupButtonWidget.java

License:Apache License

@Override
protected void onPopupOpened() {
    super.onPopupOpened();

    if (customLayout) {
        return;//from w  w w.java  2  s  . c  om
    }

    // 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()));
                }
            }
        }
    }
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.window.CubaWindowWidget.java

License:Apache License

public CubaWindowWidget() {
    DOM.sinkEvents(header, DOM.getEventsSunk(header) | Event.ONCONTEXTMENU);
    addStyleName(NONMODAL_WINDOW_CLASSNAME);
    Event.sinkEvents(getModalityCurtain(), Event.ONCLICK);
    Event.setEventListener(getModalityCurtain(), event -> {
        if (closeOnClickOutside) {
            if (clickOnModalityCurtain != null) {
                clickOnModalityCurtain.run();
            }//  w  w  w.  j av a2 s. co m
        }
    });
}

From source file:com.sencha.gxt.core.client.dom.XElement.java

License:sencha.com license

/**
 * Adds the event type to the element's sunk events.
 * /* w  w w .j  a  v  a 2 s.c  o m*/
 * @param event the events to add
 */
public final void addEventsSunk(int event) {
    int bits = DOM.getEventsSunk((Element) this.cast());
    DOM.sinkEvents((Element) this.cast(), bits | event);
}

From source file:com.sencha.gxt.widget.core.client.container.CssFloatLayoutContainer.java

License:sencha.com license

@Override
public HandlerRegistration addScrollHandler(ScrollHandler handler) {
    DOM.sinkEvents(getContainerTarget(), Event.ONSCROLL | DOM.getEventsSunk(getContainerTarget()));
    return addDomHandler(handler, ScrollEvent.getType());
}