use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class RelationColumnTest method assertMinimumWidth.
private void assertMinimumWidth(final Optional<BaseExpressionGrid> peer, final double peerWidth, final double relationGridWidth, final double expectedMinimumWidth) {
doReturn(peerWidth).when(peerExpressionEditor).getMinimumWidth();
doReturn(relationGridWidth).when(gridWidget).getWidth();
parentUiModel.setCellValue(1, 0, new ExpressionCellValue(peer));
assertEquals(expectedMinimumWidth, column.getMinimumWidth(), 0.0);
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class FunctionGrid method doSetKind.
void doSetKind(final FunctionDefinition.Kind kind, final FunctionDefinition function, final Optional<Expression> expression, final Optional<BaseExpressionGrid> editor) {
final GridCellValueTuple gcv = new GridCellValueTuple<>(0, 0, this, new ExpressionCellValue(editor));
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new SetKindCommand(gcv, function, kind, expression, () -> synchroniseViewWhenExpressionEditorChanged(this)));
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class ExpressionContainerGrid method getExistingEditor.
Optional<BaseExpressionGrid> getExistingEditor() {
Optional<BaseExpressionGrid> beg = Optional.empty();
final GridCell<?> cell = model.getRow(0).getCells().get(0);
if (cell != null) {
final GridCellValue<?> value = cell.getValue();
if (value instanceof ExpressionCellValue) {
final ExpressionCellValue ecv = (ExpressionCellValue) value;
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ecv.getValue();
if (editor.isPresent()) {
beg = Optional.of(editor.get());
}
}
}
return beg;
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class ExpressionContainerUIModelMapper method fromDMNModel.
@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
final String uuid = nodeUUID.get();
final GridData uiModel = this.uiModel.get();
final Optional<Expression> expression = dmnModel.get();
final Optional<HasName> hasName = this.hasName.get();
final boolean isOnlyVisualChangeAllowed = this.isOnlyVisualChangeAllowedSupplier.get();
final HasExpression hasExpression = this.hasExpression.get();
final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitions.get().getExpressionEditorDefinition(expression);
expressionEditorDefinition.ifPresent(definition -> {
Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = expressionGridCache.get().getExpressionGrid(uuid);
if (!editor.isPresent()) {
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.of(uuid), hasExpression, hasName, isOnlyVisualChangeAllowed, 0);
expressionGridCache.get().putExpressionGrid(uuid, oEditor);
editor = oEditor;
}
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> _editor = editor;
uiModel.setCell(0, 0, () -> new ContextGridCell<>(new ExpressionCellValue(_editor), listSelector));
});
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class ExpressionContainerGridTest method testSetUndefinedExpression.
@Test
public void testSetUndefinedExpression() {
grid.setExpression(NODE_UUID, hasExpression, Optional.of(hasName), false);
final GridCellValue<?> gridCellValue = grid.getModel().getCell(0, 0).getValue();
assertThat(gridCellValue).isInstanceOf(ExpressionCellValue.class);
final ExpressionCellValue expressionCellValue = (ExpressionCellValue) gridCellValue;
assertThat(expressionCellValue.getValue().isPresent()).isTrue();
assertThat(expressionCellValue.getValue().get()).isSameAs(undefinedExpressionEditor);
assertThat(grid.isOnlyVisualChangeAllowed()).isFalse();
verify(undefinedExpressionEditor).selectFirstCell();
verify(gridLayer).batch();
}
Aggregations