Search in sources :

Example 16 with Element

use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.

the class TextAnnotationTextPropertyProviderImplTest method checkSupportsTextAnnotationElements.

@Test
@SuppressWarnings("unchecked")
public void checkSupportsTextAnnotationElements() {
    assertTrue(provider.supports(element));
    final Element other = mock(Element.class);
    final Definition otherContent = mock(Definition.class);
    final InputData otherDefinition = mock(InputData.class);
    when(other.getContent()).thenReturn(otherContent);
    when(otherContent.getDefinition()).thenReturn(otherDefinition);
    assertFalse(provider.supports(other));
}
Also used : Element(org.kie.workbench.common.stunner.core.graph.Element) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) InputData(org.kie.workbench.common.dmn.api.definition.v1_1.InputData) Test(org.junit.Test)

Example 17 with Element

use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.

the class ContextGridTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    tupleWithoutValue = new GridCellTuple(0, 1, gridWidget);
    tupleWithValue = new GridCellValueTuple<>(0, 1, gridWidget, new BaseGridCellValue<>("value"));
    definition = new ContextEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, expressionEditorDefinitionsSupplier);
    expression = definition.getModelClass();
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(parent).when(literalExpressionEditor).getParentInformation();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    doReturn(parent).when(undefinedExpressionEditor).getParentInformation();
    doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    doReturn(session).when(sessionManager).getCurrentSession();
    doReturn(canvasHandler).when(session).getCanvasHandler();
    when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
    when(canvasHandler.getGraphIndex()).thenReturn(index);
    when(index.get(anyString())).thenReturn(element);
    when(element.getContent()).thenReturn(mock(Definition.class));
    when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
    when(canvasCommandFactory.updatePropertyValue(any(Element.class), anyString(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(anyString());
}
Also used : ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Optional(java.util.Optional) Element(org.kie.workbench.common.stunner.core.graph.Element) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) UndefinedExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionEditorDefinition) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) UpdateElementPropertyCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) Before(org.junit.Before)

Example 18 with Element

use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.

the class AssignmentsEditorWidget method getProcessVariables.

protected String getProcessVariables() {
    Diagram diagram = canvasSessionManager.getCurrentSession().getCanvasHandler().getDiagram();
    Iterator<Element> it = diagram.getGraph().nodes().iterator();
    while (it.hasNext()) {
        Element element = it.next();
        if (element.getContent() instanceof View) {
            Object oDefinition = ((View) element.getContent()).getDefinition();
            if (oDefinition instanceof BPMNDiagramImpl) {
                BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
                ProcessVariables variables = bpmnDiagram.getProcessData().getProcessVariables();
                if (variables != null) {
                    return variables.getValue();
                }
                break;
            }
        }
    }
    return null;
}
Also used : ProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables) Element(org.kie.workbench.common.stunner.core.graph.Element) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Example 19 with Element

use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.

the class AbstractProcessFilteredNodeProviderBaseTest method testGetSelectorDataWithNoValues.

@Test
public void testGetSelectorDataWithNoValues() {
    @SuppressWarnings("unchecked") Iterable<Element> nodes = mock(Iterable.class);
    when(graph.nodes()).thenReturn(nodes);
    when(nodes.spliterator()).thenReturn(Spliterators.emptySpliterator());
    SelectorData selectorData = provider.getSelectorData(renderingContext);
    Map values = selectorData.getValues();
    assertTrue(values.isEmpty());
}
Also used : Element(org.kie.workbench.common.stunner.core.graph.Element) Map(java.util.Map) SelectorData(org.kie.workbench.common.forms.dynamic.model.config.SelectorData) Test(org.junit.Test)

Example 20 with Element

use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.

the class DefaultRouteFormProviderTest method testGetSelectorDataWithValues.

@Test
public void testGetSelectorDataWithValues() {
    List<Element> nodes = mockModes();
    when(graph.nodes()).thenReturn(nodes);
    // add the desired edges to the selected node.
    when(selectedNode.getOutEdges()).thenReturn(outEdges);
    SelectorData selectorData = provider.getSelectorData(renderingContext);
    Map values = selectorData.getValues();
    verifyValues(values);
}
Also used : Element(org.kie.workbench.common.stunner.core.graph.Element) Map(java.util.Map) SelectorData(org.kie.workbench.common.forms.dynamic.model.config.SelectorData) Test(org.junit.Test)

Aggregations

Element (org.kie.workbench.common.stunner.core.graph.Element)85 Test (org.junit.Test)55 View (org.kie.workbench.common.stunner.core.graph.content.view.View)34 Graph (org.kie.workbench.common.stunner.core.graph.Graph)27 FlowElement (org.eclipse.bpmn2.FlowElement)24 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)24 RootElement (org.eclipse.bpmn2.RootElement)24 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)24 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)14 Edge (org.kie.workbench.common.stunner.core.graph.Edge)12 Node (org.kie.workbench.common.stunner.core.graph.Node)11 Map (java.util.Map)7 Optional (java.util.Optional)6 Before (org.junit.Before)6 Collection (java.util.Collection)5 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)5 Shape (org.kie.workbench.common.stunner.core.client.shape.Shape)5 Matchers.anyString (org.mockito.Matchers.anyString)5 Logger (java.util.logging.Logger)4 BPMNDiagram (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram)4