Search in sources :

Example 1 with IRowIdAccessor

use of org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor in project nebula.widgets.nattable by eclipse.

the class BlinkLayerTest method setUp.

@Before
public void setUp() {
    this.display = Display.getDefault();
    this.dataList = new LinkedList<BlinkingRowDataFixture>();
    IColumnPropertyAccessor<BlinkingRowDataFixture> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<BlinkingRowDataFixture>(RowDataListFixture.getPropertyNames());
    this.listDataProvider = new ListDataProvider<BlinkingRowDataFixture>(this.dataList, columnPropertyAccessor);
    this.propertyChangeListener = getPropertyChangeListener();
    this.dataLayer = new DataLayer(this.listDataProvider);
    this.layerUnderTest = new BlinkLayer<BlinkingRowDataFixture>(this.dataLayer, this.listDataProvider, new IRowIdAccessor<BlinkingRowDataFixture>() {

        @Override
        public Serializable getRowId(BlinkingRowDataFixture rowObject) {
            return rowObject.getSecurity_id();
        }
    }, columnPropertyAccessor, this.configRegistry);
    this.layerUnderTest.blinkingEnabled = true;
    registerBlinkConfigTypes();
    load10Rows();
}
Also used : BlinkingRowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.BlinkingRowDataFixture) IRowIdAccessor(org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) Before(org.junit.Before)

Example 2 with IRowIdAccessor

use of org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor in project nebula.widgets.nattable by eclipse.

the class RowSelectionEditUtilsTest method setup.

@Before
public void setup() {
    List<RowDataFixture> listFixture = RowDataListFixture.getList(10);
    IRowDataProvider<RowDataFixture> bodyDataProvider = new ListDataProvider<RowDataFixture>(listFixture, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
    this.gridLayerStack = new GridLayerFixture(bodyDataProvider);
    this.selectionLayer = this.gridLayerStack.getBodyLayer().getSelectionLayer();
    this.selectionLayer.setSelectionModel(new RowSelectionModel<RowDataFixture>(this.selectionLayer, bodyDataProvider, new IRowIdAccessor<RowDataFixture>() {

        @Override
        public Serializable getRowId(RowDataFixture rowObject) {
            return rowObject.getSecurity_id();
        }
    }));
    this.natTable = new NatTableFixture(this.gridLayerStack);
    // Ensure no active editor (static) is present
    // Although deprecated this needs to still work for backwards
    // compatibility
    assertNull(ActiveCellEditorRegistry.getActiveCellEditor());
}
Also used : IRowIdAccessor(org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor) ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) GridLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture) Before(org.junit.Before)

Example 3 with IRowIdAccessor

use of org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor in project nebula.widgets.nattable by eclipse.

the class ColumnGroupHeaderLayerSelectionTest method shouldMoveAnchorOnDeselectWithCtrlWithPreserve.

@Test
public void shouldMoveAnchorOnDeselectWithCtrlWithPreserve() {
    this.gridLayer.getBodyLayer().getSelectionLayer().setSelectionModel(new PreserveSelectionModel<>(this.gridLayer.getBodyLayer().getSelectionLayer(), this.dataProvider, new IRowIdAccessor<NumberValues>() {

        @Override
        public Serializable getRowId(NumberValues rowObject) {
            return rowObject.getColumnOneNumber();
        }
    }));
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 2, 0, false, false));
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 6, 0, false, true));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(0));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(1));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(2));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
    PositionCoordinate selectionAnchor = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectionAnchor();
    assertEquals(0, selectionAnchor.getRowPosition());
    assertEquals(5, selectionAnchor.getColumnPosition());
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 6, 0, false, true));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(0));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(1));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(2));
    assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
    assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
    selectionAnchor = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectionAnchor();
    assertEquals(0, selectionAnchor.getRowPosition());
    assertEquals(0, selectionAnchor.getColumnPosition());
}
Also used : IRowIdAccessor(org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor) ViewportSelectColumnGroupCommand(org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) NumberValues(org.eclipse.nebula.widgets.nattable.dataset.NumberValues) Test(org.junit.Test)

Example 4 with IRowIdAccessor

use of org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor in project nebula.widgets.nattable by eclipse.

the class RowSelectionModelStructuralChangeEventHandlerTest method setup.

@Before
public void setup() {
    this.listFixture = RowDataListFixture.getList(10);
    this.bodyDataProvider = new ListDataProvider<RowDataFixture>(this.listFixture, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
    GridLayerFixture gridLayer = new GridLayerFixture(this.bodyDataProvider);
    this.nattable = new NatTableFixture(gridLayer, false);
    this.bodyDataLayer = (DataLayer) gridLayer.getBodyDataLayer();
    this.selectionLayer = gridLayer.getBodyLayer().getSelectionLayer();
    this.selectionLayer.setSelectionModel(new RowSelectionModel<RowDataFixture>(this.selectionLayer, this.bodyDataProvider, new IRowIdAccessor<RowDataFixture>() {

        @Override
        public Serializable getRowId(RowDataFixture rowObject) {
            return rowObject.getSecurity_id();
        }
    }));
    this.listener = new LayerListenerFixture();
    // we register the listener to the SelectionLayer because for some cases
    // like clearing a collection, the selection change is not propagated
    // the layer stack upwards as it gets stopped on layer conversion
    this.selectionLayer.addLayerListener(this.listener);
}
Also used : IRowIdAccessor(org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) GridLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) Before(org.junit.Before)

Example 5 with IRowIdAccessor

use of org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor in project nebula.widgets.nattable by eclipse.

the class RowSelectionTraversalTest method setUp.

@Before
public void setUp() {
    // only use 10 columns to make the test cases easier
    String[] propertyNames = Arrays.copyOfRange(RowDataListFixture.getPropertyNames(), 0, 10);
    IRowDataProvider<RowDataFixture> bodyDataProvider = new ListDataProvider<RowDataFixture>(RowDataListFixture.getList(10), new ReflectiveColumnPropertyAccessor<RowDataFixture>(propertyNames));
    this.selectionLayer = new SelectionLayer(new DataLayer(bodyDataProvider));
    this.selectionLayer.setSelectionModel(new RowSelectionModel<RowDataFixture>(this.selectionLayer, bodyDataProvider, new IRowIdAccessor<RowDataFixture>() {

        @Override
        public Serializable getRowId(RowDataFixture rowObject) {
            return rowObject.getSecurity_id();
        }
    }));
    this.viewportLayer = new ViewportLayer(this.selectionLayer);
}
Also used : IRowIdAccessor(org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor) ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) Before(org.junit.Before)

Aggregations

IRowIdAccessor (org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor)14 RowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture)8 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)7 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)7 Before (org.junit.Before)7 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)6 ReflectiveColumnPropertyAccessor (org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor)6 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)6 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)6 HashMap (java.util.HashMap)4 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)4 Person (org.eclipse.nebula.widgets.nattable.dataset.person.Person)4 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)4 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)4 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)4 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)3 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)2 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)2