use of org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCache in project kie-wb-common by kiegroup.
the class ExpressionEditorTest method setUp.
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
this.decision = new Decision();
this.expressionGridCache = new ExpressionGridCacheImpl();
this.definitions = new Definitions();
this.definitions.setName(new Name(DRG_NAME));
testedEditor = spy(new ExpressionEditor(view, decisionNavigator, dmnGraphUtils, dmnDiagramsSession, drdNameChanger));
testedEditor.bind(dmnSession);
when(session.getCanvasControl(eq(ExpressionGridCache.class))).thenReturn(expressionGridCache);
when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
when(dmnDiagramsSession.getCurrentDMNDiagramElement()).thenReturn(Optional.of(dmnDiagramElement));
}
use of org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCache in project kie-wb-common by kiegroup.
the class UndefinedExpressionGrid method onExpressionTypeChanged.
public void onExpressionTypeChanged(final ExpressionType type) {
final Optional<Expression> expression = expressionEditorDefinitionsSupplier.get().stream().filter(e -> e.getType().equals(type)).map(ExpressionEditorDefinition::getModelClass).findFirst().get();
final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression);
expressionEditorDefinition.ifPresent(ed -> {
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new SetCellValueCommand(parent, nodeUUID, hasExpression, () -> expression, expressionGridCache, (editor) -> {
resize(BaseExpressionGrid.RESIZE_EXISTING);
editor.ifPresent(BaseExpressionGrid::selectFirstCell);
}, () -> {
resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
selectCell(0, 0, false, false);
}, () -> {
Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = Optional.empty();
if (nodeUUID.isPresent()) {
final String uuid = nodeUUID.get();
editor = expressionGridCache.getExpressionGrid(uuid);
}
if (!editor.isPresent()) {
ed.enrich(nodeUUID, hasExpression, expression);
editor = ed.getEditor(parent, nodeUUID, hasExpression, hasName, isOnlyVisualChangeAllowed, nesting);
}
return editor;
}));
});
}
Aggregations