Search in sources :

Example 1 with SetCellValueCommand

use of org.kie.workbench.common.dmn.client.commands.expressions.types.undefined.SetCellValueCommand 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;
        }));
    });
}
Also used : CellEditorControlsView(org.kie.workbench.common.dmn.client.widgets.grid.controls.container.CellEditorControlsView) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) DelegatingGridWidgetCellSelectorMouseEventHandler(org.kie.workbench.common.dmn.client.widgets.grid.handlers.DelegatingGridWidgetCellSelectorMouseEventHandler) BaseDelegatingExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseDelegatingExpressionGrid) HasListSelectorControl(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl) ListSelectorView(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.ListSelectorView) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) ExpressionType(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionType) BaseExpressionGridRenderer(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGridRenderer) GridSelectionManager(org.uberfire.ext.wires.core.grids.client.widget.layer.GridSelectionManager) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) ExpressionEditorChanged(org.kie.workbench.common.dmn.client.widgets.grid.model.ExpressionEditorChanged) RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent) ReadOnlyProvider(org.kie.workbench.common.stunner.core.client.ReadOnlyProvider) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) NodeMouseEventHandler(org.uberfire.ext.wires.core.grids.client.widget.grid.NodeMouseEventHandler) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) Event(javax.enterprise.event.Event) DMNGridPanel(org.kie.workbench.common.dmn.client.widgets.panel.DMNGridPanel) EventPropagationMode(com.ait.lienzo.shared.core.types.EventPropagationMode) UndefinedExpressionSelectorPopoverView(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.selector.UndefinedExpressionSelectorPopoverView) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) ExpressionGridCache(org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCache) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) SessionCommandManager(org.kie.workbench.common.stunner.core.client.command.SessionCommandManager) DomainObject(org.kie.workbench.common.stunner.core.domainobject.DomainObject) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.undefined.SetCellValueCommand) DMNModelInstrumentedBase(org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase) HasName(org.kie.workbench.common.dmn.api.definition.HasName) GridPinnedModeManager(org.uberfire.ext.wires.core.grids.client.widget.layer.pinning.GridPinnedModeManager) List(java.util.List) DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) DefaultCanvasCommandFactory(org.kie.workbench.common.dmn.client.commands.factory.DefaultCanvasCommandFactory) ExpressionEditorGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.ExpressionEditorGridRow) Optional(java.util.Optional) DelegatingGridWidgetEditCellMouseEventHandler(org.kie.workbench.common.dmn.client.widgets.grid.handlers.DelegatingGridWidgetEditCellMouseEventHandler) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) Collections(java.util.Collections) Optional(java.util.Optional) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.undefined.SetCellValueCommand)

Example 2 with SetCellValueCommand

use of org.kie.workbench.common.dmn.client.commands.expressions.types.undefined.SetCellValueCommand in project kie-wb-common by kiegroup.

the class UndefinedExpressionGridTest method assertOnExpressionTypeChanged.

@SuppressWarnings("unchecked")
private void assertOnExpressionTypeChanged(final int nesting) {
    setupGrid(nesting);
    grid.onExpressionTypeChanged(ExpressionType.LITERAL_EXPRESSION);
    verify(sessionCommandManager).execute(eq(canvasHandler), setCellValueCommandArgumentCaptor.capture());
    final SetCellValueCommand setCellValueCommand = setCellValueCommandArgumentCaptor.getValue();
    setCellValueCommand.execute(canvasHandler);
    verify(literalExpressionEditorDefinition).getEditor(eq(parent), eq(nesting == 0 ? Optional.of(NODE_UUID) : Optional.empty()), eq(hasExpression), eq(hasName), eq(false), eq(nesting));
    assertResize(BaseExpressionGrid.RESIZE_EXISTING);
    verify(literalExpressionEditor).selectCell(eq(0), eq(0), eq(false), eq(false));
    verify(literalExpressionEditor).selectFirstCell();
    verify(gridPanel).setFocus(true);
    reset(gridPanel, gridLayer, parent);
    setupParent();
    setCellValueCommand.undo(canvasHandler);
    assertResize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
    verify(gridLayer).select(grid);
    verify(grid).selectCell(eq(0), eq(0), eq(false), eq(false));
}
Also used : SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.undefined.SetCellValueCommand)

Aggregations

SetCellValueCommand (org.kie.workbench.common.dmn.client.commands.expressions.types.undefined.SetCellValueCommand)2 EventPropagationMode (com.ait.lienzo.shared.core.types.EventPropagationMode)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 Supplier (java.util.function.Supplier)1 Event (javax.enterprise.event.Event)1 TranslationService (org.jboss.errai.ui.client.local.spi.TranslationService)1 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)1 HasName (org.kie.workbench.common.dmn.api.definition.HasName)1 DMNModelInstrumentedBase (org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase)1 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)1 DefaultCanvasCommandFactory (org.kie.workbench.common.dmn.client.commands.factory.DefaultCanvasCommandFactory)1 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)1 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)1 ExpressionType (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionType)1 UndefinedExpressionSelectorPopoverView (org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.selector.UndefinedExpressionSelectorPopoverView)1 BaseDelegatingExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseDelegatingExpressionGrid)1 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)1