Search in sources :

Example 66 with Node

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

the class CaseManagementCanvasHandlerTest method checkApplyElementMutationRenderableShapes.

@Test
@SuppressWarnings("unchecked")
public void checkApplyElementMutationRenderableShapes() {
    final ActivityShape shape = spy(makeShape());
    final Node<View<BPMNViewDefinition>, Edge> node = makeNode("uuid", shape);
    final MutationContext mutationContext = mock(MutationContext.class);
    doNothing().when(shape).applyPosition(eq(node), eq(mutationContext));
    doNothing().when(shape).applyProperties(eq(node), eq(mutationContext));
    doNothing().when(shape).applyTitle(anyString(), any(Node.class), eq(mutationContext));
    handler.applyElementMutation(shape, node, true, true, mutationContext);
    verify(shape, times(1)).applyPosition(eq(node), eq(mutationContext));
    verify(shape, times(1)).applyProperties(eq(node), eq(mutationContext));
    verify(canvas, times(1)).draw();
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) ActivityShape(org.kie.workbench.common.stunner.cm.client.shape.ActivityShape) PictureShapeView(org.kie.workbench.common.stunner.shapes.client.view.PictureShapeView) ActivityView(org.kie.workbench.common.stunner.cm.client.shape.view.ActivityView) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) MutationContext(org.kie.workbench.common.stunner.core.client.shape.MutationContext) Test(org.junit.Test)

Example 67 with Node

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

the class CaseManagementContainmentAcceptorControlImplTest method getAddEdgeCommand.

@Test
public void getAddEdgeCommand() {
    final Node parent = mock(Node.class);
    final Node child = mock(Node.class);
    control.getAddEdgeCommand(parent, child);
    verify(canvasCommandFactory, times(1)).setChildNode(eq(parent), eq(child));
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Test(org.junit.Test)

Example 68 with Node

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

the class CaseManagementContainmentAcceptorControlImplTest method getSetEdgeCommand.

@Test
public void getSetEdgeCommand() {
    final Node parent = mock(Node.class);
    final Node child = mock(Node.class);
    control.getSetEdgeCommand(parent, child, Optional.empty(), Optional.empty(), Optional.empty());
    verify(canvasCommandFactory, times(1)).setChildNode(eq(parent), eq(child), eq(Optional.empty()), eq(Optional.empty()), eq(Optional.empty()));
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Test(org.junit.Test)

Example 69 with Node

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

the class AbstractProcessFilteredNodeProvider method findElements.

protected Collection<Pair<Object, String>> findElements(final Predicate<Node> filter, final Function<Node, Pair<Object, String>> mapper) {
    final Diagram diagram = sessionManager.getCurrentSession().getCanvasHandler().getDiagram();
    @SuppressWarnings("unchecked") Iterable<Node> it = diagram.getGraph().nodes();
    return StreamSupport.stream(it.spliterator(), false).filter(filter).map(mapper).filter(pair -> pair != null).collect(Collectors.toSet());
}
Also used : SelectorData(org.kie.workbench.common.forms.dynamic.model.config.SelectorData) FormRenderingContext(org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext) Predicate(java.util.function.Predicate) Collection(java.util.Collection) SelectorDataProvider(org.kie.workbench.common.forms.dynamic.model.config.SelectorDataProvider) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) TreeMap(java.util.TreeMap) Map(java.util.Map) StreamSupport(java.util.stream.StreamSupport) Comparator(java.util.Comparator) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) Pair(org.uberfire.commons.data.Pair) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Node(org.kie.workbench.common.stunner.core.graph.Node) Node(org.kie.workbench.common.stunner.core.graph.Node) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Example 70 with Node

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

the class ProcessVariablesProvider method findElements.

@Override
protected Collection<Pair<Object, String>> findElements(Predicate<Node> filter, Function<Node, Pair<Object, String>> mapper) {
    Collection<Pair<Object, String>> result = new ArrayList<>();
    String elementUUID = sessionManager.getCurrentSession().getCanvasHandler().getDiagram().getMetadata().getCanvasRootUUID();
    Node node;
    if (elementUUID != null) {
        node = sessionManager.getCurrentSession().getCanvasHandler().getDiagram().getGraph().getNode(elementUUID);
        Object oDefinition = ((View) node.getContent()).getDefinition();
        if (oDefinition instanceof BPMNDiagram) {
            BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
            ProcessVariables processVars = bpmnDiagram.getProcessData().getProcessVariables();
            if (processVars.getValue().length() > 0) {
                List<String> list = Arrays.asList(processVars.getValue().split(","));
                list.forEach(s1 -> {
                    String value = s1.split(":")[0];
                    result.add(new Pair<>(value, value));
                });
            }
        }
    }
    return result;
}
Also used : ProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables) BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Pair(org.uberfire.commons.data.Pair)

Aggregations

Node (org.kie.workbench.common.stunner.core.graph.Node)153 Edge (org.kie.workbench.common.stunner.core.graph.Edge)85 View (org.kie.workbench.common.stunner.core.graph.content.view.View)59 Test (org.junit.Test)38 Graph (org.kie.workbench.common.stunner.core.graph.Graph)32 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)24 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)21 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)17 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)15 Element (org.kie.workbench.common.stunner.core.graph.Element)14 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)13 DefinitionSet (org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet)13 EdgeImpl (org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl)13 Matchers.anyString (org.mockito.Matchers.anyString)13 List (java.util.List)12 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)12 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)12 Before (org.junit.Before)11 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)11 Child (org.kie.workbench.common.stunner.core.graph.content.relationship.Child)11