Search in sources :

Example 16 with TableCellElement

use of com.google.gwt.dom.client.TableCellElement in project cuba by cuba-platform.

the class TableAggregationRow method addCell.

protected void addCell(String text, char align, String style, boolean sorted) {
    final TableCellElement td = DOM.createTD().cast();
    final Element container = DOM.createDiv();
    container.setClassName(tableWidget.getStylePrimaryName() + "-cell-wrapper");
    td.setClassName(tableWidget.getStylePrimaryName() + "-cell-content");
    td.addClassName(tableWidget.getStylePrimaryName() + "-aggregation-cell");
    if (style != null && !style.equals("")) {
        td.addClassName(tableWidget.getStylePrimaryName() + "-cell-content-" + style);
    }
    if (sorted) {
        td.addClassName(tableWidget.getStylePrimaryName() + "-cell-content-sorted");
    }
    container.setInnerText(text);
    setAlign(align, container);
    td.appendChild(container);
    tr.appendChild(td);
    Tools.textSelectionEnable(td, tableWidget.isTextSelectionEnabled());
}
Also used : TableCellElement(com.google.gwt.dom.client.TableCellElement) Element(com.google.gwt.dom.client.Element) TableCellElement(com.google.gwt.dom.client.TableCellElement)

Example 17 with TableCellElement

use of com.google.gwt.dom.client.TableCellElement in project ovirt-engine by oVirt.

the class ColumnResizeCellTable method getHeaderCell.

private TableCellElement getHeaderCell(TableElement tableElement, int columnIndex) {
    TableSectionElement tHeadElement = tableElement.getTHead();
    if (tHeadElement == null) {
        return null;
    }
    List<TableCellElement> cells = getCells(tHeadElement.getRows(), columnIndex);
    return (cells.size() == 1) ? cells.get(0) : null;
}
Also used : TableSectionElement(com.google.gwt.dom.client.TableSectionElement) TableCellElement(com.google.gwt.dom.client.TableCellElement)

Example 18 with TableCellElement

use of com.google.gwt.dom.client.TableCellElement in project ovirt-engine by oVirt.

the class ColumnResizeCellTable method setColumnWidth.

public void setColumnWidth(Column<T, ?> column, String width, boolean overridePersist) {
    boolean columnVisible = isColumnVisible(column);
    if (columnVisible) {
        columnWidthMap.put(column, width);
    } else {
        width = HIDDEN_WIDTH;
    }
    // Update header cell visibility
    TableCellElement headerCell = getHeaderCell(getElement().cast(), getColumnIndex(column));
    if (headerCell != null) {
        headerCell.getStyle().setVisibility(columnVisible ? Visibility.VISIBLE : Visibility.HIDDEN);
    }
    // Prevent resizing of "hidden" (1px wide) columns
    if (columnResizingEnabled) {
        Header<?> header = getHeader(getColumnIndex(column));
        if (header instanceof ResizableHeader) {
            ((ResizableHeader<?>) header).setResizeEnabled(columnVisible);
        }
    }
    if (columnResizePersistenceEnabled && !overridePersist && columnVisible) {
        String persistedWidth = readColumnWidth(column);
        if (persistedWidth != null) {
            width = persistedWidth;
        }
    }
    super.setColumnWidth(column, width);
    column.setCellStyleNames(columnVisible ? GRID_VISIBLE : GRID_HIDDEN);
    int index = getColumnIndex(column);
    if (index >= 0) {
        removeColumnStyleName(index, columnVisible ? GRID_HIDDEN : GRID_VISIBLE);
        addColumnStyleName(index, columnVisible ? GRID_VISIBLE : GRID_HIDDEN);
    }
    redraw();
}
Also used : ResizableHeader(org.ovirt.engine.ui.common.widget.table.header.ResizableHeader) TableCellElement(com.google.gwt.dom.client.TableCellElement)

Example 19 with TableCellElement

use of com.google.gwt.dom.client.TableCellElement in project cuba by cuba-platform.

the class CubaTreeRendererConnector method createRenderer.

@Override
public Renderer<String> createRenderer() {
    return new HtmlRenderer() {

        @Override
        public void render(RendererCellReference cell, String htmlString) {
            String content = getContentString(htmlString);
            Element icon = getIconElement(cell);
            Element span = findSpan(cell);
            if (span == null) {
                _render(cell, content, icon);
            } else {
                String oldContent = span.getInnerHTML();
                if (!Objects.equals(content, oldContent)) {
                    _render(cell, content, icon);
                }
            }
        }

        protected Element findSpan(RendererCellReference cell) {
            TableCellElement cellEl = cell.getElement();
            int childCount = DOM.getChildCount(cellEl);
            for (int i = 0; i < childCount; i++) {
                Element child = DOM.getChild(cellEl, i);
                if (SpanElement.TAG.equalsIgnoreCase(child.getTagName())) {
                    return child;
                }
            }
            return null;
        }

        protected Element getIconElement(RendererCellReference cell) {
            Element iconEl = null;
            JsonObject row = getParent().getParent().getDataSource().getRow(cell.getRowIndex());
            if (row != null && row.hasKey(ITEM_ICON)) {
                String resourceUrl = getResourceUrl(row.getString(ITEM_ICON));
                iconEl = getConnection().getIcon(resourceUrl).getElement();
            }
            return iconEl;
        }

        protected void _render(RendererCellReference cell, String content, @Nullable Element icon) {
            Element span = DOM.createSpan();
            span.addClassName(V_CAPTIONTEXT_STYLENAME);
            span.setInnerSafeHtml(SafeHtmlUtils.fromSafeConstant(content));
            TableCellElement cellEl = cell.getElement();
            cellEl.removeAllChildren();
            if (icon != null) {
                cellEl.appendChild(icon);
            }
            cellEl.appendChild(span);
        }

        private String getContentString(String htmlString) {
            switch(getState().mode) {
                case HTML:
                    return htmlString;
                case PREFORMATTED:
                    return "<pre>" + SafeHtmlUtils.htmlEscape(htmlString) + "</pre>";
                default:
                    return SafeHtmlUtils.htmlEscape(htmlString);
            }
        }
    };
}
Also used : Element(com.google.gwt.user.client.Element) TableCellElement(com.google.gwt.dom.client.TableCellElement) SpanElement(com.google.gwt.dom.client.SpanElement) RendererCellReference(com.vaadin.client.widget.grid.RendererCellReference) HtmlRenderer(com.vaadin.client.renderers.HtmlRenderer) JsonObject(elemental.json.JsonObject) TableCellElement(com.google.gwt.dom.client.TableCellElement) Nullable(javax.annotation.Nullable)

Example 20 with TableCellElement

use of com.google.gwt.dom.client.TableCellElement in project kie-wb-common by kiegroup.

the class AbstractMergableGridWidget method getSelectedCellExtents.

/**
 * Retrieve the extents of a cell
 * @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;
}
Also used : Coordinate(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate) TableRowElement(com.google.gwt.dom.client.TableRowElement) TableCellElement(com.google.gwt.dom.client.TableCellElement)

Aggregations

TableCellElement (com.google.gwt.dom.client.TableCellElement)26 TableRowElement (com.google.gwt.dom.client.TableRowElement)16 Coordinate (org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate)8 DivElement (com.google.gwt.dom.client.DivElement)4 Element (com.google.gwt.dom.client.Element)4 TableSectionElement (com.google.gwt.dom.client.TableSectionElement)4 DynamicDataRow (org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow)3 Context (com.google.gwt.cell.client.Cell.Context)2 EventTarget (com.google.gwt.dom.client.EventTarget)2 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)2 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)2 Test (org.junit.Test)2 GWT (com.google.gwt.core.client.GWT)1 NativeEvent (com.google.gwt.dom.client.NativeEvent)1 SpanElement (com.google.gwt.dom.client.SpanElement)1 TableElement (com.google.gwt.dom.client.TableElement)1 Request (com.google.gwt.http.client.Request)1 RequestCallback (com.google.gwt.http.client.RequestCallback)1 Response (com.google.gwt.http.client.Response)1 DateTimeFormat (com.google.gwt.i18n.client.DateTimeFormat)1