Package com.google.gwt.gen2.table.client

Examples of com.google.gwt.gen2.table.client.FixedWidthFlexTable$FixedWidthFlexTableImpl


   */
  public void testDistributePositiveWidth() {
    // Create some column info
    ColumnResizer resizer = new ColumnResizer();
    List<ColumnWidthInfo> columns = new ArrayList<ColumnWidthInfo>();
    columns.add(new ColumnWidthInfo(100, 300, 200, 150));
    columns.add(new ColumnWidthInfo(0, 100, 50, 50));
    columns.add(new ColumnWidthInfo(0, 500, 300, 100));

    // Only the first column gets any width, goes to -50%
    {
      assertEquals(0, resizer.distributeWidth(columns, 50));
      assertEquals(150, columns.get(0).getNewWidth());
View Full Code Here


   * Verify that we can distribute a zero width.
   */
  public void testDistributeZeroWidth() {
    // Create some column info
    List<ColumnWidthInfo> columns = new ArrayList<ColumnWidthInfo>();
    columns.add(new ColumnWidthInfo(100, 300, 200, 150));
    columns.add(new ColumnWidthInfo(0, 100, 50, 50));
    columns.add(new ColumnWidthInfo(0, 500, 300, 200));

    // Distribute some width
    ColumnResizer resizer = new ColumnResizer();
    resizer.distributeWidth(columns, 0);

View Full Code Here

   * @param width the width in pixels
   * @return the new column width
   */
  public int setColumnWidth(int column, int width) {
    // Constrain the size of the column
    ColumnWidthInfo info = getColumnWidthInfo(column);
    if (info.hasMaximumWidth()) {
      width = Math.min(width, info.getMaximumWidth());
    }
    if (info.hasMinimumWidth()) {
      width = Math.max(width, info.getMinimumWidth());
    }

    // Try to constrain the size of the grid
    if (resizePolicy.isSacrificial()) {
      // Get the sacrifice columns
View Full Code Here

  private void applyNewColumnWidths(int startIndex,
      List<ColumnWidthInfo> infos, boolean forced) {
    int offset = getHeaderOffset();
    int numColumns = infos.size();
    for (int i = 0; i < numColumns; i++) {
      ColumnWidthInfo info = infos.get(i);
      int newWidth = info.getNewWidth();
      if (forced || info.getCurrentWidth() != newWidth) {
        dataTable.setColumnWidth(startIndex + i, newWidth);
        headerTable.setColumnWidth(startIndex + i + offset, newWidth);
        if (footerTable != null) {
          footerTable.setColumnWidth(startIndex + i + offset, newWidth);
        }
View Full Code Here

        idealWidth = Math.min(idealWidth, maxWidth);
      }
      minWidth = Math.max(minWidth, idealWidth);
    }

    return new ColumnWidthInfo(minWidth, maxWidth, preferredWidth, curWidth);
  }
View Full Code Here

  /**
   * Setup the scroll table.
   */
  protected AbstractScrollTable createScrollTable() {
    // Create the three component tables
    FixedWidthFlexTable headerTable = createHeaderTable();
    FixedWidthFlexTable footerTable = createFooterTable();
    FixedWidthGrid dataTable = createDataTable();

    // Create the scroll table
    ScrollTable theScrollTable = new ScrollTable(dataTable, headerTable);
    theScrollTable.setFooterTable(footerTable);
View Full Code Here

  /**
   * @return the new footer table
   */
  private FixedWidthFlexTable createFooterTable() {
    FixedWidthFlexTable footerTable = new FixedWidthFlexTable();
    footerTable.setHTML(0, 0, "&nbsp;");
    for (int i = 0; i < 12; i++) {
      footerTable.setText(0, i + 1, "Col " + i);
    }
    return footerTable;
  }
View Full Code Here

  /**
   * @return the new header table
   */
  private FixedWidthFlexTable createHeaderTable() {
    FixedWidthFlexTable headerTable = new FixedWidthFlexTable();

    // Level 1 headers
    FlexCellFormatter headerFormatter = headerTable.getFlexCellFormatter();
    headerTable.setHTML(0, 0, "User Information");
    headerFormatter.setColSpan(0, 0, 13);

    // Create the select all checkbox
    final CheckBox selectAll = new CheckBox();
    selectAll.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        if (selectAll.getValue()) {
          getDataTable().selectAllRows();
        } else {
          getDataTable().deselectAllRows();
        }
      }
    });

    // Level 2 headers
    headerTable.setWidget(1, 0, selectAll);
    headerFormatter.setRowSpan(1, 0, 2);
    headerFormatter.setHorizontalAlignment(1, 0,
        HasHorizontalAlignment.ALIGN_CENTER);
    headerTable.setHTML(1, 1, "First and Last Name");
    headerFormatter.setColSpan(1, 1, 2);
    headerFormatter.setRowSpan(1, 1, 2);
    headerTable.setHTML(1, 2, "General Info");
    headerFormatter.setColSpan(1, 2, 3);
    headerTable.setHTML(1, 3, "Favorite Color");
    headerFormatter.setColSpan(1, 3, 1);
    headerFormatter.setRowSpan(1, 3, 2);
    headerTable.setHTML(1, 4, "Preferred Sport");
    headerFormatter.setColSpan(1, 4, 1);
    headerFormatter.setRowSpan(1, 4, 2);
    headerTable.setHTML(1, 5, "School Info");
    headerFormatter.setColSpan(1, 5, 3);
    headerTable.setHTML(1, 6, "Login Info");
    headerFormatter.setColSpan(1, 6, 2);

    // Level 3 headers
    headerTable.setHTML(2, 0, "Age");
    headerTable.setHTML(2, 1, "Gender");
    headerTable.setHTML(2, 2, "Race");
    headerTable.setHTML(2, 3, "College");
    headerTable.setHTML(2, 4, "Year");
    headerTable.setHTML(2, 5, "GPA");
    headerTable.setHTML(2, 6, "ID");
    headerTable.setHTML(2, 7, "Pin");

    return headerTable;
  }
View Full Code Here

    layout.setWidget(3, 0, highlightedRowLabel);
    layout.setWidget(2, 1, unhighlightedRowLabel);
    layout.setWidget(3, 1, unhighlightedCellLabel);

    // Add all of the listeners
    FixedWidthGrid dataTable = ScrollTableDemo.get().getDataTable();
    dataTable.addTableListener(new TableListener() {
      public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
        addLogEntry("cell clicked: (" + row + "," + cell + ")", "#ff00ff");
      }
    });
    dataTable.addColumnSortHandler(new ColumnSortHandler() {
      public void onColumnSorted(ColumnSortEvent event) {
        ColumnSortList sortList = event.getColumnSortList();
        int column = -1;
        boolean ascending = true;
        if (sortList != null) {
          column = sortList.getPrimaryColumn();
          ascending = sortList.isPrimaryAscending();
        }
        if (ascending) {
          addLogEntry("sorted column: " + column + " (ascending)", "black");
        } else {
          addLogEntry("sorted column: " + column, "black");
        }
      }
    });
    dataTable.addCellHighlightHandler(new CellHighlightHandler() {
      public void onCellHighlight(CellHighlightEvent event) {
        Cell cell = event.getValue();
        highlightedCellLabel.setText("Highlighted cell: (" + cell.getRowIndex()
            + "," + cell.getCellIndex() + ")");
      }
    });
    dataTable.addCellUnhighlightHandler(new CellUnhighlightHandler() {
      public void onCellUnhighlight(CellUnhighlightEvent event) {
        Cell cell = event.getValue();
        unhighlightedCellLabel.setText("Last unhighlighted cell: ("
            + cell.getRowIndex() + "," + cell.getCellIndex() + ")");
      }
    });
    dataTable.addRowHighlightHandler(new RowHighlightHandler() {
      public void onRowHighlight(RowHighlightEvent event) {
        Row cell = event.getValue();
        highlightedRowLabel.setText("Highlighted row: (" + cell.getRowIndex()
            + ")");
      }
    });
    dataTable.addRowUnhighlightHandler(new RowUnhighlightHandler() {
      public void onRowUnhighlight(RowUnhighlightEvent event) {
        Row cell = event.getValue();
        unhighlightedRowLabel.setText("Last unhighlighted row: ("
            + cell.getRowIndex() + ")");
      }
    });
    dataTable.addRowSelectionHandler(new RowSelectionHandler() {
      public void onRowSelection(RowSelectionEvent event) {
        // Show the previously selected rows
        Set<Row> deselectedRows = event.getDeselectedRows();
        String previous = "Previously selected rows: ";
        for (Row row : event.getOldValue()) {
View Full Code Here

   * Test accessors.
   */
  public void testAccessor() {
    // Initialize the grid
    SortableGrid testGrid = getSortableGrid();
    ColumnSorter mySorter = new ColumnSorter() {
      @Override
      public void onSortColumn(SortableGrid grid, ColumnSortList sortList,
          ColumnSorterCallback callback) {
      }
    };
View Full Code Here

TOP

Related Classes of com.google.gwt.gen2.table.client.FixedWidthFlexTable$FixedWidthFlexTableImpl

Copyright © 2018 www.massapicom. 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.