Search in sources :

Example 1 with RenameColumnHeaderCommand

use of org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand in project nebula.widgets.nattable by eclipse.

the class RenameColumnIntegrationTest method shouldUpdateRenamedColumnOnDeleteMultipleColumnRanges.

@Test
public void shouldUpdateRenamedColumnOnDeleteMultipleColumnRanges() {
    assertEquals("Column 5", this.natTableFixture.getDataValueByPosition(5, 0).toString());
    this.natTableFixture.doCommand(new RenameColumnHeaderCommand(this.natTableFixture, 5, TEST_COLUMN_NAME));
    assertEquals(TEST_COLUMN_NAME, this.natTableFixture.getDataValueByPosition(5, 0).toString());
    // simulate deletion of a column
    this.provider.setColumnCount(this.provider.getColumnCount() - 3);
    this.grid.getColumnHeaderDataLayer().fireLayerEvent(new ColumnDeleteEvent(this.grid.getBodyDataLayer(), new Range(1, 3), new Range(6, 7)));
    assertEquals(TEST_COLUMN_NAME, this.natTableFixture.getDataValueByPosition(3, 0).toString());
    assertEquals("Column 5", this.natTableFixture.getDataValueByPosition(5, 0).toString());
}
Also used : ColumnDeleteEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent) RenameColumnHeaderCommand(org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) Test(org.junit.Test)

Example 2 with RenameColumnHeaderCommand

use of org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand in project nebula.widgets.nattable by eclipse.

the class RenameColumnIntegrationTest method shouldUpdateRenamedColumnOnDeleteOneColumn.

@Test
public void shouldUpdateRenamedColumnOnDeleteOneColumn() {
    assertEquals("Column 5", this.natTableFixture.getDataValueByPosition(5, 0).toString());
    this.natTableFixture.doCommand(new RenameColumnHeaderCommand(this.natTableFixture, 5, TEST_COLUMN_NAME));
    assertEquals(TEST_COLUMN_NAME, this.natTableFixture.getDataValueByPosition(5, 0).toString());
    // simulate deletion of a column
    this.provider.setColumnCount(this.provider.getColumnCount() - 1);
    this.grid.getColumnHeaderDataLayer().fireLayerEvent(new ColumnDeleteEvent(this.grid.getBodyDataLayer(), 0));
    assertEquals(TEST_COLUMN_NAME, this.natTableFixture.getDataValueByPosition(4, 0).toString());
    assertEquals("Column 5", this.natTableFixture.getDataValueByPosition(5, 0).toString());
}
Also used : ColumnDeleteEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent) RenameColumnHeaderCommand(org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand) Test(org.junit.Test)

Example 3 with RenameColumnHeaderCommand

use of org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand in project nebula.widgets.nattable by eclipse.

the class RenameColumnIntegrationTest method shouldUpdateRenamedColumnOnAddingMultipleColumnRanges.

@Test
public void shouldUpdateRenamedColumnOnAddingMultipleColumnRanges() {
    this.natTableFixture.doCommand(new TurnViewportOffCommand());
    assertEquals("Column 5", this.natTableFixture.getDataValueByPosition(5, 0).toString());
    this.natTableFixture.doCommand(new RenameColumnHeaderCommand(this.natTableFixture, 5, TEST_COLUMN_NAME));
    assertEquals(TEST_COLUMN_NAME, this.natTableFixture.getDataValueByPosition(5, 0).toString());
    // simulate deletion of a column
    this.provider.setColumnCount(this.provider.getColumnCount() + 3);
    this.grid.getColumnHeaderDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), new Range(1, 3), new Range(7, 8)));
    assertEquals(TEST_COLUMN_NAME, this.natTableFixture.getDataValueByPosition(7, 0).toString());
    assertEquals("Column 5", this.natTableFixture.getDataValueByPosition(5, 0).toString());
}
Also used : RenameColumnHeaderCommand(org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand) ColumnInsertEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) TurnViewportOffCommand(org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOffCommand) Test(org.junit.Test)

Example 4 with RenameColumnHeaderCommand

use of org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand in project nebula.widgets.nattable by eclipse.

the class RenameColumnIntegrationTest method shouldRenameColumnHeader.

@Test
public void shouldRenameColumnHeader() {
    String originalColumnHeader = this.natTableFixture.getDataValueByPosition(2, 0).toString();
    assertEquals("Column 2", originalColumnHeader);
    this.natTableFixture.doCommand(new RenameColumnHeaderCommand(this.natTableFixture, 2, TEST_COLUMN_NAME));
    String renamedColumnHeader = this.natTableFixture.getDataValueByPosition(2, 0).toString();
    assertEquals(TEST_COLUMN_NAME, renamedColumnHeader);
    assertEquals(1, this.listener.getEventsCount());
    RenameColumnHeaderEvent event = (RenameColumnHeaderEvent) this.listener.getReceivedEvent(RenameColumnHeaderEvent.class);
    assertEquals(new Range(2, 3), event.getColumnPositionRanges().iterator().next());
}
Also used : RenameColumnHeaderEvent(org.eclipse.nebula.widgets.nattable.columnRename.event.RenameColumnHeaderEvent) RenameColumnHeaderCommand(org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) Test(org.junit.Test)

Example 5 with RenameColumnHeaderCommand

use of org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand in project nebula.widgets.nattable by eclipse.

the class RenameColumnIntegrationTest method shouldRenameColumnHeaderForReorderedColumn.

@Test
public void shouldRenameColumnHeaderForReorderedColumn() {
    String originalColumnHeader = this.natTableFixture.getDataValueByPosition(2, 0).toString();
    assertEquals("Column 2", originalColumnHeader);
    this.natTableFixture.doCommand(new ColumnReorderCommand(this.natTableFixture, 1, 5));
    originalColumnHeader = this.natTableFixture.getDataValueByPosition(2, 0).toString();
    assertEquals("Column 3", originalColumnHeader);
    this.natTableFixture.doCommand(new RenameColumnHeaderCommand(this.natTableFixture, 2, TEST_COLUMN_NAME));
    String renamedColumnHeader = this.natTableFixture.getDataValueByPosition(2, 0).toString();
    assertEquals(TEST_COLUMN_NAME, renamedColumnHeader);
    assertEquals(2, this.listener.getEventsCount());
    RenameColumnHeaderEvent event = (RenameColumnHeaderEvent) this.listener.getReceivedEvent(RenameColumnHeaderEvent.class);
    assertEquals(new Range(2, 3), event.getColumnPositionRanges().iterator().next());
}
Also used : RenameColumnHeaderEvent(org.eclipse.nebula.widgets.nattable.columnRename.event.RenameColumnHeaderEvent) RenameColumnHeaderCommand(org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) Test(org.junit.Test)

Aggregations

RenameColumnHeaderCommand (org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand)8 Test (org.junit.Test)8 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)6 ColumnDeleteEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent)3 ColumnInsertEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent)3 RenameColumnHeaderEvent (org.eclipse.nebula.widgets.nattable.columnRename.event.RenameColumnHeaderEvent)2 TurnViewportOffCommand (org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOffCommand)2 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)1