示例#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
  public void addItems(Iterable<TItemInput> items, boolean top) {
    TableSectionElement tbody = Document.get().createTBodyElement();
    for (TItemInput item : items) tbody.appendChild(codec_.getRowForItem(item));
    if (top) addToTop(tbody);
    else getElement().appendChild(tbody);

    codec_.onRowsChanged(tbody);
  }
  @PatchMethod
  static TableRowElement insertRow(TableElement e, int index) {
    NodeList<TableRowElement> rows = e.getRows();
    TableRowElement newRow = Document.get().createTRElement();
    if (rows.getLength() < 1) {
      TableSectionElement tbody = Document.get().createTBodyElement();
      e.appendChild(tbody);
      tbody.appendChild(newRow);
    } else {

      if (index == -1 || index >= rows.getLength()) {
        TableRowElement after = rows.getItem(rows.getLength() - 1);
        after.getParentElement().insertAfter(newRow, after);
      } else {
        TableRowElement before = rows.getItem(index);
        before.getParentElement().insertBefore(newRow, before);
      }
    }

    return newRow;
  }