use of org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture in project nebula.widgets.nattable by eclipse.
the class SummaryRowIntegrationTest method initLayerStackWithSummaryRow.
@Before
public void initLayerStackWithSummaryRow() {
this.dataList = RowDataListFixture.getList().subList(0, 4);
// Rows 0, 1, 2, 3; Summary row would be position 4
assertEquals(4, this.dataList.size());
this.dataProvider = new ListDataProvider<RowDataFixture>(this.dataList, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
IConfigRegistry configRegistry = new ConfigRegistry();
this.dataLayer = new DataLayer(this.dataProvider);
this.summaryRowLayer = new SummaryRowLayer(this.dataLayer, configRegistry);
IUniqueIndexLayer columnReorderLayer = new ColumnReorderLayer(this.summaryRowLayer);
IUniqueIndexLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
IUniqueIndexLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
this.layerStackWithSummary = new ViewportLayer(selectionLayer);
// NatTableFixture initializes the client area
this.natTable = new NatTableFixture(this.layerStackWithSummary, false);
this.natTable.setConfigRegistry(configRegistry);
this.natTable.addConfiguration(new TestSummaryRowConfiguration());
this.natTable.configure();
}
use of org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture in project nebula.widgets.nattable by eclipse.
the class SummaryRowIntegrationTest method rowAddShouldClearCacheAndCalculateNewSummary.
@Test
public void rowAddShouldClearCacheAndCalculateNewSummary() throws Exception {
// Trigger summary calculation
Object askPriceSummary = this.natTable.getDataValueByPosition(this.askPriceColumnIndex, 4);
assertNull(askPriceSummary);
Thread.sleep(100);
// Verify calculated summary value
askPriceSummary = this.natTable.getDataValueByPosition(this.askPriceColumnIndex, 4);
assertEquals("110.0", askPriceSummary.toString());
// Add data and fire event
this.dataList.add(new RowDataFixture("SID", "SDesc", "A", new Date(), new PricingTypeBean("MN"), 2.0, 2.1, 100, true, 3.0, 1.0, 1.0, 1000, 100000, 50000));
this.dataLayer.fireLayerEvent(new RowInsertEvent(this.dataLayer, 4));
// Trigger summary calculation - on the new summary row
askPriceSummary = this.natTable.getDataValueByPosition(this.askPriceColumnIndex, 5);
assertEquals("110.0", askPriceSummary.toString());
Thread.sleep(100);
// Verify summary value is REcalculated
askPriceSummary = this.natTable.getDataValueByPosition(this.askPriceColumnIndex, 5);
assertEquals("112.1", askPriceSummary.toString());
}
use of org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture 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);
}
use of org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture 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));
}
use of org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture in project nebula.widgets.nattable by eclipse.
the class Rendering_cells_as_a_link_and_button method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
this.gridLayer = new SelectionExampleGridLayer();
NatTable natTable = new NatTable(parent, this.gridLayer, false);
IConfigRegistry configRegistry = new ConfigRegistry();
DataLayer bodyDataLayer = this.gridLayer.getBodyDataLayer();
// Step 1: Create a label accumulator - adds custom labels to all cells
// which we wish to render differently. In this case render as a button.
ColumnOverrideLabelAccumulator cellLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyDataLayer);
cellLabelAccumulator.registerColumnOverrides(0, LINK_CELL_LABEL);
cellLabelAccumulator.registerColumnOverrides(2, BUTTON_CELL_LABEL);
// Step 2: Register label accumulator
bodyDataLayer.setConfigLabelAccumulator(cellLabelAccumulator);
// Step 3: Register your custom cell style and , against the
// label applied to the link cell.
LinkClickConfiguration<RowDataFixture> linkClickConfiguration = new LinkClickConfiguration<>();
addLinkToColumn(configRegistry, natTable.getDisplay().getSystemColor(SWT.COLOR_BLUE), linkClickConfiguration);
natTable.addConfiguration(linkClickConfiguration);
// Step 4: Register your custom cell painter, cell style, against the
// label applied to the button cell.
addButtonToColumn(configRegistry);
natTable.addConfiguration(new ButtonClickConfiguration<RowDataFixture>(this.buttonPainter));
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new DebugMenuConfiguration(natTable));
natTable.setConfigRegistry(configRegistry);
natTable.configure();
// Layout SWT widgets. Not relevant to example code.
parent.setLayout(new GridLayout(1, true));
natTable.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
setupTextArea(parent);
return natTable;
}
Aggregations