use of org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandCollapseCommand in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method testExpandToLevel.
// collapseAll - expand to first level - expand one element in second level
// - ensure others in second level are still collapsed
@Test
public void testExpandToLevel() {
// first collapse all
this.treeLayer.doCommand(new TreeCollapseAllCommand());
// expand first level
this.treeLayer.doCommand(new TreeExpandToLevelCommand(0));
assertEquals(7, this.treeLayer.getRowCount());
assertEquals(4, this.treeLayer.collapsedNodes.size());
assertEquals(4, this.treeLayer.getHiddenRowIndexes().size());
// expand one single node on second level to ensure the collapsed states
// are correct
this.treeLayer.doCommand(new TreeExpandCollapseCommand(0, 2));
assertEquals(8, this.treeLayer.getRowCount());
assertEquals(3, this.treeLayer.collapsedNodes.size());
assertEquals(3, this.treeLayer.getHiddenRowIndexes().size());
}
use of org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandCollapseCommand 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.tree.command.TreeExpandCollapseCommand in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method testExpandAllLevelsOnSearchWithoutLevelHeader.
@Test
public void testExpandAllLevelsOnSearchWithoutLevelHeader() {
this.treeLayer.setShowTreeLevelHeader(false);
this.treeLayer.doCommand(new TreeExpandCollapseCommand(9, 2));
this.treeLayer.doCommand(new TreeExpandCollapseCommand(6, 0));
assertEquals(7, this.treeLayer.getRowCount());
assertEquals(2, this.treeLayer.collapsedNodes.size());
assertEquals(4, this.treeLayer.getHiddenRowIndexes().size());
// 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(0, this.treeLayer.collapsedNodes.size());
assertEquals(0, this.treeLayer.getHiddenRowIndexes().size());
}
use of org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandCollapseCommand in project nebula.widgets.nattable by eclipse.
the class TreeExpandCollapseAction method run.
@Override
public void run(NatTable natTable, MouseEvent event) {
int c = natTable.getColumnPositionByX(event.x);
int r = natTable.getRowPositionByY(event.y);
ILayerCell cell = natTable.getCellByPosition(c, r);
int rowIndex = cell.getLayer().getRowIndexByPosition(cell.getOriginRowPosition());
int columnIndex = cell.getLayer().getColumnIndexByPosition(cell.getOriginColumnPosition());
TreeExpandCollapseCommand command = new TreeExpandCollapseCommand(rowIndex, columnIndex);
natTable.doCommand(command);
}
use of org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandCollapseCommand 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());
}
Aggregations