Java Code Examples for com.google.gwt.user.client.DOM#setEventListener()

The following examples show how to use com.google.gwt.user.client.DOM#setEventListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubaResizableTextAreaWrapperWidget.java    From cuba with Apache License 2.0 6 votes vote down vote up
public void setResizableDirection(ResizeDirection resizableDirection) {
    this.resizableDirection = resizableDirection;
    if (resizableDirection == ResizeDirection.NONE) {
        if (isResizable()) {
            DOM.sinkEvents(resizeElement, 0);
            DOM.setEventListener(resizeElement, null);
            resizeElement.removeFromParent();
            resizeElement = null;
        }
    } else {
        if (!isResizable()) {
            resizeElement = DOM.createDiv();
            resizeElement.setClassName(RESIZE_ELEMENT);
            getElement().appendChild(resizeElement);
            DOM.sinkEvents(resizeElement, MOUSE_EVENTS);
            DOM.setEventListener(resizeElement, new ResizeEventListener());
        }
    }
}
 
Example 2
Source File: ParagraphRenderer.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
  *
  * Set/unset an event handler in the paragraph's DOM element
  *
  * @param element
  * @param paragraphType
  */
 private void updateEventHandler(final ContentElement element, ParagraphBehaviour paragraphType) {

   if (!GWT.isClient()) return;

   Element implNodelet = element.getImplNodelet();

   final EventHandler handler = paragraphType == null ? null
       : Paragraph.eventHandlerRegistry.get(paragraphType);

   if (handler != null) {
     DOM.sinkEvents(DomHelper.castToOld(implNodelet), LISTENER_EVENTS);
     DOM.setEventListener(DomHelper.castToOld(implNodelet), new EventListener() {
       @Override
       public void onBrowserEvent(Event event) {
         handler.onEvent(element, event);
       }
     });
   } else {
     DOM.setEventListener(implNodelet, null);
     DOM.sinkEvents(implNodelet, DOM.getEventsSunk(implNodelet) & ~LISTENER_EVENTS);
   }

}
 
Example 3
Source File: AnnotationSpreadRenderer.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
private void updateEventHandler(final ContentElement element, String eventHandlerId) {
  Element implNodelet = element.getImplNodelet();
  final EventHandler handler =
      eventHandlerId == null ? null : AnnotationPaint.eventHandlerRegistry.get(eventHandlerId);
  if (handler != null) {
    DOM.sinkEvents(DomHelper.castToOld(implNodelet), MOUSE_LISTENER_EVENTS);
    DOM.setEventListener(DomHelper.castToOld(implNodelet), new EventListener() {
      @Override
      public void onBrowserEvent(Event event) {
        handler.onEvent(element, event);
      }
    });
  } else {
    removeListener(DomHelper.castToOld(implNodelet));
  }
}
 
Example 4
Source File: BaseCheckBox.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
/**
 * This method is called when a widget is detached from the browser's
 * document. Overridden because of IE bug that throws away checked state and
 * in order to clear the event listener off of the <code>inputElem</code>.
 */
@Override
protected void onUnload() {
    // Clear out the inputElem's event listener (breaking the circular
    // reference between it and the widget).
    DOM.setEventListener(inputElem, null);
    setValue(getValue());
}
 
Example 5
Source File: CubaFieldGroupLayoutComponentSlot.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected void moveIndicatorsRight(final CubaCaptionWidget captionWidget) {
    // Indicators element always present in DOM tree of slot
    if (rightCaption == null) {
        rightCaption = createRightCaption();
        getWrapperElement().insertAfter(rightCaption, getWidget().getElement());
    }

    // detach all indicators
    for (int i = 0; i < rightCaption.getChildCount(); i++) {
        rightCaption.getChild(i).removeFromParent();
    }

    /* now attach only necessary indicators */

    if (captionWidget.getRequiredIndicatorElement() != null) {
        captionWidget.getRequiredIndicatorElement().removeFromParent();

        if (!(getWidget() instanceof VCheckBox)) {
            requiredElement = captionWidget.getRequiredIndicatorElement();
            rightCaption.appendChild(requiredElement);
        }
    } else if (requiredElement != null) {
        requiredElement.removeFromParent();
        requiredElement = null;
    }

    if (captionWidget.getContextHelpIndicatorElement() != null) {
        captionWidget.getContextHelpIndicatorElement().removeFromParent();
        contextHelpIndicatorElement = captionWidget.getContextHelpIndicatorElement();
        rightCaption.appendChild(contextHelpIndicatorElement);

        DOM.sinkEvents(contextHelpIndicatorElement, Event.ONCLICK);
        DOM.setEventListener(contextHelpIndicatorElement, this);
    } else {
        if (contextHelpIndicatorElement != null) {
            contextHelpIndicatorElement.removeFromParent();
            DOM.setEventListener(contextHelpIndicatorElement, null);
            contextHelpIndicatorElement = null;
        }
    }

    if (captionWidget.getErrorIndicatorElement() != null) {
        captionWidget.getErrorIndicatorElement().removeFromParent();

        if (!(getWidget() instanceof VCheckBox)) {
            errorIndicatorElement = captionWidget.getErrorIndicatorElement();
            rightCaption.appendChild(errorIndicatorElement);
        }
    } else if (errorIndicatorElement != null) {
        errorIndicatorElement.removeFromParent();
        errorIndicatorElement = null;
    }
}
 
Example 6
Source File: AnnotationSpreadRenderer.java    From swellrt with Apache License 2.0 4 votes vote down vote up
@Deprecated
private void removeListener(com.google.gwt.user.client.Element implNodelet) {
  DOM.setEventListener(implNodelet, null);
  DOM.sinkEvents(implNodelet, DOM.getEventsSunk(implNodelet) & ~MOUSE_LISTENER_EVENTS);
}
 
Example 7
Source File: AnnotationSpreadRenderer.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
private void removeListener(com.google.gwt.user.client.Element implNodelet) {
  DOM.setEventListener(implNodelet, null);
  DOM.sinkEvents(implNodelet, DOM.getEventsSunk(implNodelet) & ~MOUSE_LISTENER_EVENTS);
}
 
Example 8
Source File: BaseCheckBox.java    From gwt-material with Apache License 2.0 2 votes vote down vote up
/**
 * This method is called when a widget is attached to the browser's document.
 * onAttach needs special handling for the CheckBox case. Must still call
 * {@link Widget#onAttach()} to preserve the <code>onAttach</code> contract.
 */
@Override
protected void onLoad() {
    DOM.setEventListener(inputElem, this);
}