Search in sources :

Example 11 with Command

use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.

the class BaseExpressionGrid method executeRenderQueueCommands.

@Override
protected void executeRenderQueueCommands(final boolean isSelectionLayer) {
    final List<Pair<Group, GridRenderer.RendererCommand>> gridLineCommands = new ArrayList<>();
    final List<Pair<Group, GridRenderer.RendererCommand>> allOtherCommands = new ArrayList<>();
    final List<Pair<Group, GridRenderer.RendererCommand>> selectedCellsCommands = new ArrayList<>();
    for (Pair<Group, List<GridRenderer.RendererCommand>> p : renderQueue) {
        final Group parent = p.getK1();
        final List<GridRenderer.RendererCommand> commands = p.getK2();
        for (GridRenderer.RendererCommand command : commands) {
            if (command instanceof GridRenderer.RenderSelectedCellsCommand) {
                selectedCellsCommands.add(new Pair<>(parent, command));
            } else if (command instanceof GridRenderer.RenderHeaderGridLinesCommand) {
                gridLineCommands.add(new Pair<>(parent, command));
            } else if (command instanceof GridRenderer.RenderBodyGridLinesCommand) {
                gridLineCommands.add(new Pair<>(parent, command));
            } else {
                allOtherCommands.add(new Pair<>(parent, command));
            }
        }
    }
    final Predicate<Pair<Group, GridRenderer.RendererCommand>> renderHeader = (p) -> {
        final GridRenderer.RendererCommand command = p.getK2();
        if (isHeaderHidden()) {
            return !(command instanceof GridRenderer.RendererHeaderCommand);
        }
        return true;
    };
    renderQueue.clear();
    allOtherCommands.stream().filter(renderHeader).forEach(p -> addCommandToRenderQueue(p.getK1(), p.getK2()));
    gridLineCommands.stream().filter(renderHeader).forEach(p -> addCommandToRenderQueue(p.getK1(), p.getK2()));
    selectedCellsCommands.stream().filter(renderHeader).forEach(p -> addCommandToRenderQueue(p.getK1(), p.getK2()));
    super.executeRenderQueueCommands(isSelectionLayer);
}
Also used : TextAreaSingletonDOMElementFactory(org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.TextAreaSingletonDOMElementFactory) CellEditorControlsView(org.kie.workbench.common.dmn.client.widgets.grid.controls.container.CellEditorControlsView) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) ListSelectorView(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.ListSelectorView) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) Group(com.ait.lienzo.client.core.shape.Group) GridSelectionManager(org.uberfire.ext.wires.core.grids.client.widget.layer.GridSelectionManager) BaseGridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.impl.BaseGridWidget) GridLayerRedrawManager(org.uberfire.ext.wires.core.grids.client.widget.layer.impl.GridLayerRedrawManager) SetHeaderValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetHeaderValueCommand) Layer(com.ait.lienzo.client.core.shape.Layer) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand) DeleteHeaderValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteHeaderValueCommand) CanvasCommandFactory(org.kie.workbench.common.stunner.core.client.command.CanvasCommandFactory) Predicate(java.util.function.Predicate) GridDataCache(org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) AbstractCanvasGraphCommand(org.kie.workbench.common.stunner.core.client.canvas.command.AbstractCanvasGraphCommand) DeleteCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteCellValueCommand) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) HasName(org.kie.workbench.common.dmn.api.definition.HasName) List(java.util.List) TextBoxSingletonDOMElementFactory(org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.TextBoxSingletonDOMElementFactory) Optional(java.util.Optional) EditableHeaderGridWidgetMouseDoubleClickHandler(org.kie.workbench.common.dmn.client.widgets.grid.columns.EditableHeaderGridWidgetMouseDoubleClickHandler) Viewport(com.ait.lienzo.client.core.shape.Viewport) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer) Function(java.util.function.Function) ArrayList(java.util.ArrayList) RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Element(org.kie.workbench.common.stunner.core.graph.Element) Command(org.kie.workbench.common.stunner.core.command.Command) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) Pair(org.uberfire.commons.data.Pair) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) DMNGridPanel(org.kie.workbench.common.dmn.client.widgets.panel.DMNGridPanel) CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) EditableHeaderMetaData(org.kie.workbench.common.dmn.client.widgets.grid.columns.EditableHeaderMetaData) SessionCommandManager(org.kie.workbench.common.stunner.core.client.command.SessionCommandManager) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) GridPinnedModeManager(org.uberfire.ext.wires.core.grids.client.widget.layer.pinning.GridPinnedModeManager) NodeMouseDoubleClickHandler(com.ait.lienzo.client.core.event.NodeMouseDoubleClickHandler) INodeXYEvent(com.ait.lienzo.client.core.event.INodeXYEvent) GridCellValueTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellValueTuple) CompositeCommand(org.kie.workbench.common.stunner.core.command.impl.CompositeCommand) Group(com.ait.lienzo.client.core.shape.Group) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer) Pair(org.uberfire.commons.data.Pair)

Example 12 with Command

use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.

the class BaseExpressionGridGeneralTest method doTestSetTypeRefConsumer.

@SuppressWarnings("unchecked")
private void doTestSetTypeRefConsumer() {
    grid.setTypeRefConsumer().accept(decision.getVariable(), TYPE_REF);
    verify(sessionCommandManager).execute(eq(canvasHandler), commandCaptor.capture());
    final Command command = commandCaptor.getValue();
    assertThat(command).isInstanceOf(SetTypeRefCommand.class);
    command.execute(canvasHandler);
}
Also used : UpdateElementPropertyCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand) SetTypeRefCommand(org.kie.workbench.common.dmn.client.commands.general.SetTypeRefCommand) SetHeaderValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetHeaderValueCommand) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand) DeleteHeaderValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteHeaderValueCommand) DeleteCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteCellValueCommand) DeleteHasValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteHasValueCommand) SetHasValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetHasValueCommand) SetComponentWidthCommand(org.kie.workbench.common.dmn.client.commands.factory.canvas.SetComponentWidthCommand) Command(org.kie.workbench.common.stunner.core.command.Command)

Example 13 with Command

use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.

the class BaseExpressionGridGeneralTest method doTestSetValueConsumer.

@SuppressWarnings("unchecked")
private void doTestSetValueConsumer(final boolean updateStunnerTitle, final Class... expectedCommandClasses) {
    grid.setValueConsumer(updateStunnerTitle).accept(decision, NAME);
    verify(sessionCommandManager).execute(eq(canvasHandler), commandCaptor.capture());
    final Command command = commandCaptor.getValue();
    GridFactoryCommandUtils.assertCommands(command, expectedCommandClasses);
    command.execute(canvasHandler);
}
Also used : UpdateElementPropertyCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand) SetTypeRefCommand(org.kie.workbench.common.dmn.client.commands.general.SetTypeRefCommand) SetHeaderValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetHeaderValueCommand) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand) DeleteHeaderValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteHeaderValueCommand) DeleteCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteCellValueCommand) DeleteHasValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteHasValueCommand) SetHasValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetHasValueCommand) SetComponentWidthCommand(org.kie.workbench.common.dmn.client.commands.factory.canvas.SetComponentWidthCommand) Command(org.kie.workbench.common.stunner.core.command.Command)

Example 14 with Command

use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.

the class BaseExpressionGridGeneralTest method doTestClearValueConsumer.

@SuppressWarnings("unchecked")
private void doTestClearValueConsumer(final boolean updateStunnerTitle, final Class... expectedCommandClasses) {
    grid.clearValueConsumer(updateStunnerTitle, new Name()).accept(decision);
    verify(sessionCommandManager).execute(eq(canvasHandler), commandCaptor.capture());
    final Command command = commandCaptor.getValue();
    GridFactoryCommandUtils.assertCommands(command, expectedCommandClasses);
    command.execute(canvasHandler);
}
Also used : UpdateElementPropertyCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand) SetTypeRefCommand(org.kie.workbench.common.dmn.client.commands.general.SetTypeRefCommand) SetHeaderValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetHeaderValueCommand) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand) DeleteHeaderValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteHeaderValueCommand) DeleteCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteCellValueCommand) DeleteHasValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteHasValueCommand) SetHasValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetHasValueCommand) SetComponentWidthCommand(org.kie.workbench.common.dmn.client.commands.factory.canvas.SetComponentWidthCommand) Command(org.kie.workbench.common.stunner.core.command.Command) HasName(org.kie.workbench.common.dmn.api.definition.HasName) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Example 15 with Command

use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.

the class LiteralExpressionPMMLDocumentModelGridTest method testNewCellHasValueCommand.

@Test
public void testNewCellHasValueCommand() {
    setupGrid(0);
    final List<String> parameterNames = asList("param1", "param2");
    final String modelName = (String) tupleWithValue.getValue().getValue();
    when(pmmlDocumentMetadataProvider.getPMMLDocumentModelParameterNames(eq(DOCUMENT_NAME), eq(modelName))).thenReturn(parameterNames);
    final Command command = grid.newCellHasValueCommand().apply(tupleWithValue);
    verify(pmmlDocumentMetadataProvider).getPMMLDocumentModelParameterNames(eq(DOCUMENT_NAME), eq(modelName));
    GridFactoryCommandUtils.assertCommands(command, SetCellValueCommand.class, SetParametersCommand.class);
    final SetParametersCommand setParametersCommand = (SetParametersCommand) ((CompositeCommand) command).getCommands().get(1);
    setParametersCommand.execute(canvasHandler);
    assertThat(grandParentExpression.getFormalParameter().stream().map(ii -> ii.getName().getValue()).collect(Collectors.toList())).containsExactly("param1", "param2");
}
Also used : DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Mock(org.mockito.Mock) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) SetParametersCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.function.SetParametersCommand) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) GridFactoryCommandUtils(org.kie.workbench.common.dmn.client.editors.expressions.types.GridFactoryCommandUtils) ReadOnlyProvider(org.kie.workbench.common.stunner.core.client.ReadOnlyProvider) LiteralExpressionPMMLDocumentModelEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.function.supplementary.pmml.model.LiteralExpressionPMMLDocumentModelEditorDefinition) Arrays.asList(java.util.Arrays.asList) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Command(org.kie.workbench.common.stunner.core.command.Command) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) Before(org.junit.Before) DMNEditorConstants(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand) Test(org.junit.Test) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) LiteralExpressionPMMLDocument(org.kie.workbench.common.dmn.api.definition.model.LiteralExpressionPMMLDocument) Mockito.verify(org.mockito.Mockito.verify) Consumer(java.util.function.Consumer) LiteralExpressionPMMLDocumentModel(org.kie.workbench.common.dmn.api.definition.model.LiteralExpressionPMMLDocumentModel) List(java.util.List) Optional(java.util.Optional) FunctionGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.function.FunctionGrid) BaseEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.BaseEditorDefinition) CompositeCommand(org.kie.workbench.common.stunner.core.command.impl.CompositeCommand) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) Mockito.mock(org.mockito.Mockito.mock) SetParametersCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.function.SetParametersCommand) SetParametersCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.function.SetParametersCommand) Command(org.kie.workbench.common.stunner.core.command.Command) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand) CompositeCommand(org.kie.workbench.common.stunner.core.command.impl.CompositeCommand) CompositeCommand(org.kie.workbench.common.stunner.core.command.impl.CompositeCommand) Test(org.junit.Test)

Aggregations

Command (org.kie.workbench.common.stunner.core.command.Command)74 Test (org.junit.Test)53 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)23 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)22 CommandResult (org.kie.workbench.common.stunner.core.command.CommandResult)19 CompositeCommand (org.kie.workbench.common.stunner.core.command.impl.CompositeCommand)16 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)14 Edge (org.kie.workbench.common.stunner.core.graph.Edge)12 Node (org.kie.workbench.common.stunner.core.graph.Node)12 List (java.util.List)10 GraphCommandResultBuilder (org.kie.workbench.common.stunner.core.graph.command.GraphCommandResultBuilder)10 AbstractGraphCommand (org.kie.workbench.common.stunner.core.graph.command.impl.AbstractGraphCommand)10 View (org.kie.workbench.common.stunner.core.graph.content.view.View)9 SetCellValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand)7 Consumer (java.util.function.Consumer)6 UpdateElementPositionCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand)6 ArrayList (java.util.ArrayList)5 AddNodeCommand (org.kie.workbench.common.stunner.core.client.canvas.command.AddNodeCommand)5 Element (org.kie.workbench.common.stunner.core.graph.Element)5 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)5