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

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

Introduction

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

Prototype

@Override
public int getCellCount(int row) 

Source Link

Document

Gets the number of cells on a given row.

Usage

From source file:ch.eaternity.client.FlexTableRowDragController.java

License:Apache License

private int getWidgetRow(Widget widget, FlexTable table) {
    for (int row = 0; row < table.getRowCount(); row++) {
        for (int col = 0; col < table.getCellCount(row); col++) {
            Widget w = table.getWidget(row, col);
            if (w == widget) {
                return row;
            }/*www. ja v  a2  s.  co m*/
        }
    }
    throw new RuntimeException("Unable to determine widget row");
}

From source file:ch.eaternity.client.FlexTableUtil.java

License:Apache License

/**
 * Copy an entire FlexTable from one FlexTable to another. Each element is copied by creating a
 * new {@link HTML} widget by calling {@link FlexTable#getHTML(int, int)} on the source table.
 * //from w  w w .j  a  va2 s.c om
 * @param sourceTable the FlexTable to copy a row from
 * @param targetTable the FlexTable to copy a row to
 * @param sourceRow the index of the source row
 * @param targetRow the index before which to insert the copied row
 */
public static void copyRow(FlexTable sourceTable, FlexTable targetTable, int sourceRow, int targetRow) {
    targetTable.insertRow(targetRow);
    for (int col = 0; col < sourceTable.getCellCount(sourceRow); col++) {
        HTML html = new HTML(sourceTable.getHTML(sourceRow, col));
        targetTable.setWidget(targetRow, col, html);
    }
    copyRowStyle(sourceTable, targetTable, sourceRow, targetRow);
}

From source file:ch.eaternity.client.FlexTableUtil.java

License:Apache License

/**
 * Move an entire FlexTable from one FlexTable to another. Elements are moved by attempting to
 * call {@link FlexTable#getWidget(int, int)} on the source table. If no widget is found (because
 * <code>null</code> is returned), a new {@link HTML} is created instead by calling
 * {@link FlexTable#getHTML(int, int)} on the source table.
 * /*from ww  w. j  a  va 2 s . co m*/
 * @param sourceTable the FlexTable to move a row from
 * @param targetTable the FlexTable to move a row to
 * @param sourceRow the index of the source row
 * @param targetRow the index before which to insert the moved row
 */
public static void moveRow(FlexTable sourceTable, FlexTable targetTable, int sourceRow, int targetRow) {
    if (sourceTable == targetTable && sourceRow >= targetRow) {
        sourceRow++;
    }
    targetTable.insertRow(targetRow);
    for (int col = 0; col < sourceTable.getCellCount(sourceRow); col++) {
        Widget w = sourceTable.getWidget(sourceRow, col);
        if (w != null) {
            targetTable.setWidget(targetRow, col, w);
        } else {
            HTML html = new HTML(sourceTable.getHTML(sourceRow, col));
            targetTable.setWidget(targetRow, col, html);
        }
    }
    copyRowStyle(sourceTable, targetTable, sourceRow, targetRow);
    sourceTable.removeRow(sourceRow);
}

From source file:com.dawg6.web.dhcalc.client.FlexTableHelper.java

License:Open Source License

/**
 * Fixes problem with {@link FlexCellFormatter#setRowSpan(int, int, int)}, see comment for
 * {@link #FlexTableHelper}.//from   w  ww .j a  v  a 2  s.com
 */
public static void fixRowSpan(final FlexTable flexTable) {
    Set<Element> tdToRemove = new HashSet<Element>();
    {
        int rowCount = flexTable.getRowCount();
        for (int row = 0; row < rowCount; row++) {
            int cellCount = flexTable.getCellCount(row);
            //System.out.println("\tcellCount: " + row + " " + cellCount);
            for (int cell = 0; cell < cellCount; cell++) {
                int colSpan = flexTable.getFlexCellFormatter().getColSpan(row, cell);
                int rowSpan = flexTable.getFlexCellFormatter().getRowSpan(row, cell);
                if (rowSpan != 1) {
                    int column = getColumnOfCell(flexTable, row, cell);
                    for (int row2 = row + 1; row2 < row + rowSpan; row2++) {
                        int baseCell2 = getCellOfColumn(flexTable, row2, column);
                        for (int cell2 = baseCell2; cell2 < baseCell2 + colSpan; cell2++) {
                            if (cell2 != -1) {
                                /*System.out.println("remove (row,cell,column): "
                                   + row2
                                   + " "
                                   + cell2
                                   + " "
                                   + column);*/
                                Element td = flexTable.getCellFormatter().getElement(row2, cell2);
                                tdToRemove.add(td);
                            }
                        }
                    }
                }
            }
        }
    }
    // remove TD elements
    for (Element td : tdToRemove) {
        Element tr = DOM.getParent(td);
        DOM.removeChild(tr, td);
    }
}

From source file:com.dawg6.web.dhcalc.client.FlexTableHelper.java

License:Open Source License

private static int getCellOfColumn(FlexTable flexTable, int row, int column) {
    int cellCount = flexTable.getCellCount(row);
    int currentColumn = 0;
    for (int cell = 0; cell < cellCount; cell++) {
        int colSpan = getColSpan(flexTable, row, cell);
        if (currentColumn == column) {
            return cell;
        }/* w  w  w  . ja  v a2s.  co m*/
        currentColumn += colSpan;
    }
    return -1;
}

From source file:com.ephesoft.dcma.gwt.rv.client.view.TableExtractionView.java

License:Open Source License

private void clearSelectedRowStyle(final FlexTable flexTable) {
    for (int i = 0; i < flexTable.getRowCount(); i++) {
        for (int j = 0; j < flexTable.getCellCount(i); j++) {
            if (flexTable.getWidget(i, j) != null) {
                flexTable.getWidget(i, j).removeStyleName(ReviewValidateConstants.ROW_SELECTION_STYLE);
            }// www .  j  av  a 2s . c  o  m
        }
    }
}

From source file:com.google.gwt.sample.stockwatcher.client.SchedulePage.java

private void addEditRegularScheduleColumnAllRow(FlexTable ft) {
    for (int i = 1; i < ft.getRowCount(); i++) {
        Anchor edit = new Anchor("Edit");
        ft.setWidget(i, ft.getCellCount(i), edit);
        edit.setName(ft.getText(i, 0));//  w  w  w.  jav a  2 s .  c o m
        setEditRegularScheduleClickHandler(edit);
    }
}

From source file:com.google.gwt.sample.stockwatcher.client.SchedulePage.java

private void addEditSpecialScheduleColumnAllRow(FlexTable ft) {
    for (int i = 1; i < ft.getRowCount(); i++) {
        Anchor edit = new Anchor("Edit");
        ft.setWidget(i, ft.getCellCount(i), edit);
        edit.setName(ft.getText(i, 0));/*from ww w . j  a  v  a  2 s  .  c o  m*/
        setEditSpecialScheduleClickHandler(edit);
    }
}

From source file:com.google.gwt.sample.stockwatcher.client.SchedulePage.java

private void addEditRuleColumnAllRow(FlexTable ft) {
    for (int i = 1; i < ft.getRowCount(); i++) {
        final Anchor edit = new Anchor("Edit");
        ft.setWidget(i, ft.getCellCount(i), edit);
        edit.setName(ft.getText(i, 0));/*from   w  w  w .j  a  v a  2 s  .c o  m*/
        setEditRuleClickHandler(edit);
    }
}

From source file:com.google.gwt.sample.stockwatcher.client.SchedulePage.java

private void addEditRuleColumnLatestRow(FlexTable ft) {

    int lastRow = ft.getRowCount() - 1;

    final Anchor edit = new Anchor("Edit");
    ft.setWidget(lastRow, ft.getCellCount(lastRow), edit);
    edit.setName(ft.getText(lastRow, 0));
    setEditRuleClickHandler(edit);/* w w w.j  ava 2 s  .  co m*/
}