예제 #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
  @Override
  public void setCampaignList(List<Campaign> campaignList) {
    int i = 0;
    TableSectionElement tbody = campaignTable.getTBodies().getItem(0);
    for (final Campaign cam : campaignList) {
      TableRowElement tr = tbody.insertRow(i);
      tr.setAttribute("class", "items");

      TableCellElement tdName = tr.insertCell(0);
      tdName.setInnerText(cam.getTitle());

      TableCellElement tdCat = tr.insertCell(1);
      tdCat.setAttribute("class", "text-right color-success");
      tdCat.setInnerText(cam.getTags().get(0));

      TableCellElement tcDate = tr.insertCell(2);
      tcDate.setInnerText(cam.getDate());

      TableCellElement tcOp = tr.insertCell(3);
      tcOp.setClassName("text-center");

      AnchorElement aEdit = Document.get().createAnchorElement();
      aEdit.setClassName("label label-default");
      aEdit.setInnerHTML("<i class=\"fa fa-pencil\"></i>");

      AnchorElement aDel = Document.get().createAnchorElement();
      aDel.setClassName("label label-danger");
      aDel.setInnerHTML("<i class=\"fa fa-times\"></i>");

      tcOp.appendChild(aEdit);
      tcOp.appendChild(aDel);

      Event.sinkEvents(aEdit, Event.ONCLICK);
      Event.setEventListener(
          aEdit,
          new EventListener() {
            @Override
            public void onBrowserEvent(Event event) {
              System.out.println("ok");
              if (Event.ONCLICK == event.getTypeInt()) {
                listener.goTo(new EditCampaignPlace("", cam));
              }
            }
          });

      Event.sinkEvents(aDel, Event.ONCLICK);
      Event.setEventListener(
          aDel,
          new EventListener() {
            @Override
            public void onBrowserEvent(Event event) {
              if (Event.ONCLICK == event.getTypeInt()) {
                Window.alert("Borrar " + cam.getTitle());
              }
            }
          });
      i++;
    }
  }
예제 #3
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);
  }
예제 #4
0
  private int removeTopRows(TableSectionElement tbody, int rowCount) {
    while (rowCount > 0 && tbody.getRows().getLength() >= 0) {
      TableRowElement topRow = tbody.getRows().getItem(0);
      if (codec_.isValueRow(topRow)) rowCount--;
      selectedRows_.remove(topRow);
      topRow.removeFromParent();
    }

    if (tbody.getRows().getLength() > 0) codec_.onRowsChanged(tbody);
    else tbody.removeFromParent();

    return rowCount;
  }
  @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;
  }