use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent in project nebula.widgets.nattable by eclipse.
the class DataChangeLayerIdIndexTest method shouldUpdateChangeOnColumnDelete.
@Test
public void shouldUpdateChangeOnColumnDelete() {
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 ColumnDeleteEvent(this.dataLayer, 0));
assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 2).hasLabel(DataChangeLayer.DIRTY));
assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(0, 2).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Column 1 is dirty", this.dataChangeLayer.isColumnDirty(1));
assertTrue("Column 0 is not dirty", this.dataChangeLayer.isColumnDirty(0));
assertTrue("Row 2 is not dirty", this.dataChangeLayer.isRowDirty(2));
assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(0, 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.ColumnDeleteEvent in project nebula.widgets.nattable by eclipse.
the class DataChangeLayerTest method shouldUpdateChangeOnColumnDelete.
@Test
public void shouldUpdateChangeOnColumnDelete() {
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 ColumnDeleteEvent(this.dataLayer, 0));
assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 2).hasLabel(DataChangeLayer.DIRTY));
assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(0, 2).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Column 1 is dirty", this.dataChangeLayer.isColumnDirty(1));
assertTrue("Column 0 is not dirty", this.dataChangeLayer.isColumnDirty(0));
assertTrue("Row 2 is not dirty", this.dataChangeLayer.isRowDirty(2));
assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(0, 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.ColumnDeleteEvent in project nebula.widgets.nattable by eclipse.
the class ColumnHideShowLayerStructuralChangeEventTest method testHandleHiddenColumnDeleteEvent.
@Test
public void testHandleHiddenColumnDeleteEvent() {
// 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 2: value "three"
this.contents.get(0).remove(2);
this.underlyingLayer.fireLayerEvent(new ColumnDeleteEvent(this.underlyingLayer, 2));
assertEquals(4, this.columnHideShowLayer.getColumnCount());
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(-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));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent in project nebula.widgets.nattable by eclipse.
the class ColumnHideShowLayerStructuralChangeEventTest method testHandleLastColumnDeleteEvent.
@Test
public void testHandleLastColumnDeleteEvent() {
// 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 last column in list
int lastColumnIndex = this.contents.get(0).size() - 1;
this.contents.get(0).remove(lastColumnIndex);
this.underlyingLayer.fireLayerEvent(new ColumnDeleteEvent(this.underlyingLayer, lastColumnIndex));
assertEquals(3, this.columnHideShowLayer.getColumnCount());
assertEquals(0, this.columnHideShowLayer.getColumnIndexByPosition(0));
assertEquals(1, this.columnHideShowLayer.getColumnIndexByPosition(1));
assertEquals(3, this.columnHideShowLayer.getColumnIndexByPosition(2));
assertEquals(-1, this.columnHideShowLayer.getColumnIndexByPosition(3));
assertEquals("one", this.columnHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.columnHideShowLayer.getDataValueByPosition(1, 0));
assertEquals("four", this.columnHideShowLayer.getDataValueByPosition(2, 0));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent in project nebula.widgets.nattable by eclipse.
the class ColumnReorderLayerStructuralChangeEventTest method testHandleColumnDeleteEvent.
@Test
public void testHandleColumnDeleteEvent() {
// 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 column position 1 (index 2: value "three")
this.contents.get(0).remove(2);
this.underlyingLayer.fireLayerEvent(new ColumnDeleteEvent(this.underlyingLayer, 2));
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("four", this.columnReorderLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.columnReorderLayer.getDataValueByPosition(1, 0));
assertEquals("one", this.columnReorderLayer.getDataValueByPosition(2, 0));
}
Aggregations