com.google.gwt.event.dom.client.DomEvent Java Examples

The following examples show how to use com.google.gwt.event.dom.client.DomEvent. 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: ConfigViewImpl.java    From bitcoin-transaction-explorer with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void setValue(final AdministratedApplicationConfig value, final boolean fireEvents) {
  for (int i = 0; i < connectorListBox.getItemCount(); i++) {
    if(connectorListBox.getValue(i).equals(value.getBlockchainSource().name())) {
      connectorListBox.setSelectedIndex(i);
      DomEvent.fireNativeEvent(Document.get().createChangeEvent(), connectorListBox);
      break;
    }
  }

  currentEditor.setValue(value);

  applicationTitle.setText(value.getApplicationTitle());
  applicationSubtitle.setText(value.getApplicationSubTitle());
  donationAddress.setText(value.getHostDonationAddress());
}
 
Example #2
Source File: CubaTreeTableConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected void init() {
    super.init();

    getWidget()._delegate.cellClickListener = new TableCellClickListener() {
        @Override
        public void onClick(String columnKey, int rowKey, boolean isText) {
            getRpcProxy(CubaTableServerRpc.class).onClick(columnKey, String.valueOf(rowKey), isText);
        }
    };

    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());
                }
            }
        }
    });
    getWidget()._delegate.totalAggregationInputHandler = (columnKey, value, isFocused) -> {
        getRpcProxy(CubaTableServerRpc.class).onAggregationTotalInputChange(columnKey, value, isFocused);
    };

    getWidget()._delegate.emptyStateLinkClickHandler = () -> getRpcProxy(CubaTableServerRpc.class).onEmptyStateLinkClick();
}
 
Example #3
Source File: CubaScrollTableConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected void init() {
    super.init();

    getWidget()._delegate.cellClickListener = new TableCellClickListener() {
        @Override
        public void onClick(String columnKey, int rowKey, boolean isText) {
            getRpcProxy(CubaTableServerRpc.class).onClick(columnKey, String.valueOf(rowKey), isText);
        }
    };

    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());
                }
            }
        }
    });
    getWidget()._delegate.totalAggregationInputHandler = (columnKey, value, isFocused) -> {
        getRpcProxy(CubaTableServerRpc.class).onAggregationTotalInputChange(columnKey, value, isFocused);
    };

    getWidget()._delegate.emptyStateLinkClickHandler = () -> getRpcProxy(CubaTableServerRpc.class).onEmptyStateLinkClick();
}
 
Example #4
Source File: MaterialDropDown.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
@Override
public void add(final Widget child) {
    String tagName = child.getElement().getTagName();
    if (child instanceof ListItem || tagName.toLowerCase().startsWith("li")) {
        child.getElement().getStyle().setDisplay(Style.Display.BLOCK);
        add(child, (Element) getElement());
    } else {
        ListItem li = new ListItem(child);
        // Checks if there are sub dropdown components
        if (child instanceof MaterialLink) {
            MaterialLink link = (MaterialLink) child;
            handlers.add(link.addClickHandler(event -> SelectionEvent.fire(MaterialDropDown.this, child)));
            for (int i = 0; i < link.getWidgetCount(); i++) {
                if (link.getWidget(i) instanceof MaterialDropDown) {
                    registerHandler(link.addClickHandler(DomEvent::stopPropagation));
                    link.stopTouchStartEvent();
                }
            }
        }

        if (child instanceof HasWaves) {
            li.setWaves(((HasWaves) child).getWaves());
            ((HasWaves) child).setWaves(null);
        }
        li.getElement().getStyle().setDisplay(Style.Display.BLOCK);
        add(li, (Element) getElement());
    }
}
 
Example #5
Source File: MaterialListValueBox.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
@Override
public void load() {
    JQueryElement listBoxElement = $(listBox.getElement());
    JsMaterialElement.$(listBox.getElement()).material_select(() -> $("input.select-dropdown").trigger("close", true));
    listBoxElement.change((e, param) -> {
        try {
            ValueChangeEvent.fire(this, getValue());
        } catch (IndexOutOfBoundsException ex) {
            GWT.log("ListBox value change handler threw an exception.", ex);
        }
        return true;
    });

    JQueryElement selectDropdown = listBoxElement.siblings("input.select-dropdown");
    selectDropdown.mousedown((event, o) -> {
        $("input[data-activates!='" + listBoxElement.attr("data-activates") + "'].select-dropdown").trigger("close", true);
        return true;
    });

    selectDropdown.blur((e, param1) -> {
        DomEvent.fireNativeEvent(Document.get().createBlurEvent(), this);
        return true;
    });

    selectDropdown.focus((e, param1) -> {
        DomEvent.fireNativeEvent(Document.get().createFocusEvent(), this);

        if (isAsynchronous() && !isLoaded()) {
            load(getAsyncCallback());
        }

        return true;
    });

    if (isAllowBlank()) {
        addBlankItemIfNeeded();
    }
}
 
Example #6
Source File: MockComponent.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Invoked by GWT whenever a browser event is dispatched to this component.
 */
@Override
public void onBrowserEvent(Event event) {
  if (!shouldCancel(event)) return;
  switch (event.getTypeInt()) {
    case Event.ONTOUCHSTART:
    case Event.ONTOUCHEND:
      if (isForm()) {
        select();
      }
    case Event.ONTOUCHMOVE:
    case Event.ONTOUCHCANCEL:
      cancelBrowserEvent(event);
      DomEvent.fireNativeEvent(event, handlers);
      break;

    case Event.ONMOUSEDOWN:
    case Event.ONMOUSEUP:
    case Event.ONMOUSEMOVE:
    case Event.ONMOUSEOVER:
    case Event.ONMOUSEOUT:
      cancelBrowserEvent(event);
      mouseListeners.fireMouseEvent(this, event);
      break;

    case Event.ONCLICK:
      cancelBrowserEvent(event);
      select();
      break;

    default:
      // Ignore unexpected events
      break;
  }
}
 
Example #7
Source File: InputBoolean.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean eventTargetsLabelOrChild(DomEvent<?> event) {
	Event nativeEvent = Event.as(event.getNativeEvent());
	EventTarget target = nativeEvent.getEventTarget();
	if (Element.is(target)) {
		return this.labelElement.isOrHasChild(Element.as(target));
	}
	return false;
}
 
Example #8
Source File: CompositeFocusHelper.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void focus() {
	if (!this.focused) {
		this.focused = true;
		this.updateHandler();
		DomEvent.fireNativeEvent(Document.get().createFocusEvent(), this);
	}
}
 
Example #9
Source File: CompositeFocusHelper.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void blur() {
	if (this.focused) {
		this.focused = false;
		this.updateHandler();
		DomEvent.fireNativeEvent(Document.get().createBlurEvent(), this);
	}
}
 
Example #10
Source File: ConfigViewImpl.java    From bitcoin-transaction-explorer with MIT License 5 votes vote down vote up
public ConfigViewImpl() {
  initWidget(UI_BINDER.createAndBindUi(this));

  for (final BlockchainSource source : compatibleSources) {
    connectorListBox.addItem(M.messages().configConnectorOption(source), source.name());
  }
  DomEvent.fireNativeEvent(Document.get().createChangeEvent(), connectorListBox);

  StyleUtil.setPlaceHolder(createPassword, M.messages().configPasswordPlaceHolder());
  StyleUtil.setPlaceHolder(password, M.messages().configPasswordPlaceHolder());
  StyleUtil.setPlaceHolder(createPasswordRepeat, M.messages().configPasswordRepeatPlaceHolder());
}
 
Example #11
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void fireMouseDownEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(
        Document.get().createMouseDownEvent(1, 1, 1, 1, 1, false, false, false, false, 1),
        widget
    );
}
 
Example #12
Source File: FullCalendar.java    From gwtbootstrap3-extras with Apache License 2.0 4 votes vote down vote up
private void renderCalendar() {
    boolean selectable = false;
    boolean selectHelper = false;
    boolean unselectAuto = true;
    boolean selectOverlap = true;

    JsArray<JavaScriptObject> javascriptParams = null;
    String language = null;
    String timezone = null;
    String weekNumberTitle = null;
    String unselectCancel = null;
    String selectContraint = null;
    if (config != null) {
        selectable = config.isSelectable();
        selectHelper = config.isSelectHelper();
        unselectAuto = config.isUnselectAuto();
        selectOverlap = config.isSelectOverlap();
        timezone = config.getTimezone();
        weekNumberTitle = config.getWeekNumberTitle();
        unselectCancel = config.getUnselectCancel();
        selectContraint = config.getSelectContraint();
        javascriptParams = config.getJavaScriptParameters();
        if (config.getLangauge() != null) {
            language = config.getLangauge().getCode();
            ensureInjected(config.getLangauge());
        }
    }
    addCalendar(getElement().getId(),
            currentView.name(),
            editable,
            selectable,
            selectHelper,
            unselectAuto,
            selectOverlap,
            language,
            timezone,
            weekNumberTitle,
            unselectCancel,
            selectContraint,
            javascriptParams
    );
    //Let everyone know it is ok to add events and set properties on the instance
    DomEvent.fireNativeEvent(Document.get().createLoadEvent(), this);
}
 
Example #13
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void fireMouseMoveEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(
        Document.get().createMouseMoveEvent(1, 1, 1, 1, 1, false, false, false, false, 1),
        widget
    );
}
 
Example #14
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void fireMouseWheelEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.MOUSEWHEEL, false, false), widget);
}
 
Example #15
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public <H extends HasHandlers & IsWidget> void fireMouseOverEvent(H widget) {
    DomEvent.fireNativeEvent(
        Document.get().createMouseOverEvent(1, 1, 1, 1, 1, false, false, false, false, 1, widget.asWidget().getElement()),
        widget
    );
}
 
Example #16
Source File: SinglePageLayout.java    From djvu-html5 with GNU General Public License v2.0 4 votes vote down vote up
private boolean isOnText(DomEvent<?> event) {
	return "SPAN".equals(Element.as(event.getNativeEvent().getEventTarget()).getNodeName());
}
 
Example #17
Source File: GadgetWidgetUi.java    From swellrt with Apache License 2.0 4 votes vote down vote up
<H extends EventHandler> HandlerRegistration addHandler(
    final H handler, DomEvent.Type<H> type) {
  return addDomHandler(handler, type);
}
 
Example #18
Source File: Viewport.java    From gwt-traction with Apache License 2.0 4 votes vote down vote up
static void dispatchEvent(Event event, boolean hasFocus) {
if (instance != null) {
    instance.hasFocus = hasFocus;
    DomEvent.fireNativeEvent(event, instance);
}
   }
 
Example #19
Source File: InputSlider.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void killEvent(DomEvent<?> event) {
	event.preventDefault();
	event.stopPropagation();
}
 
Example #20
Source File: GadgetWidgetUi.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
<H extends EventHandler> HandlerRegistration addHandler(
    final H handler, DomEvent.Type<H> type) {
  return addDomHandler(handler, type);
}
 
Example #21
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void fireMouseUpEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(
        Document.get().createMouseUpEvent(1, 1, 1, 1, 1, false, false, false, false, 1),
        widget
    );
}
 
Example #22
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void fireTouchCancelEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.TOUCHCANCEL, false, false), widget);
}
 
Example #23
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void fireTouchEndEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.TOUCHEND, false, false), widget);
}
 
Example #24
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void fireTouchMoveEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.TOUCHMOVE, false, false), widget);
}
 
Example #25
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void fireTouchStartEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.TOUCHSTART, false, false), widget);
}
 
Example #26
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void fireGestureEndEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.GESTUREEND, false, false), widget);
}
 
Example #27
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void fireGestureChangeEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.GESTURECHANGE, false, false), widget);
}
 
Example #28
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void fireGestureStartEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.GESTURESTART, false, false), widget);
}
 
Example #29
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void fireKeyPressEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createKeyPressEvent(false, false, false, false, 1), widget);
}
 
Example #30
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void fireKeyUpEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createKeyUpEvent(false, false, false, false, 1), widget);
}