Search in sources :

Example 21 with CompositeColumn

use of org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn in project drools-wb by kiegroup.

the class LimitedEntryBRLConditionColumnSynchronizer 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 LimitedEntryBRLConditionColumn modelColumn = (LimitedEntryBRLConditionColumn) md.getColumn();
    final List<CompositeColumn<? extends BaseColumn>> modelConditionColumns = model.getConditions();
    final int modelConditionColumnCount = modelConditionColumns.size();
    if (modelConditionColumnCount == 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final List<BaseColumn> allModelColumns = model.getExpandedColumns();
    final int minColumnIndex = allModelColumns.indexOf(modelConditionColumns.get(0));
    final int maxColumnIndex = allModelColumns.indexOf(modelConditionColumns.get(modelConditionColumnCount - 1));
    final int targetColumnIndex = md.getTargetColumnIndex();
    final int sourceColumnIndex = md.getSourceColumnIndex();
    if (targetColumnIndex < minColumnIndex || targetColumnIndex > maxColumnIndex) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    moveModelData(targetColumnIndex, sourceColumnIndex, sourceColumnIndex);
    modelConditionColumns.remove(modelColumn);
    modelConditionColumns.add(targetColumnIndex - minColumnIndex, modelColumn);
}
Also used : LimitedEntryBRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLConditionColumn) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)

Example 22 with CompositeColumn

use of org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn in project drools-wb by kiegroup.

the class ActionWorkItemSetFieldPluginTest method mockPatterns.

private void mockPatterns() {
    final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class);
    final List<CompositeColumn<?>> patterns = Collections.singletonList(fakePattern());
    final List<ActionCol52> actions = Arrays.asList(fakeActionCol(), fakeActionCol());
    when(model.getConditions()).thenReturn(patterns);
    when(model.getActionCols()).thenReturn(actions);
    when(presenter.getModel()).thenReturn(model);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)

Aggregations

CompositeColumn (org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)22 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)20 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)17 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)12 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)12 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)11 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)11 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)11 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)11 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)11 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)11 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)11 List (java.util.List)7 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)5 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)4 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)4 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)4 MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)4 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)3