use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools-wb by kiegroup.
the class LimitedEntryBRLActionColumnSynchronizer method moveColumnsTo.
@Override
public void moveColumnsTo(final List<MoveColumnToMetaData> metaData) throws VetoException {
// Check operation is supported
if (!handlesMoveColumnsTo(metaData)) {
return;
}
final MoveColumnToMetaData md = metaData.get(0);
final LimitedEntryBRLActionColumn modelColumn = (LimitedEntryBRLActionColumn) md.getColumn();
final List<ActionCol52> modelActionColumns = model.getActionCols();
final int modelActionColumnCount = modelActionColumns.size();
if (modelActionColumnCount == 0) {
throw new ModelSynchronizer.MoveVetoException();
}
final List<BaseColumn> allModelColumns = model.getExpandedColumns();
final int minColumnIndex = allModelColumns.indexOf(modelActionColumns.get(0));
final int maxColumnIndex = allModelColumns.indexOf(modelActionColumns.get(modelActionColumnCount - 1));
final int targetColumnIndex = md.getTargetColumnIndex();
final int sourceColumnIndex = md.getSourceColumnIndex();
if (targetColumnIndex < minColumnIndex || targetColumnIndex > maxColumnIndex) {
throw new ModelSynchronizer.MoveVetoException();
}
moveModelData(targetColumnIndex, sourceColumnIndex, sourceColumnIndex);
modelActionColumns.remove(modelColumn);
modelActionColumns.add(targetColumnIndex - minColumnIndex, modelColumn);
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools-wb by kiegroup.
the class ActionColumnSynchronizer method isWorkItemFragmentBeforeInsertFactCol.
protected boolean isWorkItemFragmentBeforeInsertFactCol(final List<? extends MetaData> metaData) {
final List<ActionCol52> columnsToMove = metaData.stream().map(c -> (MoveColumnToMetaData) c).map(MoveColumnToMetaData::getColumn).map(c -> (ActionCol52) c).collect(Collectors.toList());
final List<String> bindingsUsedByWID = new ArrayList<>();
bindingsUsedByWID.addAll(columnsToMove.stream().filter(c -> c instanceof ActionWorkItemInsertFactCol52).map(c -> (ActionWorkItemInsertFactCol52) c).map(ActionWorkItemInsertFactCol52::getBoundName).collect(Collectors.toList()));
final AtomicBoolean result = new AtomicBoolean(true);
final int tgtIndex = ((MoveColumnToMetaData) metaData.get(0)).getTargetColumnIndex();
final List<BaseColumn> modelColumns = model.getExpandedColumns();
// Cannot move "Insert and Set field" created by the WID to after other "Insert and Set field"
for (String binding : bindingsUsedByWID) {
model.getActionCols().stream().filter(c -> !columnsToMove.contains(c)).filter(c -> c instanceof ActionInsertFactCol52).filter(c -> !(c instanceof ActionWorkItemInsertFactCol52)).map(c -> (ActionInsertFactCol52) c).filter(c -> c.getBoundName().equals(binding)).map(modelColumns::indexOf).filter(i -> tgtIndex >= i).findFirst().ifPresent(i -> result.set(false));
}
return result.get();
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools-wb by kiegroup.
the class ActionColumnSynchronizer method doMoveActionFragment.
protected void doMoveActionFragment(final List<MoveColumnToMetaData> metaData) throws VetoException {
final MoveColumnToMetaData md = metaData.get(0);
final BaseColumn firstColumnInFragment = md.getColumn();
final BaseColumn lastColumnInFragment = metaData.get(metaData.size() - 1).getColumn();
final int srcColumnFirstIndex = model.getExpandedColumns().indexOf(firstColumnInFragment);
final int srcColumnLastIndex = model.getExpandedColumns().indexOf(lastColumnInFragment);
final List<ActionCol52> srcModelFragmentColumns = IntStream.rangeClosed(srcColumnFirstIndex, srcColumnLastIndex).mapToObj(i -> model.getExpandedColumns().get(i)).map(column -> (ActionCol52) column).collect(Collectors.toList());
final int srcModelFragmentColumnsCount = srcModelFragmentColumns.size();
if (srcModelFragmentColumnsCount == 0) {
throw new ModelSynchronizer.MoveVetoException();
}
if (srcModelFragmentColumnsCount != metaData.size()) {
throw new ModelSynchronizer.MoveVetoException();
}
final int tgtColumnIndex = md.getTargetColumnIndex();
final int tgtActionIndex = findTargetActionIndex(md);
final List<BaseColumn> allModelColumns = model.getExpandedColumns();
moveModelData(tgtColumnIndex, allModelColumns.indexOf(srcModelFragmentColumns.get(0)), allModelColumns.indexOf(srcModelFragmentColumns.get(0)) + srcModelFragmentColumnsCount - 1);
// Moving left
if (tgtColumnIndex < srcColumnFirstIndex) {
final AtomicInteger offset = new AtomicInteger(0);
srcModelFragmentColumns.forEach(column -> {
model.getActionCols().remove(column);
model.getActionCols().add(tgtActionIndex + offset.getAndIncrement(), column);
});
}
// Moving right
if (tgtColumnIndex > srcColumnFirstIndex) {
srcModelFragmentColumns.forEach(column -> {
model.getActionCols().remove(column);
model.getActionCols().add(tgtActionIndex, column);
});
}
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools-wb by kiegroup.
the class ActionColumnSynchronizer method delete.
@Override
public void delete(final ColumnMetaData metaData) throws VetoException {
// Check operation is supported
if (!handlesDelete(metaData)) {
return;
}
final ActionCol52 column = (ActionCol52) metaData.getColumn();
final int columnIndex = model.getExpandedColumns().indexOf(column);
model.getActionCols().remove(column);
synchroniseDeleteColumn(columnIndex);
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools-wb by kiegroup.
the class ActionWorkItemExecuteColumnSynchronizer method append.
@Override
public void append(final ColumnMetaData metaData) throws VetoException {
if (!handlesAppend(metaData)) {
return;
}
final ActionCol52 column = (ActionCol52) metaData.getColumn();
model.getActionCols().add(column);
synchroniseAppendColumn(column);
}
Aggregations