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));
}
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);
}
});
}
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;
}
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;
}
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;
}
Aggregations