示例#1
0
  /**
   * Automatically tries to create a proxy image from given element.
   *
   * @param element
   * @param alignImageToEvent if true, proxy image is aligned to start event, else next to mouse
   *     cursor
   * @deprecated As of 7.2, call or override {@link #createDragImage(Element,boolean)} instead
   */
  @Deprecated
  public void createDragImage(
      com.google.gwt.user.client.Element element, boolean alignImageToEvent) {
    Element cloneNode = (Element) element.cloneNode(true);

    // Set size explicitly for cloned node to avoid stretching #14617.
    cloneNode.getStyle().setWidth(element.getOffsetWidth(), Unit.PX);
    cloneNode.getStyle().setHeight(element.getOffsetHeight(), Unit.PX);

    syncContent(element, cloneNode);
    if (BrowserInfo.get().isIE()) {
      if (cloneNode.getTagName().toLowerCase().equals("tr")) {
        TableElement table = Document.get().createTableElement();
        TableSectionElement tbody = Document.get().createTBodyElement();
        table.appendChild(tbody);
        tbody.appendChild(cloneNode);
        cloneNode = table.cast();
      }
    }
    if (alignImageToEvent) {
      int absoluteTop = element.getAbsoluteTop();
      int absoluteLeft = element.getAbsoluteLeft();
      int clientX = WidgetUtil.getTouchOrMouseClientX(startEvent);
      int clientY = WidgetUtil.getTouchOrMouseClientY(startEvent);
      int offsetX = absoluteLeft - clientX;
      int offsetY = absoluteTop - clientY;
      setDragImage(cloneNode, offsetX, offsetY);
    } else {
      setDragImage(cloneNode);
    }
  }
示例#2
0
 /**
  * TODO consider extracting touches support to an impl class specific for webkit (only browser
  * that really supports touches).
  *
  * @param event
  * @return
  */
 protected int getEventPosition(Event event) {
   if (isVertical()) {
     return WidgetUtil.getTouchOrMouseClientY(event);
   } else {
     return WidgetUtil.getTouchOrMouseClientX(event);
   }
 }
示例#3
0
  @Override
  protected void sendContextClickEvent(MouseEventDetails details, EventTarget eventTarget) {
    // if element is the resize indicator, ignore the event
    if (isResizeHandle(eventTarget)) {
      WidgetUtil.clearTextSelection();
      return;
    }

    EventCellReference<JsonObject> eventCell = getWidget().getEventCell();

    Section section = eventCell.getSection();
    String rowKey = null;
    if (eventCell.isBody() && eventCell.getRow() != null) {
      rowKey = getRowKey(eventCell.getRow());
    }

    String columnId = getColumnId(eventCell.getColumn());

    getRpcProxy(GridServerRpc.class)
        .contextClick(eventCell.getRowIndex(), rowKey, columnId, section, details);

    WidgetUtil.clearTextSelection();
  }
  @Override
  protected Slot getSlot(Element e, NativeEvent event) {
    Slot slot = null;
    if (getLayout().getElement() == e) {
      // Most likely between components, use the closes one in that case
      slot = findSlotHorizontally(12, event);
    } else {
      slot = WidgetUtil.findWidget(e, Slot.class);
      if (slot == null) {
        return null;
      }
      VAbstractOrderedLayout layout = VDragDropUtil.getSlotLayout(slot);
      while (layout != getLayout() && getLayout().getElement().isOrHasChild(e.getParentElement())) {
        e = e.getParentElement();
        slot = WidgetUtil.findWidget(e, Slot.class);
        if (slot == null) {
          return null;
        }
        layout = VDragDropUtil.getSlotLayout(slot);
      }
    }

    return slot;
  }
示例#5
0
  @Override
  public void onBrowserEvent(Event event) {
    if (disabled || readonly) {
      return;
    }
    final Element targ = DOM.eventGetTarget(event);

    if (DOM.eventGetType(event) == Event.ONMOUSEWHEEL) {
      processMouseWheelEvent(event);
    } else if (dragging || targ == handle) {
      processHandleEvent(event);
    } else if (targ == smaller) {
      decreaseValue(true);
    } else if (targ == bigger) {
      increaseValue(true);
    } else if (DOM.eventGetType(event) == Event.MOUSEEVENTS) {
      processBaseEvent(event);
    } else if (BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYPRESS
        || !BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYDOWN) {

      if (handleNavigation(event.getKeyCode(), event.getCtrlKey(), event.getShiftKey())) {

        feedbackPopup.show();

        delayedValueUpdater.trigger();

        DOM.eventPreventDefault(event);
        DOM.eventCancelBubble(event, true);
      }
    } else if (targ.equals(getElement()) && DOM.eventGetType(event) == Event.ONFOCUS) {
      feedbackPopup.show();
    } else if (targ.equals(getElement()) && DOM.eventGetType(event) == Event.ONBLUR) {
      feedbackPopup.hide();
    } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
      feedbackPopup.show();
    }
    if (WidgetUtil.isTouchEvent(event)) {
      event.preventDefault(); // avoid simulated events
      event.stopPropagation();
    }
  }
  private void updateItem(VCheckBox widget, JsonObject item, boolean requireInitialization) {
    String itemHtml = item.getString(ListingJsonConstants.JSONKEY_ITEM_VALUE);
    if (!isHtmlContentAllowed()) {
      itemHtml = WidgetUtil.escapeHTML(itemHtml);
    }

    String iconUrl = item.getString(ListingJsonConstants.JSONKEY_ITEM_ICON);
    if (iconUrl != null && iconUrl.length() != 0) {
      Icon icon = client.getIcon(iconUrl);
      itemHtml = icon.getElement().getString() + itemHtml;
    }

    widget.setHTML(itemHtml);
    widget.setValue(item.getBoolean(ListingJsonConstants.JSONKEY_ITEM_SELECTED));
    setOptionEnabled(widget, item);

    if (requireInitialization) {
      widget.addStyleName(CLASSNAME_OPTION);
      widget.addClickHandler(this);
      getWidget().add(widget);
    }
    optionsToItems.put(widget, item);
  }