Search in sources :

Example 1 with HasName

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);
        })));
    });
}
Also used : NodeMouseClickHandler(com.ait.lienzo.client.core.event.NodeMouseClickHandler) 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) HasCellEditorControls(org.kie.workbench.common.dmn.client.widgets.grid.controls.HasCellEditorControls) 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) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) ExpressionType(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionType) 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) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) ArrayList(java.util.ArrayList) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) DMNGridPanel(org.kie.workbench.common.dmn.client.widgets.panel.DMNGridPanel) EventPropagationMode(com.ait.lienzo.shared.core.types.EventPropagationMode) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) CanvasCommandFactory(org.kie.workbench.common.stunner.core.client.command.CanvasCommandFactory) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) GridDataCache(org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) SessionCommandManager(org.kie.workbench.common.stunner.core.client.command.SessionCommandManager) HasName(org.kie.workbench.common.dmn.api.definition.HasName) List(java.util.List) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) Optional(java.util.Optional) GridCellValueTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellValueTuple) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) GridCellValueTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellValueTuple)

Example 2 with HasName

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);
            });
        }
    });
}
Also used : CellEditorControlsView(org.kie.workbench.common.dmn.client.widgets.grid.controls.container.CellEditorControlsView) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) HasListSelectorControl(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl) 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) ClearExpressionTypeCommand(org.kie.workbench.common.dmn.client.commands.general.ClearExpressionTypeCommand) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) BaseGridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.impl.BaseGridWidget) Supplier(java.util.function.Supplier) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) DMNEditorConstants(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants) DMNGridPanel(org.kie.workbench.common.dmn.client.widgets.panel.DMNGridPanel) EventPropagationMode(com.ait.lienzo.shared.core.types.EventPropagationMode) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) SessionCommandManager(org.kie.workbench.common.stunner.core.client.command.SessionCommandManager) HasName(org.kie.workbench.common.dmn.api.definition.HasName) List(java.util.List) Optional(java.util.Optional) INodeXYEvent(com.ait.lienzo.client.core.event.INodeXYEvent) ExpressionEditorColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn) Collections(java.util.Collections) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) HasName(org.kie.workbench.common.dmn.api.definition.HasName)

Example 3 with 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());
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Before(org.junit.Before)

Example 4 with HasName

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;
        }
    };
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) HasName(org.kie.workbench.common.dmn.api.definition.HasName) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)

Example 5 with HasName

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;
        }
    };
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridDataCache(org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache) HasName(org.kie.workbench.common.dmn.api.definition.HasName) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)

Aggregations

HasName (org.kie.workbench.common.dmn.api.definition.HasName)19 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)9 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)9 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)8 Test (org.junit.Test)7 Optional (java.util.Optional)6 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)6 Decision (org.kie.workbench.common.dmn.api.definition.v1_1.Decision)5 Matchers.anyString (org.mockito.Matchers.anyString)5 Before (org.junit.Before)4 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)4 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)4 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)4 GridDataCache (org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache)4 UpdateElementPropertyCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand)3 Element (org.kie.workbench.common.stunner.core.graph.Element)3 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)3 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)3 BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)3 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)3