Java Code Examples for com.google.gwt.dom.client.Style.setMarginRight()

The following are Jave code examples for showing how to use setMarginRight() of the com.google.gwt.dom.client.Style class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: cuba   File: TableAggregationRow.java   Source Code and License Vote up 6 votes
public void setCellWidth(int cellIx, int width) {
    // CAUTION: copied from VScrollTableRow with small changes
    final Element cell = DOM.getChild(tr, cellIx);
    Style wrapperStyle = cell.getFirstChildElement().getStyle();
    int wrapperWidth = width;
    if (BrowserInfo.get().isWebkit()
            || BrowserInfo.get().isOpera10()) {
                /*
                 * Some versions of Webkit and Opera ignore the width
                 * definition of zero width table cells. Instead, use 1px
                 * and compensate with a negative margin.
                 */
        if (width == 0) {
            wrapperWidth = 1;
            wrapperStyle.setMarginRight(-1, Style.Unit.PX);
        } else {
            wrapperStyle.clearMarginRight();
        }
    }
    wrapperStyle.setPropertyPx("width", wrapperWidth);
    cell.getStyle().setPropertyPx("width", width);
}
 
Example 2
Project: cuba   File: CubaGroupTableWidget.java   Source Code and License Vote up 4 votes
private void calcAndSetWidthForSpannedCell() {
    final int cells = tHead.getVisibleCellCount();
    for (int i = 0; i < groupColIndex; i++) {
        int w = CubaGroupTableWidget.this.getColWidth(getColKeyByIndex(i));
        if (w < 0) {
            w = 0;
        }
        super.setCellWidth(i, w);
    }

    Element tr = getElement();

    int totalSpannedWidth = 0;
    for (int i = groupColIndex; i < cells; i++) {
        HeaderCell headerCell = tHead.getHeaderCell(i);

        int headerWidth = headerCell.getOffsetWidth() > headerCell.getWidth() + MAX_ROUNDING_DIFF ?
                headerCell.getWidth() : headerCell.getOffsetWidth();

        totalSpannedWidth += headerWidth;
    }

    Element td = DOM.getChild(tr, DOM.getChildCount(tr) - 1);

    Style wrapperStyle = td.getFirstChildElement().getStyle();
    WidgetUtil.setWidthExcludingPaddingAndBorder(td, totalSpannedWidth, 13, false);

    int wrapperWidth;
    ComputedStyle style = new ComputedStyle(td);
    if (style.getPaddingWidth() > 1.0) {
        // this is applied for havana theme, because it has vertical padding
        // for cell-container and width of TD element must be less, then whole row
        String tdWidthPx = td.getStyle().getWidth().replace("px", "");
        wrapperWidth = Integer.parseInt(tdWidthPx);
    } else {
        // this is applied for halo theme, because it hasn't vertical padding
        // for cell-container and width of TD element must be equal to whole row - 1px
        // 1px is the padding-left of :first-child
        wrapperWidth = totalSpannedWidth - 1;
    }

    if (BrowserInfo.get().isWebkit()
            || BrowserInfo.get().isOpera10()) {
                /*
                 * Some versions of Webkit and Opera ignore the width
                 * definition of zero width table cells. Instead, use 1px
                 * and compensate with a negative margin.
                 */
        if (totalSpannedWidth == 0) {
            wrapperWidth = 1;
            wrapperStyle.setMarginRight(-1, Style.Unit.PX);
        } else {
            wrapperStyle.clearMarginRight();
        }
    }

    if (BrowserInfo.get().isChrome()) {
        if (groupColIndex == groupColumns.size() - 1) {
            wrapperWidth -= groupColIndex * 2;
        }
        wrapperWidth++;
    }

    wrapperStyle.setPropertyPx("width", wrapperWidth);
}