use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent in project nebula.widgets.nattable by eclipse.
the class DataChangeLayerTest method shouldUpdateChangeOnColumnInsert.
@Test
public void shouldUpdateChangeOnColumnInsert() {
assertEquals("Simpson", this.dataLayer.getDataValue(1, 2));
this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 2, "Muntz"));
assertEquals("Muntz", this.dataLayer.getDataValue(1, 2));
// simulate column deletion
this.dataLayer.fireLayerEvent(new ColumnInsertEvent(this.dataLayer, 0));
assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 2).hasLabel(DataChangeLayer.DIRTY));
assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(2, 2).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Column 1 is dirty", this.dataChangeLayer.isColumnDirty(1));
assertTrue("Column 2 is not dirty", this.dataChangeLayer.isColumnDirty(2));
assertTrue("Row 2 is not dirty", this.dataChangeLayer.isRowDirty(2));
assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(2, 2));
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());
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent in project nebula.widgets.nattable by eclipse.
the class ColumnHideShowLayerStructuralChangeEventTest method testHandleColumnAddEvent.
@Test
public void testHandleColumnAddEvent() {
// test start order: 0 1 2 3 4
assertEquals(0, this.columnHideShowLayer.getColumnIndexByPosition(0));
assertEquals(1, this.columnHideShowLayer.getColumnIndexByPosition(1));
assertEquals(2, this.columnHideShowLayer.getColumnIndexByPosition(2));
assertEquals(3, this.columnHideShowLayer.getColumnIndexByPosition(3));
assertEquals(4, this.columnHideShowLayer.getColumnIndexByPosition(4));
assertEquals("one", this.columnHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.columnHideShowLayer.getDataValueByPosition(1, 0));
assertEquals("three", this.columnHideShowLayer.getDataValueByPosition(2, 0));
assertEquals("four", this.columnHideShowLayer.getDataValueByPosition(3, 0));
assertEquals("five", this.columnHideShowLayer.getDataValueByPosition(4, 0));
// hide column at position 2: 0 1 3 4
List<Integer> columnsToHide = new ArrayList<Integer>();
columnsToHide.add(2);
this.columnHideShowLayer.hideColumnPositions(columnsToHide);
assertEquals(4, this.columnHideShowLayer.getColumnCount());
assertEquals(0, this.columnHideShowLayer.getColumnIndexByPosition(0));
assertEquals(1, this.columnHideShowLayer.getColumnIndexByPosition(1));
assertEquals(3, this.columnHideShowLayer.getColumnIndexByPosition(2));
assertEquals(4, this.columnHideShowLayer.getColumnIndexByPosition(3));
assertEquals(-1, this.columnHideShowLayer.getColumnIndexByPosition(4));
assertEquals("one", this.columnHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.columnHideShowLayer.getDataValueByPosition(1, 0));
assertEquals("four", this.columnHideShowLayer.getDataValueByPosition(2, 0));
assertEquals("five", this.columnHideShowLayer.getDataValueByPosition(3, 0));
// add column add index 2
this.contents.get(0).add(2, "test");
this.underlyingLayer.fireLayerEvent(new ColumnInsertEvent(this.underlyingLayer, 2));
assertEquals(5, this.columnHideShowLayer.getColumnCount());
assertEquals(0, this.columnHideShowLayer.getColumnIndexByPosition(0));
assertEquals(1, this.columnHideShowLayer.getColumnIndexByPosition(1));
assertEquals(2, this.columnHideShowLayer.getColumnIndexByPosition(2));
assertEquals(4, this.columnHideShowLayer.getColumnIndexByPosition(3));
assertEquals(5, this.columnHideShowLayer.getColumnIndexByPosition(4));
assertEquals(-1, this.columnHideShowLayer.getColumnIndexByPosition(5));
assertEquals("one", this.columnHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.columnHideShowLayer.getDataValueByPosition(1, 0));
assertEquals("test", this.columnHideShowLayer.getDataValueByPosition(2, 0));
assertEquals("four", this.columnHideShowLayer.getDataValueByPosition(3, 0));
assertEquals("five", this.columnHideShowLayer.getDataValueByPosition(4, 0));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent in project nebula.widgets.nattable by eclipse.
the class ColumnReorderLayerStructuralChangeEventTest method testHandleColumnAddEvent.
@Test
public void testHandleColumnAddEvent() {
// test start order: 0 1 2 3
assertEquals(0, this.columnReorderLayer.getColumnIndexByPosition(0));
assertEquals(1, this.columnReorderLayer.getColumnIndexByPosition(1));
assertEquals(2, this.columnReorderLayer.getColumnIndexByPosition(2));
assertEquals(3, this.columnReorderLayer.getColumnIndexByPosition(3));
assertEquals("one", this.columnReorderLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.columnReorderLayer.getDataValueByPosition(1, 0));
assertEquals("three", this.columnReorderLayer.getDataValueByPosition(2, 0));
assertEquals("four", this.columnReorderLayer.getDataValueByPosition(3, 0));
// reorder to inverse order: 3 2 1 0
this.columnReorderLayer.reorderColumnPosition(3, 0);
this.columnReorderLayer.reorderColumnPosition(3, 1);
this.columnReorderLayer.reorderColumnPosition(3, 2);
assertEquals(3, this.columnReorderLayer.getColumnIndexByPosition(0));
assertEquals(2, this.columnReorderLayer.getColumnIndexByPosition(1));
assertEquals(1, this.columnReorderLayer.getColumnIndexByPosition(2));
assertEquals(0, this.columnReorderLayer.getColumnIndexByPosition(3));
assertEquals("four", this.columnReorderLayer.getDataValueByPosition(0, 0));
assertEquals("three", this.columnReorderLayer.getDataValueByPosition(1, 0));
assertEquals("two", this.columnReorderLayer.getDataValueByPosition(2, 0));
assertEquals("one", this.columnReorderLayer.getDataValueByPosition(3, 0));
// add row add index 2
this.contents.get(0).add(2, "test");
this.underlyingLayer.fireLayerEvent(new ColumnInsertEvent(this.underlyingLayer, 2));
assertEquals(4, this.columnReorderLayer.getColumnIndexByPosition(0));
assertEquals(3, this.columnReorderLayer.getColumnIndexByPosition(1));
assertEquals(2, this.columnReorderLayer.getColumnIndexByPosition(2));
assertEquals(1, this.columnReorderLayer.getColumnIndexByPosition(3));
assertEquals(0, this.columnReorderLayer.getColumnIndexByPosition(4));
assertEquals("four", this.columnReorderLayer.getDataValueByPosition(0, 0));
assertEquals("three", this.columnReorderLayer.getDataValueByPosition(1, 0));
assertEquals("test", this.columnReorderLayer.getDataValueByPosition(2, 0));
assertEquals("two", this.columnReorderLayer.getDataValueByPosition(3, 0));
assertEquals("one", this.columnReorderLayer.getDataValueByPosition(4, 0));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent 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());
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent in project nebula.widgets.nattable by eclipse.
the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateHiddenOnInsert.
@Test
public void shouldUpdateHiddenOnInsert() {
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());
}
Aggregations