Search in sources :

Example 6 with GroupedDynamicDataRow

use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow in project kie-wb-common by kiegroup.

the class DynamicDataTestsWithGroupingColumnAdditions method testIndexing_DataCoordinates.

@Test
public void testIndexing_DataCoordinates() {
    // [1][-][3] --> [1][x][3] --> [0,0][0,1][0,2]
    // [1][2][3] --> [-][2][3] --> [1,0][1,1][1,2]
    // [-][2][3] -->
    CellValue<? extends Comparable<?>> cv = data.get(0).get(0);
    data.setMerged(true);
    data.applyModelGrouping(cv);
    assertEquals(data.size(), 2);
    Coordinate c;
    c = data.get(0).get(0).getCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 0);
    c = data.get(0).get(1).getCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 1);
    c = data.get(0).get(2).getCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 2);
    c = data.get(1).get(0).getCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 0);
    c = data.get(1).get(1).getCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 1);
    c = data.get(1).get(2).getCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 2);
    data.addColumn(3, makeCellValueList(3), true);
    assertEquals(data.size(), 2);
    assertEquals(data.get(0).size(), 4);
    assertEquals(data.get(1).size(), 4);
    assertTrue(data.get(0) instanceof GroupedDynamicDataRow);
    GroupedDynamicDataRow gdr = (GroupedDynamicDataRow) data.get(0);
    assertEquals(gdr.getChildRows().size(), 2);
    assertEquals(gdr.getChildRows().get(0).size(), 4);
    assertEquals(gdr.getChildRows().get(1).size(), 4);
    // [1][-][3][-] --> [1][x][3][-] --> [0,0][0,1][0,2][0,3]
    // [1][2][3][-] --> [-][2][3][-] --> [1,0][1,1][1,2][1,3]
    c = data.get(0).get(0).getCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 0);
    c = data.get(0).get(1).getCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 1);
    c = data.get(0).get(2).getCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 2);
    c = data.get(0).get(3).getCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 3);
    c = data.get(1).get(0).getCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 0);
    c = data.get(1).get(1).getCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 1);
    c = data.get(1).get(2).getCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 2);
    c = data.get(1).get(3).getCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 3);
}
Also used : Coordinate(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate) GroupedDynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow) Test(org.junit.Test)

Example 7 with GroupedDynamicDataRow

use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow in project kie-wb-common by kiegroup.

the class DynamicDataTestsWithGroupingColumnDeletions method testIndexing_DataCoordinates.

@Test
public void testIndexing_DataCoordinates() {
    // [1][-][3] --> [1][x][3] --> [0,0][0,1][0,2]
    // [1][2][3] --> [-][2][3] --> [1,0][1,1][1,2]
    // [-][2][3] -->
    CellValue<? extends Comparable<?>> cv = data.get(0).get(0);
    data.setMerged(true);
    data.applyModelGrouping(cv);
    assertEquals(data.size(), 2);
    Coordinate c;
    c = data.get(0).get(0).getCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 0);
    c = data.get(0).get(1).getCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 1);
    c = data.get(0).get(2).getCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 2);
    c = data.get(1).get(0).getCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 0);
    c = data.get(1).get(1).getCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 1);
    c = data.get(1).get(2).getCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 2);
    data.deleteColumn(2);
    assertEquals(data.size(), 2);
    assertEquals(data.get(0).size(), 2);
    assertEquals(data.get(1).size(), 2);
    assertTrue(data.get(0) instanceof GroupedDynamicDataRow);
    GroupedDynamicDataRow gdr = (GroupedDynamicDataRow) data.get(0);
    assertEquals(gdr.getChildRows().size(), 2);
    assertEquals(gdr.getChildRows().get(0).size(), 2);
    assertEquals(gdr.getChildRows().get(1).size(), 2);
    // [1][-][3][-] --> [1][x] --> [0,0][0,1]
    // [1][2][3][-] --> [-][2] --> [1,0][1,1]
    c = data.get(0).get(0).getCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 0);
    c = data.get(0).get(1).getCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 1);
    c = data.get(1).get(0).getCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 0);
    c = data.get(1).get(1).getCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 1);
}
Also used : Coordinate(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate) GroupedDynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow) Test(org.junit.Test)

Example 8 with GroupedDynamicDataRow

use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow in project kie-wb-common by kiegroup.

the class DynamicDataTestsWithGroupingColumnDeletions method testIndexing_HtmlCoordinates.

@Test
public void testIndexing_HtmlCoordinates() {
    // [1][-][3] --> [1][x][3] --> [0,0][0,1][0,2]
    // [1][2][3] --> [-][2][3] --> [1,0][1,1][1,2]
    // [-][2][3] -->
    CellValue<? extends Comparable<?>> cv = data.get(0).get(0);
    data.setMerged(true);
    data.applyModelGrouping(cv);
    assertEquals(data.size(), 2);
    Coordinate c;
    c = data.get(0).get(0).getHtmlCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 0);
    c = data.get(0).get(1).getHtmlCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 1);
    c = data.get(0).get(2).getHtmlCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 2);
    c = data.get(1).get(0).getHtmlCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 0);
    c = data.get(1).get(1).getHtmlCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 1);
    c = data.get(1).get(2).getHtmlCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 2);
    data.deleteColumn(2);
    assertEquals(data.size(), 2);
    assertEquals(data.get(0).size(), 2);
    assertEquals(data.get(1).size(), 2);
    assertTrue(data.get(0) instanceof GroupedDynamicDataRow);
    GroupedDynamicDataRow gdr = (GroupedDynamicDataRow) data.get(0);
    assertEquals(gdr.getChildRows().size(), 2);
    assertEquals(gdr.getChildRows().get(0).size(), 2);
    assertEquals(gdr.getChildRows().get(1).size(), 2);
    // [1][-][3][-] --> [1][x] --> [0,0][0,1]
    // [1][2][3][-] --> [-][2] --> [1,0][1,1]
    c = data.get(0).get(0).getHtmlCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 0);
    c = data.get(0).get(1).getHtmlCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 1);
    c = data.get(1).get(0).getHtmlCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 0);
    c = data.get(1).get(1).getHtmlCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 1);
}
Also used : Coordinate(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate) GroupedDynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow) Test(org.junit.Test)

Example 9 with GroupedDynamicDataRow

use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow in project kie-wb-common by kiegroup.

the class DynamicDataTestsWithGroupingColumnDeletions method testIndexing_PhysicalCoordinates.

@Test
public void testIndexing_PhysicalCoordinates() {
    // [1][-][3] --> [1][x][3] --> [0,0][0,1][0,2] --> [0,0][0,1][0,2]
    // [1][2][3] --> [-][2][3] --> [1,0][1,1][0,2] --> [1,0][1,1][-,-]
    // [-][2][3] -->
    CellValue<? extends Comparable<?>> cv = data.get(0).get(0);
    data.setMerged(true);
    data.applyModelGrouping(cv);
    assertEquals(data.size(), 2);
    Coordinate c;
    c = data.get(0).get(0).getPhysicalCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 0);
    c = data.get(0).get(1).getPhysicalCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 1);
    c = data.get(0).get(2).getPhysicalCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 2);
    c = data.get(1).get(0).getPhysicalCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 0);
    c = data.get(1).get(1).getPhysicalCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 1);
    data.deleteColumn(2);
    assertEquals(data.size(), 2);
    assertEquals(data.get(0).size(), 2);
    assertEquals(data.get(1).size(), 2);
    assertTrue(data.get(0) instanceof GroupedDynamicDataRow);
    GroupedDynamicDataRow gdr = (GroupedDynamicDataRow) data.get(0);
    assertEquals(gdr.getChildRows().size(), 2);
    assertEquals(gdr.getChildRows().get(0).size(), 2);
    assertEquals(gdr.getChildRows().get(1).size(), 2);
    // [1][-][3][-] --> [1][x] --> [0,0][0,1] --> [0,0][0,1]
    // [1][2][3][-] --> [-][2] --> [1,0][1,1] --> [1,0][1,1]
    c = data.get(0).get(0).getPhysicalCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 0);
    c = data.get(0).get(1).getPhysicalCoordinate();
    assertEquals(c.getRow(), 0);
    assertEquals(c.getCol(), 1);
    c = data.get(1).get(0).getPhysicalCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 0);
    c = data.get(1).get(1).getPhysicalCoordinate();
    assertEquals(c.getRow(), 1);
    assertEquals(c.getCol(), 1);
}
Also used : Coordinate(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate) GroupedDynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow) Test(org.junit.Test)

Aggregations

GroupedDynamicDataRow (org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow)9 Test (org.junit.Test)6 Coordinate (org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate)6 DynamicDataRow (org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow)2