use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupReorderLayerTest method shouldDragRightAndNotRemoveFromAnUnbreakableGroup.
@Test
public void shouldDragRightAndNotRemoveFromAnUnbreakableGroup() {
assertEquals(2, getColumnIndexesInGroup(0).size());
setGroupUnBreakable(0);
this.layer.doCommand(new ColumnReorderCommand(this.layer, 0, 1));
assertEquals(2, getColumnIndexesInGroup(0).size());
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupReorderLayerTest method shouldMoveInAndOutGroupsByOneStepUp.
@Test
public void shouldMoveInAndOutGroupsByOneStepUp() {
this.modelFixture.addColumnsIndexesToGroup("G4", 7, 8, 9);
assertEquals("G3", this.modelFixture.getColumnGroupByIndex(10).getName());
ColumnReorderCommand command = new ColumnReorderCommand(this.layer, 10, 9);
this.layer.doCommand(command);
assertNull(this.modelFixture.getColumnGroupByIndex(10));
this.layer.doCommand(command);
assertEquals("G4", this.modelFixture.getColumnGroupByIndex(10).getName());
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand 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);
}
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ReorderColumnCommandTest method testReorderColumnCommand.
@Test
public void testReorderColumnCommand() {
int fromColumnPosition = 4;
int toColumnPosition = 1;
ILayerCommand reorderColumnCommand = new ColumnReorderCommand(this.columnReorderLayer, fromColumnPosition, toColumnPosition);
this.columnReorderLayer.doCommand(reorderColumnCommand);
Assert.assertEquals(0, this.columnReorderLayer.getColumnIndexByPosition(0));
Assert.assertEquals(4, this.columnReorderLayer.getColumnIndexByPosition(1));
Assert.assertEquals(1, this.columnReorderLayer.getColumnIndexByPosition(2));
Assert.assertEquals(2, this.columnReorderLayer.getColumnIndexByPosition(3));
Assert.assertEquals(3, this.columnReorderLayer.getColumnIndexByPosition(4));
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class PersistenceIntegrationTest method saveStateToPropeties.
public void saveStateToPropeties() throws Exception {
// Resize column 2 to 200px
assertEquals(100, this.natTableFixture.getColumnWidthByPosition(2));
this.natTableFixture.doCommand(new ColumnResizeCommand(this.natTableFixture, 2, 200));
assertEquals(200, this.natTableFixture.getColumnWidthByPosition(2));
// Resize row 2 to 100px
assertEquals(20, this.natTableFixture.getRowHeightByPosition(2));
this.natTableFixture.doCommand(new RowResizeCommand(this.natTableFixture, 2, 100));
assertEquals(100, this.natTableFixture.getRowHeightByPosition(2));
// Reorder column 1 --> 5 (grid coordinates)
// 0, 1, 2, 3, 4, 5,.. --> 1, 2, 3, 0, 4, 5,..
assertEquals(0, this.natTableFixture.getColumnIndexByPosition(1));
this.natTableFixture.doCommand(new ColumnReorderCommand(this.natTableFixture, 1, 5));
assertEquals(1, this.natTableFixture.getColumnIndexByPosition(1));
// Reorder row 1 --> 5 (grid coordinates)
// 0, 1, 2, 3, 4, 5,.. --> 1, 2, 3, 0, 4, 5,..
assertEquals(0, this.natTableFixture.getRowIndexByPosition(1));
this.natTableFixture.doCommand(new RowReorderCommand(this.natTableFixture, 1, 5));
assertEquals(1, this.natTableFixture.getRowIndexByPosition(1));
// Hide column with index 3 (grid coordinates)
assertEquals(3, this.natTableFixture.getColumnIndexByPosition(3));
this.natTableFixture.doCommand(new ColumnHideCommand(this.natTableFixture, 3));
assertEquals(0, this.natTableFixture.getColumnIndexByPosition(3));
this.natTableFixture.saveState(TEST_PERSISTENCE_PREFIX, this.properties);
// Ensure that properties got persisted
assertEquals("true", this.properties.get("testPrefix.COLUMN_HEADER.columnWidth.resizableByDefault"));
assertEquals("100", this.properties.get("testPrefix.COLUMN_HEADER.columnWidth.defaultSize"));
assertEquals("true", this.properties.get("testPrefix.COLUMN_HEADER.rowHeight.resizableByDefault"));
assertEquals("40", this.properties.get("testPrefix.ROW_HEADER.columnWidth.defaultSize"));
assertEquals("true", this.properties.get("testPrefix.ROW_HEADER.rowHeight.resizableByDefault"));
assertEquals("true", this.properties.get("testPrefix.ROW_HEADER.columnWidth.resizableByDefault"));
assertEquals("40", this.properties.get("testPrefix.ROW_HEADER.rowHeight.defaultSize"));
assertEquals("20", this.properties.get("testPrefix.CORNER.rowHeight.defaultSize"));
assertEquals("true", this.properties.get("testPrefix.CORNER.columnWidth.resizableByDefault"));
assertEquals("true", this.properties.get("testPrefix.CORNER.rowHeight.resizableByDefault"));
assertEquals("20", this.properties.get("testPrefix.BODY.rowHeight.defaultSize"));
assertEquals("true", this.properties.get("testPrefix.BODY.rowHeight.resizableByDefault"));
assertEquals("true", this.properties.get("testPrefix.BODY.columnWidth.resizableByDefault"));
assertEquals("1,2,3,0,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,", this.properties.get("testPrefix.BODY.columnIndexOrder"));
assertEquals("1:100,", this.properties.get("testPrefix.BODY.rowHeight.sizes"));
assertEquals("1:200,", this.properties.get("testPrefix.BODY.columnWidth.sizes"));
}
Aggregations