Search in sources :

Example 1 with MoveRowToMetaData

use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveRowToMetaData in project drools-wb by kiegroup.

the class ModelSynchronizerImpl method moveRowsTo.

@Override
@SuppressWarnings("unchecked")
public void moveRowsTo(final int targetRowIndex, final List<GridRow> rows) throws VetoException {
    // Generate meta-data to handle moves
    final List<MoveRowToMetaData> metaData = new ArrayList<MoveRowToMetaData>();
    for (int index = 0; index < rows.size(); index++) {
        final GridRow row = rows.get(index);
        final int sourceRowIndex = uiModel.getRows().indexOf(row);
        if (sourceRowIndex == targetRowIndex) {
            throw new MoveVetoException();
        }
        final List<DTCellValue52> modelRow = model.getData().get(sourceRowIndex);
        metaData.add(new MoveRowToMetaDataImpl(sourceRowIndex, targetRowIndex + index, modelRow));
    }
    final List<Synchronizer> handlers = new ArrayList<Synchronizer>();
    for (Synchronizer synchronizer : synchronizers) {
        if (synchronizer.handlesMoveRowsTo(metaData)) {
            handlers.add(synchronizer);
        }
    }
    if (handlers.isEmpty()) {
        throw new MoveVetoException();
    }
    for (Synchronizer synchronizer : handlers) {
        synchronizer.moveRowsTo(metaData);
    }
}
Also used : Synchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) MoveRowToMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveRowToMetaData) ArrayList(java.util.ArrayList) MoveRowToMetaDataImpl(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveRowToMetaDataImpl) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow)

Aggregations

ArrayList (java.util.ArrayList)1 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)1 ModelSynchronizer (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer)1 Synchronizer (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer)1 MoveRowToMetaData (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveRowToMetaData)1 MoveRowToMetaDataImpl (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveRowToMetaDataImpl)1 GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)1