Search in sources :

Example 16 with ColumnReorderCommand

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());
}
Also used : ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) MultiColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand) Test(org.junit.Test)

Example 17 with ColumnReorderCommand

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());
}
Also used : ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) MultiColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand) Test(org.junit.Test)

Example 18 with ColumnReorderCommand

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);
    }
}
Also used : ColumnResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand) SelectAllCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectAllCommand) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) InitializeAutoResizeColumnsCommand(org.eclipse.nebula.widgets.nattable.resize.command.InitializeAutoResizeColumnsCommand) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultGridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) Test(org.junit.Test)

Example 19 with ColumnReorderCommand

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));
}
Also used : ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) ILayerCommand(org.eclipse.nebula.widgets.nattable.command.ILayerCommand) Test(org.junit.Test)

Example 20 with ColumnReorderCommand

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"));
}
Also used : ColumnResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand) ColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand) RowResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) RowReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.RowReorderCommand)

Aggregations

ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)42 Test (org.junit.Test)39 MultiColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand)22 ColumnInsertEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent)4 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)4 ColumnReorderLayer (org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer)4 ColumnResizeCommand (org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand)3 RenameColumnHeaderEvent (org.eclipse.nebula.widgets.nattable.columnRename.event.RenameColumnHeaderEvent)2 ILayerCommand (org.eclipse.nebula.widgets.nattable.command.ILayerCommand)2 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)2 ClientAreaResizeCommand (org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand)2 ColumnHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer)2 ColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand)2 MultiColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand)2 ColumnDeleteEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent)2 SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 RenameColumnHeaderCommand (org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand)1