Search in sources :

Example 1 with IConfigLabelAccumulator

use of org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator 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));
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) IConfigLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator) Test(org.junit.Test)

Example 2 with IConfigLabelAccumulator

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

the class RowSizeConfigurationCommandTest method setup.

@Before
public void setup() {
    this.dataLayer = new DataLayer(new DummyBodyDataProvider(4, 4));
    this.dataLayer.setConfigLabelAccumulator(new IConfigLabelAccumulator() {

        @Override
        public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
            configLabels.addLabel("ROW_" + rowPosition);
        }
    });
}
Also used : DummyBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) IConfigLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator) Before(org.junit.Before)

Example 3 with IConfigLabelAccumulator

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

the class AbstractLayerTransform method getConfigLabelsByPosition.

@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
    LabelStack configLabels = null;
    int underlyingColumnPosition = localToUnderlyingColumnPosition(columnPosition);
    int underlyingRowPosition = localToUnderlyingRowPosition(rowPosition);
    if (underlyingColumnPosition != -1 && underlyingRowPosition != -1) {
        configLabels = this.underlyingLayer.getConfigLabelsByPosition(underlyingColumnPosition, underlyingRowPosition);
        IConfigLabelAccumulator configLabelAccumulator = getConfigLabelAccumulator();
        if (configLabelAccumulator != null) {
            configLabelAccumulator.accumulateConfigLabels(configLabels, columnPosition, rowPosition);
        }
    } else {
        // the the layer-position-transformation returned -1 for the
        // underlying position, it is not possible the get the LabelStack
        // from the underlying layer. In this case we simply create a new
        // LabelStack.
        configLabels = new LabelStack();
    }
    String regionName = getRegionName();
    if (regionName != null) {
        configLabels.addLabel(regionName);
    }
    return configLabels;
}
Also used : IConfigLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator)

Example 4 with IConfigLabelAccumulator

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

the class CompositeLayer method getConfigLabelsByPosition.

@Override
public LabelStack getConfigLabelsByPosition(int compositeColumnPosition, int compositeRowPosition) {
    Point layoutCoordinate = getLayoutXYByPosition(compositeColumnPosition, compositeRowPosition);
    if (layoutCoordinate == null) {
        return new LabelStack();
    }
    ILayer childLayer = this.childLayerLayout[layoutCoordinate.x][layoutCoordinate.y];
    int childColumnPosition = compositeColumnPosition - getColumnPositionOffset(layoutCoordinate.x);
    int childRowPosition = compositeRowPosition - getRowPositionOffset(layoutCoordinate.y);
    LabelStack configLabels = childLayer.getConfigLabelsByPosition(childColumnPosition, childRowPosition);
    String regionName = this.childLayerToRegionNameMap.get(childLayer);
    IConfigLabelAccumulator configLabelAccumulator = this.regionNameToConfigLabelAccumulatorMap.get(regionName);
    if (configLabelAccumulator != null) {
        configLabelAccumulator.accumulateConfigLabels(configLabels, childColumnPosition, childRowPosition);
    }
    configLabels.addLabel(regionName);
    return configLabels;
}
Also used : IConfigLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 5 with IConfigLabelAccumulator

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

the class CompositeLayer method getProvidedLabels.

@Override
public Collection<String> getProvidedLabels() {
    Collection<String> labels = super.getProvidedLabels();
    for (int layoutX = 0; layoutX < this.layoutXCount; layoutX++) {
        for (int layoutY = 0; layoutY < this.layoutYCount; layoutY++) {
            ILayer childLayer = this.childLayerLayout[layoutX][layoutY];
            String regionName = this.childLayerToRegionNameMap.get(childLayer);
            labels.add(regionName);
            IConfigLabelAccumulator accumulator = this.regionNameToConfigLabelAccumulatorMap.get(regionName);
            if (accumulator != null && accumulator instanceof IConfigLabelProvider) {
                labels.addAll(((IConfigLabelProvider) accumulator).getProvidedLabels());
            }
            if (childLayer instanceof AbstractLayer) {
                labels.addAll(((AbstractLayer) childLayer).getProvidedLabels());
            }
        }
    }
    return labels;
}
Also used : IConfigLabelProvider(org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelProvider) IConfigLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator) Point(org.eclipse.swt.graphics.Point)

Aggregations

IConfigLabelAccumulator (org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator)15 LabelStack (org.eclipse.nebula.widgets.nattable.layer.LabelStack)10 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)5 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)5 HashMap (java.util.HashMap)4 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)4 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)4 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)4 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 Composite (org.eclipse.swt.widgets.Composite)4 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)3 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)3 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)3 Person (org.eclipse.nebula.widgets.nattable.dataset.person.Person)3 AggregateConfigLabelAccumulator (org.eclipse.nebula.widgets.nattable.layer.cell.AggregateConfigLabelAccumulator)3 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)2 ReflectiveColumnPropertyAccessor (org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor)2