Search in sources :

Example 6 with AbstractTableRowData

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);
        }
    }
}
Also used : AbstractTableRowData(org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData) InternalTableRow(org.eclipse.scout.rt.client.ui.basic.table.internal.InternalTableRow) ArrayList(java.util.ArrayList)

Example 7 with AbstractTableRowData

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);
        }
    }
}
Also used : AbstractTableRowData(org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData)

Aggregations

AbstractTableRowData (org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData)7 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)1 ITableRowDataMapper (org.eclipse.scout.rt.client.ui.basic.table.ITableRowDataMapper)1 InternalTableRow (org.eclipse.scout.rt.client.ui.basic.table.internal.InternalTableRow)1