Java 类com.google.gwt.event.dom.client.DomEvent 实例源码

项目:gwtmvp    文件:EventManager.java   
/**
 * Sets an event handler for an {@code Element}. All previous event handlers of this type of event are removed.
 * @param element The element to bind the event handler for
 * @param eventType The event type (e.g. {@code ClickEvent.getType()})
 * @param handler The handler that handler the event
 */
public static <H extends EventHandler> void setEventHandler(final Element element, DomEvent.Type<H> eventType, H handler) {
  if (element == null) {
    return;
  }
  HandlerManager hm = handlerManagers.get(element);
  if (hm == null) {
    handlerManagers.put(element, hm = new HandlerManager(element));
    DOM.setEventListener(element, new EventListener() {
      @Override
      public void onBrowserEvent(Event event) {
        DomEvent.fireNativeEvent(event, handlerManagers.get(element), element);
      }
    });
  }
  DOM.sinkBitlessEvent(element, eventType.getName());
  while (hm.getHandlerCount(eventType) > 0) {
    hm.removeHandler(eventType, hm.getHandler(eventType, 0));
  }
  hm.addHandler(eventType, handler);
}
项目:umlet    文件:MainView.java   
@UiHandler("paletteChooser")
void onPaletteChooserMouseWheel(MouseWheelEvent event) {
    // determine new index based on scroll direction
    int newIndex = paletteChooser.getSelectedIndex();
    if (event.getDeltaY() < 0) {
        newIndex--;
    }
    else {
        newIndex++;
    }

    // set new index (if it's valid) and trigger change event (is not automatically triggered)
    if (newIndex >= 0 && newIndex < paletteChooser.getItemCount()) {
        paletteChooser.setSelectedIndex(newIndex);
        DomEvent.fireNativeEvent(Document.get().createChangeEvent(), paletteChooser);
    }
}
项目:gwtmvp    文件:TaskAdapter.java   
private void finishEdit(DomEvent<?> event, boolean save) {
  int index = getItemIndexFromEvent(event);
  Task task = getItem(index, true);
  TaskAdapterView view = getItemView(index);
  if (save) {
    if (view.getNameInput().getValue().trim().length() == 0) {
      removeTask(index);
    } else {
      task.setName(view.getNameInput().getValue());
      view.getName().setInnerText(task.getName());
      Dao.onTasksChanged();
    }
  }
  view.getEditButton().removeClassName("hidden");
  view.getRemoveButton().removeClassName("hidden");
  view.getName().removeClassName("hidden");
  view.getNameInput().addClassName("hidden");
}
项目:bitcoin-transaction-explorer    文件:ConfigViewImpl.java   
@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());
}
项目:QMAClone    文件:PopupCanvas.java   
public void prepare() {
    canvas = new GWTCanvas(width, height);
    popupPanel.setWidget(canvas);
    for (Entry<EventHandler, DomEvent.Type<EventHandler>> entry : eventHandlers.entrySet()) {
        canvas.addDomHandler(entry.getKey(), entry.getValue());
    }
}
项目:RedQueryBuilder    文件:GwtTestDom.java   
@Test
public void testTextBox() throws Exception {
    TextBox tb = new TextBox();
    RootPanel.get().add(tb);
    final List events = new ArrayList();
    tb.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            events.add(event);
        }
    });

    DomEvent.fireNativeEvent(Document.get().createChangeEvent(), tb);

    assertEquals(1, events.size());
}
项目:kie-wb-common    文件:FocusableLienzoPanelView.java   
protected void broadcastBlurEvent() {
    final NativeEvent blur = Document.get().createBlurEvent();
    for (int i = 0; i < RootPanel.get().getWidgetCount(); i++) {
        final Widget w = RootPanel.get().getWidget(i);
        DomEvent.fireNativeEvent(blur,
                                 w);
    }
}
项目:swarm    文件:Mouse.java   
private void onMouseOrTouchUp(DomEvent event, int x, int y, boolean isTouch)
{
    s_logger.log(Level.INFO, "up");

    if( !m_isMouseDown )
    {
        return;
    }

    m_wasMouseJustDown = m_isMouseDown; // should always be the case;
    m_isMouseDown = false;

    this.setMousePoint(x, y, m_mouseEvent.getPoint());
    m_mouseEvent.set(E_MouseEventType.MOUSE_UP, 0, Element.as(event.getNativeEvent().getEventTarget()), isTouch);

    dispatchEvent(m_mouseEvent);

    Event.releaseCapture(m_container.getElement());
    event.preventDefault();
}
项目:swarm    文件:Mouse.java   
private void onMouseOrTouchDown(DomEvent event, int x, int y, boolean isTouch)
{
    m_isTouching = isTouch;

    s_logger.log(Level.INFO, "down");

    m_isMouseDown = true;
    m_hasMouseStrayedWhileDown = false;

    setMousePoint(x, y, m_mouseDownPoint);

    m_mouseEvent.getPoint().copy(m_mouseDownPoint);
    m_mouseEvent.set(E_MouseEventType.MOUSE_DOWN, 0, Element.as(event.getNativeEvent().getEventTarget()), isTouch);
    dispatchEvent(m_mouseEvent);

    Event.setCapture(m_container.getElement());
    event.preventDefault();
}
项目:wires    文件:FocusableLienzoPanel.java   
protected void broadcastBlurEvent() {
    final NativeEvent blur = Document.get().createBlurEvent();
    for ( int i = 0; i < RootPanel.get().getWidgetCount(); i++ ) {
        final Widget w = RootPanel.get().getWidget( i );
        DomEvent.fireNativeEvent( blur,
                                  w );
    }
}
项目:gwt-dynamic-plugins    文件:ModuleReadyFeatureProvider.java   
@Override
public void call(String moduleName, AsyncCallback<Void> callback) {
    LOG.info("ModuleReadyFeatureProvider.call: moduleName=" + moduleName);
    for (ModuleBean moduleBean : moduleUnreadyList)
        if (Utils.equals(moduleName, moduleBean.getName())) {
            moduleReadyList.add(moduleBean);
            moduleUnreadyList.remove(moduleBean);
            if (moduleUnreadyList.isEmpty()) {
                timeoutTimer.cancel();
                DomEvent.fireNativeEvent(Document.get().createLoadEvent(), this);
            }
            return;
        }
    throw new IllegalArgumentException("Module with name '" + moduleName + "' isn't expected");
}
项目:jbpm-data-modeler    文件:PackageSelector.java   
private void processNewPackage(String newPackageName) {
    if (newPackageName != null && !"".equals(newPackageName.trim())) {
        boolean exists = false;
        newPackageName = newPackageName.trim();
        int count = packageList.getItemCount();
        if (count > 0) {
            for (int i = 0; i < count; i++) {
                if ((exists = newPackageName.equals(packageList.getValue(i)))) break;
            }
        }
        if (exists) {
            packageList.setSelectedValue(newPackageName);
        } else {
            packageList.addItem(newPackageName, newPackageName);
            packageList.setSelectedValue(newPackageName);
            DomEvent.fireNativeEvent(Document.get().createChangeEvent(), packageList);
        }
    }
}
项目:LAS    文件:WindowBox.java   
@Override
public void onBrowserEvent(Event event) {

    // If we're not yet dragging, only trigger mouse events if the event occurs
    // in the caption wrapper
    if (this.resizable) {
        switch (event.getTypeInt()) {
        case Event.ONMOUSEDOWN:
        case Event.ONMOUSEUP:
        case Event.ONMOUSEMOVE:
        case Event.ONMOUSEOVER:
        case Event.ONMOUSEOUT:

            if (this.dragMode >= 0 || calcDragMode(event.getClientX(),event.getClientY()) >= 0) {
                // paste'n'copy from Widget.onBrowserEvent
                switch (DOM.eventGetType(event)) {
                case Event.ONMOUSEOVER:
                    // Only fire the mouse over event if it's coming from outside this
                    // widget.
                case Event.ONMOUSEOUT:
                    // Only fire the mouse out event if it's leaving this
                    // widget.
                    Element related = event.getRelatedEventTarget().cast();
                    if (related != null && getElement().isOrHasChild(related)) {
                        return;
                    }
                    break;
                }
                DomEvent.fireNativeEvent(event, this, this.getElement());
                return;
            }
            if (this.dragMode<0)
                this.updateCursor(this.dragMode);
        }
    }

    super.onBrowserEvent(event);
}
项目:cuba    文件:CubaTreeTableConnector.java   
@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());
                }
            }
        }
    });
}
项目:cuba    文件:CubaScrollTableConnector.java   
@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());
                }
            }
        }
    });
}
项目:Wiab.pro    文件:GadgetWidgetUi.java   
<H extends EventHandler> HandlerRegistration addHandler(
    final H handler, DomEvent.Type<H> type) {
  return addDomHandler(handler, type);
}
项目:Wiab.pro    文件:MouseComeLeaveEvent.java   
@Override
public final DomEvent.Type<MouseComeLeaveHandler> getAssociatedType() {
  return TYPE;
}
项目:gwtmvp    文件:ViewAdapter.java   
/**
 * Returns the item index that is related to an event fired from within an item view. If the event is not 
 * fired from a sub-view of the item or the view is no longer attached in the hierarchy, it returns -1.
 * @param event The event from the event handler.
 * @return The item index associated with the event or -1 if the event was not fired from this {@code ViewAdapter}.
 */
public int getItemIndexFromEvent(DomEvent<?> event) {
  Element e = event.getNativeEvent().getCurrentEventTarget().cast();
  while (e != null && e.getParentElement() != parentElement) {
    e = e.getParentElement();
  }
  if (e == null) {
    return -1;
  }
  Integer index = rootElementsToIndexMap.get(e);
  return (index == null ? -1 : index);
}
项目:hftinymce-gwt    文件:HFRichTextEditor.java   
/**
 * This gets called by the JSNI code for every event that we want to handle.
 * @param elementId the unique ID of the HFRichTextEditor. Used to locate the source of the event.
 * @param event the NativeEvent that we will fire into the GWT event handling loop
 */
public static void handleNativeEvent(String elementId, Object event) {
    if (event instanceof NativeEvent) {
        HFRichTextEditor editorInstance = getActiveEditor(elementId);
        if (editorInstance != null) {
            DomEvent.fireNativeEvent((NativeEvent) event, editorInstance);
        }
    }
}
项目:gwt-material    文件:MaterialDropDown.java   
@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;
            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());
    }
}
项目:gwt-material    文件:MaterialWidgetTestCase.java   
public void fireFocusEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createFocusEvent(), widget);
}
项目:gwt-material    文件:MaterialWidgetTestCase.java   
public void fireBlurEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createBlurEvent(), widget);
}
项目:gwt-material    文件:MaterialWidgetTestCase.java   
public void fireClickEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(
        Document.get().createClickEvent(1, 1, 1, 1, 1, false, false, false, false),
        widget
    );
}
项目:gwt-material    文件:MaterialWidgetTestCase.java   
public void fireDoubleClickEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(
        Document.get().createDblClickEvent(1, 1, 1, 1, 1, false, false, false, false),
        widget
    );
}
项目:gwt-material    文件:MaterialWidgetTestCase.java   
public void fireKeyDownEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createKeyDownEvent(false, false, false, false, 1), widget);
}
项目:gwt-material    文件:MaterialWidgetTestCase.java   
public void fireKeyPressEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createKeyPressEvent(false, false, false, false, 1), widget);
}
项目:gwt-material    文件:MaterialWidgetTestCase.java   
public void fireGestureStartEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.GESTURESTART, false, false), widget);
}
项目:gwt-material    文件:MaterialWidgetTestCase.java   
public void fireGestureChangeEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.GESTURECHANGE, false, false), widget);
}
项目:gwt-material    文件:MaterialWidgetTestCase.java   
public void fireGestureEndEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.GESTUREEND, false, false), widget);
}
项目:gwt-material    文件:MaterialWidgetTestCase.java   
public void fireTouchCancelEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.TOUCHCANCEL, false, false), widget);
}
项目:optaplanner-wb    文件:ConstraintMatchInputWidget.java   
public HandlerRegistration addConstraintMatchBlurHandler(final BlurHandler blurHandler) {
    HandlerRegistration registration = constraintMatchTextBox.addBlurHandler(blurHandler);
    DomEvent.fireNativeEvent(Document.get().createBlurEvent(),
                             constraintMatchTextBox);

    return registration;
}
项目:che    文件:Tree.java   
/** {@inheritDoc} */
@Override
public void onBrowserEvent(Event event) {
  switch (event.getTypeInt()) {
    case Event.ONCLICK:
      onClick(event);
      break;
    case Event.ONDBLCLICK:
      onDoubleClick(event);
      break;
    case Event.ONSCROLL:
      onScroll(event);
      break;
    case Event.ONFOCUS:
      onFocus(event);
      break;
    case Event.ONBLUR:
      onBlur(event);
      break;
    case Event.ONCONTEXTMENU:
      if (disableNativeContextMenu) {
        event.preventDefault();
      }
      onRightClick(event);
      break;
  }
  view.onEvent(event);

  // we are not calling super so must fire dom events
  DomEvent.fireNativeEvent(event, this, this.getElement());
}
项目:appformer    文件:FocusableLienzoPanel.java   
protected void broadcastBlurEvent() {
    final NativeEvent blur = Document.get().createBlurEvent();
    for (int i = 0; i < RootPanel.get().getWidgetCount(); i++) {
        final Widget w = RootPanel.get().getWidget(i);
        DomEvent.fireNativeEvent(blur,
                                 w);
    }
}
项目:dhcalc    文件:BaseSpinner.java   
public void setValue(T value) {
    T a = getValue();
    T b = bound(value);

    if (!isEqual(a, b)) {
        this.box.setValue(b);
        DomEvent.fireNativeEvent(Document.get().createChangeEvent(), box);
    }
}
项目:yaph    文件:PasswordFieldWidget.java   
public void setType(String type) {
    int index = 0;
    for (int i = 0; i < this.type.getItemCount(); i++) {
        if (type.equals(this.type.getValue(i)))
            index = i;
    }
    this.type.setItemSelected(index, true);
    DomEvent.fireNativeEvent(Document.get().createChangeEvent(), this.type);
}
项目:plugin-editor-codemirror    文件:CodeMirrorEditorWidget.java   
private void fireChangeEvent() {
    DomEvent.fireNativeEvent(Document.get().createChangeEvent(), this);
}
项目:plugin-editor-codemirror    文件:CodeMirrorEditorWidget.java   
private void fireFocusEvent() {
    DomEvent.fireNativeEvent(Document.get().createFocusEvent(), this);
}
项目:plugin-editor-codemirror    文件:CodeMirrorEditorWidget.java   
private void fireBlurEvent() {
    DomEvent.fireNativeEvent(Document.get().createBlurEvent(), this);
}
项目:bitcoin-transaction-explorer    文件:ConfigViewImpl.java   
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());
}
项目:gwt-traction    文件:Viewport.java   
static void dispatchEvent(Event event, boolean hasFocus) {
if (instance != null) {
    instance.hasFocus = hasFocus;
    DomEvent.fireNativeEvent(event, instance);
}
   }