Example usage for com.google.gwt.user.client.ui FlexTable removeCell

List of usage examples for com.google.gwt.user.client.ui FlexTable removeCell

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui FlexTable removeCell.

Prototype

@Override
    public void removeCell(int row, int col) 

Source Link

Usage

From source file:org.jbpm.form.builder.ng.model.client.form.items.MIGLayoutFormItem.java

License:Apache License

private void populate(FlexTable grid) {
    if (this.borderWidth != null && this.borderWidth > 0) {
        grid.setBorderWidth(this.borderWidth);
    }//from  w w  w . java2 s  .co m
    if (this.cellpadding != null && this.cellpadding >= 0) {
        grid.setCellPadding(this.cellpadding);
    }
    if (this.cellspacing != null && this.cellspacing >= 0) {
        grid.setCellSpacing(this.cellspacing);
    }
    if (getHeight() != null) {
        grid.setHeight(getHeight());
    }
    if (getWidth() != null) {
        grid.setWidth(getWidth());
    }
    if (this.title != null) {
        grid.setTitle(this.title);
    }
    if (this.rows != null && this.rows > 0) {
        while (this.rows > grid.getRowCount()) {
            grid.insertRow(grid.getRowCount());
            int columnCount = 0;
            FlexCellFormatter formatter = grid.getFlexCellFormatter();
            for (int cell = 0; cell < grid.getCellCount(grid.getRowCount() - 1); cell++) {
                columnCount += formatter.getColSpan(grid.getRowCount() - 1, cell);
            }
            while (this.columns > columnCount) {
                grid.addCell(grid.getRowCount() - 1); //at least one cell per column. Modified later by colspans
                columnCount++;
            }
        }
        while (this.rows < grid.getRowCount()) {
            grid.removeRow(grid.getRowCount() - 1);
        }
    }
    if (this.columns != null && this.columns > 0) {
        for (int row = 0; row < grid.getRowCount(); row++) {
            int columnCount = 0;
            FlexCellFormatter formatter = grid.getFlexCellFormatter();
            for (int cell = 0; cell < grid.getCellCount(row); cell++) {
                columnCount += formatter.getColSpan(row, cell);
            }
            while (this.columns > columnCount) {
                grid.addCell(row);
                columnCount++;
            }
            while (this.columns < columnCount) {
                int cellCount = grid.getCellCount(row);
                if (cellCount > 0) {
                    int cellColumns = formatter.getColSpan(row, cellCount - 1);
                    if (cellColumns > 1 && columnCount - cellColumns >= this.columns) {
                        grid.removeCell(row, cellCount - 1);
                    } else {
                        grid.removeCell(row, cellCount - 1);
                    }
                }
                columnCount--;
            }
        }
    }
}