use of org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer in project nebula.widgets.nattable by eclipse.
the class GridLayerTest method initBodyLayer.
// **** New tests using fixtures ****
/**
* @see ViewportLayerFixture#DEFAULT_CLIENT_AREA
*/
@Test
public void initBodyLayer() throws Exception {
DefaultGridLayer gridLayer = new GridLayerFixture();
ViewportLayer viewport = gridLayer.getBodyLayer().getViewportLayer();
viewport.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
return new Rectangle(0, 0, 160, 80);
}
});
// Client area gets init when this command is fired
gridLayer.doCommand(new InitializeClientAreaCommandFixture());
Assert.assertEquals(160, viewport.getClientAreaWidth());
Assert.assertEquals(80, viewport.getClientAreaHeight());
Assert.assertEquals(160, viewport.getWidth());
Assert.assertEquals(80, viewport.getHeight());
}
use of org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer in project nebula.widgets.nattable by eclipse.
the class EditTraversalStrategyLeftRightTest method setUp.
@Before
public void setUp() {
this.dataLayer = new DataLayerFixture(10, 10, 100, 20);
this.selectionLayer = new SelectionLayer(this.dataLayer);
this.viewportLayer = new ViewportLayer(this.selectionLayer);
this.viewportLayer.setRegionName(GridRegion.BODY);
this.viewportLayer.addConfiguration(new DefaultEditBindings());
this.viewportLayer.addConfiguration(new DefaultEditConfiguration());
this.natTable = new NatTableFixture(this.viewportLayer);
this.natTable.enableEditingOnAllCells();
this.natTable.getConfigRegistry().registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.NEVER_EDITABLE, DisplayMode.EDIT, NOT_EDITABLE);
this.natTable.getConfigRegistry().registerConfigAttribute(EditConfigAttributes.OPEN_ADJACENT_EDITOR, Boolean.TRUE);
this.natTable.registerLabelOnColumn(this.dataLayer, 2, NOT_EDITABLE);
this.natTable.registerLabelOnColumn(this.dataLayer, 5, NOT_EDITABLE);
this.natTable.registerLabelOnColumn(this.dataLayer, 6, NOT_EDITABLE);
this.natTable.registerLabelOnColumn(this.dataLayer, 7, NOT_EDITABLE);
this.natTable.registerLabelOnColumn(this.dataLayer, 8, NOT_EDITABLE);
this.natTable.registerLabelOnColumn(this.dataLayer, 9, NOT_EDITABLE);
}
use of org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer in project nebula.widgets.nattable by eclipse.
the class EditTraversalStrategyUpDownTest 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<>(RowDataListFixture.getList(10), new ReflectiveColumnPropertyAccessor<RowDataFixture>(propertyNames));
this.dataLayer = new DataLayer(bodyDataProvider, 20, 20);
this.selectionLayer = new SelectionLayer(this.dataLayer);
this.viewportLayer = new ViewportLayer(this.selectionLayer);
this.viewportLayer.setRegionName(GridRegion.BODY);
this.viewportLayer.addConfiguration(new DefaultEditBindings());
this.viewportLayer.addConfiguration(new DefaultEditConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new TextCellEditor(true, true));
configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, new DefaultDataValidator());
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultBooleanDisplayConverter(), DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 9);
}
});
this.natTable = new NatTableFixture(this.viewportLayer);
this.natTable.enableEditingOnAllCells();
this.natTable.getConfigRegistry().registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.NEVER_EDITABLE, DisplayMode.EDIT, NOT_EDITABLE);
this.natTable.getConfigRegistry().registerConfigAttribute(EditConfigAttributes.OPEN_ADJACENT_EDITOR, Boolean.TRUE);
// register non editable rows
this.overrider = new RowOverrideLabelAccumulator<>(bodyDataProvider, new IRowIdAccessor<RowDataFixture>() {
@Override
public Serializable getRowId(RowDataFixture rowObject) {
return rowObject.getSecurity_id();
}
});
this.overrider.registerRowOverrides(2, NOT_EDITABLE);
this.overrider.registerRowOverrides(5, NOT_EDITABLE);
this.overrider.registerRowOverrides(6, NOT_EDITABLE);
this.overrider.registerRowOverrides(7, NOT_EDITABLE);
this.overrider.registerRowOverrides(8, NOT_EDITABLE);
this.overrider.registerRowOverrides(9, NOT_EDITABLE);
AggregateConfigLabelAccumulator accumulator = new AggregateConfigLabelAccumulator();
accumulator.add(this.overrider);
accumulator.add(new ColumnLabelAccumulator());
this.dataLayer.setConfigLabelAccumulator(accumulator);
}
use of org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer in project nebula.widgets.nattable by eclipse.
the class EditIntegrationTest method updateAllUnderlyingCellsIfSpanned.
@Test
public void updateAllUnderlyingCellsIfSpanned() throws Exception {
CompositeLayer layer = new CompositeLayer(1, 1);
DummySpanningBodyDataProvider dataProvider = new DummySpanningBodyDataProvider(100, 100);
SelectionLayer selectionLayer = new SelectionLayer(new SpanningDataLayer(dataProvider));
layer.setChildLayer(GridRegion.BODY, new ViewportLayer(selectionLayer), 0, 0);
this.natTable = new NatTableFixture(layer, 1200, 300, false);
layer.addConfiguration(new DefaultEditBindings());
layer.addConfiguration(new DefaultEditConfiguration());
this.natTable.enableEditingOnAllCells();
this.natTable.configure();
assertEquals("Col: 1, Row: 1", dataProvider.getDataValue(0, 0));
assertEquals("Col: 1, Row: 2", dataProvider.getDataValue(0, 1));
assertEquals("Col: 2, Row: 1", dataProvider.getDataValue(1, 0));
assertEquals("Col: 2, Row: 2", dataProvider.getDataValue(1, 1));
this.natTable.doCommand(new SelectCellCommand(this.natTable, 1, 1, false, false));
this.natTable.notifyListeners(SWT.KeyDown, SWTUtils.keyEventWithChar('C'));
assertNotNull(this.natTable.getActiveCellEditor());
this.natTable.getActiveCellEditor().getEditorControl().notifyListeners(SWT.KeyDown, SWTUtils.keyEvent(SWT.CR));
assertEquals("C", dataProvider.getDataValue(0, 0));
assertEquals("C", dataProvider.getDataValue(0, 1));
assertEquals("C", dataProvider.getDataValue(1, 0));
assertEquals("C", dataProvider.getDataValue(1, 1));
}
use of org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer in project nebula.widgets.nattable by eclipse.
the class RowStructuralChangeEventIntegrationTest method setUp.
@Before
public void setUp() {
this.contents = new ArrayList<String>(Arrays.asList("one", "two", "three", "four", "five"));
IDataProvider bodyDataProvider = new ListDataProvider<String>(this.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;
}
});
this.underlyingLayer = new DataLayer(bodyDataProvider);
this.rowReorderLayer = new RowReorderLayer(this.underlyingLayer);
this.rowHideShowLayer = new RowHideShowLayer(this.rowReorderLayer);
this.selectionLayer = new SelectionLayer(this.rowHideShowLayer);
this.viewportLayer = new ViewportLayer(this.selectionLayer);
IDataProvider colDataProvider = new DummyColumnHeaderDataProvider(bodyDataProvider);
ColumnHeaderLayer colHeader = new ColumnHeaderLayer(new DataLayer(colDataProvider), this.viewportLayer, this.selectionLayer);
IDataProvider rowDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(new DataLayer(rowDataProvider), this.viewportLayer, this.selectionLayer);
CornerLayer cornerLayer = new CornerLayer(new DataLayer(new DefaultCornerDataProvider(colDataProvider, rowDataProvider)), rowHeaderLayer, colHeader);
GridLayer grid = new GridLayer(this.viewportLayer, colHeader, rowHeaderLayer, cornerLayer);
this.natTable = new NatTable(new Shell(), grid);
this.natTable.setSize(600, 600);
}
Aggregations