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());
}
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;
}
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();
}
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);
}
}
};
}
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;
}
Aggregations