use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class ResizeColumnHideShowLayerTest method testHideShowPercentageSizedColumns.
// test hide with percentage sized columns (not fixed values)
@Test
public void testHideShowPercentageSizedColumns() {
this.bodyDataLayer.setColumnPercentageSizing(true);
ClientAreaResizeCommand cmd = new ClientAreaResizeCommand(null);
cmd.setCalcArea(new Rectangle(0, 0, 600, 100));
this.hideShowLayer.doCommand(cmd);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(0));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(2));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.hideColumnPositions(2);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(0));
assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(2));
assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.showAllColumns();
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(0));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(2));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(4));
}
use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class ResizeColumnHideShowLayerTest method testHideShowFixedPercentageSizedColumns.
// test hide with all percentage with fixed percentage values
@Test
public void testHideShowFixedPercentageSizedColumns() {
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));
this.hideShowLayer.showAllColumns();
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));
}
use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class ResizeColumnHideShowLayerTest method testHideShowPercentageSizedColumnsAndDefaultMinWidth.
@Test
public void testHideShowPercentageSizedColumnsAndDefaultMinWidth() {
this.bodyDataLayer.setColumnPercentageSizing(true);
this.bodyDataLayer.setDefaultMinColumnWidth(10);
ClientAreaResizeCommand cmd = new ClientAreaResizeCommand(null);
cmd.setCalcArea(new Rectangle(0, 0, 600, 100));
this.hideShowLayer.doCommand(cmd);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(0));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(2));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.hideColumnPositions(2);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(0));
assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(2));
assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.showAllColumns();
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(0));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(2));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(4));
}
use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class ResizeColumnHideShowLayerTest method testHideShowDefaultColumnWithPercentageLastColumn.
// test hide with mixed sized where last column
// should take remaining space
@Test
public void testHideShowDefaultColumnWithPercentageLastColumn() {
// the last column should take the remaining space
this.bodyDataLayer.setColumnPercentageSizing(4, true);
ClientAreaResizeCommand cmd = new ClientAreaResizeCommand(null);
cmd.setCalcArea(new Rectangle(0, 0, 600, 100));
this.hideShowLayer.doCommand(cmd);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.hideColumnPositions(1);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(300, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.showAllColumns();
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(4));
}
use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class ResizeColumnHideShowLayerTest method testHideResizeShowSpecificColumn.
@Test
public void testHideResizeShowSpecificColumn() {
// change width of the column that gets hidden
this.bodyDataLayer.setColumnWidthByPosition(1, 50);
// the last column should take the remaining space
this.bodyDataLayer.setColumnPercentageSizing(4, true);
ClientAreaResizeCommand cmd = new ClientAreaResizeCommand(null);
cmd.setCalcArea(new Rectangle(0, 0, 600, 100));
this.hideShowLayer.doCommand(cmd);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(250, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.hideColumnPositions(1);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(300, this.hideShowLayer.getColumnWidthByPosition(4));
// resize a column
this.bodyDataLayer.setColumnWidthByPosition(0, 50);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(350, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.showAllColumns();
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(300, this.hideShowLayer.getColumnWidthByPosition(4));
}
Aggregations