Search in sources :

Example 1 with StructuralRefreshCommand

use of org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand in project nebula.widgets.nattable by eclipse.

the class DataChangeLayerIdIndexTest method shouldClearOnStructuralChange.

@Test
public void shouldClearOnStructuralChange() {
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 1));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, "Lovejoy"));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 1));
    // perform a full refresh, like changing the underlying data model
    this.dataChangeLayer.doCommand(new StructuralRefreshCommand());
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 1));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 1));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 1).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Column 1 is dirty", this.dataChangeLayer.isColumnDirty(1));
    assertFalse("Row 1 is dirty", this.dataChangeLayer.isRowDirty(1));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 1));
    assertTrue("changed columns are not empty", this.dataChangeLayer.changedColumns.isEmpty());
    assertTrue("changed rows are not empty", this.dataChangeLayer.changedRows.isEmpty());
    assertTrue("changes are not empty", this.dataChangeLayer.dataChanges.isEmpty());
}
Also used : StructuralRefreshCommand(org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Test(org.junit.Test)

Example 2 with StructuralRefreshCommand

use of org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand in project nebula.widgets.nattable by eclipse.

the class DataChangeLayerTest method shouldClearOnStructuralChange.

@Test
public void shouldClearOnStructuralChange() {
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 1));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, "Lovejoy"));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 1));
    // perform a full refresh, like changing the underlying data model
    this.dataChangeLayer.doCommand(new StructuralRefreshCommand());
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 1));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 1));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 1).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Column 1 is dirty", this.dataChangeLayer.isColumnDirty(1));
    assertFalse("Row 1 is dirty", this.dataChangeLayer.isRowDirty(1));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 1));
    assertTrue("changed columns are not empty", this.dataChangeLayer.changedColumns.isEmpty());
    assertTrue("changed rows are not empty", this.dataChangeLayer.changedRows.isEmpty());
    assertTrue("changes are not empty", this.dataChangeLayer.dataChanges.isEmpty());
}
Also used : StructuralRefreshCommand(org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Test(org.junit.Test)

Example 3 with StructuralRefreshCommand

use of org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand in project nebula.widgets.nattable by eclipse.

the class HierarchicalTreeLayerGlazedListsTest method shouldRetainCollapsedStateOnSort.

@Test
public void shouldRetainCollapsedStateOnSort() throws InterruptedException, ExecutionException, TimeoutException {
    // collapse second level of first item of mercedes (row index 6 hidden)
    // mind the initial sorting
    this.treeLayer.doCommand(new TreeExpandCollapseCommand(6, 2));
    assertEquals(10, this.treeLayer.getRowCount());
    assertEquals(1, this.treeLayer.getCollapsedNodes().size());
    HierarchicalTreeNode node = this.treeLayer.getCollapsedNodes().iterator().next();
    assertEquals(6, node.rowIndex);
    assertEquals(2, node.columnIndex);
    assertNotNull(node.rowObject);
    assertEquals(7, this.treeLayer.getHiddenRowIndexes().iterator().next().intValue());
    // sort column index 2 DESC
    HierarchicalWrapperSortModel sortModel = new HierarchicalWrapperSortModel(this.sortedList, this.columnPropertyAccessor, this.treeLayer.getLevelIndexMapping(), this.columnHeaderDataLayer, this.configRegistry);
    sortModel.sort(2, SortDirectionEnum.DESC, false);
    // refresh the layers to ensure the state is current
    // sometimes in the tests list change events where missing
    this.treeLayer.doCommand(new StructuralRefreshCommand());
    assertEquals(10, this.treeLayer.getRowCount());
    assertEquals(1, this.treeLayer.getCollapsedNodes().size());
    // collapsed now row index 3
    node = this.treeLayer.getCollapsedNodes().iterator().next();
    assertEquals(9, node.rowIndex);
    assertEquals(2, node.columnIndex);
    assertNotNull(node.rowObject);
    // hidden row now index 4
    assertEquals(10, this.treeLayer.getHiddenRowIndexes().iterator().next().intValue());
}
Also used : StructuralRefreshCommand(org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand) HierarchicalTreeNode(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer.HierarchicalTreeNode) TreeExpandCollapseCommand(org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandCollapseCommand) Test(org.junit.Test)

Example 4 with StructuralRefreshCommand

use of org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand in project nebula.widgets.nattable by eclipse.

the class HierarchicalTreeLayerGlazedListsTest method shouldCleanupRetainedCollapsedStates.

@Test
public void shouldCleanupRetainedCollapsedStates() throws InterruptedException, ExecutionException, TimeoutException {
    // collapse first level of first item
    this.treeLayer.doCommand(new TreeExpandCollapseCommand(0, 0));
    assertEquals(7, this.treeLayer.getRowCount());
    assertEquals(1, this.treeLayer.getCollapsedNodes().size());
    HierarchicalTreeNode node = this.treeLayer.getCollapsedNodes().iterator().next();
    assertEquals(0, node.rowIndex);
    assertEquals(0, node.columnIndex);
    assertNotNull(node.rowObject);
    assertEquals(4, this.treeLayer.getHiddenRowIndexes().size());
    assertEquals("McLaren", this.treeLayer.getDataValueByPosition(1, 1));
    // filter out BMW which is the first row that is collapsed
    this.filterList.setMatcher(new Matcher<HierarchicalWrapper>() {

        @Override
        public boolean matches(HierarchicalWrapper item) {
            return !((Car) item.getObject(0)).getManufacturer().equals("BMW");
        }
    });
    // refresh the layers to ensure the state is current
    // sometimes in the tests list change events where missing
    this.treeLayer.doCommand(new StructuralRefreshCommand());
    assertEquals(6, this.treeLayer.getRowCount());
    assertEquals(1, this.treeLayer.getCollapsedNodes().size());
    node = this.treeLayer.getCollapsedNodes().iterator().next();
    // row index -1 as we retain but the object is not available anymore
    assertEquals(-1, node.rowIndex);
    assertEquals(0, node.columnIndex);
    assertNotNull(node.rowObject);
    // nothing hidden as it is filtered
    assertEquals(0, this.treeLayer.getHiddenRowIndexes().size());
    assertEquals("McLaren", this.treeLayer.getDataValueByPosition(1, 0));
    // cleanup retained
    this.treeLayer.cleanupRetainedCollapsedNodes();
    assertEquals(6, this.treeLayer.getRowCount());
    // nothing collapsed anymore as collapsed node was removed/filtered
    assertEquals(0, this.treeLayer.getCollapsedNodes().size());
    assertEquals(0, this.treeLayer.getHiddenRowIndexes().size());
    assertEquals("McLaren", this.treeLayer.getDataValueByPosition(1, 0));
    this.filterList.setMatcher(null);
    // refresh the layers to ensure the state is current
    // sometimes in the tests list change events where missing
    this.treeLayer.doCommand(new StructuralRefreshCommand());
    // no restore of collapsed nodes
    assertEquals(11, this.treeLayer.getRowCount());
    assertEquals(0, this.treeLayer.getCollapsedNodes().size());
    assertEquals(0, this.treeLayer.getHiddenRowIndexes().size());
    assertEquals("BMW", this.treeLayer.getDataValueByPosition(1, 1));
}
Also used : StructuralRefreshCommand(org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand) HierarchicalWrapper(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalWrapper) HierarchicalTreeNode(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer.HierarchicalTreeNode) TreeExpandCollapseCommand(org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandCollapseCommand) Test(org.junit.Test)

Example 5 with StructuralRefreshCommand

use of org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand in project nebula.widgets.nattable by eclipse.

the class HierarchicalTreeLayerGlazedListsTest method shouldRetainCollapsedStateOnDescSorting.

@Test
public void shouldRetainCollapsedStateOnDescSorting() throws InterruptedException, ExecutionException, TimeoutException {
    HierarchicalWrapper rowObject = this.sortedList.get(0);
    // collapse first level of first item
    this.treeLayer.doCommand(new TreeExpandCollapseCommand(0, 0));
    assertEquals(7, this.treeLayer.getRowCount());
    assertEquals(1, this.treeLayer.getCollapsedNodes().size());
    HierarchicalTreeNode node = this.treeLayer.getCollapsedNodes().iterator().next();
    assertEquals(0, node.rowIndex);
    assertEquals(0, node.columnIndex);
    assertNotNull(node.rowObject);
    assertEquals(4, this.treeLayer.getHiddenRowIndexes().size());
    // sort column index 2 DESC
    HierarchicalWrapperSortModel sortModel = new HierarchicalWrapperSortModel(this.sortedList, this.columnPropertyAccessor, this.treeLayer.getLevelIndexMapping(), this.columnHeaderDataLayer, this.configRegistry);
    sortModel.sort(2, SortDirectionEnum.DESC, false);
    // refresh the layers to ensure the state is current
    // sometimes in the tests list change events where missing
    this.treeLayer.doCommand(new StructuralRefreshCommand());
    int row = this.treeLayer.findTopRowIndex(0, rowObject);
    assertEquals(0, row);
    assertEquals(7, this.treeLayer.getRowCount());
    assertEquals(1, this.treeLayer.getCollapsedNodes().size());
    node = this.treeLayer.getCollapsedNodes().iterator().next();
    assertEquals(0, node.rowIndex);
    assertEquals(0, node.columnIndex);
    assertNotNull(node.rowObject);
    assertEquals(4, this.treeLayer.getHiddenRowIndexes().size());
}
Also used : StructuralRefreshCommand(org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand) HierarchicalWrapper(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalWrapper) HierarchicalTreeNode(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer.HierarchicalTreeNode) TreeExpandCollapseCommand(org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandCollapseCommand) Test(org.junit.Test)

Aggregations

StructuralRefreshCommand (org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand)9 Test (org.junit.Test)8 HierarchicalTreeNode (org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer.HierarchicalTreeNode)5 TreeExpandCollapseCommand (org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandCollapseCommand)5 HierarchicalWrapper (org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalWrapper)4 UpdateDataCommand (org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand)3 ClientAreaResizeCommand (org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand)1 ResizeStructuralRefreshEvent (org.eclipse.nebula.widgets.nattable.layer.event.ResizeStructuralRefreshEvent)1