use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class ResizeColumnHideShowLayerTest method testHideResizeShowFixedPercentageSizedColumns.
@Test
public void testHideResizeShowFixedPercentageSizedColumns() {
this.bodyDataLayer.setColumnWidthPercentageByPosition(0, 15);
this.bodyDataLayer.setColumnWidthPercentageByPosition(1, 15);
this.bodyDataLayer.setColumnWidthPercentageByPosition(2, 15);
this.bodyDataLayer.setColumnWidthPercentageByPosition(3, 15);
this.bodyDataLayer.setColumnWidthPercentageByPosition(4, 40);
ClientAreaResizeCommand cmd = new ClientAreaResizeCommand(null);
cmd.setCalcArea(new Rectangle(0, 0, 600, 100));
this.hideShowLayer.doCommand(cmd);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(0));
assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(2));
assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(240, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.hideColumnPositions(1, 2);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(129, this.hideShowLayer.getColumnWidthByPosition(0));
assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(2));
assertEquals(129, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(342, this.hideShowLayer.getColumnWidthByPosition(4));
// resize a column - minor rounding issues in double to int
this.bodyDataLayer.setColumnWidthByPosition(0, 99);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(100, this.hideShowLayer.getColumnWidthByPosition(0));
assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(2));
assertEquals(159, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(341, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.showAllColumns();
// with some rounding issues and corrections this will be the result
// at least all columns in an appropriate ratio are visible again
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(77, this.hideShowLayer.getColumnWidthByPosition(0));
assertEquals(70, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(69, this.hideShowLayer.getColumnWidthByPosition(2));
assertEquals(122, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(262, this.hideShowLayer.getColumnWidthByPosition(4));
}
use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class RowSizeConfigurationCommandTest method testSetPercentage.
@Test
public void testSetPercentage() {
assertEquals(20, this.dataLayer.getRowHeightByPosition(0));
assertEquals(20, this.dataLayer.getRowHeightByPosition(1));
assertEquals(20, this.dataLayer.getRowHeightByPosition(2));
assertEquals(20, this.dataLayer.getRowHeightByPosition(3));
this.dataLayer.doCommand(new RowSizeConfigurationCommand("ROW_0", 100, false));
this.dataLayer.doCommand(new RowSizeConfigurationCommand("ROW_1", 100, false));
this.dataLayer.doCommand(new RowSizeConfigurationCommand("ROW_2", null, true));
this.dataLayer.doCommand(new RowSizeConfigurationCommand("ROW_3", null, true));
// recalculate percentages
ClientAreaResizeCommand resizeCommand = new ClientAreaResizeCommand(null);
resizeCommand.setCalcArea(new Rectangle(0, 0, 500, 500));
this.dataLayer.doCommand(resizeCommand);
assertEquals(100, this.dataLayer.getRowHeightByPosition(0));
assertEquals(100, this.dataLayer.getRowHeightByPosition(1));
assertEquals(150, this.dataLayer.getRowHeightByPosition(2));
assertEquals(150, this.dataLayer.getRowHeightByPosition(3));
}
use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class RowSizeConfigurationCommandTest method testPercentageSizing.
@Test
public void testPercentageSizing() {
assertEquals(20, this.dataLayer.getRowHeightByPosition(0));
assertEquals(20, this.dataLayer.getRowHeightByPosition(1));
assertEquals(20, this.dataLayer.getRowHeightByPosition(2));
assertEquals(20, this.dataLayer.getRowHeightByPosition(3));
RowSizeConfigurationCommand command = new RowSizeConfigurationCommand(null, null, true);
this.dataLayer.doCommand(command);
// recalculate percentages
ClientAreaResizeCommand resizeCommand = new ClientAreaResizeCommand(null);
resizeCommand.setCalcArea(new Rectangle(0, 0, 500, 500));
this.dataLayer.doCommand(resizeCommand);
assertEquals(125, this.dataLayer.getRowHeightByPosition(0));
assertEquals(125, this.dataLayer.getRowHeightByPosition(1));
assertEquals(125, this.dataLayer.getRowHeightByPosition(2));
assertEquals(125, this.dataLayer.getRowHeightByPosition(3));
}
use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class SearchGridCommandHandlerTest method setUp.
@Before
public void setUp() {
this.gridLayer = new GridLayerFixture();
this.gridLayer.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
return new Rectangle(0, 0, 1050, 250);
}
});
this.gridLayer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.V_SCROLL | SWT.H_SCROLL)));
this.configRegistry = new ConfigRegistry();
new DefaultNatTableStyleConfiguration().configureRegistry(this.configRegistry);
this.commandHandler = new SearchGridCellsCommandHandler(this.gridLayer.getBodyLayer().getSelectionLayer());
selectCell(3, 3);
}
use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class ColumnSizeConfigurationCommandTest method testSetPercentage.
@Test
public void testSetPercentage() {
assertEquals(100, this.dataLayer.getColumnWidthByPosition(0));
assertEquals(100, this.dataLayer.getColumnWidthByPosition(1));
assertEquals(100, this.dataLayer.getColumnWidthByPosition(2));
assertEquals(100, this.dataLayer.getColumnWidthByPosition(3));
this.dataLayer.doCommand(new ColumnSizeConfigurationCommand("COLUMN_0", 100, false));
this.dataLayer.doCommand(new ColumnSizeConfigurationCommand("COLUMN_1", 100, false));
this.dataLayer.doCommand(new ColumnSizeConfigurationCommand("COLUMN_2", null, true));
this.dataLayer.doCommand(new ColumnSizeConfigurationCommand("COLUMN_3", null, true));
// recalculate percentages
ClientAreaResizeCommand resizeCommand = new ClientAreaResizeCommand(null);
resizeCommand.setCalcArea(new Rectangle(0, 0, 500, 500));
this.dataLayer.doCommand(resizeCommand);
assertEquals(100, this.dataLayer.getColumnWidthByPosition(0));
assertEquals(100, this.dataLayer.getColumnWidthByPosition(1));
assertEquals(150, this.dataLayer.getColumnWidthByPosition(2));
assertEquals(150, this.dataLayer.getColumnWidthByPosition(3));
}
Aggregations