use of org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandCollapseCommand in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method testCollapseAll.
// collapseAll - expand single item with sub items - sub items are all
// collapsed
@Test
public void testCollapseAll() {
this.treeLayer.doCommand(new TreeCollapseAllCommand());
assertEquals(3, this.treeLayer.getRowCount());
assertEquals(6, this.treeLayer.collapsedNodes.size());
assertEquals(8, this.treeLayer.getHiddenRowIndexes().size());
HideRowPositionsEvent hideEvent = (HideRowPositionsEvent) this.layerListener.getReceivedEvent(HideRowPositionsEvent.class);
Collection<Range> rowPositionRanges = hideEvent.getRowPositionRanges();
assertEquals(2, rowPositionRanges.size());
assertTrue(rowPositionRanges.contains(new Range(1, 5)));
assertTrue(rowPositionRanges.contains(new Range(7, 11)));
this.treeLayer.doCommand(new TreeExpandCollapseCommand(0, 0));
assertEquals(5, this.treeLayer.getRowCount());
assertEquals(5, this.treeLayer.collapsedNodes.size());
assertEquals(6, this.treeLayer.getHiddenRowIndexes().size());
ShowRowPositionsEvent showEvent = (ShowRowPositionsEvent) this.layerListener.getReceivedEvent(ShowRowPositionsEvent.class);
rowPositionRanges = showEvent.getRowPositionRanges();
assertEquals(1, rowPositionRanges.size());
assertEquals(new Range(2, 4), rowPositionRanges.iterator().next());
}
use of org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandCollapseCommand in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method testExpandAllLevelsOnSearch.
@Test
public void testExpandAllLevelsOnSearch() {
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 HierarchicalTreeLayerTest method testExpandOnSearchWithoutLevelHeader.
@Test
public void testExpandOnSearchWithoutLevelHeader() {
this.treeLayer.setShowTreeLevelHeader(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(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 TreeExpandCollapseKeyAction method run.
@Override
public void run(NatTable natTable, KeyEvent event) {
PositionCoordinate anchorPosition = this.selectionLayer.getSelectionAnchor();
if (anchorPosition.rowPosition != SelectionLayer.NO_SELECTION && anchorPosition.columnPosition != SelectionLayer.NO_SELECTION) {
int rowIndex = this.selectionLayer.getRowIndexByPosition(anchorPosition.rowPosition);
int columnIndex = this.selectionLayer.getColumnIndexByPosition(anchorPosition.columnPosition);
TreeExpandCollapseCommand command = new TreeExpandCollapseCommand(rowIndex, columnIndex);
natTable.doCommand(command);
}
}
Aggregations