List of usage examples for com.google.gwt.dom.client TableCellElement setRowSpan
public void setRowSpan(int rowSpan)
From source file:com.extjs.gxt.ui.client.widget.layout.TableLayout.java
License:sencha.com license
protected Element getNextCell(Component widget) { if (cells == null) { cells = new ArrayList<List<Boolean>>(); }/* w w w .j av a 2 s . c o m*/ TableData data = (TableData) getLayoutData(widget); if (data == null) { data = new TableData(); setLayoutData(widget, data); } TableCellElement td = DOM.createTD().cast(); td.setClassName("x-table-layout-cell"); td.setAttribute("role", "presentation"); int[] cell = getNextNonSpan(currentColumn, currentRow); int curCol = currentColumn = cell[0]; int curRow = currentRow = cell[1]; for (int rowIndex = curRow; rowIndex < curRow + (data.getRowspan() != -1 ? data.getRowspan() : 1); rowIndex++) { setupList(rowIndex); for (int colIndex = curCol; colIndex < curCol + (data.getColspan() != -1 ? data.getColspan() : 1); colIndex++) { cells.get(rowIndex).set(colIndex, true); } } if (data.getColspan() != 1) { td.setColSpan(data.getColspan()); } if (data.getRowspan() != 1) { td.setRowSpan(data.getRowspan()); } if (data.getPadding() > 0) { td.getStyle().setPropertyPx("padding", data.getPadding()); } else if (cellPadding > 0) { td.getStyle().setPropertyPx("padding", cellPadding); } if (data.getStyleName() != null) { fly(td).addStyleName(data.getStyleName()); } if (data.horizontalAlign != null) { td.setAlign(data.horizontalAlign.name()); } else if (cellHorizontalAlign != null) { td.setAlign(cellHorizontalAlign.name()); } if (data.verticalAlign != null) { td.setVAlign(data.verticalAlign.name()); } else if (cellVerticalAlign != null) { td.setVAlign(cellVerticalAlign.name()); } if (data.getHeight() != null) { td.setAttribute("height", data.getHeight()); } if (data.getWidth() != null) { td.setAttribute("width", data.getWidth()); } if (data.getStyle() != null) { fly(td).applyStyles(data.getStyle()); } getRow(curRow).dom.appendChild(td); return td.cast(); }
From source file:org.drools.guvnor.client.widgets.decoratedgrid.VerticalMergableGridWidget.java
License:Apache License
@SuppressWarnings("rawtypes") private TableCellElement makeTableCellElement(int iCol, DynamicDataRow rowData) { TableCellElement tce = null; // Column to handle rendering DynamicColumn<?> column = columns.get(iCol); CellValue<? extends Comparable<?>> cellData = rowData.get(iCol); int rowSpan = cellData.getRowSpan(); if (rowSpan > 0) { // Use Elements rather than Templates as it's easier to set attributes that need to be dynamic tce = Document.get().createTDElement(); DivElement div = Document.get().createDivElement(); DivElement divText = Document.get().createDivElement(); tce.addClassName(style.cellTableCell()); div.setClassName(style.cellTableCellDiv()); divText.addClassName(style.cellTableTextDiv()); // Set widths int colWidth = column.getWidth(); div.getStyle().setWidth(colWidth, Unit.PX); divText.getStyle().setWidth(colWidth, Unit.PX); tce.getStyle().setWidth(colWidth, Unit.PX); // Set heights, TD includes border, DIV does not int divHeight = cellHeightCalculator.calculateHeight(rowSpan); div.getStyle().setHeight(divHeight, Unit.PX); tce.setRowSpan(rowSpan); //Styling depending upon state if (cellData.isOtherwise()) { tce.addClassName(style.cellTableCellOtherwise()); }// w ww . jav a 2s.co m if (cellData instanceof GroupedCellValue) { GroupedCellValue gcv = (GroupedCellValue) cellData; if (gcv.hasMultipleValues()) { tce.addClassName(style.cellTableCellMultipleValues()); } } if (cellData.isSelected()) { tce.removeClassName(style.cellTableCellMultipleValues()); tce.removeClassName(style.cellTableCellOtherwise()); tce.addClassName(style.cellTableCellSelected()); } // Render the cell and set inner HTML SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder(); if (!cellData.isOtherwise()) { Coordinate c = cellData.getCoordinate(); Context context = new Context(c.getRow(), c.getCol(), c); column.render(context, rowData, cellBuilder); } else { cellBuilder.appendEscaped("<otherwise>"); } divText.setInnerHTML(cellBuilder.toSafeHtml().asString()); // Construct the table tce.appendChild(div); div.appendChild(divText); tce.setTabIndex(0); //Add on "Grouping" widget, if applicable if (rowSpan > 1 || cellData.isGrouped()) { Element de = DOM.createDiv(); DivElement divGroup = DivElement.as(de); divGroup.setTitle(messages.groupCells()); divGroup.addClassName(style.cellTableGroupDiv()); if (cellData.isGrouped()) { divGroup.setInnerHTML(selectorUngroupedCellsHtml); } else { divGroup.setInnerHTML(selectorGroupedCellsHtml); } div.appendChild(divGroup); } } return tce; }
From source file:org.drools.guvnor.client.widgets.drools.decoratedgrid.AbstractVerticalMergableGridWidget.java
License:Apache License
@SuppressWarnings("rawtypes") private TableCellElement makeTableCellElement(int iCol, DynamicDataRow rowData) { TableCellElement tce = null; // Column to handle rendering DynamicColumn<T> column = columns.get(iCol); CellValue<? extends Comparable<?>> cellData = rowData.get(iCol); int rowSpan = cellData.getRowSpan(); if (rowSpan > 0) { // Use Elements rather than Templates as it's easier to set attributes that need to be dynamic tce = Document.get().createTDElement(); DivElement div = Document.get().createDivElement(); DivElement divText = Document.get().createDivElement(); tce.addClassName(resources.cellTableCell()); tce.addClassName(resources.cellTableColumn(column.getModelColumn())); div.setClassName(resources.cellTableCellDiv()); divText.addClassName(resources.cellTableTextDiv()); // Set widths int colWidth = column.getWidth(); div.getStyle().setWidth(colWidth, Unit.PX); divText.getStyle().setWidth(colWidth, Unit.PX); tce.getStyle().setWidth(colWidth, Unit.PX); // Set heights, TD includes border, DIV does not int divHeight = cellHeightCalculator.calculateHeight(rowSpan); div.getStyle().setHeight(divHeight, Unit.PX); tce.setRowSpan(rowSpan); //Styling depending upon state if (cellData.isOtherwise()) { tce.addClassName(resources.cellTableCellOtherwise()); } else {//from w w w .j a v a 2s . c o m tce.removeClassName(resources.cellTableCellOtherwise()); } if (cellData instanceof GroupedCellValue) { GroupedCellValue gcv = (GroupedCellValue) cellData; if (gcv.hasMultipleValues()) { tce.addClassName(resources.cellTableCellMultipleValues()); } } else { tce.removeClassName(resources.cellTableCellMultipleValues()); } if (cellData.isSelected()) { tce.addClassName(resources.cellTableCellSelected()); } else { tce.removeClassName(resources.cellTableCellSelected()); } // Render the cell and set inner HTML SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder(); if (!cellData.isOtherwise()) { Coordinate c = cellData.getCoordinate(); Context context = new Context(c.getRow(), c.getCol(), c); column.render(context, rowData, cellBuilder); } else { cellBuilder.appendEscaped("<otherwise>"); } divText.setInnerHTML(cellBuilder.toSafeHtml().asString()); // Construct the table tce.appendChild(div); div.appendChild(divText); tce.setTabIndex(0); //Add on "Grouping" widget, if applicable if (rowSpan > 1 || cellData.isGrouped()) { Element de = DOM.createDiv(); DivElement divGroup = DivElement.as(de); divGroup.setTitle(Constants.INSTANCE.groupCells()); divGroup.addClassName(resources.cellTableGroupDiv()); if (cellData.isGrouped()) { divGroup.setInnerHTML(selectorUngroupedCellsHtml); } else { divGroup.setInnerHTML(selectorGroupedCellsHtml); } div.appendChild(divGroup); } } return tce; }
From source file:org.kie.guvnor.decoratedgrid.client.widget.AbstractVerticalMergableGridWidget.java
License:Apache License
@SuppressWarnings("rawtypes") private TableCellElement makeTableCellElement(int iCol, DynamicDataRow rowData) { TableCellElement tce = null; // Column to handle rendering DynamicColumn<T> column = columns.get(iCol); CellValue<? extends Comparable<?>> cellData = rowData.get(iCol); int rowSpan = cellData.getRowSpan(); if (rowSpan > 0) { // Use Elements rather than Templates as it's easier to set attributes that need to be dynamic tce = Document.get().createTDElement(); DivElement div = Document.get().createDivElement(); DivElement divText = Document.get().createDivElement(); tce.addClassName(resources.cellTableCell()); tce.addClassName(resources.cellTableColumn(column.getModelColumn())); div.setClassName(resources.cellTableCellDiv()); divText.addClassName(resources.cellTableTextDiv()); // Set widths int colWidth = column.getWidth(); div.getStyle().setWidth(colWidth, Unit.PX); divText.getStyle().setWidth(colWidth, Unit.PX); tce.getStyle().setWidth(colWidth, Unit.PX); // Set heights, TD includes border, DIV does not int divHeight = cellHeightCalculator.calculateHeight(rowSpan); div.getStyle().setHeight(divHeight, Unit.PX); tce.setRowSpan(rowSpan); //Styling depending upon state if (cellData.isOtherwise()) { tce.addClassName(resources.cellTableCellOtherwise()); } else {/*from ww w . j a v a2 s .c om*/ tce.removeClassName(resources.cellTableCellOtherwise()); } if (cellData instanceof CellValue.GroupedCellValue) { CellValue.GroupedCellValue gcv = (CellValue.GroupedCellValue) cellData; if (gcv.hasMultipleValues()) { tce.addClassName(resources.cellTableCellMultipleValues()); } } else { tce.removeClassName(resources.cellTableCellMultipleValues()); } if (cellData.isSelected()) { tce.addClassName(resources.cellTableCellSelected()); } else { tce.removeClassName(resources.cellTableCellSelected()); } // Render the cell and set inner HTML SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder(); if (!cellData.isOtherwise()) { Coordinate c = cellData.getCoordinate(); Context context = new Context(c.getRow(), c.getCol(), c); column.render(context, rowData, cellBuilder); } else { cellBuilder.appendEscaped("<otherwise>"); } divText.setInnerHTML(cellBuilder.toSafeHtml().asString()); // Construct the table tce.appendChild(div); div.appendChild(divText); tce.setTabIndex(0); //Add on "Grouping" widget, if applicable if (rowSpan > 1 || cellData.isGrouped()) { Element de = DOM.createDiv(); DivElement divGroup = DivElement.as(de); divGroup.setTitle(Constants.INSTANCE.groupCells()); divGroup.addClassName(resources.cellTableGroupDiv()); if (cellData.isGrouped()) { divGroup.setInnerHTML(selectorUngroupedCellsHtml); } else { divGroup.setInnerHTML(selectorGroupedCellsHtml); } div.appendChild(divGroup); } } return tce; }