Example usage for com.google.gwt.dom.client TableRowElement insertCell

List of usage examples for com.google.gwt.dom.client TableRowElement insertCell

Introduction

In this page you can find the example usage for com.google.gwt.dom.client TableRowElement insertCell.

Prototype

public final native TableCellElement insertCell(int index) ;

Source Link

Document

Insert an empty TD cell into this row.

Usage

From source file:com.google.gerrit.client.change.IncludedInBox.java

License:Apache License

private void appendRow(String title, JsArrayString l) {
    TableRowElement row = table.insertRow(-1);
    TableCellElement th = Document.get().createTHElement();
    th.setInnerText(title);//from w w  w  . j a  va2s. co  m
    row.appendChild(th);
    row.insertCell(-1).setInnerSafeHtml(formatList(l));
}

From source file:com.google.gwt.sample.contacts.client.view.ContactsViewImpl.java

public void setRowData(List<T> rowData) {
    this.rowData = rowData;

    TableElement table = Document.get().createTableElement();
    TableSectionElement tbody;/* w w  w. j  a  v a  2 s  . c  o  m*/
    table.appendChild(tbody = Document.get().createTBodyElement());

    for (int i = 0; i < rowData.size(); ++i) {
        TableRowElement row = tbody.insertRow(-1);
        T t = rowData.get(i);

        for (int j = 0; j < columnDefinitions.size(); ++j) {
            TableCellElement cell = row.insertCell(-1);
            StringBuilder sb = new StringBuilder();
            columnDefinitions.get(j).render(t, sb);
            cell.setInnerHTML(sb.toString());

            // TODO: Really total hack! There's gotta be a better way...
            Element child = cell.getFirstChildElement();
            if (child != null) {
                Event.sinkEvents(child, Event.ONFOCUS | Event.ONBLUR);
            }
        }
    }

    contactsTable.setHTML(table.getInnerHTML());
}

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

License:Apache License

@Override
protected Element createElement() {
    Element elem = super.createElement();
    Container myContainer = new DefaultContainerImpl(elem);

    // Now we need to layout the rest of the row details
    Table detailsLayout = new Table(myContainer);
    detailsLayout.setFixedLayout(true);//  w  w  w  . j  a  va  2s  . c  o m
    detailsLayout.getElement().setClassName(getCss().detailsLayout());

    // We have a 1 row, 2 column layout
    TableRowElement row = detailsLayout.insertRow(-1);

    // Create the first column.
    eventTraceContainerCell = row.insertCell(-1);

    // Add the piechart and detailsTable to the second column
    TableCellElement detailsTableCell = row.insertCell(-1);
    detailsTableCell.getStyle().setPropertyPx("paddingRight", getCss().uiPadding());

    // Attach the pie chart.
    detailsTableContainer = new DefaultContainerImpl(detailsTableCell);
    PieChart pieChart = createPieChart(detailsTableContainer);
    int pieChartHeight = pieChart.getElement().getOffsetHeight() + getCss().uiPadding();

    this.detailsTable = createDetailsTable(detailsTableContainer, pieChartHeight, getParentRow().getEvent());

    // Now we populate the first column.
    Container eventTraceContainer = new DefaultContainerImpl(eventTraceContainerCell);
    treeDiv = eventTraceContainer.getDocument().createDivElement();
    eventTraceContainerCell.appendChild(treeDiv);

    hintletTree = createHintletTree(treeDiv);
    createEventTrace(eventTraceContainer, pieChartHeight);

    profileDiv = new Div(eventTraceContainer);
    updateProfile();

    // Ensure that window resizes don't mess up our row size due to text
    // reflow. Things may need to grow or shrink.
    manageEventListener(ResizeEvent.addResizeListener(WindowExt.getHostWindow(), WindowExt.getHostWindow(),
            new ResizeListener() {
                public void onResize(ResizeEvent event) {
                    if (heightFixer == null && getParentRow().isExpanded()) {
                        heightFixer = new Command.Method() {
                            public void execute() {
                                // We don't want to do this for each resize, but once at
                                // the end.
                                fixHeightOfParentRow();
                                heightFixer = null;
                            }
                        };

                        Command.defer(heightFixer, 200);
                    }
                }
            }));
    return elem;
}

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.// ww w  . j  a  v a 2s  .  com
 * 
 * @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;
}

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

License:Apache License

private Table createMultiNodeDetailsTable(Container parent, int pieChartHeight, ArrayList<Item> selectedNodes) {
    Table table = new Table(parent);
    table.setFixedLayout(true);/*w w  w  .  j  av a 2  s  .c  o  m*/
    table.addStyleName(getCss().detailsTable());

    // Assume that List is sorted.
    UiEvent earliest = (UiEvent) selectedNodes.get(0).getItemTarget();
    UiEvent latest = (UiEvent) selectedNodes.get(selectedNodes.size() - 1).getItemTarget();
    double delta = latest.getTime() - earliest.getTime();

    TableRowElement row = table.appendRow();
    TableCellElement cell = row.insertCell(-1);
    cell.setClassName(getCss().detailsTableKey());
    cell.setInnerText("Time Delta");
    cell = row.insertCell(-1);
    cell.setInnerText(TimeStampFormatter.formatMilliseconds(delta));

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

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

License:Apache License

private void constructReportUi(Resources resources) {
    Css css = resources.hintletReportDialogCss();
    Container reportPaneContainer = new DefaultContainerImpl(reportPane.getElement());

    // Create a container for the summary information.
    Div summaryInfoDiv = new Div(reportPaneContainer);
    summaryInfoDiv.setStyleName(css.reportPaneInner());
    Container summaryInfoContainer = new DefaultContainerImpl(summaryInfoDiv.getElement());

    // Create the title for the summary information.
    summaryTitle = summaryInfoDiv.getElement().getOwnerDocument().createDivElement();
    summaryTitle.setClassName(css.reportTitle());
    updateSummaryTitle();/*from  w w  w  .  j  av a2 s . c o  m*/
    summaryInfoDiv.getElement().appendChild(summaryTitle);

    // Summary info is a 2 column section. PieChart on the left, and the startup
    // statistics on the right.
    Table summaryLayout = new Table(summaryInfoContainer);
    summaryLayout.setFixedLayout(true);
    TableRowElement row = summaryLayout.insertRow(-1);
    row.setVAlign("top");
    TableCellElement leftCell = row.insertCell(-1);
    Container pieChartContainer = new DefaultContainerImpl(leftCell);

    // Create a piechart with no data initially.
    this.pieChart = new PieChart(pieChartContainer, new ArrayList<ColorCodedValue>(), resources);

    // TODO (jaimeyap): Add startup statistics to the right of the pie chart.
    // Things like "time to first paint" or "page load time".

    // Create the inner container to hold to hint report.
    Div hintReportDiv = new Div(reportPaneContainer);
    hintReportDiv.setStyleName(css.reportPaneInner());
    Container hintReportContainer = new DefaultContainerImpl(hintReportDiv.getElement());

    // Create the title for the hint report.
    DivElement hintTitle = hintReportDiv.getElement().getOwnerDocument().createDivElement();
    hintTitle.setInnerText("Hints");
    hintTitle.setClassName(css.reportTitle());
    hintReportDiv.getElement().appendChild(hintTitle);

    // Construct the scope bar for selecting different type of hint reports.
    buildHintReportScopeBar(resources, hintReportContainer);

    // Create the hint report.
    this.report = new HintletReport(hintReportContainer, new HintletReportModel(), resources,
            HintletReport.REPORT_TYPE_SEVERITY);
}

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

License:Apache License

/**
 * Appends a TableRowElement and populates it with two cells.
 * // w w  w  .java 2s.co m
 * @param summaryTable
 * @param title
 * @param value
 */
private static void addRowPair(Table dataTable, Css css, boolean isEven, String title, String value) {
    TableRowElement row = dataTable.appendRow();
    if (isEven) {
        row.setClassName(css.rowEven());
    }

    final TableCellElement nameCell = row.insertCell(-1);
    nameCell.setClassName(css.nameCell());
    nameCell.setInnerText(title);

    final TableCellElement valueCell = row.insertCell(-1);
    valueCell.setClassName(css.valueCell());
    valueCell.setInnerText(value);
}

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

License:Apache License

/**
 * Appends a TableRowElement and populates it with two cells.
 * // w  ww . j av  a  2s.co  m
 * @param summaryTable
 * @param title
 * @param value
 */
private static void addRowPairByClass(Table dataTable, Css css, String rowClass, String title, String value) {
    TableRowElement row = dataTable.appendRow();
    row.setClassName(rowClass);

    final TableCellElement nameCell = row.insertCell(-1);
    nameCell.setClassName(css.nameCell());
    nameCell.setInnerText(title);

    final TableCellElement valueCell = row.insertCell(-1);
    valueCell.setClassName(css.valueCell());
    valueCell.setInnerText(value);
}

From source file:org.drools.guvnor.client.widgets.decoratedgrid.VerticalMergableGridWidget.java

License:Apache License

@Override
void showColumn(int index) {
    if (index < 0) {
        throw new IllegalArgumentException("index cannot be less than zero");
    }//from  w w w .  j  a  va 2  s .  co  m
    if (index > columns.size()) {
        throw new IllegalArgumentException("index cannot be greater than the number of rows");
    }

    for (int iRow = 0; iRow < data.size(); iRow++) {
        DynamicDataRow rowData = data.get(iRow);
        TableCellElement tce = makeTableCellElement(index, rowData);
        if (tce != null) {

            CellValue<? extends Comparable<?>> cell = rowData.get(index);
            Coordinate hc = cell.getHtmlCoordinate();

            TableRowElement tre = tbody.getRows().getItem(hc.getRow());
            TableCellElement ntce = tre.insertCell(hc.getCol());
            tre.replaceChild(tce, ntce);
        }
    }
}

From source file:org.xwiki.gwt.wysiwyg.client.plugin.table.util.TableUtils.java

License:Open Source License

/**
 * Insert a row in the currently edited table.
 * /*ww  w.  j  av a2 s. c om*/
 * @param doc the Document to get the selection from.
 * @param insertBefore indicates the creation position relatively to the currently edited row.
 * @return the newly created TableRowElement.
 */
public TableRowElement insertRow(Document doc, boolean insertBefore) {
    TableRowElement row = getRow(getCaretNode(doc));
    TableElement table = getTable(row);
    int index = row.getRowIndex();

    if (!insertBefore) {
        index++;
    }

    TableRowElement newRow = table.insertRow(index);
    // Populate the row
    int cellCount = row.getCells().getLength();
    for (int i = 0; i < cellCount; i++) {
        TableCellElement cell = newRow.insertCell(i);
        cell.setInnerHTML(CELL_DEFAULTHTML);
    }

    return newRow;
}