use of org.eclipse.nebula.widgets.nattable.layer.DataLayer in project nebula.widgets.nattable by eclipse.
the class CalculatedValueCacheTest method testCalculateInSameThreadWithColumnKey.
@Test
public void testCalculateInSameThreadWithColumnKey() throws Exception {
this.valueCache = new CalculatedValueCache(new DataLayer(new DummyBodyDataProvider(10, 10)), true, false);
Object result = this.valueCache.getCalculatedValue(0, 0, false, this.calculator);
assertEquals(Integer.valueOf(42), Integer.valueOf(result.toString()));
}
use of org.eclipse.nebula.widgets.nattable.layer.DataLayer in project nebula.widgets.nattable by eclipse.
the class CalculatedValueCacheTest method testIllegalState.
@Test(expected = IllegalStateException.class)
public void testIllegalState() {
this.valueCache = new CalculatedValueCache(new DataLayer(new DummyBodyDataProvider(10, 10)), false, false);
this.valueCache.getCalculatedValue(0, 0, false, this.calculator);
}
use of org.eclipse.nebula.widgets.nattable.layer.DataLayer in project nebula.widgets.nattable by eclipse.
the class CalculatedValueCacheTest method testCalculateInBackgroundWithCoordsKey.
@Test
public void testCalculateInBackgroundWithCoordsKey() throws Exception {
this.valueCache = new CalculatedValueCache(new DataLayer(new DummyBodyDataProvider(10, 10)), true, true);
Object result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
// as calculation is performed in background, the immediate return value
// is null
assertNull(result);
// now wait so the background process is able to finish
Thread.sleep(250);
result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
assertEquals(Integer.valueOf(42), Integer.valueOf(result.toString()));
}
use of org.eclipse.nebula.widgets.nattable.layer.DataLayer in project nebula.widgets.nattable by eclipse.
the class CalculatedValueCacheTest method testCalculateInSameThreadWithCoordsKey.
@Test
public void testCalculateInSameThreadWithCoordsKey() throws Exception {
this.valueCache = new CalculatedValueCache(new DataLayer(new DummyBodyDataProvider(10, 10)), true, true);
Object result = this.valueCache.getCalculatedValue(0, 0, false, this.calculator);
assertEquals(Integer.valueOf(42), Integer.valueOf(result.toString()));
}
use of org.eclipse.nebula.widgets.nattable.layer.DataLayer in project nebula.widgets.nattable by eclipse.
the class ViewportIntegrationTest method shouldInitWithNoScroll.
@Test
public void shouldInitWithNoScroll() {
List<String> contents = new ArrayList<>(Arrays.asList("one", "two", "three", "four", "five"));
IDataProvider bodyDataProvider = new ListDataProvider<>(contents, new IColumnAccessor<String>() {
@Override
public Object getDataValue(String rowObject, int columnIndex) {
return rowObject;
}
@Override
public void setDataValue(String rowObject, int columnIndex, Object newValue) {
// ignore
}
@Override
public int getColumnCount() {
return 1;
}
});
SelectionLayer selectionLayer = new SelectionLayer(new DataLayer(bodyDataProvider));
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
IDataProvider colDataProvider = new DummyColumnHeaderDataProvider(bodyDataProvider);
ColumnHeaderLayer colHeader = new ColumnHeaderLayer(new DataLayer(colDataProvider), viewportLayer, selectionLayer);
IDataProvider rowDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(new DataLayer(rowDataProvider), viewportLayer, selectionLayer);
CornerLayer cornerLayer = new CornerLayer(new DataLayer(new DefaultCornerDataProvider(colDataProvider, rowDataProvider)), rowHeaderLayer, colHeader);
GridLayer grid = new GridLayer(viewportLayer, colHeader, rowHeaderLayer, cornerLayer);
// create the table with no scrollbars
NatTable natTable = new NatTable(new Shell(), SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.DOUBLE_BUFFERED, grid);
// this caused a NPE for scrollbar initialization
natTable.setSize(600, 600);
}
Aggregations