Search in sources :

Example 6 with RowInsertEvent

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

the class RowStructuralChangeEventIntegrationTest method shouldUpdateOnInsertAndDelete.

@Test
public void shouldUpdateOnInsertAndDelete() {
    this.contents.add("six");
    this.underlyingLayer.fireLayerEvent(new RowInsertEvent(this.underlyingLayer, 5));
    this.viewportLayer.doCommand(new RowReorderCommand(this.viewportLayer, 3, 6));
    this.viewportLayer.doCommand(new RowReorderCommand(this.viewportLayer, 3, 5));
    this.viewportLayer.doCommand(new MultiRowHideCommand(this.viewportLayer, new int[] { 2, 3, 5 }));
    assertEquals("[0, 1, 2, 5, 4, 3]", this.rowReorderLayer.getRowIndexOrder().toString());
    assertEquals("[2, 3, 5]", this.rowHideShowLayer.getHiddenRowIndexes().toString());
    this.contents.add(3, "test");
    this.underlyingLayer.fireLayerEvent(new RowInsertEvent(this.underlyingLayer, 3));
    assertEquals("[0, 1, 2, 3, 6, 5, 4]", this.rowReorderLayer.getRowIndexOrder().toString());
    assertEquals("[2, 4, 6]", this.rowHideShowLayer.getHiddenRowIndexes().toString());
    this.contents.remove(3);
    this.underlyingLayer.fireLayerEvent(new RowDeleteEvent(this.underlyingLayer, 3));
    assertEquals("[0, 1, 2, 5, 4, 3]", this.rowReorderLayer.getRowIndexOrder().toString());
    assertEquals("[2, 3, 5]", this.rowHideShowLayer.getHiddenRowIndexes().toString());
}
Also used : RowInsertEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowInsertEvent) MultiRowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiRowHideCommand) RowDeleteEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent) RowReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.RowReorderCommand) Test(org.junit.Test)

Example 7 with RowInsertEvent

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

the class DataChangeLayerTest method shouldUpdateOnMultiRowInsert.

@Test
public void shouldUpdateOnMultiRowInsert() {
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, "Lovejoy"));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 3, "Lovejoy"));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 5, "Lovejoy"));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 7, "Lovejoy"));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 9, "Lovejoy"));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 0));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 1));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 2));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 3));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 4));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 5));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 6));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 7));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 8));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 9));
    this.dataModel.add(9, new Person(44, "Nelson", "Muntz", Gender.MALE, false, new Date(), 100d));
    this.dataModel.add(7, new Person(43, "Nelson", "Muntz", Gender.MALE, false, new Date(), 100d));
    this.dataModel.add(5, new Person(42, "Nelson", "Muntz", Gender.MALE, false, new Date(), 100d));
    this.dataModel.add(3, new Person(41, "Nelson", "Muntz", Gender.MALE, false, new Date(), 100d));
    this.dataModel.add(1, new Person(40, "Nelson", "Muntz", Gender.MALE, false, new Date(), 100d));
    this.dataLayer.fireLayerEvent(new RowInsertEvent(this.dataLayer, new Range(1, 1), new Range(3, 3), new Range(5, 5), new Range(7, 7), new Range(9, 9)));
    assertEquals(23, this.dataModel.size());
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 0));
    assertEquals("Muntz", this.dataLayer.getDataValue(1, 1));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 2));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 3));
    assertEquals("Muntz", this.dataLayer.getDataValue(1, 4));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 5));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 6));
    assertEquals("Muntz", this.dataLayer.getDataValue(1, 7));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 8));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 9));
    assertEquals("Muntz", this.dataLayer.getDataValue(1, 10));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 11));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 12));
    assertEquals("Muntz", this.dataLayer.getDataValue(1, 13));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 14));
    assertEquals("Simpson", this.dataChangeLayer.getDataValueByPosition(1, 0));
    assertEquals("Muntz", this.dataChangeLayer.getDataValueByPosition(1, 1));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 2));
    assertEquals("Simpson", this.dataChangeLayer.getDataValueByPosition(1, 3));
    assertEquals("Muntz", this.dataChangeLayer.getDataValueByPosition(1, 4));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 5));
    assertEquals("Simpson", this.dataChangeLayer.getDataValueByPosition(1, 6));
    assertEquals("Muntz", this.dataChangeLayer.getDataValueByPosition(1, 7));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 8));
    assertEquals("Simpson", this.dataChangeLayer.getDataValueByPosition(1, 9));
    assertEquals("Muntz", this.dataChangeLayer.getDataValueByPosition(1, 10));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 11));
    assertEquals("Simpson", this.dataChangeLayer.getDataValueByPosition(1, 12));
    assertEquals("Muntz", this.dataChangeLayer.getDataValueByPosition(1, 13));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 14));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 0).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 1).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 2).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 3).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 4).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 5).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 6).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 7).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 8).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 9).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 10).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 11).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 12).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 13).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 14).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 15).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Column 1 is not dirty", this.dataChangeLayer.isColumnDirty(1));
    assertFalse("Row 0 is not dirty", this.dataChangeLayer.isRowDirty(0));
    assertFalse("Row 1 is not dirty", this.dataChangeLayer.isRowDirty(1));
    assertTrue("Row 2 is not dirty", this.dataChangeLayer.isRowDirty(2));
    assertFalse("Row 3 is not dirty", this.dataChangeLayer.isRowDirty(3));
    assertFalse("Row 4 is not dirty", this.dataChangeLayer.isRowDirty(4));
    assertTrue("Row 5 is not dirty", this.dataChangeLayer.isRowDirty(5));
    assertFalse("Row 6 is not dirty", this.dataChangeLayer.isRowDirty(6));
    assertFalse("Row 7 is not dirty", this.dataChangeLayer.isRowDirty(7));
    assertTrue("Row 8 is not dirty", this.dataChangeLayer.isRowDirty(8));
    assertFalse("Row 9 is not dirty", this.dataChangeLayer.isRowDirty(9));
    assertFalse("Row 10 is not dirty", this.dataChangeLayer.isRowDirty(10));
    assertTrue("Row 11 is not dirty", this.dataChangeLayer.isRowDirty(11));
    assertFalse("Row 12 is not dirty", this.dataChangeLayer.isRowDirty(12));
    assertFalse("Row 13 is not dirty", this.dataChangeLayer.isRowDirty(13));
    assertTrue("Row 14 is not dirty", this.dataChangeLayer.isRowDirty(14));
    assertFalse("Row 15 is not dirty", this.dataChangeLayer.isRowDirty(15));
    assertFalse("Row 16 is not dirty", this.dataChangeLayer.isRowDirty(16));
    assertFalse("Row 17 is not dirty", this.dataChangeLayer.isRowDirty(17));
    assertFalse("Row 18 is not dirty", this.dataChangeLayer.isRowDirty(18));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 2));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 5));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 8));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 11));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 14));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 4));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(0, 2));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(2, 3));
    assertFalse("changed columns are empty", this.dataChangeLayer.changedColumns.isEmpty());
    assertFalse("changed rows are empty", this.dataChangeLayer.changedRows.isEmpty());
    assertFalse("changes are empty", this.dataChangeLayer.dataChanges.isEmpty());
}
Also used : RowInsertEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowInsertEvent) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person) Date(java.util.Date) Test(org.junit.Test)

Example 8 with RowInsertEvent

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

the class DataChangeLayerTest method shouldUpdateChangeOnRowInsert.

@Test
public void shouldUpdateChangeOnRowInsert() {
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 2, "Lovejoy"));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 2));
    // input a new row
    this.dataModel.add(2, new Person(40, "Nelson", "Muntz", Gender.MALE, false, new Date(), 100d));
    this.dataLayer.fireLayerEvent(new RowInsertEvent(this.dataLayer, 2));
    assertEquals("Muntz", this.dataLayer.getDataValue(1, 2));
    assertEquals("Muntz", this.dataChangeLayer.getDataValueByPosition(1, 2));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 3));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 3));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 2).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Row 1 is dirty", this.dataChangeLayer.isRowDirty(2));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 2));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 3).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Column 1 is not dirty", this.dataChangeLayer.isColumnDirty(1));
    assertTrue("Row 1 is not dirty", this.dataChangeLayer.isRowDirty(3));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 3));
    assertFalse("changed columns are empty", this.dataChangeLayer.changedColumns.isEmpty());
    assertFalse("changed rows are empty", this.dataChangeLayer.changedRows.isEmpty());
    assertFalse("changes are empty", this.dataChangeLayer.dataChanges.isEmpty());
}
Also used : RowInsertEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowInsertEvent) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person) Date(java.util.Date) Test(org.junit.Test)

Example 9 with RowInsertEvent

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

the class DataChangeLayerIdIndexTest method shouldUpdateChangeOnRowInsert.

@Test
public void shouldUpdateChangeOnRowInsert() {
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 2, "Lovejoy"));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 2));
    // input a new row
    this.dataModel.add(2, new Person(40, "Nelson", "Muntz", Gender.MALE, false, new Date(), 100d));
    this.dataLayer.fireLayerEvent(new RowInsertEvent(this.dataLayer, 2));
    assertEquals("Muntz", this.dataLayer.getDataValue(1, 2));
    assertEquals("Muntz", this.dataChangeLayer.getDataValueByPosition(1, 2));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 3));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 3));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 2).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Row 1 is dirty", this.dataChangeLayer.isRowDirty(2));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 2));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 3).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Column 1 is not dirty", this.dataChangeLayer.isColumnDirty(1));
    assertTrue("Row 1 is not dirty", this.dataChangeLayer.isRowDirty(3));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 3));
    assertFalse("changed columns are empty", this.dataChangeLayer.changedColumns.isEmpty());
    assertFalse("changed rows are empty", this.dataChangeLayer.changedRows.isEmpty());
    assertFalse("changes are empty", this.dataChangeLayer.dataChanges.isEmpty());
}
Also used : RowInsertEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowInsertEvent) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person) Date(java.util.Date) Test(org.junit.Test)

Aggregations

RowInsertEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowInsertEvent)9 Test (org.junit.Test)9 Date (java.util.Date)5 Person (org.eclipse.nebula.widgets.nattable.dataset.person.Person)4 UpdateDataCommand (org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand)4 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)3 ArrayList (java.util.ArrayList)2 RowDeleteEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent)2 PricingTypeBean (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.PricingTypeBean)1 RowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture)1 FreezeRowCommand (org.eclipse.nebula.widgets.nattable.freeze.command.FreezeRowCommand)1 MultiRowHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.MultiRowHideCommand)1 RowReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.RowReorderCommand)1