use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class FunctionGrid method doSetKind.
void doSetKind(final FunctionDefinition.Kind kind, final FunctionDefinition function, final Optional<ExpressionEditorDefinition<Expression>> oDefinition) {
oDefinition.ifPresent(definition -> {
final GridCellTuple parent = new GridCellTuple(0, 1, FunctionGrid.this);
final Optional<Expression> expression = definition.getModelClass();
definition.enrich(nodeUUID, hasExpression, expression);
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new SetKindCommand(parent, function, kind, expression, (editor) -> {
editor.ifPresent(e -> {
e.resize(BaseExpressionGrid.RESIZE_EXISTING);
e.selectFirstCell();
});
}, () -> {
resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
selectFirstCell();
}, () -> {
Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = Optional.empty();
editor = definition.getEditor(parent, Optional.empty(), getExpression().get().get(), hasName, isOnlyVisualChangeAllowed, nesting + 1);
return editor;
}));
});
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class PropertiesPanelNotifierTest method testNotifyExpressions.
@Test
public void testNotifyExpressions() {
final Node node = mock(Node.class);
final HasExpression hasExpression = mock(HasExpression.class);
final Expression expression = mock(Expression.class);
final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class);
final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class);
when(expression.getHasTypeRefs()).thenReturn(asList(hasTypeRef1, hasTypeRef2));
when(hasExpression.getExpression()).thenReturn(expression);
doNothing().when(notifier).notifyOutdatedElement(any(), any());
notifier.notifyExpressions(node, hasExpression);
verify(notifier).notifyOutdatedElement(node, hasTypeRef1);
verify(notifier).notifyOutdatedElement(node, hasTypeRef2);
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class BaseExpressionGridRenderingTest method getGrid.
@Override
@SuppressWarnings("unchecked")
public BaseExpressionGrid getGrid() {
final GridCellTuple parent = new GridCellTuple(0, 0, null);
final HasExpression hasExpression = mock(HasExpression.class);
final Optional<LiteralExpression> expression = Optional.of(mock(LiteralExpression.class));
final Optional<HasName> hasName = Optional.of(mock(HasName.class));
return new BaseExpressionGrid(parent, Optional.empty(), hasExpression, expression, hasName, gridPanel, gridLayer, new GridDataCache.CacheResult(new DMNGridData(), false), renderer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, 0) {
@Override
protected BaseUIModelMapper makeUiModelMapper() {
return mapper;
}
@Override
protected void initialiseUiColumns() {
// Nothing for this test
}
@Override
protected void initialiseUiModel() {
// Nothing for this test
}
@Override
protected boolean isHeaderHidden() {
return isHeaderHidden;
}
};
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class AddRelationColumnCommand method newGraphCommand.
@Override
protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) {
return new AbstractGraphCommand() {
@Override
protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) {
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) {
relation.getComponentWidths().add(uiColumnIndex, null);
final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT;
relation.getColumn().add(iiIndex, informationItem);
informationItem.getName().setValue(name);
relation.getRow().forEach(row -> {
final LiteralExpression le = new LiteralExpression();
final HasExpression hasExpression = HasExpression.wrap(row, le);
row.getExpression().add(iiIndex, hasExpression);
le.setParent(row);
});
informationItem.setParent(relation);
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) {
relation.getComponentWidths().remove(uiColumnIndex);
final int columnIndex = relation.getColumn().indexOf(informationItem);
relation.getRow().forEach(row -> row.getExpression().remove(columnIndex));
relation.getColumn().remove(informationItem);
return GraphCommandResultBuilder.SUCCESS;
}
};
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class AddRelationRowCommand method newGraphCommand.
@Override
protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) {
return new AbstractGraphCommand() {
@Override
protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) {
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) {
relation.getRow().add(uiRowIndex, row);
relation.getColumn().forEach(ii -> {
final LiteralExpression le = new LiteralExpression();
final HasExpression hasExpression = HasExpression.wrap(ii, le);
row.getExpression().add(hasExpression);
le.setParent(row);
});
row.setParent(relation);
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) {
relation.getRow().remove(row);
return GraphCommandResultBuilder.SUCCESS;
}
};
}
Aggregations