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

Examples of com.google.gwt.gen2.table.client.SelectionGrid$SelectionGridCellFormatter


   */
  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

    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

    // Add button to change policy
    {
      Button button = new Button("Set Selection Policy", new ClickHandler() {
        public void onClick(ClickEvent event) {
          SelectionGrid grid = ScrollTableDemo.get().getDataTable();
          switch (policyBox.getSelectedIndex()) {
            case 0:
              grid.setSelectionPolicy(SelectionPolicy.MULTI_ROW);
              break;
            case 1:
              grid.setSelectionPolicy(SelectionPolicy.ONE_ROW);
              break;
            case 2:
              grid.setSelectionPolicy(SelectionPolicy.CHECKBOX);
              break;
            case 3:
              grid.setSelectionPolicy(SelectionPolicy.RADIO);
              break;
          }
          PagingScrollTableDemo.get().getPagingScrollTable().reloadPage();
        }
      });
      form.addButton(button);
    }

    // Add button to change status
    {
      Button button = new Button("Toggle Status", new ClickHandler() {
        public void onClick(ClickEvent event) {
          SelectionGrid grid = ScrollTableDemo.get().getDataTable();
          grid.setSelectionEnabled(!grid.isSelectionEnabled());
          refreshPolicy();
        }
      });
      form.addButton(button);
    }
View Full Code Here

  /**
   * Refresh the policy.
   */
  private void refreshPolicy() {
    SelectionGrid grid = ScrollTableDemo.get().getDataTable();

    // Refresh the status
    if (grid.isSelectionEnabled()) {
      statusLabel.setText("enabled");
    } else {
      statusLabel.setText("disabled");
    }

    // Refresh the policy
    SelectionPolicy policy = grid.getSelectionPolicy();
    if (policy == SelectionPolicy.MULTI_ROW) {
      policyBox.setSelectedIndex(0);
    } else if (policy == SelectionPolicy.ONE_ROW) {
      policyBox.setSelectedIndex(1);
    } else if (policy == SelectionPolicy.CHECKBOX) {
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

    // Sort the column with a column sorter
    {
      TestPageLoadHandler plh = new TestPageLoadHandler();
      scrollTable.addPageLoadHandler(plh);
      dataTable.setColumnSorter(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.SelectionGrid$SelectionGridCellFormatter

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.