Example usage for com.google.gwt.gen2.table.client FixedWidthGrid setHTML

List of usage examples for com.google.gwt.gen2.table.client FixedWidthGrid setHTML

Introduction

In this page you can find the example usage for com.google.gwt.gen2.table.client FixedWidthGrid setHTML.

Prototype

@Override
    public void setHTML(int row, int column, String html) 

Source Link

Usage

From source file:com.google.gwt.gen2.demo.scrolltable.client.ScrollTableDemo.java

License:Apache License

/**
 * Add a row of data cells each consisting of a string that describes the
 * row:column coordinates of the new cell. The number of columns in the new
 * row will match the number of columns in the grid.
 * //from ww w . ja  v a2  s.  c  o m
 * @param beforeRow the index to add the new row into
 */
public void insertDataRow(int beforeRow) {
    // Insert the new row
    FixedWidthGrid dataTable = getDataTable();
    beforeRow = dataTable.insertRow(beforeRow);

    // Set the data in the new row
    Student student = STUDENT_DATA.generateStudent();
    dataTable.setText(beforeRow, 0, student.getFirstName());
    dataTable.setText(beforeRow, 1, student.getLastName());
    dataTable.setText(beforeRow, 2, student.getAge() + "");
    dataTable.setText(beforeRow, 3, student.isMale() ? "male" : "female");
    dataTable.setText(beforeRow, 4, student.getRace());
    String color = student.getFavoriteColor();
    String colorHtml = "<FONT color=\"" + color + "\">" + color + "</FONT>";
    dataTable.setHTML(beforeRow, 5, colorHtml);
    dataTable.setText(beforeRow, 6, student.getFavoriteSport());
    dataTable.setText(beforeRow, 7, student.getCollege());
    dataTable.setText(beforeRow, 8, student.getGraduationYear() + "");
    String gpa = student.getGpa() + "";
    if (gpa.length() > 4) {
        gpa = gpa.substring(0, 4);
    }
    dataTable.setText(beforeRow, 9, gpa);
    dataTable.setText(beforeRow, 10, student.getId() + "");
    dataTable.setText(beforeRow, 11, student.getPin() + "");
}

From source file:edu.caltech.ipac.firefly.ui.table.TableOptions.java

private ScrollTable makeColsTable(final BasicPagingTable table) {

    final FixedWidthFlexTable header = new FixedWidthFlexTable();
    header.setHTML(0, 0, "Column");
    header.setWidget(0, 1, selectAllCheckBox);
    selectAllCheckBox.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent ev) {
            boolean hasSel = false;
            for (Map.Entry<ColDef, CheckBox> entry : checkBoxes.entrySet()) {
                if (entry.getValue().getValue()) {
                    hasSel = true;//ww  w.j a v a 2s  . c  o  m
                    break;
                }
            }

            if (selectAllCheckBox.getValue() && !hasSel) {
                for (Map.Entry<ColDef, CheckBox> entry : checkBoxes.entrySet()) {
                    entry.getValue().setValue(true);
                }
            } else {
                for (Map.Entry<ColDef, CheckBox> entry : checkBoxes.entrySet()) {
                    entry.getValue().setValue(false);
                }
                selectAllCheckBox.setValue(false);
            }
            applyChanges();
        }
    });

    //        final SortableGrid.ColumnSorter[] origSorter = new SortableGrid.ColumnSorter[1];
    @SuppressWarnings("deprecation")
    final FixedWidthGrid data = new FixedWidthGrid(0, 2);
    data.unsinkEvents(Event.ONMOUSEOVER);
    data.setSelectionEnabled(false);

    final ScrollTable view = new ScrollTable(data, header, new BasicTable.Images());
    FlexTable.FlexCellFormatter formatter = header.getFlexCellFormatter();
    formatter.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
    view.setMaximumColumnWidth(1, 35);
    view.setMinimumColumnWidth(1, 35);
    view.setColumnSortable(1, false);

    final DefaultTableDefinition<TableData.Row> tdef = (DefaultTableDefinition<TableData.Row>) table
            .getTableDefinition();
    int cRowIdx = 0;
    for (int i = 0; i < tdef.getColumnDefinitionCount(); i++) {
        final ColDef col = (ColDef) tdef.getColumnDefinition(i);
        if (!col.isImmutable()) {
            data.insertRow(cRowIdx);
            data.setHTML(cRowIdx, 0, col.getTitle());

            CheckBox cb = new CheckBox();
            cb.setValue(tdef.isColumnVisible(col));
            checkBoxes.put(col, cb);
            data.setWidget(cRowIdx, 1, cb);
            data.getCellFormatter().setAlignment(cRowIdx, 1, HasHorizontalAlignment.ALIGN_CENTER,
                    HasVerticalAlignment.ALIGN_MIDDLE);
            cRowIdx++;

            cb.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    applyChanges();
                }
            });
        }
    }

    return view;
}