Search in sources :

Example 26 with DataLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture in project nebula.widgets.nattable by eclipse.

the class MultiColumnReorderEventDiffTest method before.

@Before
public void before() {
    this.dataLayer = new DataLayerFixture(20, 20, 100, 40);
    this.viewportLayer = new ViewportLayer(this.dataLayer);
    this.viewportLayer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 800, 400);
        }
    });
    this.viewportLayer.setOriginX(this.viewportLayer.getStartXOfColumnPosition(2));
    this.viewportLayer.setOriginY(this.viewportLayer.getStartYOfRowPosition(2));
}
Also used : IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) Before(org.junit.Before)

Example 27 with DataLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture in project nebula.widgets.nattable by eclipse.

the class SortStatePersistorTest method setup.

@Before
public void setup() {
    this.properties = new Properties();
    this.sortModel = new SortModelFixture();
    this.sortHeaderLayer = new SortHeaderLayer<RowDataFixture>(new DataLayerFixture(10, 20, 100, 20), this.sortModel);
    this.sortStatePersistor = new SortStatePersistor<RowDataFixture>(this.sortModel);
}
Also used : SortModelFixture(org.eclipse.nebula.widgets.nattable.test.fixture.SortModelFixture) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) Properties(java.util.Properties) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) Before(org.junit.Before)

Example 28 with DataLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture in project nebula.widgets.nattable by eclipse.

the class SortStatePersistorTest method loadStateFromProperties.

/**
 * Save string format: column index : sort direction : sort order |
 */
@Test
public void loadStateFromProperties() throws Exception {
    this.properties.put(KEY, "0:DESC:3|3:ASC:2|5:DESC:1|6:ASC:0|");
    this.sortModel = SortModelFixture.getEmptyModel();
    this.sortHeaderLayer = new SortHeaderLayer<RowDataFixture>(new DataLayerFixture(10, 20, 100, 20), this.sortModel);
    this.sortStatePersistor = new SortStatePersistor<RowDataFixture>(this.sortModel);
    this.sortStatePersistor.loadState(TEST_PREFIX, this.properties);
    ISortModel sortModel = this.sortHeaderLayer.getSortModel();
    // Sort direction
    assertEquals(SortDirectionEnum.DESC, sortModel.getSortDirection(0));
    assertEquals(SortDirectionEnum.ASC, sortModel.getSortDirection(3));
    assertEquals(SortDirectionEnum.DESC, sortModel.getSortDirection(5));
    assertEquals(SortDirectionEnum.ASC, sortModel.getSortDirection(6));
    // Sort order
    assertEquals(3, sortModel.getSortOrder(0));
    assertEquals(2, sortModel.getSortOrder(3));
    assertEquals(1, sortModel.getSortOrder(5));
    assertEquals(0, sortModel.getSortOrder(6));
    // No other columns should be flagged as sorted
    assertEquals(-1, sortModel.getSortOrder(4));
    assertFalse(sortModel.isColumnIndexSorted(4));
    assertEquals(SortDirectionEnum.NONE, sortModel.getSortDirection(4));
}
Also used : DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) ISortModel(org.eclipse.nebula.widgets.nattable.sort.ISortModel) Test(org.junit.Test)

Example 29 with DataLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture in project nebula.widgets.nattable by eclipse.

the class TickUpdateCommandHandlerTest method setup.

@Before
public void setup() {
    DataLayerFixture bodyDataLayer = new DataLayerFixture();
    this.selectionLayer = new SelectionLayer(bodyDataLayer);
    this.selectionLayer.setSelectedCell(1, 1);
    this.testConfigRegistry = new ConfigRegistry();
    this.testConfigRegistry.registerConfigAttribute(TickUpdateConfigAttributes.UPDATE_HANDLER, new TickUpdateHandlerFixture());
    this.testConfigRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE);
    registerCellStyleAccumulators(bodyDataLayer);
    this.commandHandler = new TickUpdateCommandHandler(this.selectionLayer);
}
Also used : ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) TickUpdateHandlerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.TickUpdateHandlerFixture) Before(org.junit.Before)

Example 30 with DataLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture in project nebula.widgets.nattable by eclipse.

the class TickUpdateCommandHandlerTest method registerCellStyleAccumulators.

private void registerCellStyleAccumulators(DataLayer bodyDataLayer) {
    AggregateConfigLabelAccumulator aggregrateConfigLabelAccumulator = new AggregateConfigLabelAccumulator();
    this.columnLabelAccumulator = new ColumnOverrideLabelAccumulator(new DataLayerFixture());
    aggregrateConfigLabelAccumulator.add(this.columnLabelAccumulator, new AlternatingRowConfigLabelAccumulator());
    bodyDataLayer.setConfigLabelAccumulator(aggregrateConfigLabelAccumulator);
}
Also used : DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) ColumnOverrideLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator) AggregateConfigLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.AggregateConfigLabelAccumulator) AlternatingRowConfigLabelAccumulator(org.eclipse.nebula.widgets.nattable.grid.cell.AlternatingRowConfigLabelAccumulator)

Aggregations

DataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture)57 Test (org.junit.Test)28 Before (org.junit.Before)27 BaseDataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture)11 LayerListenerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture)7 Rectangle (org.eclipse.swt.graphics.Rectangle)7 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)6 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)6 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)5 IClientAreaProvider (org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider)5 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)4 ColumnOverrideLabelAccumulator (org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator)3 LayerCommandFixture (org.eclipse.nebula.widgets.nattable.test.fixture.command.LayerCommandFixture)3 ColumnGroupModelFixture (org.eclipse.nebula.widgets.nattable.test.fixture.group.ColumnGroupModelFixture)3 Properties (java.util.Properties)2 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)2 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)2 RowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture)2 ColumnHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer)2 RowHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer)2