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);
}
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);
}
}
Aggregations