Java Code Examples for com.gargoylesoftware.htmlunit.html.HtmlTableRow#getCells()

The following examples show how to use com.gargoylesoftware.htmlunit.html.HtmlTableRow#getCells() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropertyTable.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
/**
 * Creates a new instance of {@link PropertyTable}.
 *
 * @param page
 *         the whole details HTML page
 * @param property
 *         the property tab to extract
 */
@SuppressFBWarnings("BC")
public PropertyTable(final HtmlPage page, final String property) {
    super(page);

    title = getTitleOfTable(page, property);

    DomElement propertyElement = page.getElementById(property);
    assertThat(propertyElement).isInstanceOf(HtmlTable.class);

    HtmlTable table = (HtmlTable) propertyElement;
    List<HtmlTableRow> tableHeaderRows = table.getHeader().getRows();
    assertThat(tableHeaderRows).hasSize(1);

    HtmlTableRow header = tableHeaderRows.get(0);
    List<HtmlTableCell> cells = header.getCells();
    assertThat(cells).hasSize(3);

    propertyName = cells.get(0).getTextContent();
    assertThat(cells.get(1).getTextContent()).isEqualTo("Total");
    assertThat(cells.get(2).getTextContent()).isEqualTo("Distribution");

    List<HtmlTableBody> bodies = table.getBodies();
    assertThat(bodies).hasSize(1);
    List<HtmlTableRow> contentRows = bodies.get(0).getRows();

    for (HtmlTableRow row : contentRows) {
        List<HtmlTableCell> rowCells = row.getCells();
        rows.add(new PropertyRow(rowCells));
    }
}
 
Example 2
Source File: HTMLTableRowElement.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the cells in the row.
 * @return the cells in the row
 */
@JsxGetter
public Object getCells() {
    final HtmlTableRow row = (HtmlTableRow) getDomNodeOrDie();
    return new HTMLCollection(row, false) {
        @Override
        protected List<DomNode> computeElements() {
            return new ArrayList<>(row.getCells());
        }
    };
}
 
Example 3
Source File: HTMLTableCellElement.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public int getOffsetWidth() {
    float w = super.getOffsetWidth();
    final MouseEvent event = MouseEvent.getCurrentMouseEvent();
    if (isAncestorOfEventTarget(event)) {
        return (int) w;
    }

    if (isDisplayNone()) {
        return 0;
    }

    final ComputedCSSStyleDeclaration style = getWindow().getComputedStyle(this, null);
    if ("collapse".equals(style.getStyleAttribute(StyleAttributes.Definition.BORDER_COLLAPSE))) {
        final HtmlTableRow row = getRow();
        if (row != null) {
            final HtmlElement thiz = getDomNodeOrDie();
            final List<HtmlTableCell> cells = row.getCells();
            final boolean ie = getBrowserVersion().hasFeature(JS_TABLE_CELL_OFFSET_INCLUDES_BORDER);
            final boolean leftmost = cells.indexOf(thiz) == 0;
            final boolean rightmost = cells.indexOf(thiz) == cells.size() - 1;
            w -= (ie && leftmost ? 0 : 0.5) * style.getBorderLeftValue();
            w -= (ie && rightmost ? 0 : 0.5) * style.getBorderRightValue();
        }
    }

    return (int) w;
}
 
Example 4
Source File: HTMLTableRowElement.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the cells in the row.
 * @return the cells in the row
 */
@JsxGetter
public Object getCells() {
    final HtmlTableRow row = (HtmlTableRow) getDomNodeOrDie();
    return new HTMLCollection(row, false) {
        @Override
        protected List<DomNode> computeElements() {
            return new ArrayList<DomNode>(row.getCells());
        }
    };
}
 
Example 5
Source File: HTMLTableCellElement.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public int getOffsetWidth() {
    float w = super.getOffsetWidth();
    final MouseEvent event = MouseEvent.getCurrentMouseEvent();
    if (isAncestorOfEventTarget(event)) {
        return (int) w;
    }

    if (isDisplayNone()) {
        return 0;
    }

    final ComputedCSSStyleDeclaration style = getWindow().getComputedStyle(this, null);
    if ("collapse".equals(style.getStyleAttribute(StyleAttributes.Definition.BORDER_COLLAPSE))) {
        final HtmlTableRow row = getRow();
        if (row != null) {
            final HtmlElement thiz = getDomNodeOrDie();
            final List<HtmlTableCell> cells = row.getCells();
            final boolean ie = getBrowserVersion().hasFeature(JS_TABLE_CELL_OFFSET_INCLUDES_BORDER);
            final boolean leftmost = cells.indexOf(thiz) == 0;
            final boolean rightmost = cells.indexOf(thiz) == cells.size() - 1;
            w -= (ie && leftmost ? 0 : 0.5) * style.getBorderLeftValue();
            w -= (ie && rightmost ? 0 : 0.5) * style.getBorderRightValue();
        }
    }

    return (int) w;
}