use of org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent in project kie-wb-common by kiegroup.
the class PropertiesPanelNotifierTest method testRefreshFormPropertiesWhenPropertiesPanelIsUpdated.
@Test
public void testRefreshFormPropertiesWhenPropertiesPanelIsUpdated() {
final Node node = mock(Node.class);
final ClientSession clientSession = mock(ClientSession.class);
final String uuid = "uuid";
when(node.getUUID()).thenReturn(uuid);
when(sessionManager.getCurrentSession()).thenReturn(clientSession);
when(notifier.getSelectedElementUUID()).thenReturn(Optional.of(uuid));
notifier.refreshFormProperties(node);
verify(refreshFormPropertiesEvent).fire(propertiesEventArgumentCaptor.capture());
final RefreshFormPropertiesEvent value = propertiesEventArgumentCaptor.getValue();
assertEquals(uuid, value.getUuid());
assertEquals(clientSession, value.getSession());
}
use of org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent in project kie-wb-common by kiegroup.
the class ExpressionContainerGridTest method testSelectCellWithDomainObjectInStunnerGraph.
@Test
public void testSelectCellWithDomainObjectInStunnerGraph() {
final int uiRowIndex = 0;
final int uiColumnIndex = 1;
final LiteralExpression domainObject = mock(LiteralExpression.class);
when(hasExpression.asDMNModelInstrumentedBase()).thenReturn(domainObject);
when(graph.nodes()).thenReturn(Collections.singletonList(node));
final Definition definition = mock(Definition.class);
when(node.getUUID()).thenReturn(NODE_UUID);
when(node.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(domainObject);
grid.setExpression(NODE_UUID, hasExpression, Optional.of(hasName), false);
grid.selectCell(uiRowIndex, uiColumnIndex, false, true);
verify(gridLayer).select(eq(grid));
verify(refreshFormPropertiesEvent).fire(refreshFormPropertiesEventCaptor.capture());
final RefreshFormPropertiesEvent refreshFormPropertiesEvent = refreshFormPropertiesEventCaptor.getValue();
assertThat(refreshFormPropertiesEvent.getUuid()).isEqualTo(NODE_UUID);
assertThat(refreshFormPropertiesEvent.getSession()).isEqualTo(session);
verify(cellSelectionManager).selectCell(eq(uiRowIndex), eq(uiColumnIndex), eq(false), eq(true));
}
use of org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent in project kie-wb-common by kiegroup.
the class BaseExpressionGridGeneralTest method testSelectHeaderCellWithDomainObjectInStunnerGraph.
@Test
public void testSelectHeaderCellWithDomainObjectInStunnerGraph() {
grid.getModel().appendColumn(new RowNumberColumn());
grid.getModel().appendColumn(new RowNumberColumn());
// Mock graph to contain decision
final Definition definition = mock(Definition.class);
when(node.getUUID()).thenReturn(NODE_UUID);
when(node.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(decision);
// Mock grid to dispatch header selection as a DomainObject
doAnswer(i -> {
grid.fireDomainObjectSelectionEvent(decision);
return null;
}).when(grid).doAfterHeaderSelectionChange(anyInt(), anyInt());
grid.selectHeaderCell(0, 1, false, false);
assertHeaderSelection();
verify(refreshFormPropertiesEvent).fire(refreshFormPropertiesEventCaptor.capture());
final RefreshFormPropertiesEvent refreshFormPropertiesEvent = refreshFormPropertiesEventCaptor.getValue();
assertThat(refreshFormPropertiesEvent.getUuid()).isEqualTo(NODE_UUID);
assertThat(refreshFormPropertiesEvent.getSession()).isEqualTo(session);
}
use of org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent in project kie-wb-common by kiegroup.
the class LiteralExpressionPMMLDocumentModelEditorDefinition method getEditor.
@Override
public Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> getEditor(final GridCellTuple parent, final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<HasName> hasName, final boolean isOnlyVisualChangeAllowed, final int nesting) {
return Optional.of(new LiteralExpressionPMMLGrid(parent, nodeUUID, hasExpression, hasName, getGridPanel(), getGridLayer(), makeGridData(() -> Optional.ofNullable((LiteralExpressionPMMLDocumentModel) hasExpression.getExpression())), definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, editorSelectedEvent, refreshFormPropertiesEvent, domainObjectSelectionEvent, getCellEditorControls(), listSelector, translationService, isOnlyVisualChangeAllowed, nesting, headerEditor, readOnlyProvider) {
@Override
protected String getPlaceHolder() {
return translationService.getTranslation(DMNEditorConstants.LiteralExpressionPMMLDocumentModelEditorDefinition_Placeholder);
}
@Override
protected void loadValues(final Consumer<List<String>> consumer) {
final String pmmlDocumentName = getExpressionPMMLValue(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT);
consumer.accept(pmmlDocumentMetadataProvider.getPMMLDocumentModels(pmmlDocumentName));
}
@Override
public Function<GridCellValueTuple, Command> newCellHasValueCommand() {
return (gridCellValueTuple) -> {
final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> builder = new CompositeCommand.Builder<>();
// Command to set the PMMLDocumentModel value
builder.addCommand(new SetCellValueCommand(gridCellValueTuple, () -> uiModelMapper, gridLayer::batch));
// Command to set PMMLDocumentModel parameters
getParentFunctionGrid().ifPresent(parentFunctionGrid -> {
final String pmmlDocumentName = getExpressionPMMLValue(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT);
final String pmmlDocumentModelName = StringUtils.createUnquotedString((String) gridCellValueTuple.getValue().getValue());
final List<String> parameters = pmmlDocumentMetadataProvider.getPMMLDocumentModelParameterNames(pmmlDocumentName, pmmlDocumentModelName);
parentFunctionGrid.getExpression().get().ifPresent(function -> {
builder.addCommand(new SetParametersCommand(function, convertParametersToInformationItems(parameters), gridLayer::batch));
});
});
return builder.build();
};
}
private List<InformationItem> convertParametersToInformationItems(final List<String> parameters) {
final List<InformationItem> informationItems = new ArrayList<>();
parameters.forEach(parameter -> informationItems.add(new InformationItem(new Id(), new Description(), new Name(parameter), BuiltInType.ANY.asQName())));
return informationItems;
}
});
}
use of org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent in project kie-wb-common by kiegroup.
the class NavigateToDRGEditorCommand method newCanvasCommand.
@Override
protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler context) {
return new AbstractCanvasCommand() {
@Override
public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) {
enableHandlers(true);
hidePaletteWidget(false);
addDRGEditorToCanvasWidget();
// Ensure Form Properties are updated to reflect the Graph node selection
refreshFormPropertiesEvent.fire(new RefreshFormPropertiesEvent(sessionManager.getCurrentSession(), nodeUUID));
return CanvasCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context) {
enableHandlers(false);
hidePaletteWidget(true);
editor.setExpression(nodeUUID, hasExpression, hasName, isOnlyVisualChangeAllowed);
editor.setExitCommand(() -> navigateToExpressionEditor(hasExpression, hasName));
addExpressionEditorToCanvasWidget();
return CanvasCommandResultBuilder.SUCCESS;
}
};
}
Aggregations