Example usage for com.google.gwt.dom.client TableCellElement getStyle

List of usage examples for com.google.gwt.dom.client TableCellElement getStyle

Introduction

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

Prototype

@Override
    public Style getStyle() 

Source Link

Usage

From source file:com.extjs.gxt.ui.client.widget.layout.TableLayout.java

License:sencha.com license

protected Element getNextCell(Component widget) {
    if (cells == null) {
        cells = new ArrayList<List<Boolean>>();
    }/*from ww w . j a va2  s  .  c  om*/

    TableData data = (TableData) getLayoutData(widget);
    if (data == null) {
        data = new TableData();
        setLayoutData(widget, data);
    }

    TableCellElement td = DOM.createTD().cast();
    td.setClassName("x-table-layout-cell");
    td.setAttribute("role", "presentation");

    int[] cell = getNextNonSpan(currentColumn, currentRow);
    int curCol = currentColumn = cell[0];
    int curRow = currentRow = cell[1];

    for (int rowIndex = curRow; rowIndex < curRow
            + (data.getRowspan() != -1 ? data.getRowspan() : 1); rowIndex++) {
        setupList(rowIndex);
        for (int colIndex = curCol; colIndex < curCol
                + (data.getColspan() != -1 ? data.getColspan() : 1); colIndex++) {
            cells.get(rowIndex).set(colIndex, true);
        }
    }

    if (data.getColspan() != 1) {
        td.setColSpan(data.getColspan());
    }

    if (data.getRowspan() != 1) {
        td.setRowSpan(data.getRowspan());
    }

    if (data.getPadding() > 0) {
        td.getStyle().setPropertyPx("padding", data.getPadding());
    } else if (cellPadding > 0) {
        td.getStyle().setPropertyPx("padding", cellPadding);
    }

    if (data.getStyleName() != null) {
        fly(td).addStyleName(data.getStyleName());
    }

    if (data.horizontalAlign != null) {
        td.setAlign(data.horizontalAlign.name());
    } else if (cellHorizontalAlign != null) {
        td.setAlign(cellHorizontalAlign.name());
    }

    if (data.verticalAlign != null) {
        td.setVAlign(data.verticalAlign.name());
    } else if (cellVerticalAlign != null) {
        td.setVAlign(cellVerticalAlign.name());
    }

    if (data.getHeight() != null) {
        td.setAttribute("height", data.getHeight());
    }
    if (data.getWidth() != null) {
        td.setAttribute("width", data.getWidth());
    }

    if (data.getStyle() != null) {
        fly(td).applyStyles(data.getStyle());
    }
    getRow(curRow).dom.appendChild(td);
    return td.cast();
}

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);/* ww  w .  j  av a 2 s  . 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.vaadin.client.widget.escalator.FlyweightCell.java

License:Apache License

void setup(final CellIterator iterator) {
    currentIterator = iterator;/*  w  w w .  ja v a 2s  . co m*/

    if (iterator.areCellsAttached()) {
        final TableCellElement e = row.getElement().getCells().getItem(column);

        assert e != null : "Cell " + column + " for logical row " + row.getRow() + " doesn't exist in the DOM!";

        e.setPropertyInt(COLSPAN_ATTR, 1);
        if (row.getColumnWidth(column) >= 0) {
            e.getStyle().setWidth(row.getColumnWidth(column), Unit.PX);
        }
        e.getStyle().clearDisplay();
        setElement(e);
    }
}

From source file:org.activityinfo.ui.client.widget.CellTableHeaderWidthApplier.java

License:Open Source License

private void setHeaderWidthInformation(boolean shouldAffix) {

    // header//  w w w  . j av a  2 s  .  com
    if (shouldAffix) {
        table.getTableHeadElement().getStyle().setWidth(headerWidth, Style.Unit.PX);
    } else {
        table.getTableHeadElement().getStyle().clearWidth();
    }

    final NodeList<TableRowElement> headerRows = table.getTableHeadElement().getRows();
    for (int i = 0; i < headerRows.getLength(); i++) {
        final TableRowElement row = headerRows.getItem(i);

        // rows
        if (shouldAffix) {
            row.getStyle().setWidth(headerRowToWidthMap.get(i), Style.Unit.PX);
        } else {
            row.getStyle().clearWidth();
        }

        // cells
        final NodeList<TableCellElement> cells = row.getCells();
        for (int j = 0; j < cells.getLength(); j++) {
            final TableCellElement cell = cells.getItem(j);

            if (shouldAffix) {
                cell.getStyle().setWidth(headerCellToWidthMap.get(new Pair<>(i, j)), Style.Unit.PX);
            } else {
                cell.getStyle().clearWidth();
            }
        }
    }
}

From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.templates.TemplateDataHeaderWidget.java

License:Apache License

private void setCursorType(Cursor cursor) {
    for (int iRow = 0; iRow < widget.headerRows.length; iRow++) {
        TableRowElement tre = widget.headerRows[iRow].<TableRowElement>cast();
        for (int iCol = 0; iCol < tre.getCells().getLength(); iCol++) {
            TableCellElement tce = tre.getCells().getItem(iCol);
            tce.getStyle().setCursor(cursor);
        }//from  w ww.j av a2s  .  c om
    }
}

From source file:org.drools.guvnor.client.decisiontable.widget.VerticalDecisionTableHeaderWidget.java

License:Apache License

private void setCursorType(Cursor cursor) {
    for (int iRow = 0; iRow < widget.rowHeaders.length; iRow++) {
        TableRowElement tre = widget.rowHeaders[iRow].<TableRowElement>cast();
        for (int iCol = 0; iCol < tre.getCells().getLength(); iCol++) {
            TableCellElement tce = tre.getCells().getItem(iCol);
            tce.getStyle().setCursor(cursor);
        }//from  www . j  a v a2  s  .co m
    }

}

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

License:Apache License

@Override
public void resizeColumn(DynamicColumn<?> col, int width) {
    if (col == null) {
        throw new IllegalArgumentException("col cannot be null");
    }/*w w w  . j a v  a2 s  .  co m*/
    if (width < 0) {
        throw new IllegalArgumentException("width cannot be less than zero");
    }

    col.setWidth(width);
    int iCol = col.getColumnIndex();
    for (DynamicDataRow row : data) {
        CellValue<? extends Comparable<?>> cell = row.get(iCol);
        Coordinate c = cell.getHtmlCoordinate();
        TableRowElement tre = tbody.getRows().getItem(c.getRow());
        TableCellElement tce = tre.getCells().getItem(c.getCol());
        DivElement div = tce.getFirstChild().<DivElement>cast();
        DivElement divText = tce.getFirstChild().getFirstChild().<DivElement>cast();

        // Set widths
        tce.getStyle().setWidth(width, Unit.PX);
        div.getStyle().setWidth(width, Unit.PX);
        divText.getStyle().setWidth(width, Unit.PX);
    }

}

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

License:Apache License

@SuppressWarnings("rawtypes")
private TableCellElement makeTableCellElement(int iCol, DynamicDataRow rowData) {

    TableCellElement tce = null;

    // Column to handle rendering
    DynamicColumn<?> column = columns.get(iCol);

    CellValue<? extends Comparable<?>> cellData = rowData.get(iCol);
    int rowSpan = cellData.getRowSpan();
    if (rowSpan > 0) {

        // Use Elements rather than Templates as it's easier to set attributes that need to be dynamic
        tce = Document.get().createTDElement();
        DivElement div = Document.get().createDivElement();
        DivElement divText = Document.get().createDivElement();
        tce.addClassName(style.cellTableCell());
        div.setClassName(style.cellTableCellDiv());
        divText.addClassName(style.cellTableTextDiv());

        // Set widths
        int colWidth = column.getWidth();
        div.getStyle().setWidth(colWidth, Unit.PX);
        divText.getStyle().setWidth(colWidth, Unit.PX);
        tce.getStyle().setWidth(colWidth, Unit.PX);

        // Set heights, TD includes border, DIV does not
        int divHeight = cellHeightCalculator.calculateHeight(rowSpan);
        div.getStyle().setHeight(divHeight, Unit.PX);
        tce.setRowSpan(rowSpan);/*  w w  w. j av a2s.com*/

        //Styling depending upon state
        if (cellData.isOtherwise()) {
            tce.addClassName(style.cellTableCellOtherwise());
        }
        if (cellData instanceof GroupedCellValue) {
            GroupedCellValue gcv = (GroupedCellValue) cellData;
            if (gcv.hasMultipleValues()) {
                tce.addClassName(style.cellTableCellMultipleValues());
            }
        }
        if (cellData.isSelected()) {
            tce.removeClassName(style.cellTableCellMultipleValues());
            tce.removeClassName(style.cellTableCellOtherwise());
            tce.addClassName(style.cellTableCellSelected());
        }

        // Render the cell and set inner HTML
        SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder();
        if (!cellData.isOtherwise()) {
            Coordinate c = cellData.getCoordinate();
            Context context = new Context(c.getRow(), c.getCol(), c);
            column.render(context, rowData, cellBuilder);
        } else {
            cellBuilder.appendEscaped("<otherwise>");
        }
        divText.setInnerHTML(cellBuilder.toSafeHtml().asString());

        // Construct the table
        tce.appendChild(div);
        div.appendChild(divText);
        tce.setTabIndex(0);

        //Add on "Grouping" widget, if applicable
        if (rowSpan > 1 || cellData.isGrouped()) {
            Element de = DOM.createDiv();
            DivElement divGroup = DivElement.as(de);
            divGroup.setTitle(messages.groupCells());
            divGroup.addClassName(style.cellTableGroupDiv());
            if (cellData.isGrouped()) {
                divGroup.setInnerHTML(selectorUngroupedCellsHtml);
            } else {
                divGroup.setInnerHTML(selectorGroupedCellsHtml);
            }
            div.appendChild(divGroup);
        }

    }
    return tce;

}

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

License:Apache License

@SuppressWarnings("rawtypes")
private TableCellElement makeTableCellElement(int iCol, DynamicDataRow rowData) {

    TableCellElement tce = null;

    // Column to handle rendering
    DynamicColumn<T> column = columns.get(iCol);

    CellValue<? extends Comparable<?>> cellData = rowData.get(iCol);
    int rowSpan = cellData.getRowSpan();
    if (rowSpan > 0) {

        // Use Elements rather than Templates as it's easier to set attributes that need to be dynamic
        tce = Document.get().createTDElement();
        DivElement div = Document.get().createDivElement();
        DivElement divText = Document.get().createDivElement();
        tce.addClassName(resources.cellTableCell());
        tce.addClassName(resources.cellTableColumn(column.getModelColumn()));
        div.setClassName(resources.cellTableCellDiv());
        divText.addClassName(resources.cellTableTextDiv());

        // Set widths
        int colWidth = column.getWidth();
        div.getStyle().setWidth(colWidth, Unit.PX);
        divText.getStyle().setWidth(colWidth, Unit.PX);
        tce.getStyle().setWidth(colWidth, Unit.PX);

        // Set heights, TD includes border, DIV does not
        int divHeight = cellHeightCalculator.calculateHeight(rowSpan);
        div.getStyle().setHeight(divHeight, Unit.PX);
        tce.setRowSpan(rowSpan);/*from w  w  w  .j a  va 2 s .  c o m*/

        //Styling depending upon state
        if (cellData.isOtherwise()) {
            tce.addClassName(resources.cellTableCellOtherwise());
        } else {
            tce.removeClassName(resources.cellTableCellOtherwise());
        }
        if (cellData instanceof GroupedCellValue) {
            GroupedCellValue gcv = (GroupedCellValue) cellData;
            if (gcv.hasMultipleValues()) {
                tce.addClassName(resources.cellTableCellMultipleValues());
            }
        } else {
            tce.removeClassName(resources.cellTableCellMultipleValues());
        }
        if (cellData.isSelected()) {
            tce.addClassName(resources.cellTableCellSelected());
        } else {
            tce.removeClassName(resources.cellTableCellSelected());
        }

        // Render the cell and set inner HTML
        SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder();
        if (!cellData.isOtherwise()) {
            Coordinate c = cellData.getCoordinate();
            Context context = new Context(c.getRow(), c.getCol(), c);
            column.render(context, rowData, cellBuilder);
        } else {
            cellBuilder.appendEscaped("<otherwise>");
        }
        divText.setInnerHTML(cellBuilder.toSafeHtml().asString());

        // Construct the table
        tce.appendChild(div);
        div.appendChild(divText);
        tce.setTabIndex(0);

        //Add on "Grouping" widget, if applicable
        if (rowSpan > 1 || cellData.isGrouped()) {
            Element de = DOM.createDiv();
            DivElement divGroup = DivElement.as(de);
            divGroup.setTitle(Constants.INSTANCE.groupCells());
            divGroup.addClassName(resources.cellTableGroupDiv());
            if (cellData.isGrouped()) {
                divGroup.setInnerHTML(selectorUngroupedCellsHtml);
            } else {
                divGroup.setInnerHTML(selectorGroupedCellsHtml);
            }
            div.appendChild(divGroup);
        }

    }
    return tce;

}

From source file:org.kie.guvnor.decoratedgrid.client.widget.AbstractVerticalMergableGridWidget.java

License:Apache License

@SuppressWarnings("rawtypes")
private TableCellElement makeTableCellElement(int iCol, DynamicDataRow rowData) {

    TableCellElement tce = null;

    // Column to handle rendering
    DynamicColumn<T> column = columns.get(iCol);

    CellValue<? extends Comparable<?>> cellData = rowData.get(iCol);
    int rowSpan = cellData.getRowSpan();
    if (rowSpan > 0) {

        // Use Elements rather than Templates as it's easier to set attributes that need to be dynamic
        tce = Document.get().createTDElement();
        DivElement div = Document.get().createDivElement();
        DivElement divText = Document.get().createDivElement();
        tce.addClassName(resources.cellTableCell());
        tce.addClassName(resources.cellTableColumn(column.getModelColumn()));
        div.setClassName(resources.cellTableCellDiv());
        divText.addClassName(resources.cellTableTextDiv());

        // Set widths
        int colWidth = column.getWidth();
        div.getStyle().setWidth(colWidth, Unit.PX);
        divText.getStyle().setWidth(colWidth, Unit.PX);
        tce.getStyle().setWidth(colWidth, Unit.PX);

        // Set heights, TD includes border, DIV does not
        int divHeight = cellHeightCalculator.calculateHeight(rowSpan);
        div.getStyle().setHeight(divHeight, Unit.PX);
        tce.setRowSpan(rowSpan);/*  w  w  w .ja  va2s . c o  m*/

        //Styling depending upon state
        if (cellData.isOtherwise()) {
            tce.addClassName(resources.cellTableCellOtherwise());
        } else {
            tce.removeClassName(resources.cellTableCellOtherwise());
        }
        if (cellData instanceof CellValue.GroupedCellValue) {
            CellValue.GroupedCellValue gcv = (CellValue.GroupedCellValue) cellData;
            if (gcv.hasMultipleValues()) {
                tce.addClassName(resources.cellTableCellMultipleValues());
            }
        } else {
            tce.removeClassName(resources.cellTableCellMultipleValues());
        }
        if (cellData.isSelected()) {
            tce.addClassName(resources.cellTableCellSelected());
        } else {
            tce.removeClassName(resources.cellTableCellSelected());
        }

        // Render the cell and set inner HTML
        SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder();
        if (!cellData.isOtherwise()) {
            Coordinate c = cellData.getCoordinate();
            Context context = new Context(c.getRow(), c.getCol(), c);
            column.render(context, rowData, cellBuilder);
        } else {
            cellBuilder.appendEscaped("<otherwise>");
        }
        divText.setInnerHTML(cellBuilder.toSafeHtml().asString());

        // Construct the table
        tce.appendChild(div);
        div.appendChild(divText);
        tce.setTabIndex(0);

        //Add on "Grouping" widget, if applicable
        if (rowSpan > 1 || cellData.isGrouped()) {
            Element de = DOM.createDiv();
            DivElement divGroup = DivElement.as(de);
            divGroup.setTitle(Constants.INSTANCE.groupCells());
            divGroup.addClassName(resources.cellTableGroupDiv());
            if (cellData.isGrouped()) {
                divGroup.setInnerHTML(selectorUngroupedCellsHtml);
            } else {
                divGroup.setInnerHTML(selectorGroupedCellsHtml);
            }
            div.appendChild(divGroup);
        }

    }
    return tce;

}