Search in sources :

Example 6 with ColumnDeleteEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent 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 7 with ColumnDeleteEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent 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 8 with ColumnDeleteEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent in project nebula.widgets.nattable by eclipse.

the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateHiddenOnInsertAndDelete.

@Test
public void shouldUpdateHiddenOnInsertAndDelete() {
    DefaultBodyLayerStack body = this.grid.getBodyLayer();
    ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer();
    body.doCommand(new MultiColumnHideCommand(body, new int[] { 2, 3, 5 }));
    assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
    this.provider.setColumnCount(7);
    this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
    assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString());
    this.provider.setColumnCount(6);
    this.grid.getBodyDataLayer().fireLayerEvent(new ColumnDeleteEvent(this.grid.getBodyDataLayer(), 3));
    assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
}
Also used : ColumnDeleteEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) ColumnInsertEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 9 with ColumnDeleteEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent in project nebula.widgets.nattable by eclipse.

the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateOnInsertAndDelete.

@Test
public void shouldUpdateOnInsertAndDelete() {
    DefaultBodyLayerStack body = this.grid.getBodyLayer();
    ColumnReorderLayer reorderLayer = body.getColumnReorderLayer();
    ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer();
    body.doCommand(new ColumnReorderCommand(body, 3, 6));
    body.doCommand(new ColumnReorderCommand(body, 3, 5));
    body.doCommand(new MultiColumnHideCommand(body, new int[] { 2, 3, 5 }));
    assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
    assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
    this.provider.setColumnCount(7);
    this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
    assertEquals("[0, 1, 2, 3, 6, 5, 4]", reorderLayer.getColumnIndexOrder().toString());
    assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString());
    this.provider.setColumnCount(6);
    this.grid.getBodyDataLayer().fireLayerEvent(new ColumnDeleteEvent(this.grid.getBodyDataLayer(), 3));
    assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
    assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
}
Also used : ColumnDeleteEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) ColumnInsertEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 10 with ColumnDeleteEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent in project nebula.widgets.nattable by eclipse.

the class DataChangeLayerTest method shouldRemoveChangeOnColumnDelete.

@Test
public void shouldRemoveChangeOnColumnDelete() {
    assertEquals("Homer", this.dataLayer.getDataValue(0, 2));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 0, 2, "Nelson"));
    assertEquals("Nelson", this.dataLayer.getDataValue(0, 2));
    // simulate column deletion
    this.dataLayer.fireLayerEvent(new ColumnDeleteEvent(this.dataLayer, 0));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 2).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Column 1 is dirty", this.dataChangeLayer.isColumnDirty(1));
    assertFalse("Row 2 is dirty", this.dataChangeLayer.isRowDirty(2));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 2));
    assertTrue("changed columns are not empty", this.dataChangeLayer.changedColumns.isEmpty());
    assertTrue("changed rows are not empty", this.dataChangeLayer.changedRows.isEmpty());
    assertTrue("changes are not empty", this.dataChangeLayer.dataChanges.isEmpty());
}
Also used : ColumnDeleteEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Test(org.junit.Test)

Aggregations

ColumnDeleteEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent)17 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)4 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)4 UpdateDataCommand (org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand)4 RenameColumnHeaderCommand (org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand)3 ColumnInsertEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent)3 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)3 ColumnHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer)2 MultiColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand)2 ColumnReorderLayer (org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer)2 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)2