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());
}
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());
}
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());
}
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;
}
Aggregations