Search in sources :

Example 46 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class BlinkLayerTest method shouldReturnTheBlinkConfigTypeWhenARowIsUpdated.

@Test
public void shouldReturnTheBlinkConfigTypeWhenARowIsUpdated() throws Exception {
    this.layerUnderTest.setBlinkDurationInMilis(100);
    this.dataList.get(0).setAsk_price(100);
    LabelStack blinkLabels = this.layerUnderTest.getConfigLabelsByPosition(6, 0);
    // Blink started
    assertEquals(1, blinkLabels.getLabels().size());
    assertEquals(BLINKING_LABEL, blinkLabels.getLabels().get(0));
    // After 50 ms
    Thread.sleep(50);
    blinkLabels = this.layerUnderTest.getConfigLabelsByPosition(6, 0);
    assertEquals(1, blinkLabels.getLabels().size());
    // Wait for blink to elapse
    Thread.sleep(110);
    // run.
    while (this.display.readAndDispatch()) ;
    blinkLabels = this.layerUnderTest.getConfigLabelsByPosition(6, 0);
    assertEquals(0, blinkLabels.getLabels().size());
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) Test(org.junit.Test)

Example 47 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class ResizeColumnHideShowLayerTest method testHiddenColumnsHaveSkipSearchLabel.

@Test
public void testHiddenColumnsHaveSkipSearchLabel() {
    LabelStack labels = this.hideShowLayer.getConfigLabelsByPosition(1, 0);
    assertTrue("LabelStack not empty", labels.getLabels().isEmpty());
    this.hideShowLayer.hideColumnPositions(1, 4);
    labels = this.hideShowLayer.getConfigLabelsByPosition(1, 0);
    assertFalse("LabelStack not empty", labels.getLabels().isEmpty());
    assertTrue("skip search label not contained", labels.hasLabel(ISearchStrategy.SKIP_SEARCH_RESULT_LABEL));
    this.hideShowLayer.showAllColumns();
    labels = this.hideShowLayer.getConfigLabelsByPosition(1, 0);
    assertTrue("LabelStack not empty", labels.getLabels().isEmpty());
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) Test(org.junit.Test)

Example 48 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class ColumnGroupHeaderLayerTest method testConfigLabelsWithAccumulator.

@Test
public void testConfigLabelsWithAccumulator() {
    // set config label accumulator
    this.columnGroupLayer.setConfigLabelAccumulator(new IConfigLabelAccumulator() {

        @Override
        public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
            if (columnPosition == 0 || columnPosition == 3) {
                configLabels.addLabel("custom");
            }
        }
    });
    // check expanded column group
    LabelStack stack = this.columnGroupLayer.getConfigLabelsByPosition(0, 0);
    assertEquals(3, stack.getLabels().size());
    assertTrue(stack.hasLabel(GridRegion.COLUMN_GROUP_HEADER));
    assertTrue(stack.hasLabel("custom"));
    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(3, stack.getLabels().size());
    assertTrue(stack.hasLabel(GridRegion.COLUMN_GROUP_HEADER));
    assertTrue(stack.hasLabel("custom"));
    assertTrue(stack.hasLabel(DefaultColumnGroupHeaderLayerConfiguration.GROUP_COLLAPSED_CONFIG_TYPE));
    // check ungrouped
    stack = this.columnGroupLayer.getConfigLabelsByPosition(3, 0);
    assertEquals(0, stack.getLabels().size());
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) IConfigLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator) Test(org.junit.Test)

Example 49 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class ColumnOverrideLabelAccumulatorTest method testRegisterOverridesCollection.

@Test
public void testRegisterOverridesCollection() {
    this.labelAccumulator.registerColumnOverrides(0, TEST_LABEL1);
    List<String> labels = new ArrayList<String>();
    labels.add(TEST_LABEL2);
    labels.add(TEST_LABEL3);
    this.labelAccumulator.registerColumnOverrides(0, labels);
    LabelStack configLabels = new LabelStack();
    this.labelAccumulator.accumulateConfigLabels(configLabels, 0, 0);
    Assert.assertEquals(3, configLabels.getLabels().size());
    Assert.assertEquals(TEST_LABEL1, configLabels.getLabels().get(0));
    Assert.assertEquals(TEST_LABEL2, configLabels.getLabels().get(1));
    Assert.assertEquals(TEST_LABEL3, configLabels.getLabels().get(2));
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 50 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class ColumnOverrideLabelAccumulatorTest method testRegisterOverridesEllipse.

@Test
public void testRegisterOverridesEllipse() {
    this.labelAccumulator.registerColumnOverrides(0, TEST_LABEL1);
    this.labelAccumulator.registerColumnOverrides(0, TEST_LABEL2, TEST_LABEL3);
    LabelStack configLabels = new LabelStack();
    this.labelAccumulator.accumulateConfigLabels(configLabels, 0, 0);
    Assert.assertEquals(3, configLabels.getLabels().size());
    Assert.assertEquals(TEST_LABEL1, configLabels.getLabels().get(0));
    Assert.assertEquals(TEST_LABEL2, configLabels.getLabels().get(1));
    Assert.assertEquals(TEST_LABEL3, configLabels.getLabels().get(2));
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) Test(org.junit.Test)

Aggregations

LabelStack (org.eclipse.nebula.widgets.nattable.layer.LabelStack)80 Test (org.junit.Test)30 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)14 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)13 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)11 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)10 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)10 HashMap (java.util.HashMap)9 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)9 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)9 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 GridLayout (org.eclipse.swt.layout.GridLayout)9 Composite (org.eclipse.swt.widgets.Composite)9 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)8 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)8 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)8 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)8 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)8