List<CdmBase> selection = new ArrayList<>();
int[] fullySelectedRowPositions = bodyLayer.getSelectionLayer().getFullySelectedRowPositions();
for (int i : fullySelectedRowPositions) {
- Object rowObject = bodyDataProvider.getRowObject(i);
+ /*
+ * Differentiation between "index" and "position" is important here
+ * "position" is the current visible index "index" refers to the
+ * underlying data model deleting an entity could lead to an
+ * IndexOutOfBoundExceptions if the position is used
+ */
+ int rowIndexByPosition = natTable.getRowIndexByPosition(i);
+ Object rowObject = bodyDataProvider.getRowObject(rowIndexByPosition);
if(rowObject instanceof CdmBase){
selection.add((CdmBase) rowObject);
}