Search in sources :

Example 1 with MoveColumnToMetaDataImpl

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

the class ModelSynchronizerImpl method moveColumnsTo.

@Override
@SuppressWarnings("unchecked")
public void moveColumnsTo(final int targetColumnIndex, final List<GridColumn<?>> columns) throws VetoException {
    // Generate meta-data to handle moves
    final List<MoveColumnToMetaData> metaData = new ArrayList<MoveColumnToMetaData>();
    for (int index = 0; index < columns.size(); index++) {
        final GridColumn<?> column = columns.get(index);
        final int sourceColumnIndex = uiModel.getColumns().indexOf(column);
        if (sourceColumnIndex == targetColumnIndex) {
            throw new MoveVetoException();
        }
        final BaseColumn modelColumn = model.getExpandedColumns().get(sourceColumnIndex);
        metaData.add(new MoveColumnToMetaDataImpl(sourceColumnIndex, targetColumnIndex + index, modelColumn));
    }
    Synchronizer handler = null;
    for (Synchronizer synchronizer : synchronizers) {
        if (synchronizer.handlesMoveColumnsTo(metaData)) {
            handler = synchronizer;
            break;
        }
    }
    if (handler == null) {
        throw new MoveVetoException();
    }
    handler.moveColumnsTo(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) ArrayList(java.util.ArrayList) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) MoveColumnToMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveColumnToMetaData) MoveColumnToMetaDataImpl(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveColumnToMetaDataImpl)

Example 2 with MoveColumnToMetaDataImpl

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

the class ModelSynchronizerImpl method moveColumnTo.

@Override
@SuppressWarnings("unchecked")
public void moveColumnTo(final int targetColumnIndex, final GridColumn<?> column) throws VetoException {
    final int sourceColumnIndex = uiModel.getColumns().indexOf(column);
    if (sourceColumnIndex == targetColumnIndex) {
        throw new MoveVetoException();
    }
    final BaseColumn modelColumn = model.getExpandedColumns().get(sourceColumnIndex);
    final List<MoveColumnToMetaData> metaData = new ArrayList<MoveColumnToMetaData>() {

        {
            add(new MoveColumnToMetaDataImpl(sourceColumnIndex, targetColumnIndex, modelColumn));
        }
    };
    final List<Synchronizer> handlers = new ArrayList<Synchronizer>();
    for (Synchronizer synchronizer : synchronizers) {
        if (synchronizer.handlesMoveColumnsTo(metaData)) {
            handlers.add(synchronizer);
        }
    }
    if (handlers.isEmpty()) {
        throw new MoveVetoException();
    }
    for (Synchronizer synchronizer : handlers) {
        synchronizer.moveColumnsTo(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) ArrayList(java.util.ArrayList) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) MoveColumnToMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveColumnToMetaData) MoveColumnToMetaDataImpl(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveColumnToMetaDataImpl)

Aggregations

ArrayList (java.util.ArrayList)2 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)2 ModelSynchronizer (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer)2 Synchronizer (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer)2 MoveColumnToMetaData (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveColumnToMetaData)2 MoveColumnToMetaDataImpl (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveColumnToMetaDataImpl)2