Search in sources :

Example 1 with RenameColumnHeaderEvent

use of org.eclipse.nebula.widgets.nattable.columnRename.event.RenameColumnHeaderEvent 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 2 with RenameColumnHeaderEvent

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

the class RenameColumnIntegrationTest method shouldRenameColumnHeaderForReorderedColumnProgrammatically.

@Test
public void shouldRenameColumnHeaderForReorderedColumnProgrammatically() {
    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.grid.getColumnHeaderLayer().renameColumnIndex(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) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) Test(org.junit.Test)

Example 3 with RenameColumnHeaderEvent

use of org.eclipse.nebula.widgets.nattable.columnRename.event.RenameColumnHeaderEvent 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)

Example 4 with RenameColumnHeaderEvent

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

the class ColumnHeaderLayer method renameColumnIndex.

public boolean renameColumnIndex(int columnIndex, String customColumnName) {
    boolean renamed = this.renameColumnHelper.renameColumnIndex(columnIndex, customColumnName);
    if (renamed) {
        // search for the bottom layer in the horizontal dependency to
        // create the event for index and correct layer
        ILayer baseLayer = getHorizontalLayerDependency();
        while (baseLayer.getUnderlyingLayerByPosition(0, 0) != null) {
            baseLayer = baseLayer.getUnderlyingLayerByPosition(0, 0);
        }
        baseLayer.fireLayerEvent(new RenameColumnHeaderEvent(baseLayer, columnIndex));
    }
    return renamed;
}
Also used : RenameColumnHeaderEvent(org.eclipse.nebula.widgets.nattable.columnRename.event.RenameColumnHeaderEvent) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer)

Aggregations

RenameColumnHeaderEvent (org.eclipse.nebula.widgets.nattable.columnRename.event.RenameColumnHeaderEvent)4 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)3 Test (org.junit.Test)3 RenameColumnHeaderCommand (org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand)2 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)2 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)1