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

EventManager.java 文件源码 项目:gwtmvp 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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);
}
MainView.java 文件源码 项目:umlet 阅读 20 收藏 0 点赞 0 评论 0
@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);
    }
}
TaskAdapter.java 文件源码 项目:gwtmvp 阅读 20 收藏 0 点赞 0 评论 0
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");
}
ConfigViewImpl.java 文件源码 项目:bitcoin-transaction-explorer 阅读 23 收藏 0 点赞 0 评论 0
@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());
}
PopupCanvas.java 文件源码 项目:QMAClone 阅读 20 收藏 0 点赞 0 评论 0
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());
    }
}
GwtTestDom.java 文件源码 项目:RedQueryBuilder 阅读 22 收藏 0 点赞 0 评论 0
@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());
}
FocusableLienzoPanelView.java 文件源码 项目:kie-wb-common 阅读 22 收藏 0 点赞 0 评论 0
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);
    }
}
Mouse.java 文件源码 项目:swarm 阅读 27 收藏 0 点赞 0 评论 0
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();
}
Mouse.java 文件源码 项目:swarm 阅读 37 收藏 0 点赞 0 评论 0
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();
}
FocusableLienzoPanel.java 文件源码 项目:wires 阅读 24 收藏 0 点赞 0 评论 0
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 );
    }
}
ModuleReadyFeatureProvider.java 文件源码 项目:gwt-dynamic-plugins 阅读 21 收藏 0 点赞 0 评论 0
@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");
}
PackageSelector.java 文件源码 项目:jbpm-data-modeler 阅读 23 收藏 0 点赞 0 评论 0
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);
        }
    }
}
WindowBox.java 文件源码 项目:LAS 阅读 24 收藏 0 点赞 0 评论 0
@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);
}
CubaTreeTableConnector.java 文件源码 项目:cuba 阅读 25 收藏 0 点赞 0 评论 0
@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());
                }
            }
        }
    });
}
CubaScrollTableConnector.java 文件源码 项目:cuba 阅读 22 收藏 0 点赞 0 评论 0
@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());
                }
            }
        }
    });
}
GadgetWidgetUi.java 文件源码 项目:Wiab.pro 阅读 87 收藏 0 点赞 0 评论 0
<H extends EventHandler> HandlerRegistration addHandler(
    final H handler, DomEvent.Type<H> type) {
  return addDomHandler(handler, type);
}
MouseComeLeaveEvent.java 文件源码 项目:Wiab.pro 阅读 23 收藏 0 点赞 0 评论 0
@Override
public final DomEvent.Type<MouseComeLeaveHandler> getAssociatedType() {
  return TYPE;
}
ViewAdapter.java 文件源码 项目:gwtmvp 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 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);
}
HFRichTextEditor.java 文件源码 项目:hftinymce-gwt 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    }
}
MaterialDropDown.java 文件源码 项目:gwt-material 阅读 21 收藏 0 点赞 0 评论 0
@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());
    }
}
MaterialWidgetTestCase.java 文件源码 项目:gwt-material 阅读 24 收藏 0 点赞 0 评论 0
public void fireFocusEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createFocusEvent(), widget);
}
MaterialWidgetTestCase.java 文件源码 项目:gwt-material 阅读 31 收藏 0 点赞 0 评论 0
public void fireBlurEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createBlurEvent(), widget);
}
MaterialWidgetTestCase.java 文件源码 项目:gwt-material 阅读 22 收藏 0 点赞 0 评论 0
public void fireClickEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(
        Document.get().createClickEvent(1, 1, 1, 1, 1, false, false, false, false),
        widget
    );
}
MaterialWidgetTestCase.java 文件源码 项目:gwt-material 阅读 25 收藏 0 点赞 0 评论 0
public void fireDoubleClickEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(
        Document.get().createDblClickEvent(1, 1, 1, 1, 1, false, false, false, false),
        widget
    );
}
MaterialWidgetTestCase.java 文件源码 项目:gwt-material 阅读 21 收藏 0 点赞 0 评论 0
public void fireKeyDownEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createKeyDownEvent(false, false, false, false, 1), widget);
}
MaterialWidgetTestCase.java 文件源码 项目:gwt-material 阅读 20 收藏 0 点赞 0 评论 0
public void fireKeyPressEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createKeyPressEvent(false, false, false, false, 1), widget);
}
MaterialWidgetTestCase.java 文件源码 项目:gwt-material 阅读 20 收藏 0 点赞 0 评论 0
public void fireGestureStartEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.GESTURESTART, false, false), widget);
}
MaterialWidgetTestCase.java 文件源码 项目:gwt-material 阅读 22 收藏 0 点赞 0 评论 0
public void fireGestureChangeEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.GESTURECHANGE, false, false), widget);
}
MaterialWidgetTestCase.java 文件源码 项目:gwt-material 阅读 20 收藏 0 点赞 0 评论 0
public void fireGestureEndEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.GESTUREEND, false, false), widget);
}
MaterialWidgetTestCase.java 文件源码 项目:gwt-material 阅读 23 收藏 0 点赞 0 评论 0
public void fireTouchCancelEvent(HasHandlers widget) {
    DomEvent.fireNativeEvent(Document.get().createHtmlEvent(BrowserEvents.TOUCHCANCEL, false, false), widget);
}


问题


面经


文章

微信
公众号

扫码关注公众号