Search in sources :

Example 36 with DataLayer

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()));
}
Also used : DummyBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) Test(org.junit.Test)

Example 37 with DataLayer

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);
}
Also used : DummyBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) Test(org.junit.Test)

Example 38 with DataLayer

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()));
}
Also used : DummyBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) Test(org.junit.Test)

Example 39 with DataLayer

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()));
}
Also used : DummyBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) Test(org.junit.Test)

Example 40 with DataLayer

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);
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) ArrayList(java.util.ArrayList) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) DummyColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummyColumnHeaderDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) Shell(org.eclipse.swt.widgets.Shell) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) Test(org.junit.Test)

Aggregations

DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)227 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)150 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)99 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)96 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)93 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)91 HashMap (java.util.HashMap)83 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)82 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)78 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)77 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)77 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)76 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)75 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)75 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)74 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)74 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)70 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)64 Test (org.junit.Test)62 GridLayout (org.eclipse.swt.layout.GridLayout)56