use of org.kie.workbench.common.dmn.api.definition.HasName in project kie-wb-common by kiegroup.
the class UndefinedExpressionGrid method onExpressionTypeChanged.
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 -> {
final Optional<BaseExpressionGrid> editor = ed.getEditor(parent, nodeUUID, hasExpression, expression, hasName, nesting);
final GridCellValueTuple gcv = new GridCellValueTuple<>(parent.getRowIndex(), parent.getColumnIndex(), parent.getGridWidget(), new ExpressionCellValue(editor));
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new SetCellValueCommand(gcv, () -> uiModelMapper, () -> editor.ifPresent(e -> {
e.selectFirstCell();
synchroniseViewWhenExpressionEditorChanged(e);
})));
});
}
use of org.kie.workbench.common.dmn.api.definition.HasName in project kie-wb-common by kiegroup.
the class ExpressionContainerGrid method spyHasName.
Optional<HasName> spyHasName(final ParameterizedCommand<Optional<HasName>> onHasNameChanged) {
final Name name = new Name() {
@Override
public String getValue() {
return hasName.orElse(HasName.NOP).getName().getValue();
}
@Override
public void setValue(final String value) {
hasName.ifPresent(hn -> {
hn.getName().setValue(value);
onHasNameChanged.execute(hasName);
});
}
};
return Optional.of(new HasName() {
@Override
public Name getName() {
return name;
}
@Override
public void setName(final Name name) {
hasName.ifPresent(hn -> {
hn.setName(name);
onHasNameChanged.execute(hasName);
});
}
});
}
use of org.kie.workbench.common.dmn.api.definition.HasName in project kie-wb-common by kiegroup.
the class RelationGridTest method setUp.
@Before
public void setUp() throws Exception {
tupleWithoutValue = new GridCellTuple(0, 1, gridWidget);
tupleWithValue = new GridCellValueTuple<>(0, 1, gridWidget, new BaseGridCellValue<>("value"));
definition = new RelationEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService);
final Decision decision = new Decision();
decision.setName(new Name("name"));
hasName = Optional.of(decision);
expression = definition.getModelClass();
doReturn(canvasHandler).when(dmnClientFullSession).getCanvasHandler();
doReturn(dmnClientFullSession).when(sessionManager).getCurrentSession();
doReturn(parentGridData).when(parentGridWidget).getModel();
doReturn(Collections.singletonList(parentGridColumn)).when(parentGridData).getColumns();
parent = spy(new GridCellTuple(0, 0, parentGridWidget));
when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(anyString());
}
use of org.kie.workbench.common.dmn.api.definition.HasName in project kie-wb-common by kiegroup.
the class BaseExpressionGridCacheTest method getGrid.
@Override
@SuppressWarnings("unchecked")
public BaseExpressionGrid getGrid() {
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(parentCell, Optional.empty(), hasExpression, expression, hasName, gridPanel, gridLayer, cacheResult, renderer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, 0) {
@Override
protected BaseUIModelMapper makeUiModelMapper() {
return mapper;
}
@Override
protected void initialiseUiColumns() {
model.appendColumn(uiColumn);
}
@Override
protected void initialiseUiModel() {
model.appendRow(uiRow);
}
@Override
protected boolean isHeaderHidden() {
return false;
}
};
}
use of org.kie.workbench.common.dmn.api.definition.HasName in project kie-wb-common by kiegroup.
the class BaseExpressionGridGeneralTest method getGrid.
@Override
@SuppressWarnings("unchecked")
public BaseExpressionGrid getGrid() {
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(parentCell, 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 false;
}
};
}
Aggregations