use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer in project nebula.widgets.nattable by eclipse.
the class ConfigLabelProviderTest method testProvidedGridLabelsSortHeader.
@Test
public void testProvidedGridLabelsSortHeader() {
SelectionLayer selectionLayer = new SelectionLayer(this.bodyDataLayer);
GridLayer grid = new GridLayer(selectionLayer, new SortHeaderLayer<Person>(new ColumnHeaderLayer(this.columnHeaderDataLayer, this.bodyDataLayer, selectionLayer), new SortModelFixture()), this.rowHeaderDataLayer, this.cornerDataLayer);
Collection<String> labels = grid.getProvidedLabels();
assertEquals(19, labels.size());
assertTrue(labels.contains(GridRegion.CORNER));
assertTrue(labels.contains(GridRegion.COLUMN_HEADER));
assertTrue(labels.contains(GridRegion.ROW_HEADER));
assertTrue(labels.contains(GridRegion.BODY));
assertTrue(labels.contains(AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE));
assertTrue(labels.contains(AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE));
assertTrue(labels.contains(SelectionStyleLabels.SELECTION_ANCHOR_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.SELECTION_ANCHOR_GRID_LINE_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.FILL_HANDLE_CELL));
assertTrue(labels.contains(SelectionStyleLabels.FILL_HANDLE_REGION));
assertTrue(labels.contains(SelectionStyleLabels.COPY_BORDER_STYLE));
assertTrue(labels.contains(DefaultSortConfiguration.SORT_CONFIG_TYPE));
assertTrue(labels.contains(DefaultSortConfiguration.SORT_UP_CONFIG_TYPE));
assertTrue(labels.contains(DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE));
assertTrue(labels.contains(DefaultSortConfiguration.SORT_SEQ_CONFIG_TYPE + "0"));
assertTrue(labels.contains(DefaultSortConfiguration.SORT_SEQ_CONFIG_TYPE + "1"));
assertTrue(labels.contains(DefaultSortConfiguration.SORT_SEQ_CONFIG_TYPE + "2"));
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer in project nebula.widgets.nattable by eclipse.
the class ConfigLabelProviderTest method testProvidedGridLabels.
@Test
public void testProvidedGridLabels() {
GridLayer grid = new GridLayer(this.bodyDataLayer, this.columnHeaderDataLayer, this.rowHeaderDataLayer, this.cornerDataLayer);
Collection<String> labels = grid.getProvidedLabels();
assertEquals(6, labels.size());
assertTrue(labels.contains(GridRegion.CORNER));
assertTrue(labels.contains(GridRegion.COLUMN_HEADER));
assertTrue(labels.contains(GridRegion.ROW_HEADER));
assertTrue(labels.contains(GridRegion.BODY));
assertTrue(labels.contains(AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE));
assertTrue(labels.contains(AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE));
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer in project nebula.widgets.nattable by eclipse.
the class MultiRowResizeCommandTest method testMultiResizeWithDownscaleOnSelection.
@Test
public void testMultiResizeWithDownscaleOnSelection() {
GridLayer gridLayer = new DummyGridLayerStack();
IDpiConverter dpiConverter = new AbstractDpiConverter() {
@Override
protected void readDpiFromDisplay() {
this.dpi = 120;
}
};
gridLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
setClientAreaProvider(gridLayer);
// select columns
gridLayer.doCommand(new SelectColumnCommand(gridLayer, 3, 1, false, false));
gridLayer.doCommand(new SelectColumnCommand(gridLayer, 4, 1, false, true));
gridLayer.doCommand(new SelectColumnCommand(gridLayer, 5, 1, false, true));
// 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));
// select rows
gridLayer.doCommand(new SelectRowsCommand(gridLayer, 1, new int[] { 3, 4, 5 }, false, true, -1));
// resize one of the selected columns
RowResizeCommand columnResizeCommand = new RowResizeCommand(gridLayer, 3, 50, true);
gridLayer.doCommand(columnResizeCommand);
// command executed with down scaling enabled, therefore set height 50
// is first down scaled on setting the value and then up scaled to 50
// again on accessing the height
assertEquals(25, gridLayer.getRowHeightByPosition(2));
assertEquals(50, gridLayer.getRowHeightByPosition(3));
assertEquals(50, gridLayer.getRowHeightByPosition(4));
assertEquals(50, 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 RowSizeConfigurationCommandTest method testSetSizeInGrid.
@Test
public void testSetSizeInGrid() {
GridLayer grid = new DummyGridLayerStack();
assertEquals(20, grid.getColumnHeaderLayer().getRowHeightByPosition(0));
assertEquals(20, grid.getBodyLayer().getRowHeightByPosition(0));
assertEquals(20, grid.getBodyLayer().getRowHeightByPosition(9));
grid.doCommand(new RowSizeConfigurationCommand(null, 50, false));
assertEquals(50, grid.getColumnHeaderLayer().getRowHeightByPosition(0));
assertEquals(50, grid.getBodyLayer().getRowHeightByPosition(0));
assertEquals(50, grid.getBodyLayer().getRowHeightByPosition(9));
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer in project nebula.widgets.nattable by eclipse.
the class AutoResizeColumnsTest method autoResizeOneColumn.
/**
* These sequence of actions were causing a nasty bug in AutoResize
*/
@Test
public void autoResizeOneColumn() throws Exception {
GridLayer gridLayer = new DummyGridLayerStack();
setClientAreaProvider(gridLayer);
// Resize column
gridLayer.doCommand(new ColumnResizeCommand(gridLayer, 2, 10));
assertEquals(10, gridLayer.getColumnWidthByPosition(2));
// Auto resize the one column
InitializeAutoResizeColumnsCommand command = new InitializeAutoResizeColumnsCommand(gridLayer, 2, this.configRegistry, this.gcFactory);
gridLayer.doCommand(command);
// Note: the actual resized width is platform specific (font
// dependency),
// hence we can't compare against a fixed value.
int columnWidth = gridLayer.getColumnWidthByPosition(2);
assertTrue(columnWidth > 10);
// Reorder columns
gridLayer.doCommand(new ColumnReorderCommand(gridLayer, 2, 1));
assertEquals(columnWidth, gridLayer.getColumnWidthByPosition(1));
// Select all columns
gridLayer.doCommand(new SelectAllCommand());
// Resize all selected columns
command = new InitializeAutoResizeColumnsCommand(gridLayer, 1, this.configRegistry, this.gcFactory);
gridLayer.doCommand(command);
for (int columnPosition = 1; columnPosition <= 20; columnPosition++) {
assertTrue("column " + columnPosition + " should have been resized, but it is still its original width", gridLayer.getColumnWidthByPosition(columnPosition) != 100);
}
}
Aggregations