com.google.gwt.dom.client.BrowserEvents Java Examples

The following examples show how to use com.google.gwt.dom.client.BrowserEvents. 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: CellBrowser.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void onBrowserEvent2(Event event) {
  super.onBrowserEvent2(event);

  // Handle keyboard navigation between lists.
  String eventType = event.getType();
  if (BrowserEvents.KEYDOWN.equals(eventType) && !isKeyboardNavigationSuppressed()) {
    int keyCode = event.getKeyCode();
    boolean isRtl = LocaleInfo.getCurrentLocale().isRTL();
    keyCode = KeyCodes.maybeSwapArrowKeysForRtl(keyCode, isRtl);
    switch (keyCode) {
      case KeyCodes.KEY_LEFT:
        keyboardNavigateShallow();
        return;
      case KeyCodes.KEY_RIGHT:
        keyboardNavigateDeep();
        return;
    }
  }
}
 
Example #2
Source File: GwtTreeCell.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Context context, Element parent, TreeState.TreeNodeState value, NativeEvent event, ValueUpdater<TreeState.TreeNodeState> valueUpdater) {
  String type = event.getType();

  if (type.equals(BrowserEvents.DBLCLICK)) {

    myCellTree.getTreeViewModel().getDoubleClickHandler().accept(value);
  }
  else {
    super.onBrowserEvent(context, parent, value, event, valueUpdater);
  }
}
 
Example #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
Source File: GwtTreeCell.java    From consulo with Apache License 2.0 4 votes vote down vote up
public GwtTreeCell() {
  super(BrowserEvents.DBLCLICK);
}
 
Example #12
Source File: CellTreeNodeView.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * Sets whether this item's children are displayed.
 *
 * @param open       whether the item is open
 * @param fireEvents true to fire events if the state changes
 * @return true if successfully opened, false otherwise.
 */
public boolean setOpen(boolean open, boolean fireEvents) {
  // Early out.
  if (this.open == open) {
    return this.open;
  }

  // If this node is a leaf node, do not call TreeViewModel.getNodeInfo().
  if (open && isLeaf()) {
    return false;
  }

  // The animation clears the innerHtml of the childContainer. If we reopen a
  // node as its closing, it is possible that the new data will be set
  // synchronously, so we have to cancel the animation before attaching the
  // data display to the node info.
  tree.cancelTreeNodeAnimation();
  this.animate = true;
  this.open = open;
  if (open) {
    if (!nodeInfoLoaded) {
      nodeInfoLoaded = true;
      nodeInfo = tree.getNodeInfo(value);

      // Sink events for the new node.
      if (nodeInfo != null) {
        Set<String> eventsToSink = new HashSet<String>();
        // Listen for focus and blur for keyboard navigation
        eventsToSink.add(BrowserEvents.FOCUS);
        eventsToSink.add(BrowserEvents.BLUR);

        Set<String> consumedEvents = nodeInfo.getCell().getConsumedEvents();
        if (consumedEvents != null) {
          eventsToSink.addAll(consumedEvents);
        }
        CellBasedWidgetImpl.get().sinkEvents(tree, eventsToSink);
      }
    }

    // If we don't have any nodeInfo, we must be a leaf node.
    if (nodeInfo != null) {
      // Add a loading message.
      ensureChildContainer();
      showOrHide(showMoreElem, false);
      showOrHide(emptyMessageElem, false);
      if (!isRootNode()) {
        setStyleName(getCellParent(), tree.getStyle().cellTreeOpenItem(), true);
      }
      ensureAnimationFrame().getStyle().setProperty("display", "");
      onOpen(nodeInfo);

      // Fire an event.
      if (fireEvents) {
        OpenEvent.fire(tree, getTreeNode());
      }
    }
    else {
      this.open = false;
    }
  }
  else {
    if (!isRootNode()) {
      setStyleName(getCellParent(), tree.getStyle().cellTreeOpenItem(), false);
    }
    cleanup(false);
    tree.maybeAnimateTreeNode(this);
    updateImage(false);

    // Keyboard select this node if the open node was a child.
    CellTreeNodeView<?> keySelected = tree.getKeyboardSelectedNode();
    while (keySelected != null) {
      if (keySelected == this) {
        tree.keyboardSelect(this, true);
        break;
      }
      keySelected = keySelected.getParentNode();
    }

    // Fire an event.
    if (fireEvents) {
      CloseEvent.fire(tree, getTreeNode());
    }
  }

  return this.open;
}