use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent in project nebula.widgets.nattable by eclipse.
the class DataChangeLayerIdIndexTest 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());
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent in project nebula.widgets.nattable by eclipse.
the class ColumnHideShowLayerStructuralChangeEventTest method testHandleColumnDeleteEvent.
@Test
public void testHandleColumnDeleteEvent() {
// 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));
// delete column index 1: value "two")
this.contents.get(0).remove(1);
this.underlyingLayer.fireLayerEvent(new ColumnDeleteEvent(this.underlyingLayer, 1));
assertEquals(3, this.columnHideShowLayer.getColumnCount());
assertEquals(0, this.columnHideShowLayer.getColumnIndexByPosition(0));
assertEquals(2, this.columnHideShowLayer.getColumnIndexByPosition(1));
assertEquals(3, this.columnHideShowLayer.getColumnIndexByPosition(2));
assertEquals(-1, this.columnHideShowLayer.getColumnIndexByPosition(3));
assertEquals("one", this.columnHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("four", this.columnHideShowLayer.getDataValueByPosition(1, 0));
assertEquals("five", this.columnHideShowLayer.getDataValueByPosition(2, 0));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent in project nebula.widgets.nattable by eclipse.
the class ColumnHideShowLayerStructuralChangeEventTest method testHandleMultipleColumnDeleteEvent.
@Test
public void testHandleMultipleColumnDeleteEvent() {
// 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));
// delete columns in the middle
this.contents.get(0).remove(1);
this.contents.get(0).remove(1);
this.contents.get(0).remove(1);
this.underlyingLayer.fireLayerEvent(new ColumnDeleteEvent(this.underlyingLayer, new Range(1, 4)));
assertEquals(2, this.columnHideShowLayer.getColumnCount());
assertEquals(0, this.columnHideShowLayer.getColumnIndexByPosition(0));
assertEquals(1, this.columnHideShowLayer.getColumnIndexByPosition(1));
assertEquals(-1, this.columnHideShowLayer.getColumnIndexByPosition(2));
assertEquals("one", this.columnHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("five", this.columnHideShowLayer.getDataValueByPosition(1, 0));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent in project nebula.widgets.nattable by eclipse.
the class ColumnReorderLayerStructuralChangeEventTest method testHandleLastColumnDeleteEvent.
@Test
public void testHandleLastColumnDeleteEvent() {
// 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));
// delete last column
int lastColumnIndex = this.contents.get(0).size() - 1;
this.contents.get(0).remove(lastColumnIndex);
this.underlyingLayer.fireLayerEvent(new ColumnDeleteEvent(this.underlyingLayer, lastColumnIndex));
assertEquals(2, this.columnReorderLayer.getColumnIndexByPosition(0));
assertEquals(1, this.columnReorderLayer.getColumnIndexByPosition(1));
assertEquals(0, this.columnReorderLayer.getColumnIndexByPosition(2));
assertEquals(-1, this.columnReorderLayer.getColumnIndexByPosition(3));
assertEquals("three", this.columnReorderLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.columnReorderLayer.getDataValueByPosition(1, 0));
assertEquals("one", this.columnReorderLayer.getDataValueByPosition(2, 0));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent in project nebula.widgets.nattable by eclipse.
the class ColumnReorderLayerStructuralChangeEventTest method testHandleMultipleColumnDeleteEvent.
@Test
public void testHandleMultipleColumnDeleteEvent() {
// 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));
// delete columns in the middle
this.contents.get(0).remove(1);
this.contents.get(0).remove(1);
this.underlyingLayer.fireLayerEvent(new ColumnDeleteEvent(this.underlyingLayer, new Range(1, 3)));
assertEquals(2, this.columnReorderLayer.getColumnCount());
assertEquals(1, this.columnReorderLayer.getColumnIndexByPosition(0));
assertEquals(0, this.columnReorderLayer.getColumnIndexByPosition(1));
assertEquals(-1, this.columnReorderLayer.getColumnIndexByPosition(2));
assertEquals("four", this.columnReorderLayer.getDataValueByPosition(0, 0));
assertEquals("one", this.columnReorderLayer.getDataValueByPosition(1, 0));
}
Aggregations