use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer in project nebula.widgets.nattable by eclipse.
the class ColumnSizeConfigurationCommandTest method testSetSizeInGrid.
@Test
public void testSetSizeInGrid() {
GridLayer grid = new DummyGridLayerStack();
assertEquals(40, grid.getRowHeaderLayer().getColumnWidthByPosition(0));
assertEquals(100, grid.getBodyLayer().getColumnWidthByPosition(0));
assertEquals(100, grid.getBodyLayer().getColumnWidthByPosition(9));
grid.doCommand(new ColumnSizeConfigurationCommand(null, 150, false));
assertEquals(150, grid.getRowHeaderLayer().getColumnWidthByPosition(0));
assertEquals(150, grid.getBodyLayer().getColumnWidthByPosition(0));
assertEquals(150, grid.getBodyLayer().getColumnWidthByPosition(9));
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer in project nebula.widgets.nattable by eclipse.
the class ColumnSizeConfigurationCommandTest method testSetSizeInBodyRegion.
@Test
public void testSetSizeInBodyRegion() {
GridLayer grid = new DummyGridLayerStack();
assertEquals(40, grid.getRowHeaderLayer().getColumnWidthByPosition(0));
assertEquals(100, grid.getBodyLayer().getColumnWidthByPosition(0));
assertEquals(100, grid.getBodyLayer().getColumnWidthByPosition(9));
grid.doCommand(new ColumnSizeConfigurationCommand(GridRegion.BODY, 150, false));
assertEquals(40, grid.getRowHeaderLayer().getColumnWidthByPosition(0));
assertEquals(150, grid.getBodyLayer().getColumnWidthByPosition(0));
assertEquals(150, grid.getBodyLayer().getColumnWidthByPosition(9));
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer in project nebula.widgets.nattable by eclipse.
the class MultiColumnResizeCommandTest method testMultiResizeWithoutDownscale.
@Test
public void testMultiResizeWithoutDownscale() {
GridLayer gridLayer = new DummyGridLayerStack();
IDpiConverter dpiConverter = new AbstractDpiConverter() {
@Override
protected void readDpiFromDisplay() {
this.dpi = 120;
}
};
gridLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
setClientAreaProvider(gridLayer);
// scaling enabled, therefore default width of 100 pixels is up scaled
// to 125
assertEquals(125, gridLayer.getColumnWidthByPosition(2));
assertEquals(125, gridLayer.getColumnWidthByPosition(3));
assertEquals(125, gridLayer.getColumnWidthByPosition(4));
assertEquals(125, gridLayer.getColumnWidthByPosition(5));
assertEquals(125, gridLayer.getColumnWidthByPosition(6));
MultiColumnResizeCommand resizeCommand = new MultiColumnResizeCommand(gridLayer, new int[] { 3, 4, 5 }, 150);
gridLayer.doCommand(resizeCommand);
// command executed with down scaling disabled, therefore set width 150
// is up scaled to 188
assertEquals(125, gridLayer.getColumnWidthByPosition(2));
assertEquals(188, gridLayer.getColumnWidthByPosition(3));
assertEquals(188, gridLayer.getColumnWidthByPosition(4));
assertEquals(188, gridLayer.getColumnWidthByPosition(5));
assertEquals(125, gridLayer.getColumnWidthByPosition(6));
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer in project nebula.widgets.nattable by eclipse.
the class MultiRowResizeCommandTest method testMultiResizeWithoutDownscale.
@Test
public void testMultiResizeWithoutDownscale() {
GridLayer gridLayer = new DummyGridLayerStack();
IDpiConverter dpiConverter = new AbstractDpiConverter() {
@Override
protected void readDpiFromDisplay() {
this.dpi = 120;
}
};
gridLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
setClientAreaProvider(gridLayer);
// scaling enabled, therefore default height of 20 pixels is up scaled
// to 25
assertEquals(25, gridLayer.getRowHeightByPosition(2));
assertEquals(25, gridLayer.getRowHeightByPosition(3));
assertEquals(25, gridLayer.getRowHeightByPosition(4));
assertEquals(25, gridLayer.getRowHeightByPosition(5));
assertEquals(25, gridLayer.getRowHeightByPosition(6));
MultiRowResizeCommand resizeCommand = new MultiRowResizeCommand(gridLayer, new int[] { 3, 4, 5 }, 50);
gridLayer.doCommand(resizeCommand);
// command executed with down scaling disabled, therefore set height 50
// is up scaled to 63
assertEquals(25, gridLayer.getRowHeightByPosition(2));
assertEquals(63, gridLayer.getRowHeightByPosition(3));
assertEquals(63, gridLayer.getRowHeightByPosition(4));
assertEquals(63, gridLayer.getRowHeightByPosition(5));
assertEquals(25, gridLayer.getRowHeightByPosition(6));
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer 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);
}
Aggregations