use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 in project drools-wb by kiegroup.
the class ConditionColumnSynchronizer method doMovePattern.
private void doMovePattern(final List<MoveColumnToMetaData> metaData) throws VetoException {
final MoveColumnToMetaData md = metaData.get(0);
final ConditionCol52 srcModelColumn = (ConditionCol52) md.getColumn();
final Pattern52 srcModelPattern = model.getPattern(srcModelColumn);
if (srcModelPattern == null) {
throw new ModelSynchronizer.MoveVetoException();
}
final List<ConditionCol52> srcModelPatternConditionColumns = srcModelPattern.getChildColumns();
final int srcModelPatternConditionColumnCount = srcModelPatternConditionColumns.size();
if (srcModelPatternConditionColumnCount == 0) {
throw new ModelSynchronizer.MoveVetoException();
}
if (srcModelPatternConditionColumnCount != metaData.size()) {
throw new ModelSynchronizer.MoveVetoException();
}
final int tgtColumnIndex = md.getTargetColumnIndex();
final int tgtPatternIndex = findTargetPatternIndex(md);
final List<BaseColumn> allModelColumns = model.getExpandedColumns();
moveModelData(tgtColumnIndex, allModelColumns.indexOf(srcModelPatternConditionColumns.get(0)), allModelColumns.indexOf(srcModelPatternConditionColumns.get(0)) + srcModelPatternConditionColumnCount - 1);
model.getConditions().remove(srcModelPattern);
model.getConditions().add(tgtPatternIndex, srcModelPattern);
}
use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 in project drools-wb by kiegroup.
the class ConditionColumnSynchronizer method append.
@Override
public void append(final PatternConditionMetaData metaData) throws VetoException {
// Check operation is supported
if (!handlesAppend(metaData)) {
return;
}
final Pattern52 pattern = metaData.getPattern();
final ConditionCol52 column = (ConditionCol52) metaData.getColumn();
// Add pattern if it does not already exist
if (!model.getConditions().contains(pattern)) {
model.getConditions().add(pattern);
// Signal patterns changed event
final BoundFactsChangedEvent bfce = new BoundFactsChangedEvent(rm.getLHSBoundFacts());
eventBus.fireEvent(bfce);
}
pattern.getChildColumns().add(column);
synchroniseAppendColumn(column);
}
use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 in project drools-wb by kiegroup.
the class ConditionColumnSynchronizer method doMoveSingleCondition.
// Move a single Condition column; it must remain within the bounds of it's parent Pattern's columns
private void doMoveSingleCondition(final MoveColumnToMetaData metaData) throws VetoException {
final ConditionCol52 modelColumn = (ConditionCol52) metaData.getColumn();
final Pattern52 modelPattern = model.getPattern(modelColumn);
if (modelPattern == null) {
throw new ModelSynchronizer.MoveVetoException();
}
final List<ConditionCol52> modelPatternConditionColumns = modelPattern.getChildColumns();
final int modelPatternConditionColumnCount = modelPatternConditionColumns.size();
if (modelPatternConditionColumnCount == 0) {
throw new ModelSynchronizer.MoveVetoException();
}
final List<BaseColumn> allModelColumns = model.getExpandedColumns();
final int minColumnIndex = allModelColumns.indexOf(modelPatternConditionColumns.get(0));
final int maxColumnIndex = allModelColumns.indexOf(modelPatternConditionColumns.get(modelPatternConditionColumnCount - 1));
final int targetColumnIndex = metaData.getTargetColumnIndex();
final int sourceColumnIndex = metaData.getSourceColumnIndex();
if (targetColumnIndex < minColumnIndex || targetColumnIndex > maxColumnIndex) {
throw new ModelSynchronizer.MoveVetoException();
}
moveModelData(targetColumnIndex, sourceColumnIndex, sourceColumnIndex);
modelPatternConditionColumns.remove(modelColumn);
modelPatternConditionColumns.add(targetColumnIndex - minColumnIndex, modelColumn);
}
use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 in project drools-wb by kiegroup.
the class ConditionColumnSynchronizer method isPattern.
private boolean isPattern(final List<MoveColumnToMetaData> metaData) {
if (!metaData.stream().allMatch((c) -> c.getColumn() instanceof ConditionCol52)) {
return false;
}
final MoveColumnToMetaData md = metaData.get(0);
final ConditionCol52 srcModelColumn = (ConditionCol52) md.getColumn();
final Pattern52 srcModelPattern = model.getPattern(srcModelColumn);
return srcModelPattern.getChildColumns().size() == metaData.size();
}
use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 in project drools-wb by kiegroup.
the class GuidedDecisionTableTheme method getModelColumnType.
ModelColumnType getModelColumnType(final GridColumn<?> uiColumn) {
final int uiColumnIndex = uiModel.getColumns().indexOf(uiColumn);
final BaseColumn modelColumn = model.getExpandedColumns().get(uiColumnIndex);
if (modelColumn instanceof RowNumberCol52) {
return ModelColumnType.ROW_NUMBER;
} else if (modelColumn instanceof DescriptionCol52) {
return ModelColumnType.DESCRIPTION;
} else if (modelColumn instanceof MetadataCol52) {
return ModelColumnType.METADATA;
} else if (modelColumn instanceof AttributeCol52) {
return ModelColumnType.ATTRIBUTE;
} else if (modelColumn instanceof ConditionCol52) {
return ModelColumnType.CONDITION;
} else if (modelColumn instanceof ActionCol52) {
return ModelColumnType.ACTION;
}
// proof rendering than throw an exception.
return ModelColumnType.UNKNOWN;
}
Aggregations