List of usage examples for com.google.gwt.dom.client TableCellElement removeClassName
@Override
public boolean removeClassName(String className)
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);// w w w. ja v a 2 s. co m //Styling depending upon state if (cellData.isOtherwise()) { tce.addClassName(style.cellTableCellOtherwise()); } 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.decoratedgrid.VerticalMergableGridWidget.java
License:Apache License
@Override
@SuppressWarnings({ "rawtypes" })
void deselectCell(CellValue<? extends Comparable<?>> cell) {
if (cell == null) {
throw new IllegalArgumentException("cell cannot be null");
}//from ww w. j av a 2s . co m
Coordinate hc = cell.getHtmlCoordinate();
TableRowElement tre = tbody.getRows().getItem(hc.getRow()).<TableRowElement>cast();
TableCellElement tce = tre.getCells().getItem(hc.getCol()).<TableCellElement>cast();
//Merging, grouping etc could have led to the selected HTML cell disappearing
if (tce != null) {
String cellSelectedStyle = style.cellTableCellSelected();
String cellMultipleValuesStyle = style.cellTableCellMultipleValues();
String cellOtherwiseStyle = style.cellTableCellOtherwise();
tce.removeClassName(cellSelectedStyle);
//Re-apply applicable styling
if (cell.isOtherwise()) {
tce.addClassName(cellOtherwiseStyle);
}
if (cell instanceof GroupedCellValue) {
GroupedCellValue gcv = (GroupedCellValue) cell;
if (gcv.hasMultipleValues()) {
tce.addClassName(cellMultipleValuesStyle);
}
}
}
}
From source file:org.drools.guvnor.client.widgets.decoratedgrid.VerticalMergableGridWidget.java
License:Apache License
@Override void selectCell(CellValue<? extends Comparable<?>> cell) { if (cell == null) { throw new IllegalArgumentException("cell cannot be null"); }/*from w ww .j ava 2 s .c o m*/ Coordinate hc = cell.getHtmlCoordinate(); TableRowElement tre = tbody.getRows().getItem(hc.getRow()).<TableRowElement>cast(); TableCellElement tce = tre.getCells().getItem(hc.getCol()).<TableCellElement>cast(); //Cell selected style takes precedence String cellSelectedStyle = style.cellTableCellSelected(); String cellOtherwiseStyle = style.cellTableCellOtherwise(); String cellMultipleValuesStyle = style.cellTableCellMultipleValues(); tce.removeClassName(cellMultipleValuesStyle); tce.removeClassName(cellOtherwiseStyle); tce.addClassName(cellSelectedStyle); tce.focus(); }
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);//from w ww . j a v a2 s .co m //Styling depending upon state if (cellData.isOtherwise()) { tce.addClassName(resources.cellTableCellOtherwise()); } else { 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.drools.guvnor.client.widgets.drools.decoratedgrid.AbstractVerticalMergableGridWidget.java
License:Apache License
@Override
@SuppressWarnings({ "rawtypes" })
void deselectCell(CellValue<? extends Comparable<?>> cell) {
if (cell == null) {
throw new IllegalArgumentException("cell cannot be null");
}//from w w w . j a va2 s. c o m
Coordinate hc = cell.getHtmlCoordinate();
TableRowElement tre = tbody.getRows().getItem(hc.getRow()).<TableRowElement>cast();
TableCellElement tce = tre.getCells().getItem(hc.getCol()).<TableCellElement>cast();
//Merging, grouping etc could have led to the selected HTML cell disappearing
if (tce != null) {
String cellSelectedStyle = resources.cellTableCellSelected();
String cellMultipleValuesStyle = resources.cellTableCellMultipleValues();
String cellOtherwiseStyle = resources.cellTableCellOtherwise();
tce.removeClassName(cellSelectedStyle);
//Re-apply applicable styling
if (cell.isOtherwise()) {
tce.addClassName(cellOtherwiseStyle);
}
if (cell instanceof GroupedCellValue) {
GroupedCellValue gcv = (GroupedCellValue) cell;
if (gcv.hasMultipleValues()) {
tce.addClassName(cellMultipleValuesStyle);
}
}
}
}
From source file:org.drools.guvnor.client.widgets.drools.decoratedgrid.AbstractVerticalMergableGridWidget.java
License:Apache License
@Override void selectCell(CellValue<? extends Comparable<?>> cell) { if (cell == null) { throw new IllegalArgumentException("cell cannot be null"); }//from www .j a v a 2 s .c o m Coordinate hc = cell.getHtmlCoordinate(); TableRowElement tre = tbody.getRows().getItem(hc.getRow()).<TableRowElement>cast(); TableCellElement tce = tre.getCells().getItem(hc.getCol()).<TableCellElement>cast(); //Cell selected style takes precedence String cellSelectedStyle = resources.cellTableCellSelected(); String cellOtherwiseStyle = resources.cellTableCellOtherwise(); String cellMultipleValuesStyle = resources.cellTableCellMultipleValues(); tce.removeClassName(cellMultipleValuesStyle); tce.removeClassName(cellOtherwiseStyle); tce.addClassName(cellSelectedStyle); tce.focus(); }
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);/*from w ww . ja v a2s . com*/ //Styling depending upon state if (cellData.isOtherwise()) { tce.addClassName(resources.cellTableCellOtherwise()); } else { 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; }
From source file:org.kie.guvnor.decoratedgrid.client.widget.AbstractVerticalMergableGridWidget.java
License:Apache License
@Override
@SuppressWarnings({ "rawtypes" })
void deselectCell(CellValue<? extends Comparable<?>> cell) {
if (cell == null) {
throw new IllegalArgumentException("cell cannot be null");
}//from w ww. j av a2s . co m
Coordinate hc = cell.getHtmlCoordinate();
TableRowElement tre = tbody.getRows().getItem(hc.getRow()).<TableRowElement>cast();
TableCellElement tce = tre.getCells().getItem(hc.getCol()).<TableCellElement>cast();
//Merging, grouping etc could have led to the selected HTML cell disappearing
if (tce != null) {
String cellSelectedStyle = resources.cellTableCellSelected();
String cellMultipleValuesStyle = resources.cellTableCellMultipleValues();
String cellOtherwiseStyle = resources.cellTableCellOtherwise();
tce.removeClassName(cellSelectedStyle);
//Re-apply applicable styling
if (cell.isOtherwise()) {
tce.addClassName(cellOtherwiseStyle);
}
if (cell instanceof CellValue.GroupedCellValue) {
CellValue.GroupedCellValue gcv = (CellValue.GroupedCellValue) cell;
if (gcv.hasMultipleValues()) {
tce.addClassName(cellMultipleValuesStyle);
}
}
}
}