Search in sources :

Example 21 with TableCellElement

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

the class AbstractVerticalMergableGridWidget method deselectCell.

@Override
@SuppressWarnings({ "rawtypes" })
void deselectCell(CellValue<? extends Comparable<?>> cell) {
    if (cell == null) {
        throw new IllegalArgumentException("cell cannot be null");
    }
    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);
            }
        }
    }
}
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)

Example 22 with TableCellElement

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

the class AbstractVerticalMergableGridWidget method showColumn.

@Override
void showColumn(int index) {
    if (index < 0) {
        throw new IllegalArgumentException("index cannot be less than zero");
    }
    if (index > columns.size()) {
        throw new IllegalArgumentException("index cannot be greater than the number of rows");
    }
    for (int iRow = 0; iRow < data.size(); iRow++) {
        DynamicDataRow rowData = data.get(iRow);
        TableCellElement tce = makeTableCellElement(index, rowData);
        if (tce != null) {
            CellValue<? extends Comparable<?>> cell = rowData.get(index);
            Coordinate hc = cell.getHtmlCoordinate();
            TableRowElement tre = tbody.getRows().getItem(hc.getRow());
            TableCellElement ntce = tre.insertCell(hc.getCol());
            tre.replaceChild(tce, ntce);
        }
    }
}
Also used : Coordinate(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate) TableRowElement(com.google.gwt.dom.client.TableRowElement) DynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow) TableCellElement(com.google.gwt.dom.client.TableCellElement)

Example 23 with TableCellElement

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

the class AbstractVerticalMergableGridWidget method hideColumn.

@Override
void hideColumn(int index) {
    if (index < 0) {
        throw new IllegalArgumentException("index cannot be less than zero");
    }
    if (index > columns.size()) {
        throw new IllegalArgumentException("index cannot be greater than the number of rows");
    }
    for (int iRow = 0; iRow < data.size(); iRow++) {
        DynamicDataRow rowData = data.get(iRow);
        CellValue<? extends Comparable<?>> cell = rowData.get(index);
        if (cell.getRowSpan() > 0) {
            Coordinate hc = cell.getHtmlCoordinate();
            TableRowElement tre = tbody.getRows().getItem(hc.getRow());
            TableCellElement tce = tre.getCells().getItem(hc.getCol());
            tre.removeChild(tce);
        }
    }
}
Also used : Coordinate(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate) TableRowElement(com.google.gwt.dom.client.TableRowElement) DynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow) TableCellElement(com.google.gwt.dom.client.TableCellElement)

Example 24 with TableCellElement

use of com.google.gwt.dom.client.TableCellElement in project gwt-test-utils by gwt-test-utils.

the class GridPatcher method createRow.

private static TableRowElement createRow(int columns, String cellContent) {
    TableRowElement tr = Document.get().createTRElement();
    for (int i = 0; i < columns; i++) {
        TableCellElement cell = Document.get().createTDElement();
        cell.setInnerHTML(cellContent);
        tr.appendChild(cell);
    }
    return tr;
}
Also used : TableRowElement(com.google.gwt.dom.client.TableRowElement) TableCellElement(com.google.gwt.dom.client.TableCellElement)

Example 25 with TableCellElement

use of com.google.gwt.dom.client.TableCellElement in project gwt-test-utils by gwt-test-utils.

the class TableRowElementTest method insertCell.

@Test
public void insertCell() {
    // Given
    TableCellElement td0 = Document.get().createTDElement();
    tr.appendChild(td0);
    TableCellElement td1 = Document.get().createTDElement();
    tr.appendChild(td1);
    // When
    TableCellElement insert = tr.insertCell(1);
    // Then
    assertThat(tr.getChildCount()).isEqualTo(3);
    assertThat(tr.getChild(0)).isEqualTo(td0);
    assertThat(tr.getChild(1)).isEqualTo(insert);
    assertThat(tr.getChild(2)).isEqualTo(td1);
}
Also used : TableCellElement(com.google.gwt.dom.client.TableCellElement) GwtTestTest(com.googlecode.gwt.test.GwtTestTest) Test(org.junit.Test)

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