use of org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData in project scout.rt by eclipse.
the class AbstractTable method importFromTableRowBeanData.
public void importFromTableRowBeanData(List<? extends AbstractTableRowData> rowDatas, Class<? extends AbstractTableRowData> rowType) {
discardAllDeletedRows();
int deleteCount = 0;
List<ITableRow> newRows = new ArrayList<ITableRow>(rowDatas.size());
ITableRowDataMapper mapper = createTableRowDataMapper(rowType);
for (int i = 0, ni = rowDatas.size(); i < ni; i++) {
AbstractTableRowData rowData = rowDatas.get(i);
if (rowData.getRowState() != AbstractTableRowData.STATUS_DELETED && mapper.acceptImport(rowData)) {
ITableRow newTableRow = new TableRow(getColumnSet());
mapper.importTableRowData(newTableRow, rowData);
newRows.add(newTableRow);
} else {
deleteCount++;
}
}
replaceRows(newRows);
if (deleteCount > 0) {
try {
setTableChanging(true);
//
for (int i = 0, ni = rowDatas.size(); i < ni; i++) {
AbstractTableRowData rowData = rowDatas.get(i);
if (rowData.getRowState() == AbstractTableRowData.STATUS_DELETED && mapper.acceptImport(rowData)) {
ITableRow newTableRow = new TableRow(getColumnSet());
mapper.importTableRowData(newTableRow, rowData);
newTableRow.setStatus(ITableRow.STATUS_NON_CHANGED);
ITableRow addedRow = addRow(newTableRow);
deleteRow(addedRow);
}
}
} finally {
setTableChanging(false);
}
}
}
use of org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData in project scout.rt by eclipse.
the class AbstractTable method exportToTableBeanData.
@Override
public void exportToTableBeanData(AbstractTableFieldBeanData target) {
ITableRowDataMapper rowMapper = createTableRowDataMapper(target.getRowType());
for (int i = 0, ni = getRowCount(); i < ni; i++) {
ITableRow row = getRow(i);
if (rowMapper.acceptExport(row)) {
AbstractTableRowData rowData = target.addRow();
rowMapper.exportTableRowData(row, rowData);
}
}
List<ITableRow> deletedRows = getDeletedRows();
for (ITableRow delRow : deletedRows) {
if (rowMapper.acceptExport(delRow)) {
AbstractTableRowData rowData = target.addRow();
rowMapper.exportTableRowData(delRow, rowData);
rowData.setRowState(AbstractTableRowData.STATUS_DELETED);
}
}
}
Aggregations