Search in sources :

Example 16 with HasExpression

use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.

the class LiteralExpressionPMMLDocumentModelEditorDefinitionTest method testEditor.

@Test
public void testEditor() {
    when(hasExpression.getExpression()).thenReturn(definition.getModelClass().get());
    final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, hasName, false, 0);
    assertTrue(oEditor.isPresent());
    final GridWidget editor = oEditor.get();
    assertTrue(editor instanceof LiteralExpressionPMMLGrid);
}
Also used : LiteralExpressionPMMLGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.function.supplementary.pmml.LiteralExpressionPMMLGrid) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) Test(org.junit.Test)

Example 17 with HasExpression

use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.

the class InvocationEditorDefinitionTest method testEditor.

@Test
public void testEditor() {
    when(hasExpression.getExpression()).thenReturn(definition.getModelClass().get());
    final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, hasName, false, 0);
    assertTrue(oEditor.isPresent());
    final GridWidget editor = oEditor.get();
    assertTrue(editor instanceof InvocationGrid);
}
Also used : GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) Test(org.junit.Test)

Example 18 with HasExpression

use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.

the class FunctionEditorDefinitionTest method testEditor.

@Test
public void testEditor() {
    when(hasExpression.getExpression()).thenReturn(definition.getModelClass().get());
    final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, hasName, false, 0);
    assertTrue(oEditor.isPresent());
    final GridWidget editor = oEditor.get();
    assertTrue(editor instanceof FunctionGrid);
}
Also used : GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) Test(org.junit.Test)

Example 19 with HasExpression

use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.

the class BoxedExpressionHelper method getOptionalHasExpression.

public Optional<HasExpression> getOptionalHasExpression(final Node<View, Edge> node) {
    final Object definition = DefinitionUtils.getElementDefinition(node);
    final HasExpression expression;
    if (definition instanceof BusinessKnowledgeModel) {
        expression = ((BusinessKnowledgeModel) definition).asHasExpression();
    } else if (definition instanceof Decision) {
        expression = (Decision) definition;
    } else {
        expression = null;
    }
    return Optional.ofNullable(expression);
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision)

Example 20 with HasExpression

use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.

the class DecisionNavigatorNestedItemFactory method makeEditExpressionEvent.

EditExpressionEvent makeEditExpressionEvent(final Node<View, Edge> node) {
    final ClientSession currentSession = sessionManager.getCurrentSession();
    final Object definition = DefinitionUtils.getElementDefinition(node);
    final HasExpression hasExpression = helper.getHasExpression(node);
    final Optional<HasName> hasName = Optional.of((HasName) definition);
    final boolean isOnlyVisualChangeAllowed = isOnlyVisualChangeAllowed(definition) || readOnlyProvider.isReadOnlyDiagram();
    return new EditExpressionEvent(currentSession, node.getUUID(), hasExpression, hasName, isOnlyVisualChangeAllowed);
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) HasName(org.kie.workbench.common.dmn.api.definition.HasName) ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent)

Aggregations

HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)78 Test (org.junit.Test)41 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)30 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)24 HasName (org.kie.workbench.common.dmn.api.definition.HasName)18 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)15 BaseUIModelMapper (org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper)15 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)15 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)15 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)13 Optional (java.util.Optional)12 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)12 View (org.kie.workbench.common.stunner.core.graph.content.view.View)12 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)10 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)10 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)8 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)8 ArrayList (java.util.ArrayList)7 EditExpressionEvent (org.kie.workbench.common.dmn.client.events.EditExpressionEvent)6 Before (org.junit.Before)5