use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class BlinkLayerTest method layerStackShouldUpdate.
@Test
public void layerStackShouldUpdate() throws Exception {
// add label accumulator to DataLayer
this.dataLayer.setConfigLabelAccumulator(new IConfigLabelAccumulator() {
@Override
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
configLabels.addLabel(TEST_LABEL);
}
});
this.layerUnderTest.setBlinkDurationInMilis(100);
this.dataList.get(0).setAsk_price(100);
LabelStack blinkLabels = this.layerUnderTest.getConfigLabelsByPosition(6, 0);
// Blink started
assertEquals(2, blinkLabels.getLabels().size());
assertEquals(BLINKING_LABEL, blinkLabels.getLabels().get(0));
assertEquals(TEST_LABEL, blinkLabels.getLabels().get(1));
// After 50 ms
Thread.sleep(50);
blinkLabels = this.layerUnderTest.getConfigLabelsByPosition(6, 0);
assertEquals(2, blinkLabels.getLabels().size());
// Wait for blink to elapse
Thread.sleep(110);
// run.
while (this.display.readAndDispatch()) ;
blinkLabels = this.layerUnderTest.getConfigLabelsByPosition(6, 0);
assertEquals(1, blinkLabels.getLabels().size());
assertEquals(TEST_LABEL, blinkLabels.getLabels().get(0));
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method testConfigLabelsByPosition.
@Test
public void testConfigLabelsByPosition() {
LabelStack stack = this.treeLayer.getConfigLabelsByPosition(0, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(HierarchicalTreeLayer.LEVEL_HEADER_CELL));
stack = this.treeLayer.getConfigLabelsByPosition(1, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_EXPANDED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 0));
stack = this.treeLayer.getConfigLabelsByPosition(2, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 1));
stack = this.treeLayer.getConfigLabelsByPosition(3, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(HierarchicalTreeLayer.LEVEL_HEADER_CELL));
stack = this.treeLayer.getConfigLabelsByPosition(4, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_EXPANDED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 2));
stack = this.treeLayer.getConfigLabelsByPosition(5, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 3));
stack = this.treeLayer.getConfigLabelsByPosition(6, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(HierarchicalTreeLayer.LEVEL_HEADER_CELL));
stack = this.treeLayer.getConfigLabelsByPosition(7, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 4));
stack = this.treeLayer.getConfigLabelsByPosition(8, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 5));
this.treeLayer.setShowTreeLevelHeader(false);
stack = this.treeLayer.getConfigLabelsByPosition(0, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_EXPANDED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 0));
stack = this.treeLayer.getConfigLabelsByPosition(1, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 1));
stack = this.treeLayer.getConfigLabelsByPosition(2, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_EXPANDED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 2));
stack = this.treeLayer.getConfigLabelsByPosition(3, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 3));
stack = this.treeLayer.getConfigLabelsByPosition(4, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 4));
stack = this.treeLayer.getConfigLabelsByPosition(5, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 5));
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method testExpandCollapseConfigLabelsByPosition.
@Test
public void testExpandCollapseConfigLabelsByPosition() {
LabelStack stack = this.treeLayer.getConfigLabelsByPosition(1, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_EXPANDED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 0));
// collapse first level - note that this is done by index
this.treeLayer.expandOrCollapse(0, 0);
stack = this.treeLayer.getConfigLabelsByPosition(1, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_COLLAPSED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 0));
// expand first level again
this.treeLayer.expandOrCollapse(0, 0);
stack = this.treeLayer.getConfigLabelsByPosition(4, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_EXPANDED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 2));
// collapse second level
this.treeLayer.expandOrCollapse(2, 0);
stack = this.treeLayer.getConfigLabelsByPosition(4, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_COLLAPSED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 2));
// expand second level again
this.treeLayer.expandOrCollapse(2, 0);
stack = this.treeLayer.getConfigLabelsByPosition(5, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 3));
stack = this.treeLayer.getConfigLabelsByPosition(6, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(HierarchicalTreeLayer.LEVEL_HEADER_CELL));
stack = this.treeLayer.getConfigLabelsByPosition(7, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 4));
stack = this.treeLayer.getConfigLabelsByPosition(8, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 5));
this.treeLayer.setShowTreeLevelHeader(false);
stack = this.treeLayer.getConfigLabelsByPosition(0, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_EXPANDED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 0));
// collapse first level
this.treeLayer.expandOrCollapse(0, 0);
stack = this.treeLayer.getConfigLabelsByPosition(0, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_COLLAPSED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 0));
// expand first level again
this.treeLayer.expandOrCollapse(0, 0);
stack = this.treeLayer.getConfigLabelsByPosition(2, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_EXPANDED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 2));
// collapse second level
this.treeLayer.expandOrCollapse(2, 0);
stack = this.treeLayer.getConfigLabelsByPosition(2, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_COLLAPSED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 2));
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method testExpandCollapseConfigLabelsByPositionForChildColumns.
@Test
public void testExpandCollapseConfigLabelsByPositionForChildColumns() {
// collapse first level - note that this is done by index
this.treeLayer.expandOrCollapse(0, 0);
LabelStack stack = this.treeLayer.getConfigLabelsByPosition(1, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_COLLAPSED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 0));
stack = this.treeLayer.getConfigLabelsByPosition(2, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 1));
stack = this.treeLayer.getConfigLabelsByPosition(3, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(HierarchicalTreeLayer.LEVEL_HEADER_CELL));
stack = this.treeLayer.getConfigLabelsByPosition(4, 0);
assertEquals(2, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 2));
assertTrue(stack.hasLabel(HierarchicalTreeLayer.COLLAPSED_CHILD));
stack = this.treeLayer.getConfigLabelsByPosition(5, 0);
assertEquals(2, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 3));
assertTrue(stack.hasLabel(HierarchicalTreeLayer.COLLAPSED_CHILD));
stack = this.treeLayer.getConfigLabelsByPosition(6, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(HierarchicalTreeLayer.LEVEL_HEADER_CELL));
stack = this.treeLayer.getConfigLabelsByPosition(7, 0);
assertEquals(2, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 4));
assertTrue(stack.hasLabel(HierarchicalTreeLayer.COLLAPSED_CHILD));
stack = this.treeLayer.getConfigLabelsByPosition(8, 0);
assertEquals(2, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 5));
assertTrue(stack.hasLabel(HierarchicalTreeLayer.COLLAPSED_CHILD));
// expand first level again
this.treeLayer.expandOrCollapse(0, 0);
// collapse second level
this.treeLayer.expandOrCollapse(2, 0);
stack = this.treeLayer.getConfigLabelsByPosition(0, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(HierarchicalTreeLayer.LEVEL_HEADER_CELL));
stack = this.treeLayer.getConfigLabelsByPosition(1, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_EXPANDED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 0));
stack = this.treeLayer.getConfigLabelsByPosition(2, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 1));
stack = this.treeLayer.getConfigLabelsByPosition(3, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(HierarchicalTreeLayer.LEVEL_HEADER_CELL));
stack = this.treeLayer.getConfigLabelsByPosition(4, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_COLLAPSED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 2));
stack = this.treeLayer.getConfigLabelsByPosition(5, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 3));
stack = this.treeLayer.getConfigLabelsByPosition(6, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(HierarchicalTreeLayer.LEVEL_HEADER_CELL));
stack = this.treeLayer.getConfigLabelsByPosition(7, 0);
assertEquals(2, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 4));
assertTrue(stack.hasLabel(HierarchicalTreeLayer.COLLAPSED_CHILD));
stack = this.treeLayer.getConfigLabelsByPosition(8, 0);
assertEquals(2, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 5));
assertTrue(stack.hasLabel(HierarchicalTreeLayer.COLLAPSED_CHILD));
// expand second level again
this.treeLayer.expandOrCollapse(2, 0);
// disable handle collapsed children, collapse first level, check
this.treeLayer.setHandleCollapsedChildren(false);
// collapse first level
this.treeLayer.expandOrCollapse(0, 0);
stack = this.treeLayer.getConfigLabelsByPosition(0, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(HierarchicalTreeLayer.LEVEL_HEADER_CELL));
stack = this.treeLayer.getConfigLabelsByPosition(1, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_COLLAPSED_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 0));
stack = this.treeLayer.getConfigLabelsByPosition(2, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 1));
stack = this.treeLayer.getConfigLabelsByPosition(3, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(HierarchicalTreeLayer.LEVEL_HEADER_CELL));
stack = this.treeLayer.getConfigLabelsByPosition(4, 0);
assertEquals(4, stack.getLabels().size());
assertTrue(stack.hasLabel(TreeLayer.TREE_COLUMN_CELL));
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0));
// special situation
// the parent is collapsed but we show the data of the child level
// in that case we can not show the expand/collapse of the child,
// because the parent is collapsed
assertTrue(stack.hasLabel(DefaultTreeLayerConfiguration.TREE_LEAF_CONFIG_TYPE));
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 2));
stack = this.treeLayer.getConfigLabelsByPosition(5, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 3));
stack = this.treeLayer.getConfigLabelsByPosition(6, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(HierarchicalTreeLayer.LEVEL_HEADER_CELL));
stack = this.treeLayer.getConfigLabelsByPosition(7, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 4));
stack = this.treeLayer.getConfigLabelsByPosition(8, 0);
assertEquals(1, stack.getLabels().size());
assertTrue(stack.hasLabel(ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 5));
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class ColumnGroupHeaderLayerTest method testConfigLabels.
@Test
public void testConfigLabels() {
// check expanded column group
LabelStack stack = this.columnGroupLayer.getConfigLabelsByPosition(0, 0);
assertEquals(2, stack.getLabels().size());
assertTrue(stack.hasLabel(GridRegion.COLUMN_GROUP_HEADER));
assertTrue(stack.hasLabel(DefaultColumnGroupHeaderLayerConfiguration.GROUP_EXPANDED_CONFIG_TYPE));
// check collapsed column group
this.model.getColumnGroupByIndex(0).setCollapsed(true);
stack = this.columnGroupLayer.getConfigLabelsByPosition(0, 0);
assertEquals(2, stack.getLabels().size());
assertTrue(stack.hasLabel(GridRegion.COLUMN_GROUP_HEADER));
assertTrue(stack.hasLabel(DefaultColumnGroupHeaderLayerConfiguration.GROUP_COLLAPSED_CONFIG_TYPE));
// check ungrouped
stack = this.columnGroupLayer.getConfigLabelsByPosition(3, 0);
assertEquals(0, stack.getLabels().size());
}
Aggregations