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

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

Introduction

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

Prototype

@Override
    public int getOffsetWidth() 

Source Link

Usage

From source file:com.vaadin.client.ui.VTabsheet.java

License:Apache License

/** For internal use only. May be removed or replaced in the future. */
public void updateDynamicWidth() {
    // Find width consumed by tabs
    TableCellElement spacerCell = ((TableElement) tb.getElement().cast()).getRows().getItem(0).getCells()
            .getItem(tb.getTabCount());//w w w .  jav  a2  s  .co m

    int spacerWidth = spacerCell.getOffsetWidth();
    DivElement div = (DivElement) spacerCell.getFirstChildElement();

    int spacerMinWidth = spacerCell.getOffsetWidth() - div.getOffsetWidth();

    int tabsWidth = tb.getOffsetWidth() - spacerWidth + spacerMinWidth;

    // Find content width
    Style style = tabPanel.getElement().getStyle();
    String overflow = style.getProperty("overflow");
    style.setProperty("overflow", "hidden");
    style.setPropertyPx("width", tabsWidth);

    boolean hasTabs = tabPanel.getWidgetCount() > 0;

    Style wrapperstyle = null;
    if (hasTabs) {
        wrapperstyle = getCurrentlyDisplayedWidget().getElement().getParentElement().getStyle();
        wrapperstyle.setPropertyPx("width", tabsWidth);
    }
    // Get content width from actual widget

    int contentWidth = 0;
    if (hasTabs) {
        contentWidth = getCurrentlyDisplayedWidget().getOffsetWidth();
    }
    style.setProperty("overflow", overflow);

    // Set widths to max(tabs,content)
    if (tabsWidth < contentWidth) {
        tabsWidth = contentWidth;
    }

    int outerWidth = tabsWidth + getContentAreaBorderWidth();

    tabs.getStyle().setPropertyPx("width", outerWidth);
    style.setPropertyPx("width", tabsWidth);
    if (hasTabs) {
        wrapperstyle.setPropertyPx("width", tabsWidth);
    }

    contentNode.getStyle().setPropertyPx("width", tabsWidth);
    super.setWidth(outerWidth + "px");
    updateOpenTabSize();
}

From source file:com.vaadin.terminal.gwt.client.ui.VTabsheet.java

License:Open Source License

private void updateDynamicWidth() {
    // Find width consumed by tabs
    TableCellElement spacerCell = ((TableElement) tb.getElement().cast()).getRows().getItem(0).getCells()
            .getItem(tb.getTabCount());//ww  w .j  a  va  2s  . co m

    int spacerWidth = spacerCell.getOffsetWidth();
    DivElement div = (DivElement) spacerCell.getFirstChildElement();

    int spacerMinWidth = spacerCell.getOffsetWidth() - div.getOffsetWidth();

    int tabsWidth = tb.getOffsetWidth() - spacerWidth + spacerMinWidth;

    // Find content width
    Style style = tp.getElement().getStyle();
    String overflow = style.getProperty("overflow");
    style.setProperty("overflow", "hidden");
    style.setPropertyPx("width", tabsWidth);

    boolean hasTabs = tp.getWidgetCount() > 0;

    Style wrapperstyle = null;
    if (hasTabs) {
        wrapperstyle = tp.getWidget(tp.getVisibleWidget()).getElement().getParentElement().getStyle();
        wrapperstyle.setPropertyPx("width", tabsWidth);
    }
    // Get content width from actual widget

    int contentWidth = 0;
    if (hasTabs) {
        contentWidth = tp.getWidget(tp.getVisibleWidget()).getOffsetWidth();
    }
    style.setProperty("overflow", overflow);

    // Set widths to max(tabs,content)
    if (tabsWidth < contentWidth) {
        tabsWidth = contentWidth;
    }

    int outerWidth = tabsWidth + getContentAreaBorderWidth();

    tabs.getStyle().setPropertyPx("width", outerWidth);
    style.setPropertyPx("width", tabsWidth);
    if (hasTabs) {
        wrapperstyle.setPropertyPx("width", tabsWidth);
    }

    contentNode.getStyle().setPropertyPx("width", tabsWidth);
    super.setWidth(outerWidth + "px");
    updateOpenTabSize();
}

From source file:org.activityinfo.ui.client.component.table.filter.FilterCellAction.java

License:Open Source License

@Override
public void execute(Object object) {
    final CellTable<Projection> grid = table.getTable();
    final TableSectionElement tableHeadElement = grid.getTableHeadElement();
    final FilterPanel filterPanel = new FilterPanel(table, column);
    filterPanel.show(new PopupPanel.PositionCallback() {
        @Override/*from  w ww  . j a  v  a  2  s .co  m*/
        public void setPosition(int offsetWidth, int offsetHeight) {
            // get second row (first row is header action row)
            final TableRowElement row = tableHeadElement.getRows().getItem(1);
            final int columnIndex = grid.getColumnIndex(column);
            final TableCellElement cellElement = row.getCells().getItem(columnIndex);
            final int absoluteTop = cellElement.getAbsoluteTop();
            final int absoluteLeft = cellElement.getAbsoluteLeft();
            final int height = cellElement.getOffsetHeight();
            final int width = cellElement.getOffsetWidth();

            filterPanel.getPopup().setWidth(width + "px");
            filterPanel.getPopup().setPopupPosition(absoluteLeft, absoluteTop + height);
        }
    });
}

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

License:Open Source License

public void saveHeaderWidthInformation() {
    headerWidth = table.getTableHeadElement().getOffsetWidth();
    final NodeList<TableRowElement> headerRows = table.getTableHeadElement().getRows();
    for (int i = 0; i < headerRows.getLength(); i++) {
        final TableRowElement row = headerRows.getItem(i);
        headerRowToWidthMap.put(i, row.getOffsetWidth());

        final NodeList<TableCellElement> cells = row.getCells();
        for (int j = 0; j < cells.getLength(); j++) {
            final TableCellElement cell = cells.getItem(j);
            headerCellToWidthMap.put(new Pair<>(i, j), cell.getOffsetWidth());
        }/*from w ww. j av  a  2  s .com*/
    }
}

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

License:Apache License

/**
 * Retrieve the extents of a cell/*from  ww  w .  j av  a 2 s  . c o m*/
 * 
 * @param cv
 *            The cell for which to retrieve the extents
 * @return
 */
CellSelectionDetail getSelectedCellExtents(CellValue<? extends Comparable<?>> cv) {

    if (cv == null) {
        throw new IllegalArgumentException("cv cannot be null");
    }

    // Cells in hidden columns do not have extents
    if (!columns.get(cv.getCoordinate().getCol()).isVisible()) {
        return null;
    }

    Coordinate hc = cv.getHtmlCoordinate();
    TableRowElement tre = tbody.getRows().getItem(hc.getRow()).<TableRowElement>cast();
    TableCellElement tce = tre.getCells().getItem(hc.getCol()).<TableCellElement>cast();
    int offsetX = tce.getOffsetLeft();
    int offsetY = tce.getOffsetTop();
    int w = tce.getOffsetWidth();
    int h = tce.getOffsetHeight();
    CellSelectionDetail e = new CellSelectionDetail(cv.getCoordinate(), offsetX, offsetY, h, w);
    return e;
}