use of org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer.HierarchicalTreeNode in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method testUnhideOnSearch.
@Test
public void testUnhideOnSearch() {
this.treeLayer.setExpandOnSearch(false);
this.treeLayer.doCommand(new TreeExpandCollapseCommand(9, 2));
assertEquals(10, this.treeLayer.getRowCount());
assertEquals(1, this.treeLayer.collapsedNodes.size());
HierarchicalTreeNode node = this.treeLayer.collapsedNodes.iterator().next();
assertEquals(2, node.columnIndex);
assertEquals(9, node.rowIndex);
assertNotNull(node.rowObject);
assertEquals(10, this.treeLayer.getHiddenRowIndexes().iterator().next().intValue());
// search for the collapsed row
ConfigRegistry configRegistry = new ConfigRegistry();
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultDisplayConverter());
GridSearchStrategy gridSearchStrategy = new GridSearchStrategy(configRegistry, false, true);
SearchCommand searchCommand = new SearchCommand("sing", this.selectionLayer, gridSearchStrategy, ISearchDirection.SEARCH_FORWARD, false, false, false, false, false, false, new CellValueAsStringComparator<>());
this.treeLayer.doCommand(searchCommand);
assertEquals(11, this.treeLayer.getRowCount());
assertEquals(1, this.treeLayer.collapsedNodes.size());
node = this.treeLayer.collapsedNodes.iterator().next();
assertEquals(2, node.columnIndex);
assertEquals(9, node.rowIndex);
assertNotNull(node.rowObject);
assertEquals(0, this.treeLayer.getHiddenRowIndexes().size());
}
use of org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer.HierarchicalTreeNode 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());
}
use of org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer.HierarchicalTreeNode 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));
}
use of org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer.HierarchicalTreeNode 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());
}
use of org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer.HierarchicalTreeNode in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerGlazedListsTest method shouldRetainCollapsedStateOnFilter.
@Test
public void shouldRetainCollapsedStateOnFilter() 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));
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());
// bring it back to is previous state and the collapsed state is
// restored
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());
assertEquals("McLaren", this.treeLayer.getDataValueByPosition(1, 1));
}
Aggregations