Example usage for com.google.gwt.coreext.client IterableFastStringMap iterate

List of usage examples for com.google.gwt.coreext.client IterableFastStringMap iterate

Introduction

In this page you can find the example usage for com.google.gwt.coreext.client IterableFastStringMap iterate.

Prototype

public native void iterate(IterationCallBack<T> cb) ;

Source Link

Usage

From source file:com.google.speedtracer.client.visualizations.view.EventWaterfallRowDetails.java

License:Apache License

/**
 * Creates the details table information for a single UiEvent selected in the
 * event trace tree./*from ww  w.j  a  v a 2s. co  m*/
 * 
 * @param parent The parent {@link Container} that we will be attaching the
 *          table to.
 * @param pieChartHeight The height in pixels of the piechart so that we can
 *          position ourselves accordingly.
 * @param e The {@link UiEvent} that we will be displaying the details of.
 * 
 * @return The {@link Table} that contains the detail information
 */
private Table createDetailsTable(Container parent, int pieChartHeight, final UiEvent e) {
    IterableFastStringMap<CellRenderer> detailsMap = getDetailsMapForEvent(e);
    final Table table = new Table(parent);

    detailsMap.iterate(new IterableFastStringMap.IterationCallBack<CellRenderer>() {
        private boolean hasRow = false;

        public void onIteration(String key, CellRenderer cellRenderer) {
            // If we have at least one piece of data for this table, we add a
            // header
            if (!hasRow) {
                // Establish column widths.
                Element keyCol = Document.get().createElement("th");
                keyCol.setClassName(getCss().detailsKeyColumn());
                Element valCol = Document.get().createElement("th");
                table.getTableHead().appendChild(keyCol);
                table.getTableHead().appendChild(valCol);

                // Now add the title
                Element titleRow = Document.get().createElement("tr");
                Element title = Document.get().createElement("th");
                title.setAttribute("colspan", "2");
                title.setAttribute("align", "left");
                title.setInnerText("Details for " + UiEvent.typeToDetailedTypeString(e));
                title.getStyle().setWidth(100, Unit.PX);
                titleRow.appendChild(title);
                table.getTableHead().appendChild(titleRow);
                hasRow = true;
            }

            TableRowElement row = table.appendRow();
            TableCellElement cell = row.insertCell(-1);
            cell.setClassName(getCss().detailsTableKey());
            String rowKey = key.substring(1);
            cell.setInnerText(rowKey);
            cell = row.insertCell(-1);
            cellRenderer.render(cell);
        }
    });

    table.addStyleName(getCss().detailsTable());
    // ensure that the table is positioned below the pieChart
    table.getElement().getStyle().setPropertyPx("marginTop", pieChartHeight);
    return table;
}