use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class ResizeColumnHideShowLayerTest method testHideShowSaveStatePercentageSizingWithoutFixOnResize.
@Test
public void testHideShowSaveStatePercentageSizingWithoutFixOnResize() {
// enable percentage sizing
this.bodyDataLayer.setColumnPercentageSizing(true);
this.bodyDataLayer.setFixColumnPercentageValuesOnResize(false);
this.bodyDataLayer.setDefaultMinColumnWidth(10);
this.bodyDataLayer.setMinColumnWidth(4, 20);
// trigger percentage calculation
ClientAreaResizeCommand resizeCommand = new ClientAreaResizeCommand(null);
resizeCommand.setCalcArea(new Rectangle(0, 0, 500, 500));
this.hideShowLayer.doCommand(resizeCommand);
assertEquals(500, this.hideShowLayer.getWidth());
// this results in 10 percent
this.bodyDataLayer.setColumnWidthByPosition(1, 50);
this.bodyDataLayer.setColumnPositionResizable(4, false);
assertTrue(this.bodyDataLayer.isColumnPositionResizable(1));
assertFalse(this.bodyDataLayer.isColumnPositionResizable(4));
this.hideShowLayer.hideColumnPositions(1, 4);
assertEquals(500, this.hideShowLayer.getWidth());
assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(4));
assertFalse(this.bodyDataLayer.isColumnPositionResizable(1));
assertFalse(this.bodyDataLayer.isColumnPositionResizable(4));
// test save state
Properties props = new Properties();
this.hideShowLayer.saveState("hidden", props);
String hidden = props.getProperty("hidden" + ResizeColumnHideShowLayer.PERSISTENCE_KEY_HIDDEN_COLUMNS);
assertNotNull(hidden);
assertEquals("1:[-1|-1|true|true|10.0],4:[-1|20|false|true|-1.0],", hidden);
}
use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class ResizeColumnHideShowLayerTest method testHideResizeShowDynamicPercentageSizedColumnsWithMinSize.
@Test
public void testHideResizeShowDynamicPercentageSizedColumnsWithMinSize() {
this.bodyDataLayer.setColumnPercentageSizing(true);
this.bodyDataLayer.setDefaultMinColumnWidth(25);
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));
// resize first column to 100
this.bodyDataLayer.setColumnWidthByPosition(0, 100);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(101, this.hideShowLayer.getColumnWidthByPosition(0));
assertEquals(199, 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();
// because of the resize the current visible percentage columns are
// fixed, showing the hidden column again makes it visible, and because
// of the min size config, the other columns are updated to not exceed
// 600
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(96, this.hideShowLayer.getColumnWidthByPosition(0));
assertEquals(191, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(25, this.hideShowLayer.getColumnWidthByPosition(2));
assertEquals(144, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(144, 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 testHideResizeShowSpecificColumn2.
@Test
public void testHideResizeShowSpecificColumn2() {
// the last two columns should take the remaining space
this.bodyDataLayer.setColumnPercentageSizing(3, true);
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(150, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.hideColumnPositions(1);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(4));
// resize a column
this.bodyDataLayer.setColumnWidthByPosition(0, 40);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(260, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.showAllColumns();
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(203, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(157, 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 testHideResizeShowSpecificColumn3.
@Test
public void testHideResizeShowSpecificColumn3() {
// specify a default min width
this.bodyDataLayer.setDefaultMinColumnWidth(25);
// the last two columns should take the remaining space
this.bodyDataLayer.setColumnPercentageSizing(3, true);
this.bodyDataLayer.setColumnPercentageSizing(4, true);
this.bodyDataLayer.setColumnWidthByPosition(1, 300);
ClientAreaResizeCommand cmd = new ClientAreaResizeCommand(null);
cmd.setCalcArea(new Rectangle(0, 0, 600, 100));
this.hideShowLayer.doCommand(cmd);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(50, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(50, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.hideColumnPositions(1);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(4));
// resize a column
this.bodyDataLayer.setColumnWidthByPosition(0, 200);
assertEquals(600, this.hideShowLayer.getWidth());
assertEquals(100, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.showAllColumns();
assertEquals(650, this.hideShowLayer.getWidth());
assertEquals(25, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(25, 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 testColumnPositionAfterHide.
@Test
public void testColumnPositionAfterHide() {
this.bodyDataLayer.setColumnPercentageSizing(true);
ClientAreaResizeCommand cmd = new ClientAreaResizeCommand(null);
cmd.setCalcArea(new Rectangle(0, 0, 1000, 100));
this.hideShowLayer.doCommand(cmd);
assertEquals(1000, this.hideShowLayer.getWidth());
assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(0));
assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(2));
assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(4));
this.hideShowLayer.hideColumnPositions(1, 2, 3);
assertEquals(1000, this.hideShowLayer.getWidth());
assertEquals(500, this.hideShowLayer.getColumnWidthByPosition(0));
assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(2));
assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(3));
assertEquals(500, this.hideShowLayer.getColumnWidthByPosition(4));
assertEquals(0, this.hideShowLayer.getColumnPositionByX(480));
}
Aggregations