Examples of FlexCellFormatter


Examples of com.google.gwt.widgetideas.table.client.overrides.FlexTable.FlexCellFormatter

   * Test ghost row count with spans.
   */
  public void testGhostRowSpans() {
    // Initialize the table
    FixedWidthFlexTable testTable = getFixedWidthFlexTable();
    FlexCellFormatter cellFormatter = testTable.getFlexCellFormatter();
    for (int row = 0; row < 3; row++) {
      for (int cell = 0; cell < 3; cell++) {
        testTable.setHTML(row, cell, "");
      }
    }

    // Set colspan
    assertGhostCount(3, testTable);
    cellFormatter.setColSpan(0, 1, 3);
    assertGhostCount(5, testTable);
    cellFormatter.setColSpan(0, 1, 2);
    assertGhostCount(4, testTable);
    cellFormatter.setColSpan(0, 1, 1);
    assertGhostCount(3, testTable);
    cellFormatter.setColSpan(0, 1, 0);
    assertGhostCount(3, testTable);

    // Set rowspan
    assertGhostCount(3, testTable);
    cellFormatter.setRowSpan(0, 1, 3);
    assertGhostCount(4, testTable);
    cellFormatter.setRowSpan(0, 1, 2);
    assertGhostCount(4, testTable);
    cellFormatter.setRowSpan(0, 1, 1);
    assertGhostCount(3, testTable);
  }
View Full Code Here

Examples of org.gwt.mosaic.override.client.FlexTable.FlexCellFormatter

      table.removeRow(0);
    }

    // Generate the header table
    int columnCount = allInfos.size();
    FlexCellFormatter formatter = table.getFlexCellFormatter();
    List<ColumnHeaderInfo> prevInfos = null;
    for (int col = 0; col < columnCount; col++) {
      List<ColumnHeaderInfo> infos = allInfos.get(col);
      int row = 0;
      for (ColumnHeaderInfo info : infos) {
        // Get the actual row and cell index
        int rowSpan = info.getRowSpan();
        int cell = 0;
        if (table.getRowCount() > row) {
          cell = table.getCellCount(row);
        }

        // Compare to the cell in the previous column
        if (prevInfos != null) {
          boolean headerAdded = false;
          int prevRow = 0;
          for (ColumnHeaderInfo prevInfo : prevInfos) {
            // Increase the colSpan of the previous cell
            if (prevRow == row && info.equals(prevInfo)) {
              int colSpan = formatter.getColSpan(row, cell - 1);
              formatter.setColSpan(row, cell - 1, colSpan + 1);
              headerAdded = true;
              break;
            }
            prevRow += prevInfo.getRowSpan();
          }

          if (headerAdded) {
            row += rowSpan;
            continue;
          }
        }

        // Set the new header
        Object header = info.getHeader();
        if (header instanceof Widget) {
          table.setWidget(row, cell, (Widget) header);
        } else {
          table.setHTML(row, cell, header.toString());
        }

        // Update the rowSpan
        if (rowSpan > 1) {
          formatter.setRowSpan(row, cell, rowSpan);
        }

        // Increment the row
        row += rowSpan;
      }

      // Increment the previous info
      prevInfos = infos;
    }

    // Insert the checkbox column
    SelectionPolicy selectionPolicy = getDataTable().getSelectionPolicy();
    if (selectionPolicy.hasInputColumn()) {
      // Get the select all box
      Widget box = null;
      if (isHeader
          && getDataTable().getSelectionPolicy() == SelectionPolicy.CHECKBOX) {
        box = getSelectAllWidget();
      }

      // Add the offset column
      table.insertCell(0, 0);
      if (box != null) {
        table.setWidget(0, 0, box);
      } else {
        table.setHTML(0, 0, "&nbsp;");
      }
      formatter.setRowSpan(0, 0, table.getRowCount());
      formatter.setHorizontalAlignment(0, 0,
          HasHorizontalAlignment.ALIGN_CENTER);
      table.setColumnWidth(0, getDataTable().getInputColumnWidth());
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.